fxdefs.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                     FOX Definitions, Types, and Macros                        *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: fxdefs.h,v 1.178.2.2 2006/11/09 23:21:43 fox Exp $                           *
00023 ********************************************************************************/
00024 #ifndef FXDEFS_H
00025 #define FXDEFS_H
00026 
00027 #ifndef FOX_BIGENDIAN
00028 #error FOX_BIGENDIAN should have been set by build environment!
00029 #endif
00030 
00031 
00032 /********************************  Definitions  ********************************/
00033 
00034 // Truth values
00035 #ifndef TRUE
00036 #define TRUE 1
00037 #endif
00038 #ifndef FALSE
00039 #define FALSE 0
00040 #endif
00041 #ifndef MAYBE
00042 #define MAYBE 2
00043 #endif
00044 #ifndef NULL
00045 #define NULL 0
00046 #endif
00047 
00049 #ifndef PI
00050 #define PI      3.1415926535897932384626433833
00051 #endif
00052 
00054 #define EULER   2.7182818284590452353602874713
00055 
00057 #define DTOR    0.0174532925199432957692369077
00058 
00060 #define RTOD    57.295779513082320876798154814
00061 
00063 #define FXINFINITE ((FXuint) -1)
00064 
00065 
00066 // Path separator
00067 #ifdef WIN32
00068 #define PATHSEP '\\'
00069 #define PATHSEPSTRING "\\"
00070 #define PATHLISTSEP ';'
00071 #define PATHLISTSEPSTRING ";"
00072 #define ISPATHSEP(c) ((c)=='/' || (c)=='\\')
00073 #else
00074 #define PATHSEP '/'
00075 #define PATHSEPSTRING "/"
00076 #define PATHLISTSEP ':'
00077 #define PATHLISTSEPSTRING ":"
00078 #define ISPATHSEP(c) ((c)=='/')
00079 #endif
00080 
00081 // End Of Line
00082 #ifdef WIN32
00083 #define ENDLINE "\r\n"
00084 #else
00085 #define ENDLINE "\n"
00086 #endif
00087 
00088 
00089 // For Windows
00090 #ifdef _DEBUG
00091 #ifndef DEBUG
00092 #define DEBUG
00093 #endif
00094 #endif
00095 #ifdef _NDEBUG
00096 #ifndef NDEBUG
00097 #define NDEBUG
00098 #endif
00099 #endif
00100 
00101 
00102 // Shared library support
00103 #ifdef WIN32
00104   #define FXEXPORT __declspec(dllexport)
00105   #define FXIMPORT __declspec(dllimport)
00106   #define FXDLLLOCAL
00107   #define FXDLLPUBLIC
00108 #else
00109   #ifdef GCC_HASCLASSVISIBILITY
00110     #define FXEXPORT __attribute__ ((visibility("default")))
00111     #define FXIMPORT
00112     #define FXDLLLOCAL __attribute__ ((visibility("hidden")))
00113     #define FXDLLPUBLIC __attribute__ ((visibility("default")))
00114   #else
00115     #define FXEXPORT
00116     #define FXIMPORT
00117     #define FXDLLLOCAL
00118     #define FXDLLPUBLIC
00119   #endif
00120 #endif
00121 
00122 // Define FXAPI for DLL builds
00123 #ifdef FOXDLL
00124   #ifdef FOXDLL_EXPORTS
00125     #define FXAPI FXEXPORT
00126     #define FXTEMPLATE_EXTERN
00127     //#ifdef BUILDING_TCOMMON
00128     //#define FXAPIR
00129     //#else
00130     #define FXAPIR FXEXPORT
00131     //#endif // BUILDING_TCOMMON
00132   #else
00133     #define FXAPI  FXIMPORT
00134     #define FXTEMPLATE_EXTERN extern
00135     #define FXAPIR FXIMPORT
00136   #endif // FOXDLL_EXPORTS
00137 #else
00138   #define FXAPI
00139   #define FXTEMPLATE_EXTERN
00140   #define FXAPIR
00141 #endif // FOXDLL
00142 
00143 // Throwable classes must always be visible on GCC in all binaries
00144 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00145 #ifdef WIN32
00146   #define FXEXCEPTIONAPI(api) api
00147 #elif defined(GCC_HASCLASSVISIBILITY)
00148   #define FXEXCEPTIONAPI(api) FXEXPORT
00149 #endif
00150 #endif
00151 #ifndef FXEXCEPTIONAPI
00152   #define FXEXCEPTIONAPI(api)
00153 #endif
00154 
00155 #ifdef FX_GRAPHINGMODULE
00156 #if FX_GRAPHINGMODULE==1
00157  #define FXGRAPHINGMODULEAPI FXAPI
00158 #elif FX_GRAPHINGMODULE==2
00159  #ifdef FOXDLL
00160   #ifdef FX_GRAPHINGMODULE_EXPORTS
00161    #define FXGRAPHINGMODULEAPI FXEXPORT
00162   #else
00163    #define FXGRAPHINGMODULEAPI FXIMPORT
00164   #endif
00165  #else
00166   #define FXGRAPHINGMODULEAPI
00167  #endif
00168 #endif
00169 #endif
00170 
00171 // Forcing inlines, marking deprecation and restricting are non-portable extensions
00172 #if defined(_MSC_VER) && !defined(__GCCXML__)
00173  #define FXFORCEINLINE __forceinline
00174  #define FXDEPRECATED __declspec(deprecated)
00175  #define FXMEMALIGNED(v) __declspec(align(v))
00176  #if _MSC_VER>=1300
00177   #define __func__ __FUNCTION__
00178  #endif
00179  #if _MSC_VER>=1400
00180   #define FXMALLOCATTR __declspec(restrict)
00181   #define FXRESTRICT __restrict
00182  #endif
00183 #elif defined(__GNUC__) && !defined(__GCCXML__)
00184  #define FXFORCEINLINE inline __attribute__ ((always_inline))
00185  #define FXDEPRECATED __attribute ((deprecated))
00186  #define FXMEMALIGNED(v) __attribute__ ((aligned(v)))
00187  #define FXMALLOCATTR __attribute__ ((malloc))
00188  #define FXRESTRICT __restrict
00189 #else
00191  #define FXFORCEINLINE inline
00193  #define FXDEPRECATED
00195  #define FXMEMALIGNED(v)
00196 #endif
00197 #ifndef FXMALLOCATTR
00198  #define FXMALLOCATTR
00199 #endif
00200 #ifndef FXRESTRICT
00201  #define FXRESTRICT
00202 #endif
00203 #ifdef DEBUG    // No inlining when debugging
00204  #undef FXFORCEINLINE
00205  #define FXFORCEINLINE
00206 #endif
00207 #if defined(FOXDLL_EXPORTS) || defined(FOXPYTHONDLL_EXPORTS) || defined(FX_GRAPHINGMODULE_EXPORTS) || defined(FX_FOXCOMPAT)
00208  #define FXDEPRECATEDEXT
00209 #else
00210  #define FXDEPRECATEDEXT FXDEPRECATED
00211 #endif
00212 
00213 // Callback
00214 #ifdef WIN32
00215 #ifndef CALLBACK
00216 #define CALLBACK __stdcall
00217 #endif
00218 #endif
00219 
00220 // Stop really stupid warnings
00221 #ifdef _MSC_VER
00222 // Level 4 warnings
00223 #pragma warning(disable: 4100)      // Parameter not used
00224 #pragma warning(disable: 4127)      // Conditional expression is constant
00225 #pragma warning(disable: 4189)      // Local variable initialised but not referenced
00226 #pragma warning(disable: 4239)      // Move semantics used
00227 #pragma warning(disable: 4348)      // Template default parameter redefined
00228 #pragma warning(disable: 4511)      // Copy constructor could not be generated
00229 #pragma warning(disable: 4512)      // Assignment operator could not be generated
00230 #pragma warning(disable: 4610)      // Constructor required to instance
00231 #pragma warning(disable: 4706)      // Assignment within conditional expression
00232 
00233 #define _MFC_OVERRIDES_NEW          // Stop crtdbg.h defining its own debug operator new's
00234 #include <crtdbg.h>                 // Include now to prevent inclusion later
00235 #endif
00236 
00237 // We need std::move et al for move semantics
00238 #include <utility>
00239 #ifdef HAVE_CPP0XRVALUEREFS
00240 // Helper macro for move-enabled subclasses
00241 #define FXADDMOVEBASECLASS(_class, _baseclass) \
00242   _class (_class &&o) : _baseclass(std::forward<_baseclass>(o)) { } \
00243   _class &&operator=(_class &&o) { _baseclass::operator=(std::forward<_baseclass>(o)); return *this; }
00244 // Helper macro for move-only subclasses
00245 #define FXMOVEBASECLASS(_class, _baseclass) \
00246 private: \
00247   _class (const _class &); \
00248   _class &operator=(const _class &); \
00249 public: \
00250   FXADDMOVEBASECLASS(_class, _baseclass)
00251 #else
00252 #define FXADDMOVEBASECLASS(_class, _baseclass)
00253 #define FXMOVEBASECLASS(_class, _baseclass)
00254 namespace std
00255 {
00256   template<class T> T &move(T &a) { return a; }
00257   template<class T> T &move(const T &a) { return const_cast<T &>(a); }
00258   template<class T, class A> T &forward(A &a) { return a; }
00259 }
00260 #endif
00261 
00262 // Checking printf and scanf format strings
00263 #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__)
00264 #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg)))
00265 #define FX_SCANF(fmt,arg)  __attribute__((format(scanf,fmt,arg)))
00266 #else
00267 #define FX_PRINTF(fmt,arg)
00268 #define FX_SCANF(fmt,arg)
00269 #endif
00270 
00271 // Raw event type
00272 #ifndef WIN32
00273 union _XEvent;
00274 #else
00275 struct tagMSG;
00276 #endif
00277 
00278 
00279 namespace FX {
00280 
00281 
00282 // FOX System Defined Selector Types
00283 enum FXSelType {
00284   SEL_NONE,
00285   SEL_KEYPRESS,                         
00286   SEL_KEYRELEASE,                       
00287   SEL_LEFTBUTTONPRESS,                  
00288   SEL_LEFTBUTTONRELEASE,                
00289   SEL_MIDDLEBUTTONPRESS,                
00290   SEL_MIDDLEBUTTONRELEASE,              
00291   SEL_RIGHTBUTTONPRESS,                 
00292   SEL_RIGHTBUTTONRELEASE,               
00293   SEL_MOTION,                           
00294   SEL_ENTER,                            
00295   SEL_LEAVE,                            
00296   SEL_FOCUSIN,                          
00297   SEL_FOCUSOUT,                         
00298   SEL_KEYMAP,
00299   SEL_UNGRABBED,                        
00300   SEL_PAINT,                            
00301   SEL_CREATE,
00302   SEL_DESTROY,
00303   SEL_UNMAP,                            
00304   SEL_MAP,                              
00305   SEL_CONFIGURE,                        
00306   SEL_SELECTION_LOST,                   
00307   SEL_SELECTION_GAINED,                 
00308   SEL_SELECTION_REQUEST,                
00309   SEL_RAISED,                           
00310   SEL_LOWERED,                          
00311   SEL_CLOSE,                            
00312   SEL_DELETE,                           
00313   SEL_MINIMIZE,                         
00314   SEL_RESTORE,                          
00315   SEL_MAXIMIZE,                         
00316   SEL_UPDATE,                           
00317   SEL_COMMAND,                          
00318   SEL_APPLY,                            
00319   SEL_RESET,                            
00320   SEL_CLICKED,                          
00321   SEL_DOUBLECLICKED,                    
00322   SEL_TRIPLECLICKED,                    
00323   SEL_MOUSEWHEEL,                       
00324   SEL_CHANGED,                          
00325   SEL_VERIFY,                           
00326   SEL_DESELECTED,                       
00327   SEL_SELECTED,                         
00328   SEL_INSERTED,                         
00329   SEL_REPLACED,                         
00330   SEL_DELETED,                          
00331   SEL_OPENED,                           
00332   SEL_CLOSED,                           
00333   SEL_EXPANDED,                         
00334   SEL_COLLAPSED,                        
00335   SEL_BEGINDRAG,                        
00336   SEL_ENDDRAG,                          
00337   SEL_DRAGGED,                          
00338   SEL_LASSOED,                          
00339   SEL_TIMEOUT,                          
00340   SEL_SIGNAL,                           
00341   SEL_CLIPBOARD_LOST,                   
00342   SEL_CLIPBOARD_GAINED,                 
00343   SEL_CLIPBOARD_REQUEST,                
00344   SEL_CHORE,                            
00345   SEL_FOCUS_SELF,                       
00346   SEL_FOCUS_RIGHT,                      
00347   SEL_FOCUS_LEFT,                       
00348   SEL_FOCUS_DOWN,                       
00349   SEL_FOCUS_UP,                         
00350   SEL_FOCUS_NEXT,                       
00351   SEL_FOCUS_PREV,                       
00352   SEL_DND_ENTER,                        
00353   SEL_DND_LEAVE,                        
00354   SEL_DND_DROP,                         
00355   SEL_DND_MOTION,                       
00356   SEL_DND_REQUEST,                      
00357   SEL_IO_READ,                          
00358   SEL_IO_WRITE,                         
00359   SEL_IO_EXCEPT,                        
00360   SEL_PICKED,                           
00361   SEL_QUERY_TIP,                        
00362   SEL_QUERY_HELP,                       
00363   SEL_DOCKED,                           
00364   SEL_FLOATED,                          
00365   SEL_SESSION_NOTIFY,                   
00366   SEL_SESSION_CLOSED,                   
00367   SEL_LAST
00368   };
00369 
00370 
00372 enum {
00373   SHIFTMASK        = 0x001,           
00374   CAPSLOCKMASK     = 0x002,           
00375   CONTROLMASK      = 0x004,           
00376 #ifdef __APPLE__
00377   ALTMASK          = 0x2000,          
00378   METAMASK         = 0x10,            
00379 #else
00380   ALTMASK          = 0x008,           
00381   METAMASK         = 0x040,           
00382 #endif
00383   NUMLOCKMASK      = 0x010,           
00384   SCROLLLOCKMASK   = 0x0E0,           
00385   LEFTBUTTONMASK   = 0x100,           
00386   MIDDLEBUTTONMASK = 0x200,           
00387   RIGHTBUTTONMASK  = 0x400            
00388   };
00389 
00390 
00392 enum {
00393   LEFTBUTTON       = 1,
00394   MIDDLEBUTTON     = 2,
00395   RIGHTBUTTON      = 3
00396   };
00397 
00398 
00400 enum {
00401   CROSSINGNORMAL,            
00402   CROSSINGGRAB,              
00403   CROSSINGUNGRAB             
00404   };
00405 
00406 
00408 enum {
00409   VISIBILITYTOTAL,
00410   VISIBILITYPARTIAL,
00411   VISIBILITYNONE
00412   };
00413 
00414 
00416 enum {
00417   FILEMATCH_FILE_NAME   = 1,        
00418   FILEMATCH_NOESCAPE    = 2,        
00419   FILEMATCH_PERIOD      = 4,        
00420   FILEMATCH_LEADING_DIR = 8,        
00421   FILEMATCH_CASEFOLD    = 16        
00422   };
00423 
00424 
00426 enum FXDragAction {
00427   DRAG_REJECT  = 0,                 
00428   DRAG_ACCEPT  = 1,                 
00429   DRAG_COPY    = 2,                 
00430   DRAG_MOVE    = 3,                 
00431   DRAG_LINK    = 4,                 
00432   DRAG_PRIVATE = 5                  
00433   };
00434 
00435 
00437 enum FXDNDOrigin {
00438   FROM_SELECTION  = 0,              
00439   FROM_CLIPBOARD  = 1,              
00440   FROM_DRAGNDROP  = 2               
00441   };
00442 
00443 
00445 enum FXExponent {
00446   EXP_NEVER=FALSE,                  
00447   EXP_ALWAYS=TRUE,                  
00448   EXP_AUTO=MAYBE                    
00449   };
00450 
00451 
00453 enum {
00454   SEARCH_FORWARD      = 0,    
00455   SEARCH_BACKWARD     = 1,    
00456   SEARCH_NOWRAP       = 0,    
00457   SEARCH_WRAP         = 2,    
00458   SEARCH_EXACT        = 0,    
00459   SEARCH_IGNORECASE   = 4,    
00460   SEARCH_REGEX        = 8,    
00461   SEARCH_PREFIX       = 16    
00462   };
00463 
00464 
00465 /*********************************  Typedefs  **********************************/
00466 
00467 // Forward declarations
00468 class                          FXObject;
00469 class                          FXStream;
00470 class                          FXString;
00471 
00472 
00473 // Streamable types; these are fixed size!
00474 typedef char                   FXchar;
00475 typedef unsigned char          FXuchar;
00476 typedef FXuchar                FXbool;
00477 typedef unsigned short         FXushort;
00478 typedef short                  FXshort;
00479 typedef unsigned int           FXuint;
00480 typedef int                    FXint;
00481 typedef float                  FXfloat;
00482 typedef double                 FXdouble;
00483 typedef FXObject              *FXObjectPtr;
00484 #ifdef _MSC_VER
00485 #ifndef _NATIVE_WCHAR_T_DEFINED
00486 #error MSVC compiler option /Zc:wchar_t must be specified
00487 #endif
00488 typedef unsigned int           FXwchar;
00489 typedef wchar_t                FXnchar;
00490 #else
00491 typedef wchar_t                FXwchar;
00492 typedef unsigned short         FXnchar;
00493 #endif
00494 #if defined(__LP64__) || defined(_LP64) || (_MIPS_SZLONG == 64) || (__WORDSIZE == 64)
00495 typedef unsigned long          FXulong;
00496 typedef long                   FXlong;
00497 #elif defined(_MSC_VER) || (defined(__BCPLUSPLUS__) && __BORLANDC__ > 0x500) || defined(__WATCOM_INT64__)
00498 typedef unsigned __int64       FXulong;
00499 typedef __int64                FXlong;
00500 #elif defined(__GNUG__) || defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__MWERKS__) || defined(__SC__) || defined(_LONGLONG)
00501 typedef unsigned long long     FXulong;
00502 typedef long long              FXlong;
00503 #else
00504 #error "FXlong and FXulong not defined for this architecture!"
00505 #endif
00506 
00507 // Integral types large enough to hold value of a pointer
00508 #if defined(_MSC_VER) && defined(_WIN64)
00509 #ifndef FX_IS64BITPROCESSOR
00510  #define FX_IS64BITPROCESSOR
00511 #endif
00512 typedef __int64                FXival;
00513 typedef unsigned __int64       FXuval;
00514 #else
00515 typedef long                   FXival;
00516 typedef unsigned long          FXuval;
00517 #endif
00518 
00519 // Integral types large enough to hold value of a file pointer
00520 typedef FXulong                FXfval;
00521 
00522 // Handle to something in server
00523 #ifndef WIN32
00524 typedef unsigned long          FXID;
00525 #else
00526 typedef void*                  FXID;
00527 #endif
00528 
00529 // Pixel type (could be color index)
00530 typedef unsigned long          FXPixel;
00531 
00532 // RGBA pixel value
00533 typedef FXuint                 FXColor;
00534 
00535 // Hot key
00536 typedef FXuint                 FXHotKey;
00537 
00538 // Drag type
00539 #ifndef WIN32
00540 typedef FXID                   FXDragType;
00541 #else
00542 typedef FXushort               FXDragType;
00543 #endif
00544 
00545 // Input source handle type
00546 #ifndef WIN32
00547 typedef FXint                  FXInputHandle;
00548 #else
00549 typedef void*                  FXInputHandle;
00550 #endif
00551 
00552 // Raw event type
00553 #ifndef WIN32
00554 typedef _XEvent                FXRawEvent;
00555 #else
00556 typedef tagMSG                 FXRawEvent;
00557 #endif
00558 
00559 
00560 /**********************************  Macros  ***********************************/
00561 
00563 template<typename type> type *FXOFFSETPTR(type *p, FXival offset) { return (type *)(((FXuval)p)+offset); }
00564 
00566 #define FXABS(val) (((val)>=0)?(val):-(val))
00567 
00569 #define FXMAX(a,b) (((a)>(b))?(a):(b))
00570 
00572 #define FXMIN(a,b) (((a)>(b))?(b):(a))
00573 
00575 #define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z))
00576 
00578 #define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z))
00579 
00581 #define FXMIN4(x,y,z,w) (FXMIN(FXMIN(x,y),FXMIN(z,w)))
00582 
00584 #define FXMAX4(x,y,z,w) (FXMAX(FXMAX(x,y),FXMAX(z,w)))
00585 
00587 #define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a)))
00588 
00590 #define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x)))
00591 
00593 #define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t))
00594 
00595 
00596 /* We must define some of these macros as functions so BPL can pick them up */
00597 
00599 inline float  FXLERP(float  a, float  b, float  f) { return ((a)+((b)-(a))*(f)); }
00600 inline double FXLERP(double a, double b, double f) { return ((a)+((b)-(a))*(f)); }
00601 
00603 #define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0))
00604 
00606 #define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0]))
00607 
00609 #define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem)))
00610 
00612 inline FXuint MKUINT(FXuint l, FXuint h) { return ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16)); }
00613 #define MKUINT_(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16))
00614 
00616 inline FXuint FXSEL(FXuint type, FXuint id) { return ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16)); }
00617 
00619 inline FXushort FXSELTYPE(FXuint s) { return ((FX::FXushort)(((s)>>16)&0xffff)); }
00620 
00622 inline FXushort FXSELID(FXuint s) { return ((FX::FXushort)((s)&0xffff)); }
00623 
00625 inline FXuchar FXBITREVERSE(FXuchar b) { return (((b&0x01)<<7)|((b&0x02)<<5)|((b&0x04)<<3)|((b&0x08)<<1)|((b&0x10)>>1)|((b&0x20)>>3)|((b&0x40)>>5)|((b&0x80)>>7)); }
00626 
00628 #define FXISUTF(c) (((c)&0xC0)!=0x80)
00629 
00630 
00631 // Definitions for big-endian machines
00632 #if FOX_BIGENDIAN == 1
00633 
00635 inline FXuint FXRGBA(FXuchar r, FXuchar g, FXuchar b, FXuchar a)    { return (((FX::FXuint)(FX::FXuchar)(r)<<24) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<8) | ((FX::FXuint)(FX::FXuchar)(a))); }
00636 
00638 inline FXuint FXRGB(FXuchar r, FXuchar g, FXuchar b)                { return (((FX::FXuint)(FX::FXuchar)(r)<<24) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<8) | 0x000000ff); }
00639 
00641 inline FXuchar FXREDVAL(FXuint rgba)        { return ((FX::FXuchar)(((rgba)>>24)&0xff)); }
00642 
00644 inline FXuchar FXGREENVAL(FXuint rgba)      { return ((FX::FXuchar)(((rgba)>>16)&0xff)); }
00645 
00647 inline FXuchar FXBLUEVAL(FXuint rgba)       { return ((FX::FXuchar)(((rgba)>>8)&0xff)); }
00648 
00650 inline FXuchar FXALPHAVAL(FXuint rgba)      { return ((FX::FXuchar)((rgba)&0xff)); }
00651 
00653 inline FXuchar FXRGBACOMPVAL(FXuint rgba, int comp) { return ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff)); }
00654 
00655 #endif
00656 
00657 
00658 // Definitions for little-endian machines
00659 #if FOX_BIGENDIAN == 0
00660 
00662 inline FXuint FXRGBA(FXuchar r, FXuchar g, FXuchar b, FXuchar a)    { return (((FX::FXuint)(FX::FXuchar)(r)) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)<<16) | ((FX::FXuint)(FX::FXuchar)(a)<<24)); }
00663 
00665 inline FXuint FXRGB(FXuchar r, FXuchar g, FXuchar b)                { return (((FX::FXuint)(FX::FXuchar)(r)) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)<<16) | 0xff000000); }
00666 
00668 inline FXuchar FXREDVAL(FXuint rgba)        { return ((FX::FXuchar)((rgba)&0xff)); }
00669 
00671 inline FXuchar FXGREENVAL(FXuint rgba)      { return ((FX::FXuchar)(((rgba)>>8)&0xff)); }
00672 
00674 inline FXuchar FXBLUEVAL(FXuint rgba)       { return ((FX::FXuchar)(((rgba)>>16)&0xff)); }
00675 
00677 inline FXuchar FXALPHAVAL(FXuint rgba)      { return ((FX::FXuchar)(((rgba)>>24)&0xff)); }
00678 
00680 inline FXuchar FXRGBACOMPVAL(FXuint rgba, int comp) { return ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff)); }
00681 
00682 #endif
00683 
00684 
00692 #ifndef NDEBUG
00693 #define FXASSERT(exp) ((exp)?((void)0):(void)FX::fxassert(#exp,__FILE__,__LINE__))
00694 #else
00695 #define FXASSERT(exp) ((void)0)
00696 #endif
00697 
00698 
00711 #ifndef NDEBUG
00712 #define FXTRACE(arguments) FX::fxtrace arguments
00713 #else
00714 #define FXTRACE(arguments) ((void)0)
00715 #endif
00716 
00717 template<typename type> inline void **fxtypeptrptrtovoidptrptr(type **d) throw()
00718 { // Aliasing safe pointer conversion
00719   union { type **t; void **p; } temp;
00720   temp.t=d;
00721   return temp.p;
00722 }
00723 
00730 #define FXMALLOC(ptr,type,no)     (FX::fxmalloc(fxtypeptrptrtovoidptrptr(ptr),sizeof(type)*(no)))
00731 
00738 #define FXCALLOC(ptr,type,no)     (FX::fxcalloc(fxtypeptrptrtovoidptrptr(ptr),sizeof(type)*(no)))
00739 
00749 #define FXRESIZE(ptr,type,no)     (FX::fxresize(fxtypeptrptrtovoidptrptr(ptr),sizeof(type)*(no)))
00750 
00758 #define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup(fxtypeptrptrtovoidptrptr(ptr),(const void*)(src),sizeof(type)*(no)))
00759 
00766 #define FXFREE(ptr)               (FX::fxfree(fxtypeptrptrtovoidptrptr(ptr)))
00767 
00768 
00769 /**********************************  Globals  **********************************/
00770 
00772 extern FXAPI FXuint fxrandom(FXuint& seed);
00773 
00775 extern FXAPI FXuint fxadler32(FXuint c, const FXuchar *buff, FXuval len) throw();
00776 
00778 extern FXAPI FXString fxdump8(FXuchar *buffer, FXuval len) throw();
00779 
00781 extern FXAPI FXString fxdump32(FXuint *buffer, FXuval len) throw();
00782 
00784 extern FXAPI FXString fxstrfval(FXfval len, FXint fw=0, char fmt='f', int prec=2);
00785 
00787 extern FXAPI const FXuint *fx2powerprimes(FXuint topval) throw();
00788 
00789 
00791 extern FXAPI FXint fxmalloc(void** ptr,unsigned long size);
00792 
00794 extern FXAPI FXint fxcalloc(void** ptr,unsigned long size);
00795 
00797 extern FXAPI FXint fxresize(void** ptr,unsigned long size);
00798 
00800 extern FXAPI FXint fxmemdup(void** ptr,const void* src,unsigned long size);
00801 
00803 extern FXAPI void fxfree(void** ptr);
00804 
00806 extern FXAPI void fxerror(const char* format,...) FX_PRINTF(1,2) ;
00807 
00809 extern FXAPI void fxwarning(const char* format,...) FX_PRINTF(1,2) ;
00810 
00812 extern FXAPI void fxmessage(const char* format,...) FX_PRINTF(1,2) ;
00813 
00815 extern FXAPI void fxassert(const char* expression,const char* filename,unsigned int lineno);
00816 
00818 extern FXAPI void fxtrace(unsigned int level,const char* format,...) FX_PRINTF(2,3) ;
00819 
00821 extern FXAPI void fxsleep(unsigned int n);
00822 
00824 extern FXAPI bool fxfilematch(const char *pattern,const char *string,FXuint flags=(FILEMATCH_NOESCAPE|FILEMATCH_FILE_NAME));
00825 
00827 extern FXAPI FXColor makeHiliteColor(FXColor clr);
00828 
00830 extern FXAPI FXColor makeShadowColor(FXColor clr);
00831 
00833 extern FXAPI FXint fxgetpid();
00834 
00836 //extern FXAPI bool fxtoDOS(FXchar*& string,FXint& len);
00837 
00839 //extern FXAPI bool fxfromDOS(FXchar*& string,FXint& len);
00840 
00842 extern FXAPI FXchar *fxstrdup(const FXchar* str);
00843 
00845 extern FXAPI FXuint fxstrhash(const FXchar* str);
00846 
00848 extern FXAPI FXColor fxcolorfromname(const FXchar* colorname);
00849 
00851 extern FXAPI FXchar* fxnamefromcolor(FXchar *colorname,FXColor color);
00852 
00854 extern FXAPI void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b);
00855 
00857 extern FXAPI void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v);
00858 
00860 extern FXAPI FXint fxieeefloatclass(FXfloat number);
00861 extern FXAPI FXint fxieeedoubleclass(FXdouble number);
00862 
00864 extern FXAPI FXwchar fxkeysym2ucs(FXwchar sym);
00865 
00867 extern FXAPI FXwchar fxucs2keysym(FXwchar ucs);
00868 
00870 extern FXAPI FXint fxparsegeometry(const FXchar *string,FXint& x,FXint& y,FXint& w,FXint& h);
00871 
00873 extern FXAPI FXbool fxisconsole(const FXchar *path);
00874 
00876 extern FXAPI const FXString &fxdemanglesymbol(const FXString &rawsymbol, bool errorIfNotFound=true);
00877 
00879 extern FXAPI const FXuchar fxversion[3];
00880 
00881 // TnFOX version number
00882 extern FXAPI const FXuchar tnfoxversion[2];
00883 
00885 extern FXAPI unsigned int fxTraceLevel;
00886 
00888 extern FXAPI FXwchar wc(const FXchar *ptr) throw();
00889 
00891 extern FXAPI FXwchar wc(const FXnchar *ptr) throw();
00892 
00894 extern FXAPI FXint wclen(const FXchar *ptr) throw();
00895 
00897 extern FXAPI FXint wclen(const FXnchar *ptr) throw();
00898 
00900 extern FXAPI FXint wcvalidate(const FXchar* string,FXint pos) throw();
00901 
00903 extern FXAPI FXint wcvalidate(const FXnchar *string,FXint pos) throw();
00904 
00906 extern FXAPI FXint wcinc(const FXchar* string,FXint pos) throw();
00907 
00909 extern FXAPI FXint wcinc(const FXnchar *string,FXint pos) throw();
00910 
00912 extern FXAPI FXint wcdec(const FXchar* string,FXint pos) throw();
00913 
00915 extern FXAPI FXint wcdec(const FXnchar *string,FXint pos) throw();
00916 
00918 extern FXAPI bool isutfvalid(const FXchar* str) throw();
00919 
00921 extern FXAPI bool isutfvalid(const FXnchar* str) throw();
00922 
00924 extern FXAPI FXint utfslen(const FXwchar *str,FXint n) throw();
00925 
00927 extern FXAPI FXint utfslen(const FXwchar *str) throw();
00928 
00930 extern FXAPI FXint utfslen(const FXnchar *str,FXint n) throw();
00931 
00933 extern FXAPI FXint utfslen(const FXnchar *str) throw();
00934 
00936 extern FXAPI FXint wcslen(const FXchar *str,FXint n) throw();
00937 
00939 extern FXAPI FXint wcslen(const FXchar *str) throw();
00940 
00942 extern FXAPI FXint ncslen(const FXchar *str,FXint n) throw();
00943 
00945 extern FXAPI FXint ncslen(const FXchar *str) throw();
00946 
00948 extern FXAPI FXint utf2wcs(FXwchar *dst,const FXchar *src,FXint n) throw();
00949 
00951 extern FXAPI FXint utf2wcs(FXwchar *dst,const FXchar *src) throw();
00952 
00954 extern FXAPI FXint utf2ncs(FXnchar *dst,const FXchar *src,FXint n) throw();
00955 
00957 extern FXAPI FXint utf2ncs(FXnchar *dst,const FXchar *src) throw();
00958 
00960 extern FXAPI FXint wc2utfs(FXchar* dst,const FXwchar *src,FXint n) throw();
00961 
00963 extern FXAPI FXint wc2utfs(FXchar* dst,const FXwchar *src) throw();
00964 
00966 extern FXAPI FXint nc2utfs(FXchar* dst,const FXnchar *src,FXint n) throw();
00967 
00969 extern FXAPI FXint nc2utfs(FXchar* dst,const FXnchar *src) throw();
00970 
00971 
00972 
00973 // Have to put all forward declarations of all template types with default parameters here
00974 // as recent compilers no longer allow multiple declarations of default parameterised templates
00975 //
00976 // Personally I think that ISO C++ decision sucks, however I must admit things are now much
00977 // easier to maintain should I ever change the template spec.
00978 namespace Generic { struct NullType; }
00979 template<typename T, int alignment> class aligned_allocator;
00980 template<class dictbase, class type=Generic::NullType> class FXLRUCache;
00981 template<typename type, class allocator=FX::aligned_allocator<type, 0> > class QMemArray;
00982 
00983 }
00984 
00985 #include "fxassemblerops.h"
00986 #include "FXMemoryPool.h"
00987 
00988 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:20 2009 for TnFOX by doxygen v1.4.7