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
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_DOCK_SAME = 0,
00053 LAYOUT_DOCK_NEXT = 0x00000040,
00054 LAYOUT_RESERVED_1 = 0x00000080,
00055 LAYOUT_FIX_WIDTH = 0x00000100,
00056 LAYOUT_FIX_HEIGHT = 0x00000200,
00057 LAYOUT_MIN_WIDTH = 0,
00058 LAYOUT_MIN_HEIGHT = 0,
00059 LAYOUT_FILL_X = 0x00000400,
00060 LAYOUT_FILL_Y = 0x00000800,
00061 LAYOUT_FILL = LAYOUT_FILL_X|LAYOUT_FILL_Y,
00062 LAYOUT_EXPLICIT = LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT
00063 };
00064
00065
00067 enum {
00068 FRAME_NONE = 0,
00069 FRAME_SUNKEN = 0x00001000,
00070 FRAME_RAISED = 0x00002000,
00071 FRAME_THICK = 0x00004000,
00072 FRAME_GROOVE = FRAME_THICK,
00073 FRAME_RIDGE = FRAME_THICK|FRAME_RAISED|FRAME_SUNKEN,
00074 FRAME_LINE = FRAME_RAISED|FRAME_SUNKEN,
00075 FRAME_NORMAL = FRAME_SUNKEN|FRAME_THICK
00076 };
00077
00078
00080 enum {
00081 PACK_NORMAL = 0,
00082 PACK_UNIFORM_HEIGHT = 0x00008000,
00083 PACK_UNIFORM_WIDTH = 0x00010000
00084 };
00085
00086
00087 class FXIcon;
00088 class FXBitmap;
00089 class FXCursor;
00090 class FXRegion;
00091 class FXComposite;
00092 class FXAccelTable;
00093 class FXComposeContext;
00094
00095
00097 class FXAPI FXWindow : public FXDrawable {
00098 FXDECLARE(FXWindow)
00099 friend class FXApp;
00100 private:
00101 FXWindow *parent;
00102 FXWindow *owner;
00103 FXWindow *first;
00104 FXWindow *last;
00105 FXWindow *next;
00106 FXWindow *prev;
00107 FXWindow *focus;
00108 FXuint wk;
00109 protected:
00110 FXComposeContext *composeContext;
00111 FXCursor *defaultCursor;
00112 FXCursor *savedCursor;
00113 FXCursor *dragCursor;
00114 FXAccelTable *accelTable;
00115 FXObject *target;
00116 FXSelector message;
00117 FXint xpos;
00118 FXint ypos;
00119 FXColor backColor;
00120 FXString tag;
00121 FXuint flags;
00122 FXuint options;
00123 public:
00124 static FXDragType octetType;
00125 static FXDragType deleteType;
00126 static FXDragType textType;
00127 static FXDragType utf8Type;
00128 static FXDragType utf16Type;
00129 static FXDragType colorType;
00130 static FXDragType urilistType;
00131 static const FXDragType stringType;
00132 static const FXDragType imageType;
00134 static inline FXuint userHandednessLayout()
00135 {
00136 return FXProcess::userHandedness()==FXProcess::RIGHT_HANDED ?
00137 LAYOUT_RIGHT : LAYOUT_LEFT;
00138 }
00140 static inline FXuint defaultPadding() { return FXProcess::screenScale(2); }
00142 static inline FXuint defaultSpacing() { return FXProcess::screenScale(4); }
00144 static inline FXuint scaleLayoutValue(FXuint value) { return FXProcess::screenScale(value); }
00145
00146 protected:
00147 FXWindow();
00148 FXWindow(FXApp* a,FXVisual *vis);
00149 FXWindow(FXApp* a,FXWindow* own,FXuint opts,FXint x,FXint y,FXint w,FXint h);
00150 static FXWindow* findDefault(FXWindow* window);
00151 static FXWindow* findInitial(FXWindow* window);
00152 virtual bool doesOverrideRedirect() const;
00153 protected:
00154 #ifdef WIN32
00155 virtual FXID GetDC() const;
00156 virtual int ReleaseDC(FXID) const;
00157 virtual const char* GetClass() const;
00158 #else
00159 void addColormapWindows();
00160 void remColormapWindows();
00161 #endif
00162 private:
00163 FXWindow(const FXWindow&);
00164 FXWindow& operator=(const FXWindow&);
00165 protected:
00166
00167
00168 enum {
00169 FLAG_SHOWN = 0x00000001,
00170 FLAG_ENABLED = 0x00000002,
00171 FLAG_UPDATE = 0x00000004,
00172 FLAG_DROPTARGET = 0x00000008,
00173 FLAG_FOCUSED = 0x00000010,
00174 FLAG_DIRTY = 0x00000020,
00175 FLAG_RECALC = 0x00000040,
00176 FLAG_TIP = 0x00000080,
00177 FLAG_HELP = 0x00000100,
00178 FLAG_DEFAULT = 0x00000200,
00179 FLAG_INITIAL = 0x00000400,
00180 FLAG_SHELL = 0x00000800,
00181 FLAG_ACTIVE = 0x00001000,
00182 FLAG_PRESSED = 0x00002000,
00183 FLAG_KEY = 0x00004000,
00184 FLAG_CARET = 0x00008000,
00185 FLAG_CHANGED = 0x00010000,
00186 FLAG_LASSO = 0x00020000,
00187 FLAG_TRYDRAG = 0x00040000,
00188 FLAG_DODRAG = 0x00080000,
00189 FLAG_SCROLLINSIDE = 0x00100000,
00190 FLAG_SCROLLING = 0x00200000,
00191 FLAG_OWNED = 0x00400000,
00192 FLAG_POPUP = 0x00800000
00193 };
00194
00195 public:
00196
00197
00198 long onPaint(FXObject*,FXSelector,void*);
00199 long onMap(FXObject*,FXSelector,void*);
00200 long onUnmap(FXObject*,FXSelector,void*);
00201 long onConfigure(FXObject*,FXSelector,void*);
00202 long onUpdate(FXObject*,FXSelector,void*);
00203 long onMotion(FXObject*,FXSelector,void*);
00204 long onMouseWheel(FXObject*,FXSelector,void*);
00205 long onEnter(FXObject*,FXSelector,void*);
00206 long onLeave(FXObject*,FXSelector,void*);
00207 long onLeftBtnPress(FXObject*,FXSelector,void*);
00208 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00209 long onMiddleBtnPress(FXObject*,FXSelector,void*);
00210 long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00211 long onRightBtnPress(FXObject*,FXSelector,void*);
00212 long onRightBtnRelease(FXObject*,FXSelector,void*);
00213 long onBeginDrag(FXObject*,FXSelector,void*);
00214 long onEndDrag(FXObject*,FXSelector,void*);
00215 long onDragged(FXObject*,FXSelector,void*);
00216 long onKeyPress(FXObject*,FXSelector,void*);
00217 long onKeyRelease(FXObject*,FXSelector,void*);
00218 long onUngrabbed(FXObject*,FXSelector,void*);
00219 long onDestroy(FXObject*,FXSelector,void*);
00220 long onFocusSelf(FXObject*,FXSelector,void*);
00221 long onFocusIn(FXObject*,FXSelector,void*);
00222 long onFocusOut(FXObject*,FXSelector,void*);
00223 long onSelectionLost(FXObject*,FXSelector,void*);
00224 long onSelectionGained(FXObject*,FXSelector,void*);
00225 long onSelectionRequest(FXObject*,FXSelector,void*);
00226 long onClipboardLost(FXObject*,FXSelector,void*);
00227 long onClipboardGained(FXObject*,FXSelector,void*);
00228 long onClipboardRequest(FXObject*,FXSelector,void*);
00229 long onDNDEnter(FXObject*,FXSelector,void*);
00230 long onDNDLeave(FXObject*,FXSelector,void*);
00231 long onDNDMotion(FXObject*,FXSelector,void*);
00232 long onDNDDrop(FXObject*,FXSelector,void*);
00233 long onDNDRequest(FXObject*,FXSelector,void*);
00234 long onQueryHelp(FXObject*,FXSelector,void*);
00235 long onQueryTip(FXObject*,FXSelector,void*);
00236 long onCmdShow(FXObject*,FXSelector,void*);
00237 long onCmdHide(FXObject*,FXSelector,void*);
00238 long onUpdToggleShown(FXObject*,FXSelector,void*);
00239 long onCmdToggleShown(FXObject*,FXSelector,void*);
00240 long onCmdRaise(FXObject*,FXSelector,void*);
00241 long onCmdLower(FXObject*,FXSelector,void*);
00242 long onCmdEnable(FXObject*,FXSelector,void*);
00243 long onCmdDisable(FXObject*,FXSelector,void*);
00244 long onUpdToggleEnabled(FXObject*,FXSelector,void*);
00245 long onCmdToggleEnabled(FXObject*,FXSelector,void*);
00246 long onCmdUpdate(FXObject*,FXSelector,void*);
00247 long onUpdYes(FXObject*,FXSelector,void*);
00248 long onCmdDelete(FXObject*,FXSelector,void*);
00249
00250 public:
00251
00252
00253 enum {
00254 ID_NONE,
00255 ID_HIDE,
00256 ID_SHOW,
00257 ID_TOGGLESHOWN,
00258 ID_LOWER,
00259 ID_RAISE,
00260 ID_DELETE,
00261 ID_DISABLE,
00262 ID_ENABLE,
00263 ID_TOGGLEENABLED,
00264 ID_UNCHECK,
00265 ID_CHECK,
00266 ID_UNKNOWN,
00267 ID_UPDATE,
00268 ID_AUTOSCROLL,
00269 ID_TIPTIMER,
00270 ID_HSCROLLED,
00271 ID_VSCROLLED,
00272 ID_SETVALUE,
00273 ID_SETINTVALUE,
00274 ID_SETREALVALUE,
00275 ID_SETSTRINGVALUE,
00276 ID_SETICONVALUE,
00277 ID_SETINTRANGE,
00278 ID_SETREALRANGE,
00279 ID_GETINTVALUE,
00280 ID_GETREALVALUE,
00281 ID_GETSTRINGVALUE,
00282 ID_GETICONVALUE,
00283 ID_GETINTRANGE,
00284 ID_GETREALRANGE,
00285 ID_SETHELPSTRING,
00286 ID_GETHELPSTRING,
00287 ID_SETTIPSTRING,
00288 ID_GETTIPSTRING,
00289 ID_QUERY_MENU,
00290 ID_HOTKEY,
00291 ID_ACCEL,
00292 ID_UNPOST,
00293 ID_POST,
00294 ID_MDI_TILEHORIZONTAL,
00295 ID_MDI_TILEVERTICAL,
00296 ID_MDI_CASCADE,
00297 ID_MDI_MAXIMIZE,
00298 ID_MDI_MINIMIZE,
00299 ID_MDI_RESTORE,
00300 ID_MDI_CLOSE,
00301 ID_MDI_WINDOW,
00302 ID_MDI_MENUWINDOW,
00303 ID_MDI_MENUMINIMIZE,
00304 ID_MDI_MENURESTORE,
00305 ID_MDI_MENUCLOSE,
00306 ID_MDI_NEXT,
00307 ID_MDI_PREV,
00308 ID_LAST
00309 };
00310
00311 public:
00312
00313
00314 static const FXchar *octetTypeName;
00315 static const FXchar *deleteTypeName;
00316 static const FXchar *textTypeName;
00317 static const FXchar *colorTypeName;
00318 static const FXchar *urilistTypeName;
00319 static const FXchar *utf8TypeName;
00320 static const FXchar *utf16TypeName;
00321
00322 public:
00323
00325 FXWindow(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00326
00328 FXWindow* getParent() const { return parent; }
00329
00331 FXWindow* getOwner() const { return owner; }
00332
00334 FXWindow* getShell() const;
00335
00337 FXWindow* getRoot() const;
00338
00340 FXWindow* getNext() const { return next; }
00341
00343 FXWindow* getPrev() const { return prev; }
00344
00346 FXWindow* getFirst() const { return first; }
00347
00349 FXWindow* getLast() const { return last; }
00350
00352 FXWindow* getFocus() const { return focus; }
00353
00355 void setKey(FXuint k){ wk=k; }
00356
00358 FXuint getKey() const { return wk; }
00359
00361 void setTarget(FXObject *t){ target=t; }
00362
00364 FXObject* getTarget() const { return target; }
00365
00367 void setSelector(FXSelector sel){ message=sel; }
00368
00370 FXSelector getSelector() const { return message; }
00371
00373 FXint getX() const { return xpos; }
00374
00376 FXint getY() const { return ypos; }
00377
00379 virtual FXint getDefaultWidth();
00380
00382 virtual FXint getDefaultHeight();
00383
00385 virtual FXint getWidthForHeight(FXint givenheight);
00386
00388 virtual FXint getHeightForWidth(FXint givenwidth);
00389
00391 void setX(FXint x);
00392
00394 void setY(FXint y);
00395
00401 void setWidth(FXint w);
00402
00408 void setHeight(FXint h);
00409
00411 void setLayoutHints(FXuint lout);
00412
00414 FXuint getLayoutHints() const;
00415
00417 FXAccelTable* getAccelTable() const { return accelTable; }
00418
00420 void setAccelTable(FXAccelTable* acceltable){ accelTable=acceltable; }
00421
00423 void addHotKey(FXHotKey code);
00424
00426 void remHotKey(FXHotKey code);
00427
00429 void setHelpTag(const FXString& text){ tag=text; }
00430
00432 const FXString& getHelpTag() const { return tag; }
00433
00435 bool isShell() const;
00436
00438 bool isPopup() const;
00439
00441 bool isOwnerOf(const FXWindow* window) const;
00442
00444 bool isChildOf(const FXWindow* window) const;
00445
00447 bool containsChild(const FXWindow* child) const;
00448
00450 FXWindow* getChildAt(FXint x,FXint y) const;
00451
00453 FXint numChildren() const;
00454
00459 FXint indexOfChild(const FXWindow *window) const;
00460
00465 FXWindow* childAtIndex(FXint index) const;
00466
00468 static FXWindow* commonAncestor(FXWindow* a,FXWindow* b);
00469
00471 static bool before(const FXWindow *a,const FXWindow* b);
00472
00474 static bool after(const FXWindow *a,const FXWindow* b);
00475
00477 FXComposeContext* getComposeContext() const { return composeContext; }
00478
00480 void createComposeContext();
00481
00483 void destroyComposeContext();
00484
00486 void setDefaultCursor(FXCursor* cur);
00487
00489 FXCursor* getDefaultCursor() const { return defaultCursor; }
00490
00492 void setSavedCursor(FXCursor* cur) { savedCursor=cur; }
00493
00495 FXCursor* getSavedCursor() const { return savedCursor; }
00496
00498 void setDragCursor(FXCursor* cur);
00499
00501 FXCursor* getDragCursor() const { return dragCursor; }
00502
00504 FXint getCursorPosition(FXint& x,FXint& y,FXuint& buttons) const;
00505
00507 FXint setCursorPosition(FXint x,FXint y);
00508
00510 bool isEnabled() const;
00511
00513 bool isActive() const;
00514
00516 virtual bool canFocus() const;
00517
00519 bool hasFocus() const;
00520
00522 bool inFocusChain() const;
00523
00525 virtual void setFocus();
00526
00528 virtual void killFocus();
00529
00531 virtual void changeFocus(FXWindow *child);
00532
00540 virtual void setDefault(FXbool enable=TRUE);
00541
00543 bool isDefault() const;
00544
00546 void setInitial(bool enable=true);
00547
00549 bool isInitial() const;
00550
00552 virtual void enable();
00553
00555 virtual void disable();
00556
00558 virtual void create();
00559
00561 virtual void attach(FXID w);
00562
00564 virtual void detach();
00565
00567 virtual void destroy();
00568
00570 virtual void setShape(const FXRegion& region);
00571
00573 virtual void setShape(FXBitmap* bitmap);
00574
00576 virtual void setShape(FXIcon* icon);
00577
00579 virtual void clearShape();
00580
00582 virtual void raise();
00583
00585 virtual void lower();
00586
00592 virtual void move(FXint x,FXint y);
00593
00599 virtual void resize(FXint w,FXint h);
00600
00606 virtual void position(FXint x,FXint y,FXint w,FXint h);
00607
00609 virtual void recalc();
00610
00612 virtual void layout();
00613
00615 void forceRefresh();
00616
00618 virtual void reparent(FXWindow* father,FXWindow *other=NULL);
00619
00621 void scroll(FXint x,FXint y,FXint w,FXint h,FXint dx,FXint dy) const;
00622
00624 void update(FXint x,FXint y,FXint w,FXint h) const;
00625
00627 void update() const;
00628
00630 void repaint(FXint x,FXint y,FXint w,FXint h) const;
00631
00633 void repaint() const;
00634
00639 void grab();
00640
00642 void ungrab();
00643
00645 bool grabbed() const;
00646
00648 void grabKeyboard();
00649
00651 void ungrabKeyboard();
00652
00654 bool grabbedKeyboard() const;
00655
00657 virtual void show();
00658
00660 virtual void hide();
00661
00663 bool shown() const;
00664
00666 virtual bool isComposite() const;
00667
00669 bool underCursor() const;
00670
00672 bool hasSelection() const;
00673
00675 bool acquireSelection(const FXDragType *types,FXuint numtypes);
00676
00678 bool releaseSelection();
00679
00681 bool hasClipboard() const;
00682
00684 bool acquireClipboard(const FXDragType *types,FXuint numtypes);
00685
00687 bool releaseClipboard();
00688
00690 virtual void dropEnable();
00691
00693 virtual void dropDisable();
00694
00696 bool isDropEnabled() const;
00697
00699 bool isDragging() const;
00700
00702 bool beginDrag(const FXDragType *types,FXuint numtypes);
00703
00708 bool handleDrag(FXint x,FXint y,FXDragAction action=DRAG_COPY);
00709
00714 FXDragAction endDrag(bool drop=true);
00715
00717 bool isDropTarget() const;
00718
00723 void setDragRectangle(FXint x,FXint y,FXint w,FXint h,bool wantupdates=true) const;
00724
00729 void clearDragRectangle() const;
00730
00732 void acceptDrop(FXDragAction action=DRAG_ACCEPT) const;
00733
00735 FXDragAction didAccept() const;
00736
00748 void dropFinished(FXDragAction action=DRAG_REJECT) const;
00749
00751 bool inquireDNDTypes(FXDNDOrigin origin,FXDragType*& types,FXuint& numtypes) const;
00752
00754 bool offeredDNDType(FXDNDOrigin origin,FXDragType type) const;
00755
00757 FXDragAction inquireDNDAction() const;
00758
00763 bool setDNDData(FXDNDOrigin origin,FXDragType type,FXuchar* data,FXuint size) const;
00764
00768 bool setDNDData(FXDNDOrigin origin,FXDragType type,const FXString& string) const;
00769
00774 bool getDNDData(FXDNDOrigin origin,FXDragType type,FXuchar*& data,FXuint& size) const;
00775
00779 bool getDNDData(FXDNDOrigin origin,FXDragType type,FXString& string) const;
00780
00782 virtual bool contains(FXint parentx,FXint parenty) const;
00783
00785 void translateCoordinatesFrom(FXint& tox,FXint& toy,const FXWindow* fromwindow,FXint fromx,FXint fromy) const;
00786
00788 void translateCoordinatesTo(FXint& tox,FXint& toy,const FXWindow* towindow,FXint fromx,FXint fromy) const;
00789
00791 virtual void setBackColor(FXColor clr);
00792
00794 FXColor getBackColor() const { return backColor; }
00795
00796 virtual bool doesSaveUnder() const;
00797
00799 virtual void save(FXStream& store) const;
00800
00802 virtual void load(FXStream& store);
00803
00805 virtual ~FXWindow();
00806 };
00807
00808 }
00809
00810 #endif