Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
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,2005 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.195 2005/02/04 03:41:00 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 friend class FXDockHandler; 00160 friend class FXEmbedderWindow; 00161 00162 private: 00163 00164 // Platform independent private data 00165 void *display; // Display we're talking to 00166 const FXchar *dpy; // Initial display guess 00167 FXHash hash; // Window handle hash table 00168 FXRegistry registry; // Application setting registry 00169 FXWindow *focusWindow; // Window which has the focus 00170 FXWindow *cursorWindow; // Window under the cursor 00171 FXWindow *mouseGrabWindow; // Window which grabbed the mouse 00172 FXWindow *keyboardGrabWindow; // Window which grabbed the keyboard 00173 FXWindow *keyWindow; // Window in which keyboard key was pressed 00174 FXWindow *selectionWindow; // Selection window 00175 FXWindow *clipboardWindow; // Clipboard window 00176 FXWindow *dropWindow; // Drop target window 00177 FXWindow *dragWindow; // Drag source window 00178 FXWindow *refresher; // GUI refresher pointer 00179 FXWindow *refresherstop; // GUI refresher end pointer 00180 FXPopup *popupWindow; // Current popup window 00181 FXRootWindow *root; // Root window 00182 FXVisual *monoVisual; // Monochrome visual 00183 FXVisual *defaultVisual; // Default [color] visual 00184 FXTimer *timers; // List of timers, sorted by time 00185 FXChore *chores; // List of chores 00186 FXRepaint *repaints; // Unhandled repaint rectangles 00187 FXTimer *timerrecs; // List of recycled timer records 00188 FXChore *chorerecs; // List of recycled chore records 00189 FXRepaint *repaintrecs; // List of recycled repaint records 00190 FXInvocation *invocation; // Modal loop invocation 00191 FXSignal *signals; // Array of signal records 00192 FXint nsignals; // Number of signals 00193 FXFont *normalFont; // Normal font 00194 FXFont *stockFont; // Stock font 00195 FXMutex appMutex; // Application wide mutex 00196 FXEvent event; // Event 00197 FXInput *inputs; // Input file descriptors being watched 00198 FXint ninputs; // Number of inputs 00199 FXint maxinput; // Maximum input number 00200 FXuchar *ddeData; // DDE array 00201 FXuint ddeSize; // DDE array size 00202 FXuint maxcolors; // Maximum number of colors to allocate 00203 FXuint typingSpeed; // Typing speed 00204 FXuint clickSpeed; // Double click speed 00205 FXuint scrollSpeed; // Scroll speed 00206 FXuint scrollDelay; // Scroll delay 00207 FXuint blinkSpeed; // Cursor blink speed 00208 FXuint animSpeed; // Animation speed 00209 FXuint menuPause; // Menu popup delay 00210 FXuint tooltipPause; // Tooltip popup delay 00211 FXuint tooltipTime; // Tooltip display time 00212 FXint dragDelta; // Minimum distance considered a move 00213 FXint wheelLines; // Scroll by this many lines 00214 FXColor borderColor; // Border color 00215 FXColor baseColor; // Background color of GUI controls 00216 FXColor hiliteColor; // Highlight color of GUI controls 00217 FXColor shadowColor; // Shadow color of GUI controls 00218 FXColor backColor; // Background color 00219 FXColor foreColor; // Foreground color 00220 FXColor selforeColor; // Select foreground color 00221 FXColor selbackColor; // Select background color 00222 FXColor tipforeColor; // Tooltip foreground color 00223 FXColor tipbackColor; // Tooltip background color 00224 FXColor selMenuTextColor; // Select foreground color in menus 00225 FXColor selMenuBackColor; // Select background color in menus 00226 FXCursor *waitCursor; // Current wait cursor 00227 FXuint waitCount; // Number of times wait cursor was called 00228 FXCursor *cursor[DEF_ROTATE_CURSOR+1]; 00229 FXint appArgc; // Argument count 00230 const FXchar *const *appArgv; // Argument vector 00231 FXbool initialized; // Has been initialized 00232 00233 private: 00234 static FXApp *app; // Application pointer 00235 00236 // Platform dependent private stuff 00237 #ifndef WIN32 00238 private: 00239 FXID wmDeleteWindow; // Catch delete window 00240 FXID wmQuitApp; // Catch quit application 00241 FXID wmProtocols; // Window manager protocols 00242 FXID wmMotifHints; // Motif hints 00243 FXID wmTakeFocus; // Focus explicitly set by app 00244 FXID wmState; // Window state 00245 FXID wmNetSupported; // Extended Window Manager states list 00246 FXID wmNetState; // Extended Window Manager window state 00247 FXID wmNetHMaximized; // Extended Window Manager horizontally maximized 00248 FXID wmNetVMaximized; // Extended Window Manager vertically maximized 00249 FXID embedAtom; // XEMBED support 00250 FXID embedInfoAtom; // XEMBED info support 00251 FXID timestampAtom; // Server time 00252 FXID ddeTargets; // DDE targets atom 00253 FXID ddeAtom; // DDE exchange atom 00254 FXID ddeDelete; // DDE delete target atom 00255 FXID ddeIncr; // DDE incremental data exchange atom 00256 FXDragType *ddeTypeList; // DDE drop type list 00257 FXuint ddeNumTypes; // DDE number of drop types 00258 FXDragAction ddeAction; // DDE action 00259 FXDragAction ansAction; // Reply action 00260 FXID xcbSelection; // Clipboard selection 00261 FXDragType *xcbTypeList; // Clipboard type list 00262 FXuint xcbNumTypes; // Clipboard number of types on list 00263 FXDragType *xselTypeList; // Selection type list 00264 FXuint xselNumTypes; // Selection number of types on list 00265 FXDragType *xdndTypeList; // XDND type list 00266 FXuint xdndNumTypes; // XDND number of types 00267 FXID xdndProxy; // XDND proxy atom 00268 FXID xdndAware; // XDND awareness atom 00269 FXID xdndEnter; // XDND enter window message 00270 FXID xdndLeave; // XDND leave window message 00271 FXID xdndPosition; // XDND position update message 00272 FXID xdndStatus; // XDND status feedback message 00273 FXID xdndDrop; // XDND drop message 00274 FXID xdndFinished; // XDND finished message 00275 FXID xdndSelection; // XDND selection atom 00276 FXID xdndActionMove; // XDND Move action 00277 FXID xdndActionCopy; // XDND Copy action 00278 FXID xdndActionLink; // XDND Link action 00279 FXID xdndActionPrivate; // XDND Private action 00280 FXID xdndTypes; // XDND types list atom 00281 FXID xdndSource; // XDND drag source window 00282 FXID xdndTarget; // XDND drop target window 00283 FXID xdndProxyTarget; // XDND window to set messages to 00284 FXbool xdndStatusPending; // XDND waiting for status feedback 00285 FXbool xdndStatusReceived; // XDND received at least one status 00286 FXbool xdndWantUpdates; // XDND target wants new positions while in rect 00287 FXRectangle xdndRect; // XDND rectangle bounding target 00288 FXint xrreventbase; // XRR event base 00289 FXID stipples[23]; // Standard stipple patterns 00290 void *r_fds; // Set of file descriptors for read 00291 void *w_fds; // Set of file descriptors for write 00292 void *e_fds; // Set of file descriptors for exceptions 00293 void *xim; // Input method 00294 void *xic; // Input method context 00295 FXbool shmi; // Use XSHM Image possible 00296 FXbool shmp; // Use XSHM Pixmap possible 00297 FXbool synchronize; // Synchronized 00298 00299 #else 00300 00301 FXushort ddeTargets; // DDE targets atom 00302 FXushort ddeAtom; // DDE Exchange Atom 00303 FXDragType ddeDelete; // DDE Delete Target Atom 00304 FXDragType *ddeTypeList; // DDE drop type list 00305 FXuint ddeNumTypes; // DDE number of drop types 00306 FXDragAction ddeAction; // DDE action 00307 FXDragAction ansAction; // Reply action 00308 FXDragType *xselTypeList; // Selection type list 00309 FXuint xselNumTypes; // Selection number of types on list 00310 void* xdndTypes; // Handle to file mapping object for types list 00311 FXushort xdndAware; // XDND awareness atom 00312 FXID xdndSource; // XDND drag source window 00313 FXID xdndTarget; // XDND drop target window 00314 FXbool xdndStatusPending; // XDND waiting for status feedback 00315 FXbool xdndFinishPending; // XDND waiting for drop-confirmation 00316 FXbool xdndStatusReceived; // XDND received at least one status 00317 FXRectangle xdndRect; // XDND rectangle bounding target 00318 FXID stipples[17]; // Standard stipple bitmaps 00319 void **handles; // Waitable object handles 00320 00321 #endif 00322 00323 private: 00324 00325 // Internal helper functions 00326 FXApp(const FXApp&); 00327 FXApp &operator=(const FXApp&); 00328 static void signalhandler(int sig); 00329 static void immediatesignalhandler(int sig); 00330 void leaveWindow(FXWindow *window,FXWindow *ancestor); 00331 void enterWindow(FXWindow *window,FXWindow *ancestor); 00332 void selectionSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); 00333 void selectionGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); 00334 void selectionGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); 00335 void clipboardSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); 00336 void clipboardGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); 00337 void clipboardGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); 00338 void dragdropSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); 00339 void dragdropGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); 00340 void dragdropGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); 00341 #ifndef WIN32 00342 void addRepaint(FXID win,FXint x,FXint y,FXint w,FXint h,FXbool synth=0); 00343 void removeRepaints(FXID win,FXint x,FXint y,FXint w,FXint h); 00344 void scrollRepaints(FXID win,FXint dx,FXint dy); 00345 #else 00346 static long CALLBACK wndproc(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam); 00347 protected: 00348 virtual long dispatchEvent(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam); 00349 #endif 00350 00351 protected: 00352 00353 /// Return TRUE when new raw event is available 00354 virtual FXbool getNextEvent(FXRawEvent& ev,FXbool blocking=TRUE); 00355 00356 /// Dispatch raw event 00357 virtual FXbool dispatchEvent(FXRawEvent& ev); 00358 00359 public: 00360 long onCmdQuit(FXObject*,FXSelector,void*); 00361 long onCmdDump(FXObject*,FXSelector,void*); 00362 long onCmdHover(FXObject*,FXSelector,void*); 00363 00364 public: 00365 00366 /// Messages applications understand 00367 enum { 00368 ID_QUIT=1, /// Terminate the application normally 00369 ID_DUMP, /// Dump the current widget tree 00370 ID_HOVER, 00371 ID_LAST 00372 }; 00373 00374 public: 00375 00376 /// Information 00377 static const FXuchar copyright[]; /// Copyright notice of library 00378 00379 public: 00380 00381 /** 00382 * Construct application object; the name and vendor strings are used 00383 * as keys into the registry database for this application's settings. 00384 * Only one single application object can be constructed. 00385 */ 00386 FXApp(const FXString& name="Application",const FXString& vendor="FoxDefault"); 00387 00388 /// Get application name 00389 const FXString& getAppName() const { return registry.getAppKey(); } 00390 00391 /// Get vendor name 00392 const FXString& getVendorName() const { return registry.getVendorKey(); } 00393 00394 /// Connection to display; this is called by init() 00395 FXbool openDisplay(const FXchar* dpyname=NULL); 00396 00397 /// Close connection to the display 00398 FXbool closeDisplay(); 00399 00400 /// Return pointer 00401 void* getDisplay() const { return display; } 00402 00403 /// Is application initialized 00404 FXbool isInitialized() const { return initialized; } 00405 00406 /// Get argument count 00407 FXint getArgc() const { return appArgc; } 00408 00409 /// Get argument vector 00410 const FXchar *const *getArgv() const { return appArgv; } 00411 00412 /// Get default visual 00413 FXVisual* getDefaultVisual() const { return defaultVisual; } 00414 00415 /// Change default visual 00416 void setDefaultVisual(FXVisual* vis); 00417 00418 /// Get monochrome visual 00419 FXVisual* getMonoVisual() const { return monoVisual; } 00420 00421 /// Get root Window 00422 FXRootWindow* getRootWindow() const { return root; } 00423 00424 /// Set root Window 00425 void setRootWindow(FXRootWindow* rt); 00426 00427 /// Get the window under the cursor, if any 00428 FXWindow *getCursorWindow() const { return cursorWindow; } 00429 00430 /// Get the window which has the focus, if any 00431 FXWindow *getFocusWindow() const { return focusWindow; } 00432 00433 /// Get current popup window, if any 00434 FXPopup* getPopupWindow() const { return popupWindow; } 00435 00436 /// Find window from id 00437 FXWindow* findWindowWithId(FXID xid) const; 00438 00439 /// Find window from root x,y, starting from given window 00440 FXWindow* findWindowAt(FXint rx,FXint ry,FXID window=0) const; 00441 00442 /// Create application's windows 00443 virtual void create(); 00444 00445 /// Destroy application's windows 00446 virtual void destroy(); 00447 00448 /// Detach application's windows 00449 virtual void detach(); 00450 00451 /** 00452 * Add timeout message to be sent to target object in ms milliseconds; 00453 * the timer fires only once after the interval expires. The void* ptr 00454 * is user data which will be passed into the void* ptr of the message 00455 * handler. If a timer with the same target and message already exists, 00456 * it will be rescheduled. 00457 */ 00458 void addTimeout(FXObject* tgt,FXSelector sel,FXuint ms=1000,void* ptr=NULL); 00459 00460 /** 00461 * Remove timeout identified by tgt and sel. 00462 */ 00463 void removeTimeout(FXObject* tgt,FXSelector sel); 00464 00465 /** 00466 * Return TRUE if given timeout has been set 00467 */ 00468 FXbool hasTimeout(FXObject *tgt,FXSelector sel) const; 00469 00470 /** 00471 * Return, in ms, the time remaining until the given timer fires. 00472 * If the timer is past due, 0 is returned. If there is no such 00473 * timer, infinity (UINT_MAX) is returned. 00474 */ 00475 FXuint remainingTimeout(FXObject *tgt,FXSelector sel); 00476 00477 /** 00478 * Process any timouts due at this time. 00479 */ 00480 void handleTimouts(); 00481 00482 /** 00483 * Add a idle processing message to be sent to target object when 00484 * the system becomes idle, i.e. there are no events to be processed. 00485 * The void* ptr is user data which will be passed into the void* ptr 00486 * of the message handler. If a chore with the same target and message 00487 * already exists, it will be rescheduled. 00488 */ 00489 void addChore(FXObject* tgt,FXSelector sel,void *ptr=NULL); 00490 00491 /** 00492 * Remove idle processing message identified by tgt and sel. 00493 */ 00494 void removeChore(FXObject* tgt,FXSelector sel); 00495 00496 /** 00497 * Return TRUE if given chore has been set 00498 */ 00499 FXbool hasChore(FXObject *tgt,FXSelector sel) const; 00500 00501 /** 00502 * Add signal processing message to be sent to target object when 00503 * the signal sig is raised; flags are to be set as per POSIX definitions. 00504 * When immediate is TRUE, the message will be sent to the target right away; 00505 * this should be used with extreme care as the application is interrupted 00506 * at an unknown point in its execution. 00507 */ 00508 void addSignal(FXint sig,FXObject* tgt,FXSelector sel,FXbool immediate=FALSE,FXuint flags=0); 00509 00510 /// Remove signal message for signal sig 00511 void removeSignal(FXint sig); 00512 00513 /** 00514 * Add a file descriptor fd to be watched for activity as determined 00515 * by mode, where mode is a bitwise OR (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT). 00516 * A message of type SEL_IO_READ, SEL_IO_WRITE, or SEL_IO_EXCEPT will be sent 00517 * to the target when the specified activity is detected on the file descriptor. 00518 */ 00519 FXbool addInput(FXInputHandle fd,FXuint mode,FXObject *tgt,FXSelector sel); 00520 00521 /** 00522 * Remove input message and target object for the specified file descriptor 00523 * and mode, which is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT). 00524 */ 00525 FXbool removeInput(FXInputHandle fd,FXuint mode); 00526 00527 /// Return key state 00528 FXbool getKeyState(FXuint keysym) const; 00529 00530 /// Peek to determine if there's an event 00531 FXbool peekEvent(); 00532 00533 /// Perform one event dispatch; return true if event was dispatched 00534 FXbool runOneEvent(FXbool blocking=TRUE); 00535 00536 /** 00537 * Run the main application event loop until stop() is called, 00538 * and return the exit code passed as argument to stop(). 00539 */ 00540 FXint run(); 00541 00542 /** 00543 * Run an event loop till some flag becomes non-zero, and 00544 * then return. 00545 */ 00546 FXint runUntil(FXuint& condition); 00547 00548 /** 00549 * Run event loop while events are available, non-modally. 00550 * Return when no more events, timers, or chores are outstanding. 00551 */ 00552 FXint runWhileEvents(); 00553 00554 /** 00555 * Run event loop while there are events are available in the queue. 00556 * Returns 1 when all events in the queue have been handled, and 0 when 00557 * the event loop was terminated due to stop() or stopModal(). 00558 * Except for the modal window and its children, user input to all windows 00559 * is blocked; if the modal window is NULL, all user input is blocked. 00560 */ 00561 FXint runModalWhileEvents(FXWindow* window=NULL); 00562 00563 /** 00564 * Run modal event loop, blocking keyboard and mouse events to all windows 00565 * until stopModal is called. 00566 */ 00567 FXint runModal(); 00568 00569 /** 00570 * Run a modal event loop for the given window, until stop() or stopModal() is 00571 * called. Except for the modal window and its children, user input to all 00572 * windows is blocked; if the modal window is NULL all user input is blocked. 00573 */ 00574 FXint runModalFor(FXWindow* window); 00575 00576 /** 00577 * Run modal while window is shown, or until stop() or stopModal() is called. 00578 * Except for the modal window and its children, user input to all windows 00579 * is blocked; if the modal window is NULL all user input is blocked. 00580 */ 00581 FXint runModalWhileShown(FXWindow* window); 00582 00583 /** 00584 * Run popup menu while shown, until stop() or stopModal() is called. 00585 * Also returns when entering previous cascading popup menu. 00586 */ 00587 FXint runPopup(FXWindow* window); 00588 00589 /// True if the window is modal 00590 FXbool isModal(FXWindow* window) const; 00591 00592 /// Return window of current modal loop 00593 FXWindow* getModalWindow() const; 00594 00595 /// Return mode of current modal loop 00596 FXModality getModality() const; 00597 00598 /** 00599 * Terminate the outermost event loop, and all inner modal loops; 00600 * All more deeper nested event loops will be terminated with code equal 00601 * to 0, while the outermost event loop will return code equal to value. 00602 */ 00603 void stop(FXint value=0); 00604 00605 /** 00606 * Break out of the matching modal loop, returning code equal to value. 00607 * All deeper nested event loops are terminated with code equal to 0. 00608 */ 00609 void stopModal(FXWindow* window,FXint value=0); 00610 00611 /** 00612 * Break out of the innermost modal loop, returning code equal to value. 00613 */ 00614 void stopModal(FXint value=0); 00615 00616 /// Force GUI refresh 00617 void forceRefresh(); 00618 00619 /// Schedule a refresh 00620 void refresh(); 00621 00622 /// Flush pending repaints 00623 void flush(FXbool sync=FALSE); 00624 00625 /** 00626 * Paint all windows marked for repainting. 00627 * On return all the applications windows have been painted. 00628 */ 00629 void repaint(); 00630 00631 /** 00632 * Initialize application. 00633 * Parses and removes common command line arguments, reads the registry. 00634 * Finally, if connect is TRUE, it opens the display. 00635 */ 00636 virtual void init(int& argc,char** argv,FXbool connect=TRUE); 00637 00638 /** 00639 * Exit application. 00640 * Closes the display and writes the registry. 00641 */ 00642 virtual void exit(FXint code=0); 00643 00644 /** 00645 * Return a reference to the registry. The registry keeps 00646 * settings and configuration information for an application, 00647 * which are automatically loaded when the application starts 00648 * up, and saved when the application terminates. 00649 */ 00650 FXRegistry& reg(){ return registry; } 00651 00652 /// Register new DND type 00653 FXDragType registerDragType(const FXString& name) const; 00654 00655 /// Get drag type name 00656 FXString getDragTypeName(FXDragType type) const; 00657 00658 /// Return drag window if a drag operation is in progress 00659 FXWindow* getDragWindow() const { return dragWindow; } 00660 00661 /// Beep 00662 void beep(); 00663 00664 /// Return application instance 00665 static inline FXApp* instance(){ return app; } 00666 00667 /// Change default font 00668 void setNormalFont(FXFont* font); 00669 00670 /// Return default font 00671 FXFont* getNormalFont() const { return normalFont; } 00672 00673 /// Begin of wait-cursor block; wait-cursor blocks may be nested. 00674 void beginWaitCursor(); 00675 00676 /// End of wait-cursor block 00677 void endWaitCursor(); 00678 00679 /// Change to a new wait cursor 00680 void setWaitCursor(FXCursor *cur); 00681 00682 /// Return current wait cursor 00683 FXCursor* getWaitCursor() const { return waitCursor; } 00684 00685 /// Obtain a default cursor 00686 FXCursor* getDefaultCursor(FXDefaultCursor which) const { return cursor[which]; } 00687 00688 /// Change default cursor 00689 void setDefaultCursor(FXDefaultCursor which,FXCursor* cur); 00690 00691 /** 00692 * Return a reference to the application-wide mutex. 00693 * Normally, the main user interface thread holds this mutex, 00694 * insuring that no other threads are modifying data during the 00695 * processing of user interface messages. However, whenever the 00696 * main user interface thread blocks for messages, it releases 00697 * this mutex, to allow other threads to modify the same data. 00698 * When a new message becomes available, the main user interface 00699 * thread regains the mutex prior to dispatching the message. 00700 * Other threads should hold this mutex only for short durations, 00701 * so as to not starve the main user interface thread. 00702 */ 00703 FXMutex& mutex(){ return appMutex; } 00704 00705 /// Obtain application-wide settings 00706 FXuint getTypingSpeed() const { return typingSpeed; } 00707 FXuint getClickSpeed() const { return clickSpeed; } 00708 FXuint getScrollSpeed() const { return scrollSpeed; } 00709 FXuint getScrollDelay() const { return scrollDelay; } 00710 FXuint getBlinkSpeed() const { return blinkSpeed; } 00711 FXuint getAnimSpeed() const { return animSpeed; } 00712 FXuint getMenuPause() const { return menuPause; } 00713 FXuint getTooltipPause() const { return tooltipPause; } 00714 FXuint getTooltipTime() const { return tooltipTime; } 00715 FXint getDragDelta() const { return dragDelta; } 00716 FXint getWheelLines() const { return wheelLines; } 00717 00718 /// Change application-wide settings 00719 void setTypingSpeed(FXuint speed); 00720 void setClickSpeed(FXuint speed); 00721 void setScrollSpeed(FXuint speed); 00722 void setScrollDelay(FXuint delay); 00723 void setBlinkSpeed(FXuint speed); 00724 void setAnimSpeed(FXuint speed); 00725 void setMenuPause(FXuint pause); 00726 void setTooltipPause(FXuint pause); 00727 void setTooltipTime(FXuint time); 00728 void setDragDelta(FXint delta); 00729 void setWheelLines(FXint lines); 00730 00731 /// Obtain default colors 00732 FXColor getBorderColor() const { return borderColor; } 00733 FXColor getBaseColor() const { return baseColor; } 00734 FXColor getHiliteColor() const { return hiliteColor; } 00735 FXColor getShadowColor() const { return shadowColor; } 00736 FXColor getBackColor() const { return backColor; } 00737 FXColor getForeColor() const { return foreColor; } 00738 FXColor getSelforeColor() const { return selforeColor; } 00739 FXColor getSelbackColor() const { return selbackColor; } 00740 FXColor getTipforeColor() const { return tipforeColor; } 00741 FXColor getTipbackColor() const { return tipbackColor; } 00742 FXColor getSelMenuTextColor() const { return selMenuTextColor; } 00743 FXColor getSelMenuBackColor() const { return selMenuBackColor; } 00744 00745 /// Change default colors 00746 void setBorderColor(FXColor color); 00747 void setBaseColor(FXColor color); 00748 void setHiliteColor(FXColor color); 00749 void setShadowColor(FXColor color); 00750 void setBackColor(FXColor color); 00751 void setForeColor(FXColor color); 00752 void setSelforeColor(FXColor color); 00753 void setSelbackColor(FXColor color); 00754 void setTipforeColor(FXColor color); 00755 void setTipbackColor(FXColor color); 00756 void setSelMenuTextColor(FXColor color); 00757 void setSelMenuBackColor(FXColor color); 00758 00759 /// Save 00760 virtual void save(FXStream& store) const; 00761 00762 /// Load 00763 virtual void load(FXStream& store); 00764 00765 /// Dump widget information 00766 void dumpWidgets() const; 00767 00768 /// Destroy the application and all reachable resources 00769 virtual ~FXApp(); 00770 }; 00771 00772 } 00773 00774 #endif
Copyright © 1997-2005 Jeroen van der Zijp |