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

fxdefs.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * FOX Definitions, Types, and Macros *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: fxdefs.h,v 1.178.2.2 2006/11/09 23:21:43 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXDEFS_H
25 #define FXDEFS_H
26 
27 
28 /******************************** Definitions ********************************/
29 
30 // Truth values
31 #ifndef TRUE
32 #define TRUE 1
33 #endif
34 #ifndef FALSE
35 #define FALSE 0
36 #endif
37 #ifndef MAYBE
38 #define MAYBE 2
39 #endif
40 #ifndef NULL
41 #define NULL 0
42 #endif
43 
44 /// Pi
45 #ifndef PI
46 #define PI 3.1415926535897932384626433833
47 #endif
48 
49 /// Euler constant
50 #define EULER 2.7182818284590452353602874713
51 
52 /// Multiplier for degrees to radians
53 #define DTOR 0.0174532925199432957692369077
54 
55 /// Multiplier for radians to degrees
56 #define RTOD 57.295779513082320876798154814
57 
58 
59 // Path separator
60 #ifdef WIN32
61 #define PATHSEP '\\'
62 #define PATHSEPSTRING "\\"
63 #define PATHLISTSEP ';'
64 #define PATHLISTSEPSTRING ";"
65 #define ISPATHSEP(c) ((c)=='/' || (c)=='\\')
66 #else
67 #define PATHSEP '/'
68 #define PATHSEPSTRING "/"
69 #define PATHLISTSEP ':'
70 #define PATHLISTSEPSTRING ":"
71 #define ISPATHSEP(c) ((c)=='/')
72 #endif
73 
74 // End Of Line
75 #ifdef WIN32
76 #define ENDLINE "\r\n"
77 #else
78 #define ENDLINE "\n"
79 #endif
80 
81 
82 // For Windows
83 #ifdef _DEBUG
84 #ifndef DEBUG
85 #define DEBUG
86 #endif
87 #endif
88 #ifdef _NDEBUG
89 #ifndef NDEBUG
90 #define NDEBUG
91 #endif
92 #endif
93 
94 
95 // Shared library support
96 #ifdef WIN32
97 #define FXLOCAL
98 #define FXEXPORT __declspec(dllexport)
99 #define FXIMPORT __declspec(dllimport)
100 #else
101 #if defined(__GNUC__) && (__GNUC__ >= 4)
102 #define FXLOCAL __attribute__ ((visibility("hidden")))
103 #define FXEXPORT __attribute__ ((visibility("default")))
104 #define FXIMPORT
105 #else
106 #define FXLOCAL
107 #define FXEXPORT
108 #define FXIMPORT
109 #endif
110 #endif
111 
112 // Define FXAPI for DLL builds
113 #ifdef FOXDLL
114 #ifdef FOXDLL_EXPORTS
115 #define FXAPI FXEXPORT
116 #define FXTEMPLATE_EXTERN
117 #else
118 #define FXAPI FXIMPORT
119 #define FXTEMPLATE_EXTERN extern
120 #endif
121 #else
122 #define FXAPI
123 #define FXTEMPLATE_EXTERN
124 #endif
125 
126 // Callback
127 #ifdef WIN32
128 #ifndef CALLBACK
129 #define CALLBACK __stdcall
130 #endif
131 #endif
132 
133 
134 // Disable some warnings in VC++
135 #ifdef _MSC_VER
136 #pragma warning(disable: 4251)
137 #pragma warning(disable: 4231)
138 #pragma warning(disable: 4244)
139 #endif
140 
141 // Checking printf and scanf format strings
142 #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__)
143 #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg)))
144 #define FX_SCANF(fmt,arg) __attribute__((format(scanf,fmt,arg)))
145 #else
146 #define FX_PRINTF(fmt,arg)
147 #define FX_SCANF(fmt,arg)
148 #endif
149 
150 // Raw event type
151 #ifndef WIN32
152 union _XEvent;
153 #else
154 struct tagMSG;
155 #endif
156 
157 
158 namespace FX {
159 
160 
161 // FOX System Defined Selector Types
162 enum FXSelType {
163  SEL_NONE,
164  SEL_KEYPRESS, /// Key pressed
165  SEL_KEYRELEASE, /// Key released
166  SEL_LEFTBUTTONPRESS, /// Left mouse button pressed
167  SEL_LEFTBUTTONRELEASE, /// Left mouse button released
168  SEL_MIDDLEBUTTONPRESS, /// Middle mouse button pressed
169  SEL_MIDDLEBUTTONRELEASE, /// Middle mouse button released
170  SEL_RIGHTBUTTONPRESS, /// Right mouse button pressed
171  SEL_RIGHTBUTTONRELEASE, /// Right mouse button released
172  SEL_MOTION, /// Mouse motion
173  SEL_ENTER, /// Mouse entered window
174  SEL_LEAVE, /// Mouse left window
175  SEL_FOCUSIN, /// Focus into window
176  SEL_FOCUSOUT, /// Focus out of window
178  SEL_UNGRABBED, /// Lost the grab (Windows)
179  SEL_PAINT, /// Must repaint window
182  SEL_UNMAP, /// Window was hidden
183  SEL_MAP, /// Window was shown
184  SEL_CONFIGURE, /// Resize
185  SEL_SELECTION_LOST, /// Widget lost selection
186  SEL_SELECTION_GAINED, /// Widget gained selection
187  SEL_SELECTION_REQUEST, /// Inquire selection data
188  SEL_RAISED, /// Window to top of stack
189  SEL_LOWERED, /// Window to bottom of stack
190  SEL_CLOSE, /// Close window
191  SEL_DELETE, /// Delete window
192  SEL_MINIMIZE, /// Iconified
193  SEL_RESTORE, /// No longer iconified or maximized
194  SEL_MAXIMIZE, /// Maximized
195  SEL_UPDATE, /// GUI update
196  SEL_COMMAND, /// GUI command
197  SEL_CLICKED, /// Clicked
198  SEL_DOUBLECLICKED, /// Double-clicked
199  SEL_TRIPLECLICKED, /// Triple-clicked
200  SEL_MOUSEWHEEL, /// Mouse wheel
201  SEL_CHANGED, /// GUI has changed
202  SEL_VERIFY, /// Verify change
203  SEL_DESELECTED, /// Deselected
204  SEL_SELECTED, /// Selected
205  SEL_INSERTED, /// Inserted
206  SEL_REPLACED, /// Replaced
207  SEL_DELETED, /// Deleted
208  SEL_OPENED, /// Opened
209  SEL_CLOSED, /// Closed
210  SEL_EXPANDED, /// Expanded
211  SEL_COLLAPSED, /// Collapsed
212  SEL_BEGINDRAG, /// Start a drag
213  SEL_ENDDRAG, /// End a drag
214  SEL_DRAGGED, /// Dragged
215  SEL_LASSOED, /// Lassoed
216  SEL_TIMEOUT, /// Timeout occurred
217  SEL_SIGNAL, /// Signal received
218  SEL_CLIPBOARD_LOST, /// Widget lost clipboard
219  SEL_CLIPBOARD_GAINED, /// Widget gained clipboard
220  SEL_CLIPBOARD_REQUEST, /// Inquire clipboard data
221  SEL_CHORE, /// Background chore
222  SEL_FOCUS_SELF, /// Focus on widget itself
223  SEL_FOCUS_RIGHT, /// Focus moved right
224  SEL_FOCUS_LEFT, /// Focus moved left
225  SEL_FOCUS_DOWN, /// Focus moved down
226  SEL_FOCUS_UP, /// Focus moved up
227  SEL_FOCUS_NEXT, /// Focus moved to next widget
228  SEL_FOCUS_PREV, /// Focus moved to previous widget
229  SEL_DND_ENTER, /// Drag action entering potential drop target
230  SEL_DND_LEAVE, /// Drag action leaving potential drop target
231  SEL_DND_DROP, /// Drop on drop target
232  SEL_DND_MOTION, /// Drag position changed over potential drop target
233  SEL_DND_REQUEST, /// Inquire drag and drop data
234  SEL_IO_READ, /// Read activity on a pipe
235  SEL_IO_WRITE, /// Write activity on a pipe
236  SEL_IO_EXCEPT, /// Except activity on a pipe
237  SEL_PICKED, /// Picked some location
238  SEL_QUERY_TIP, /// Message inquiring about tooltip
239  SEL_QUERY_HELP, /// Message inquiring about statusline help
240  SEL_DOCKED, /// Toolbar docked
241  SEL_FLOATED, /// Toolbar floated
242  SEL_SESSION_NOTIFY, /// Session is about to close
243  SEL_SESSION_CLOSED, /// Session is closed
245  };
248 /// FOX Keyboard and Button states
249 enum {
250  SHIFTMASK = 0x001, /// Shift key is down
251  CAPSLOCKMASK = 0x002, /// Caps Lock key is down
252  CONTROLMASK = 0x004, /// Ctrl key is down
253 #ifdef __APPLE__
254  ALTMASK = 0x2000, /// Alt key is down
255  METAMASK = 0x10, /// Meta key is down
256 #else
257  ALTMASK = 0x008, /// Alt key is down
258  METAMASK = 0x040, /// Meta key is down
259 #endif
260  NUMLOCKMASK = 0x010, /// Num Lock key is down
261  SCROLLLOCKMASK = 0x0E0, /// Scroll Lock key is down (seems to vary)
262  LEFTBUTTONMASK = 0x100, /// Left mouse button is down
263  MIDDLEBUTTONMASK = 0x200, /// Middle mouse button is down
264  RIGHTBUTTONMASK = 0x400 /// Right mouse button is down
265  };
266 
268 /// FOX Mouse buttons
269 enum {
272  RIGHTBUTTON = 3
273  };
274 
275 
276 /// FOX window crossing modes
277 enum {
278  CROSSINGNORMAL, /// Normal crossing event
279  CROSSINGGRAB, /// Crossing due to mouse grab
280  CROSSINGUNGRAB /// Crossing due to mouse ungrab
281  };
284 /// FOX window visibility modes
285 enum {
289  };
290 
291 
292 /// Options for fxfilematch
293 enum {
294  FILEMATCH_FILE_NAME = 1, /// No wildcard can ever match `/'
295  FILEMATCH_NOESCAPE = 2, /// Backslashes don't quote special chars
296  FILEMATCH_PERIOD = 4, /// Leading `.' is matched only explicitly
297  FILEMATCH_LEADING_DIR = 8, /// Ignore `/...' after a match
298  FILEMATCH_CASEFOLD = 16 /// Compare without regard to case
299  };
300 
301 
302 /// Drag and drop actions
303 enum FXDragAction {
304  DRAG_REJECT = 0, /// Reject all drop actions
305  DRAG_ACCEPT = 1, /// Accept any drop action
306  DRAG_COPY = 2, /// Copy
307  DRAG_MOVE = 3, /// Move
308  DRAG_LINK = 4, /// Link
309  DRAG_PRIVATE = 5 /// Private
310  };
311 
312 
313 /// Origin of data
314 enum FXDNDOrigin {
315  FROM_SELECTION = 0, /// Primary selection
316  FROM_CLIPBOARD = 1, /// Clipboard
317  FROM_DRAGNDROP = 2 /// Drag and drop source
318  };
321 /// Exponent display
322 enum FXExponent {
323  EXP_NEVER=FALSE, /// Never use exponential notation
324  EXP_ALWAYS=TRUE, /// Always use exponential notation
325  EXP_AUTO=MAYBE /// Use exponential notation if needed
326  };
327 
328 
329 /// Search modes for search/replace dialogs
330 enum {
331  SEARCH_FORWARD = 0, /// Search forward (default)
332  SEARCH_BACKWARD = 1, /// Search backward
333  SEARCH_NOWRAP = 0, /// Don't wrap (default)
334  SEARCH_WRAP = 2, /// Wrap around to start
335  SEARCH_EXACT = 0, /// Exact match (default)
336  SEARCH_IGNORECASE = 4, /// Ignore case
337  SEARCH_REGEX = 8, /// Regular expression match
338  SEARCH_PREFIX = 16 /// Prefix of subject string
339  };
340 
341 
342 /********************************* Typedefs **********************************/
343 
344 // Forward declarations
345 class FXObject;
346 class FXStream;
347 class FXString;
349 
350 // Streamable types; these are fixed size!
351 typedef char FXchar;
352 typedef unsigned char FXuchar;
353 typedef FXuchar FXbool;
354 typedef unsigned short FXushort;
355 typedef short FXshort;
356 typedef unsigned int FXuint;
357 typedef int FXint;
358 typedef float FXfloat;
359 typedef double FXdouble;
361 #ifdef WIN32
362 typedef unsigned int FXwchar;
363 #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
364 typedef unsigned short FXnchar;
365 #elif defined(__WATCOM_INT64__)
366 typedef long char FXnchar;
367 #else
368 typedef wchar_t FXnchar;
369 #endif
370 #else
371 typedef wchar_t FXwchar;
372 typedef unsigned short FXnchar;
373 #endif
374 #if defined(__LP64__) || defined(_LP64) || (_MIPS_SZLONG == 64) || (__WORDSIZE == 64)
375 typedef unsigned long FXulong;
376 typedef long FXlong;
377 #elif defined(_MSC_VER) || (defined(__BCPLUSPLUS__) && __BORLANDC__ > 0x500) || defined(__WATCOM_INT64__)
378 typedef unsigned __int64 FXulong;
379 typedef __int64 FXlong;
380 #elif defined(__GNUG__) || defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__MWERKS__) || defined(__SC__) || defined(_LONGLONG)
381 typedef unsigned long long FXulong;
382 typedef long long FXlong;
383 #else
384 #error "FXlong and FXulong not defined for this architecture!"
385 #endif
386 
387 // Integral types large enough to hold value of a pointer
388 #if defined(_MSC_VER) && defined(_WIN64)
389 typedef __int64 FXival;
390 typedef unsigned __int64 FXuval;
391 #elif defined(__GNUC__) && defined(_WIN64)
392 typedef long long FXival;
393 typedef unsigned long long FXuval;
394 #else
395 typedef long FXival;
396 typedef unsigned long FXuval;
397 #endif
400 // Handle to something in server
401 #ifndef WIN32
402 typedef unsigned long FXID;
403 #else
404 typedef void* FXID;
405 #endif
406 
407 // Time since January 1, 1970 (UTC)
408 typedef long FXTime;
409 
410 // Pixel type (could be color index)
411 typedef unsigned long FXPixel;
413 // RGBA pixel value
414 typedef FXuint FXColor;
415 
416 // Hot key
417 typedef FXuint FXHotKey;
418 
419 // Drag type
420 #ifndef WIN32
421 typedef FXID FXDragType;
422 #else
423 typedef FXushort FXDragType;
424 #endif
425 
426 // Input source handle type
427 #ifndef WIN32
428 typedef FXint FXInputHandle;
429 #else
430 typedef void* FXInputHandle;
431 #endif
432 
433 // Raw event type
434 #ifndef WIN32
435 typedef _XEvent FXRawEvent;
436 #else
437 typedef tagMSG FXRawEvent;
438 #endif
439 
440 
441 /********************************** Macros ***********************************/
443 
444 /// Abolute value
445 #define FXABS(val) (((val)>=0)?(val):-(val))
446 
447 /// Return the maximum of a or b
448 #define FXMAX(a,b) (((a)>(b))?(a):(b))
449 
450 /// Return the minimum of a or b
451 #define FXMIN(a,b) (((a)>(b))?(b):(a))
452 
453 /// Return the minimum of x, y and z
454 #define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z))
455 
456 /// Return the maximum of x, y and z
457 #define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z))
458 
459 /// Return the minimum of x, y, z, and w
460 #define FXMIN4(x,y,z,w) (FXMIN(FXMIN(x,y),FXMIN(z,w)))
462 /// Return the maximum of of x, y, z, and w
463 #define FXMAX4(x,y,z,w) (FXMAX(FXMAX(x,y),FXMAX(z,w)))
464 
465 /// Return minimum and maximum of a, b
466 #define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a)))
467 
468 /// Clamp value x to range [lo..hi]
469 #define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x)))
470 
471 /// Swap a pair of numbers
472 #define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t))
473 
474 /// Linear interpolation between a and b, where 0<=f<=1
475 #define FXLERP(a,b,f) ((a)+((b)-(a))*(f))
476 
477 /// Offset of member in a structure
478 #define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0))
479 
480 /// Number of elements in a static array
481 #define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0]))
482 
483 /// Container class of a member class
484 #define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem)))
486 /// Make int out of two shorts
487 #define MKUINT(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16))
489 /// Make selector from message type and message id
490 #define FXSEL(type,id) ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16))
492 /// Get type from selector
493 #define FXSELTYPE(s) ((FX::FXushort)(((s)>>16)&0xffff))
495 /// Get ID from selector
496 #define FXSELID(s) ((FX::FXushort)((s)&0xffff))
498 /// Reverse bits in byte
499 #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))
501 /// Test if character c is at the start of a utf8 sequence
502 #define FXISUTF(c) (((c)&0xC0)!=0x80)
504 
505 // Definitions for big-endian machines
506 #if FOX_BIGENDIAN == 1
507 
508 /// Make RGBA color
509 #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)))
510 
511 /// Make RGB color
512 #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<24) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<8) | 0x000000ff)
513 
514 /// Get red value from RGBA color
515 #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff))
516 
517 /// Get green value from RGBA color
518 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff))
519 
520 /// Get blue value from RGBA color
521 #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff))
522 
523 /// Get alpha value from RGBA color
524 #define FXALPHAVAL(rgba) ((FX::FXuchar)((rgba)&0xff))
525 
526 /// Get component value of RGBA color
527 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff))
528 
529 #endif
531 
532 // Definitions for little-endian machines
533 #if FOX_BIGENDIAN == 0
534 
535 /// Make RGBA color
536 #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))
537 
538 /// Make RGB color
539 #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)<<16) | 0xff000000)
540 
541 /// Get red value from RGBA color
542 #define FXREDVAL(rgba) ((FX::FXuchar)((rgba)&0xff))
543 
544 /// Get green value from RGBA color
545 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff))
546 
547 /// Get blue value from RGBA color
548 #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff))
549 
550 /// Get alpha value from RGBA color
551 #define FXALPHAVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff))
552 
553 /// Get component value of RGBA color
554 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff))
555 
556 #endif
557 
558 
559 /**
560 * FXASSERT() prints out a message when the expression fails,
561 * and nothing otherwise. Unlike assert(), FXASSERT() will not
562 * terminate the execution of the application.
563 * When compiling your application for release, all assertions
564 * are compiled out; thus there is no impact on execution speed.
565 */
566 #ifndef NDEBUG
567 #define FXASSERT(exp) ((exp)?((void)0):(void)FX::fxassert(#exp,__FILE__,__LINE__))
568 #else
569 #define FXASSERT(exp) ((void)0)
570 #endif
571 
572 
573 /**
574 * FXTRACE() allows you to trace the execution of your application
575 * with increasing levels of detail the higher the trace level.
576 * The trace level is determined by variable fxTraceLevel, which
577 * may be set from the command line with "-tracelevel <level>".
578 * When compiling your application for release, all trace statements
579 * are compiled out, just like FXASSERT.
580 * A statement like: FXTRACE((10,"The value of x=%d\n",x)) will
581 * generate output only if fxTraceLevel is set to 11 or greater.
582 * The default value fxTraceLevel=0 will block all trace outputs.
583 * Note the double parentheses!
584 */
585 #ifndef NDEBUG
586 #define FXTRACE(arguments) FX::fxtrace arguments
587 #else
588 #define FXTRACE(arguments) ((void)0)
589 #endif
590 
592 /**
593 * Allocate a memory block of no elements of type and store a pointer
594 * to it into the address pointed to by ptr.
595 * Return FALSE if size!=0 and allocation fails, TRUE otherwise.
596 * An allocation of a zero size block returns a NULL pointer.
597 */
598 #define FXMALLOC(ptr,type,no) (FX::fxmalloc((void **)(ptr),sizeof(type)*(no)))
599 
600 /**
601 * Allocate a zero-filled memory block no elements of type and store a pointer
602 * to it into the address pointed to by ptr.
603 * Return FALSE if size!=0 and allocation fails, TRUE otherwise.
604 * An allocation of a zero size block returns a NULL pointer.
605 */
606 #define FXCALLOC(ptr,type,no) (FX::fxcalloc((void **)(ptr),sizeof(type)*(no)))
608 /**
609 * Resize the memory block referred to by the pointer at the address ptr, to a
610 * hold no elements of type.
611 * Returns FALSE if size!=0 and reallocation fails, TRUE otherwise.
612 * If reallocation fails, pointer is left to point to old block; a reallocation
613 * to a zero size block has the effect of freeing it.
614 * The ptr argument must be the address where the pointer to the allocated
615 * block is to be stored.
616 */
617 #define FXRESIZE(ptr,type,no) (FX::fxresize((void **)(ptr),sizeof(type)*(no)))
618 
619 /**
620 * Allocate and initialize memory from another block.
621 * Return FALSE if size!=0 and source!=NULL and allocation fails, TRUE otherwise.
622 * An allocation of a zero size block returns a NULL pointer.
623 * The ptr argument must be the address where the pointer to the allocated
624 * block is to be stored.
625 */
626 #define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup((void **)(ptr),(const void*)(src),sizeof(type)*(no)))
627 
628 /**
629 * Free a block of memory allocated with either FXMALLOC, FXCALLOC, FXRESIZE, or FXMEMDUP.
630 * It is OK to call free a NULL pointer. The argument must be the address of the
631 * pointer to the block to be released. The pointer is set to NULL to prevent
632 * any further references to the block after releasing it.
633 */
634 #define FXFREE(ptr) (FX::fxfree((void **)(ptr)))
635 
636 
637 /**
638 * These are some of the ISO C99 standard single-precision transcendental functions.
639 * On LINUX, specify _GNU_SOURCE or _ISOC99_SOURCE to enable native implementation;
640 * otherwise, these macros will be used. Apple OS-X implements fabsf(x), ceilf(x),
641 * floorf(x), and fmodf(x,y).
642 * Define FLOAT_MATH_FUNCTIONS if these functions are available in some other
643 * library you're linking to.
644 */
645 #ifdef __OpenBSD__
646 #define FLOAT_MATH_FUNCTIONS
647 #endif
648 #ifndef FLOAT_MATH_FUNCTIONS
649 #ifndef __USE_ISOC99
650 #ifndef __APPLE__
651 #define fabsf(x) ((float)fabs((double)(x)))
652 #define ceilf(x) ((float)ceil((double)(x)))
653 #define floorf(x) ((float)floor((double)(x)))
654 #define fmodf(x,y) ((float)fmod((double)(x),(double)(y)))
655 #endif
656 #define sqrtf(x) ((float)sqrt((double)(x)))
657 #define sinf(x) ((float)sin((double)(x)))
658 #define cosf(x) ((float)cos((double)(x)))
659 #define tanf(x) ((float)tan((double)(x)))
660 #define asinf(x) ((float)asin((double)(x)))
661 #define acosf(x) ((float)acos((double)(x)))
662 #define atanf(x) ((float)atan((double)(x)))
663 #define atan2f(y,x) ((float)atan2((double)(y),(double)(x)))
664 #define powf(x,y) ((float)pow((double)(x),(double)(y)))
665 #define expf(x) ((float)exp((double)(x)))
666 #define logf(x) ((float)log((double)(x)))
667 #define log10f(x) ((float)log10((double)(x)))
668 #endif
669 #endif
670 
671 
672 /********************************** Globals **********************************/
673 
674 /// Simple, thread-safe, random number generator
675 extern FXAPI FXuint fxrandom(FXuint& seed);
676 
677 /// Allocate memory
678 extern FXAPI FXint fxmalloc(void** ptr,unsigned long size);
679 
680 /// Allocate cleaned memory
681 extern FXAPI FXint fxcalloc(void** ptr,unsigned long size);
682 
683 /// Resize memory
684 extern FXAPI FXint fxresize(void** ptr,unsigned long size);
685 
686 /// Duplicate memory
687 extern FXAPI FXint fxmemdup(void** ptr,const void* src,unsigned long size);
688 
689 /// Free memory, resets ptr to NULL afterward
690 extern FXAPI void fxfree(void** ptr);
692 /// Error routine
693 extern FXAPI void fxerror(const char* format,...) FX_PRINTF(1,2) ;
695 /// Warning routine
696 extern FXAPI void fxwarning(const char* format,...) FX_PRINTF(1,2) ;
698 /// Log message to [typically] stderr
699 extern FXAPI void fxmessage(const char* format,...) FX_PRINTF(1,2) ;
701 /// Assert failed routine:- usually not called directly but called through FXASSERT
702 extern FXAPI void fxassert(const char* expression,const char* filename,unsigned int lineno);
704 /// Trace printout routine:- usually not called directly but called through FXTRACE
705 extern FXAPI void fxtrace(unsigned int level,const char* format,...) FX_PRINTF(2,3) ;
707 /// Sleep n microseconds
708 extern FXAPI void fxsleep(unsigned int n);
709 
710 /// Match a file name with a pattern
711 extern FXAPI bool fxfilematch(const char *pattern,const char *string,FXuint flags=(FILEMATCH_NOESCAPE|FILEMATCH_FILE_NAME));
712 
713 /// Get highlight color
715 
716 /// Get shadow color
718 
719 /// Get process id
720 extern FXAPI FXint fxgetpid();
721 
722 /// Convert string of length len to MSDOS; return new string and new length
723 extern FXAPI bool fxtoDOS(FXchar*& string,FXint& len);
724 
725 /// Convert string of length len from MSDOS; return new string and new length
726 extern FXAPI bool fxfromDOS(FXchar*& string,FXint& len);
727 
728 /// Duplicate string
729 extern FXAPI FXchar *fxstrdup(const FXchar* str);
730 
731 /// Calculate a hash value from a string
732 extern FXAPI FXuint fxstrhash(const FXchar* str);
733 
734 /// Get RGB value from color name
735 extern FXAPI FXColor fxcolorfromname(const FXchar* colorname);
736 
737 /// Get name of (closest) color to RGB
738 extern FXAPI FXchar* fxnamefromcolor(FXchar *colorname,FXColor color);
739 
740 /// Convert RGB to HSV
741 extern FXAPI void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b);
742 
743 /// Convert HSV to RGB
744 extern FXAPI void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v);
745 
746 /// Floating point number classification: 0=OK, +/-1=Inf, +/-2=NaN
747 extern FXAPI FXint fxieeefloatclass(FXfloat number);
748 extern FXAPI FXint fxieeedoubleclass(FXdouble number);
749 
750 /// Convert keysym to unicode character
751 extern FXAPI FXwchar fxkeysym2ucs(FXwchar sym);
752 
753 /// Convert unicode character to keysym
754 extern FXAPI FXwchar fxucs2keysym(FXwchar ucs);
755 
756 /// Parse geometry, a-la X11 geometry specification
757 extern FXAPI FXint fxparsegeometry(const FXchar *string,FXint& x,FXint& y,FXint& w,FXint& h);
758 
759 /// True if executable with given path is a console application
760 extern FXAPI FXbool fxisconsole(const FXchar *path);
761 
762 /// Version number that the library has been compiled with
763 extern FXAPI const FXuchar fxversion[3];
764 
765 /// Controls tracing level
766 extern FXAPI unsigned int fxTraceLevel;
767 
768 /// Return wide character from utf8 string at ptr
769 extern FXAPI FXwchar wc(const FXchar *ptr);
770 
771 /// Return wide character from utf16 string at ptr
772 extern FXAPI FXwchar wc(const FXnchar *ptr);
773 
774 /// Return number of FXchar's of wide character at ptr
775 extern FXAPI FXint wclen(const FXchar *ptr);
776 
777 /// Return number of FXnchar's of narrow character at ptr
778 extern FXAPI FXint wclen(const FXnchar *ptr);
779 
780 /// Return start of utf8 character containing position
781 extern FXAPI FXint wcvalidate(const FXchar* string,FXint pos);
782 
783 /// Return start of utf16 character containing position
784 extern FXAPI FXint wcvalidate(const FXnchar *string,FXint pos);
785 
786 /// Advance to next utf8 character start
787 extern FXAPI FXint wcinc(const FXchar* string,FXint pos);
788 
789 /// Advance to next utf16 character start
790 extern FXAPI FXint wcinc(const FXnchar *string,FXint pos);
791 
792 /// Retreat to previous utf8 character start
793 extern FXAPI FXint wcdec(const FXchar* string,FXint pos);
794 
795 /// Retreat to previous utf16 character start
796 extern FXAPI FXint wcdec(const FXnchar *string,FXint pos);
797 
798 /// Length of utf8 representation of wide characters string str of length n
799 extern FXAPI FXint utfslen(const FXwchar *str,FXint n);
800 
801 /// Length of utf8 representation of wide character string str
802 extern FXAPI FXint utfslen(const FXwchar *str);
803 
804 /// Length of utf8 representation of narrow characters string str of length n
805 extern FXAPI FXint utfslen(const FXnchar *str,FXint n);
806 
807 /// Length of utf8 representation of narrow characters string str
808 extern FXAPI FXint utfslen(const FXnchar *str);
809 
810 /// Length of wide character representation of utf8 string str of length n
811 extern FXAPI FXint wcslen(const FXchar *str,FXint n);
812 
813 /// Length of wide character representation of utf8 string str
814 extern FXAPI FXint wcslen(const FXchar *str);
815 
816 /// Length of narrow character representation of utf8 string str of length n
817 extern FXAPI FXint ncslen(const FXchar *str,FXint n);
818 
819 /// Length of narrow character representation of utf8 string str
820 extern FXAPI FXint ncslen(const FXchar *str);
821 
822 /// Copy utf8 string of length n to wide character string dst
823 extern FXAPI FXint utf2wcs(FXwchar *dst,const FXchar *src,FXint n);
824 
825 /// Copy utf8 string to wide character string dst
826 extern FXAPI FXint utf2wcs(FXwchar *dst,const FXchar *src);
827 
828 /// Copy utf8 string of length n to narrow character string dst
829 extern FXAPI FXint utf2ncs(FXnchar *dst,const FXchar *src,FXint n);
830 
831 /// Copy utf8 string to narrow character string dst
832 extern FXAPI FXint utf2ncs(FXnchar *dst,const FXchar *src);
833 
834 /// Copy wide character substring of length n to dst
835 extern FXAPI FXint wc2utfs(FXchar* dst,const FXwchar *src,FXint n);
836 
837 /// Copy wide character string to dst
838 extern FXAPI FXint wc2utfs(FXchar* dst,const FXwchar *src);
839 
840 /// Copy narrow character substring of length n to dst
841 extern FXAPI FXint nc2utfs(FXchar* dst,const FXnchar *src,FXint n);
842 
843 /// Copy narrow character string to dst
844 extern FXAPI FXint nc2utfs(FXchar* dst,const FXnchar *src);
845 
846 
847 }
848 
849 #endif
Window to bottom of stack.
Definition: fxdefs.h:192
Definition: fxdefs.h:305
Definition: fxdefs.h:183
Session is closed.
Definition: fxdefs.h:246
Accept any drop action.
Definition: fxdefs.h:332
Middle mouse button is down.
Definition: fxdefs.h:270
Private.
Definition: fxdefs.h:336
FXDragAction
Drag and drop actions.
Definition: fxdefs.h:330
Focus moved down.
Definition: fxdefs.h:228
unsigned long FXID
Definition: fxdefs.h:442
Use exponential notation if needed.
Definition: fxdefs.h:360
unsigned short FXushort
Definition: fxdefs.h:394
Move.
Definition: fxdefs.h:334
Search forward (default)
Definition: fxdefs.h:370
Don't wrap (default)
Definition: fxdefs.h:372
GUI command.
Definition: fxdefs.h:199
GUI has changed.
Definition: fxdefs.h:204
char FXchar
Definition: fxdefs.h:387
Focus into window.
Definition: fxdefs.h:178
Caps Lock key is down.
Definition: fxdefs.h:258
FXint wclen(const FXchar *ptr)
Return number of FXchar's of wide character at ptr.
FXwchar fxkeysym2ucs(FXwchar sym)
Convert keysym to unicode character.
Drop on drop target.
Definition: fxdefs.h:234
Window was shown.
Definition: fxdefs.h:186
unsigned long FXPixel
Definition: fxdefs.h:451
#define TRUE
Definition: fxdefs.h:32
Exact match (default)
Definition: fxdefs.h:374
short FXshort
Definition: fxdefs.h:395
FXExponent
Exponent display.
Definition: fxdefs.h:357
FXchar * fxnamefromcolor(FXchar *colorname, FXColor color)
Get name of (closest) color to RGB.
void void void fxmessage(const char *format,...) FX_PRINTF(1
Log message to [typically] stderr.
unsigned int FXuint
Definition: fxdefs.h:396
FXint wc2utfs(FXchar *dst, const FXwchar *src, FXint n)
Copy wide character substring of length n to dst.
Expanded.
Definition: fxdefs.h:213
Definition: fxdefs.h:282
Write activity on a pipe.
Definition: fxdefs.h:238
FXuint FXHotKey
Definition: fxdefs.h:457
unsigned short FXnchar
Definition: fxdefs.h:412
FXwchar fxucs2keysym(FXwchar ucs)
Convert unicode character to keysym.
Inquire selection data.
Definition: fxdefs.h:190
FXint fxcalloc(void **ptr, unsigned long size)
Allocate cleaned memory.
Regular expression match.
Definition: fxdefs.h:376
Must repaint window.
Definition: fxdefs.h:182
Except activity on a pipe.
Definition: fxdefs.h:239
GUI update.
Definition: fxdefs.h:198
FXint fxieeefloatclass(FXfloat number)
Floating point number classification: 0=OK, +/-1=Inf, +/-2=NaN.
#define FXAPI
Definition: fxdefs.h:122
_XEvent FXRawEvent
Definition: fxdefs.h:475
Crossing due to mouse ungrab.
Definition: fxdefs.h:295
Copy.
Definition: fxdefs.h:333
FXuchar FXbool
Definition: fxdefs.h:393
Clipboard.
Definition: fxdefs.h:347
Definition: fxdefs.h:281
Focus moved right.
Definition: fxdefs.h:226
Ignore `/...' after a match.
Definition: fxdefs.h:320
Reject all drop actions.
Definition: fxdefs.h:331
Definition: fxdefs.h:247
Focus moved to previous widget.
Definition: fxdefs.h:231
Drag action leaving potential drop target.
Definition: fxdefs.h:233
Closed.
Definition: fxdefs.h:212
FXint utf2wcs(FXwchar *dst, const FXchar *src, FXint n)
Copy utf8 string of length n to wide character string dst.
void fxrgb_to_hsv(FXfloat &h, FXfloat &s, FXfloat &v, FXfloat r, FXfloat g, FXfloat b)
Convert RGB to HSV.
Iconified.
Definition: fxdefs.h:195
Read activity on a pipe.
Definition: fxdefs.h:237
FXDNDOrigin
Origin of data.
Definition: fxdefs.h:345
Mouse entered window.
Definition: fxdefs.h:176
FXint wcinc(const FXchar *string, FXint pos)
Advance to next utf8 character start.
Window was hidden.
Definition: fxdefs.h:185
Resize.
Definition: fxdefs.h:187
FXuint FXColor
Definition: fxdefs.h:454
Drag and drop source.
Definition: fxdefs.h:348
FXuint fxrandom(FXuint &seed)
Simple, thread-safe, random number generator.
Definition: fxdefs.h:283
Left mouse button is down.
Definition: fxdefs.h:269
Definition: fxdefs.h:306
Right mouse button released.
Definition: fxdefs.h:174
Never use exponential notation.
Definition: fxdefs.h:358
Deleted.
Definition: fxdefs.h:210
Toolbar docked.
Definition: fxdefs.h:243
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
Middle mouse button pressed.
Definition: fxdefs.h:171
bool fxfilematch(const char *pattern, const char *string, FXuint flags=(FILEMATCH_NOESCAPE|FILEMATCH_FILE_NAME))
Match a file name with a pattern.
void void fxsleep(unsigned int n)
Sleep n microseconds.
FXint wcslen(const FXchar *str, FXint n)
Length of wide character representation of utf8 string str of length n.
Backslashes don't quote special chars.
Definition: fxdefs.h:318
FXObject * FXObjectPtr
Definition: fxdefs.h:400
Background chore.
Definition: fxdefs.h:224
Widget gained selection.
Definition: fxdefs.h:189
Meta key is down.
Definition: fxdefs.h:265
double FXdouble
Definition: fxdefs.h:399
Double-clicked.
Definition: fxdefs.h:201
long FXival
Definition: fxdefs.h:435
Opened.
Definition: fxdefs.h:211
Inquire clipboard data.
Definition: fxdefs.h:223
Mouse left window.
Definition: fxdefs.h:177
FXint fxmemdup(void **ptr, const void *src, unsigned long size)
Duplicate memory.
wchar_t FXwchar
Definition: fxdefs.h:411
FXint utfslen(const FXwchar *str, FXint n)
Length of utf8 representation of wide characters string str of length n.
Picked some location.
Definition: fxdefs.h:240
long FXTime
Definition: fxdefs.h:448
Dragged.
Definition: fxdefs.h:217
Key pressed.
Definition: fxdefs.h:167
Ctrl key is down.
Definition: fxdefs.h:259
End a drag.
Definition: fxdefs.h:216
FXuint fxstrhash(const FXchar *str)
Calculate a hash value from a string.
int FXint
Definition: fxdefs.h:397
Signal received.
Definition: fxdefs.h:220
FXColor makeHiliteColor(FXColor clr)
Get highlight color.
void fxhsv_to_rgb(FXfloat &r, FXfloat &g, FXfloat &b, FXfloat h, FXfloat s, FXfloat v)
Convert HSV to RGB.
No longer iconified or maximized.
Definition: fxdefs.h:196
Ignore case.
Definition: fxdefs.h:375
FXint fxmalloc(void **ptr, unsigned long size)
Allocate memory.
void fxtrace(unsigned int level, const char *format,...) FX_PRINTF(2
Trace printout routine:- usually not called directly but called through FXTRACE.
Widget lost selection.
Definition: fxdefs.h:188
Selected.
Definition: fxdefs.h:207
Left mouse button pressed.
Definition: fxdefs.h:169
Start a drag.
Definition: fxdefs.h:215
Link.
Definition: fxdefs.h:335
Inserted.
Definition: fxdefs.h:208
FXint wcdec(const FXchar *string, FXint pos)
Retreat to previous utf8 character start.
Focus moved up.
Definition: fxdefs.h:229
Right mouse button pressed.
Definition: fxdefs.h:173
Normal crossing event.
Definition: fxdefs.h:293
Deselected.
Definition: fxdefs.h:206
void void void void fxassert(const char *expression, const char *filename, unsigned int lineno)
Assert failed routine:- usually not called directly but called through FXASSERT.
Close window.
Definition: fxdefs.h:193
Scroll Lock key is down (seems to vary)
Definition: fxdefs.h:268
bool fxtoDOS(FXchar *&string, FXint &len)
Convert string of length len to MSDOS; return new string and new length.
FXint utf2ncs(FXnchar *dst, const FXchar *src, FXint n)
Copy utf8 string of length n to narrow character string dst.
Shift key is down.
Definition: fxdefs.h:257
Definition: fxdefs.h:307
#define FALSE
Definition: fxdefs.h:35
Left mouse button released.
Definition: fxdefs.h:170
Right mouse button is down.
Definition: fxdefs.h:271
Lost the grab (Windows)
Definition: fxdefs.h:181
Definition: fxdefs.h:184
Always use exponential notation.
Definition: fxdefs.h:359
Clicked.
Definition: fxdefs.h:200
Collapsed.
Definition: fxdefs.h:214
Timeout occurred.
Definition: fxdefs.h:219
Maximized.
Definition: fxdefs.h:197
Focus moved left.
Definition: fxdefs.h:227
Mouse wheel.
Definition: fxdefs.h:203
Drag action entering potential drop target.
Definition: fxdefs.h:232
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
unsigned char FXuchar
Definition: fxdefs.h:392
Toolbar floated.
Definition: fxdefs.h:244
void fxfree(void **ptr)
Free memory, resets ptr to NULL afterward.
FXint FXInputHandle
Definition: fxdefs.h:468
float FXfloat
Definition: fxdefs.h:398
FXColor fxcolorfromname(const FXchar *colorname)
Get RGB value from color name.
Widget lost clipboard.
Definition: fxdefs.h:221
Session is about to close.
Definition: fxdefs.h:245
Num Lock key is down.
Definition: fxdefs.h:267
Focus moved to next widget.
Definition: fxdefs.h:230
FXwchar wc(const FXchar *ptr)
Return wide character from utf8 string at ptr.
Drag position changed over potential drop target.
Definition: fxdefs.h:235
Wrap around to start.
Definition: fxdefs.h:373
FXSelType
Definition: fxdefs.h:165
FXchar * fxstrdup(const FXchar *str)
Duplicate string.
Widget gained clipboard.
Definition: fxdefs.h:222
void fxerror(const char *format,...) FX_PRINTF(1
Error routine.
Prefix of subject string.
Definition: fxdefs.h:377
Triple-clicked.
Definition: fxdefs.h:202
Definition: fxdefs.h:180
Lassoed.
Definition: fxdefs.h:218
FXint wcvalidate(const FXchar *string, FXint pos)
Return start of utf8 character containing position.
Message inquiring about statusline help.
Definition: fxdefs.h:242
Definition: fxdefs.h:166
Focus on widget itself.
Definition: fxdefs.h:225
Compare without regard to case.
Definition: fxdefs.h:321
Mouse motion.
Definition: fxdefs.h:175
unsigned long FXuval
Definition: fxdefs.h:436
Window to top of stack.
Definition: fxdefs.h:191
Leading `.' is matched only explicitly.
Definition: fxdefs.h:319
Replaced.
Definition: fxdefs.h:209
FXint fxieeedoubleclass(FXdouble number)
Delete window.
Definition: fxdefs.h:194
Focus out of window.
Definition: fxdefs.h:179
Key released.
Definition: fxdefs.h:168
FXbool fxisconsole(const FXchar *path)
True if executable with given path is a console application.
Search backward.
Definition: fxdefs.h:371
FXID FXDragType
Definition: fxdefs.h:461
Verify change.
Definition: fxdefs.h:205
Primary selection.
Definition: fxdefs.h:346
bool fxfromDOS(FXchar *&string, FXint &len)
Convert string of length len from MSDOS; return new string and new length.
Alt key is down.
Definition: fxdefs.h:264
FXint fxresize(void **ptr, unsigned long size)
Resize memory.
FXint nc2utfs(FXchar *dst, const FXnchar *src, FXint n)
Copy narrow character substring of length n to dst.
FXint ncslen(const FXchar *str, FXint n)
Length of narrow character representation of utf8 string str of length n.
FXColor makeShadowColor(FXColor clr)
Get shadow color.
Middle mouse button released.
Definition: fxdefs.h:172
Message inquiring about tooltip.
Definition: fxdefs.h:241
Crossing due to mouse grab.
Definition: fxdefs.h:294
FXint fxparsegeometry(const FXchar *string, FXint &x, FXint &y, FXint &w, FXint &h)
Parse geometry, a-la X11 geometry specification.
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
#define MAYBE
Definition: fxdefs.h:38
void void fxwarning(const char *format,...) FX_PRINTF(1
Warning routine.
Inquire drag and drop data.
Definition: fxdefs.h:236

Copyright © 1997-2005 Jeroen van der Zijp