Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXWindow.h
1 /********************************************************************************
2 * *
3 * W i n d o w O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXWINDOW_H
22 #define FXWINDOW_H
23 
24 #ifndef FXDRAWABLE_H
25 #include "FXDrawable.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 // Forward declarations
32 class FXIcon;
33 class FXBitmap;
34 class FXCursor;
35 class FXRegion;
36 class FXDCWindow;
37 class FXComposite;
38 class FXAccelTable;
39 class FXComposeContext;
40 
41 
43 enum {
44  LAYOUT_NORMAL = 0,
45  LAYOUT_SIDE_TOP = 0,
46  LAYOUT_SIDE_BOTTOM = 0x00000001,
47  LAYOUT_SIDE_LEFT = 0x00000002,
48  LAYOUT_SIDE_RIGHT = LAYOUT_SIDE_LEFT|LAYOUT_SIDE_BOTTOM,
49  LAYOUT_FILL_COLUMN = 0x00000001,
50  LAYOUT_FILL_ROW = 0x00000002,
51  LAYOUT_LEFT = 0,
52  LAYOUT_RIGHT = 0x00000004,
53  LAYOUT_CENTER_X = 0x00000008,
54  LAYOUT_FIX_X = LAYOUT_RIGHT|LAYOUT_CENTER_X,
55  LAYOUT_TOP = 0,
56  LAYOUT_BOTTOM = 0x00000010,
57  LAYOUT_CENTER_Y = 0x00000020,
58  LAYOUT_FIX_Y = LAYOUT_BOTTOM|LAYOUT_CENTER_Y,
59  LAYOUT_DOCK_SAME = 0,
60  LAYOUT_DOCK_NEXT = 0x00000040,
61  LAYOUT_RESERVED_1 = 0x00000080,
62  LAYOUT_FIX_WIDTH = 0x00000100,
63  LAYOUT_FIX_HEIGHT = 0x00000200,
64  LAYOUT_MIN_WIDTH = 0,
65  LAYOUT_MIN_HEIGHT = 0,
66  LAYOUT_FILL_X = 0x00000400,
67  LAYOUT_FILL_Y = 0x00000800,
68  LAYOUT_FILL = LAYOUT_FILL_X|LAYOUT_FILL_Y,
69  LAYOUT_EXPLICIT = LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT
70  };
71 
72 
74 enum {
75  FRAME_NONE = 0,
76  FRAME_SUNKEN = 0x00001000,
77  FRAME_RAISED = 0x00002000,
78  FRAME_THICK = 0x00004000,
79  FRAME_GROOVE = FRAME_THICK,
80  FRAME_RIDGE = FRAME_THICK|FRAME_RAISED|FRAME_SUNKEN,
81  FRAME_LINE = FRAME_RAISED|FRAME_SUNKEN,
82  FRAME_NORMAL = FRAME_SUNKEN|FRAME_THICK
83  };
84 
85 
87 enum {
88  PACK_NORMAL = 0,
89  PACK_UNIFORM_HEIGHT = 0x00008000,
90  PACK_UNIFORM_WIDTH = 0x00010000
91  };
92 
93 
95 enum FXDNDOrigin {
96  FROM_SELECTION = 0,
97  FROM_CLIPBOARD = 1,
98  FROM_DRAGNDROP = 2
99  };
100 
101 
103 enum FXDragAction {
104  DRAG_REJECT = 0,
105  DRAG_ASK = 1,
106  DRAG_COPY = 2,
107  DRAG_MOVE = 3,
108  DRAG_LINK = 4,
109  DRAG_PRIVATE = 5,
110  DRAG_ACCEPT = 6
111  };
112 
113 
130 class FXAPI FXWindow : public FXDrawable {
131  FXDECLARE(FXWindow)
132  friend class FXApp;
133 private:
134  FXWindow *parent; // Parent Window
135  FXWindow *owner; // Owner Window
136  FXWindow *first; // First Child
137  FXWindow *last; // Last Child
138  FXWindow *next; // Next Sibling
139  FXWindow *prev; // Previous Sibling
140  FXWindow *focus; // Focus Child
141  FXuint wk; // Window Key
142 protected:
143  FXComposeContext *composeContext; // Compose context
144  FXCursor *defaultCursor; // Normal Cursor
145  FXCursor *dragCursor; // Cursor during drag
146  FXAccelTable *accelTable; // Accelerator table
147  FXObject *target; // Target object
148  FXSelector message; // Message ID
149  FXint xpos; // Window X Position
150  FXint ypos; // Window Y Position
151  FXColor backColor; // Window background color
152  FXString tag; // Help tag
153  FXuint flags; // Window state flags
154  FXuint options; // Window options
155 public:
156  static FXDragType octetType; // Raw octet stream
157  static FXDragType deleteType; // Delete request
158  static FXDragType textType; // Ascii text request
159  static FXDragType colorType; // Color request
160  static FXDragType urilistType; // URI list request
161  static FXDragType utf8Type; // UTF-8 text request
162  static FXDragType utf16Type; // UTF-16 text request
163  static FXDragType actionType; // Clipboard action
164  static const FXDragType stringType; // Clipboard text type (pre-registered)
165  static const FXDragType imageType; // Clipboard image type (pre-registered)
166 protected:
167  FXWindow();
168  FXWindow(FXApp* a,FXVisual *vis);
169  FXWindow(FXApp* a,FXWindow* own,FXuint opts,FXint x,FXint y,FXint w,FXint h);
170  virtual FXbool doesOverrideRedirect() const;
171 protected:
172 #ifdef WIN32
173  virtual FXID GetDC() const;
174  virtual int ReleaseDC(FXID) const;
175  virtual const void* GetClass() const;
176 #else
177  void addColormapWindows();
178  void remColormapWindows();
179 #endif
180 private:
181  FXWindow(const FXWindow&);
182  FXWindow& operator=(const FXWindow&);
183 protected:
184 
185  // Window state flags
186  enum {
187  FLAG_SHOWN = 0x00000001, // Is shown
188  FLAG_ENABLED = 0x00000002, // Able to receive input
189  FLAG_UPDATE = 0x00000004, // Is subject to GUI update
190  FLAG_DROPTARGET = 0x00000008, // Drop target
191  FLAG_FOCUSED = 0x00000010, // Has focus
192  FLAG_DIRTY = 0x00000020, // Needs layout
193  FLAG_RECALC = 0x00000040, // Needs recalculation
194  FLAG_TIP = 0x00000080, // Show tip
195  FLAG_HELP = 0x00000100, // Show help
196  FLAG_DEFAULT = 0x00000200, // Default widget
197  FLAG_INITIAL = 0x00000400, // Initial widget
198  FLAG_SHELL = 0x00000800, // Shell window
199  FLAG_ACTIVE = 0x00001000, // Window is active
200  FLAG_PRESSED = 0x00002000, // Button has been pressed
201  FLAG_KEY = 0x00004000, // Keyboard key pressed
202  FLAG_CARET = 0x00008000, // Caret is on
203  FLAG_CHANGED = 0x00010000, // Window data changed
204  FLAG_LASSO = 0x00020000, // Lasso mode
205  FLAG_TRYDRAG = 0x00040000, // Tentative drag mode
206  FLAG_DODRAG = 0x00080000, // Doing drag mode
207  FLAG_SCROLLINSIDE = 0x00100000, // Scroll only when inside
208  FLAG_SCROLLING = 0x00200000, // Right mouse scrolling
209  FLAG_OWNED = 0x00400000, // Owned window handle
210  FLAG_CURSOR = 0x00800000 // Showing cursor
211  };
212 
213 public:
214 
216  enum WindowClass {
217  ClassNormal,
230  ClassDesktop
231  };
232 
233 public:
234 
235  // Message handlers
236  long onPaint(FXObject*,FXSelector,void*);
237  long onMap(FXObject*,FXSelector,void*);
238  long onUnmap(FXObject*,FXSelector,void*);
239  long onConfigure(FXObject*,FXSelector,void*);
240  long onUpdate(FXObject*,FXSelector,void*);
241  long onMotion(FXObject*,FXSelector,void*);
242  long onMouseWheel(FXObject*,FXSelector,void*);
243  long onEnter(FXObject*,FXSelector,void*);
244  long onLeave(FXObject*,FXSelector,void*);
245  long onLeftBtnPress(FXObject*,FXSelector,void*);
246  long onLeftBtnRelease(FXObject*,FXSelector,void*);
247  long onMiddleBtnPress(FXObject*,FXSelector,void*);
248  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
249  long onRightBtnPress(FXObject*,FXSelector,void*);
250  long onRightBtnRelease(FXObject*,FXSelector,void*);
251  long onSpaceBallMotion(FXObject*,FXSelector,void*);
252  long onSpaceBallButtonPress(FXObject*,FXSelector,void*);
253  long onSpaceBallButtonRelease(FXObject*,FXSelector,void*);
254  long onBeginDrag(FXObject*,FXSelector,void*);
255  long onEndDrag(FXObject*,FXSelector,void*);
256  long onDragged(FXObject*,FXSelector,void*);
257  long onKeyPress(FXObject*,FXSelector,void*);
258  long onKeyRelease(FXObject*,FXSelector,void*);
259  long onUngrabbed(FXObject*,FXSelector,void*);
260  long onDestroy(FXObject*,FXSelector,void*);
261  long onFocusSelf(FXObject*,FXSelector,void*);
262  long onFocusIn(FXObject*,FXSelector,void*);
263  long onFocusOut(FXObject*,FXSelector,void*);
264  long onSelectionLost(FXObject*,FXSelector,void*);
265  long onSelectionGained(FXObject*,FXSelector,void*);
266  long onSelectionRequest(FXObject*,FXSelector,void*);
267  long onClipboardLost(FXObject*,FXSelector,void*);
268  long onClipboardGained(FXObject*,FXSelector,void*);
269  long onClipboardRequest(FXObject*,FXSelector,void*);
270  long onDNDEnter(FXObject*,FXSelector,void*);
271  long onDNDLeave(FXObject*,FXSelector,void*);
272  long onDNDMotion(FXObject*,FXSelector,void*);
273  long onDNDDrop(FXObject*,FXSelector,void*);
274  long onDNDRequest(FXObject*,FXSelector,void*);
275  long onQueryHelp(FXObject*,FXSelector,void*);
276  long onQueryTip(FXObject*,FXSelector,void*);
277  long onCmdShow(FXObject*,FXSelector,void*);
278  long onCmdHide(FXObject*,FXSelector,void*);
279  long onUpdToggleShown(FXObject*,FXSelector,void*);
280  long onCmdToggleShown(FXObject*,FXSelector,void*);
281  long onCmdRaise(FXObject*,FXSelector,void*);
282  long onCmdLower(FXObject*,FXSelector,void*);
283  long onCmdEnable(FXObject*,FXSelector,void*);
284  long onCmdDisable(FXObject*,FXSelector,void*);
285  long onUpdToggleEnabled(FXObject*,FXSelector,void*);
286  long onCmdToggleEnabled(FXObject*,FXSelector,void*);
287  long onCmdUpdate(FXObject*,FXSelector,void*);
288  long onUpdYes(FXObject*,FXSelector,void*);
289  long onCmdDelete(FXObject*,FXSelector,void*);
290 
291 public:
292 
293  // Message ID's common to most Windows
294  enum {
295  ID_NONE,
296  ID_HIDE,
297  ID_SHOW,
298  ID_TOGGLESHOWN,
299  ID_LOWER,
300  ID_RAISE,
301  ID_DELETE,
302  ID_DISABLE,
303  ID_ENABLE,
304  ID_TOGGLEENABLED,
305  ID_UNCHECK,
306  ID_CHECK,
307  ID_UNKNOWN,
308  ID_UPDATE,
309  ID_TIPTIMER,
310  ID_SETVALUE,
311  ID_SETINTVALUE,
312  ID_SETLONGVALUE,
313  ID_SETREALVALUE,
314  ID_SETSTRINGVALUE,
315  ID_SETICONVALUE,
316  ID_SETINTRANGE,
317  ID_SETREALRANGE,
318  ID_GETINTVALUE,
319  ID_GETLONGVALUE,
320  ID_GETREALVALUE,
321  ID_GETSTRINGVALUE,
322  ID_GETICONVALUE,
323  ID_GETINTRANGE,
324  ID_GETREALRANGE,
325  ID_SETHELPSTRING,
326  ID_GETHELPSTRING,
327  ID_SETTIPSTRING,
328  ID_GETTIPSTRING,
329  ID_QUERY_MENU,
330  ID_HOTKEY,
331  ID_ACCEL,
332  ID_UNPOST,
333  ID_POST,
334  ID_MDI_TILEHORIZONTAL,
335  ID_MDI_TILEVERTICAL,
336  ID_MDI_CASCADE,
337  ID_MDI_MAXIMIZE,
338  ID_MDI_MINIMIZE,
339  ID_MDI_RESTORE,
340  ID_MDI_CLOSE,
341  ID_MDI_WINDOW,
342  ID_MDI_MENUWINDOW,
343  ID_MDI_MENUMINIMIZE,
344  ID_MDI_MENURESTORE,
345  ID_MDI_MENUCLOSE,
346  ID_MDI_NEXT,
347  ID_MDI_PREV,
348  ID_LAST
349  };
350 
351 public:
352 
353  // Predefined DND type names
354  static const FXchar octetTypeName[];
355  static const FXchar deleteTypeName[];
356  static const FXchar textTypeName[];
357  static const FXchar colorTypeName[];
358  static const FXchar urilistTypeName[];
359  static const FXchar utf8TypeName[];
360  static const FXchar utf16TypeName[];
361  static const FXchar actionTypeName[];
362 
363 public:
364 
366  FXWindow(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
367 
369  FXWindow* getParent() const { return parent; }
370 
372  FXWindow* getOwner() const { return owner; }
373 
375  FXWindow* getShell() const;
376 
378  FXWindow* getRoot() const;
379 
381  FXWindow* getNext() const { return next; }
382 
384  FXWindow* getPrev() const { return prev; }
385 
387  FXWindow* getFirst() const { return first; }
388 
390  FXWindow* getLast() const { return last; }
391 
393  FXWindow* getFocus() const { return focus; }
394 
396  virtual WindowClass getWindowClass() const;
397 
399  void setKey(FXuint k){ wk=k; }
400 
402  FXuint getKey() const { return wk; }
403 
405  FXWindow* getChildWithKey(FXuint k) const;
406 
408  void setTarget(FXObject *t){ target=t; }
409 
411  FXObject* getTarget() const { return target; }
412 
414  void setSelector(FXSelector sel){ message=sel; }
415 
417  FXSelector getSelector() const { return message; }
418 
420  FXint getX() const { return xpos; }
421 
423  FXint getY() const { return ypos; }
424 
426  virtual FXint getDefaultWidth();
427 
429  virtual FXint getDefaultHeight();
430 
432  virtual FXint getWidthForHeight(FXint givenheight);
433 
435  virtual FXint getHeightForWidth(FXint givenwidth);
436 
438  void setX(FXint x);
439 
441  void setY(FXint y);
442 
448  void setWidth(FXint w);
449 
455  void setHeight(FXint h);
456 
458  void setLayoutHints(FXuint lout);
459 
461  FXuint getLayoutHints() const;
462 
464  FXAccelTable* getAccelTable() const { return accelTable; }
465 
467  void setAccelTable(FXAccelTable* acceltable){ accelTable=acceltable; }
468 
470  void addHotKey(FXHotKey code);
471 
473  void remHotKey(FXHotKey code);
474 
476  void setHelpTag(const FXString& text){ tag=text; }
477 
479  const FXString& getHelpTag() const { return tag; }
480 
482  FXbool isShell() const;
483 
485  FXbool isOwnerOf(const FXWindow* window) const;
486 
488  FXbool isChildOf(const FXWindow* window) const;
489 
491  FXbool containsChild(const FXWindow* child) const;
492 
494  FXWindow* getChildAt(FXint x,FXint y) const;
495 
497  FXint numChildren() const;
498 
503  FXint indexOfChild(const FXWindow *window) const;
504 
509  FXWindow* childAtIndex(FXint index) const;
510 
512  static FXWindow* commonAncestor(FXWindow* a,FXWindow* b);
513 
515  static FXbool before(const FXWindow *a,const FXWindow* b);
516 
518  static FXbool after(const FXWindow *a,const FXWindow* b);
519 
521  FXComposeContext* getComposeContext() const { return composeContext; }
522 
524  void createComposeContext();
525 
527  void destroyComposeContext();
528 
530  FXbool cursorShown() const;
531 
533  void showCursor(FXbool flag=true);
534 
536  void setDefaultCursor(FXCursor* cur);
537 
539  FXCursor* getDefaultCursor() const { return defaultCursor; }
540 
542  void setDragCursor(FXCursor* cur);
543 
545  FXCursor* getDragCursor() const { return dragCursor; }
546 
548  FXbool getCursorPosition(FXint& x,FXint& y,FXuint& buttons) const;
549 
551  FXbool setCursorPosition(FXint x,FXint y);
552 
554  FXbool isActive() const;
555 
557  virtual FXbool canFocus() const;
558 
560  FXbool hasFocus() const;
561 
563  FXbool inFocusChain() const;
564 
566  virtual void setFocus();
567 
569  virtual void killFocus();
570 
572  virtual void changeFocus(FXWindow *child);
573 
575  FXbool isDefault() const;
576 
584  virtual void setDefault(FXuchar flag=true);
585 
587  FXWindow* findDefault() const;
588 
590  FXbool isInitial() const;
591 
593  void setInitial(FXbool flag=true);
594 
596  FXWindow* findInitial() const;
597 
599  FXbool isEnabled() const;
600 
602  virtual void enable();
603 
605  virtual void disable();
606 
608  virtual void create();
609 
611  virtual void attach(FXID w);
612 
614  virtual void detach();
615 
617  virtual void destroy();
618 
620  virtual void setShape(const FXRegion& region);
621 
623  virtual void setShape(FXBitmap* bitmap);
624 
626  virtual void setShape(FXIcon* icon);
627 
629  virtual void clearShape();
630 
632  virtual void raise();
633 
635  virtual void lower();
636 
642  virtual void move(FXint x,FXint y);
643 
649  virtual void resize(FXint w,FXint h);
650 
656  virtual void position(FXint x,FXint y,FXint w,FXint h);
657 
659  virtual void recalc();
660 
662  virtual void layout();
663 
665  void forceRefresh();
666 
668  virtual void reparent(FXWindow* father,FXWindow *other=NULL);
669 
671  void scroll(FXint x,FXint y,FXint w,FXint h,FXint dx,FXint dy) const;
672 
674  void update(FXint x,FXint y,FXint w,FXint h) const;
675 
677  void update() const;
678 
680  void repaint(FXint x,FXint y,FXint w,FXint h) const;
681 
683  void repaint() const;
684 
686  FXbool grabbed() const;
687 
692  void grab();
693 
695  void ungrab();
696 
698  FXbool grabbedKeyboard() const;
699 
701  void grabKeyboard();
702 
704  void ungrabKeyboard();
705 
707  FXbool shown() const;
708 
710  virtual void show();
711 
713  virtual void hide();
714 
716  virtual FXbool isComposite() const;
717 
719  FXbool underCursor() const;
720 
722  FXbool hasSelection() const;
723 
725  FXbool acquireSelection(const FXDragType *types,FXuint numtypes);
726 
728  FXbool releaseSelection();
729 
731  FXbool hasClipboard() const;
732 
734  FXbool acquireClipboard(const FXDragType *types,FXuint numtypes);
735 
737  FXbool releaseClipboard();
738 
740  FXbool isDropEnabled() const;
741 
743  virtual void dropEnable();
744 
746  virtual void dropDisable();
747 
749  FXbool isDragging() const;
750 
752  FXbool beginDrag(const FXDragType *types,FXuint numtypes);
753 
758  FXbool handleDrag(FXint x,FXint y,FXDragAction action=DRAG_COPY);
759 
764  FXDragAction endDrag(FXbool drop=true);
765 
767  FXbool isDropTarget() const;
768 
773  void setDragRectangle(FXint x,FXint y,FXint w,FXint h,FXbool wantupdates=true) const;
774 
779  void clearDragRectangle() const;
780 
782  void acceptDrop(FXDragAction action=DRAG_ACCEPT) const;
783 
785  FXDragAction didAccept() const;
786 
798  void dropFinished(FXDragAction action=DRAG_REJECT) const;
799 
801  FXbool inquireDNDTypes(FXDNDOrigin origin,FXDragType*& types,FXuint& numtypes) const;
802 
804  FXbool offeredDNDType(FXDNDOrigin origin,FXDragType type) const;
805 
807  FXDragAction inquireDNDAction() const;
808 
813  FXbool setDNDData(FXDNDOrigin origin,FXDragType type,FXuchar* data,FXuint size) const;
814 
818  FXbool setDNDData(FXDNDOrigin origin,FXDragType type,const FXString& string) const;
819 
824  FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXuchar*& data,FXuint& size) const;
825 
829  FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXString& string) const;
830 
832  virtual FXbool contains(FXint parentx,FXint parenty) const;
833 
835  void translateCoordinatesFrom(FXint& tox,FXint& toy,const FXWindow* fromwindow,FXint fromx,FXint fromy) const;
836 
838  void translateCoordinatesTo(FXint& tox,FXint& toy,const FXWindow* towindow,FXint fromx,FXint fromy) const;
839 
841  virtual void setBackColor(FXColor clr);
842 
844  FXColor getBackColor() const { return backColor; }
845 
847  virtual FXbool doesSaveUnder() const;
848 
857  virtual const FXchar* tr(const FXchar* text,const FXchar* hint=NULL,FXint count=-1) const FX_FORMAT(2) ;
858 
860  virtual void save(FXStream& store) const;
861 
863  virtual void load(FXStream& store);
864 
866  virtual ~FXWindow();
867  };
868 
869 }
870 
871 #endif

Copyright © 1997-2016 Jeroen van der Zijp