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

FXApp.h

00001 /******************************************************************************** 00002 * * 00003 * A p p l i c a t i o n O b j e c t * 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: FXApp.h,v 1.172 2004/04/30 03:44:51 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXAPP_H 00025 #define FXAPP_H 00026 00027 #ifndef FXOBJECT_H 00028 #include "FXObject.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 // Forward declarations 00035 class FXWindow; 00036 class FXIcon; 00037 class FXBitmap; 00038 class FXCursor; 00039 class FXRootWindow; 00040 class FXMainWindow; 00041 class FXPopup; 00042 class FXFont; 00043 class FXDC; 00044 class FXDCWindow; 00045 class FXVisual; 00046 class FXGLVisual; 00047 class FXGLContext; 00048 00049 00050 // Opaque FOX objects 00051 struct FXTimer; 00052 struct FXChore; 00053 struct FXSignal; 00054 struct FXRepaint; 00055 struct FXInput; 00056 struct FXInvocation; 00057 00058 00059 00060 /// File input modes for addInput 00061 enum FXInputMode { 00062 INPUT_NONE = 0, /// Inactive 00063 INPUT_READ = 1, /// Read input fd 00064 INPUT_WRITE = 2, /// Write input fd 00065 INPUT_EXCEPT = 4 /// Except input fd 00066 }; 00067 00068 00069 /// All ways of being modal 00070 enum FXModality { 00071 MODAL_FOR_NONE, /// Non modal event loop (dispatch normally) 00072 MODAL_FOR_WINDOW, /// Modal dialog (beep if outside of modal dialog) 00073 MODAL_FOR_POPUP /// Modal for popup (always dispatch to popup) 00074 }; 00075 00076 00077 /// Default cursors provided by the application 00078 enum FXDefaultCursor { 00079 DEF_ARROW_CURSOR, /// Arrow cursor 00080 DEF_RARROW_CURSOR, /// Reverse arrow cursor 00081 DEF_TEXT_CURSOR, /// Text cursor 00082 DEF_HSPLIT_CURSOR, /// Horizontal split cursor 00083 DEF_VSPLIT_CURSOR, /// Vertical split cursor 00084 DEF_XSPLIT_CURSOR, /// Cross split cursor 00085 DEF_SWATCH_CURSOR, /// Color swatch drag cursor 00086 DEF_MOVE_CURSOR, /// Move cursor 00087 DEF_DRAGH_CURSOR, /// Resize horizontal edge 00088 DEF_DRAGV_CURSOR, /// Resize vertical edge 00089 DEF_DRAGTL_CURSOR, /// Resize upper-leftcorner 00090 DEF_DRAGBR_CURSOR=DEF_DRAGTL_CURSOR, /// Resize bottom-right corner 00091 DEF_DRAGTR_CURSOR, /// Resize upper-right corner 00092 DEF_DRAGBL_CURSOR=DEF_DRAGTR_CURSOR, /// Resize bottom-left corner 00093 DEF_DNDSTOP_CURSOR, /// Drag and drop stop 00094 DEF_DNDCOPY_CURSOR, /// Drag and drop copy 00095 DEF_DNDMOVE_CURSOR, /// Drag and drop move 00096 DEF_DNDLINK_CURSOR, /// Drag and drop link 00097 DEF_CROSSHAIR_CURSOR, /// Cross hair cursor 00098 DEF_CORNERNE_CURSOR, /// North-east cursor 00099 DEF_CORNERNW_CURSOR, /// North-west cursor 00100 DEF_CORNERSE_CURSOR, /// South-east cursor 00101 DEF_CORNERSW_CURSOR, /// South-west cursor 00102 DEF_HELP_CURSOR, /// Help arrow cursor 00103 DEF_HAND_CURSOR, /// Hand cursor 00104 DEF_ROTATE_CURSOR /// Rotate cursor 00105 }; 00106 00107 00108 00109 /// FOX Event 00110 struct FXAPI FXEvent { 00111 FXuint type; /// Event type 00112 FXuint time; /// Time of last event 00113 FXint win_x; /// Window-relative x-coord 00114 FXint win_y; /// Window-relative y-coord 00115 FXint root_x; /// Root x-coord 00116 FXint root_y; /// Root y-coord 00117 FXint state; /// Keyboard/Modifier state 00118 FXint code; /// Button, Keysym, or mode; DDE Source 00119 FXString text; /// Text of keyboard event 00120 FXint last_x; /// Window-relative x-coord of previous mouse location 00121 FXint last_y; /// Window-relative y-coord of previous mouse location 00122 FXint click_x; /// Window-relative x-coord of mouse press 00123 FXint click_y; /// Window-relative y-coord of mouse press 00124 FXint rootclick_x; /// Root-relative x-coord of mouse press 00125 FXint rootclick_y; /// Root-relative y-coord of mouse press 00126 FXuint click_time; /// Time of mouse button press 00127 FXuint click_button; /// Mouse button pressed 00128 FXint click_count; /// Click-count 00129 FXbool moved; /// Moved cursor since press 00130 FXRectangle rect; /// Rectangle 00131 FXbool synthetic; /// True if synthetic expose event 00132 FXDragType target; /// Target drag type being requested 00133 }; 00134 00135 00136 /// Application Object 00137 class FXAPI FXApp : public FXObject { 00138 FXDECLARE(FXApp) 00139 00140 // We've got many friends 00141 friend class FXId; 00142 friend class FXBitmap; 00143 friend class FXImage; 00144 friend class FXIcon; 00145 friend class FXCursor; 00146 friend class FXDrawable; 00147 friend class FXWindow; 00148 friend class FXShell; 00149 friend class FXRootWindow; 00150 friend class FXTopWindow; 00151 friend class FXMainWindow; 00152 friend class FXPopup; 00153 friend class FXFont; 00154 friend class FXVisual; 00155 friend class FXGLVisual; 00156 friend class FXGLContext; 00157 friend class FXDC; 00158 friend class FXDCWindow; 00159 00160 private: 00161 00162 // Platform independent private data 00163 void *display; // Display we're talking to 00164 const FXchar *dpy; // Initial display guess 00165 FXHash hash; // Window handle hash table 00166 FXRegistry registry; // Application setting registry 00167 FXWindow *focusWindow; // Window which has the focus 00168 FXWindow *cursorWindow; // Window under the cursor 00169 FXWindow *mouseGrabWindow; // Window which grabbed the mouse 00170 FXWindow *keyboardGrabWindow; // Window which grabbed the keyboard 00171 FXWindow *keyWindow; // Window in which keyboard key was pressed 00172 FXWindow *selectionWindow; // Selection window 00173 FXWindow *clipboardWindow; // Clipboard window 00174 FXWindow *dropWindow; // Drop target window 00175 FXWindow *dragWindow; // Drag source window 00176 FXWindow *refresher; // GUI refresher pointer 00177 FXWindow *refresherstop; // GUI refresher end pointer 00178 FXPopup *popupWindow; // Current popup window 00179 FXRootWindow *root; // Root window 00180 FXVisual *monoVisual; // Monochrome visual 00181 FXVisual *defaultVisual; // Default [color] visual 00182 FXTimer *timers; // List of timers, sorted by time 00183 FXChore *chores; // List of chores 00184 FXRepaint *repaints; // Unhandled repaint rectangles 00185 FXTimer *timerrecs; // List of recycled timer records 00186 FXChore *chorerecs; // List of recycled chore records 00187 FXRepaint *repaintrecs; // List of recycled repaint records 00188 FXInvocation *invocation; // Modal loop invocation 00189 FXSignal *signals; // Array of signal records 00190 FXint nsignals; // Number of signals 00191 FXFont *normalFont; // Normal font 00192 FXFont *stockFont; // Stock font 00193 FXuint maxcolors; // Maximum number of colors to allocate 00194 FXEvent event; // Event 00195 FXInput *inputs; // Input file descriptors being watched 00196 FXint ninputs; // Number of inputs 00197 FXint maxinput; // Maximum input number 00198 FXuchar *ddeData; // DDE array 00199 FXuint ddeSize; // DDE array size 00200 FXuint typingSpeed; // Typing speed 00201 FXuint clickSpeed; // Double click speed 00202 FXuint scrollSpeed; // Scroll speed 00203 FXuint scrollDelay; // Scroll delay 00204 FXuint blinkSpeed; // Cursor blink speed 00205 FXuint animSpeed; // Animation speed 00206 FXuint menuPause; // Menu popup delay 00207 FXuint tooltipPause; // Tooltip popup delay 00208 FXuint tooltipTime; // Tooltip display time 00209 FXint dragDelta; // Minimum distance considered a move 00210 FXint wheelLines; // Scroll by this many lines 00211 FXColor borderColor; // Border color 00212 FXColor baseColor; // Background color of GUI controls 00213 FXColor hiliteColor; // Highlight color of GUI controls 00214 FXColor shadowColor; // Shadow color of GUI controls 00215 FXColor backColor; // Background color 00216 FXColor foreColor; // Foreground color 00217 FXColor selforeColor; // Select foreground color 00218 FXColor selbackColor; // Select background color 00219 FXColor tipforeColor; // Tooltip foreground color 00220 FXColor tipbackColor; // Tooltip background color 00221 FXCursor *waitCursor; // Current wait cursor 00222 FXuint waitCount; // Number of times wait cursor was called 00223 FXCursor *cursor[DEF_ROTATE_CURSOR+1]; 00224 FXint appArgc; // Argument count 00225 const FXchar *const *appArgv; // Argument vector 00226 FXbool initialized; // Has been initialized 00227 00228 private: 00229 static FXApp *app; // Application pointer 00230 00231 // Platform dependent private stuff 00232 #ifndef WIN32 00233 private: 00234 FXID wmDeleteWindow; // Catch delete window 00235 FXID wmQuitApp; // Catch quit application 00236 FXID wmProtocols; // Window manager protocols 00237 FXID wmMotifHints; // Motif hints 00238 FXID wmTakeFocus; // Focus explicitly set by app 00239 FXID wmState; // Window state 00240 FXID wmNetSupported; // Extended Window Manager states list 00241 FXID wmNetState; // Extended Window Manager window state 00242 FXID wmNetHMaximized; // Extended Window Manager horizontally maximized 00243 FXID wmNetVMaximized; // Extended Window Manager vertically maximized 00244 FXID ddeTargets; // DDE targets atom 00245 FXID ddeAtom; // DDE exchange atom 00246 FXID ddeDelete; // DDE delete target atom 00247 FXID ddeIncr; // DDE incremental data exchange atom 00248 FXDragType *ddeTypeList; // DDE drop type list 00249 FXuint ddeNumTypes; // DDE number of drop types 00250 FXDragAction ddeAction; // DDE action 00251 FXDragAction ansAction; // Reply action 00252 FXID xcbSelection; // Clipboard selection 00253 FXDragType *xcbTypeList; // Clipboard type list 00254 FXuint xcbNumTypes; // Clipboard number of types on list 00255 FXDragType *xselTypeList; // Selection type list 00256 FXuint xselNumTypes; // Selection number of types on list 00257 FXDragType *xdndTypeList; // XDND type list 00258 FXuint xdndNumTypes; // XDND number of types 00259 FXID xdndProxy; // XDND proxy atom 00260 FXID xdndAware; // XDND awareness atom 00261 FXID xdndEnter; // XDND enter window message 00262 FXID xdndLeave; // XDND leave window message 00263 FXID xdndPosition; // XDND position update message 00264 FXID xdndStatus; // XDND status feedback message 00265 FXID xdndDrop; // XDND drop message 00266 FXID xdndFinished; // XDND finished message 00267 FXID xdndSelection; // XDND selection atom 00268 FXID xdndActionMove; // XDND Move action 00269 FXID xdndActionCopy; // XDND Copy action 00270 FXID xdndActionLink; // XDND Link action 00271 FXID xdndActionPrivate; // XDND Private action 00272 FXID xdndTypes; // XDND types list atom 00273 FXID xdndSource; // XDND drag source window 00274 FXID xdndTarget; // XDND drop target window 00275 FXID xdndProxyTarget; // XDND window to set messages to 00276 FXbool xdndStatusPending; // XDND waiting for status feedback 00277 FXbool xdndStatusReceived; // XDND received at least one status 00278 FXbool xdndWantUpdates; // XDND target wants new positions while in rect 00279 FXRectangle xdndRect; // XDND rectangle bounding target 00280 FXID stipples[23]; // Standard stipple patterns 00281 void *r_fds; // Set of file descriptors for read 00282 void *w_fds; // Set of file descriptors for write 00283 void *e_fds; // Set of file descriptors for exceptions 00284 void *xim; // Input method 00285 void *xic; // Input method context 00286 FXbool shmi; // Use XSHM Image possible 00287 FXbool shmp; // Use XSHM Pixmap possible 00288 FXbool synchronize; // Synchronized 00289 00290 #else 00291 00292 FXushort ddeTargets; // DDE targets atom 00293 FXushort ddeAtom; // DDE Exchange Atom 00294 FXDragType ddeDelete; // DDE Delete Target Atom 00295 FXDragType *ddeTypeList; // DDE drop type list 00296 FXuint ddeNumTypes; // DDE number of drop types 00297 FXDragAction ddeAction; // DDE action 00298 FXDragAction ansAction; // Reply action 00299 FXDragType *xselTypeList; // Selection type list 00300 FXuint xselNumTypes; // Selection number of types on list 00301 void* xdndTypes; // Handle to file mapping object for types list 00302 FXushort xdndAware; // XDND awareness atom 00303 FXID xdndSource; // XDND drag source window 00304 FXID xdndTarget; // XDND drop target window 00305 FXbool xdndStatusPending; // XDND waiting for status feedback 00306 FXbool xdndFinishPending; // XDND waiting for drop-confirmation 00307 FXbool xdndStatusReceived; // XDND received at least one status 00308 FXRectangle xdndRect; // XDND rectangle bounding target 00309 FXID stipples[17]; // Standard stipple bitmaps 00310 void **handles; // Waitable object handles 00311 00312 #endif 00313 00314 private: 00315 00316 // Internal helper functions 00317 FXApp(const FXApp&); 00318 FXApp &operator=(const FXApp&); 00319 static void signalhandler(int sig); 00320 static void immediatesignalhandler(int sig); 00321 void dragdropSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); 00322 void dragdropGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); 00323 void dragdropGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); 00324 void selectionSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); 00325 void selectionGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); 00326 void selectionGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); 00327 void clipboardSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); 00328 void clipboardGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); 00329 void clipboardGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); 00330 #ifndef WIN32 00331 void addRepaint(FXID win,FXint x,FXint y,FXint w,FXint h,FXbool synth=0); 00332 void removeRepaints(FXID win,FXint x,FXint y,FXint w,FXint h); 00333 void scrollRepaints(FXID win,FXint dx,FXint dy); 00334 #else 00335 void leaveWindow(FXWindow *win,FXWindow *anc); 00336 void enterWindow(FXWindow *win,FXWindow *anc); 00337 static long CALLBACK wndproc(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam); 00338 protected: 00339 virtual long dispatchEvent(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam); 00340 #endif 00341 00342 protected: 00343 00344 /// Return TRUE when new raw event is available 00345 virtual FXbool getNextEvent(FXRawEvent& ev,FXbool blocking=TRUE); 00346 00347 /// Dispatch raw event 00348 virtual FXbool dispatchEvent(FXRawEvent& ev); 00349 00350 public: 00351 long onCmdQuit(FXObject*,FXSelector,void*); 00352 long onCmdDump(FXObject*,FXSelector,void*); 00353 00354 public: 00355 00356 /// Messages applications understand 00357 enum { 00358 ID_QUIT=0, /// Terminate the application normally 00359 ID_DUMP, /// Dump the current widget tree 00360 ID_LAST 00361 }; 00362 00363 public: 00364 00365 /// Information 00366 static const FXuchar copyright[]; /// Copyright notice of library 00367 00368 public: 00369 00370 /** 00371 * Construct application object; the name and vendor strings are used 00372 * as keys into the registry database for this application's settings 00373 */ 00374 FXApp(const FXString& name="Application",const FXString& vendor="FoxDefault"); 00375 00376 /// Get application name 00377 FXString getAppName() const { return registry.getAppKey(); } 00378 00379 /// Get vendor name 00380 FXString getVendorName() const { return registry.getVendorKey(); } 00381 00382 /// Connection to display; this is called by init() 00383 FXbool openDisplay(const FXchar* dpyname=NULL); 00384 00385 /// Close connection to the display 00386 FXbool closeDisplay(); 00387 00388 /// Return pointer 00389 void* getDisplay() const { return display; } 00390 00391 /// Is application initialized 00392 FXbool isInitialized() const { return initialized; } 00393 00394 /// Get argument count 00395 FXint getArgc() const { return appArgc; } 00396 00397 /// Get argument vector 00398 const FXchar *const *getArgv() const { return appArgv; } 00399 00400 /// Get default visual 00401 FXVisual* getDefaultVisual() const { return defaultVisual; } 00402 00403 /// Change default visual 00404 void setDefaultVisual(FXVisual* vis); 00405 00406 /// Get monochrome visual 00407 FXVisual* getMonoVisual() const { return monoVisual; } 00408 00409 /// Get root Window 00410 FXRootWindow* getRootWindow() const { return root; } 00411 00412 /// Get the window under the cursor, if any 00413 FXWindow *getCursorWindow() const { return cursorWindow; } 00414 00415 /// Get the window which has the focus, if any 00416 FXWindow *getFocusWindow() const { return focusWindow; } 00417 00418 /// Get current popup window, if any 00419 FXPopup* getPopupWindow() const { return popupWindow; } 00420 00421 /// Find window from id 00422 FXWindow* findWindowWithId(FXID xid) const; 00423 00424 /// Find window from root x,y, starting from given window 00425 FXWindow* findWindowAt(FXint rx,FXint ry,FXID window=0) const; 00426 00427 /** 00428 * Add timeout message to be sent to target object in ms milliseconds; 00429 * the timer fires only once after the interval expires. The void* ptr 00430 * is user data which will be passed into the void* ptr of the message 00431 * handler. If a timer with the same target and message already exists, 00432 * it will be rescheduled. 00433 */ 00434 FXTimer* addTimeout(FXObject* tgt,FXSelector sel,FXuint ms=1000,void* ptr=NULL); 00435 00436 /** 00437 * Remove timeout identified by tgt and sel; returns NULL. 00438 */ 00439 FXTimer* removeTimeout(FXObject* tgt,FXSelector sel); 00440 00441 /** 00442 * Remove timeout t; returns NULL. 00443 */ 00444 FXTimer* removeTimeout(FXTimer *t); 00445 00446 /** 00447 * Return TRUE if given timeout has been set 00448 */ 00449 FXbool hasTimeout(FXObject *tgt,FXSelector sel) const; 00450 00451 /** 00452 * Return, in ms, the time remaining until the given timer fires. 00453 * If the timer is past due, 0 is returned. If there is no such 00454 * timer, infinity (UINT_MAX) is returned. 00455 */ 00456 FXuint remainingTimeout(FXObject *tgt,FXSelector sel) const; 00457 00458 /** 00459 * Return, in ms, the time remaining until the given timer fires. 00460 * If the timer is past due, 0 is returned. If there is no such 00461 * timer, infinity (UINT_MAX) is returned. 00462 */ 00463 FXuint remainingTimeout(FXTimer *t) const; 00464 00465 /** 00466 * Add a idle processing message to be sent to target object when 00467 * the system becomes idle, i.e. there are no events to be processed. 00468 * The void* ptr is user data which will be passed into the void* ptr 00469 * of the message handler. If a chore with the same target and message 00470 * already exists, it will be rescheduled. 00471 */ 00472 FXChore* addChore(FXObject* tgt,FXSelector sel,void *ptr=NULL); 00473 00474 /** 00475 * Remove idle processing message identified by tgt and sel; returns NULL. 00476 */ 00477 FXChore* removeChore(FXObject* tgt,FXSelector sel); 00478 00479 /** 00480 * Remove idle processing message; returns NULL. 00481 */ 00482 FXChore* removeChore(FXChore *c); 00483 00484 /** 00485 * Return TRUE if given chore has been set 00486 */ 00487 FXbool hasChore(FXObject *tgt,FXSelector sel) const; 00488 00489 /** 00490 * Add signal processing message to be sent to target object when 00491 * the signal sig is raised; flags are to be set as per POSIX definitions. 00492 * When immediate is TRUE, the message will be sent to the target right away; 00493 * this should be used with extreme care as the application is interrupted 00494 * at an unknown point in its execution. 00495 */ 00496 void addSignal(FXint sig,FXObject* tgt,FXSelector sel,FXbool immediate=FALSE,FXuint flags=0); 00497 00498 /// Remove signal message for signal sig 00499 void removeSignal(FXint sig); 00500 00501 /** 00502 * Add a file descriptor fd to be watched for activity as determined 00503 * by mode, where mode is a bitwise OR (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT). 00504 * A message of type SEL_IO_READ, SEL_IO_WRITE, or SEL_IO_EXCEPT will be sent 00505 * to the target when the specified activity is detected on the file descriptor. 00506 */ 00507 FXbool addInput(FXInputHandle fd,FXuint mode,FXObject *tgt,FXSelector sel); 00508 00509 /** 00510 * Remove input message and target object for the specified file descriptor 00511 * and mode, which is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT). 00512 */ 00513 FXbool removeInput(FXInputHandle fd,FXuint mode); 00514 00515 /// Create application's windows 00516 virtual void create(); 00517 00518 /// Destroy application's windows 00519 virtual void destroy(); 00520 00521 /// Detach application's windows 00522 virtual void detach(); 00523 00524 /// Peek to determine if there's an event 00525 FXbool peekEvent(); 00526 00527 /// Perform one event dispatch; return true if event was dispatched 00528 FXbool runOneEvent(FXbool blocking=TRUE); 00529 00530 /** 00531 * Run the main application event loop until stop() is called, 00532 * and return the exit code passed as argument to stop(). 00533 */ 00534 FXint run(); 00535 00536 /** 00537 * Run an event loop till some flag becomes non-zero, and 00538 * then return. 00539 */ 00540 FXint runUntil(FXuint& condition); 00541 00542 /** 00543 * Run event loop while events are available, non-modally. 00544 * Return when no more events, timers, or chores are outstanding. 00545 */ 00546 FXint runWhileEvents(); 00547 00548 /** 00549 * Run event loop while there are events are available in the queue. 00550 * Returns 1 when all events in the queue have been handled, and 0 when 00551 * the event loop was terminated due to stop() or stopModal(). 00552 * Except for the modal window and its children, user input to all windows 00553 * is blocked; if the modal window is NULL, all user input is blocked. 00554 */ 00555 FXint runModalWhileEvents(FXWindow* window=NULL); 00556 00557 /** 00558 * Run modal event loop, blocking keyboard and mouse events to all windows 00559 * until stopModal is called. 00560 */ 00561 FXint runModal(); 00562 00563 /** 00564 * Run a modal event loop for the given window, until stop() or stopModal() is 00565 * called. Except for the modal window and its children, user input to all 00566 * windows is blocked; if the modal window is NULL all user input is blocked. 00567 */ 00568 FXint runModalFor(FXWindow* window); 00569 00570 /** 00571 * Run modal while window is shown, or until stop() or stopModal() is called. 00572 * Except for the modal window and its children, user input to all windows 00573 * is blocked; if the modal window is NULL all user input is blocked. 00574 */ 00575 FXint runModalWhileShown(FXWindow* window); 00576 00577 /** 00578 * Run popup menu while shown, until stop() or stopModal() is called. 00579 * Also returns when entering previous cascading popup menu. 00580 */ 00581 FXint runPopup(FXWindow* window); 00582 00583 /// True if the window is modal 00584 FXbool isModal(FXWindow* window) const; 00585 00586 /// Return window of current modal loop 00587 FXWindow* getModalWindow() const; 00588 00589 /// Return mode of current modal loop 00590 FXModality getModality() const; 00591 00592 /** 00593 * Terminate the outermost event loop, and all inner modal loops; 00594 * All more deeper nested event loops will be terminated with code equal 00595 * to 0, while the outermost event loop will return code equal to value. 00596 */ 00597 void stop(FXint value=0); 00598 00599 /** 00600 * Break out of the matching modal loop, returning code equal to value. 00601 * All deeper nested event loops are terminated with code equal to 0. 00602 */ 00603 void stopModal(FXWindow* window,FXint value=0); 00604 00605 /** 00606 * Break out of the innermost modal loop, returning code equal to value. 00607 */ 00608 void stopModal(FXint value=0); 00609 00610 /// Force GUI refresh 00611 void forceRefresh(); 00612 00613 /// Schedule a refresh 00614 void refresh(); 00615 00616 /// Flush pending repaints 00617 void flush(FXbool sync=FALSE); 00618 00619 /** 00620 * Paint all windows marked for repainting. 00621 * On return all the applications windows have been painted. 00622 */ 00623 void repaint(); 00624 00625 /** 00626 * Initialize application. 00627 * Parses and removes common command line arguments, reads the registry. 00628 * Finally, if connect is TRUE, it opens the display. 00629 */ 00630 virtual void init(int& argc,char** argv,FXbool connect=TRUE); 00631 00632 /** 00633 * Exit application. 00634 * Closes the display and writes the registry. 00635 */ 00636 virtual void exit(FXint code=0); 00637 00638 /// Get registry 00639 FXRegistry& reg(){ return registry; } 00640 00641 /// Register new DND type 00642 FXDragType registerDragType(const FXString& name) const; 00643 00644 /// Get drag type name 00645 FXString getDragTypeName(FXDragType type) const; 00646 00647 /// Return drag window if a drag operation is in progress 00648 FXWindow* getDragWindow() const { return dragWindow; } 00649 00650 /// Beep 00651 void beep(); 00652 00653 /// Return application instance 00654 static inline FXApp* instance(){ return app; } 00655 00656 /// Change default font 00657 void setNormalFont(FXFont* font); 00658 00659 /// Return default font 00660 FXFont* getNormalFont() const { return normalFont; } 00661 00662 /// Begin of wait-cursor block; wait-cursor blocks may be nested. 00663 void beginWaitCursor(); 00664 00665 /// End of wait-cursor block 00666 void endWaitCursor(); 00667 00668 /// Change to a new wait cursor 00669 void setWaitCursor(FXCursor *cur); 00670 00671 /// Return current wait cursor 00672 FXCursor* getWaitCursor() const { return waitCursor; } 00673 00674 /// Obtain a default cursor 00675 FXCursor* getDefaultCursor(FXDefaultCursor which) const { return cursor[which]; } 00676 00677 /// Change default cursor 00678 void setDefaultCursor(FXDefaultCursor which,FXCursor* cur); 00679 00680 /// Obtain application-wide settings 00681 FXuint getTypingSpeed() const { return typingSpeed; } 00682 FXuint getClickSpeed() const { return clickSpeed; } 00683 FXuint getScrollSpeed() const { return scrollSpeed; } 00684 FXuint getScrollDelay() const { return scrollDelay; } 00685 FXuint getBlinkSpeed() const { return blinkSpeed; } 00686 FXuint getAnimSpeed() const { return animSpeed; } 00687 FXuint getMenuPause() const { return menuPause; } 00688 FXuint getTooltipPause() const { return tooltipPause; } 00689 FXuint getTooltipTime() const { return tooltipTime; } 00690 FXint getDragDelta() const { return dragDelta; } 00691 FXint getWheelLines() const { return wheelLines; } 00692 00693 /// Change application-wide settings 00694 void setTypingSpeed(FXuint speed); 00695 void setClickSpeed(FXuint speed); 00696 void setScrollSpeed(FXuint speed); 00697 void setScrollDelay(FXuint delay); 00698 void setBlinkSpeed(FXuint speed); 00699 void setAnimSpeed(FXuint speed); 00700 void setMenuPause(FXuint pause); 00701 void setTooltipPause(FXuint pause); 00702 void setTooltipTime(FXuint time); 00703 void setDragDelta(FXint delta); 00704 void setWheelLines(FXint lines); 00705 00706 /// Obtain default colors 00707 FXColor getBorderColor() const { return borderColor; } 00708 FXColor getBaseColor() const { return baseColor; } 00709 FXColor getHiliteColor() const { return hiliteColor; } 00710 FXColor getShadowColor() const { return shadowColor; } 00711 FXColor getBackColor() const { return backColor; } 00712 FXColor getForeColor() const { return foreColor; } 00713 FXColor getSelforeColor() const { return selforeColor; } 00714 FXColor getSelbackColor() const { return selbackColor; } 00715 FXColor getTipforeColor() const { return tipforeColor; } 00716 FXColor getTipbackColor() const { return tipbackColor; } 00717 00718 /// Change default colors 00719 void setBorderColor(FXColor color); 00720 void setBaseColor(FXColor color); 00721 void setHiliteColor(FXColor color); 00722 void setShadowColor(FXColor color); 00723 void setBackColor(FXColor color); 00724 void setForeColor(FXColor color); 00725 void setSelforeColor(FXColor color); 00726 void setSelbackColor(FXColor color); 00727 void setTipforeColor(FXColor color); 00728 void setTipbackColor(FXColor color); 00729 00730 /// Save 00731 virtual void save(FXStream& store) const; 00732 00733 /// Load 00734 virtual void load(FXStream& store); 00735 00736 /// Dump widget information 00737 void dumpWidgets() const; 00738 00739 /// Destroy the application and all reachable resources 00740 virtual ~FXApp(); 00741 }; 00742 00743 } 00744 00745 #endif

Copyright © 1997-2004 Jeroen van der Zijp