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,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXApp.h,v 1.275 2009/01/06 13:07:21 fox Exp $                            *
00022 ********************************************************************************/
00023 #ifndef FXAPP_H
00024 #define FXAPP_H
00025 
00026 #ifndef FXOBJECT_H
00027 #include "FXObject.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 // Forward declarations
00034 class FXApp;
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 class FXTranslator;
00049 class FXComposeContext;
00050 
00051 // Opaque FOX objects
00052 struct FXTimer;
00053 struct FXChore;
00054 struct FXSignal;
00055 struct FXRepaint;
00056 struct FXInput;
00057 struct FXHandles;
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_DNDASK_CURSOR,                    /// Drag and drop ask
00097   DEF_DNDCOPY_CURSOR,                   /// Drag and drop copy
00098   DEF_DNDMOVE_CURSOR,                   /// Drag and drop move
00099   DEF_DNDLINK_CURSOR,                   /// Drag and drop link
00100   DEF_CROSSHAIR_CURSOR,                 /// Cross hair cursor
00101   DEF_CORNERNE_CURSOR,                  /// North-east cursor
00102   DEF_CORNERNW_CURSOR,                  /// North-west cursor
00103   DEF_CORNERSE_CURSOR,                  /// South-east cursor
00104   DEF_CORNERSW_CURSOR,                  /// South-west cursor
00105   DEF_HELP_CURSOR,                      /// Help arrow cursor
00106   DEF_HAND_CURSOR,                      /// Hand cursor
00107   DEF_ROTATE_CURSOR,                    /// Rotate cursor
00108   DEF_BLANK_CURSOR,                     /// Blank cursor
00109   DEF_WAIT_CURSOR                       /// Wait cursor
00110   };
00111 
00112 
00113 
00114 /// FOX Event
00115 struct FXAPI FXEvent {
00116   FXuint      type;           /// Event type
00117   FXuint      time;           /// Time of last event
00118   FXint       win_x;          /// Window-relative x-coord
00119   FXint       win_y;          /// Window-relative y-coord
00120   FXint       root_x;         /// Root x-coord
00121   FXint       root_y;         /// Root y-coord
00122   FXint       state;          /// Mouse button and modifier key state
00123   FXint       code;           /// Button, Keysym, or mode; DDE Source
00124   FXString    text;           /// Text of keyboard event
00125   FXint       last_x;         /// Window-relative x-coord of previous mouse location
00126   FXint       last_y;         /// Window-relative y-coord of previous mouse location
00127   FXint       click_x;        /// Window-relative x-coord of mouse press
00128   FXint       click_y;        /// Window-relative y-coord of mouse press
00129   FXint       rootclick_x;    /// Root-relative x-coord of mouse press
00130   FXint       rootclick_y;    /// Root-relative y-coord of mouse press
00131   FXuint      click_time;     /// Time of mouse button press
00132   FXint       click_button;   /// Mouse button pressed
00133   FXint       click_count;    /// Click-count
00134   FXint       values[6];      /// Valuators from space ball
00135   FXbool      moved;          /// Moved cursor since press
00136   FXRectangle rect;           /// Rectangle
00137   FXbool      synthetic;      /// True if synthetic expose event
00138   FXDragType  target;         /// Target drag type being requested
00139   };
00140 
00141 
00142 /**
00143 * The Application object is the central point of a FOX user-interface.
00144 * It manages the event queue, timers, signals, chores, and input sources.
00145 * Each FOX application should have exactly one Application object, which
00146 * is the ultimate owner of the entire widget tree; when the application
00147 * object is deleted, all the widgets and other reachable resources of
00148 * the widget tree are also deleted.
00149 * When the Application is initialized using init(), it parses the
00150 * command line arguments meant for it, and opens the display.
00151 * The run() function is used to run the application; this function
00152 * does not return until the user is ready to quit the application.
00153 * During run(), the application processes events from the various
00154 * windows and dispatches them to the appropriate handlers.
00155 * Finally, a call to exit() terminates the application.
00156 * The Application object also manages a registry of configuration
00157 * data, which is read during init() and written back at the exit();
00158 * thus, all configurations changed by the user normally persist to
00159 * the next invocation of the application.
00160 * Since different organizations and different applications each need
00161 * to keep their own set of configuration data, an application name
00162 * and vendor name can be passed in the Application object's constructor
00163 * to identify a particular application's configuration data.
00164 */
00165 class FXAPI FXApp : public FXObject {
00166   FXDECLARE(FXApp)
00167 
00168   // We've got many friends
00169   friend class FXId;
00170   friend class FXBitmap;
00171   friend class FXImage;
00172   friend class FXIcon;
00173   friend class FXCursor;
00174   friend class FXDrawable;
00175   friend class FXWindow;
00176   friend class FXShell;
00177   friend class FXRootWindow;
00178   friend class FXTopWindow;
00179   friend class FXMainWindow;
00180   friend class FXPopup;
00181   friend class FXFont;
00182   friend class FXVisual;
00183   friend class FXGLVisual;
00184   friend class FXGLContext;
00185   friend class FXDC;
00186   friend class FXDCWindow;
00187   friend class FXDragCorner;
00188   friend class FXDockHandler;
00189   friend class FXComposeContext;
00190 
00191 private:
00192 
00193   // Platform independent private data
00194   void            *display;             // Display we're talking to
00195   const FXchar    *dpy;                 // Initial display guess
00196   FXHash           hash;                // Window handle hash table
00197   FXRegistry       registry;            // Application setting registry
00198   FXWindow        *activeWindow;        // Active toplevel window
00199   FXWindow        *cursorWindow;        // Window under the cursor
00200   FXWindow        *mouseGrabWindow;     // Window which grabbed the mouse
00201   FXWindow        *keyboardGrabWindow;  // Window which grabbed the keyboard
00202   FXWindow        *keyWindow;           // Window in which keyboard key was pressed
00203   FXWindow        *selectionWindow;     // Selection window
00204   FXWindow        *clipboardWindow;     // Clipboard window
00205   FXWindow        *dropWindow;          // Drop target window
00206   FXWindow        *dragWindow;          // Drag source window
00207   FXWindow        *refresher;           // GUI refresher pointer
00208   FXWindow        *refresherstop;       // GUI refresher end pointer
00209   FXPopup         *popupWindow;         // Current popup window
00210   FXRootWindow    *root;                // Root window
00211   FXVisual        *monoVisual;          // Monochrome visual
00212   FXVisual        *defaultVisual;       // Default [color] visual
00213   FXTimer         *timers;              // List of timers, sorted by time
00214   FXChore         *chores;              // List of chores
00215   FXRepaint       *repaints;            // Unhandled repaint rectangles
00216   FXTimer         *timerrecs;           // List of recycled timer records
00217   FXChore         *chorerecs;           // List of recycled chore records
00218   FXRepaint       *repaintrecs;         // List of recycled repaint records
00219   FXInvocation    *invocation;          // Modal loop invocation
00220   FXSignal        *signals;             // Array of signal records
00221   FXint            signalreceived;      // Latest signal received
00222   FXFont          *normalFont;          // Normal font
00223   FXFont          *stockFont;           // Stock font
00224   FXMutex          appMutex;            // Application wide mutex
00225   FXEvent          event;               // Event
00226   FXuint           stickyMods;          // Sticky modifier state
00227   FXInput         *inputs;              // Input file descriptors being watched
00228   FXint            ninputs;             // Number of inputs
00229   FXHandles       *handles;             // Input handles
00230   FXint            maxhandle;           // Maximum handle number
00231   FXuchar         *ddeData;             // DDE array
00232   FXuint           ddeSize;             // DDE array size
00233   FXuint           maxcolors;           // Maximum number of colors to allocate
00234   FXTime           typingSpeed;         // Typing speed
00235   FXTime           clickSpeed;          // Double click speed
00236   FXTime           scrollSpeed;         // Scroll speed
00237   FXTime           scrollDelay;         // Scroll delay
00238   FXTime           blinkSpeed;          // Cursor blink speed
00239   FXTime           animSpeed;           // Animation speed
00240   FXTime           menuPause;           // Menu popup delay
00241   FXTime           toolTipPause;        // Tooltip popup delay
00242   FXTime           toolTipTime;         // Tooltip display time
00243   FXTime           autoHideDelay;       // Cursor autohide delay time
00244   FXint            dragDelta;           // Minimum distance considered a move
00245   FXint            wheelLines;          // Scroll by this many lines
00246   FXint            scrollBarSize;       // Scrollbar size
00247   FXColor          borderColor;         // Border color
00248   FXColor          baseColor;           // Background color of GUI controls
00249   FXColor          hiliteColor;         // Highlight color of GUI controls
00250   FXColor          shadowColor;         // Shadow color of GUI controls
00251   FXColor          backColor;           // Background color
00252   FXColor          foreColor;           // Foreground color
00253   FXColor          selforeColor;        // Select foreground color
00254   FXColor          selbackColor;        // Select background color
00255   FXColor          tipforeColor;        // Tooltip foreground color
00256   FXColor          tipbackColor;        // Tooltip background color
00257   FXColor          selMenuTextColor;    // Select foreground color in menus
00258   FXColor          selMenuBackColor;    // Select background color in menus
00259   FXCursor        *waitCursor;          // Current wait cursor
00260   FXuint           waitCount;           // Number of times wait cursor was called
00261   FXuint           windowCount;         // Number of windows
00262   FXCursor        *cursor[DEF_WAIT_CURSOR+1];
00263   FXTranslator    *translator;          // Message translator
00264   FXint                appArgc;         // Argument count
00265   const FXchar *const *appArgv;         // Argument vector
00266   const FXchar    *inputmethod;         // Input method name
00267   const FXchar    *inputstyle;          // Input method style
00268   FXbool           initialized;         // Has been initialized
00269 
00270 private:
00271   static FXApp    *app;                 // Application pointer
00272 
00273   // Platform dependent private stuff
00274 #ifdef WIN32
00275 
00276   FXushort         ddeTargets;          // DDE targets atom
00277   FXushort         ddeAtom;             // DDE Exchange Atom
00278   FXDragType       ddeDelete;           // DDE Delete Target Atom
00279   FXDragType      *ddeTypeList;         // DDE drop type list
00280   FXuint           ddeNumTypes;         // DDE number of drop types
00281   FXDragAction     ddeAction;           // DDE action
00282   FXDragAction     ansAction;           // Reply action
00283   FXDragType      *xselTypeList;        // Selection type list
00284   FXuint           xselNumTypes;        // Selection number of types on list
00285   void*            xdndTypes;           // Handle to file mapping object for types list
00286   FXushort         xdndAware;           // XDND awareness atom
00287   FXID             xdndSource;          // XDND drag source window
00288   FXID             xdndTarget;          // XDND drop target window
00289   FXbool           xdndStatusPending;   // XDND waiting for status feedback
00290   FXbool           xdndFinishPending;   // XDND waiting for drop-confirmation
00291   FXbool           xdndStatusReceived;  // XDND received at least one status
00292   FXbool           xdndFinishSent;      // XDND finish sent
00293   FXRectangle      xdndRect;            // XDND rectangle bounding target
00294   FXID             stipples[17];        // Standard stipple bitmaps
00295 
00296 #else
00297 
00298 private:
00299   FXID             wmDeleteWindow;      // Catch delete window
00300   FXID             wmQuitApp;           // Catch quit application
00301   FXID             wmProtocols;         // Window manager protocols
00302   FXID             wmMotifHints;        // Motif hints
00303   FXID             wmTakeFocus;         // Focus explicitly set by app
00304   FXID             wmState;             // Window state
00305   FXID             wmNetState;          // Extended Window Manager window state
00306   FXID             wmNetIconName;       // Extended Window Manager icon name
00307   FXID             wmNetWindowName;     // Extended Window Manager window name
00308   FXID             wmNetSupported;      // Extended Window Manager states list
00309   FXID             wmNetHidden;         // Extended Window Manager hidden
00310   FXID             wmNetShaded;         // Extended Window Manager shaded
00311   FXID             wmNetHMaximized;     // Extended Window Manager horizontally maximized
00312   FXID             wmNetVMaximized;     // Extended Window Manager vertically maximized
00313   FXID             wmNetFullScreen;     // Extended Window Manager full screen
00314   FXID             wmNetBelowOthers;    // Extended Window Manager below others
00315   FXID             wmNetAboveOthers;    // Extended Window Manager above others
00316   FXID             wmNetNeedAttention;  // Extended Window Manager need attention
00317   FXID             wmNetMoveResize;     // Extended Window Manager drag corner
00318   FXID             wmNetRestack;        // Extended Window Manager change stacking order
00319   FXID             wmNetPing;           // Extended Window Manager ping
00320   FXID             wmNetWindowType;     // Extended Window Manager window type
00321   FXID             wmWindowTypes[14];   // Window types
00322   FXID             wmWindowRole;        // Window Role
00323   FXID             wmClientLeader;      // Client leader
00324   FXID             wmClientId;          // Client id
00325   FXID             embedAtom;           // XEMBED support
00326   FXID             embedInfoAtom;       // XEMBED info support
00327   FXID             timestampAtom;       // Server time
00328   FXID             ddeTargets;          // DDE targets atom
00329   FXID             ddeAtom;             // DDE exchange atom
00330   FXID             ddeDelete;           // DDE delete target atom
00331   FXID             ddeIncr;             // DDE incremental data exchange atom
00332   FXDragType      *ddeTypeList;         // DDE drop type list
00333   FXuint           ddeNumTypes;         // DDE number of drop types
00334   FXDragAction     ddeAction;           // DDE action
00335   FXDragAction     ansAction;           // Reply action
00336   FXID             xcbSelection;        // Clipboard selection
00337   FXDragType      *xcbTypeList;         // Clipboard type list
00338   FXuint           xcbNumTypes;         // Clipboard number of types on list
00339   FXDragType      *xselTypeList;        // Selection type list
00340   FXuint           xselNumTypes;        // Selection number of types on list
00341   FXDragType      *xdndTypeList;        // XDND type list
00342   FXuint           xdndNumTypes;        // XDND number of types
00343   FXID             xdndProxy;           // XDND proxy atom
00344   FXID             xdndAware;           // XDND awareness atom
00345   FXID             xdndEnter;           // XDND enter window message
00346   FXID             xdndLeave;           // XDND leave window message
00347   FXID             xdndPosition;        // XDND position update message
00348   FXID             xdndStatus;          // XDND status feedback message
00349   FXID             xdndDrop;            // XDND drop message
00350   FXID             xdndFinished;        // XDND finished message
00351   FXID             xdndSelection;       // XDND selection atom
00352   FXID             xdndTypes;           // XDND type list atom
00353   FXID             xdndActions;         // XDND action list atom
00354   FXID             xdndActionList[6];   // XDND actions
00355   FXID             xdndSource;          // XDND drag source window
00356   FXID             xdndTarget;          // XDND drop target window
00357   FXID             xdndProxyTarget;     // XDND window to set messages to
00358   FXbool           xdndStatusPending;   // XDND waiting for status feedback
00359   FXbool           xdndStatusReceived;  // XDND received at least one status
00360   FXbool           xdndWantUpdates;     // XDND target wants new positions while in rect
00361   FXbool           xdndFinishSent;      // XDND finish sent
00362   FXRectangle      xdndRect;            // XDND rectangle bounding target
00363   FXint            xrrScreenChange;     // Xrandr ScreenChange event
00364   FXint            xfxFixesSelection;   // Xfixes selection event
00365   FXint            xsbBallMotion;       // Space ball motion event
00366   FXint            xsbButtonPress;      // Space ball button press event
00367   FXint            xsbButtonRelease;    // Space ball button release event
00368   FXID             stipples[23];        // Standard stipple patterns
00369   void            *xsbDevice;           // Space ball input device
00370   void            *xim;                 // Input method
00371   FXbool           shmi;                // Use XSHM Image possible
00372   FXbool           shmp;                // Use XSHM Pixmap possible
00373   FXbool           xrender;             // XRender available
00374   FXbool           synchronize;         // Synchronized
00375 
00376 #endif
00377 
00378 private:
00379 
00380   // Internal helper functions
00381   FXApp(const FXApp&);
00382   FXApp &operator=(const FXApp&);
00383   static void signalhandler(int sig);
00384   static void immediatesignalhandler(int sig);
00385   void leaveWindow(FXWindow *window,FXWindow *ancestor);
00386   void enterWindow(FXWindow *window,FXWindow *ancestor);
00387   void selectionSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00388   void selectionGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00389   void selectionGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00390   void clipboardSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00391   void clipboardGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00392   void clipboardGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00393   void dragdropSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00394   void dragdropGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00395   void dragdropGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00396   void openInputDevices();
00397   void closeInputDevices();
00398 #ifdef WIN32
00399   static long CALLBACK wndproc(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam);
00400 protected:
00401   virtual long dispatchEvent(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam);
00402 #else
00403   void addRepaint(FXID win,FXint x,FXint y,FXint w,FXint h,FXbool synth=false);
00404   void removeRepaints(FXID win,FXint x,FXint y,FXint w,FXint h);
00405   void scrollRepaints(FXID win,FXint dx,FXint dy);
00406   static void imcreatecallback(void*,FXApp*,void*);
00407   static void imdestroycallback(void*,FXApp*,void*);
00408 #endif
00409 
00410 protected:
00411 
00412   /// Return true if an event arrives within blocking nanoseconds
00413   virtual FXbool getNextEvent(FXRawEvent& ev,FXTime blocking=forever);
00414 
00415   /// Dispatch raw event
00416   virtual FXbool dispatchEvent(FXRawEvent& ev);
00417 
00418 public:
00419   long onCmdQuit(FXObject*,FXSelector,void*);
00420   long onCmdDump(FXObject*,FXSelector,void*);
00421   long onCmdHover(FXObject*,FXSelector,void*);
00422 
00423 public:
00424 
00425   /// Messages applications understand
00426   enum {
00427     ID_QUIT=1,    /// Terminate the application normally
00428     ID_DUMP,      /// Dump the current widget tree
00429     ID_HOVER,
00430     ID_LAST
00431     };
00432 
00433 public:
00434 
00435   /// Information
00436   static const FXuchar copyright[];     /// Copyright notice of library
00437 
00438 public:
00439 
00440   /**
00441   * Construct application object; the name and vendor strings are used
00442   * as keys into the registry database for this application's settings.
00443   * Only one single application object can be constructed.
00444   */
00445   FXApp(const FXString& name="Application",const FXString& vendor="FoxDefault");
00446 
00447   /// Get application name
00448   const FXString& getAppName() const { return registry.getAppKey(); }
00449 
00450   /// Get vendor name
00451   const FXString& getVendorName() const { return registry.getVendorKey(); }
00452 
00453   /// Connection to display; this is called by init()
00454   FXbool openDisplay(const FXchar* dpyname=NULL);
00455 
00456   /// Close connection to the display
00457   FXbool closeDisplay();
00458 
00459   /// Return pointer
00460   void* getDisplay() const { return display; }
00461 
00462   /// Is application initialized
00463   FXbool isInitialized() const { return initialized; }
00464 
00465   /// Get argument count
00466   FXint getArgc() const { return appArgc; }
00467 
00468   /// Get argument vector
00469   const FXchar *const *getArgv() const { return appArgv; }
00470 
00471   /// Return true if input method support
00472   FXbool hasInputMethod() const;
00473 
00474   /// Get default visual
00475   FXVisual* getDefaultVisual() const { return defaultVisual; }
00476 
00477   /// Change default visual
00478   void setDefaultVisual(FXVisual* vis);
00479 
00480   /// Get monochrome visual
00481   FXVisual* getMonoVisual() const { return monoVisual; }
00482 
00483   /// Get root Window
00484   FXRootWindow* getRootWindow() const { return root; }
00485 
00486   /// Set root Window
00487   void setRootWindow(FXRootWindow* rt);
00488 
00489   /// Return window at the end of the focus chain
00490   FXWindow *getFocusWindow() const;
00491 
00492   /// Get the window under the cursor, if any
00493   FXWindow *getCursorWindow() const { return cursorWindow; }
00494 
00495   /// Get the active toplevel window, if any
00496   FXWindow *getActiveWindow() const { return activeWindow; }
00497 
00498   /// Get current popup window, if any
00499   FXPopup* getPopupWindow() const { return popupWindow; }
00500 
00501   /// Return window currently owning primary selection
00502   FXWindow* getSelectionWindow() const { return selectionWindow; }
00503 
00504   /// Return window currently owning the clipboard
00505   FXWindow* getClipboardWindow() const { return clipboardWindow; }
00506 
00507   /// Return drag window if a drag operation is in progress
00508   FXWindow* getDragWindow() const { return dragWindow; }
00509 
00510   /// Find window from id
00511   FXWindow* findWindowWithId(FXID xid) const;
00512 
00513   /// Find window from root x,y, starting from given window
00514   FXWindow* findWindowAt(FXint rx,FXint ry,FXID window=0) const;
00515 
00516   /// Create application's windows
00517   virtual void create();
00518 
00519   /// Destroy application's windows
00520   virtual void destroy();
00521 
00522   /// Detach application's windows
00523   virtual void detach();
00524 
00525   /**
00526   * Add timeout message sel to be sent to target object tgt after an interval of ns
00527   * nanoseconds; the timer fires only once after the interval expires.
00528   * The void* ptr is user data which will be passed into the void* ptr of the message
00529   * handler.
00530   * If a timer with the same target and message already exists, it will be rescheduled.
00531   * Note: the smallest interval that one can wait is actually much larger
00532   * than a nanosecond; on Unix systems, the smallest interval is about 1000 ns,
00533   * whereas on Windows, it is about 1000000 ns.
00534   */
00535   void addTimeout(FXObject* tgt,FXSelector sel,FXTime ns=1000000000,void* ptr=NULL);
00536 
00537   /**
00538   * Add deadline timeout message sel to be sent to target object tgt when the due time,
00539   * expressed in nanoseconds since Epoch (Jan 1, 1970), is reached.
00540   * This is the preferred way to schedule regularly occuring events, as the exact time of issue will
00541   * not suffer accumulating errors as with the addTimeout() method.  However, it is important to ensure
00542   * that the due time is sufficiently far into the future, as otherwise the system may be swamped
00543   * executing nothing but timeout messages.
00544   */
00545   void addDeadline(FXObject* tgt,FXSelector sel,FXTime due=forever,void* ptr=NULL);
00546 
00547   /**
00548   * Remove timeout identified by target object tgt and message sel; if sel=0, remove all timeouts which
00549   * reference object tgt.
00550   */
00551   void removeTimeout(FXObject* tgt,FXSelector sel=0);
00552 
00553   /**
00554   * Return true if a timeout with target object tgt and message sel has been set;
00555   * if sel=0, return true if any timeout has been set with target object tgt.
00556   */
00557   FXbool hasTimeout(FXObject *tgt,FXSelector sel=0) const;
00558 
00559   /**
00560   * Return the time (in nanoseconds) remaining until the timer identified by target object
00561   * tgt and message sel will fire.
00562   * If the timer is past due, 0 is returned.  If there is no such timer, the constant
00563   * forever (LLONG_MAX) is returned.  If sel=0, return the earliest timeout that will be
00564   * received by target object tgt.
00565   */
00566   FXTime remainingTimeout(FXObject *tgt,FXSelector sel=0);
00567 
00568   /**
00569   * Add a chore message sel to be sent to target object tgt when
00570   * the system becomes idle, i.e. there are no events to be processed.
00571   * The void* ptr is user data which will be passed into the void* ptr
00572   * of the message handler. If a chore with the same target and message
00573   * already exists, it will be rescheduled.
00574   */
00575   void addChore(FXObject* tgt,FXSelector sel,void *ptr=NULL);
00576 
00577   /**
00578   * Remove chore identified by target object tgt and message sel; if sel=0,
00579   * remove all idle processing messages which refernce object tgt.
00580   */
00581   void removeChore(FXObject* tgt,FXSelector sel=0);
00582 
00583   /**
00584   * Return true if a chore with target object tgt and message sel has been set;
00585   * if sel=0, return true if any chore has been set with target object tgt.
00586   */
00587   FXbool hasChore(FXObject *tgt,FXSelector sel=0) const;
00588 
00589   /**
00590   * Add signal processing message to be sent to target object when
00591   * the signal sig is raised; flags are to be set as per POSIX definitions.
00592   * When immediate is true, the message will be sent to the target right away;
00593   * this should be used with extreme care as the application is interrupted
00594   * at an unknown point in its execution.
00595   */
00596   void addSignal(FXint sig,FXObject* tgt,FXSelector sel,FXbool immediate=false,FXuint flags=0);
00597 
00598   /// Remove signal message for signal sig
00599   void removeSignal(FXint sig);
00600 
00601   /**
00602   * Add a file descriptor fd to be watched for activity as determined by
00603   * mode, where mode is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT).
00604   * A message of type SEL_IO_READ, SEL_IO_WRITE, or SEL_IO_EXCEPT will be sent
00605   * to the target when the specified activity is detected on the file descriptor;
00606   * the void* ptr is user data which will be passed into the void* ptr of the
00607   * mesage handler; often you will want to pass the file descriptor fd itself
00608   * as the value for ptr so that the message handler knows which file descriptor
00609   * is involved.
00610   */
00611   FXbool addInput(FXObject *tgt,FXSelector sel,FXInputHandle fd,FXuint mode=INPUT_READ,void* ptr=NULL);
00612 
00613   /**
00614   * Remove input message and target object for the specified file descriptor
00615   * and mode, which is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT).
00616   * Omitting the last parameter will delete all the handlers associated with the
00617   * file descriptor.
00618   */
00619   FXbool removeInput(FXInputHandle fd,FXuint mode=INPUT_READ);
00620 
00621   /// Return key state of given key
00622   FXbool getKeyState(FXuint keysym) const;
00623 
00624   /// Peek to determine if there's an event
00625   FXbool peekEvent();
00626 
00627   /// Perform one event dispatch; return true if event was dispatched
00628   FXbool runOneEvent(FXTime blocking=forever);
00629 
00630   /**
00631   * Run the main application event loop until stop() is called,
00632   * and return the exit code passed as argument to stop().
00633   */
00634   FXint run();
00635 
00636   /**
00637   * Run an event loop till some flag becomes non-zero, and
00638   * then return.
00639   */
00640   FXint runUntil(FXuint& condition);
00641 
00642   /**
00643   * Run non-modal event loop while events arrive within blocking nanoseconds.
00644   * Returns when no new events arrive in this time, and no timers, or chores
00645   * are outstanding.
00646   */
00647   FXint runWhileEvents(FXTime blocking=0);
00648 
00649   /**
00650   * Run modal event loop while events arrive within blocking nanoseconds.
00651   * Returns 1 when all events in the queue have been handled, and 0 when
00652   * the event loop was terminated due to stop() or stopModal().
00653   * Except for the modal window and its children, user input to all windows
00654   * is blocked; if the modal window is NULL, all user input is blocked.
00655   */
00656   FXint runModalWhileEvents(FXWindow* window=NULL,FXTime blocking=0);
00657 
00658   /**
00659   * Run modal event loop, blocking keyboard and mouse events to all windows
00660   * until stopModal is called.
00661   */
00662   FXint runModal();
00663 
00664   /**
00665   * Run a modal event loop for the given window, until stop() or stopModal() is
00666   * called. Except for the modal window and its children, user input to all
00667   * windows is blocked; if the modal window is NULL all user input is blocked.
00668   */
00669   FXint runModalFor(FXWindow* window);
00670 
00671   /**
00672   * Run modal while window is shown, or until stop() or stopModal() is called.
00673   * Except for the modal window and its children, user input to all windows
00674   * is blocked; if the modal window is NULL all user input is blocked.
00675   */
00676   FXint runModalWhileShown(FXWindow* window);
00677 
00678   /**
00679   * Run popup menu while shown, until stop() or stopModal() is called.
00680   * Also returns when entering previous cascading popup menu.
00681   */
00682   FXint runPopup(FXWindow* window);
00683 
00684   /// True if the window is modal
00685   FXbool isModal(FXWindow* window) const;
00686 
00687   /// Return window of current modal loop
00688   FXWindow* getModalWindow() const;
00689 
00690   /// Return mode of current modal loop
00691   FXModality getModality() const;
00692 
00693   /**
00694   * Terminate the outermost event loop, and all inner modal loops;
00695   * All more deeper nested event loops will be terminated with code equal
00696   * to 0, while the outermost event loop will return code equal to value.
00697   */
00698   void stop(FXint value=0);
00699 
00700   /**
00701   * Break out of the matching modal loop, returning code equal to value.
00702   * All deeper nested event loops are terminated with code equal to 0.
00703   */
00704   void stopModal(FXWindow* window,FXint value=0);
00705 
00706   /**
00707   * Break out of the innermost modal loop, returning code equal to value.
00708   */
00709   void stopModal(FXint value=0);
00710 
00711   /// Force GUI refresh
00712   void forceRefresh();
00713 
00714   /// Schedule a refresh
00715   void refresh();
00716 
00717   /// Flush pending repaints
00718   void flush(FXbool sync=false);
00719 
00720   /**
00721   * Paint all windows marked for repainting.
00722   * On return all the applications windows have been painted.
00723   */
00724   void repaint();
00725 
00726   /**
00727   * Initialize application.
00728   * Parses and removes common command line arguments, reads the registry.
00729   * Finally, if connect is true, it opens the display.
00730   */
00731   virtual void init(int& argc,char** argv,FXbool connect=true);
00732 
00733   /**
00734   * Exit application.
00735   * Closes the display and writes the registry.
00736   */
00737   virtual void exit(FXint code=0);
00738 
00739   /**
00740   * Return a reference to the registry.  The registry keeps
00741   * settings and configuration information for an application,
00742   * which are automatically loaded when the application starts
00743   * up, and saved when the application terminates.
00744   */
00745   FXRegistry& reg(){ return registry; }
00746 
00747   /// Register new DND type
00748   FXDragType registerDragType(const FXString& name) const;
00749 
00750   /// Get drag type name
00751   FXString getDragTypeName(FXDragType type) const;
00752 
00753   /// Beep
00754   void beep();
00755 
00756   /// Return application instance
00757   static inline FXApp* instance(){ return app; }
00758 
00759   /// Change default font
00760   void setNormalFont(FXFont* font);
00761 
00762   /// Return default font
00763   FXFont* getNormalFont() const { return normalFont; }
00764 
00765   /// Begin of wait-cursor block; wait-cursor blocks may be nested.
00766   void beginWaitCursor();
00767 
00768   /// End of wait-cursor block
00769   void endWaitCursor();
00770 
00771   /// Change to a new wait cursor
00772   void setWaitCursor(FXCursor *cur);
00773 
00774   /// Return current wait cursor
00775   FXCursor* getWaitCursor() const { return waitCursor; }
00776 
00777   /// Obtain a default cursor
00778   FXCursor* getDefaultCursor(FXDefaultCursor which) const { return cursor[which]; }
00779 
00780   /// Change default cursor
00781   void setDefaultCursor(FXDefaultCursor which,FXCursor* cur);
00782 
00783   /**
00784   * Return a reference to the application-wide mutex.
00785   * Normally, the main user interface thread holds this mutex,
00786   * insuring that no other threads are modifying data during the
00787   * processing of user interface messages. However, whenever the
00788   * main user interface thread blocks for messages, it releases
00789   * this mutex, to allow other threads to modify the same data.
00790   * When a new message becomes available, the main user interface
00791   * thread regains the mutex prior to dispatching the message.
00792   * Other threads should hold this mutex only for short durations,
00793   * so as to not starve the main user interface thread.
00794   */
00795   FXMutex& mutex(){ return appMutex; }
00796 
00797   /**
00798   * Change message translator.
00799   * The new translator will be owned by FXApp.
00800   */
00801   void setTranslator(FXTranslator* trans);
00802 
00803   /// Return message translator
00804   FXTranslator* getTranslator() const { return translator; }
00805 
00806   /// Obtain application-wide timing constants, in nanoseconds
00807   FXTime getTypingSpeed() const { return typingSpeed; }
00808   FXTime getClickSpeed() const { return clickSpeed; }
00809   FXTime getScrollSpeed() const { return scrollSpeed; }
00810   FXTime getScrollDelay() const { return scrollDelay; }
00811   FXTime getBlinkSpeed() const { return blinkSpeed; }
00812   FXTime getAnimSpeed() const { return animSpeed; }
00813   FXTime getMenuPause() const { return menuPause; }
00814   FXTime getToolTipPause() const { return toolTipPause; }
00815   FXTime getToolTipTime() const { return toolTipTime; }
00816   FXTime getAutoHideDelay() const { return autoHideDelay; }
00817 
00818   /// Change application-wide timing constants, in nanoseconds
00819   void setTypingSpeed(FXTime speed);
00820   void setClickSpeed(FXTime speed);
00821   void setScrollSpeed(FXTime speed);
00822   void setScrollDelay(FXTime delay);
00823   void setBlinkSpeed(FXTime speed);
00824   void setAnimSpeed(FXTime speed);
00825   void setMenuPause(FXTime pause);
00826   void setToolTipPause(FXTime pause);
00827   void setToolTipTime(FXTime time);
00828   void setAutoHideDelay(FXTime time);
00829 
00830   /// Access drag hysteresis
00831   void setDragDelta(FXint delta);
00832   FXint getDragDelta() const { return dragDelta; }
00833 
00834   /// Access mouse wheel scroll lines
00835   void setWheelLines(FXint lines);
00836   FXint getWheelLines() const { return wheelLines; }
00837 
00838   /// Access scroll bar slot size
00839   void setScrollBarSize(FXint size);
00840   FXint getScrollBarSize() const { return scrollBarSize; }
00841 
00842   /// Obtain default colors
00843   FXColor getBorderColor() const { return borderColor; }
00844   FXColor getBaseColor() const { return baseColor; }
00845   FXColor getHiliteColor() const { return hiliteColor; }
00846   FXColor getShadowColor() const { return shadowColor; }
00847   FXColor getBackColor() const { return backColor; }
00848   FXColor getForeColor() const { return foreColor; }
00849   FXColor getSelforeColor() const { return selforeColor; }
00850   FXColor getSelbackColor() const { return selbackColor; }
00851   FXColor getTipforeColor() const { return tipforeColor; }
00852   FXColor getTipbackColor() const { return tipbackColor; }
00853   FXColor getSelMenuTextColor() const { return selMenuTextColor; }
00854   FXColor getSelMenuBackColor() const { return selMenuBackColor; }
00855 
00856   /// Change default colors
00857   void setBorderColor(FXColor color);
00858   void setBaseColor(FXColor color);
00859   void setHiliteColor(FXColor color);
00860   void setShadowColor(FXColor color);
00861   void setBackColor(FXColor color);
00862   void setForeColor(FXColor color);
00863   void setSelforeColor(FXColor color);
00864   void setSelbackColor(FXColor color);
00865   void setTipforeColor(FXColor color);
00866   void setTipbackColor(FXColor color);
00867   void setSelMenuTextColor(FXColor color);
00868   void setSelMenuBackColor(FXColor color);
00869 
00870   /// Get number of existing windows
00871   FXuint getWindowCount() const { return windowCount; }
00872 
00873   /// Save
00874   virtual void save(FXStream& store) const;
00875 
00876   /// Load
00877   virtual void load(FXStream& store);
00878 
00879   /// Dump widget information
00880   void dumpWidgets() const;
00881 
00882   /// Destroy the application and all reachable resources
00883   virtual ~FXApp();
00884   };
00885 
00886 }
00887 
00888 #endif

Copyright © 1997-2009 Jeroen van der Zijp