?? common.h
字號:
/** * \file common.h * \author Wei Yongming <ymwei@minigui.org> * \date 2002/01/06 * * This file includes macro definitions and typedefs that commonly used * by MiniGUI. * \verbatim Copyright (C) 1998-2002 Wei Yongming. Copyright (C) 2002-2003 Feynman Software. This file is part of MiniGUI, a lightweight Graphics User Interface support library for real-time embedded Linux. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \endverbatim *//* * $Id: common.h,v 1.49 2004/02/25 02:34:49 weiym Exp $ * * MiniGUI for Linux, uClinux, eCos, and uC/OS-II version 1.5.x * Copyright (C) 1998-2002 Wei Yongming. * Copyright (C) 2002-2004 Feynman Software. * * Some data types and byte order macros come from * LGPL'ed SDL by (Sam Lantinga, slouken@devolution.com). * Copyright (C) 1997-2001 Sam Lantinga * * Fix point math routines come from Allegro * By Shawn Hargreaves and others. */#ifndef _MGUI_COMMON_H #define _MGUI_COMMON_H #ifdef __MINIGUI_LIB__ #include "../config.h"#else #include "config.h"#endif /** * \defgroup macros_types Macros and data types commonly used * @{ */ /** * \defgroup version_info Version information * @{ *//** * \def _VERSION_CODE(major, minor, micro) * \brief A macro that returns the version code from \a major, \a minor * and \a micro version number. * * MiniGUI uses this macro to evaluate the version code of current MiniGUI * library installed in your system, and define it to _MINIGUI_VERSION_CODE. * * \sa _MINIGUI_VERSION_CODE */#define _VERSION_CODE(major, minor, micro) (((major)<<16) | ((minor)<<8) | (micro))/** * \def _MINIGUI_VERSION_CODE * \brief Version code of MiniGUI. * * \sa _VERSION_CODE */#define _MINIGUI_VERSION_CODE \ ((MINIGUI_MAJOR_VERSION << 16) | (MINIGUI_MINOR_VERSION << 8) | MINIGUI_MICRO_VERSION) /** @} end of version_info */ /** * \defgroup basic_types Basic data types * @{ *//** * \var typedef unsigned char Uint8 * \brief A type definition for an 8-bit unsigned character. */typedef unsigned char Uint8;/** * \var typedef signed char Sint8 * \brief A type definition for an 8-bit signed character. */typedef signed char Sint8;/** * \var typedef unsigned short Uint16 * \brief A type definition for a 16-bit unsigned integer. */typedef unsigned short Uint16;/** * \var typedef signed short Sint16 * \brief A type definition for a 16-bit signed integer. */typedef signed short Sint16;/** * \var typedef unsigned int Uint32 * \brief A type definition for a 32-bit unsigned integer. */typedef unsigned int Uint32;/** * \var typedef signed int Sint32 * \brief A type definition for a 32-bit signed integer. */typedef signed int Sint32;/* Figure out how to support 64-bit datatypes */#if !defined(__STRICT_ANSI__)#if defined(__GNUC__)#define MGUI_HAS_64BIT_TYPE long long#endif#if defined(__CC_ARM)#define MGUI_HAS_64BIT_TYPE long long#endif#endif /* !__STRICT_ANSI__ *//* The 64-bit datatype isn't supported on all platforms */#ifdef MGUI_HAS_64BIT_TYPE/** * \var typedef unsigned long long Uint64 * \brief A type definition for a 64-bit unsigned integer. * * \warning Only available under GNU C. */typedef unsigned MGUI_HAS_64BIT_TYPE Uint64;/** * \var typedef signed long long Sint64 * \brief A type definition for a 64-bit signed integer. * * \warning Only available under GNU C. */typedef signed MGUI_HAS_64BIT_TYPE Sint64;#else/* This is really just a hack to prevent the compiler from complaining */typedef struct { Uint32 hi; Uint32 lo;} Uint64, Sint64;#endif/* Make sure the types really have the right sizes */#define MGUI_COMPILE_TIME_ASSERT(name, x) \ typedef int MGUI_dummy_ ## name[(x) * 2 - 1]MGUI_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);MGUI_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);MGUI_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);MGUI_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);MGUI_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);MGUI_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);MGUI_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);MGUI_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);#undef MGUI_COMPILE_TIME_ASSERT /** @} end of basic_types */ /** * \defgroup endian_info Endianness information * @{ *//** * \def MGUI_LIL_ENDIAN * \brief Little endianness. */#define MGUI_LIL_ENDIAN 1234/** * \def MGUI_BIG_ENDIAN * \brief Big endianness. */#define MGUI_BIG_ENDIAN 4321/* Pardon the mess, I'm trying to determine the endianness of this host. * I'm doing it by preprocessor defines rather than some sort of configure * script so that application code can use this too. The "right" way would * be to dynamically generate this file on install, but that's a lot of work. *//** * \def MGUI_BYTEORDER * \brief The byte order (endianness) of the target system. * * This macro will be either defined to MGUI_LIL_ENDIAN or MGUI_BIG_ENDIAN. * You can use the code like below * * \code * #if MGUI_BYTEORDER == MGUI_LIL_ENDIAN * ... // code for little endian system. * #else * ... // code for big endian system. * #endif * \endcode * * to write endianness independent code. */#if defined(__i386__) || defined(__ia64__) || \ (defined(__alpha__) || defined(__alpha)) || \ defined(__arm__) || \ (defined(__CC_ARM) && !defined(__BIG_ENDIAN)) || \ (defined(__mips__) && defined(__MIPSEL__)) || \ defined(__LITTLE_ENDIAN__)#define MGUI_BYTEORDER MGUI_LIL_ENDIAN#else#define MGUI_BYTEORDER MGUI_BIG_ENDIAN#endif /** @} end of endian_info */ /** * \defgroup simple_types Simple and common types and macros * @{ *//** * \var typedef int BOOL * \brief A type definition for boolean value. */typedef int BOOL;/** * \def FALSE * \brief FALSE value, defined as 0 by MiniGUI. */#ifndef FALSE #define FALSE 0#endif/** * \def TRUE * \brief TRUE value, defined as 1 by MiniGUI. */#ifndef TRUE #define TRUE 1#endif/** * \def NULL * \brief A value indicates null pointer. */#ifndef NULL#define NULL ((void *)0)#endif#define VOID void#define GUIAPI /** @} end of simple_types */ /** * \defgroup handles MiniGUI handles * @{ *//** * \var typedef unsigned int GHANDLE * \brief General handle. */typedef unsigned int GHANDLE;/** * \var typedef unsigned int HWND * \brief Handle to main window or control. */typedef unsigned int HWND;/** * \var typedef unsigned int HDC * \brief Handle to device context. */typedef unsigned int HDC;/** * \var typedef unsigned int HCURSOR * \brief Handle to cursor. */typedef unsigned int HCURSOR;/** * \var typedef unsigned int HICON * \brief Handle to icon. */typedef unsigned int HICON;/** * \var typedef unsigned int HMENU * \brief Handle to menu. */typedef unsigned int HMENU;/** * \var typedef unsigned int HACCEL * \brief Handle to accelarator. */typedef unsigned int HACCEL;/** * \var typedef unsigned int HDLG * \brief Handle to dialog box, same as HWND. */typedef unsigned int HDLG;/** * \var typedef unsigned int HHOOK * \brief Handle to keyboard or mouse event hook. */typedef unsigned int HHOOK; /** @} end of handles */ /** * \defgroup win32_types Win32-like data types and macros * @{ *//** * \var typedef unsigned char BYTE * \brief A type definition for unsigned character (byte). */typedef unsigned char BYTE;/** * \var typedef signed char BYTE * \brief A type definition for signed character. */typedef signed char SBYTE;/** * \var typedef unsigned short WORD * \brief A type definition for unsigned short integer (word). */typedef unsigned short WORD;/** * \var typedef signed short SWORD * \brief A type definition for signed short integer. */typedef signed short SWORD;/** * \var typedef unsigned long DWORD * \brief A type definition for unsigned long integer (double word). */typedef unsigned long DWORD;/** * \var typedef signed long SDWORD * \brief A type definition for signed long integer. */typedef signed long SDWORD;/** * \var typedef unsigned int UINT * \brief A type definition for unsigned integer. */typedef unsigned int UINT;/** * \var typedef long LONG * \brief A type definition for long integer. */typedef long LONG;/** * \var typedef UINT WPARAM * \brief A type definition for the first message paramter. */typedef UINT WPARAM;/** * \var typedef DWORD WPARAM * \brief A type definition for the second message paramter. */typedef DWORD LPARAM;/** * \def LOBYTE(w) * \brief Returns the low byte of the word \a w. * * \sa MAKEWORD */#define LOBYTE(w) ((BYTE)(w))/** * \def HIBYTE(w) * \brief Returns the high byte of the word \a w. * * \sa MAKEWORD */#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))/** * \def MAKEWORD(low, high) * \brief Makes a word from \a low byte and \a high byte. */#define MAKEWORD(low, high) ((WORD)(((BYTE)(low)) | (((WORD)((BYTE)(high))) << 8)))/** * \def LOWORD(l) * \brief Returns the low word of the double word \a l * * \sa MAKELONG */#define LOWORD(l) ((WORD)(DWORD)(l))/** * \def HIWORD(l) * \brief Returns the high word of the double word \a l * * \sa MAKELONG */#define HIWORD(l) ((WORD)((((DWORD)(l)) >> 16) & 0xFFFF))/** * \def LOSWORD(l) * \brief Returns the low signed word of the double word \a l * * \sa MAKELONG */#define LOSWORD(l) ((SWORD)(DWORD)(l))/** * \def HISWORD(l) * \brief Returns the high signed word of the double word \a l * * \sa MAKELONG */#define HISWORD(l) ((SWORD)((((DWORD)(l)) >> 16) & 0xFFFF))/**
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -