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