00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXWINDOW_H
00022 #define FXWINDOW_H
00023
00024 #ifndef FXDRAWABLE_H
00025 #include "FXDrawable.h"
00026 #endif
00027
00028
00029 namespace FX {
00030
00031
00032
00033 class FXIcon;
00034 class FXBitmap;
00035 class FXCursor;
00036 class FXRegion;
00037 class FXDCWindow;
00038 class FXComposite;
00039 class FXAccelTable;
00040 class FXComposeContext;
00041
00042
00043
00044 enum {
00045 LAYOUT_NORMAL = 0,
00046 LAYOUT_SIDE_TOP = 0,
00047 LAYOUT_SIDE_BOTTOM = 0x00000001,
00048 LAYOUT_SIDE_LEFT = 0x00000002,
00049 LAYOUT_SIDE_RIGHT = LAYOUT_SIDE_LEFT|LAYOUT_SIDE_BOTTOM,
00050 LAYOUT_FILL_COLUMN = 0x00000001,
00051 LAYOUT_FILL_ROW = 0x00000002,
00052 LAYOUT_LEFT = 0,
00053 LAYOUT_RIGHT = 0x00000004,
00054 LAYOUT_CENTER_X = 0x00000008,
00055 LAYOUT_FIX_X = LAYOUT_RIGHT|LAYOUT_CENTER_X,
00056 LAYOUT_TOP = 0,
00057 LAYOUT_BOTTOM = 0x00000010,
00058 LAYOUT_CENTER_Y = 0x00000020,
00059 LAYOUT_FIX_Y = LAYOUT_BOTTOM|LAYOUT_CENTER_Y,
00060 LAYOUT_DOCK_SAME = 0,
00061 LAYOUT_DOCK_NEXT = 0x00000040,
00062 LAYOUT_RESERVED_1 = 0x00000080,
00063 LAYOUT_FIX_WIDTH = 0x00000100,
00064 LAYOUT_FIX_HEIGHT = 0x00000200,
00065 LAYOUT_MIN_WIDTH = 0,
00066 LAYOUT_MIN_HEIGHT = 0,
00067 LAYOUT_FILL_X = 0x00000400,
00068 LAYOUT_FILL_Y = 0x00000800,
00069 LAYOUT_FILL = LAYOUT_FILL_X|LAYOUT_FILL_Y,
00070 LAYOUT_EXPLICIT = LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT
00071 };
00072
00073
00074
00075 enum {
00076 FRAME_NONE = 0,
00077 FRAME_SUNKEN = 0x00001000,
00078 FRAME_RAISED = 0x00002000,
00079 FRAME_THICK = 0x00004000,
00080 FRAME_GROOVE = FRAME_THICK,
00081 FRAME_RIDGE = FRAME_THICK|FRAME_RAISED|FRAME_SUNKEN,
00082 FRAME_LINE = FRAME_RAISED|FRAME_SUNKEN,
00083 FRAME_NORMAL = FRAME_SUNKEN|FRAME_THICK
00084 };
00085
00086
00087
00088 enum {
00089 PACK_NORMAL = 0,
00090 PACK_UNIFORM_HEIGHT = 0x00008000,
00091 PACK_UNIFORM_WIDTH = 0x00010000
00092 };
00093
00094
00095
00096 enum FXDNDOrigin {
00097 FROM_SELECTION = 0,
00098 FROM_CLIPBOARD = 1,
00099 FROM_DRAGNDROP = 2
00100 };
00101
00102
00103
00104 enum FXDragAction {
00105 DRAG_REJECT = 0,
00106 DRAG_ASK = 1,
00107 DRAG_COPY = 2,
00108 DRAG_MOVE = 3,
00109 DRAG_LINK = 4,
00110 DRAG_PRIVATE = 5,
00111 DRAG_ACCEPT = 6
00112 };
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 class FXAPI FXWindow : public FXDrawable {
00132 FXDECLARE(FXWindow)
00133 friend class FXApp;
00134 private:
00135 FXWindow *parent;
00136 FXWindow *owner;
00137 FXWindow *first;
00138 FXWindow *last;
00139 FXWindow *next;
00140 FXWindow *prev;
00141 FXWindow *focus;
00142 FXuint wk;
00143 protected:
00144 FXComposeContext *composeContext;
00145 FXCursor *defaultCursor;
00146 FXCursor *dragCursor;
00147 FXAccelTable *accelTable;
00148 FXObject *target;
00149 FXSelector message;
00150 FXint xpos;
00151 FXint ypos;
00152 FXColor backColor;
00153 FXString tag;
00154 FXuint flags;
00155 FXuint options;
00156 public:
00157 static FXDragType octetType;
00158 static FXDragType deleteType;
00159 static FXDragType textType;
00160 static FXDragType colorType;
00161 static FXDragType urilistType;
00162 static FXDragType utf8Type;
00163 static FXDragType utf16Type;
00164 static FXDragType actionType;
00165 static const FXDragType stringType;
00166 static const FXDragType imageType;
00167 protected:
00168 FXWindow();
00169 FXWindow(FXApp* a,FXVisual *vis);
00170 FXWindow(FXApp* a,FXWindow* own,FXuint opts,FXint x,FXint y,FXint w,FXint h);
00171 virtual FXbool doesOverrideRedirect() const;
00172 protected:
00173 #ifdef WIN32
00174 virtual FXID GetDC() const;
00175 virtual int ReleaseDC(FXID) const;
00176 virtual const void* GetClass() const;
00177 #else
00178 void addColormapWindows();
00179 void remColormapWindows();
00180 #endif
00181 private:
00182 FXWindow(const FXWindow&);
00183 FXWindow& operator=(const FXWindow&);
00184 protected:
00185
00186
00187 enum {
00188 FLAG_SHOWN = 0x00000001,
00189 FLAG_ENABLED = 0x00000002,
00190 FLAG_UPDATE = 0x00000004,
00191 FLAG_DROPTARGET = 0x00000008,
00192 FLAG_FOCUSED = 0x00000010,
00193 FLAG_DIRTY = 0x00000020,
00194 FLAG_RECALC = 0x00000040,
00195 FLAG_TIP = 0x00000080,
00196 FLAG_HELP = 0x00000100,
00197 FLAG_DEFAULT = 0x00000200,
00198 FLAG_INITIAL = 0x00000400,
00199 FLAG_SHELL = 0x00000800,
00200 FLAG_ACTIVE = 0x00001000,
00201 FLAG_PRESSED = 0x00002000,
00202 FLAG_KEY = 0x00004000,
00203 FLAG_CARET = 0x00008000,
00204 FLAG_CHANGED = 0x00010000,
00205 FLAG_LASSO = 0x00020000,
00206 FLAG_TRYDRAG = 0x00040000,
00207 FLAG_DODRAG = 0x00080000,
00208 FLAG_SCROLLINSIDE = 0x00100000,
00209 FLAG_SCROLLING = 0x00200000,
00210 FLAG_OWNED = 0x00400000,
00211 FLAG_CURSOR = 0x00800000
00212 };
00213
00214 public:
00215
00216
00217 enum WindowClass {
00218 ClassNormal,
00219 ClassGraphic,
00220 ClassSpecial,
00221 ClassRoot,
00222 ClassShell,
00223 ClassPopup,
00224 ClassToolTip,
00225 ClassMain,
00226 ClassDialog,
00227 ClassToolBar,
00228 ClassSplash,
00229 ClassNotify,
00230 ClassPanel,
00231 ClassDesktop
00232 };
00233
00234 public:
00235
00236
00237 long onPaint(FXObject*,FXSelector,void*);
00238 long onMap(FXObject*,FXSelector,void*);
00239 long onUnmap(FXObject*,FXSelector,void*);
00240 long onConfigure(FXObject*,FXSelector,void*);
00241 long onUpdate(FXObject*,FXSelector,void*);
00242 long onMotion(FXObject*,FXSelector,void*);
00243 long onMouseWheel(FXObject*,FXSelector,void*);
00244 long onEnter(FXObject*,FXSelector,void*);
00245 long onLeave(FXObject*,FXSelector,void*);
00246 long onLeftBtnPress(FXObject*,FXSelector,void*);
00247 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00248 long onMiddleBtnPress(FXObject*,FXSelector,void*);
00249 long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00250 long onRightBtnPress(FXObject*,FXSelector,void*);
00251 long onRightBtnRelease(FXObject*,FXSelector,void*);
00252 long onSpaceBallMotion(FXObject*,FXSelector,void*);
00253 long onSpaceBallButtonPress(FXObject*,FXSelector,void*);
00254 long onSpaceBallButtonRelease(FXObject*,FXSelector,void*);
00255 long onBeginDrag(FXObject*,FXSelector,void*);
00256 long onEndDrag(FXObject*,FXSelector,void*);
00257 long onDragged(FXObject*,FXSelector,void*);
00258 long onKeyPress(FXObject*,FXSelector,void*);
00259 long onKeyRelease(FXObject*,FXSelector,void*);
00260 long onUngrabbed(FXObject*,FXSelector,void*);
00261 long onDestroy(FXObject*,FXSelector,void*);
00262 long onFocusSelf(FXObject*,FXSelector,void*);
00263 long onFocusIn(FXObject*,FXSelector,void*);
00264 long onFocusOut(FXObject*,FXSelector,void*);
00265 long onSelectionLost(FXObject*,FXSelector,void*);
00266 long onSelectionGained(FXObject*,FXSelector,void*);
00267 long onSelectionRequest(FXObject*,FXSelector,void*);
00268 long onClipboardLost(FXObject*,FXSelector,void*);
00269 long onClipboardGained(FXObject*,FXSelector,void*);
00270 long onClipboardRequest(FXObject*,FXSelector,void*);
00271 long onDNDEnter(FXObject*,FXSelector,void*);
00272 long onDNDLeave(FXObject*,FXSelector,void*);
00273 long onDNDMotion(FXObject*,FXSelector,void*);
00274 long onDNDDrop(FXObject*,FXSelector,void*);
00275 long onDNDRequest(FXObject*,FXSelector,void*);
00276 long onQueryHelp(FXObject*,FXSelector,void*);
00277 long onQueryTip(FXObject*,FXSelector,void*);
00278 long onCmdShow(FXObject*,FXSelector,void*);
00279 long onCmdHide(FXObject*,FXSelector,void*);
00280 long onUpdToggleShown(FXObject*,FXSelector,void*);
00281 long onCmdToggleShown(FXObject*,FXSelector,void*);
00282 long onCmdRaise(FXObject*,FXSelector,void*);
00283 long onCmdLower(FXObject*,FXSelector,void*);
00284 long onCmdEnable(FXObject*,FXSelector,void*);
00285 long onCmdDisable(FXObject*,FXSelector,void*);
00286 long onUpdToggleEnabled(FXObject*,FXSelector,void*);
00287 long onCmdToggleEnabled(FXObject*,FXSelector,void*);
00288 long onCmdUpdate(FXObject*,FXSelector,void*);
00289 long onUpdYes(FXObject*,FXSelector,void*);
00290 long onCmdDelete(FXObject*,FXSelector,void*);
00291
00292 public:
00293
00294
00295 enum {
00296 ID_NONE,
00297 ID_HIDE,
00298 ID_SHOW,
00299 ID_TOGGLESHOWN,
00300 ID_LOWER,
00301 ID_RAISE,
00302 ID_DELETE,
00303 ID_DISABLE,
00304 ID_ENABLE,
00305 ID_TOGGLEENABLED,
00306 ID_UNCHECK,
00307 ID_CHECK,
00308 ID_UNKNOWN,
00309 ID_UPDATE,
00310 ID_TIPTIMER,
00311 ID_SETVALUE,
00312 ID_SETINTVALUE,
00313 ID_SETLONGVALUE,
00314 ID_SETREALVALUE,
00315 ID_SETSTRINGVALUE,
00316 ID_SETICONVALUE,
00317 ID_SETINTRANGE,
00318 ID_SETREALRANGE,
00319 ID_GETINTVALUE,
00320 ID_GETLONGVALUE,
00321 ID_GETREALVALUE,
00322 ID_GETSTRINGVALUE,
00323 ID_GETICONVALUE,
00324 ID_GETINTRANGE,
00325 ID_GETREALRANGE,
00326 ID_SETHELPSTRING,
00327 ID_GETHELPSTRING,
00328 ID_SETTIPSTRING,
00329 ID_GETTIPSTRING,
00330 ID_QUERY_MENU,
00331 ID_HOTKEY,
00332 ID_ACCEL,
00333 ID_UNPOST,
00334 ID_POST,
00335 ID_MDI_TILEHORIZONTAL,
00336 ID_MDI_TILEVERTICAL,
00337 ID_MDI_CASCADE,
00338 ID_MDI_MAXIMIZE,
00339 ID_MDI_MINIMIZE,
00340 ID_MDI_RESTORE,
00341 ID_MDI_CLOSE,
00342 ID_MDI_WINDOW,
00343 ID_MDI_MENUWINDOW,
00344 ID_MDI_MENUMINIMIZE,
00345 ID_MDI_MENURESTORE,
00346 ID_MDI_MENUCLOSE,
00347 ID_MDI_NEXT,
00348 ID_MDI_PREV,
00349 ID_LAST
00350 };
00351
00352 public:
00353
00354
00355 static const FXchar octetTypeName[];
00356 static const FXchar deleteTypeName[];
00357 static const FXchar textTypeName[];
00358 static const FXchar colorTypeName[];
00359 static const FXchar urilistTypeName[];
00360 static const FXchar utf8TypeName[];
00361 static const FXchar utf16TypeName[];
00362 static const FXchar actionTypeName[];
00363
00364 public:
00365
00366
00367 FXWindow(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00368
00369
00370 FXWindow* getParent() const { return parent; }
00371
00372
00373 FXWindow* getOwner() const { return owner; }
00374
00375
00376 FXWindow* getShell() const;
00377
00378
00379 FXWindow* getRoot() const;
00380
00381
00382 FXWindow* getNext() const { return next; }
00383
00384
00385 FXWindow* getPrev() const { return prev; }
00386
00387
00388 FXWindow* getFirst() const { return first; }
00389
00390
00391 FXWindow* getLast() const { return last; }
00392
00393
00394 FXWindow* getFocus() const { return focus; }
00395
00396
00397 virtual WindowClass getWindowClass() const;
00398
00399
00400 void setKey(FXuint k){ wk=k; }
00401
00402
00403 FXuint getKey() const { return wk; }
00404
00405
00406 FXWindow* getChildWithKey(FXuint k) const;
00407
00408
00409 void setTarget(FXObject *t){ target=t; }
00410
00411
00412 FXObject* getTarget() const { return target; }
00413
00414
00415 void setSelector(FXSelector sel){ message=sel; }
00416
00417
00418 FXSelector getSelector() const { return message; }
00419
00420
00421 FXint getX() const { return xpos; }
00422
00423
00424 FXint getY() const { return ypos; }
00425
00426
00427 virtual FXint getDefaultWidth();
00428
00429
00430 virtual FXint getDefaultHeight();
00431
00432
00433 virtual FXint getWidthForHeight(FXint givenheight);
00434
00435
00436 virtual FXint getHeightForWidth(FXint givenwidth);
00437
00438
00439 void setX(FXint x);
00440
00441
00442 void setY(FXint y);
00443
00444
00445
00446
00447
00448
00449 void setWidth(FXint w);
00450
00451
00452
00453
00454
00455
00456 void setHeight(FXint h);
00457
00458
00459 void setLayoutHints(FXuint lout);
00460
00461
00462 FXuint getLayoutHints() const;
00463
00464
00465 FXAccelTable* getAccelTable() const { return accelTable; }
00466
00467
00468 void setAccelTable(FXAccelTable* acceltable){ accelTable=acceltable; }
00469
00470
00471 void addHotKey(FXHotKey code);
00472
00473
00474 void remHotKey(FXHotKey code);
00475
00476
00477 void setHelpTag(const FXString& text){ tag=text; }
00478
00479
00480 const FXString& getHelpTag() const { return tag; }
00481
00482
00483 FXbool isShell() const;
00484
00485
00486 FXbool isOwnerOf(const FXWindow* window) const;
00487
00488
00489 FXbool isChildOf(const FXWindow* window) const;
00490
00491
00492 FXbool containsChild(const FXWindow* child) const;
00493
00494
00495 FXWindow* getChildAt(FXint x,FXint y) const;
00496
00497
00498 FXint numChildren() const;
00499
00500
00501
00502
00503
00504 FXint indexOfChild(const FXWindow *window) const;
00505
00506
00507
00508
00509
00510 FXWindow* childAtIndex(FXint index) const;
00511
00512
00513 static FXWindow* commonAncestor(FXWindow* a,FXWindow* b);
00514
00515
00516 static FXbool before(const FXWindow *a,const FXWindow* b);
00517
00518
00519 static FXbool after(const FXWindow *a,const FXWindow* b);
00520
00521
00522 FXComposeContext* getComposeContext() const { return composeContext; }
00523
00524
00525 void createComposeContext();
00526
00527
00528 void destroyComposeContext();
00529
00530
00531 FXbool cursorShown() const;
00532
00533
00534 void showCursor(FXbool flag=true);
00535
00536
00537 void setDefaultCursor(FXCursor* cur);
00538
00539
00540 FXCursor* getDefaultCursor() const { return defaultCursor; }
00541
00542
00543 void setDragCursor(FXCursor* cur);
00544
00545
00546 FXCursor* getDragCursor() const { return dragCursor; }
00547
00548
00549 FXbool getCursorPosition(FXint& x,FXint& y,FXuint& buttons) const;
00550
00551
00552 FXbool setCursorPosition(FXint x,FXint y);
00553
00554
00555 FXbool isActive() const;
00556
00557
00558 virtual FXbool canFocus() const;
00559
00560
00561 FXbool hasFocus() const;
00562
00563
00564 FXbool inFocusChain() const;
00565
00566
00567 virtual void setFocus();
00568
00569
00570 virtual void killFocus();
00571
00572
00573 virtual void changeFocus(FXWindow *child);
00574
00575
00576 FXbool isDefault() const;
00577
00578
00579
00580
00581
00582
00583
00584
00585 virtual void setDefault(FXuchar flag=TRUE);
00586
00587
00588 FXWindow* findDefault() const;
00589
00590
00591 FXbool isInitial() const;
00592
00593
00594 void setInitial(FXbool flag=true);
00595
00596
00597 FXWindow* findInitial() const;
00598
00599
00600 FXbool isEnabled() const;
00601
00602
00603 virtual void enable();
00604
00605
00606 virtual void disable();
00607
00608
00609 virtual void create();
00610
00611
00612 virtual void attach(FXID w);
00613
00614
00615 virtual void detach();
00616
00617
00618 virtual void destroy();
00619
00620
00621 virtual void setShape(const FXRegion& region);
00622
00623
00624 virtual void setShape(FXBitmap* bitmap);
00625
00626
00627 virtual void setShape(FXIcon* icon);
00628
00629
00630 virtual void clearShape();
00631
00632
00633 virtual void raise();
00634
00635
00636 virtual void lower();
00637
00638
00639
00640
00641
00642
00643 virtual void move(FXint x,FXint y);
00644
00645
00646
00647
00648
00649
00650 virtual void resize(FXint w,FXint h);
00651
00652
00653
00654
00655
00656
00657 virtual void position(FXint x,FXint y,FXint w,FXint h);
00658
00659
00660 virtual void recalc();
00661
00662
00663 virtual void layout();
00664
00665
00666 void forceRefresh();
00667
00668
00669 virtual void reparent(FXWindow* father,FXWindow *other=NULL);
00670
00671
00672 void scroll(FXint x,FXint y,FXint w,FXint h,FXint dx,FXint dy) const;
00673
00674
00675 void update(FXint x,FXint y,FXint w,FXint h) const;
00676
00677
00678 void update() const;
00679
00680
00681 void repaint(FXint x,FXint y,FXint w,FXint h) const;
00682
00683
00684 void repaint() const;
00685
00686
00687 FXbool grabbed() const;
00688
00689
00690
00691
00692
00693 void grab();
00694
00695
00696 void ungrab();
00697
00698
00699 FXbool grabbedKeyboard() const;
00700
00701
00702 void grabKeyboard();
00703
00704
00705 void ungrabKeyboard();
00706
00707
00708 FXbool shown() const;
00709
00710
00711 virtual void show();
00712
00713
00714 virtual void hide();
00715
00716
00717 virtual FXbool isComposite() const;
00718
00719
00720 FXbool underCursor() const;
00721
00722
00723 FXbool hasSelection() const;
00724
00725
00726 FXbool acquireSelection(const FXDragType *types,FXuint numtypes);
00727
00728
00729 FXbool releaseSelection();
00730
00731
00732 FXbool hasClipboard() const;
00733
00734
00735 FXbool acquireClipboard(const FXDragType *types,FXuint numtypes);
00736
00737
00738 FXbool releaseClipboard();
00739
00740
00741 FXbool isDropEnabled() const;
00742
00743
00744 virtual void dropEnable();
00745
00746
00747 virtual void dropDisable();
00748
00749
00750 FXbool isDragging() const;
00751
00752
00753 FXbool beginDrag(const FXDragType *types,FXuint numtypes);
00754
00755
00756
00757
00758
00759 FXbool handleDrag(FXint x,FXint y,FXDragAction action=DRAG_COPY);
00760
00761
00762
00763
00764
00765 FXDragAction endDrag(FXbool drop=true);
00766
00767
00768 FXbool isDropTarget() const;
00769
00770
00771
00772
00773
00774 void setDragRectangle(FXint x,FXint y,FXint w,FXint h,FXbool wantupdates=true) const;
00775
00776
00777
00778
00779
00780 void clearDragRectangle() const;
00781
00782
00783 void acceptDrop(FXDragAction action=DRAG_ACCEPT) const;
00784
00785
00786 FXDragAction didAccept() const;
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799 void dropFinished(FXDragAction action=DRAG_REJECT) const;
00800
00801
00802 FXbool inquireDNDTypes(FXDNDOrigin origin,FXDragType*& types,FXuint& numtypes) const;
00803
00804
00805 FXbool offeredDNDType(FXDNDOrigin origin,FXDragType type) const;
00806
00807
00808 FXDragAction inquireDNDAction() const;
00809
00810
00811
00812
00813
00814 FXbool setDNDData(FXDNDOrigin origin,FXDragType type,FXuchar* data,FXuint size) const;
00815
00816
00817
00818
00819 FXbool setDNDData(FXDNDOrigin origin,FXDragType type,const FXString& string) const;
00820
00821
00822
00823
00824
00825 FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXuchar*& data,FXuint& size) const;
00826
00827
00828
00829
00830 FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXString& string) const;
00831
00832
00833 virtual FXbool contains(FXint parentx,FXint parenty) const;
00834
00835
00836 void translateCoordinatesFrom(FXint& tox,FXint& toy,const FXWindow* fromwindow,FXint fromx,FXint fromy) const;
00837
00838
00839 void translateCoordinatesTo(FXint& tox,FXint& toy,const FXWindow* towindow,FXint fromx,FXint fromy) const;
00840
00841
00842 virtual void setBackColor(FXColor clr);
00843
00844
00845 FXColor getBackColor() const { return backColor; }
00846
00847
00848 virtual FXbool doesSaveUnder() const;
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858 virtual const FXchar* tr(const FXchar* text,const FXchar* hint=NULL,FXint count=-1) const FX_FORMAT(2) ;
00859
00860
00861 virtual void save(FXStream& store) const;
00862
00863
00864 virtual void load(FXStream& store);
00865
00866
00867 virtual ~FXWindow();
00868 };
00869
00870 }
00871
00872 #endif