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

FXApp.h

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

Copyright © 1997-2005 Jeroen van der Zijp