📄 defs.h
字号:
// Printf-like attribute definitions to obtain warnings with GNU C/C++
#if defined(__GNUC__) && !wxUSE_UNICODE
# ifndef ATTRIBUTE_PRINTF
# define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
# define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
# define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
# define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
# define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
# define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
# endif /* ATTRIBUTE_PRINTF */
#else
# ifndef ATTRIBUTE_PRINTF
# define ATTRIBUTE_PRINTF
# define ATTRIBUTE_PRINTF_1
# define ATTRIBUTE_PRINTF_2
# define ATTRIBUTE_PRINTF_3
# define ATTRIBUTE_PRINTF_4
# define ATTRIBUTE_PRINTF_5
# endif /* ATTRIBUTE_PRINTF */
#endif
// everybody gets the assert and other debug macros
#ifdef __cplusplus
#include "wx/debug.h"
#endif
// NULL declaration: it must be defined as 0 for C++ programs (in particular,
// it must not be defined as "(void *)0" which is standard for C but completely
// breaks C++ code)
#include <stddef.h>
// Macro to cut down on compiler warnings.
#if REMOVE_UNUSED_ARG
#define WXUNUSED(identifier) /* identifier */
#else // stupid, broken compiler
#define WXUNUSED(identifier) identifier
#endif
// some arguments are only used in debug mode, but unused in release one
#ifdef __WXDEBUG__
#define WXUNUSED_UNLESS_DEBUG(param) param
#else
#define WXUNUSED_UNLESS_DEBUG(param) WXUNUSED(param)
#endif
// delete pointer if it is not NULL and NULL it afterwards
// (checking that it's !NULL before passing it to delete is just a
// a question of style, because delete will do it itself anyhow, but it might
// be considered as an error by some overzealous debugging implementations of
// the library, so we do it ourselves)
#define wxDELETE(p) if ( (p) != NULL ) { delete p; p = NULL; }
// delete an array and NULL it (see comments above)
#define wxDELETEA(p) if ( (p) ) { delete [] (p); p = NULL; }
// size of statically declared array
#define WXSIZEOF(array) (sizeof(array)/sizeof(array[0]))
// ----------------------------------------------------------------------------
// compiler specific settings
// ----------------------------------------------------------------------------
// to allow compiling with warning level 4 under Microsoft Visual C++ some
// warnings just must be disabled
#ifdef __VISUALC__
#pragma warning(disable: 4514) // unreferenced inline func has been removed
/*
you might be tempted to disable this one also: triggered by CHECK and FAIL
macros in debug.h, but it's, overall, a rather useful one, so I leave it and
will try to find some way to disable this warning just for CHECK/FAIL. Anyone?
*/
#pragma warning(disable: 4127) // conditional expression is constant
#endif // VC++
#if defined(__MWERKS__)
#undef try
#undef except
#undef finally
#define except(x) catch(...)
#endif // Metrowerks
// where should i put this? we need to make sure of this as it breaks
// the <iostream> code.
#if !wxUSE_IOSTREAMH && defined(__WXDEBUG__)
# ifndef __MWERKS__
// #undef __WXDEBUG__
# ifdef wxUSE_DEBUG_NEW_ALWAYS
# undef wxUSE_DEBUG_NEW_ALWAYS
# define wxUSE_DEBUG_NEW_ALWAYS 0
# endif
# endif
#endif
// Callback function type definition
#ifdef __cplusplus
typedef void (*wxFunction) (wxObject&, wxEvent&);
#endif
// ----------------------------------------------------------------------------
// OS mnemonics -- Identify the running OS (useful for Windows)
// ----------------------------------------------------------------------------
// Not all platforms are currently available or supported
enum
{
wxUNKNOWN_PLATFORM,
wxCURSES, // Text-only CURSES
wxXVIEW_X, // Sun's XView OpenLOOK toolkit
wxMOTIF_X, // OSF Motif 1.x.x
wxCOSE_X, // OSF Common Desktop Environment
wxNEXTSTEP, // NeXTStep
wxMAC, // Apple Mac OS 8/9/X with Mac paths
wxMAC_DARWIN, // Apple Mac OS X with Unix paths
wxBEOS, // BeOS
wxGTK, // GTK on X
wxGTK_WIN32, // GTK on Win32
wxGTK_OS2, // GTK on OS/2
wxGTK_BEOS, // GTK on BeOS
wxGEOS, // GEOS
wxOS2_PM, // OS/2 Workplace
wxWINDOWS, // Windows or WfW
wxMICROWINDOWS, // MicroWindows
wxPENWINDOWS, // Windows for Pen Computing
wxWINDOWS_NT, // Windows NT
wxWIN32S, // Windows 32S API
wxWIN95, // Windows 95
wxWIN386, // Watcom 32-bit supervisor modus
wxMGL_UNIX, // MGL with direct hardware access
wxMGL_X, // MGL on X
wxMGL_WIN32, // MGL on Win32
wxMGL_OS2, // MGL on OS/2
wxMGL_DOS, // MGL on MS-DOS
wxWINDOWS_OS2, // Native OS/2 PM
wxUNIX, // wxBase under Unix
wxX11 // Plain X11 and Universal widgets
};
// ----------------------------------------------------------------------------
// standard wxWindows types
// ----------------------------------------------------------------------------
// the type for screen and DC coordinates
#if wxUSE_COMPATIBLE_COORD_TYPES
// to ensure compatibility with 2.0, we must use long
#define wxCoord long
#else // !wxUSE_COMPATIBLE_COORD_TYPES
#ifdef __WIN16__
// under Win16, int is too small, so use long to allow for bigger
// virtual canvases
typedef long wxCoord;
#else // !Win16
// other platforms we support have at least 32bit int - quite enough
typedef int wxCoord;
#endif // Win16/!Win16
#endif // wxUSE_COMPATIBLE_COORD_TYPES/!wxUSE_COMPATIBLE_COORD_TYPES
// fixed length types
#define wxInt8 char signed
#define wxUint8 char unsigned
#ifdef __WINDOWS__
#if defined(__WIN16__)
#define wxInt16 int signed
#define wxUint16 int unsigned
#define wxInt32 long signed
#define wxUint32 long unsigned
#elif defined(__WIN32__)
#define wxInt16 short signed
#define wxUint16 short unsigned
#define wxInt32 int signed
#define wxUint32 int unsigned
#else
// Win64 will have different type sizes
#error "Please define a 32 bit type"
#endif
#else // !Windows
// SIZEOF_XXX are defined by configure
#if defined(SIZEOF_INT) && (SIZEOF_INT == 4)
#define wxInt16 short signed
#define wxUint16 short unsigned
#define wxInt32 int signed
#define wxUint32 int unsigned
#elif defined(SIZEOF_INT) && (SIZEOF_INT == 2)
#define wxInt16 int signed
#define wxUint16 int unsigned
#define wxInt32 long signed
#define wxUint32 long unsigned
#else
// assume sizeof(int) == 4 - what else can we do
wxCOMPILE_TIME_ASSERT( sizeof(int) == 4, IntMustBeExactly4Bytes);
#define wxInt16 short signed
#define wxUint16 short unsigned
#define wxInt32 int signed
#define wxUint32 int unsigned
#endif
#endif // Win/!Win
#if defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
#define wxInt64 long signed
#define wxUint64 long unsigned
#elif defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
#define wxInt64 long long signed
#define wxUint64 long long unsigned
#else // FIXME: what else can we do here aside from implementing wxULongLong
#define wxInt64 wxLongLong
#define wxUint64 wxULongLong
#endif
#define wxByte wxUint8
#define wxWord wxUint16
// base floating point types
// wxFloat32 : 32 bit IEEE float ( 1 sign , 8 exponent bits , 23 fraction bits
// wxFloat64 : 64 bit IEEE float ( 1 sign , 11 exponent bits , 52 fraction bits
// wxDouble : native fastest representation that has at least wxFloat64
// precision, so use the IEEE types for storage , and this for calculations
typedef float wxFloat32 ;
#if defined( __WXMAC__ ) && defined (__MWERKS__)
typedef short double wxFloat64;
#else
typedef double wxFloat64;
#endif
#if defined( __WXMAC__ ) && !defined( __POWERPC__ )
typedef long double wxDouble;
#else
typedef double wxDouble ;
#endif
// ----------------------------------------------------------------------------
// byte ordering related definition and macros
// ----------------------------------------------------------------------------
// byte sex
#define wxBIG_ENDIAN 4321
#define wxLITTLE_ENDIAN 1234
#define wxPDP_ENDIAN 3412
#ifdef WORDS_BIGENDIAN
#define wxBYTE_ORDER wxBIG_ENDIAN
#else
#define wxBYTE_ORDER wxLITTLE_ENDIAN
#endif
// byte swapping
#if defined (__MWERKS__) && ( (__MWERKS__ < 0x0900) || macintosh )
// assembler versions for these
#ifdef __POWERPC__
inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i )
{return (__lhbrx( &i , 0 ) ) ;}
inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i )
{return (__lhbrx( &i , 0 ) ) ;}
inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i )
{return (__lwbrx( &i , 0 ) ) ;}
inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i )
{return (__lwbrx( &i , 0 ) ) ;}
#else
#pragma parameter __D0 wxUINT16_SWAP_ALWAYS(__D0)
pascal wxUint16 wxUINT16_SWAP_ALWAYS(wxUint16 value)
= { 0xE158 };
#pragma parameter __D0 wxINT16_SWAP_ALWAYS(__D0)
pascal wxInt16 wxINT16_SWAP_ALWAYS(wxInt16 value)
= { 0xE158 };
#pragma parameter __D0 wxUINT32_SWAP_ALWAYS (__D0)
pascal wxUint32 wxUINT32_SWAP_ALWAYS(wxUint32 value)
= { 0xE158, 0x4840, 0xE158 };
#pragma parameter __D0 wxINT32_SWAP_ALWAYS (__D0)
pascal wxInt32 wxINT32_SWAP_ALWAYS(wxInt32 value)
= { 0xE158, 0x4840, 0xE158 };
#endif
#else // !MWERKS
#define wxUINT16_SWAP_ALWAYS(val) \
((wxUint16) ( \
(((wxUint16) (val) & (wxUint16) 0x00ffU) << 8) | \
(((wxUint16) (val) & (wxUint16) 0xff00U) >> 8)))
#define wxINT16_SWAP_ALWAYS(val) \
((wxInt16) ( \
(((wxUint16) (val) & (wxUint16) 0x00ffU) << 8) | \
(((wxUint16) (val) & (wxUint16) 0xff00U) >> 8)))
#define wxUINT32_SWAP_ALWAYS(val) \
((wxUint32) ( \
(((wxUint32) (val) & (wxUint32) 0x000000ffU) << 24) | \
(((wxUint32) (val) & (wxUint32) 0x0000ff00U) << 8) | \
(((wxUint32) (val) & (wxUint32) 0x00ff0000U) >> 8) | \
(((wxUint32) (val) & (wxUint32) 0xff000000U) >> 24)))
#define wxINT32_SWAP_ALWAYS(val) \
((wxInt32) ( \
(((wxUint32) (val) & (wxUint32) 0x000000ffU) << 24) | \
(((wxUint32) (val) & (wxUint32) 0x0000ff00U) << 8) | \
(((wxUint32) (val) & (wxUint32) 0x00ff0000U) >> 8) | \
(((wxUint32) (val) & (wxUint32) 0xff000000U) >> 24)))
#endif
// machine specific byte swapping
#if defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
#define wxUINT64_SWAP_ALWAYS(val) \
((wxUint64) ( \
(((wxUint64) (val) & (wxUint64) 0x00000000000000ffUL) << 56) | \
(((wxUint64) (val) & (wxUint64) 0x000000000000ff00UL) << 40) | \
(((wxUint64) (val) & (wxUint64) 0x0000000000ff0000UL) << 24) | \
(((wxUint64) (val) & (wxUint64) 0x00000000ff000000UL) << 8) | \
(((wxUint64) (val) & (wxUint64) 0x000000ff00000000UL) >> 8) | \
(((wxUint64) (val) & (wxUint64) 0x0000ff0000000000UL) >> 24) | \
(((wxUint64) (val) & (wxUint64) 0x00ff000000000000UL) >> 40) | \
(((wxUint64) (val) & (wxUint64) 0xff00000000000000UL) >> 56)))
#define wxINT64_SWAP_ALWAYS(val) \
((wxInt64) ( \
(((wxUint64) (val) & (wxUint64) 0x00000000000000ffUL) << 56) | \
(((wxUint64) (val) & (wxUint64) 0x000000000000ff00UL) << 40) | \
(((wxUint64) (val) & (wxUint64) 0x0000000000ff0000UL) << 24) | \
(((wxUint64) (val) & (wxUint64) 0x00000000ff000000UL) << 8) | \
(((wxUint64) (val) & (wxUint64) 0x000000ff00000000UL) >> 8) | \
(((wxUint64) (val) & (wxUint64) 0x0000ff0000000000UL) >> 24) | \
(((wxUint64) (val) & (wxUint64) 0x00ff000000000000UL) >> 40) | \
(((wxUint64) (val) & (wxUint64) 0xff00000000000000UL) >> 56)))
#elif defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
#define wxUINT64_SWAP_ALWAYS(val) \
((wxUint64) ( \
(((wxUint64) (val) & (wxUint64) 0x00000000000000ffULL) << 56) | \
(((wxUint64) (val) & (wxUint64) 0x000000000000ff00ULL) << 40) | \
(((wxUint64) (val) & (wxUint64) 0x0000000000ff0000ULL) << 24) | \
(((wxUint64) (val) & (wxUint64) 0x00000000ff000000ULL) << 8) | \
(((wxUint64) (val) & (wxUint64) 0x000000ff00000000ULL) >> 8) | \
(((wxUint64) (val) & (wxUint64) 0x0000ff0000000000ULL) >> 24) | \
(((wxUint64) (val) & (wxUint64) 0x00ff000000000000ULL) >> 40) | \
(((wxUint64) (val) & (wxUint64) 0xff00000000000000ULL) >> 56)))
#define wxINT64_SWAP_ALWAYS(val) \
((wxInt64) ( \
(((wxUint64) (val) & (wxUint64) 0x00000000000000ffULL) << 56) | \
(((wxUint64) (val) & (wxUint64) 0x000000000000ff00ULL) << 40) | \
(((wxUint64) (val) & (wxUint64) 0x0000000000ff0000ULL) << 24) | \
(((wxUint64) (val) & (wxUint64) 0x00000000ff000000ULL) << 8) | \
(((wxUint64) (val) & (wxUint64) 0x000000ff00000000ULL) >> 8) | \
(((wxUint64) (val) & (wxUint64) 0x0000ff0000000000ULL) >> 24) | \
(((wxUint64) (val) & (wxUint64) 0x00ff000000000000ULL) >> 40) | \
(((wxUint64) (val) & (wxUint64) 0xff00000000000000ULL) >> 56)))
#else
#define wxUINT64_SWAP_ALWAYS(val) \
((wxUint64) ( \
((wxULongLong(val) & wxULongLong(0L, 0x000000ffU)) << 56) | \
((wxULongLong(val) & wxULongLong(0L, 0x0000ff00U)) << 40) | \
((wxULongLong(val) & wxULongLong(0L, 0x00ff0000U)) << 24) | \
((wxULongLong(val) & wxULongLong(0L, 0xff000000U)) << 8) | \
((wxULongLong(val) & wxULongLong(0x000000ffL, 0U)) >> 8) | \
((wxULongLong(val) & wxULongLong(0x0000ff00L, 0U)) >> 24) | \
((wxULongLong(val) & wxULongLong(0x00ff0000L, 0U)) >> 40) | \
((wxULongLong(val) & wxULongLong(0xff000000L, 0U)) >> 56)))
#define wxINT64_SWAP_ALWAYS(val) \
((wxInt64) ( \
((wxLongLong(val) & wxLongLong(0L, 0x000000ffU)) << 56) | \
((wxLongLong(val) & wxLongLong(0L, 0x0000ff00U)) << 40) | \
((wxLongLong(val) & wxLongLong(0L, 0x00ff0000U)) << 24) | \
((wxLongLong(val) & wxLongLong(0L, 0xff000000U)) << 8) | \
((wxLongLong(val) & wxLongLong(0x000000ffL, 0U)) >> 8) | \
((wxLongLong(val) & wxLongLong(0x0000ff00L, 0U)) >> 24) | \
((wxLongLong(val) & wxLongLong(0x00ff0000L, 0U)) >> 40) | \
((wxLongLong(val) & wxLongLong(0xff000000L, 0U)) >> 56)))
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -