Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

fxdefs.h

00001 /******************************************************************************** 00002 * * 00003 * FOX Definitions, Types, and Macros * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2004 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.133 2004/03/28 23:55:18 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXDEFS_H 00025 #define FXDEFS_H 00026 00027 00028 /******************************** Definitions ********************************/ 00029 00030 // Truth values 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 /// Pi 00045 #ifndef PI 00046 #define PI 3.1415926535897932384626433833 00047 #endif 00048 00049 /// Euler constant 00050 #define EULER 2.7182818284590452353602874713 00051 00052 /// Multiplier for degrees to radians 00053 #define DTOR 0.0174532925199432957692369077 00054 00055 /// Multiplier for radians to degrees 00056 #define RTOD 57.295779513082320876798154814 00057 00058 00059 // Path separator 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 // End Of Line 00076 #ifdef WIN32 00077 #define EOLSTRING "\r\n" 00078 #else 00079 #define EOLSTRING "\n" 00080 #endif 00081 00082 00083 // For Windows 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 // Shared library support 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 // Define FXAPI for DLL builds 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 // Callback 00117 #ifdef WIN32 00118 #ifndef CALLBACK 00119 #define CALLBACK __stdcall 00120 #endif 00121 #endif 00122 00123 00124 // Checking printf and scanf format strings 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 // Raw event type 00134 #ifndef WIN32 00135 union _XEvent; 00136 #else 00137 struct tagMSG; 00138 #endif 00139 00140 00141 namespace FX { 00142 00143 00144 // FOX System Defined Selector Types 00145 enum FXSelType { 00146 SEL_NONE, 00147 SEL_KEYPRESS, /// Key pressed 00148 SEL_KEYRELEASE, /// Key released 00149 SEL_LEFTBUTTONPRESS, /// Left mouse button pressed 00150 SEL_LEFTBUTTONRELEASE, /// Left mouse button released 00151 SEL_MIDDLEBUTTONPRESS, /// Middle mouse button pressed 00152 SEL_MIDDLEBUTTONRELEASE, /// Middle mouse button released 00153 SEL_RIGHTBUTTONPRESS, /// Right mouse button pressed 00154 SEL_RIGHTBUTTONRELEASE, /// Right mouse button released 00155 SEL_MOTION, /// Mouse motion 00156 SEL_ENTER, /// Mouse entered window 00157 SEL_LEAVE, /// Mouse left window 00158 SEL_FOCUSIN, /// Focus into window 00159 SEL_FOCUSOUT, /// Focus out of window 00160 SEL_KEYMAP, 00161 SEL_UNGRABBED, /// Lost the grab (Windows) 00162 SEL_PAINT, /// Must repaint window 00163 SEL_CREATE, 00164 SEL_DESTROY, 00165 SEL_UNMAP, 00166 SEL_MAP, 00167 SEL_CONFIGURE, // Resize 00168 SEL_SELECTION_LOST, // Widget lost selection 00169 SEL_SELECTION_GAINED, // Widget gained selection 00170 SEL_SELECTION_REQUEST, // Inquire selection data 00171 SEL_RAISED, // Window to top of stack 00172 SEL_LOWERED, // Window to bottom of stack 00173 SEL_CLOSE, // Close window 00174 SEL_DELETE, // Delete window 00175 SEL_MINIMIZE, // Iconified 00176 SEL_RESTORE, // No longer iconified or maximized 00177 SEL_MAXIMIZE, // Maximized 00178 SEL_UPDATE, // GUI update 00179 SEL_COMMAND, // GUI command 00180 SEL_CLICKED, // Clicked 00181 SEL_DOUBLECLICKED, // Double-clicked 00182 SEL_TRIPLECLICKED, // Triple-clicked 00183 SEL_MOUSEWHEEL, // Mouse wheel 00184 SEL_CHANGED, // GUI has changed 00185 SEL_VERIFY, // Verify change 00186 SEL_DESELECTED, // Deselected 00187 SEL_SELECTED, // Selected 00188 SEL_INSERTED, // Inserted 00189 SEL_REPLACED, // Replaced 00190 SEL_DELETED, // Deleted 00191 SEL_OPENED, // Opened 00192 SEL_CLOSED, // Closed 00193 SEL_EXPANDED, // Expanded 00194 SEL_COLLAPSED, // Collapsed 00195 SEL_BEGINDRAG, // Start a drag 00196 SEL_ENDDRAG, // End a drag 00197 SEL_DRAGGED, // Dragged 00198 SEL_LASSOED, // Lassoed 00199 SEL_TIMEOUT, // Timeout occurred 00200 SEL_SIGNAL, // Signal received 00201 SEL_CLIPBOARD_LOST, // Widget lost clipboard 00202 SEL_CLIPBOARD_GAINED, // Widget gained clipboard 00203 SEL_CLIPBOARD_REQUEST, // Inquire clipboard data 00204 SEL_CHORE, // Background chore 00205 SEL_FOCUS_SELF, // Focus on widget itself 00206 SEL_FOCUS_RIGHT, // Focus movements 00207 SEL_FOCUS_LEFT, 00208 SEL_FOCUS_DOWN, 00209 SEL_FOCUS_UP, 00210 SEL_FOCUS_NEXT, 00211 SEL_FOCUS_PREV, 00212 SEL_DND_ENTER, // Drag action entering potential drop target 00213 SEL_DND_LEAVE, // Drag action leaving potential drop target 00214 SEL_DND_DROP, // Drop on drop target 00215 SEL_DND_MOTION, // Drag position changed over potential drop target 00216 SEL_DND_REQUEST, // Inquire drag and drop data 00217 SEL_IO_READ, // Read activity on a pipe 00218 SEL_IO_WRITE, // Write activity on a pipe 00219 SEL_IO_EXCEPT, // Except activity on a pipe 00220 SEL_PICKED, // Picked some location 00221 SEL_LAST // Last message 00222 }; 00223 00224 00225 /// FOX Keyboard and Button states 00226 enum { 00227 SHIFTMASK = 0x001, /// Shift key is down 00228 CAPSLOCKMASK = 0x002, /// Caps Lock key is down 00229 CONTROLMASK = 0x004, /// Ctrl key is down 00230 ALTMASK = 0x008, /// Alt key is down 00231 METAMASK = 0x040, /// Meta key is down 00232 NUMLOCKMASK = 0x010, /// Num Lock key is down 00233 SCROLLLOCKMASK = 0x0E0, /// Scroll Lock key is down (seems to vary) 00234 LEFTBUTTONMASK = 0x100, /// Left mouse button is down 00235 MIDDLEBUTTONMASK = 0x200, /// Middle mouse button is down 00236 RIGHTBUTTONMASK = 0x400 /// Right mouse button is down 00237 }; 00238 00239 00240 /// FOX Mouse buttons 00241 enum { 00242 LEFTBUTTON = 1, 00243 MIDDLEBUTTON = 2, 00244 RIGHTBUTTON = 3 00245 }; 00246 00247 00248 /// FOX window crossing modes 00249 enum { 00250 CROSSINGNORMAL, /// Normal crossing event 00251 CROSSINGGRAB, /// Crossing due to mouse grab 00252 CROSSINGUNGRAB /// Crossing due to mouse ungrab 00253 }; 00254 00255 00256 /// FOX window visibility modes 00257 enum { 00258 VISIBILITYTOTAL, 00259 VISIBILITYPARTIAL, 00260 VISIBILITYNONE 00261 }; 00262 00263 00264 /// Options for fxfilematch 00265 enum { 00266 FILEMATCH_FILE_NAME = 1, /// No wildcard can ever match `/' 00267 FILEMATCH_NOESCAPE = 2, /// Backslashes don't quote special chars 00268 FILEMATCH_PERIOD = 4, /// Leading `.' is matched only explicitly 00269 FILEMATCH_LEADING_DIR = 8, /// Ignore `/...' after a match 00270 FILEMATCH_CASEFOLD = 16 /// Compare without regard to case 00271 }; 00272 00273 00274 /// Drag and drop actions 00275 enum FXDragAction { 00276 DRAG_REJECT = 0, /// Reject all drop actions 00277 DRAG_ACCEPT = 1, /// Accept any drop action 00278 DRAG_COPY = 2, /// Copy 00279 DRAG_MOVE = 3, /// Move 00280 DRAG_LINK = 4, /// Link 00281 DRAG_PRIVATE = 5 /// Private 00282 }; 00283 00284 00285 /// Origin of data 00286 enum FXDNDOrigin { 00287 FROM_SELECTION = 0, /// Primary selection 00288 FROM_CLIPBOARD = 1, /// Clipboard 00289 FROM_DRAGNDROP = 2 /// Drag and drop source 00290 }; 00291 00292 00293 /// Exponent display 00294 enum FXExponent { 00295 EXP_NEVER=FALSE, /// Never use exponential notation 00296 EXP_ALWAYS=TRUE, /// Always use exponential notation 00297 EXP_AUTO=MAYBE /// Use exponential notation if needed 00298 }; 00299 00300 00301 /// Search modes for search/replace dialogs 00302 enum { 00303 SEARCH_FORWARD = 0, /// Search forward (default) 00304 SEARCH_BACKWARD = 1, /// Search backward 00305 SEARCH_NOWRAP = 0, /// Don't wrap (default) 00306 SEARCH_WRAP = 2, /// Wrap around to start 00307 SEARCH_EXACT = 0, /// Exact match (default) 00308 SEARCH_IGNORECASE = 4, /// Ignore case 00309 SEARCH_REGEX = 8, /// Regular expression match 00310 SEARCH_PREFIX = 16 /// Prefix of subject string 00311 }; 00312 00313 00314 /********************************* Typedefs **********************************/ 00315 00316 // Forward declarations 00317 class FXObject; 00318 class FXStream; 00319 class FXString; 00320 00321 00322 // Streamable types; these are fixed size! 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 // Integral types large enough to hold value of a pointer 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 // Handle to something in server 00355 #ifndef WIN32 00356 typedef unsigned long FXID; 00357 #else 00358 typedef void* FXID; 00359 #endif 00360 00361 // Time since January 1, 1970 (UTC) 00362 typedef long FXTime; 00363 00364 // Pixel type (could be color index) 00365 typedef unsigned long FXPixel; 00366 00367 // RGBA pixel value 00368 typedef FXuint FXColor; 00369 00370 // Hot key 00371 typedef FXuint FXHotKey; 00372 00373 // Drag type 00374 #ifndef WIN32 00375 typedef FXID FXDragType; 00376 #else 00377 typedef FXushort FXDragType; 00378 #endif 00379 00380 // Input source handle type 00381 #ifndef WIN32 00382 typedef FXint FXInputHandle; 00383 #else 00384 typedef void* FXInputHandle; 00385 #endif 00386 00387 // Raw event type 00388 #ifndef WIN32 00389 typedef _XEvent FXRawEvent; 00390 #else 00391 typedef tagMSG FXRawEvent; 00392 #endif 00393 00394 00395 /********************************** Macros ***********************************/ 00396 00397 00398 /// Abolute value 00399 #define FXABS(val) (((val)>=0)?(val):-(val)) 00400 00401 /// Return the maximum of a or b 00402 #define FXMAX(a,b) (((a)>(b))?(a):(b)) 00403 00404 /// Return the minimum of a or b 00405 #define FXMIN(a,b) (((a)>(b))?(b):(a)) 00406 00407 /// Return the minimum of x, y and z 00408 #define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z)) 00409 00410 /// Return the maximum of x, y and z 00411 #define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z)) 00412 00413 /// Return minimum and maximum of a, b 00414 #define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a))) 00415 00416 /// Clamp value x to range [lo..hi] 00417 #define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x))) 00418 00419 /// Swap a pair of numbers 00420 #define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t)) 00421 00422 /// Linear interpolation between a and b, where 0<=f<=1 00423 #define FXLERP(a,b,f) ((a)+((b)-(a))*(f)) 00424 00425 /// Offset of member in a structure 00426 #define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0)) 00427 00428 /// Number of elements in a static array 00429 #define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0])) 00430 00431 /// Container class of a member class 00432 #define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem))) 00433 00434 /// Make int out of two shorts 00435 #define MKUINT(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16)) 00436 00437 /// Make selector from message type and message id 00438 #define FXSEL(type,id) ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16)) 00439 00440 /// Get type from selector 00441 #define FXSELTYPE(s) ((FX::FXushort)(((s)>>16)&0xffff)) 00442 00443 /// Get ID from selector 00444 #define FXSELID(s) ((FX::FXushort)((s)&0xffff)) 00445 00446 /// Reverse bits in byte 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 // The order in memory is [R G B A] matches that in FXColor 00450 00451 // Definitions for big-endian machines 00452 #if FOX_BIGENDIAN == 1 00453 00454 /// Make RGBA color 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 /// Make RGB color 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 /// Get red value from RGBA color 00461 #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff)) 00462 00463 /// Get green value from RGBA color 00464 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff)) 00465 00466 /// Get blue value from RGBA color 00467 #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff)) 00468 00469 /// Get alpha value from RGBA color 00470 #define FXALPHAVAL(rgba) ((FX::FXuchar)((rgba)&0xff)) 00471 00472 /// Get component value of RGBA color 00473 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff)) 00474 00475 #endif 00476 00477 // Definitions for little-endian machines 00478 #if FOX_BIGENDIAN == 0 00479 00480 /// Make RGBA color 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 /// Make RGB color 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 /// Get red value from RGBA color 00487 #define FXREDVAL(rgba) ((FX::FXuchar)((rgba)&0xff)) 00488 00489 /// Get green value from RGBA color 00490 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff)) 00491 00492 /// Get blue value from RGBA color 00493 #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff)) 00494 00495 /// Get alpha value from RGBA color 00496 #define FXALPHAVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff)) 00497 00498 /// Get component value of RGBA color 00499 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff)) 00500 00501 #endif 00502 00503 00504 /** 00505 * FXASSERT() prints out a message when the expression fails, 00506 * and nothing otherwise. Unlike assert(), FXASSERT() will not 00507 * terminate the execution of the application. 00508 * When compiling your application for release, all assertions 00509 * are compiled out; thus there is no impact on execution speed. 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 * FXTRACE() allows you to trace the execution of your application 00520 * with increasing levels of detail the higher the trace level. 00521 * The trace level is determined by variable fxTraceLevel, which 00522 * may be set from the command line with "-tracelevel <level>". 00523 * When compiling your application for release, all trace statements 00524 * are compiled out, just like FXASSERT. 00525 * A statement like: FXTRACE((10,"The value of x=%d\n",x)) will 00526 * generate output only if fxTraceLevel is set to 11 or greater. 00527 * The default value fxTraceLevel=0 will block all trace outputs. 00528 * Note the double parentheses! 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 * Allocate no elements of type to the specified pointer. 00539 * Return FALSE if size!=0 and allocation fails, TRUE otherwise. 00540 * An allocation of a zero size block returns a NULL pointer. 00541 */ 00542 #define FXMALLOC(ptr,type,no) (FX::fxmalloc((void **)(ptr),sizeof(type)*(no))) 00543 00544 /** 00545 * Allocate no elements of type to the specified pointer, and clear this memory to zero. 00546 * Return FALSE if size!=0 and allocation fails, TRUE otherwise. 00547 * An allocation of a zero size block returns a NULL pointer. 00548 */ 00549 #define FXCALLOC(ptr,type,no) (FX::fxcalloc((void **)(ptr),sizeof(type)*(no))) 00550 00551 /** 00552 * Resize a previously allocated block of memory. 00553 * Returns FALSE if size!=0 and reallocation fails, TRUE otherwise. 00554 * If reallocation fails, pointer is left to point to old block; a reallocation 00555 * to a zero size block has the effect of freeing it. 00556 */ 00557 #define FXRESIZE(ptr,type,no) (FX::fxresize((void **)(ptr),sizeof(type)*(no))) 00558 00559 /** 00560 * Allocate and initialize memory from another block. 00561 * Return FALSE if size!=0 and source!=NULL and allocation fails, TRUE otherwise. 00562 * An allocation of a zero size block returns a NULL pointer. 00563 */ 00564 #define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup((void **)(ptr),(const void*)(src),sizeof(type)*(no))) 00565 00566 /** 00567 * Free a block of memory allocated with either FXMALLOC, FXCALLOC, FXRESIZE, or FXMEMDUP. 00568 * It is OK to call free a NULL pointer. 00569 */ 00570 #define FXFREE(ptr) (FX::fxfree((void **)(ptr))) 00571 00572 00573 /** 00574 * These are some of the ISO C99 standard single-precision transcendental functions. 00575 * On LINUX, specify _GNU_SOURCE or _ISOC99_SOURCE to enable native implementation; 00576 * otherwise, these macros will be used. 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 /********************************** Globals **********************************/ 00598 00599 /// Simple, thread-safe, random number generator 00600 extern FXAPI FXuint fxrandom(FXuint& seed); 00601 00602 /// Allocate memory 00603 extern FXAPI FXint fxmalloc(void** ptr,unsigned long size); 00604 00605 /// Allocate cleaned memory 00606 extern FXAPI FXint fxcalloc(void** ptr,unsigned long size); 00607 00608 /// Resize memory 00609 extern FXAPI FXint fxresize(void** ptr,unsigned long size); 00610 00611 /// Duplicate memory 00612 extern FXAPI FXint fxmemdup(void** ptr,const void* src,unsigned long size); 00613 00614 /// Free memory, resets ptr to NULL afterward 00615 extern FXAPI void fxfree(void** ptr); 00616 00617 /// Error routine 00618 extern FXAPI void fxerror(const char* format,...) FX_PRINTF(1,2) ; 00619 00620 /// Warning routine 00621 extern FXAPI void fxwarning(const char* format,...) FX_PRINTF(1,2) ; 00622 00623 /// Log message to [typically] stderr 00624 extern FXAPI void fxmessage(const char* format,...) FX_PRINTF(1,2) ; 00625 00626 /// Assert failed routine:- usually not called directly but called through FXASSERT 00627 extern FXAPI void fxassert(const char* expression,const char* filename,unsigned int lineno); 00628 00629 /// Trace printout routine:- usually not called directly but called through FXTRACE 00630 extern FXAPI void fxtrace(unsigned int level,const char* format,...) FX_PRINTF(2,3) ; 00631 00632 /// Sleep n microseconds 00633 extern FXAPI void fxsleep(unsigned int n); 00634 00635 /// Match a file name with a pattern 00636 extern FXAPI FXint fxfilematch(const char *pattern,const char *string,FXuint flags=(FILEMATCH_NOESCAPE|FILEMATCH_FILE_NAME)); 00637 00638 /// Get highlight color 00639 extern FXAPI FXColor makeHiliteColor(FXColor clr); 00640 00641 /// Get shadow color 00642 extern FXAPI FXColor makeShadowColor(FXColor clr); 00643 00644 /// Get process id 00645 extern FXAPI FXint fxgetpid(); 00646 00647 /// Convert to MSDOS 00648 extern FXAPI FXbool fxtoDOS(FXchar*& string,FXint& len); 00649 00650 /// Convert from MSDOS format 00651 extern FXAPI FXbool fxfromDOS(FXchar*& string,FXint& len); 00652 00653 /// Duplicate string 00654 extern FXAPI FXchar *fxstrdup(const FXchar* str); 00655 00656 /// Calculate a hash value from a string 00657 extern FXAPI FXuint fxstrhash(const FXchar* str); 00658 00659 /// Get RGB value from color name 00660 extern FXAPI FXColor fxcolorfromname(const FXchar* colorname); 00661 00662 /// Get name of (closest) color to RGB 00663 extern FXAPI FXchar* fxnamefromcolor(FXchar *colorname,FXColor color); 00664 00665 /// Convert RGB to HSV 00666 extern FXAPI void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b); 00667 00668 /// Convert HSV to RGB 00669 extern FXAPI void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v); 00670 00671 /// Floating point number classification: 0=OK, +/-1=Inf, +/-2=NaN 00672 extern FXAPI FXint fxieeefloatclass(FXfloat number); 00673 extern FXAPI FXint fxieeedoubleclass(FXdouble number); 00674 00675 /// Parse geometry, a-la X11 geometry specification 00676 extern FXAPI FXint fxparsegeometry(const FXchar *string,FXint& x,FXint& y,FXint& w,FXint& h); 00677 00678 /// True if executable with given path is a console application 00679 extern FXbool fxisconsole(const FXchar *path); 00680 00681 /// Version number that the library has been compiled with 00682 extern FXAPI const FXuchar fxversion[3]; 00683 00684 00685 /// Controls tracing level 00686 extern FXAPI unsigned int fxTraceLevel; 00687 00688 /** 00689 * Parse accelerator from string, yielding modifier and 00690 * key code. For example, fxparseAccel("Ctl+Shift+X") 00691 * yields MKUINT(KEY_X,CONTROLMASK|SHIFTMASK). 00692 */ 00693 extern FXAPI FXHotKey fxparseAccel(const FXString& string); 00694 00695 /** 00696 * Parse hot key from string, yielding modifier and 00697 * key code. For example, fxparseHotKey(""Salt && &Pepper!"") 00698 * yields MKUINT(KEY_p,ALTMASK). 00699 */ 00700 extern FXAPI FXHotKey fxparseHotKey(const FXString& string); 00701 00702 /** 00703 * Obtain hot key offset in string, or -1 if not found. 00704 * For example, findHotKey("Salt && &Pepper!") yields 7. 00705 */ 00706 extern FXAPI FXint fxfindHotKey(const FXString& string); 00707 00708 /** 00709 * Strip hot key combination from the string. 00710 * For example, stripHotKey("Salt && &Pepper") should 00711 * yield "Salt & Pepper". 00712 */ 00713 extern FXAPI FXString fxstripHotKey(const FXString& string); 00714 00715 } 00716 00717 #endif

Copyright © 1997-2004 Jeroen van der Zijp