⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.h

📁 uC/OS系统移植综合实验程序
💻 H
📖 第 1 页 / 共 3 页
字号:
 * \code
 *      switch (message) {
 *      case MSG_MOUSEMOVE:
 *          if (lParam & KS_CAPTURED) {
 *              // the mouse is captured by this window.
 *              ...
 *          }
 *          break;
 *      ...
 * \endcode
 *
 * \sa mouse_msgs
 */
#define KS_CAPTURED                     0x00000400
/**
 * \def KS_IMEPOST
 * \brief This status indicate that the key message is posted by the IME window.
 *
 * \sa key_msgs
 */
#define KS_IMEPOST                      0x00000200
/**
 * \def KS_CAPSLOCK
 * \brief This status indicate that the CapsLock key was locked when 
 * the key or mouse message posted to the window.
 *
 * You can test the status by AND'ed with lParam of the message, like below
 *
 * \code
 *      switch (message) {
 *      case MSG_KEYDOWN:
 *          if (lParam & KS_CAPSLOCK) {
 *              // the CapsLock key is locked.
 *              ...
 *          }
 *          break;
 *      ...
 * \endcode
 *
 * \sa key_msgs
 */
#define KS_CAPSLOCK                     0x00000100
/**
 * \def KS_NUMLOCK
 * \brief This status indicate that the NumLock key was locked when 
 * the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_NUMLOCK                      0x00000080
/**
 * \def KS_SCROLLLOCK
 * \brief This status indicate that the ScrollLock key was locked when
 * the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_SCROLLLOCK                   0x00000040
/**
 * \def KS_LEFTCTRL
 * \brief This status indicate that the left-Ctrl key was pressed when
 * the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_LEFTCTRL                     0x00000020
/**
 * \def KS_RIGHTCTRL
 * \brief This status indicate that the right-Ctrl key was pressed when
 * the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_RIGHTCTRL                    0x00000010
/**
 * \def KS_CTRL
 * \brief This status indicate that either the left-Ctrl key or the right-Ctrl key 
 * was pressed when the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_CTRL                         0x00000030
/**
 * \def KS_LEFTALT
 * \brief This status indicate that left-Alt key was pressed when
 * the key  or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_LEFTALT                      0x00000008
/**
 * \def KS_RIGHTALT
 * \brief This status indicate that right-Alt key was pressed when
 * the key  or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_RIGHTALT                     0x00000004
/**
 * \def KS_ALT
 * \brief This status indicate that either the left-Alt key or the right-Alt key 
 * was pressed when the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_ALT                          0x0000000C
/**
 * \def KS_LEFTSHIFT
 * \brief This status indicate that left-Shift key was pressed when
 * the key  or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_LEFTSHIFT                    0x00000002
/**
 * \def KS_RIGHTSHIFT
 * \brief This status indicate that right-Shift key was pressed when
 * the key  or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_RIGHTSHIFT                   0x00000001
/**
 * \def KS_SHIFT
 * \brief This status indicate that either the left-Shift key or the right-Shift key 
 * was pressed when the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_SHIFT                        0x00000003
/**
 * \def MASK_KS_SHIFTKEYS
 * \brief The mask of key status.
 */
#define MASK_KS_SHIFTKEYS               0x00000FFF

/**
 * \def KS_LEFTBUTTON
 * \brief This status indicate that left button was pressed when 
 * the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_LEFTBUTTON                   0x00001000
/**
 * \def KS_RIGHTBUTTON
 * \brief This status indicate that right button was pressed when 
 * the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_RIGHTBUTTON                  0x00002000
/**
 * \def KS_MIDDLBUTTON
 * \brief This status indicate that middle button was pressed when 
 * the key or mouse message posted to the window.
 *
 * \sa key_msgs
 */
#define KS_MIDDLBUTTON                  0x00004000
/**
 * \def MASK_KS_BUTTONS
 * \brief The mask of mouse button status.
 */
#define MASK_KS_BUTTONS                 0x0000F000

    /** @} end of key_defs */

    /**
     * \defgroup err_codes Error codes
     * @{
     */
#define ERR_OK                   0
#define ERR_INV_HWND            -1
#define ERR_QUEUE_FULL          -2

#define ERR_INVALID_HANDLE      -3
#define ERR_INVALID_HMENU       -4
#define ERR_INVALID_POS         -5
#define ERR_INVALID_ID          -6
#define ERR_RES_ALLOCATION      -7

#define ERR_CTRLCLASS_INVNAME   -8
#define ERR_CTRLCLASS_INVLEN    -9
#define ERR_CTRLCLASS_MEM       -10
#define ERR_CTRLCLASS_INUSE     -11

#define ERR_ALREADY_EXIST       -12
#define ERR_NO_MATCH            -13
#define ERR_BAD_OWNER           -14

#define ERR_IME_TOOMUCHIMEWND   -15
#define ERR_IME_NOSUCHIMEWND    -16
#define ERR_IME_NOIMEWND        -17

#define ERR_CONFIG_FILE         -18
#define ERR_FILE_IO             -19
#define ERR_GFX_ENGINE          -20
#define ERR_INPUT_ENGINE        -21
#define ERR_NO_ENGINE           -22

    /** @} end of err_codes */

    /**
     * \defgroup misc_macros Miscellaneous macros
     * @{
     */
/**
 * \def TABLESIZE(table)
 * \brief A macro returns the number of elements in a \a table.
 */
#define TABLESIZE(table)    (sizeof(table)/sizeof(table[0]))

/* MAX/MIN/ABS macors */
/**
 * \def MAX(x, y)
 * \brief A macro returns the maximum of \a x and \a y.
 */
#ifndef MAX
#define MAX(x, y)           ((x > y)?x:y)
#endif
/**
 * \def MIN(x, y)
 * \brief A macro returns the minimum of \a x and \a y.
 */
#ifndef MIN
#define MIN(x, y)           ((x < y)?x:y)
#endif
/**
 * \def ABS(x)
 * \brief A macro returns the absolute value of \a x.
 */
#ifndef ABS
#define ABS(x)              (((x)<0) ? -(x) : (x))
#endif

#ifndef __NOLINUX__
/* Common used definitions */
#ifndef PATH_MAX
//    #include <dirent.h>
#endif

#ifndef PATH_MAX
    #define PATH_MAX    128
#endif

#ifndef NAME_MAX
    #define NAME_MAX    64
#endif
/**
 * \def MAX_PATH
 * \brief The possible maximal length of a path name.
 * \note This definition is an alias of PATH_MAX
 */
#define MAX_PATH        PATH_MAX
/**
 * \def MAX_NAME
 * \brief The possible maximal length of a file name.
 * \note This definition is an alias of NAME_MAX
 */
#define MAX_NAME        NAME_MAX
#else
#define MAX_PATH        256
#define MAX_NAME        64
#endif

/**
 * \enum SBPolicyType
 * \brief Scroll bar display policies in scrolled window
 */
typedef enum
{
  /**
   * the scroll bar is always visible
   */
  SB_POLICY_ALWAYS,
  /**
   * the scroll bar is shown or hided automatically
   */
  SB_POLICY_AUTOMATIC,
  /** the scroll bar is never visbile
   */
  SB_POLICY_NEVER
} SBPolicyType;


    /** @} end of misc_macros */

    /** @} end of macros_types */

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __UCOSII__

/* use our own implementation of strdup */
#undef HAVE_STRDUP
#define strdup own_strdup

/* The entry of MiniGUI */
int minigui_entry (int argc, const char* argv[]);
int ucos2_posix_pthread_init (void);
int ucos2_malloc_init (void);

#endif

#ifndef HAVE_STRDUP
char *strdup(const char *s);
#endif

#ifndef HAVE_STRCASECMP
int strcasecmp(const char *s1, const char *s2);
#endif

#if 0
#include <sys/time.h>
struct timezone;
int gettimeofday(struct timeval *tv, struct timezone* tz);
#endif

#ifdef __cplusplus
};  /* end of extern "C" */
#endif

#ifdef _USE_OWN_MALLOC

#define USE_DL_PREFIX

#include "own_malloc.h"

/* wrappers for malloc functions */
#define calloc      dlcalloc
#define free        dlfree
#define malloc      dlmalloc
#define memalign    dlmemalign
#define realloc     dlrealloc
#define valloc      dlvalloc

#endif

/* Do not use the alloca of ARMCC */
#if defined(__CC_ARM)
#   undef HAVE_ALLOCA
#   undef HAVE_ALLOCA_H
#endif

#ifdef HAVE_ALLOCA_H
#   include <alloca.h>
#   define ALLOCATE_LOCAL(size)    alloca((int)(size))
#   define DEALLOCATE_LOCAL(ptr)   /* as nothing */
#else
#   define ALLOCATE_LOCAL(size)    malloc((int)(size))
#   define DEALLOCATE_LOCAL(ptr)   free(ptr)
#endif

#ifdef _USE_OWN_STDIO

#if defined (__UCOSII__) || defined (__VXWORKS__)
#   undef _PRINTF_FLOATING_POINT
#   undef _SCANF_FLOATING_POINT
#else
#   ifdef HAVE_MATH_H
#       define _PRINTF_FLOATING_POINT      1
#       define _SCANF_FLOATING_POINT       1
#   endif
#endif

#undef _I18N_MB_REQUIRED

#if defined(__VXWORKS__)
  #define _USE_OWN_SNPRINTF
  #define _USE_OWN_VSNPRINTF
  #define _USE_OWN_VFNPRINTF
#else
  #define _USE_OWN_PRINTF
  #define _USE_OWN_FPRINTF
  #define _USE_OWN_SPRINTF
  #define _USE_FNPRINTF
  #define _USE_OWN_SNPRINTF
  #define _USE_OWN_VPRINTF
  #define _USE_OWN_VFPRINTF
  #define _USE_OWN_VSPRINTF
  #define _USE_OWN_VFNPRINTF
  #define _USE_OWN_VSNPRINTF
  #define _USE_OWN_SCANF
  #define _USE_OWN_FSCANF
  #define _USE_OWN_SSCANF
  #define _USE_OWN_VSCANF
  #define _USE_OWN_VFSCANF
  #define _USE_OWN_VSSCANF
#endif

#include "own_stdio.h"

/* wrappers for stdio functions */
#ifdef _USE_OWN_PRINTF
  #define printf      own_printf
#endif

#ifdef _USE_OWN_FPRINTF
  #define fprintf     own_fprintf
#endif

#ifdef _USE_OWN_SPRINTF
  #define sprintf     own_sprintf
#endif

#ifdef _USE_FNPRINTF
  #define fnprintf    own_fnprintf
#endif

#ifdef _USE_OWN_SNPRINTF
  #define snprintf    own_snprintf
#endif

#ifdef _USE_OWN_VPRINTF
  #define vprintf     own_vprintf
#endif

#ifdef _USE_OWN_VFPRINTF
  #define vfprintf    own_vfprintf
#endif

#ifdef _USE_OWN_VSPRINTF
  #define vsprintf    own_vsprintf
#endif

#ifdef _USE_OWN_VFNPRINTF
  #define vfnprintf   own_vfnprintf
#endif

#ifdef _USE_OWN_VSNPRINTF
  #define vsnprintf   own_vsnprintf
#endif

#ifdef _USE_OWN_SCANF
  #define scanf       own_scanf
#endif

#ifdef _USE_OWN_FSCANF
  #define fscanf      own_fscanf
#endif

#ifdef _USE_OWN_SSCANF
  #define sscanf      own_sscanf
#endif

#ifdef _USE_OWN_VSCANF
  #define vscanf      own_vscanf
#endif

#ifdef _USE_OWN_VFSCANF
  #define vfscanf     own_vfscanf
#endif

#ifdef _USE_OWN_VSSCANF
  #define vsscanf     own_vsscanf
#endif

#endif /* _USE_OWN_STDIO */

#ifdef _DEBUG_MSG
#   define _MG_PRINTF(fmt...) fprintf (stderr, fmt)
#else
#   define _MG_PRINTF(fmt) 
#endif

#endif /* _MGUI_COMMON_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -