00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXDEFS_H
00025 #define FXDEFS_H
00026
00027
00028
00029
00030
00031 #ifndef TRUE
00032 #define TRUE 1
00033 #endif
00034 #ifndef FALSE
00035 #define FALSE 0
00036 #endif
00037 #ifndef MAYBE
00038 #define MAYBE 2
00039 #endif
00040 #ifndef NULL
00041 #define NULL 0
00042 #endif
00043
00044
00045 #ifndef PI
00046 #define PI 3.1415926535897932384626433833
00047 #endif
00048
00049
00050 #define EULER 2.7182818284590452353602874713
00051
00052
00053 #define DTOR 0.0174532925199432957692369077
00054
00055
00056 #define RTOD 57.295779513082320876798154814
00057
00058
00059
00060 #ifdef WIN32
00061 #define PATHSEP '\\'
00062 #define PATHSEPSTRING "\\"
00063 #define PATHLISTSEP ';'
00064 #define PATHLISTSEPSTRING ";"
00065 #define ISPATHSEP(c) ((c)=='/' || (c)=='\\')
00066 #else
00067 #define PATHSEP '/'
00068 #define PATHSEPSTRING "/"
00069 #define PATHLISTSEP ':'
00070 #define PATHLISTSEPSTRING ":"
00071 #define ISPATHSEP(c) ((c)=='/')
00072 #endif
00073
00074
00075
00076 #ifdef WIN32
00077 #define EOLSTRING "\r\n"
00078 #else
00079 #define EOLSTRING "\n"
00080 #endif
00081
00082
00083
00084 #ifdef _DEBUG
00085 #ifndef DEBUG
00086 #define DEBUG
00087 #endif
00088 #endif
00089 #ifdef _NDEBUG
00090 #ifndef NDEBUG
00091 #define NDEBUG
00092 #endif
00093 #endif
00094
00095
00096
00097 #ifdef WIN32
00098 #define FXEXPORT __declspec(dllexport)
00099 #define FXIMPORT __declspec(dllimport)
00100 #else
00101 #define FXEXPORT
00102 #define FXIMPORT
00103 #endif
00104
00105
00106 #ifdef FOXDLL
00107 #ifdef FOXDLL_EXPORTS
00108 #define FXAPI FXEXPORT
00109 #else
00110 #define FXAPI FXIMPORT
00111 #endif
00112 #else
00113 #define FXAPI
00114 #endif
00115
00116
00117 #ifdef WIN32
00118 #ifndef CALLBACK
00119 #define CALLBACK __stdcall
00120 #endif
00121 #endif
00122
00123
00124
00125 #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__)
00126 #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg)))
00127 #define FX_SCANF(fmt,arg) __attribute__((format(scanf,fmt,arg)))
00128 #else
00129 #define FX_PRINTF(fmt,arg)
00130 #define FX_SCANF(fmt,arg)
00131 #endif
00132
00133
00134 #ifndef WIN32
00135 union _XEvent;
00136 #else
00137 struct tagMSG;
00138 #endif
00139
00140
00141 namespace FX {
00142
00143
00144
00145 enum FXSelType {
00146 SEL_NONE,
00147 SEL_KEYPRESS,
00148 SEL_KEYRELEASE,
00149 SEL_LEFTBUTTONPRESS,
00150 SEL_LEFTBUTTONRELEASE,
00151 SEL_MIDDLEBUTTONPRESS,
00152 SEL_MIDDLEBUTTONRELEASE,
00153 SEL_RIGHTBUTTONPRESS,
00154 SEL_RIGHTBUTTONRELEASE,
00155 SEL_MOTION,
00156 SEL_ENTER,
00157 SEL_LEAVE,
00158 SEL_FOCUSIN,
00159 SEL_FOCUSOUT,
00160 SEL_KEYMAP,
00161 SEL_UNGRABBED,
00162 SEL_PAINT,
00163 SEL_CREATE,
00164 SEL_DESTROY,
00165 SEL_UNMAP,
00166 SEL_MAP,
00167 SEL_CONFIGURE,
00168 SEL_SELECTION_LOST,
00169 SEL_SELECTION_GAINED,
00170 SEL_SELECTION_REQUEST,
00171 SEL_RAISED,
00172 SEL_LOWERED,
00173 SEL_CLOSE,
00174 SEL_DELETE,
00175 SEL_MINIMIZE,
00176 SEL_RESTORE,
00177 SEL_MAXIMIZE,
00178 SEL_UPDATE,
00179 SEL_COMMAND,
00180 SEL_CLICKED,
00181 SEL_DOUBLECLICKED,
00182 SEL_TRIPLECLICKED,
00183 SEL_MOUSEWHEEL,
00184 SEL_CHANGED,
00185 SEL_VERIFY,
00186 SEL_DESELECTED,
00187 SEL_SELECTED,
00188 SEL_INSERTED,
00189 SEL_REPLACED,
00190 SEL_DELETED,
00191 SEL_OPENED,
00192 SEL_CLOSED,
00193 SEL_EXPANDED,
00194 SEL_COLLAPSED,
00195 SEL_BEGINDRAG,
00196 SEL_ENDDRAG,
00197 SEL_DRAGGED,
00198 SEL_LASSOED,
00199 SEL_TIMEOUT,
00200 SEL_SIGNAL,
00201 SEL_CLIPBOARD_LOST,
00202 SEL_CLIPBOARD_GAINED,
00203 SEL_CLIPBOARD_REQUEST,
00204 SEL_CHORE,
00205 SEL_FOCUS_SELF,
00206 SEL_FOCUS_RIGHT,
00207 SEL_FOCUS_LEFT,
00208 SEL_FOCUS_DOWN,
00209 SEL_FOCUS_UP,
00210 SEL_FOCUS_NEXT,
00211 SEL_FOCUS_PREV,
00212 SEL_DND_ENTER,
00213 SEL_DND_LEAVE,
00214 SEL_DND_DROP,
00215 SEL_DND_MOTION,
00216 SEL_DND_REQUEST,
00217 SEL_IO_READ,
00218 SEL_IO_WRITE,
00219 SEL_IO_EXCEPT,
00220 SEL_PICKED,
00221 SEL_LAST
00222 };
00223
00224
00225
00226 enum {
00227 SHIFTMASK = 0x001,
00228 CAPSLOCKMASK = 0x002,
00229 CONTROLMASK = 0x004,
00230 ALTMASK = 0x008,
00231 METAMASK = 0x040,
00232 NUMLOCKMASK = 0x010,
00233 SCROLLLOCKMASK = 0x0E0,
00234 LEFTBUTTONMASK = 0x100,
00235 MIDDLEBUTTONMASK = 0x200,
00236 RIGHTBUTTONMASK = 0x400
00237 };
00238
00239
00240
00241 enum {
00242 LEFTBUTTON = 1,
00243 MIDDLEBUTTON = 2,
00244 RIGHTBUTTON = 3
00245 };
00246
00247
00248
00249 enum {
00250 CROSSINGNORMAL,
00251 CROSSINGGRAB,
00252 CROSSINGUNGRAB
00253 };
00254
00255
00256
00257 enum {
00258 VISIBILITYTOTAL,
00259 VISIBILITYPARTIAL,
00260 VISIBILITYNONE
00261 };
00262
00263
00264
00265 enum {
00266 FILEMATCH_FILE_NAME = 1,
00267 FILEMATCH_NOESCAPE = 2,
00268 FILEMATCH_PERIOD = 4,
00269 FILEMATCH_LEADING_DIR = 8,
00270 FILEMATCH_CASEFOLD = 16
00271 };
00272
00273
00274
00275 enum FXDragAction {
00276 DRAG_REJECT = 0,
00277 DRAG_ACCEPT = 1,
00278 DRAG_COPY = 2,
00279 DRAG_MOVE = 3,
00280 DRAG_LINK = 4,
00281 DRAG_PRIVATE = 5
00282 };
00283
00284
00285
00286 enum FXDNDOrigin {
00287 FROM_SELECTION = 0,
00288 FROM_CLIPBOARD = 1,
00289 FROM_DRAGNDROP = 2
00290 };
00291
00292
00293
00294 enum FXExponent {
00295 EXP_NEVER=FALSE,
00296 EXP_ALWAYS=TRUE,
00297 EXP_AUTO=MAYBE
00298 };
00299
00300
00301
00302 enum {
00303 SEARCH_FORWARD = 0,
00304 SEARCH_BACKWARD = 1,
00305 SEARCH_NOWRAP = 0,
00306 SEARCH_WRAP = 2,
00307 SEARCH_EXACT = 0,
00308 SEARCH_IGNORECASE = 4,
00309 SEARCH_REGEX = 8,
00310 SEARCH_PREFIX = 16
00311 };
00312
00313
00314
00315
00316
00317 class FXObject;
00318 class FXStream;
00319 class FXString;
00320
00321
00322
00323 typedef char FXchar;
00324 typedef unsigned char FXuchar;
00325 typedef FXuchar FXbool;
00326 typedef unsigned short FXushort;
00327 typedef short FXshort;
00328 typedef unsigned int FXuint;
00329 typedef unsigned int FXwchar;
00330 typedef int FXint;
00331 typedef float FXfloat;
00332 typedef double FXdouble;
00333 typedef FXObject *FXObjectPtr;
00334 #if defined(_MSC_VER) || (defined(__BCPLUSPLUS__) && __BORLANDC__ > 0x500) || defined(__WATCOM_INT64__)
00335 #define FX_LONG
00336 typedef unsigned __int64 FXulong;
00337 typedef __int64 FXlong;
00338 #elif defined(__GNUG__) || defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__MWERKS__) || defined(__SC__)
00339 #define FX_LONG
00340 typedef unsigned long long int FXulong;
00341 typedef long long int FXlong;
00342 #endif
00343
00344
00345 #if defined(_MSC_VER) && defined(_WIN64)
00346 typedef __int64 FXival;
00347 typedef unsigned __int64 FXuval;
00348 #else
00349 typedef long FXival;
00350 typedef unsigned long FXuval;
00351 #endif
00352
00353
00354
00355 #ifndef WIN32
00356 typedef unsigned long FXID;
00357 #else
00358 typedef void* FXID;
00359 #endif
00360
00361
00362 typedef long FXTime;
00363
00364
00365 typedef unsigned long FXPixel;
00366
00367
00368 typedef FXuint FXColor;
00369
00370
00371 typedef FXuint FXHotKey;
00372
00373
00374 #ifndef WIN32
00375 typedef FXID FXDragType;
00376 #else
00377 typedef FXushort FXDragType;
00378 #endif
00379
00380
00381 #ifndef WIN32
00382 typedef FXint FXInputHandle;
00383 #else
00384 typedef void* FXInputHandle;
00385 #endif
00386
00387
00388 #ifndef WIN32
00389 typedef _XEvent FXRawEvent;
00390 #else
00391 typedef tagMSG FXRawEvent;
00392 #endif
00393
00394
00395
00396
00397
00398
00399 #define FXABS(val) (((val)>=0)?(val):-(val))
00400
00401
00402 #define FXMAX(a,b) (((a)>(b))?(a):(b))
00403
00404
00405 #define FXMIN(a,b) (((a)>(b))?(b):(a))
00406
00407
00408 #define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z))
00409
00410
00411 #define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z))
00412
00413
00414 #define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a)))
00415
00416
00417 #define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x)))
00418
00419
00420 #define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t))
00421
00422
00423 #define FXLERP(a,b,f) ((a)+((b)-(a))*(f))
00424
00425
00426 #define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0))
00427
00428
00429 #define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0]))
00430
00431
00432 #define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem)))
00433
00434
00435 #define MKUINT(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16))
00436
00437
00438 #define FXSEL(type,id) ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16))
00439
00440
00441 #define FXSELTYPE(s) ((FX::FXushort)(((s)>>16)&0xffff))
00442
00443
00444 #define FXSELID(s) ((FX::FXushort)((s)&0xffff))
00445
00446
00447 #define FXBITREVERSE(b) (((b&0x01)<<7)|((b&0x02)<<5)|((b&0x04)<<3)|((b&0x08)<<1)|((b&0x10)>>1)|((b&0x20)>>3)|((b&0x40)>>5)|((b&0x80)>>7))
00448
00449
00450
00451
00452 #if FOX_BIGENDIAN == 1
00453
00454
00455 #define FXRGBA(r,g,b,a) (((FX::FXuint)(FX::FXuchar)(r)<<24) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<8) | ((FX::FXuint)(FX::FXuchar)(a)))
00456
00457
00458 #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<24) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<8) | 0x000000ff)
00459
00460
00461 #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff))
00462
00463
00464 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff))
00465
00466
00467 #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff))
00468
00469
00470 #define FXALPHAVAL(rgba) ((FX::FXuchar)((rgba)&0xff))
00471
00472
00473 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff))
00474
00475 #endif
00476
00477
00478 #if FOX_BIGENDIAN == 0
00479
00480
00481 #define FXRGBA(r,g,b,a) (((FX::FXuint)(FX::FXuchar)(r)) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)<<16) | ((FX::FXuint)(FX::FXuchar)(a)<<24))
00482
00483
00484 #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)<<16) | 0xff000000)
00485
00486
00487 #define FXREDVAL(rgba) ((FX::FXuchar)((rgba)&0xff))
00488
00489
00490 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff))
00491
00492
00493 #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff))
00494
00495
00496 #define FXALPHAVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff))
00497
00498
00499 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff))
00500
00501 #endif
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 #ifndef NDEBUG
00512 #define FXASSERT(exp) ((exp)?((void)0):(void)FX::fxassert(#exp,__FILE__,__LINE__))
00513 #else
00514 #define FXASSERT(exp) ((void)0)
00515 #endif
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530 #ifndef NDEBUG
00531 #define FXTRACE(arguments) FX::fxtrace arguments
00532 #else
00533 #define FXTRACE(arguments) ((void)0)
00534 #endif
00535
00536
00537
00538
00539
00540
00541
00542 #define FXMALLOC(ptr,type,no) (FX::fxmalloc((void **)(ptr),sizeof(type)*(no)))
00543
00544
00545
00546
00547
00548
00549 #define FXCALLOC(ptr,type,no) (FX::fxcalloc((void **)(ptr),sizeof(type)*(no)))
00550
00551
00552
00553
00554
00555
00556
00557 #define FXRESIZE(ptr,type,no) (FX::fxresize((void **)(ptr),sizeof(type)*(no)))
00558
00559
00560
00561
00562
00563
00564 #define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup((void **)(ptr),(const void*)(src),sizeof(type)*(no)))
00565
00566
00567
00568
00569
00570 #define FXFREE(ptr) (FX::fxfree((void **)(ptr)))
00571
00572
00573
00574
00575
00576
00577
00578 #ifndef __USE_ISOC99
00579 #define sqrtf(x) ((float)sqrt((double)(x)))
00580 #define fabsf(x) ((float)fabs((double)(x)))
00581 #define ceilf(x) ((float)ceil((double)(x)))
00582 #define floorf(x) ((float)floor((double)(x)))
00583 #define sinf(x) ((float)sin((double)(x)))
00584 #define cosf(x) ((float)cos((double)(x)))
00585 #define tanf(x) ((float)tan((double)(x)))
00586 #define asinf(x) ((float)asin((double)(x)))
00587 #define acosf(x) ((float)acos((double)(x)))
00588 #define atanf(x) ((float)atan((double)(x)))
00589 #define atan2f(y,x) ((float)atan2((double)(y),(double)(x)))
00590 #define powf(x,y) ((float)pow((double)(x),(double)(y)))
00591 #define expf(x) ((float)exp((double)(x)))
00592 #define fmodf(x,y) ((float)fmod((double)(x),(double)(y)))
00593 #define logf(x) ((float)log((double)(x)))
00594 #define log10f(x) ((float)log10((double)(x)))
00595 #endif
00596
00597
00598
00599
00600 extern FXAPI FXuint fxrandom(FXuint& seed);
00601
00602
00603 extern FXAPI FXint fxmalloc(void** ptr,unsigned long size);
00604
00605
00606 extern FXAPI FXint fxcalloc(void** ptr,unsigned long size);
00607
00608
00609 extern FXAPI FXint fxresize(void** ptr,unsigned long size);
00610
00611
00612 extern FXAPI FXint fxmemdup(void** ptr,const void* src,unsigned long size);
00613
00614
00615 extern FXAPI void fxfree(void** ptr);
00616
00617
00618 extern FXAPI void fxerror(const char* format,...) FX_PRINTF(1,2) ;
00619
00620
00621 extern FXAPI void fxwarning(const char* format,...) FX_PRINTF(1,2) ;
00622
00623
00624 extern FXAPI void fxmessage(const char* format,...) FX_PRINTF(1,2) ;
00625
00626
00627 extern FXAPI void fxassert(const char* expression,const char* filename,unsigned int lineno);
00628
00629
00630 extern FXAPI void fxtrace(unsigned int level,const char* format,...) FX_PRINTF(2,3) ;
00631
00632
00633 extern FXAPI void fxsleep(unsigned int n);
00634
00635
00636 extern FXAPI FXint fxfilematch(const char *pattern,const char *string,FXuint flags=(FILEMATCH_NOESCAPE|FILEMATCH_FILE_NAME));
00637
00638
00639 extern FXAPI FXColor makeHiliteColor(FXColor clr);
00640
00641
00642 extern FXAPI FXColor makeShadowColor(FXColor clr);
00643
00644
00645 extern FXAPI FXint fxgetpid();
00646
00647
00648 extern FXAPI FXchar *fxstrdup(const FXchar* str);
00649
00650
00651 extern FXAPI FXuint fxstrhash(const FXchar* str);
00652
00653
00654 extern FXAPI FXColor fxcolorfromname(const FXchar* colorname);
00655
00656
00657 extern FXAPI FXchar* fxnamefromcolor(FXchar *colorname,FXColor color);
00658
00659
00660 extern FXAPI void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b);
00661
00662
00663 extern FXAPI void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v);
00664
00665
00666 extern FXAPI FXint fxieeefloatclass(FXfloat number);
00667 extern FXAPI FXint fxieeedoubleclass(FXdouble number);
00668
00669
00670 extern FXAPI FXint fxparsegeometry(const FXchar *string,FXint& x,FXint& y,FXint& w,FXint& h);
00671
00672
00673 extern FXbool fxisconsole(const FXchar *path);
00674
00675
00676 extern FXAPI const FXuchar fxversion[3];
00677
00678
00679
00680 extern FXAPI unsigned int fxTraceLevel;
00681
00682
00683
00684
00685
00686
00687 extern FXAPI FXHotKey fxparseAccel(const FXString& string);
00688
00689
00690
00691
00692
00693
00694 extern FXAPI FXHotKey fxparseHotKey(const FXString& string);
00695
00696
00697
00698
00699
00700 extern FXAPI FXint fxfindHotKey(const FXString& string);
00701
00702
00703
00704
00705
00706
00707 extern FXAPI FXString fxstripHotKey(const FXString& string);
00708
00709 }
00710
00711 #endif