📄 defs.h
字号:
/////////////////////////////////////////////////////////////////////////////
// Name: defs.h
// Purpose: Declarations/definitions common to all wx source files
// Author: Julian Smart and others
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: defs.h,v 1.1 2005/03/16 06:48:54 kehc Exp $
// Copyright: (c)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DEFS_H_
#define _WX_DEFS_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "defs.h"
#endif
// ----------------------------------------------------------------------------
// compiler and OS identification
// ----------------------------------------------------------------------------
#include "wx/platform.h"
// Make sure the environment is set correctly
#if defined(__WXMSW__) && defined(__X__)
#error "Target can't be both X and Windows"
#elif !defined(__WXMOTIF__) && !defined(__WXMSW__) && !defined(__WXGTK__) && \
!defined(__WXPM__) && !defined(__WXMAC__) && !defined(__X__) && \
!defined(__WXMGL__) && !defined(__WXX11__) && wxUSE_GUI
#ifdef __UNIX__
#error "No Target! You should use wx-config program for compilation flags!"
#else // !Unix
#error "No Target! You should use supplied makefiles for compilation!"
#endif // Unix/!Unix
#endif
// include the feature test macros
#include "wx/features.h"
// suppress some Visual C++ warnings
#ifdef __VISUALC__
# pragma warning(disable:4201) // nonstandard extension used: nameless struct/union
# pragma warning(disable:4244) // conversion from double to float
# pragma warning(disable:4100) // unreferenced formal parameter
# pragma warning(disable:4511) // copy ctor couldn't be generated
# pragma warning(disable:4512) // operator=() couldn't be generated
# pragma warning(disable:4699) // using precompiled header
# pragma warning(disable:4134) // conversion between pointers to members of same class
# pragma warning(disable:4710) // function not inlined
#ifndef WIN32
# pragma warning(disable:4135) // conversion between different integral types
# pragma warning(disable:4769) // assignment of near pointer to long integer
// This one is really annoying, since it occurs for each cast to (HANDLE)...
# pragma warning(disable:4305) // truncation of long to near ptr
#endif
#endif // __VISUALC__
// suppress some Watcom C++ warnings
#ifdef __WATCOMC__
# pragma warning 849 9 // Disable 'virtual function hidden'
# pragma warning 549 9 // Disable 'operand contains compiler generated information'
#endif // __VISUALC__
// suppress some Salford C++ warnings
#ifdef __SALFORDC__
# pragma suppress 353 // Possible nested comments
# pragma suppress 593 // Define not used
# pragma suppress 61 // enum has no name (doesn't suppress!)
# pragma suppress 106 // unnamed, unused parameter
# pragma suppress 571 // Virtual function hiding
#endif // __SALFORDC__
// ----------------------------------------------------------------------------
// wxWindows version and compatibility defines
// ----------------------------------------------------------------------------
#include "wx/version.h"
// possibility to build non GUI apps is new, so don't burden ourselves with
// compatibility code
#if !wxUSE_GUI
#undef WXWIN_COMPATIBILITY_2
#undef WXWIN_COMPATIBILITY_2_2
#define WXWIN_COMPATIBILITY_2 0
#define WXWIN_COMPATIBILITY_2_2 0
#endif // !GUI
// ============================================================================
// non portable C++ features
// ============================================================================
// ----------------------------------------------------------------------------
// compiler defects workarounds
// ----------------------------------------------------------------------------
#if defined(__VISUALC__) && !defined(WIN32)
// VC1.5 does not have LPTSTR type
#define LPTSTR LPSTR
#define LPCTSTR LPCSTR
#elif defined(__BORLANDC__) && !defined(__WIN32__)
#ifndef LPTSTR
#define LPTSTR LPSTR
#endif
#ifndef LPCTSTR
#define LPCTSTR LPSTR
#endif
#endif
/*
Digital Unix C++ compiler only defines this symbol for .cxx and .hxx files,
so define it ourselves (newer versions do it for all files, though, and
don't allow it to be redefined)
*/
#if defined(__DECCXX) && !defined(__VMS) && !defined(__cplusplus)
#define __cplusplus
#endif /* __DECCXX */
// Resolves linking problems under HP-UX when compiling with gcc/g++
#if defined(__HPUX__) && defined(__GNUG__)
#define va_list __gnuc_va_list
#endif // HP-UX
// ----------------------------------------------------------------------------
// check for native bool type and TRUE/FALSE constants
// ----------------------------------------------------------------------------
// Add more tests here for Windows compilers that already define bool
// (under Unix, configure tests for this)
#ifndef HAVE_BOOL
#if defined( __MWERKS__ )
#if (__MWERKS__ >= 0x1000) && __option(bool)
#define HAVE_BOOL
#endif
#elif defined(__APPLE__) && defined(__APPLE_CC__)
// Apple bundled gcc supports bool
#define HAVE_BOOL
#elif defined(__VISUALC__) && (__VISUALC__ == 1020)
// in VC++ 4.2 the bool keyword is reserved (hence can't be typedefed)
// but not implemented, so we must #define it
#define bool unsigned int
#elif defined(__VISUALC__) && (__VISUALC__ == 1010)
// For VisualC++ 4.1, we need to define
// bool as something between 4.0 & 5.0...
typedef unsigned int wxbool;
#define bool wxbool
#define HAVE_BOOL
#elif defined(__VISUALC__) && (__VISUALC__ > 1020)
// VC++ supports bool since 4.2
#define HAVE_BOOL
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x500)
// Borland 5.0+ supports bool
#define HAVE_BOOL
#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
// Watcom 11+ supports bool
#define HAVE_BOOL
#elif defined(__DIGITALMARS__)
// DigitalMars supports bool
#define HAVE_BOOL
#elif defined(__GNUWIN32__)
// Cygwin supports bool
#define HAVE_BOOL
#elif defined(__VISAGECPP__)
#if __IBMCPP__ < 400
typedef unsigned long bool;
#define true ((bool)1)
#define false ((bool)0)
#endif
#define HAVE_BOOL
#endif // compilers
#endif // HAVE_BOOL
#if !defined(HAVE_BOOL) && !defined(bool) && !defined(VMS)
// NB: of course, this doesn't replace the standard type, because, for
// example, overloading based on bool/int parameter doesn't work and
// so should be avoided in portable programs
typedef unsigned int bool;
#endif // bool
#ifdef __cplusplus
// define boolean constants: don't use true/false here as not all compilers
// support them but also redefine TRUE which could have been defined as 1
// by previous headers: this would be incorrect as our TRUE is supposed to
// be of type bool, just like true, not int
//
// however if the user code absolutely needs TRUE to be defined in its own
// way, it can predefine WX_TRUE_DEFINED to prevent the redefinition here
#ifdef TRUE
#ifndef WX_TRUE_DEFINED
#undef TRUE
#undef FALSE
#endif
#endif
#ifndef TRUE
#define TRUE ((bool)1)
#define FALSE ((bool)0)
#endif
#else // !__cplusplus
// the definitions above don't work for C sources
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#endif // C++/!C++
typedef short int WXTYPE;
// special care should be taken with this type under Windows where the real
// window id is unsigned, so we must always do the cast before comparing them
// (or else they would be always different!). Usign wxGetWindowId() which does
// the cast itself is recommended. Note that this type can't be unsigned
// because wxID_ANY == -1 is a valid (and largely used) value for window id.
typedef int wxWindowID;
// ----------------------------------------------------------------------------
// other feature tests
// ----------------------------------------------------------------------------
// Every ride down a slippery slope begins with a single step..
//
// Yes, using nested classes is indeed against our coding standards in
// general, but there are places where you can use them to advantage
// without totally breaking ports that cannot use them. If you do, then
// wrap it in this guard, but such cases should still be relatively rare.
#ifndef __WIN16__
#define wxUSE_NESTED_CLASSES 1
#else
#define wxUSE_NESTED_CLASSES 0
#endif
// check for explicit keyword support
#ifndef HAVE_EXPLICIT
#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
// VC++ 6.0 has explicit (what about the earlier versions?)
#define HAVE_EXPLICIT
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)
// BC++ 4.52 doesn't support explicit, CBuilder 1 does
#define HAVE_EXPLICIT
#elif defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
// Metrowerks CW6 or higher has explicit
#define HAVE_EXPLICIT
#elif defined(__DIGITALMARS__)
#define HAVE_EXPLICIT
#endif
#endif // !HAVE_EXPLICIT
#ifdef HAVE_EXPLICIT
#define wxEXPLICIT explicit
#else // !HAVE_EXPLICIT
#define wxEXPLICIT
#endif // HAVE_EXPLICIT/!HAVE_EXPLICIT
// ----------------------------------------------------------------------------
// portable calling conventions macros
// ----------------------------------------------------------------------------
// stdcall is used for all functions called by Windows under Windows
#if defined(__WINDOWS__) && !defined(__WXWINE__)
#if defined(__GNUWIN32__)
#define wxSTDCALL __attribute__((stdcall))
#else
// both VC++ and Borland understand this
#define wxSTDCALL _stdcall
#endif
#else // Win
// no such stupidness under Unix
#define wxSTDCALL
#endif // platform
// LINKAGEMODE mode is empty for everyting except OS/2
#ifndef LINKAGEMODE
#define LINKAGEMODE
#endif // LINKAGEMODE
// wxCALLBACK should be used for the functions which are called back by
// Windows (such as compare function for wxListCtrl)
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
#define wxCALLBACK wxSTDCALL
#else
// no stdcall under Unix nor Win16
#define wxCALLBACK
#endif // platform
// generic calling convention for the extern "C" functions
#if defined(__VISUALC__)
#define wxC_CALLING_CONV _cdecl
#elif defined(__VISAGECPP__)
#define wxC_CALLING_CONV _Optlink
#else // !Visual C++
#define wxC_CALLING_CONV
#endif // compiler
// callling convention for the qsort(3) callback
#define wxCMPFUNC_CONV wxC_CALLING_CONV
// compatibility :-(
#define CMPFUNC_CONV wxCMPFUNC_CONV
// ----------------------------------------------------------------------------
// Making or using wxWindows as a Windows DLL
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
// __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well
// as VC++ and gcc
#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNUC__) || defined(__WATCOMC__) || defined(__DIGITALMARS__)
#define WXEXPORT __declspec(dllexport)
#define WXIMPORT __declspec(dllimport)
#else // compiler doesn't support __declspec()
#define WXEXPORT
#define WXIMPORT
#endif
#elif defined(__WXPM__)
#if defined (__WATCOMC__)
#define WXEXPORT __declspec(dllexport)
// __declspec(dllimport) prepends __imp to imported symbols. We do NOT
// want that!
#define WXIMPORT
#elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
#define WXEXPORT _Export
#define WXIMPORT _Export
#endif
#elif defined(__WXMAC__)
#ifdef __MWERKS__
#define WXEXPORT __declspec(export)
#define WXIMPORT __declspec(import)
#endif
#endif
// for other platforms/compilers we don't anything
#ifndef WXEXPORT
#define WXEXPORT
#define WXIMPORT
#endif
// WXDLLEXPORT maps to export declaration when building the DLL, to import
// declaration if using it or to nothing at all if we don't use wxWin DLL
#ifdef WXMAKINGDLL
#define WXDLLEXPORT WXEXPORT
#define WXDLLEXPORT_DATA(type) WXEXPORT type
#define WXDLLEXPORT_CTORFN
#elif defined(WXUSINGDLL)
#define WXDLLEXPORT WXIMPORT
#define WXDLLEXPORT_DATA(type) WXIMPORT type
#define WXDLLEXPORT_CTORFN
#else // not making nor using DLL
#define WXDLLEXPORT
#define WXDLLEXPORT_DATA(type) type
#define WXDLLEXPORT_CTORFN
#endif
// For ostream, istream ofstream
#if defined(__BORLANDC__) && defined( _RTLDLL )
# define WXDLLIMPORT __import
#else
# define WXDLLIMPORT
#endif
#ifdef __cplusplus
class WXDLLEXPORT wxObject;
class WXDLLEXPORT wxEvent;
#endif
// symbolic constant used by all Find()-like functions returning positive
// integer on success as failure indicator
#define wxNOT_FOUND (-1)
// ----------------------------------------------------------------------------
// Very common macros
// ----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -