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_QUERY_TIP,
00222 SEL_QUERY_HELP,
00223 SEL_LAST
00224 };
00225
00226
00227
00228
enum {
00229 SHIFTMASK = 0x001,
00230 CAPSLOCKMASK = 0x002,
00231 CONTROLMASK = 0x004,
00232
#ifdef __APPLE__
00233
ALTMASK = 0x2000
00234 METAMASK = 0x10,
00235
#else
00236
ALTMASK = 0x008,
00237 METAMASK = 0x040,
00238
#endif
00239
NUMLOCKMASK = 0x010,
00240 SCROLLLOCKMASK = 0x0E0,
00241 LEFTBUTTONMASK = 0x100,
00242 MIDDLEBUTTONMASK = 0x200,
00243 RIGHTBUTTONMASK = 0x400
00244 };
00245
00246
00247
00248
enum {
00249 LEFTBUTTON = 1,
00250 MIDDLEBUTTON = 2,
00251 RIGHTBUTTON = 3
00252 };
00253
00254
00255
00256
enum {
00257
CROSSINGNORMAL,
00258
CROSSINGGRAB,
00259
CROSSINGUNGRAB
00260 };
00261
00262
00263
00264
enum {
00265 VISIBILITYTOTAL,
00266 VISIBILITYPARTIAL,
00267 VISIBILITYNONE
00268 };
00269
00270
00271
00272
enum {
00273
FILEMATCH_FILE_NAME = 1,
00274
FILEMATCH_NOESCAPE = 2,
00275
FILEMATCH_PERIOD = 4,
00276
FILEMATCH_LEADING_DIR = 8,
00277
FILEMATCH_CASEFOLD = 16
00278 };
00279
00280
00281
00282
enum FXDragAction {
00283
DRAG_REJECT = 0,
00284
DRAG_ACCEPT = 1,
00285
DRAG_COPY = 2,
00286
DRAG_MOVE = 3,
00287
DRAG_LINK = 4,
00288
DRAG_PRIVATE = 5
00289 };
00290
00291
00292
00293
enum FXDNDOrigin {
00294
FROM_SELECTION = 0,
00295
FROM_CLIPBOARD = 1,
00296
FROM_DRAGNDROP = 2
00297 };
00298
00299
00300
00301
enum FXExponent {
00302
EXP_NEVER=FALSE,
00303
EXP_ALWAYS=TRUE,
00304
EXP_AUTO=MAYBE
00305 };
00306
00307
00308
00309 enum {
00310 SEARCH_FORWARD = 0,
00311 SEARCH_BACKWARD = 1,
00312 SEARCH_NOWRAP = 0,
00313 SEARCH_WRAP = 2,
00314 SEARCH_EXACT = 0,
00315 SEARCH_IGNORECASE = 4,
00316 SEARCH_REGEX = 8,
00317 SEARCH_PREFIX = 16
00318 };
00319
00320
00321
00322
00323
00324 class FXObject;
00325
class FXStream;
00326
class FXString;
00327
00328
00329
00330
typedef char FXchar;
00331
typedef unsigned char FXuchar;
00332
typedef FXuchar FXbool;
00333
typedef unsigned short FXushort;
00334
typedef short FXshort;
00335
typedef unsigned int FXuint;
00336 typedef unsigned int FXwchar;
00337
typedef int FXint;
00338
typedef float FXfloat;
00339
typedef double FXdouble;
00340
typedef FXObject *FXObjectPtr;
00341
#if defined(__LP64__) || defined(_LP64) || (_MIPS_SZLONG == 64) || (__WORDSIZE == 64)
00342
typedef unsigned long FXulong;
00343
typedef long FXlong;
00344
#elif defined(_MSC_VER) || (defined(__BCPLUSPLUS__) && __BORLANDC__ > 0x500) || defined(__WATCOM_INT64__)
00345
typedef unsigned __int64 FXulong;
00346
typedef __int64 FXlong;
00347
#elif defined(__GNUG__) || defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__MWERKS__) || defined(__SC__) || defined(_LONGLONG)
00348
typedef unsigned long long FXulong;
00349
typedef long long FXlong;
00350
#else
00351
#error "FXlong and FXulong not defined for this architecture!"
00352
#endif
00353
00354
00355
#if defined(_MSC_VER) && defined(_WIN64)
00356
typedef __int64 FXival;
00357
typedef unsigned __int64 FXuval;
00358
#else
00359
typedef long FXival;
00360
typedef unsigned long FXuval;
00361
#endif
00362
00363
00364
00365
#ifndef WIN32
00366
typedef unsigned long FXID;
00367
#else
00368
typedef void* FXID;
00369
#endif
00370
00371
00372
typedef long FXTime;
00373
00374
00375
typedef unsigned long FXPixel;
00376
00377
00378
typedef FXuint FXColor;
00379
00380
00381
typedef FXuint FXHotKey;
00382
00383
00384
#ifndef WIN32
00385
typedef FXID FXDragType;
00386
#else
00387
typedef FXushort FXDragType;
00388
#endif
00389
00390
00391
#ifndef WIN32
00392
typedef FXint FXInputHandle;
00393
#else
00394
typedef void* FXInputHandle;
00395
#endif
00396
00397
00398
#ifndef WIN32
00399
typedef _XEvent FXRawEvent;
00400
#else
00401
typedef tagMSG FXRawEvent;
00402
#endif
00403
00404
00405
00406
00407
00408
00409
#define FXABS(val) (((val)>=0)?(val):-(val))
00410
00411
00412
#define FXMAX(a,b) (((a)>(b))?(a):(b))
00413
00414
00415
#define FXMIN(a,b) (((a)>(b))?(b):(a))
00416
00417
00418
#define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z))
00419
00420
00421
#define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z))
00422
00423
00424
#define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a)))
00425
00426
00427
#define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x)))
00428
00429
00430
#define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t))
00431
00432
00433
#define FXLERP(a,b,f) ((a)+((b)-(a))*(f))
00434
00435
00436
#define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0))
00437
00438
00439
#define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0]))
00440
00441
00442
#define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem)))
00443
00444
00445
#define MKUINT(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16))
00446
00447
00448
#define FXSEL(type,id) ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16))
00449
00450
00451
#define FXSELTYPE(s) ((FX::FXushort)(((s)>>16)&0xffff))
00452
00453
00454
#define FXSELID(s) ((FX::FXushort)((s)&0xffff))
00455
00456
00457
#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))
00458
00459
00460
00461
00462
#if FOX_BIGENDIAN == 1
00463
00464
00465
#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)))
00466
00467
00468
#define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<24) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<8) | 0x000000ff)
00469
00470
00471
#define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff))
00472
00473
00474
#define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff))
00475
00476
00477
#define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff))
00478
00479
00480
#define FXALPHAVAL(rgba) ((FX::FXuchar)((rgba)&0xff))
00481
00482
00483
#define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff))
00484
00485
#endif
00486
00487
00488
#if FOX_BIGENDIAN == 0
00489
00490
00491
#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))
00492
00493
00494
#define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)<<16) | 0xff000000)
00495
00496
00497
#define FXREDVAL(rgba) ((FX::FXuchar)((rgba)&0xff))
00498
00499
00500
#define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff))
00501
00502
00503
#define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff))
00504
00505
00506
#define FXALPHAVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff))
00507
00508
00509
#define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff))
00510
00511
#endif
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
#ifndef NDEBUG
00522
#define FXASSERT(exp) ((exp)?((void)0):(void)FX::fxassert(#exp,__FILE__,__LINE__))
00523
#else
00524
#define FXASSERT(exp) ((void)0)
00525
#endif
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
#ifndef NDEBUG
00541
#define FXTRACE(arguments) FX::fxtrace arguments
00542
#else
00543
#define FXTRACE(arguments) ((void)0)
00544
#endif
00545
00546
00547
00548
00549
00550
00551
00552
00553
#define FXMALLOC(ptr,type,no) (FX::fxmalloc((void **)(ptr),sizeof(type)*(no)))
00554
00555
00556
00557
00558
00559
00560
00561
#define FXCALLOC(ptr,type,no) (FX::fxcalloc((void **)(ptr),sizeof(type)*(no)))
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
#define FXRESIZE(ptr,type,no) (FX::fxresize((void **)(ptr),sizeof(type)*(no)))
00573
00574
00575
00576
00577
00578
00579
00580
00581
#define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup((void **)(ptr),(const void*)(src),sizeof(type)*(no)))
00582
00583
00584
00585
00586
00587
00588
00589
#define FXFREE(ptr) (FX::fxfree((void **)(ptr)))
00590
00591
00592
00593
00594
00595
00596
00597
00598
#ifndef __USE_ISOC99
00599
#ifndef __APPLE__
00600
#define fabsf(x) ((float)fabs((double)(x)))
00601
#define ceilf(x) ((float)ceil((double)(x)))
00602
#define floorf(x) ((float)floor((double)(x)))
00603
#define fmodf(x,y) ((float)fmod((double)(x),(double)(y)))
00604
#endif
00605
#define sqrtf(x) ((float)sqrt((double)(x)))
00606
#define sinf(x) ((float)sin((double)(x)))
00607
#define cosf(x) ((float)cos((double)(x)))
00608
#define tanf(x) ((float)tan((double)(x)))
00609
#define asinf(x) ((float)asin((double)(x)))
00610
#define acosf(x) ((float)acos((double)(x)))
00611
#define atanf(x) ((float)atan((double)(x)))
00612
#define atan2f(y,x) ((float)atan2((double)(y),(double)(x)))
00613
#define powf(x,y) ((float)pow((double)(x),(double)(y)))
00614
#define expf(x) ((float)exp((double)(x)))
00615
#define logf(x) ((float)log((double)(x)))
00616
#define log10f(x) ((float)log10((double)(x)))
00617
#endif
00618
00619
00620
00621
00622
extern FXAPI FXuint fxrandom(FXuint& seed);
00623
00624
00625
extern FXAPI FXint fxmalloc(
void** ptr,
unsigned long size);
00626
00627
00628
extern FXAPI FXint fxcalloc(
void** ptr,
unsigned long size);
00629
00630
00631
extern FXAPI FXint fxresize(
void** ptr,
unsigned long size);
00632
00633
00634
extern FXAPI FXint fxmemdup(
void** ptr,
const void* src,
unsigned long size);
00635
00636
00637
extern FXAPI
void fxfree(
void** ptr);
00638
00639
00640
extern FXAPI
void fxerror(
const char* format,...) FX_PRINTF(1,2) ;
00641
00642
00643 extern FXAPI
void fxwarning(const
char* format,...) FX_PRINTF(1,2) ;
00644
00645
00646 extern FXAPI
void fxmessage(const
char* format,...) FX_PRINTF(1,2) ;
00647
00648
00649 extern FXAPI
void fxassert(const
char* expression,const
char* filename,
unsigned int lineno);
00650
00651
00652 extern FXAPI
void fxtrace(
unsigned int level,const
char* format,...) FX_PRINTF(2,3) ;
00653
00654
00655 extern FXAPI
void fxsleep(
unsigned int n);
00656
00657
00658 extern FXAPI FXint fxfilematch(const
char *pattern,const
char *string,FXuint flags=(FILEMATCH_NOESCAPE|FILEMATCH_FILE_NAME));
00659
00660
00661 extern FXAPI FXColor makeHiliteColor(FXColor clr);
00662
00663
00664 extern FXAPI FXColor makeShadowColor(FXColor clr);
00665
00666
00667 extern FXAPI FXint fxgetpid();
00668
00669
00670 extern FXAPI FXbool fxtoDOS(FXchar*& string,FXint& len);
00671
00672
00673 extern FXAPI FXbool fxfromDOS(FXchar*& string,FXint& len);
00674
00675
00676 extern FXAPI FXchar *fxstrdup(const FXchar* str);
00677
00678
00679 extern FXAPI FXuint fxstrhash(const FXchar* str);
00680
00681
00682 extern FXAPI FXColor fxcolorfromname(const FXchar* colorname);
00683
00684
00685 extern FXAPI FXchar* fxnamefromcolor(FXchar *colorname,FXColor color);
00686
00687
00688 extern FXAPI
void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b);
00689
00690
00691 extern FXAPI
void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v);
00692
00693
00694 extern FXAPI FXint fxieeefloatclass(FXfloat number);
00695 extern FXAPI FXint fxieeedoubleclass(FXdouble number);
00696
00697
00698 extern FXAPI FXint fxparsegeometry(const FXchar *string,FXint& x,FXint& y,FXint& w,FXint& h);
00699
00700
00701 extern FXbool fxisconsole(const FXchar *path);
00702
00703
00704 extern FXAPI const FXuchar fxversion[3];
00705
00706
00707
00708 extern FXAPI
unsigned int fxTraceLevel;
00709
00710
00711
00712
00713
00714
00715 extern FXAPI FXHotKey fxparseAccel(const FXString& string);
00716
00717
00718
00719
00720
00721
00722 extern FXAPI FXHotKey fxparseHotKey(const FXString& string);
00723
00724
00725
00726
00727
00728 extern FXAPI FXint fxfindHotKey(const FXString& string);
00729
00730
00731
00732
00733
00734
00735 extern FXAPI FXString fxstripHotKey(const FXString& string);
00736
00737 }
00738
00739 #endif