FXApp.h

Go to the documentation of this file.
00001 #ifndef FX_DISABLEGUI
00002 /********************************************************************************
00003 *                                                                               *
00004 *                     A p p l i c a t i o n   O b j e c t                       *
00005 *                                                                               *
00006 *********************************************************************************
00007 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00008 *********************************************************************************
00009 * This library is free software; you can redistribute it and/or                 *
00010 * modify it under the terms of the GNU Lesser General Public                    *
00011 * License as published by the Free Software Foundation; either                  *
00012 * version 2.1 of the License, or (at your option) any later version.            *
00013 *                                                                               *
00014 * This library is distributed in the hope that it will be useful,               *
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00017 * Lesser General Public License for more details.                               *
00018 *                                                                               *
00019 * You should have received a copy of the GNU Lesser General Public              *
00020 * License along with this library; if not, write to the Free Software           *
00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00022 *********************************************************************************
00023 * $Id: FXApp.h,v 1.230 2006/01/22 17:57:58 fox Exp $                            *
00024 ********************************************************************************/
00025 #ifndef FXAPP_H
00026 #define FXAPP_H
00027 
00028 #ifndef FXOBJECT_H
00029 #include "FXObject.h"
00030 #endif
00031 #include "FXRectangle.h"
00032 #include "FXHash.h"
00033 #include "FXRectangle.h"
00034 #include "FXRegistry.h"
00035 
00036 namespace FX {
00037 
00038 
00039 // Forward declarations
00040 class FXId;
00041 
00042 class FXApp;
00043 class FXWindow;
00044 class FXIcon;
00045 class FXBitmap;
00046 class FXCursor;
00047 class FXRootWindow;
00048 class FXMainWindow;
00049 class FXPopup;
00050 class FXFont;
00051 class FXDC;
00052 class FXDCWindow;
00053 class FXVisual;
00054 class FXGLVisual;
00055 class FXGLContext;
00056 //class FXTranslator;
00057 class FXComposeContext;
00058 
00059 // Opaque FOX objects
00060 struct FXTimer;
00061 struct FXChore;
00062 struct FXSignal;
00063 struct FXRepaint;
00064 struct FXInput;
00065 struct FXAsyncMsg;
00066 struct FXInvocation;
00067 struct FXAppDestructUpcall;
00068 
00069 
00071 enum FXInputMode {
00072   INPUT_NONE   = 0,                 
00073   INPUT_READ   = 1,                 
00074   INPUT_WRITE  = 2,                 
00075   INPUT_EXCEPT = 4                  
00076   };
00077 
00078 
00080 enum FXModality {
00081   MODAL_FOR_NONE,                 
00082   MODAL_FOR_WINDOW,               
00083   MODAL_FOR_POPUP                 
00084   };
00085 
00086 
00088 enum FXDefaultCursor {
00089   DEF_ARROW_CURSOR,                     
00090   DEF_RARROW_CURSOR,                    
00091   DEF_TEXT_CURSOR,                      
00092   DEF_HSPLIT_CURSOR,                    
00093   DEF_VSPLIT_CURSOR,                    
00094   DEF_XSPLIT_CURSOR,                    
00095   DEF_SWATCH_CURSOR,                    
00096   DEF_MOVE_CURSOR,                      
00097   DEF_DRAGH_CURSOR,                     
00098   DEF_DRAGV_CURSOR,                     
00099   DEF_DRAGTL_CURSOR,                    
00100   DEF_DRAGBR_CURSOR=DEF_DRAGTL_CURSOR,  
00101   DEF_DRAGTR_CURSOR,                    
00102   DEF_DRAGBL_CURSOR=DEF_DRAGTR_CURSOR,  
00103   DEF_DNDSTOP_CURSOR,                   
00104   DEF_DNDCOPY_CURSOR,                   
00105   DEF_DNDMOVE_CURSOR,                   
00106   DEF_DNDLINK_CURSOR,                   
00107   DEF_CROSSHAIR_CURSOR,                 
00108   DEF_CORNERNE_CURSOR,                  
00109   DEF_CORNERNW_CURSOR,                  
00110   DEF_CORNERSE_CURSOR,                  
00111   DEF_CORNERSW_CURSOR,                  
00112   DEF_HELP_CURSOR,                      
00113   DEF_HAND_CURSOR,                      
00114   DEF_ROTATE_CURSOR,                    
00115   DEF_WAIT_CURSOR                       
00116   };
00117 
00118 
00119 
00121 struct FXAPI FXEvent {
00122   FXuint      type;           
00123   FXuint      time;           
00124   FXint       win_x;          
00125   FXint       win_y;          
00126   FXint       root_x;         
00127   FXint       root_y;         
00128   FXint       state;          
00129   FXint       code;           
00130   FXString    text;           
00131   FXint       last_x;         
00132   FXint       last_y;         
00133   FXint       click_x;        
00134   FXint       click_y;        
00135   FXint       rootclick_x;    
00136   FXint       rootclick_y;    
00137   FXuint      click_time;     
00138   FXuint      click_button;   
00139   FXint       click_count;    
00140   FXbool      moved;          
00141   FXRectangle rect;           
00142   FXbool      synthetic;      
00143   FXDragType  target;         
00144   };
00145 
00146 
00148 class FXAPI FXLockable {
00149 public:
00150   virtual ~FXLockable() { }
00151   virtual void lock() { }               
00152   virtual void unlock() { }             
00153   };
00154 
00155 
00157 class FXAPI FXEventLoop : public FXLockable, public FXObject {
00158   FXDECLARE(FXEventLoop)
00159 
00160 protected:
00161   friend class FXApp;
00162   friend class FXPopup;
00163   friend class FXWindow;
00164   friend class FXDockHandler;
00165   template<typename type> friend class FXEventLoop_Static;
00166 
00167   FXApp           *app;                 // Back link to application object
00168   FXHash           hash;                // Window handle hash table
00169   FXWindow        *activeWindow;        // Active toplevel window
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   FXTimer         *timers;              // List of timers, sorted by time
00183   FXChore         *chores;              // List of chores
00184   FXRepaint       *repaints;            // Unhandled repaint rectangles
00185   FXTimer         *timerrecs;           // List of recycled timer records
00186   FXChore         *chorerecs;           // List of recycled chore records
00187   FXRepaint       *repaintrecs;         // List of recycled repaint records
00188   FXInvocation    *invocation;          // Modal loop invocation
00189   FXSignal        *signals;             // Array of signal records
00190   FXint            nsignals;            // Number of signals
00191   FXEvent          event;               // Event
00192   FXInput         *inputs;              // Input file descriptors being watched
00193   FXint            ninputs;             // Number of inputs
00194   FXint            maxinput;            // Maximum input number
00195   FXAsyncMsg      *asyncmsgs;           // Asynchronously posted messages
00196   FXAsyncMsg      *asyncmsgsrecs;       // Recycled asynchronously posted messages
00197   bool            &initialized;         // FXApp has been initialized
00198   void           *&display;             // Display we're talking to
00199 
00200 
00201   // Platform dependent private stuff
00202 #ifndef WIN32
00203   void           *&xim;                 // Input method
00204   void            *r_fds;               // Set of file descriptors for read
00205   void            *w_fds;               // Set of file descriptors for write
00206   void            *e_fds;               // Set of file descriptors for exceptions
00207   int              latch[2];            // Used to latch event loop
00208 
00209 #else
00210   void           **handles;             // Waitable object handles
00211   void            *lastmovehwnd;
00212   long            lastmovelParam;
00213   void            *oldhwnd;
00214   void            *latch;               // Used to latch event loop
00215   FXuint          repostimer;           // Used to ensure timers & chores work
00216   FXuint          msgloopcount;         // How many times the message loop has run modally
00217   FXuint          tickmsgloopcount;     // Msg loop count at last tick
00218 
00219 #endif
00220 
00221   // Internal helper functions
00222   FXEventLoop(const FXEventLoop&);
00223   FXEventLoop &operator=(const FXEventLoop&);
00224   void setup();
00225   static void signalhandler(int sig);
00226   static void immediatesignalhandler(int sig);
00227   void leaveWindow(FXWindow *window,FXWindow *ancestor);
00228   void enterWindow(FXWindow *window,FXWindow *ancestor);
00229   void selectionSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00230   void selectionGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00231   void selectionGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00232   void clipboardSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00233   void clipboardGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00234   void clipboardGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00235   void dragdropSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00236   void dragdropGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00237   void dragdropGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00238 #ifndef WIN32
00239   void addRepaint(FXID win,FXint x,FXint y,FXint w,FXint h,FXbool synth=0);
00240   void removeRepaints(FXID win,FXint x,FXint y,FXint w,FXint h);
00241   void scrollRepaints(FXID win,FXint dx,FXint dy);
00242 #else
00243   static long CALLBACK wndproc(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam);
00244 protected:
00245   virtual long dispatchEvent(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam);
00246 #endif
00247 private:
00248   FXbool doIdleProcessing();
00249   void doTimers();
00250   void doAsyncMsgs();
00251 
00252 protected:
00253 
00255   FXEventLoop(FXApp* app=NULL);
00256 
00258   virtual bool getNextEvent(FXRawEvent& ev,bool blocking=true);
00259 
00261   virtual bool dispatchEvent(FXRawEvent& ev);
00262 
00264   virtual void latchLoop();
00265 
00267   virtual void resetLoopLatch();
00268 
00270   virtual bool getNextEventI(FXRawEvent& ev,bool blocking);
00271 
00273   virtual bool peekEventI();
00274 
00276   virtual void* makeStaticPtr(void* val);
00277 
00279   virtual void deleteStaticPtr(void* ref);
00280 
00282   virtual void* getStaticPtr(const void* ref) const;
00283 
00285   virtual void setStaticPtr(void* ref,void* val);
00286 
00287 public:
00288   enum {
00289     ID_ASYNCRECALC=1,
00290     ID_LAST
00291     };
00292 public:
00294   FXApp* getApp() const { return app; }
00295 
00297   FXRootWindow* getRootWindow() const { return root; }
00298 
00300   void setRootWindow(FXRootWindow* rt);
00301 
00303   FXWindow *getFocusWindow() const;
00304 
00306   FXWindow *getCursorWindow() const { return cursorWindow; }
00307 
00309   FXWindow *getActiveWindow() const { return activeWindow; }
00310 
00312   FXPopup* getPopupWindow() const { return popupWindow; }
00313 
00315   FXWindow* findWindowWithId(FXID xid) const;
00316 
00318   FXWindow* findWindowAt(FXint rx,FXint ry,FXID window=0) const;
00319 
00327   void addTimeout(FXObject* tgt,FXSelector sel,FXuint ms=1000,void* ptr=NULL);
00328 
00332   void removeTimeout(FXObject* tgt,FXSelector sel);
00333 
00337   bool hasTimeout(FXObject *tgt,FXSelector sel) const;
00338 
00344   FXuint remainingTimeout(FXObject *tgt,FXSelector sel);
00345 
00349   void handleTimeouts();
00350 
00358   void addChore(FXObject* tgt,FXSelector sel,void *ptr=NULL);
00359 
00363   void removeChore(FXObject* tgt,FXSelector sel);
00364 
00368   bool hasChore(FXObject *tgt,FXSelector sel) const;
00369 
00377   void addSignal(FXint sig,FXObject* tgt,FXSelector sel,FXbool immediate=FALSE,FXuint flags=0);
00378 
00380   void removeSignal(FXint sig);
00381 
00388   bool addInput(FXInputHandle fd,FXuint mode,FXObject *tgt,FXSelector sel);
00389 
00394   bool removeInput(FXInputHandle fd,FXuint mode);
00395 
00397   bool getKeyState(FXuint keysym) const;
00398 
00400   bool peekEvent();
00401 
00403   bool runOneEvent(bool blocking=true);
00404 
00409   FXint run();
00410 
00415   FXint runUntil(FXuint& condition);
00416 
00421   FXint runWhileEvents();
00422 
00430   FXint runModalWhileEvents(FXWindow* window=NULL);
00431 
00436   FXint runModal();
00437 
00443   FXint runModalFor(FXWindow* window);
00444 
00450   FXint runModalWhileShown(FXWindow* window);
00451 
00456   FXint runPopup(FXWindow* window);
00457 
00459   bool isModal(FXWindow* window) const;
00460 
00462   FXWindow* getModalWindow() const;
00463 
00465   FXModality getModality() const;
00466 
00472   void stop(FXint value=0);
00473 
00478   void stopModal(FXWindow* window,FXint value=0);
00479 
00483   void stopModal(FXint value=0);
00484 
00486   void forceRefresh();
00487 
00489   void refresh();
00490 
00492   void flush(bool sync=false);
00493 
00498   void repaint();
00499 
00501   FXWindow* getDragWindow() const { return dragWindow; }
00502 
00503   virtual ~FXEventLoop();
00504 
00505 public:
00506   long onCmdAsyncRecalc(FXObject*,FXSelector,void*);
00507 
00509   void postAsyncMessage(FXObject* tgt,FXuint message,void *ptr=NULL,FXObject* src=NULL);
00510 
00512   static void postAsyncMessage(FXId* tgt,FXuint message,void *ptr=NULL,FXObject* src=NULL);
00513 
00515   virtual FXulong getThreadId() const { return 0; }
00516 
00519   static void requestAsyncRecalc(FXWindow *what);
00520 
00521 };
00522 
00523 #ifdef _MSC_VER
00524 #pragma warning(push)
00525 #pragma warning(disable: 4251)
00526 #endif
00527 
00529 class FXAPI FXApp : public FXLockable, public FXObject {
00530   FXDECLARE(FXApp)
00531 
00532   // We've got many friends
00533   friend class FXEventLoop;
00534   friend class FXId;
00535   friend class FXBitmap;
00536   friend class FXImage;
00537   friend class FXIcon;
00538   friend class FXCursor;
00539   friend class FXDrawable;
00540   friend class FXWindow;
00541   friend class FXShell;
00542   friend class FXRootWindow;
00543   friend class FXTopWindow;
00544   friend class FXMainWindow;
00545   friend class FXPopup;
00546   friend class FXFont;
00547   friend class FXVisual;
00548   friend class FXGLVisual;
00549   friend class FXGLContext;
00550   friend class FXDC;
00551   friend class FXDCWindow;
00552   friend class FXEmbedderWindow;
00553   friend class FXDragCorner;
00554   friend class FXComposeContext;
00555 protected:
00556   mutable FXEventLoop *eventLoop;       // Event loop
00557 
00558 private:
00559 
00560   // Platform independent private data
00561   void            *display;             // Display we're talking to
00562   const FXchar    *dpy;                 // Initial display guess
00563   FXRegistry       registry;            // Application setting registry
00564   FXVisual        *monoVisual;          // Monochrome visual
00565   FXVisual        *defaultVisual;       // Default [color] visual
00566   FXFont          *normalFont;          // Normal font
00567   FXFont          *stockFont;           // Stock font
00568   FXuint           stickyMods;          // Sticky modifier state
00569   FXuchar         *ddeData;             // DDE array
00570   FXuint           ddeSize;             // DDE array size
00571   FXuint           maxcolors;           // Maximum number of colors to allocate
00572   FXuint           typingSpeed;         // Typing speed
00573   FXuint           clickSpeed;          // Double click speed
00574   FXuint           scrollSpeed;         // Scroll speed
00575   FXuint           scrollDelay;         // Scroll delay
00576   FXuint           blinkSpeed;          // Cursor blink speed
00577   FXuint           animSpeed;           // Animation speed
00578   FXuint           menuPause;           // Menu popup delay
00579   FXuint           tooltipPause;        // Tooltip popup delay
00580   FXuint           tooltipTime;         // Tooltip display time
00581   FXint            dragDelta;           // Minimum distance considered a move
00582   FXint            wheelLines;          // Scroll by this many lines
00583   FXint            scrollBarSize;       // Scrollbar size
00584   FXColor          borderColor;         // Border color
00585   FXColor          baseColor;           // Background color of GUI controls
00586   FXColor          hiliteColor;         // Highlight color of GUI controls
00587   FXColor          shadowColor;         // Shadow color of GUI controls
00588   FXColor          backColor;           // Background color
00589   FXColor          foreColor;           // Foreground color
00590   FXColor          selforeColor;        // Select foreground color
00591   FXColor          selbackColor;        // Select background color
00592   FXColor          tipforeColor;        // Tooltip foreground color
00593   FXColor          tipbackColor;        // Tooltip background color
00594   FXColor          selMenuTextColor;    // Select foreground color in menus
00595   FXColor          selMenuBackColor;    // Select background color in menus
00596   FXCursor        *waitCursor;          // Current wait cursor
00597   FXuint           waitCount;           // Number of times wait cursor was called
00598   FXuint           windowCount;         // Number of windows
00599   FXCursor        *cursor[DEF_WAIT_CURSOR+1];
00600   //FXTranslator    *translator;          // Message translator
00601   FXint            appArgc;             // Argument count
00602   const FXchar *const *appArgv;         // Argument vector
00603   const FXchar    *inputmethod;         // Input method name
00604   const FXchar    *inputstyle;          // Input method style
00605   bool             initialized;         // Has been initialized
00606   FXAppDestructUpcall *destructUpcalls; // Destruction upcalls
00607 
00608 private:
00609   static FXApp    *app;                 // Application pointer
00610 
00611   // Platform dependent private stuff
00612 #ifndef WIN32
00613 private:
00614   FXID             wmDeleteWindow;      // Catch delete window
00615   FXID             wmQuitApp;           // Catch quit application
00616   FXID             wmProtocols;         // Window manager protocols
00617   FXID             wmMotifHints;        // Motif hints
00618   FXID             wmTakeFocus;         // Focus explicitly set by app
00619   FXID             wmState;             // Window state
00620   FXID             wmNetState;          // Extended Window Manager window state
00621   FXID             wmNetIconName;       // Extended Window Manager icon name
00622   FXID             wmNetWindowName;     // Extended Window Manager window name
00623   FXID             wmNetSupported;      // Extended Window Manager states list
00624   FXID             wmNetWindowType;     // Extended Window Manager types
00625   FXID             wmNetHMaximized;     // Extended Window Manager horizontally maximized
00626   FXID             wmNetVMaximized;     // Extended Window Manager vertically maximized
00627   FXID             wmNetMoveResize;     // Extended Window Manager drag corner
00628   FXID             wmNetPing;           // Extended Window Manager ping
00629   FXID             wmNetTypes[8];       // Extended Window Manager window types
00630   FXID             wmNetStates[12];     // Extended Window Manager state
00631   FXID             wmWindowRole;        // Window Role
00632   FXID             wmClientLeader;      // Client leader
00633   FXID             wmClientId;          // Client id
00634   FXID             embedAtom;           // XEMBED support
00635   FXID             embedInfoAtom;       // XEMBED info support
00636   FXID             timestampAtom;       // Server time
00637   FXID             ddeTargets;          // DDE targets atom
00638   FXID             ddeAtom;             // DDE exchange atom
00639   FXID             ddeDelete;           // DDE delete target atom
00640   FXID             ddeIncr;             // DDE incremental data exchange atom
00641   FXDragType      *ddeTypeList;         // DDE drop type list
00642   FXuint           ddeNumTypes;         // DDE number of drop types
00643   FXDragAction     ddeAction;           // DDE action
00644   FXDragAction     ansAction;           // Reply action
00645   FXID             xcbSelection;        // Clipboard selection
00646   FXDragType      *xcbTypeList;         // Clipboard type list
00647   FXuint           xcbNumTypes;         // Clipboard number of types on list
00648   FXDragType      *xselTypeList;        // Selection type list
00649   FXuint           xselNumTypes;        // Selection number of types on list
00650   FXDragType      *xdndTypeList;        // XDND type list
00651   FXuint           xdndNumTypes;        // XDND number of types
00652   FXID             xdndProxy;           // XDND proxy atom
00653   FXID             xdndAware;           // XDND awareness atom
00654   FXID             xdndEnter;           // XDND enter window message
00655   FXID             xdndLeave;           // XDND leave window message
00656   FXID             xdndPosition;        // XDND position update message
00657   FXID             xdndStatus;          // XDND status feedback message
00658   FXID             xdndDrop;            // XDND drop message
00659   FXID             xdndFinished;        // XDND finished message
00660   FXID             xdndSelection;       // XDND selection atom
00661   FXID             xdndActionMove;      // XDND Move action
00662   FXID             xdndActionCopy;      // XDND Copy action
00663   FXID             xdndActionLink;      // XDND Link action
00664   FXID             xdndActionPrivate;   // XDND Private action
00665   FXID             xdndTypes;           // XDND types list atom
00666   FXID             xdndSource;          // XDND drag source window
00667   FXID             xdndTarget;          // XDND drop target window
00668   FXID             xdndProxyTarget;     // XDND window to set messages to
00669   FXbool           xdndStatusPending;   // XDND waiting for status feedback
00670   FXbool           xdndStatusReceived;  // XDND received at least one status
00671   FXbool           xdndWantUpdates;     // XDND target wants new positions while in rect
00672   FXbool           xdndFinishSent;      // XDND finish sent
00673   FXRectangle      xdndRect;            // XDND rectangle bounding target
00674   FXint            xrreventbase;        // XRR event base
00675   FXID             stipples[23];        // Standard stipple patterns
00676   void            *xim;                 // Input method
00677   FXbool           shmi;                // Use XSHM Image possible
00678   FXbool           shmp;                // Use XSHM Pixmap possible
00679   FXbool           synchronize;         // Synchronized
00680 
00681 #else
00682 
00683   FXushort         ddeTargets;          // DDE targets atom
00684   FXushort         ddeAtom;             // DDE Exchange Atom
00685   FXDragType       ddeDelete;           // DDE Delete Target Atom
00686   FXDragType      *ddeTypeList;         // DDE drop type list
00687   FXuint           ddeNumTypes;         // DDE number of drop types
00688   FXDragAction     ddeAction;           // DDE action
00689   FXDragAction     ansAction;           // Reply action
00690   FXDragType      *xselTypeList;        // Selection type list
00691   FXuint           xselNumTypes;        // Selection number of types on list
00692   void*            xdndTypes;           // Handle to file mapping object for types list
00693   FXushort         xdndAware;           // XDND awareness atom
00694   FXID             xdndSource;          // XDND drag source window
00695   FXID             xdndTarget;          // XDND drop target window
00696   FXbool           xdndStatusPending;   // XDND waiting for status feedback
00697   FXbool           xdndFinishPending;   // XDND waiting for drop-confirmation
00698   FXbool           xdndStatusReceived;  // XDND received at least one status
00699   FXbool           xdndFinishSent;      // XDND finish sent
00700   FXRectangle      xdndRect;            // XDND rectangle bounding target
00701   FXID             stipples[17];        // Standard stipple bitmaps
00702 
00703 #endif
00704 
00705 private:
00706 
00707   // Internal helper functions
00708   FXApp(const FXApp&);
00709   FXApp &operator=(const FXApp&);
00710 #ifndef WIN32
00711   static void imcreatecallback(void*,FXApp*,void*);
00712   static void imdestroycallback(void*,FXApp*,void*);
00713 #else
00714 protected:
00715   virtual long dispatchEvent(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam);
00716 #endif
00717 
00718 protected:
00719 
00721   virtual bool getNextEvent(FXRawEvent& ev,bool blocking=true);
00722 
00724   virtual bool dispatchEvent(FXRawEvent& ev);
00725 
00726 public:
00727   long onCmdQuit(FXObject*,FXSelector,void*);
00728   long onCmdDump(FXObject*,FXSelector,void*);
00729   long onCmdHover(FXObject*,FXSelector,void*);
00730 
00731 public:
00732 
00734   enum {
00735     ID_QUIT=1,    
00736     ID_DUMP,      
00737     ID_HOVER,
00738     ID_LAST
00739     };
00740 
00741 public:
00742 
00744   static const FXuchar *copyright;     
00745 
00746 public:
00747 
00753   FXApp(const FXString& name="Application",const FXString& vendor="FoxDefault");
00754 
00756   const FXString& getAppName() const { return registry.getAppKey(); }
00757 
00759   const FXString& getVendorName() const { return registry.getVendorKey(); }
00760 
00762   bool openDisplay(const FXchar* dpyname=NULL);
00763 
00765   bool closeDisplay();
00766 
00768   void* getDisplay() const { return display; }
00769 
00771   bool isInitialized() const { return initialized; }
00772 
00774   FXint getArgc() const { return appArgc; }
00775 
00777   const FXchar *const *getArgv() const { return appArgv; }
00778 
00780   virtual FXEventLoop* getEventLoop() const;
00781 
00783   static FXEventLoop* getPrimaryEventLoop();
00784 
00786   bool hasInputMethod() const;
00787 
00789   FXVisual* getDefaultVisual() const { return defaultVisual; }
00790 
00792   void setDefaultVisual(FXVisual* vis);
00793 
00795   FXVisual* getMonoVisual() const { return monoVisual; }
00796 
00798   FXRootWindow* getRootWindow() const { return getEventLoop()->getRootWindow(); }
00799 
00801   void setRootWindow(FXRootWindow* rt) { return getEventLoop()->setRootWindow(rt); }
00802 
00804   FXWindow *getFocusWindow() const { return getEventLoop()->getFocusWindow(); }
00805 
00807   FXWindow *getCursorWindow() const { return getEventLoop()->getCursorWindow(); }
00808 
00810   FXWindow *getActiveWindow() const { return getEventLoop()->getActiveWindow(); }
00811 
00813   FXPopup* getPopupWindow() const { return getEventLoop()->getPopupWindow(); }
00814 
00816   FXWindow* findWindowWithId(FXID xid) const { return getEventLoop()->findWindowWithId(xid); }
00817 
00819   FXWindow* findWindowAt(FXint rx,FXint ry,FXID window=0) const { return getEventLoop()->findWindowAt(rx,ry,window); }
00820 
00822   virtual void create();
00823 
00825   virtual void destroy();
00826 
00828   virtual void detach();
00829 
00837   void addTimeout(FXObject* tgt,FXSelector sel,FXuint ms=1000,void* ptr=NULL) { return getEventLoop()->addTimeout(tgt,sel,ms,ptr); }
00838 
00842   void removeTimeout(FXObject* tgt,FXSelector sel) { return getEventLoop()->removeTimeout(tgt,sel); }
00843 
00847   bool hasTimeout(FXObject *tgt,FXSelector sel) const { return getEventLoop()->hasTimeout(tgt,sel); }
00848 
00854   FXuint remainingTimeout(FXObject *tgt,FXSelector sel) const { return getEventLoop()->remainingTimeout(tgt,sel); }
00855 
00859   void handleTimeouts() { return getEventLoop()->handleTimeouts(); }
00860 
00868   void addChore(FXObject* tgt,FXSelector sel,void *ptr=NULL) { return getEventLoop()->addChore(tgt,sel,ptr); }
00869 
00873   void removeChore(FXObject* tgt,FXSelector sel) { return getEventLoop()->removeChore(tgt,sel); }
00874 
00878   FXbool hasChore(FXObject *tgt,FXSelector sel) const { return getEventLoop()->hasChore(tgt,sel); }
00879 
00887   void addSignal(FXint sig,FXObject* tgt,FXSelector sel,FXbool immediate=FALSE,FXuint flags=0) { getEventLoop()->addSignal(sig,tgt,sel,immediate,flags); }
00888 
00890   void removeSignal(FXint sig) { getEventLoop()->removeSignal(sig); }
00891 
00898   bool addInput(FXInputHandle fd,FXuint mode,FXObject *tgt,FXSelector sel) { return getEventLoop()->addInput(fd,mode,tgt,sel); }
00899 
00904   bool removeInput(FXInputHandle fd,FXuint mode) { return getEventLoop()->removeInput(fd,mode); }
00905 
00907   bool getKeyState(FXuint keysym) const;
00908 
00910   bool peekEvent() { return getEventLoop()->peekEvent(); }
00911 
00913   bool runOneEvent(bool blocking=true) { return getEventLoop()->runOneEvent(blocking); }
00914 
00919   FXint run() { return getEventLoop()->run(); }
00920 
00925   FXint runUntil(FXuint& condition) { return getEventLoop()->runUntil(condition); }
00926 
00931   FXint runWhileEvents() { return getEventLoop()->runWhileEvents(); }
00932 
00940   FXint runModalWhileEvents(FXWindow* window=NULL) { return getEventLoop()->runModalWhileEvents(window); }
00941 
00946   FXint runModal() { return getEventLoop()->runModal(); }
00947 
00953   FXint runModalFor(FXWindow* window) { return getEventLoop()->runModalFor(window); }
00954 
00960   FXint runModalWhileShown(FXWindow* window) { return getEventLoop()->runModalWhileShown(window); }
00961 
00966   FXint runPopup(FXWindow* window) { return getEventLoop()->runPopup(window); }
00967 
00969   FXbool isModal(FXWindow* window) const { return getEventLoop()->isModal(window); }
00970 
00972   FXWindow* getModalWindow() const { return getEventLoop()->getModalWindow(); }
00973 
00975   FXModality getModality() const { return getEventLoop()->getModality(); }
00976 
00982   void stop(FXint value=0) { getEventLoop()->stop(value); }
00983 
00988   void stopModal(FXWindow* window,FXint value=0) { getEventLoop()->stopModal(window, value); }
00989 
00993   void stopModal(FXint value=0) { getEventLoop()->stopModal(value); }
00994 
00996   void forceRefresh() { getEventLoop()->forceRefresh(); }
00997 
00999   void refresh() { getEventLoop()->refresh(); }
01000 
01002   void flush(bool sync=false) { getEventLoop()->flush(sync); }
01003 
01008   void repaint() { getEventLoop()->repaint(); }
01009 
01015   virtual void init(int& argc,char** argv,bool connect=true);
01016 
01021   virtual void exit(FXint code=0);
01022 
01029   FXRegistry& reg(){ return registry; }
01030 
01032   FXDragType registerDragType(const FXString& name) const;
01033 
01035   FXString getDragTypeName(FXDragType type) const;
01036 
01038   FXWindow* getDragWindow() const { return getEventLoop()->getDragWindow(); }
01039 
01041   void beep();
01042 
01044   void errorBeep();
01045 
01049   static FXlong time();
01050 
01052   static inline FXApp* instance(){ return app; }
01053 
01055   void setNormalFont(FXFont* font);
01056 
01058   FXFont* getNormalFont() const { return normalFont; }
01059 
01061   void beginWaitCursor();
01062 
01064   void endWaitCursor();
01065 
01067   void setWaitCursor(FXCursor *cur);
01068 
01070   FXCursor* getWaitCursor() const { return waitCursor; }
01071 
01073   FXCursor* getDefaultCursor(FXDefaultCursor which) const { return cursor[which]; }
01074 
01076   void setDefaultCursor(FXDefaultCursor which,FXCursor* cur);
01077 
01082   FXbool writeWindow(FXStream& store,FXWindow *window);
01083 
01088   FXbool readWindow(FXStream& store,FXWindow*& window,FXWindow* father,FXWindow* owner);
01089 
01090 
01095   //void setTranslator(FXTranslator* trans);
01096 
01098   //FXTranslator* getTranslator() const { return translator; }
01099 
01101   FXuint getTypingSpeed() const { return typingSpeed; }
01102   FXuint getClickSpeed() const { return clickSpeed; }
01103   FXuint getScrollSpeed() const { return scrollSpeed; }
01104   FXuint getScrollDelay() const { return scrollDelay; }
01105   FXuint getBlinkSpeed() const { return blinkSpeed; }
01106   FXuint getAnimSpeed() const { return animSpeed; }
01107   FXuint getMenuPause() const { return menuPause; }
01108   FXuint getTooltipPause() const { return tooltipPause; }
01109   FXuint getTooltipTime() const { return tooltipTime; }
01110   FXint getDragDelta() const { return dragDelta; }
01111   FXint getWheelLines() const { return wheelLines; }
01112   FXint getScrollBarSize() const { return scrollBarSize; }
01113 
01115   void setTypingSpeed(FXuint speed);
01116   void setClickSpeed(FXuint speed);
01117   void setScrollSpeed(FXuint speed);
01118   void setScrollDelay(FXuint delay);
01119   void setBlinkSpeed(FXuint speed);
01120   void setAnimSpeed(FXuint speed);
01121   void setMenuPause(FXuint pause);
01122   void setTooltipPause(FXuint pause);
01123   void setTooltipTime(FXuint time);
01124   void setDragDelta(FXint delta);
01125   void setWheelLines(FXint lines);
01126   void setScrollBarSize(FXint size);
01127 
01129   FXColor getBorderColor() const { return borderColor; }
01130   FXColor getBaseColor() const { return baseColor; }
01131   FXColor getHiliteColor() const { return hiliteColor; }
01132   FXColor getShadowColor() const { return shadowColor; }
01133   FXColor getBackColor() const { return backColor; }
01134   FXColor getForeColor() const { return foreColor; }
01135   FXColor getSelforeColor() const { return selforeColor; }
01136   FXColor getSelbackColor() const { return selbackColor; }
01137   FXColor getTipforeColor() const { return tipforeColor; }
01138   FXColor getTipbackColor() const { return tipbackColor; }
01139   FXColor getSelMenuTextColor() const { return selMenuTextColor; }
01140   FXColor getSelMenuBackColor() const { return selMenuBackColor; }
01141 
01143   void setBorderColor(FXColor color);
01144   void setBaseColor(FXColor color);
01145   void setHiliteColor(FXColor color);
01146   void setShadowColor(FXColor color);
01147   void setBackColor(FXColor color);
01148   void setForeColor(FXColor color);
01149   void setSelforeColor(FXColor color);
01150   void setSelbackColor(FXColor color);
01151   void setTipforeColor(FXColor color);
01152   void setTipbackColor(FXColor color);
01153   void setSelMenuTextColor(FXColor color);
01154   void setSelMenuBackColor(FXColor color);
01155 
01157   FXuint getWindowCount() const { return windowCount; }
01158 
01160   virtual void save(FXStream& store) const;
01161 
01163   virtual void load(FXStream& store);
01164 
01166   void dumpWidgets() const;
01167 
01169   void addDestructionUpcall(void (*func)(void *), void *data);
01170 
01172   void removeDestructionUpcall(void (*func)(void *), void *data);
01173 
01175   virtual ~FXApp();
01176   };
01177 
01178 #ifdef _MSC_VER
01179 #pragma warning(pop)
01180 #endif
01181 
01183 class FXAPI FXLockHold
01184 {
01185   FXbool locked;
01186   FXLockable *item;
01187 public:
01189   FXLockHold(FXLockable *obj) : locked(FALSE), item(obj) { relock(); }
01190 
01192   FXLockHold(FXLockable &obj) : locked(FALSE), item(&obj) { relock(); }
01193 
01195   ~FXLockHold() { unlock(); }
01196 
01198   void relock(){
01199     if(!locked && item){
01200         item->lock();
01201         locked=TRUE;
01202       }
01203     }
01204 
01205   // Unlocks the item if locked
01206   void unlock(){
01207     if(locked && item){
01208       item->unlock();
01209       locked=FALSE;
01210       }
01211     }
01212 
01213   };
01214 
01216 template<typename type> class FXEventLoop_Static
01217 {
01218   void *ref;
01219 public:
01220   FXEventLoop_Static(type *v=NULL) : ref(FXApp::instance()->getEventLoop()->makeStaticPtr(static_cast<void *>(v))) { }
01221   ~FXEventLoop_Static() { FXApp::instance()->getEventLoop()->deleteStaticPtr(ref); }
01223   type *operator=(type *v){
01224     FXApp::instance()->getEventLoop()->setStaticPtr(ref, static_cast<void *>(v));
01225     return v;
01226     }
01228   operator type *() const {
01229     return static_cast<type *>(FXApp::instance()->getEventLoop()->getStaticPtr(ref));
01230     }
01232   type *operator->() const {
01233     return static_cast<type *>(FXApp::instance()->getEventLoop()->getStaticPtr(ref));
01234     }
01235 };
01236 
01237 }
01238 
01239 #endif
01240 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:19 2009 for TnFOX by doxygen v1.4.7