00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXAPP_H
00022 #define FXAPP_H
00023
00024 #ifndef FXOBJECT_H
00025 #include "FXObject.h"
00026 #endif
00027
00028 namespace FX {
00029
00030
00031
00032 class FXApp;
00033 class FXWindow;
00034 class FXIcon;
00035 class FXBitmap;
00036 class FXCursor;
00037 class FXRootWindow;
00038 class FXMainWindow;
00039 class FXPopup;
00040 class FXFont;
00041 class FXDC;
00042 class FXDCWindow;
00043 class FXVisual;
00044 class FXGLVisual;
00045 class FXGLContext;
00046 class FXTranslator;
00047 class FXComposeContext;
00048
00049
00050 struct FXTimer;
00051 struct FXChore;
00052 struct FXSignal;
00053 struct FXRepaint;
00054 struct FXInput;
00055 struct FXHandles;
00056 struct FXInvocation;
00057
00058
00059
00060
00061 enum FXInputMode {
00062 INPUT_NONE = 0,
00063 INPUT_READ = 1,
00064 INPUT_WRITE = 2,
00065 INPUT_EXCEPT = 4
00066 };
00067
00068
00069
00070 enum FXModality {
00071 MODAL_FOR_NONE,
00072 MODAL_FOR_WINDOW,
00073 MODAL_FOR_POPUP
00074 };
00075
00076
00077
00078 enum FXDefaultCursor {
00079 DEF_ARROW_CURSOR,
00080 DEF_RARROW_CURSOR,
00081 DEF_TEXT_CURSOR,
00082 DEF_HSPLIT_CURSOR,
00083 DEF_VSPLIT_CURSOR,
00084 DEF_XSPLIT_CURSOR,
00085 DEF_SWATCH_CURSOR,
00086 DEF_MOVE_CURSOR,
00087 DEF_DRAGH_CURSOR,
00088 DEF_DRAGV_CURSOR,
00089 DEF_DRAGTL_CURSOR,
00090 DEF_DRAGBR_CURSOR=DEF_DRAGTL_CURSOR,
00091 DEF_DRAGTR_CURSOR,
00092 DEF_DRAGBL_CURSOR=DEF_DRAGTR_CURSOR,
00093 DEF_DNDSTOP_CURSOR,
00094 DEF_DNDASK_CURSOR,
00095 DEF_DNDCOPY_CURSOR,
00096 DEF_DNDMOVE_CURSOR,
00097 DEF_DNDLINK_CURSOR,
00098 DEF_CROSSHAIR_CURSOR,
00099 DEF_CORNERNE_CURSOR,
00100 DEF_CORNERNW_CURSOR,
00101 DEF_CORNERSE_CURSOR,
00102 DEF_CORNERSW_CURSOR,
00103 DEF_HELP_CURSOR,
00104 DEF_HAND_CURSOR,
00105 DEF_ROTATE_CURSOR,
00106 DEF_BLANK_CURSOR,
00107 DEF_WAIT_CURSOR
00108 };
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 class FXAPI FXApp : public FXObject {
00135 FXDECLARE(FXApp)
00136
00137
00138 friend class FXId;
00139 friend class FXBitmap;
00140 friend class FXImage;
00141 friend class FXIcon;
00142 friend class FXCursor;
00143 friend class FXDrawable;
00144 friend class FXWindow;
00145 friend class FXShell;
00146 friend class FXRootWindow;
00147 friend class FXTopWindow;
00148 friend class FXMainWindow;
00149 friend class FXPopup;
00150 friend class FXFont;
00151 friend class FXVisual;
00152 friend class FXGLVisual;
00153 friend class FXGLContext;
00154 friend class FXDC;
00155 friend class FXDCWindow;
00156 friend class FXDragCorner;
00157 friend class FXDockHandler;
00158 friend class FXComposeContext;
00159
00160 private:
00161
00162
00163 void *display;
00164 const FXchar *dpy;
00165 FXHash hash;
00166 FXRegistry registry;
00167 FXWindow *activeWindow;
00168 FXWindow *cursorWindow;
00169 FXWindow *mouseGrabWindow;
00170 FXWindow *keyboardGrabWindow;
00171 FXWindow *keyWindow;
00172 FXWindow *selectionWindow;
00173 FXWindow *clipboardWindow;
00174 FXWindow *dropWindow;
00175 FXWindow *dragWindow;
00176 FXWindow *refresher;
00177 FXWindow *refresherstop;
00178 FXPopup *popupWindow;
00179 FXRootWindow *root;
00180 FXVisual *monoVisual;
00181 FXVisual *defaultVisual;
00182 FXTimer *timers;
00183 FXChore *chores;
00184 FXRepaint *repaints;
00185 FXTimer *timerrecs;
00186 FXChore *chorerecs;
00187 FXRepaint *repaintrecs;
00188 FXInvocation *invocation;
00189 FXSignal *signals;
00190 FXint signalreceived;
00191 FXFont *normalFont;
00192 FXFont *stockFont;
00193 FXMutex appMutex;
00194 FXEvent event;
00195 FXuint stickyMods;
00196 FXInput *inputs;
00197 FXint ninputs;
00198 FXHandles *handles;
00199 FXint maxhandle;
00200 FXuchar *ddeData;
00201 FXuint ddeSize;
00202 FXuint maxcolors;
00203 FXTime typingSpeed;
00204 FXTime clickSpeed;
00205 FXTime scrollSpeed;
00206 FXTime scrollDelay;
00207 FXTime blinkSpeed;
00208 FXTime animSpeed;
00209 FXTime menuPause;
00210 FXTime toolTipPause;
00211 FXTime toolTipTime;
00212 FXTime autoHideDelay;
00213 FXint dragDelta;
00214 FXint wheelLines;
00215 FXint scrollBarSize;
00216 FXColor borderColor;
00217 FXColor baseColor;
00218 FXColor hiliteColor;
00219 FXColor shadowColor;
00220 FXColor backColor;
00221 FXColor foreColor;
00222 FXColor selforeColor;
00223 FXColor selbackColor;
00224 FXColor tipforeColor;
00225 FXColor tipbackColor;
00226 FXColor selMenuTextColor;
00227 FXColor selMenuBackColor;
00228 FXCursor *waitCursor;
00229 FXuint waitCount;
00230 FXuint windowCount;
00231 FXCursor *cursor[DEF_WAIT_CURSOR+1];
00232 FXTranslator *translator;
00233 FXint appArgc;
00234 const FXchar *const *appArgv;
00235 const FXchar *inputmethod;
00236 const FXchar *inputstyle;
00237 FXbool initialized;
00238
00239 private:
00240 static FXApp *app;
00241
00242
00243 #ifdef WIN32
00244
00245 FXushort ddeTargets;
00246 FXushort ddeAtom;
00247 FXDragType ddeDelete;
00248 FXDragType *ddeTypeList;
00249 FXuint ddeNumTypes;
00250 FXDragAction ddeAction;
00251 FXDragAction ansAction;
00252 FXDragType *xselTypeList;
00253 FXuint xselNumTypes;
00254 void* xdndTypes;
00255 FXushort xdndAware;
00256 FXID xdndSource;
00257 FXID xdndTarget;
00258 FXbool xdndStatusPending;
00259 FXbool xdndFinishPending;
00260 FXbool xdndStatusReceived;
00261 FXbool xdndFinishSent;
00262 FXRectangle xdndRect;
00263 FXID stipples[17];
00264
00265 #else
00266
00267 private:
00268 FXID wmDeleteWindow;
00269 FXID wmQuitApp;
00270 FXID wmProtocols;
00271 FXID wmMotifHints;
00272 FXID wmTakeFocus;
00273 FXID wmState;
00274 FXID wmNetState;
00275 FXID wmNetIconName;
00276 FXID wmNetWindowName;
00277 FXID wmNetSupported;
00278 FXID wmNetHidden;
00279 FXID wmNetShaded;
00280 FXID wmNetHMaximized;
00281 FXID wmNetVMaximized;
00282 FXID wmNetFullScreen;
00283 FXID wmNetBelowOthers;
00284 FXID wmNetAboveOthers;
00285 FXID wmNetNeedAttention;
00286 FXID wmNetMoveResize;
00287 FXID wmNetRestack;
00288 FXID wmNetPing;
00289 FXID wmNetWindowType;
00290 FXID wmWindowTypes[14];
00291 FXID wmWindowRole;
00292 FXID wmClientLeader;
00293 FXID wmClientId;
00294 FXID embedAtom;
00295 FXID embedInfoAtom;
00296 FXID timestampAtom;
00297 FXID ddeTargets;
00298 FXID ddeAtom;
00299 FXID ddeDelete;
00300 FXID ddeIncr;
00301 FXDragType *ddeTypeList;
00302 FXuint ddeNumTypes;
00303 FXDragAction ddeAction;
00304 FXDragAction ansAction;
00305 FXID xcbSelection;
00306 FXDragType *xcbTypeList;
00307 FXuint xcbNumTypes;
00308 FXDragType *xselTypeList;
00309 FXuint xselNumTypes;
00310 FXDragType *xdndTypeList;
00311 FXuint xdndNumTypes;
00312 FXID xdndProxy;
00313 FXID xdndAware;
00314 FXID xdndEnter;
00315 FXID xdndLeave;
00316 FXID xdndPosition;
00317 FXID xdndStatus;
00318 FXID xdndDrop;
00319 FXID xdndFinished;
00320 FXID xdndSelection;
00321 FXID xdndTypes;
00322 FXID xdndActions;
00323 FXID xdndActionList[6];
00324 FXID xdndSource;
00325 FXID xdndTarget;
00326 FXID xdndProxyTarget;
00327 FXbool xdndStatusPending;
00328 FXbool xdndStatusReceived;
00329 FXbool xdndWantUpdates;
00330 FXbool xdndFinishSent;
00331 FXRectangle xdndRect;
00332 FXint xrrScreenChange;
00333 FXint xfxFixesSelection;
00334 FXint xsbBallMotion;
00335 FXint xsbButtonPress;
00336 FXint xsbButtonRelease;
00337 FXID stipples[23];
00338 void *xsbDevice;
00339 void *xim;
00340 FXbool shmi;
00341 FXbool shmp;
00342 FXbool xrender;
00343 FXbool synchronize;
00344
00345 #endif
00346
00347 private:
00348
00349
00350 FXApp(const FXApp&);
00351 FXApp &operator=(const FXApp&);
00352 static void signalhandler(int sig);
00353 static void immediatesignalhandler(int sig);
00354 void leaveWindow(FXWindow *window,FXWindow *ancestor);
00355 void enterWindow(FXWindow *window,FXWindow *ancestor);
00356 void selectionSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00357 void selectionGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00358 void selectionGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00359 void clipboardSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00360 void clipboardGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00361 void clipboardGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00362 void dragdropSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size);
00363 void dragdropGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size);
00364 void dragdropGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes);
00365 void openInputDevices();
00366 void closeInputDevices();
00367 #ifdef WIN32
00368 static long CALLBACK wndproc(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam);
00369 protected:
00370 virtual long dispatchEvent(FXID hwnd,unsigned int iMsg,unsigned int wParam,long lParam);
00371 #else
00372 void addRepaint(FXID win,FXint x,FXint y,FXint w,FXint h,FXbool synth=false);
00373 void removeRepaints(FXID win,FXint x,FXint y,FXint w,FXint h);
00374 void scrollRepaints(FXID win,FXint dx,FXint dy);
00375 static void imcreatecallback(void*,FXApp*,void*);
00376 static void imdestroycallback(void*,FXApp*,void*);
00377 #endif
00378
00379 protected:
00380
00381
00382 virtual FXbool getNextEvent(FXRawEvent& ev,FXTime blocking=forever);
00383
00384
00385 virtual FXbool dispatchEvent(FXRawEvent& ev);
00386
00387 public:
00388 long onCmdQuit(FXObject*,FXSelector,void*);
00389 long onCmdDump(FXObject*,FXSelector,void*);
00390 long onCmdHover(FXObject*,FXSelector,void*);
00391
00392 public:
00393
00394
00395 enum {
00396 ID_QUIT=1,
00397 ID_DUMP,
00398 ID_HOVER,
00399 ID_LAST
00400 };
00401
00402 public:
00403
00404
00405 static const FXuchar copyright[];
00406
00407 public:
00408
00409
00410
00411
00412
00413
00414 FXApp(const FXString& name="Application",const FXString& vendor="FoxDefault");
00415
00416
00417 const FXString& getAppName() const { return registry.getAppKey(); }
00418
00419
00420 const FXString& getVendorName() const { return registry.getVendorKey(); }
00421
00422
00423 FXbool openDisplay(const FXchar* dpyname=NULL);
00424
00425
00426 FXbool closeDisplay();
00427
00428
00429 void* getDisplay() const { return display; }
00430
00431
00432 FXbool isInitialized() const { return initialized; }
00433
00434
00435 FXint getArgc() const { return appArgc; }
00436
00437
00438 const FXchar *const *getArgv() const { return appArgv; }
00439
00440
00441 FXbool hasInputMethod() const;
00442
00443
00444 FXVisual* getDefaultVisual() const { return defaultVisual; }
00445
00446
00447 void setDefaultVisual(FXVisual* vis);
00448
00449
00450 FXVisual* getMonoVisual() const { return monoVisual; }
00451
00452
00453 FXRootWindow* getRootWindow() const { return root; }
00454
00455
00456 void setRootWindow(FXRootWindow* rt);
00457
00458
00459 FXWindow *getFocusWindow() const;
00460
00461
00462 FXWindow *getCursorWindow() const { return cursorWindow; }
00463
00464
00465 FXWindow *getActiveWindow() const { return activeWindow; }
00466
00467
00468 FXPopup* getPopupWindow() const { return popupWindow; }
00469
00470
00471 FXWindow* getSelectionWindow() const { return selectionWindow; }
00472
00473
00474 FXWindow* getClipboardWindow() const { return clipboardWindow; }
00475
00476
00477 FXWindow* getDragWindow() const { return dragWindow; }
00478
00479
00480 FXWindow* findWindowWithId(FXID xid) const;
00481
00482
00483 FXWindow* findWindowAt(FXint rx,FXint ry,FXID window=0) const;
00484
00485
00486 virtual void create();
00487
00488
00489 virtual void destroy();
00490
00491
00492 virtual void detach();
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504 void addTimeout(FXObject* tgt,FXSelector sel,FXTime ns=1000000000,void* ptr=NULL);
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514 void addDeadline(FXObject* tgt,FXSelector sel,FXTime due=forever,void* ptr=NULL);
00515
00516
00517
00518
00519
00520 void removeTimeout(FXObject* tgt,FXSelector sel=0);
00521
00522
00523
00524
00525
00526 FXbool hasTimeout(FXObject *tgt,FXSelector sel=0) const;
00527
00528
00529
00530
00531
00532
00533
00534
00535 FXTime remainingTimeout(FXObject *tgt,FXSelector sel=0);
00536
00537
00538
00539
00540
00541
00542
00543
00544 void addChore(FXObject* tgt,FXSelector sel,void *ptr=NULL);
00545
00546
00547
00548
00549
00550 void removeChore(FXObject* tgt,FXSelector sel=0);
00551
00552
00553
00554
00555
00556 FXbool hasChore(FXObject *tgt,FXSelector sel=0) const;
00557
00558
00559
00560
00561
00562
00563
00564
00565 void addSignal(FXint sig,FXObject* tgt,FXSelector sel,FXbool immediate=false,FXuint flags=0);
00566
00567
00568 void removeSignal(FXint sig);
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580 FXbool addInput(FXObject *tgt,FXSelector sel,FXInputHandle fd,FXuint mode=INPUT_READ,void* ptr=NULL);
00581
00582
00583
00584
00585
00586
00587
00588 FXbool removeInput(FXInputHandle fd,FXuint mode=INPUT_READ);
00589
00590
00591 FXbool getKeyState(FXuint keysym) const;
00592
00593
00594 FXbool peekEvent();
00595
00596
00597 FXbool runOneEvent(FXTime blocking=forever);
00598
00599
00600
00601
00602
00603 FXint run();
00604
00605
00606
00607
00608
00609 FXint runUntil(FXuint& condition);
00610
00611
00612
00613
00614
00615
00616 FXint runWhileEvents(FXTime blocking=0);
00617
00618
00619
00620
00621
00622
00623
00624
00625 FXint runModalWhileEvents(FXWindow* window=NULL,FXTime blocking=0);
00626
00627
00628
00629
00630
00631 FXint runModal();
00632
00633
00634
00635
00636
00637
00638 FXint runModalFor(FXWindow* window);
00639
00640
00641
00642
00643
00644
00645 FXint runModalWhileShown(FXWindow* window);
00646
00647
00648
00649
00650
00651 FXint runPopup(FXWindow* window);
00652
00653
00654 FXbool isModal(FXWindow* window) const;
00655
00656
00657 FXWindow* getModalWindow() const;
00658
00659
00660 FXModality getModality() const;
00661
00662
00663
00664
00665
00666
00667 void stop(FXint value=0);
00668
00669
00670
00671
00672
00673 void stopModal(FXWindow* window,FXint value=0);
00674
00675
00676
00677
00678 void stopModal(FXint value=0);
00679
00680
00681 void forceRefresh();
00682
00683
00684 void refresh();
00685
00686
00687 void flush(FXbool sync=false);
00688
00689
00690
00691
00692
00693 void repaint();
00694
00695
00696
00697
00698
00699
00700 virtual void init(int& argc,char** argv,FXbool connect=true);
00701
00702
00703
00704
00705
00706 virtual void exit(FXint code=0);
00707
00708
00709
00710
00711
00712
00713
00714 FXRegistry& reg(){ return registry; }
00715
00716
00717 FXDragType registerDragType(const FXString& name) const;
00718
00719
00720 FXString getDragTypeName(FXDragType type) const;
00721
00722
00723 void beep();
00724
00725
00726 static inline FXApp* instance(){ return app; }
00727
00728
00729 void setNormalFont(FXFont* font);
00730
00731
00732 FXFont* getNormalFont() const { return normalFont; }
00733
00734
00735 void beginWaitCursor();
00736
00737
00738 void endWaitCursor();
00739
00740
00741 void setWaitCursor(FXCursor *cur);
00742
00743
00744 FXCursor* getWaitCursor() const { return waitCursor; }
00745
00746
00747 FXCursor* getDefaultCursor(FXDefaultCursor which) const { return cursor[which]; }
00748
00749
00750 void setDefaultCursor(FXDefaultCursor which,FXCursor* cur);
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764 FXMutex& mutex(){ return appMutex; }
00765
00766
00767
00768
00769
00770 void setTranslator(FXTranslator* trans);
00771
00772
00773 FXTranslator* getTranslator() const { return translator; }
00774
00775
00776 FXTime getTypingSpeed() const { return typingSpeed; }
00777 FXTime getClickSpeed() const { return clickSpeed; }
00778 FXTime getScrollSpeed() const { return scrollSpeed; }
00779 FXTime getScrollDelay() const { return scrollDelay; }
00780 FXTime getBlinkSpeed() const { return blinkSpeed; }
00781 FXTime getAnimSpeed() const { return animSpeed; }
00782 FXTime getMenuPause() const { return menuPause; }
00783 FXTime getToolTipPause() const { return toolTipPause; }
00784 FXTime getToolTipTime() const { return toolTipTime; }
00785 FXTime getAutoHideDelay() const { return autoHideDelay; }
00786
00787
00788 void setTypingSpeed(FXTime speed);
00789 void setClickSpeed(FXTime speed);
00790 void setScrollSpeed(FXTime speed);
00791 void setScrollDelay(FXTime delay);
00792 void setBlinkSpeed(FXTime speed);
00793 void setAnimSpeed(FXTime speed);
00794 void setMenuPause(FXTime pause);
00795 void setToolTipPause(FXTime pause);
00796 void setToolTipTime(FXTime time);
00797 void setAutoHideDelay(FXTime time);
00798
00799
00800 void setDragDelta(FXint delta);
00801 FXint getDragDelta() const { return dragDelta; }
00802
00803
00804 void setWheelLines(FXint lines);
00805 FXint getWheelLines() const { return wheelLines; }
00806
00807
00808 void setScrollBarSize(FXint size);
00809 FXint getScrollBarSize() const { return scrollBarSize; }
00810
00811
00812 FXColor getBorderColor() const { return borderColor; }
00813 FXColor getBaseColor() const { return baseColor; }
00814 FXColor getHiliteColor() const { return hiliteColor; }
00815 FXColor getShadowColor() const { return shadowColor; }
00816 FXColor getBackColor() const { return backColor; }
00817 FXColor getForeColor() const { return foreColor; }
00818 FXColor getSelforeColor() const { return selforeColor; }
00819 FXColor getSelbackColor() const { return selbackColor; }
00820 FXColor getTipforeColor() const { return tipforeColor; }
00821 FXColor getTipbackColor() const { return tipbackColor; }
00822 FXColor getSelMenuTextColor() const { return selMenuTextColor; }
00823 FXColor getSelMenuBackColor() const { return selMenuBackColor; }
00824
00825
00826 void setBorderColor(FXColor color);
00827 void setBaseColor(FXColor color);
00828 void setHiliteColor(FXColor color);
00829 void setShadowColor(FXColor color);
00830 void setBackColor(FXColor color);
00831 void setForeColor(FXColor color);
00832 void setSelforeColor(FXColor color);
00833 void setSelbackColor(FXColor color);
00834 void setTipforeColor(FXColor color);
00835 void setTipbackColor(FXColor color);
00836 void setSelMenuTextColor(FXColor color);
00837 void setSelMenuBackColor(FXColor color);
00838
00839
00840 FXuint getWindowCount() const { return windowCount; }
00841
00842
00843 virtual void save(FXStream& store) const;
00844
00845
00846 virtual void load(FXStream& store);
00847
00848
00849 void dumpWidgets() const;
00850
00851
00852 virtual ~FXApp();
00853 };
00854
00855 }
00856
00857 #endif