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

fxdefs.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                     FOX Definitions, Types, and Macros                        *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2010 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXDEFS_H
00022 #define FXDEFS_H
00023 
00024 
00025 /********************************  Definitions  ********************************/
00026 
00027 // Truth values
00028 #ifndef TRUE
00029 #define TRUE 1
00030 #endif
00031 #ifndef FALSE
00032 #define FALSE 0
00033 #endif
00034 #ifndef MAYBE
00035 #define MAYBE 2
00036 #endif
00037 #ifndef NULL
00038 #define NULL 0
00039 #endif
00040 
00041 // Path separator
00042 #ifdef WIN32
00043 #define PATHSEP '\\'
00044 #define PATHSEPSTRING "\\"
00045 #define PATHLISTSEP ';'
00046 #define PATHLISTSEPSTRING ";"
00047 #define ISPATHSEP(c) ((c)=='\\' || (c)=='/')
00048 #else
00049 #define PATHSEP '/'
00050 #define PATHSEPSTRING "/"
00051 #define PATHLISTSEP ':'
00052 #define PATHLISTSEPSTRING ":"
00053 #define ISPATHSEP(c) ((c)=='/')
00054 #endif
00055 
00056 // End Of Line
00057 #ifdef WIN32
00058 #define ENDLINE "\r\n"
00059 #else
00060 #define ENDLINE "\n"
00061 #endif
00062 
00063 
00064 // For Windows
00065 #ifdef _DEBUG
00066 #ifndef DEBUG
00067 #define DEBUG
00068 #endif
00069 #endif
00070 #ifdef _NDEBUG
00071 #ifndef NDEBUG
00072 #define NDEBUG
00073 #endif
00074 #endif
00075 
00076 
00077 // Shared library support
00078 #ifdef WIN32
00079 #define FXLOCAL
00080 #define FXEXPORT __declspec(dllexport)
00081 #define FXIMPORT __declspec(dllimport)
00082 #else
00083 #if defined(__GNUC__) && (__GNUC__ >= 4)
00084 #define FXLOCAL  __attribute__((visibility("hidden")))
00085 #define FXEXPORT __attribute__((visibility("default")))
00086 #define FXIMPORT
00087 #else
00088 #define FXLOCAL
00089 #define FXEXPORT
00090 #define FXIMPORT
00091 #endif
00092 #endif
00093 
00094 
00095 // Define FXAPI for DLL builds
00096 #ifdef FOXDLL
00097 #ifdef FOXDLL_EXPORTS
00098 #define FXAPI FXEXPORT
00099 #define FXTEMPLATE_EXTERN
00100 #else
00101 #define FXAPI FXIMPORT
00102 #define FXTEMPLATE_EXTERN extern
00103 #endif
00104 #else
00105 #define FXAPI
00106 #define FXTEMPLATE_EXTERN
00107 #endif
00108 
00109 
00110 // Data alignment attribute
00111 #if defined(__GNUC__)
00112 #define FXALIGNED(x)    __attribute__((aligned(x)))
00113 #elif defined(_MSC_VER)
00114 #define FXALIGNED(x)    __declspec(align(x))
00115 #else
00116 #define FXALIGNED(x)
00117 #endif
00118 
00119 
00120 // Thread-local storage attribute
00121 #if defined(__GNUC__)
00122 #define FXTHREADLOCAL   __thread
00123 #elif defined(_MSC_VER)
00124 #define FXTHREADLOCAL   __declspec(thread)
00125 #else
00126 #define FXTHREADLOCAL
00127 #endif
00128 
00129 
00130 // Callback
00131 #ifdef WIN32
00132 #ifndef CALLBACK
00133 #define CALLBACK __stdcall
00134 #endif
00135 #endif
00136 
00137 
00138 // Disable some warnings in VC++
00139 #ifdef _MSC_VER
00140 #pragma warning(disable: 4251)
00141 #pragma warning(disable: 4231)
00142 #pragma warning(disable: 4244)
00143 #endif
00144 
00145 
00146 // Checking printf and scanf format strings
00147 #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__)
00148 #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg)))
00149 #define FX_SCANF(fmt,arg)  __attribute__((format(scanf,fmt,arg)))
00150 #define FX_FORMAT(arg) __attribute__((format_arg(arg)))
00151 #else
00152 #define FX_PRINTF(fmt,arg)
00153 #define FX_SCANF(fmt,arg)
00154 #define FX_FORMAT(arg)
00155 #endif
00156 
00157 // Raw event type
00158 #ifdef WIN32
00159 struct tagMSG;
00160 #else
00161 union _XEvent;
00162 #endif
00163 
00164 
00165 namespace FX {
00166 
00167 
00168 /// Exponent display
00169 enum FXExponent {
00170   EXP_NEVER=FALSE,                  /// Never use exponential notation
00171   EXP_ALWAYS=TRUE,                  /// Always use exponential notation
00172   EXP_AUTO=MAYBE                    /// Use exponential notation if needed
00173   };
00174 
00175 
00176 /// Search modes for search/replace dialogs
00177 enum {
00178   SEARCH_FORWARD      = 0,    /// Search forward (default)
00179   SEARCH_BACKWARD     = 1,    /// Search backward
00180   SEARCH_NOWRAP       = 0,    /// Don't wrap (default)
00181   SEARCH_WRAP         = 2,    /// Wrap around to start
00182   SEARCH_EXACT        = 0,    /// Exact match (default)
00183   SEARCH_IGNORECASE   = 4,    /// Ignore case
00184   SEARCH_REGEX        = 8,    /// Regular expression match
00185   SEARCH_PREFIX       = 16    /// Prefix of subject string
00186   };
00187 
00188 
00189 /*********************************  Typedefs  **********************************/
00190 
00191 // Forward declarations
00192 class                          FXObject;
00193 class                          FXStream;
00194 class                          FXString;
00195 
00196 
00197 // Streamable types; these are fixed size!
00198 typedef char                   FXchar;
00199 typedef unsigned char          FXuchar;
00200 typedef bool                   FXbool;
00201 typedef unsigned short         FXushort;
00202 typedef short                  FXshort;
00203 typedef unsigned int           FXuint;
00204 typedef int                    FXint;
00205 typedef float                  FXfloat;
00206 typedef double                 FXdouble;
00207 #ifdef WIN32
00208 typedef unsigned int           FXwchar;
00209 #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
00210 typedef unsigned short         FXnchar;
00211 #elif defined(__WATCOMC__) && !defined(_WCHAR_T_DEFINED)
00212 typedef long char FXnchar;
00213 #else
00214 typedef wchar_t                FXnchar;
00215 #endif
00216 #else
00217 typedef wchar_t                FXwchar;
00218 typedef unsigned short         FXnchar;
00219 #endif
00220 #if defined(__LP64__) || defined(_LP64) || (_MIPS_SZLONG == 64) || (__WORDSIZE == 64)
00221 typedef unsigned long          FXulong;
00222 typedef long                   FXlong;
00223 #elif defined(_MSC_VER) || (defined(__BCPLUSPLUS__) && __BORLANDC__ > 0x500) || defined(__WATCOM_INT64__)
00224 typedef unsigned __int64       FXulong;
00225 typedef __int64                FXlong;
00226 #elif defined(__GNUG__) || defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__MWERKS__) || defined(__SC__) || defined(_LONGLONG)
00227 typedef unsigned long long     FXulong;
00228 typedef long long              FXlong;
00229 #else
00230 #error "FXlong and FXulong not defined for this architecture!"
00231 #endif
00232 
00233 // Integral types large enough to hold value of a pointer
00234 #if defined(_MSC_VER) && defined(_WIN64)
00235 typedef __int64                FXival;
00236 typedef unsigned __int64       FXuval;
00237 #else
00238 typedef long                   FXival;
00239 typedef unsigned long          FXuval;
00240 #endif
00241 
00242 
00243 // Handle to something in server
00244 #ifdef WIN32
00245 typedef void*                  FXID;
00246 #else
00247 typedef unsigned long          FXID;
00248 #endif
00249 
00250 // Time since January 1, 1970 (UTC)
00251 typedef FXlong                 FXTime;
00252 
00253 // Pixel type (could be color index)
00254 typedef unsigned long          FXPixel;
00255 
00256 // RGBA pixel value
00257 typedef FXuint                 FXColor;
00258 
00259 // Hot key
00260 typedef FXuint                 FXHotKey;
00261 
00262 // Input source handle type
00263 #ifdef WIN32
00264 typedef void*                  FXInputHandle;
00265 #else
00266 typedef FXint                  FXInputHandle;
00267 #endif
00268 
00269 // Raw event type
00270 #ifdef WIN32
00271 typedef tagMSG    FXRawEvent;
00272 #else
00273 typedef _XEvent   FXRawEvent;
00274 #endif
00275 
00276 
00277 /// Drag and drop data type
00278 #ifdef WIN32
00279 typedef FXushort  FXDragType;
00280 #else
00281 typedef FXID      FXDragType;
00282 #endif
00283 
00284 
00285 /// Pi
00286 const FXdouble PI=3.1415926535897932384626433833;
00287 
00288 /// Euler constant
00289 const FXdouble EULER=2.7182818284590452353602874713;
00290 
00291 /// Multiplier for degrees to radians
00292 const FXdouble DTOR=0.0174532925199432957692369077;
00293 
00294 /// Multiplier for radians to degrees
00295 const FXdouble RTOD=57.295779513082320876798154814;
00296 
00297 #if !defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__SC__) || defined(__BCPLUSPLUS__)
00298 /// A time in the far, far future
00299 const FXTime forever=9223372036854775807LL;
00300 #else
00301 /// A time in the far, far future
00302 const FXTime forever=9223372036854775807L;
00303 #endif
00304 
00305 
00306 /**********************************  Macros  ***********************************/
00307 
00308 /// Branch prediction optimization
00309 #if __GNUC__ >= 3
00310 #define __likely(cond)    __builtin_expect(!!(cond),1)
00311 #define __unlikely(cond)  __builtin_expect(!!(cond),0)
00312 #else
00313 #define __likely(cond)    (!!(cond))
00314 #define __unlikely(cond)  (!!(cond))
00315 #endif
00316 
00317 /// Abolute value
00318 #define FXABS(val) (((val)>=0)?(val):-(val))
00319 
00320 /// Return 1 if val >= 0 and -1 otherwise
00321 #define FXSGN(val) (((val)<0)?-1:1)
00322 
00323 /// Return 1 if val > 0, -1 if val < 0, and 0 otherwise
00324 #define FXSGNZ(val) ((val)<0?-1:(val)>0?1:0)
00325 
00326 /// Return the maximum of a or b
00327 #define FXMAX(a,b) (((a)>(b))?(a):(b))
00328 
00329 /// Return the minimum of a or b
00330 #define FXMIN(a,b) (((a)>(b))?(b):(a))
00331 
00332 /// Return the minimum of x, y and z
00333 #define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z))
00334 
00335 /// Return the maximum of x, y and z
00336 #define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z))
00337 
00338 /// Return the minimum of x, y, z, and w
00339 #define FXMIN4(x,y,z,w) (FXMIN(FXMIN(x,y),FXMIN(z,w)))
00340 
00341 /// Return the maximum of of x, y, z, and w
00342 #define FXMAX4(x,y,z,w) (FXMAX(FXMAX(x,y),FXMAX(z,w)))
00343 
00344 /// Return minimum and maximum of a, b
00345 #define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a)))
00346 
00347 /// Clamp value x to range [lo..hi]
00348 #define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x)))
00349 
00350 /// Swap a pair of numbers
00351 #define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t))
00352 
00353 /// Linear interpolation between a and b, where 0<=f<=1
00354 #define FXLERP(a,b,f) ((a)+((b)-(a))*(f))
00355 
00356 /// Offset of member in a structure
00357 #define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0))
00358 
00359 /// Number of elements in a static array
00360 #define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0]))
00361 
00362 /// Container class of a member class
00363 #define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem)))
00364 
00365 /// Make int out of two shorts
00366 #define MKUINT(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16))
00367 
00368 /// Make selector from message type and message id
00369 #define FXSEL(type,id) ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16))
00370 
00371 /// Get type from selector
00372 #define FXSELTYPE(s) ((FX::FXushort)(((s)>>16)&0xffff))
00373 
00374 /// Get ID from selector
00375 #define FXSELID(s) ((FX::FXushort)((s)&0xffff))
00376 
00377 /// Reverse bits in byte
00378 #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))
00379 
00380 /// Test if character c is at the start of a utf8 sequence
00381 #define FXISUTF(c) (((c)&0xC0)!=0x80)
00382 
00383 /// Average of two FXColor ca and FXColor cb
00384 #define FXAVGCOLOR(ca,cb) (((ca)&(cb))+((((ca)^(cb))&0xFEFEFEFE)>>1))
00385 
00386 
00387 // Definitions for big-endian machines
00388 #if FOX_BIGENDIAN == 1
00389 
00390 /// Make RGBA color
00391 #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)))
00392 
00393 /// Make RGB color
00394 #define FXRGB(r,g,b)       (((FX::FXuint)(FX::FXuchar)(r)<<24) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<8) | 0x000000ff)
00395 
00396 /// Get red value from RGBA color
00397 #define FXREDVAL(rgba)     ((FX::FXuchar)(((rgba)>>24)&0xff))
00398 
00399 /// Get green value from RGBA color
00400 #define FXGREENVAL(rgba)   ((FX::FXuchar)(((rgba)>>16)&0xff))
00401 
00402 /// Get blue value from RGBA color
00403 #define FXBLUEVAL(rgba)    ((FX::FXuchar)(((rgba)>>8)&0xff))
00404 
00405 /// Get alpha value from RGBA color
00406 #define FXALPHAVAL(rgba)   ((FX::FXuchar)((rgba)&0xff))
00407 
00408 /// Get component value of RGBA color
00409 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff))
00410 
00411 #endif
00412 
00413 
00414 // Definitions for little-endian machines
00415 #if FOX_BIGENDIAN == 0
00416 
00417 /// Make RGBA color
00418 #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))
00419 
00420 /// Make RGB color
00421 #define FXRGB(r,g,b)       (((FX::FXuint)(FX::FXuchar)(r)) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)<<16) | 0xff000000)
00422 
00423 /// Get red value from RGBA color
00424 #define FXREDVAL(rgba)     ((FX::FXuchar)((rgba)&0xff))
00425 
00426 /// Get green value from RGBA color
00427 #define FXGREENVAL(rgba)   ((FX::FXuchar)(((rgba)>>8)&0xff))
00428 
00429 /// Get blue value from RGBA color
00430 #define FXBLUEVAL(rgba)    ((FX::FXuchar)(((rgba)>>16)&0xff))
00431 
00432 /// Get alpha value from RGBA color
00433 #define FXALPHAVAL(rgba)   ((FX::FXuchar)(((rgba)>>24)&0xff))
00434 
00435 /// Get component value of RGBA color
00436 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff))
00437 
00438 #endif
00439 
00440 
00441 /**
00442 * FXASSERT() prints out a message when the expression fails,
00443 * and nothing otherwise.  Unlike assert(), FXASSERT() will not
00444 * terminate the execution of the application.
00445 * When compiling your application for release, all assertions
00446 * are compiled out; thus there is no impact on execution speed.
00447 */
00448 #ifndef NDEBUG
00449 #define FXASSERT(exp) (__likely(exp)?((void)0):(void)FX::fxassert(#exp,__FILE__,__LINE__))
00450 #else
00451 #define FXASSERT(exp) ((void)0)
00452 #endif
00453 
00454 
00455 /**
00456 * FXVERIFY prints out a message when the expression fails,
00457 * and nothing otherwise.
00458 * When compiling your application for release, these messages
00459 * are compiled out, but unlike FXASSERT, FXVERIFY will still execute
00460 * the expression.
00461 */
00462 #ifndef NDEBUG
00463 #define FXVERIFY(exp) (__likely(exp)?((void)0):(void)FX::fxverify(#exp,__FILE__,__LINE__))
00464 #else
00465 #define FXVERIFY(exp) ((void)(exp))
00466 #endif
00467 
00468 
00469 /**
00470 * FXTRACE() allows you to trace the execution of your application
00471 * with increasing levels of detail the higher the trace level.
00472 * The trace level is determined by variable fxTraceLevel, which
00473 * may be set from the command line with "-tracelevel <level>".
00474 * When compiling your application for release, all trace statements
00475 * are compiled out, just like FXASSERT.
00476 * A statement like: FXTRACE((10,"The value of x=%d\n",x)) will
00477 * generate output only if fxTraceLevel is set to 11 or greater.
00478 * The default value fxTraceLevel=0 will block all trace outputs.
00479 * Note the double parentheses!
00480 */
00481 #ifndef NDEBUG
00482 #define FXTRACE(arguments) FX::fxtrace arguments
00483 #else
00484 #define FXTRACE(arguments) ((void)0)
00485 #endif
00486 
00487 /**
00488 * Allocate a memory block of no elements of type and store a pointer
00489 * to it into the address pointed to by ptr.
00490 * Return false if size!=0 and allocation fails, true otherwise.
00491 * An allocation of a zero size block returns a NULL pointer.
00492 */
00493 #define FXMALLOC(ptr,type,no)     (FX::fxmalloc((void **)(ptr),sizeof(type)*(no)))
00494 
00495 /**
00496 * Allocate a zero-filled memory block no elements of type and store a pointer
00497 * to it into the address pointed to by ptr.
00498 * Return false if size!=0 and allocation fails, true otherwise.
00499 * An allocation of a zero size block returns a NULL pointer.
00500 */
00501 #define FXCALLOC(ptr,type,no)     (FX::fxcalloc((void **)(ptr),sizeof(type)*(no)))
00502 
00503 /**
00504 * Resize the memory block referred to by the pointer at the address ptr, to a
00505 * hold no elements of type.
00506 * Returns false if size!=0 and reallocation fails, true otherwise.
00507 * If reallocation fails, pointer is left to point to old block; a reallocation
00508 * to a zero size block has the effect of freeing it.
00509 * The ptr argument must be the address where the pointer to the allocated
00510 * block is to be stored.
00511 */
00512 #define FXRESIZE(ptr,type,no)     (FX::fxresize((void **)(ptr),sizeof(type)*(no)))
00513 
00514 /**
00515 * Allocate and initialize memory from another block.
00516 * Return false if size!=0 and source!=NULL and allocation fails, true otherwise.
00517 * An allocation of a zero size block returns a NULL pointer.
00518 * The ptr argument must be the address where the pointer to the allocated
00519 * block is to be stored.
00520 */
00521 #define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup((void **)(ptr),(const void*)(src),sizeof(type)*(no)))
00522 
00523 /**
00524 * Free a block of memory allocated with either FXMALLOC, FXCALLOC, FXRESIZE, or FXMEMDUP.
00525 * It is OK to call free a NULL pointer.  The argument must be the address of the
00526 * pointer to the block to be released.  The pointer is set to NULL to prevent
00527 * any further references to the block after releasing it.
00528 */
00529 #define FXFREE(ptr)               (FX::fxfree((void **)(ptr)))
00530 
00531 
00532 /**
00533 * These are some of the ISO C99 standard single-precision transcendental functions.
00534 * On LINUX, specify _GNU_SOURCE or _ISOC99_SOURCE to enable native implementation;
00535 * otherwise, these macros will be used.  Apple OS-X implements fabsf(x), ceilf(x),
00536 * floorf(x), and fmodf(x,y).
00537 * Define FLOAT_MATH_FUNCTIONS if these functions are available in some other
00538 * library you're linking to.
00539 */
00540 #ifdef __OpenBSD__
00541 #define FLOAT_MATH_FUNCTIONS
00542 #endif
00543 #ifndef FLOAT_MATH_FUNCTIONS
00544 #ifndef __USE_ISOC99
00545 #ifndef __APPLE__
00546 #define fabsf(x)    ((float)fabs((double)(x)))
00547 #define ceilf(x)    ((float)ceil((double)(x)))
00548 #define floorf(x)   ((float)floor((double)(x)))
00549 #define fmodf(x,y)  ((float)fmod((double)(x),(double)(y)))
00550 #endif
00551 #define sqrtf(x)    ((float)sqrt((double)(x)))
00552 #define sinf(x)     ((float)sin((double)(x)))
00553 #define cosf(x)     ((float)cos((double)(x)))
00554 #define tanf(x)     ((float)tan((double)(x)))
00555 #define asinf(x)    ((float)asin((double)(x)))
00556 #define acosf(x)    ((float)acos((double)(x)))
00557 #define atanf(x)    ((float)atan((double)(x)))
00558 #define atan2f(y,x) ((float)atan2((double)(y),(double)(x)))
00559 #define powf(x,y)   ((float)pow((double)(x),(double)(y)))
00560 #define expf(x)     ((float)exp((double)(x)))
00561 #define logf(x)     ((float)log((double)(x)))
00562 #define log10f(x)   ((float)log10((double)(x)))
00563 #endif
00564 #endif
00565 
00566 
00567 /**********************************  Globals  **********************************/
00568 
00569 /// Simple, thread-safe xor-shifting random number generator (initial seed should be non-zero)
00570 extern FXAPI FXuint fxrandom(FXuint& seed);
00571 
00572 /// Allocate memory
00573 extern FXAPI FXbool fxmalloc(void** ptr,unsigned long size);
00574 
00575 /// Allocate cleaned memory
00576 extern FXAPI FXbool fxcalloc(void** ptr,unsigned long size);
00577 
00578 /// Resize memory
00579 extern FXAPI FXbool fxresize(void** ptr,unsigned long size);
00580 
00581 /// Duplicate memory
00582 extern FXAPI FXbool fxmemdup(void** ptr,const void* src,unsigned long size);
00583 
00584 /// Free memory, resets ptr to NULL afterward
00585 extern FXAPI void fxfree(void** ptr);
00586 
00587 /// Error routine
00588 extern FXAPI void fxerror(const FXchar* format,...) FX_PRINTF(1,2) ;
00589 
00590 /// Warning routine
00591 extern FXAPI void fxwarning(const FXchar* format,...) FX_PRINTF(1,2) ;
00592 
00593 /// Log message to [typically] stderr
00594 extern FXAPI void fxmessage(const FXchar* format,...) FX_PRINTF(1,2) ;
00595 
00596 /// Assert failed routine:- usually not called directly but called through FXASSERT
00597 extern FXAPI void fxassert(const FXchar* expression,const FXchar* filename,unsigned int lineno);
00598 
00599 /// Verify failed routine:- usually not called directly but called through FXVERIFY
00600 extern FXAPI void fxverify(const FXchar* expression,const FXchar* filename,unsigned int lineno);
00601 
00602 /// Trace printout routine:- usually not called directly but called through FXTRACE
00603 extern FXAPI void fxtrace(FXint level,const FXchar* format,...) FX_PRINTF(2,3) ;
00604 
00605 /// Sleep n microseconds
00606 extern FXAPI void fxsleep(FXuint n);
00607 
00608 /// Get process id
00609 extern FXAPI FXint fxgetpid();
00610 
00611 /// Convert string of length len to MSDOS; return new string and new length
00612 extern FXAPI FXbool fxtoDOS(FXchar*& string,FXint& len);
00613 
00614 /// Convert string of length len from MSDOS; return new string and new length
00615 extern FXAPI FXbool fxfromDOS(FXchar*& string,FXint& len);
00616 
00617 /// Duplicate string
00618 extern FXAPI FXchar *fxstrdup(const FXchar* str);
00619 
00620 /// Calculate a hash value from a string
00621 extern FXAPI FXuint fxstrhash(const FXchar* str);
00622 
00623 /// Convert RGB to HSV
00624 extern FXAPI void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b);
00625 
00626 /// Convert HSV to RGB
00627 extern FXAPI void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v);
00628 
00629 /// Convert RGB to HSL
00630 extern FXAPI void fxrgb_to_hsl(FXfloat& h,FXfloat& s,FXfloat& l,FXfloat r,FXfloat g,FXfloat b);
00631 
00632 /// Convert HSL to RGB
00633 extern FXAPI void fxhsl_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat l);
00634 
00635 /// Float number classification: 0=OK, +/-1=Inf, +/-2=NaN
00636 extern FXAPI FXint fxieeefloatclass(FXfloat number);
00637 
00638 /// Double number classification: 0=OK, +/-1=Inf, +/-2=NaN
00639 extern FXAPI FXint fxieeedoubleclass(FXdouble number);
00640 
00641 /// Test for finite float
00642 extern FXAPI FXbool fxIsFinite(FXfloat number);
00643 
00644 /// Test for finite double
00645 extern FXAPI FXbool fxIsFinite(FXdouble number);
00646 
00647 /// Test for infinite float
00648 extern FXAPI FXbool fxIsInf(FXfloat number);
00649 
00650 /// Test for infinite double
00651 extern FXAPI FXbool fxIsInf(FXdouble number);
00652 
00653 /// Text for not-a-number float
00654 extern FXAPI FXbool fxIsNan(FXfloat number);
00655 
00656 /// Text for not-a-number double
00657 extern FXAPI FXbool fxIsNan(FXdouble number);
00658 
00659 /// Convert keysym to unicode character
00660 extern FXAPI FXwchar fxkeysym2ucs(FXwchar sym);
00661 
00662 /// Convert unicode character to keysym
00663 extern FXAPI FXwchar fxucs2keysym(FXwchar ucs);
00664 
00665 /// Parse geometry, a-la X11 geometry specification
00666 extern FXAPI FXint fxparsegeometry(const FXchar *string,FXint& x,FXint& y,FXint& w,FXint& h);
00667 
00668 /// True if executable with given path is a console application
00669 extern FXAPI FXbool fxisconsole(const FXchar *path);
00670 
00671 /// Version number that the library has been compiled with
00672 extern FXAPI const FXuchar fxversion[3];
00673 
00674 /// Controls tracing level
00675 extern FXAPI FXint fxTraceLevel;
00676 
00677 /// Return wide character from utf8 string at ptr
00678 extern FXAPI FXwchar wc(const FXchar *ptr);
00679 
00680 /// Return wide character from utf16 string at ptr
00681 extern FXAPI FXwchar wc(const FXnchar *ptr);
00682 
00683 /// Return number of FXchar's of wide character at ptr
00684 extern FXAPI FXint wclen(const FXchar *ptr);
00685 
00686 /// Return number of FXnchar's of narrow character at ptr
00687 extern FXAPI FXint wclen(const FXnchar *ptr);
00688 
00689 /// Return start of utf8 character containing position
00690 extern FXAPI FXint wcvalidate(const FXchar* string,FXint pos);
00691 
00692 /// Return start of utf16 character containing position
00693 extern FXAPI FXint wcvalidate(const FXnchar *string,FXint pos);
00694 
00695 /// Advance to next utf8 character start
00696 extern FXAPI FXint wcinc(const FXchar* string,FXint pos);
00697 
00698 /// Advance to next utf16 character start
00699 extern FXAPI FXint wcinc(const FXnchar *string,FXint pos);
00700 
00701 /// Retreat to previous utf8 character start
00702 extern FXAPI FXint wcdec(const FXchar* string,FXint pos);
00703 
00704 /// Retreat to previous utf16 character start
00705 extern FXAPI FXint wcdec(const FXnchar *string,FXint pos);
00706 
00707 /// Length of utf8 representation of wide characters string str of length n
00708 extern FXAPI FXint utfslen(const FXwchar *str,FXint n);
00709 
00710 /// Length of utf8 representation of wide character string str
00711 extern FXAPI FXint utfslen(const FXwchar *str);
00712 
00713 /// Length of utf8 representation of narrow characters string str of length n
00714 extern FXAPI FXint utfslen(const FXnchar *str,FXint n);
00715 
00716 /// Length of utf8 representation of narrow characters string str
00717 extern FXAPI FXint utfslen(const FXnchar *str);
00718 
00719 /// Length of wide character representation of utf8 string str of length n
00720 extern FXAPI FXint wcslen(const FXchar *str,FXint n);
00721 
00722 /// Length of wide character representation of utf8 string str
00723 extern FXAPI FXint wcslen(const FXchar *str);
00724 
00725 /// Length of narrow character representation of utf8 string str of length n
00726 extern FXAPI FXint ncslen(const FXchar *str,FXint n);
00727 
00728 /// Length of narrow character representation of utf8 string str
00729 extern FXAPI FXint ncslen(const FXchar *str);
00730 
00731 
00732 /// Convert utf8 string from src to wide character w, returning number of bytes consumed
00733 extern FXAPI FXint utf2wc(FXwchar& w,const FXchar* src);
00734 
00735 
00736 /// Convert wide character w to utf8 string at dst, returning number of bytes produced
00737 extern FXAPI FXint wc2utf(FXchar* dst,FXwchar w);
00738 
00739 
00740 /// Copy utf8 string of length sn to wide character string dst of size dn
00741 extern FXAPI FXint utf2wcs(FXwchar *dst,FXint dn,const FXchar *src,FXint sn);
00742 
00743 /// Copy utf8 string of length sn to narrow character string dst of size dn
00744 extern FXAPI FXint utf2ncs(FXnchar *dst,FXint dn,const FXchar *src,FXint sn);
00745 
00746 /// Copy wide character substring of length sn to dst of size dn
00747 extern FXAPI FXint wc2utfs(FXchar* dst,FXint dn,const FXwchar *src,FXint sn);
00748 
00749 /// Copy narrow character substring of length sn to dst of size dn
00750 extern FXAPI FXint nc2utfs(FXchar* dst,FXint dn,const FXnchar *src,FXint sn);
00751 
00752 /// Return clock ticks from cpu tick-counter
00753 extern FXAPI FXTime fxgetticks();
00754 
00755 }
00756 
00757 #endif

Copyright © 1997-2010 Jeroen van der Zijp