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

FXWindow.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * W i n d o w O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (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 GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXWindow.h,v 1.149 2006/01/22 17:58:12 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXWINDOW_H
25 #define FXWINDOW_H
26 
27 #ifndef FXDRAWABLE_H
28 #include "FXDrawable.h"
29 #endif
30 
31 
32 namespace FX {
33 
34 
35 /// Layout hints for child widgets
36 enum {
37  LAYOUT_NORMAL = 0, /// Default layout mode
38  LAYOUT_SIDE_TOP = 0, /// Pack on top side (default)
39  LAYOUT_SIDE_BOTTOM = 0x00000001, /// Pack on bottom side
40  LAYOUT_SIDE_LEFT = 0x00000002, /// Pack on left side
42  LAYOUT_FILL_COLUMN = 0x00000001, /// Matrix column is stretchable
43  LAYOUT_FILL_ROW = 0x00000002, /// Matrix row is stretchable
44  LAYOUT_LEFT = 0, /// Stick on left (default)
45  LAYOUT_RIGHT = 0x00000004, /// Stick on right
46  LAYOUT_CENTER_X = 0x00000008, /// Center horizontally
48  LAYOUT_TOP = 0, /// Stick on top (default)
49  LAYOUT_BOTTOM = 0x00000010, /// Stick on bottom
50  LAYOUT_CENTER_Y = 0x00000020, /// Center vertically
52  LAYOUT_DOCK_SAME = 0, /// Dock on same galley if it fits
53  LAYOUT_DOCK_NEXT = 0x00000040, /// Dock on next galley
54  LAYOUT_RESERVED_1 = 0x00000080,
55  LAYOUT_FIX_WIDTH = 0x00000100, /// Width fixed
56  LAYOUT_FIX_HEIGHT = 0x00000200, /// height fixed
57  LAYOUT_MIN_WIDTH = 0, /// Minimum width is the default
58  LAYOUT_MIN_HEIGHT = 0, /// Minimum height is the default
59  LAYOUT_FILL_X = 0x00000400, /// Stretch or shrink horizontally
60  LAYOUT_FILL_Y = 0x00000800, /// Stretch or shrink vertically
61  LAYOUT_FILL = LAYOUT_FILL_X|LAYOUT_FILL_Y, /// Stretch or shrink in both directions
63  };
64 
65 
66 /// Frame border appearance styles (for subclasses)
67 enum {
68  FRAME_NONE = 0, /// Default is no frame
69  FRAME_SUNKEN = 0x00001000, /// Sunken border
70  FRAME_RAISED = 0x00002000, /// Raised border
71  FRAME_THICK = 0x00004000, /// Thick border
72  FRAME_GROOVE = FRAME_THICK, /// A groove or etched-in border
73  FRAME_RIDGE = FRAME_THICK|FRAME_RAISED|FRAME_SUNKEN, /// A ridge or embossed border
74  FRAME_LINE = FRAME_RAISED|FRAME_SUNKEN, /// Simple line border
75  FRAME_NORMAL = FRAME_SUNKEN|FRAME_THICK /// Regular raised/thick border
76  };
77 
78 
79 /// Packing style (for packers)
80 enum {
81  PACK_NORMAL = 0, /// Default is each its own size
82  PACK_UNIFORM_HEIGHT = 0x00008000, /// Uniform height
83  PACK_UNIFORM_WIDTH = 0x00010000 /// Uniform width
84  };
85 
86 
87 class FXIcon;
88 class FXBitmap;
89 class FXCursor;
90 class FXRegion;
91 class FXComposite;
94 
95 
96 /// Base class for all windows
97 class FXAPI FXWindow : public FXDrawable {
99  friend class FXApp;
100 private:
101  FXWindow *parent; // Parent Window
102  FXWindow *owner; // Owner Window
103  FXWindow *first; // First Child
104  FXWindow *last; // Last Child
105  FXWindow *next; // Next Sibling
106  FXWindow *prev; // Previous Sibling
107  FXWindow *focus; // Focus Child
108  FXuint wk; // Window Key
109 protected:
110  FXComposeContext *composeContext; // Compose context
111  FXCursor *defaultCursor; // Normal Cursor
112  FXCursor *dragCursor; // Cursor during drag
113  FXAccelTable *accelTable; // Accelerator table
114  FXObject *target; // Target object
115  FXSelector message; // Message ID
116  FXint xpos; // Window X Position
117  FXint ypos; // Window Y Position
118  FXColor backColor; // Window background color
119  FXString tag; // Help tag
120  FXuint flags; // Window state flags
121  FXuint options; // Window options
122 public:
123  static FXDragType octetType; // Raw octet stream
124  static FXDragType deleteType; // Delete request
125  static FXDragType textType; // Ascii text request
126  static FXDragType utf8Type; // UTF-8 text request
127  static FXDragType utf16Type; // UTF-16 text request
128  static FXDragType colorType; // Color
129  static FXDragType urilistType; // URI List
130  static const FXDragType stringType; // Clipboard text type (pre-registered)
131  static const FXDragType imageType; // Clipboard image type (pre-registered)
132 protected:
133  FXWindow();
134  FXWindow(FXApp* a,FXVisual *vis);
135  FXWindow(FXApp* a,FXWindow* own,FXuint opts,FXint x,FXint y,FXint w,FXint h);
136  static FXWindow* findDefault(FXWindow* window);
137  static FXWindow* findInitial(FXWindow* window);
138  virtual bool doesOverrideRedirect() const;
139 protected:
140 #ifdef WIN32
141  virtual FXID GetDC() const;
142  virtual int ReleaseDC(FXID) const;
143  virtual const char* GetClass() const;
144 #else
145  void addColormapWindows();
146  void remColormapWindows();
147 #endif
148 private:
149  FXWindow(const FXWindow&);
150  FXWindow& operator=(const FXWindow&);
151 protected:
152 
153  // Window state flags
154  enum {
155  FLAG_SHOWN = 0x00000001, // Is shown
156  FLAG_ENABLED = 0x00000002, // Able to receive input
157  FLAG_UPDATE = 0x00000004, // Is subject to GUI update
158  FLAG_DROPTARGET = 0x00000008, // Drop target
159  FLAG_FOCUSED = 0x00000010, // Has focus
160  FLAG_DIRTY = 0x00000020, // Needs layout
161  FLAG_RECALC = 0x00000040, // Needs recalculation
162  FLAG_TIP = 0x00000080, // Show tip
163  FLAG_HELP = 0x00000100, // Show help
164  FLAG_DEFAULT = 0x00000200, // Default widget
165  FLAG_INITIAL = 0x00000400, // Initial widget
166  FLAG_SHELL = 0x00000800, // Shell window
167  FLAG_ACTIVE = 0x00001000, // Window is active
168  FLAG_PRESSED = 0x00002000, // Button has been pressed
169  FLAG_KEY = 0x00004000, // Keyboard key pressed
170  FLAG_CARET = 0x00008000, // Caret is on
171  FLAG_CHANGED = 0x00010000, // Window data changed
172  FLAG_LASSO = 0x00020000, // Lasso mode
173  FLAG_TRYDRAG = 0x00040000, // Tentative drag mode
174  FLAG_DODRAG = 0x00080000, // Doing drag mode
175  FLAG_SCROLLINSIDE = 0x00100000, // Scroll only when inside
176  FLAG_SCROLLING = 0x00200000, // Right mouse scrolling
177  FLAG_OWNED = 0x00400000
178  };
179 
180 public:
181 
182  // Message handlers
183  long onPaint(FXObject*,FXSelector,void*);
184  long onMap(FXObject*,FXSelector,void*);
185  long onUnmap(FXObject*,FXSelector,void*);
186  long onConfigure(FXObject*,FXSelector,void*);
187  long onUpdate(FXObject*,FXSelector,void*);
188  long onMotion(FXObject*,FXSelector,void*);
189  long onMouseWheel(FXObject*,FXSelector,void*);
190  long onEnter(FXObject*,FXSelector,void*);
191  long onLeave(FXObject*,FXSelector,void*);
192  long onLeftBtnPress(FXObject*,FXSelector,void*);
193  long onLeftBtnRelease(FXObject*,FXSelector,void*);
194  long onMiddleBtnPress(FXObject*,FXSelector,void*);
195  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
196  long onRightBtnPress(FXObject*,FXSelector,void*);
197  long onRightBtnRelease(FXObject*,FXSelector,void*);
198  long onBeginDrag(FXObject*,FXSelector,void*);
199  long onEndDrag(FXObject*,FXSelector,void*);
200  long onDragged(FXObject*,FXSelector,void*);
201  long onKeyPress(FXObject*,FXSelector,void*);
202  long onKeyRelease(FXObject*,FXSelector,void*);
203  long onUngrabbed(FXObject*,FXSelector,void*);
204  long onDestroy(FXObject*,FXSelector,void*);
205  long onFocusSelf(FXObject*,FXSelector,void*);
206  long onFocusIn(FXObject*,FXSelector,void*);
207  long onFocusOut(FXObject*,FXSelector,void*);
208  long onSelectionLost(FXObject*,FXSelector,void*);
209  long onSelectionGained(FXObject*,FXSelector,void*);
210  long onSelectionRequest(FXObject*,FXSelector,void*);
211  long onClipboardLost(FXObject*,FXSelector,void*);
212  long onClipboardGained(FXObject*,FXSelector,void*);
213  long onClipboardRequest(FXObject*,FXSelector,void*);
214  long onDNDEnter(FXObject*,FXSelector,void*);
215  long onDNDLeave(FXObject*,FXSelector,void*);
216  long onDNDMotion(FXObject*,FXSelector,void*);
217  long onDNDDrop(FXObject*,FXSelector,void*);
218  long onDNDRequest(FXObject*,FXSelector,void*);
219  long onQueryHelp(FXObject*,FXSelector,void*);
220  long onQueryTip(FXObject*,FXSelector,void*);
221  long onCmdShow(FXObject*,FXSelector,void*);
222  long onCmdHide(FXObject*,FXSelector,void*);
223  long onUpdToggleShown(FXObject*,FXSelector,void*);
224  long onCmdToggleShown(FXObject*,FXSelector,void*);
225  long onCmdRaise(FXObject*,FXSelector,void*);
226  long onCmdLower(FXObject*,FXSelector,void*);
227  long onCmdEnable(FXObject*,FXSelector,void*);
228  long onCmdDisable(FXObject*,FXSelector,void*);
229  long onUpdToggleEnabled(FXObject*,FXSelector,void*);
230  long onCmdToggleEnabled(FXObject*,FXSelector,void*);
231  long onCmdUpdate(FXObject*,FXSelector,void*);
232  long onUpdYes(FXObject*,FXSelector,void*);
233  long onCmdDelete(FXObject*,FXSelector,void*);
235 public:
237  // Message ID's common to most Windows
238  enum {
239  ID_NONE,
240  ID_HIDE, // ID_HIDE+FALSE
241  ID_SHOW, // ID_HIDE+TRUE
242  ID_TOGGLESHOWN,
243  ID_LOWER,
244  ID_RAISE,
245  ID_DELETE,
246  ID_DISABLE, // ID_DISABLE+FALSE
247  ID_ENABLE, // ID_DISABLE+TRUE
248  ID_TOGGLEENABLED,
249  ID_UNCHECK, // ID_UNCHECK+FALSE
250  ID_CHECK, // ID_UNCHECK+TRUE
251  ID_UNKNOWN, // ID_UNCHECK+MAYBE
252  ID_UPDATE,
253  ID_AUTOSCROLL,
254  ID_TIPTIMER,
255  ID_HSCROLLED,
256  ID_VSCROLLED,
257  ID_SETVALUE,
258  ID_SETINTVALUE,
259  ID_SETREALVALUE,
260  ID_SETSTRINGVALUE,
261  ID_SETICONVALUE,
262  ID_SETINTRANGE,
263  ID_SETREALRANGE,
264  ID_GETINTVALUE,
265  ID_GETREALVALUE,
266  ID_GETSTRINGVALUE,
267  ID_GETICONVALUE,
268  ID_GETINTRANGE,
269  ID_GETREALRANGE,
270  ID_SETHELPSTRING,
271  ID_GETHELPSTRING,
272  ID_SETTIPSTRING,
273  ID_GETTIPSTRING,
274  ID_QUERY_MENU,
275  ID_HOTKEY,
276  ID_ACCEL,
277  ID_UNPOST,
278  ID_POST,
279  ID_MDI_TILEHORIZONTAL,
280  ID_MDI_TILEVERTICAL,
281  ID_MDI_CASCADE,
282  ID_MDI_MAXIMIZE,
283  ID_MDI_MINIMIZE,
284  ID_MDI_RESTORE,
285  ID_MDI_CLOSE,
286  ID_MDI_WINDOW,
287  ID_MDI_MENUWINDOW,
288  ID_MDI_MENUMINIMIZE,
289  ID_MDI_MENURESTORE,
290  ID_MDI_MENUCLOSE,
291  ID_MDI_NEXT,
292  ID_MDI_PREV,
293  ID_LAST
294  };
295 
296 public:
298  // Common DND type names
299  static const FXchar octetTypeName[];
300  static const FXchar deleteTypeName[];
301  static const FXchar textTypeName[];
302  static const FXchar colorTypeName[];
303  static const FXchar urilistTypeName[];
304  static const FXchar utf8TypeName[];
305  static const FXchar utf16TypeName[];
307 public:
308 
309  /// Constructor
310  FXWindow(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
311 
312  /// Return a pointer to the parent window
313  FXWindow* getParent() const { return parent; }
314 
315  /// Return a pointer to the owner window
316  FXWindow* getOwner() const { return owner; }
317 
318  /// Return a pointer to the shell window
319  FXWindow* getShell() const;
320 
321  /// Return a pointer to the root window
322  FXWindow* getRoot() const;
323 
324  /// Return a pointer to the next (sibling) window, if any
325  FXWindow* getNext() const { return next; }
326 
327  /// Return a pointer to the previous (sibling) window , if any
328  FXWindow* getPrev() const { return prev; }
329 
330  /// Return a pointer to this window's first child window , if any
331  FXWindow* getFirst() const { return first; }
332 
333  /// Return a pointer to this window's last child window, if any
334  FXWindow* getLast() const { return last; }
335 
336  /// Return a pointer to the currently focused child window
337  FXWindow* getFocus() const { return focus; }
338 
339  /// Change window key
340  void setKey(FXuint k){ wk=k; }
341 
342  /// Return window key
343  FXuint getKey() const { return wk; }
344 
345  /// Set the message target object for this window
346  void setTarget(FXObject *t){ target=t; }
347 
348  /// Get the message target object for this window, if any
349  FXObject* getTarget() const { return target; }
351  /// Set the message identifier for this window
352  void setSelector(FXSelector sel){ message=sel; }
354  /// Get the message identifier for this window
355  FXSelector getSelector() const { return message; }
356 
357  /// Get this window's x-coordinate, in the parent's coordinate system
358  FXint getX() const { return xpos; }
359 
360  /// Get this window's y-coordinate, in the parent's coordinate system
361  FXint getY() const { return ypos; }
363  /// Return the default width of this window
364  virtual FXint getDefaultWidth();
366  /// Return the default height of this window
367  virtual FXint getDefaultHeight();
368 
369  /// Return width for given height
370  virtual FXint getWidthForHeight(FXint givenheight);
371 
372  /// Return height for given width
373  virtual FXint getHeightForWidth(FXint givenwidth);
374 
375  /// Set this window's x-coordinate, in the parent's coordinate system
376  void setX(FXint x);
377 
378  /// Set this window's y-coordinate, in the parent's coordinate system
379  void setY(FXint y);
380 
381  /**
382  * Set the window width; and flag the widget as being in need of
383  * layout by its parent. This does not immediately update the server-
384  * side representation of the widget.
385  */
386  void setWidth(FXint w);
387 
388  /**
389  * Set the window height; and flag the widget as being in need of
390  * layout by its parent. This does not immediately update the server-
391  * side representation of the widget.
392  */
393  void setHeight(FXint h);
394 
395  /// Set layout hints for this window
396  void setLayoutHints(FXuint lout);
397 
398  /// Get layout hints for this window
399  FXuint getLayoutHints() const;
400 
401  /// Return a pointer to the accelerator table
402  FXAccelTable* getAccelTable() const { return accelTable; }
403 
404  /// Set the accelerator table
405  void setAccelTable(FXAccelTable* acceltable){ accelTable=acceltable; }
406 
407  /// Add a hot key
408  void addHotKey(FXHotKey code);
409 
410  /// Remove a hot key
411  void remHotKey(FXHotKey code);
412 
413  /// Change help tag for this widget
414  void setHelpTag(const FXString& text){ tag=text; }
415 
416  /// Get the help tag for this widget
417  const FXString& getHelpTag() const { return tag; }
418 
419  /// Return true if window is a shell window
420  bool isShell() const;
421 
422  /// Return true if specified window is owned by this window
423  bool isOwnerOf(const FXWindow* window) const;
424 
425  /// Return true if specified window is ancestor of this window
426  bool isChildOf(const FXWindow* window) const;
427 
428  /// Return true if this window contains child in its subtree
429  bool containsChild(const FXWindow* child) const;
430 
431  /// Return the child window at specified coordinates
432  FXWindow* getChildAt(FXint x,FXint y) const;
433 
434  /// Return the number of child windows for this window
435  FXint numChildren() const;
436 
437  /**
438  * Return the index (starting from zero) of the specified child window,
439  * or -1 if the window is not a child or NULL
440  */
441  FXint indexOfChild(const FXWindow *window) const;
442 
443  /**
444  * Return the child window at specified index,
445  * or NULL if the index is negative or out of range
446  */
447  FXWindow* childAtIndex(FXint index) const;
448 
449  /// Return the common ancestor of window a and window b
450  static FXWindow* commonAncestor(FXWindow* a,FXWindow* b);
451 
452  /// Return TRUE if sibling a <= sibling b in list
453  static bool before(const FXWindow *a,const FXWindow* b);
454 
455  /// Return TRUE if sibling a >= sibling b in list
456  static bool after(const FXWindow *a,const FXWindow* b);
457 
458  /// Return compose context
459  FXComposeContext* getComposeContext() const { return composeContext; }
460 
461  /// Create compose context
462  void createComposeContext();
463 
464  /// Destroy compose context
465  void destroyComposeContext();
466 
467  /// Set the default cursor for this window
468  void setDefaultCursor(FXCursor* cur);
469 
470  /// Return the default cursor for this window
471  FXCursor* getDefaultCursor() const { return defaultCursor; }
472 
473  /// Set the drag cursor for this window
474  void setDragCursor(FXCursor* cur);
475 
476  /// Return the drag cursor for this window
477  FXCursor* getDragCursor() const { return dragCursor; }
478 
479  /// Return the cursor position and mouse button-state
480  FXint getCursorPosition(FXint& x,FXint& y,FXuint& buttons) const;
481 
482  /// Warp the cursor to the new position
483  FXint setCursorPosition(FXint x,FXint y);
484 
485  /// Return true if this window is able to receive mouse and keyboard events
486  bool isEnabled() const;
487 
488  /// Return true if the window is active
489  bool isActive() const;
490 
491  /// Return true if this window is a control capable of receiving the focus
492  virtual bool canFocus() const;
493 
494  /// Return true if this window has the focus
495  bool hasFocus() const;
496 
497  /// Return true if this window is in focus chain
498  bool inFocusChain() const;
499 
500  /// Move the focus to this window
501  virtual void setFocus();
502 
503  /// Remove the focus from this window
504  virtual void killFocus();
505 
506  /// Notification that focus moved to new child
507  virtual void changeFocus(FXWindow *child);
508 
509  /**
510  * This changes the default window which responds to the Return
511  * key in a dialog. If enable is TRUE, this window becomes the default
512  * window; when enable is FALSE, this window will be no longer the
513  * default window. Finally, when enable is MAYBE, the default window
514  * will revert to the initial default window.
515  */
516  virtual void setDefault(FXbool enable=TRUE);
517 
518  /// Return true if this is the default window
519  bool isDefault() const;
520 
521  /// Make this window the initial default window
522  void setInitial(bool enable=true);
523 
524  /// Return true if this is the initial default window
525  bool isInitial() const;
526 
527  /// Enable the window to receive mouse and keyboard events
528  virtual void enable();
529 
530  /// Disable the window from receiving mouse and keyboard events
531  virtual void disable();
532 
533  /// Create all of the server-side resources for this window
534  virtual void create();
535 
536  /// Attach foreign window handle to this window
537  virtual void attach(FXID w);
538 
539  /// Detach the server-side resources for this window
540  virtual void detach();
541 
542  /// Destroy the server-side resources for this window
543  virtual void destroy();
544 
545  /// Set window shape by means of region
546  virtual void setShape(const FXRegion& region);
547 
548  /// Set window shape by means of bitmap
549  virtual void setShape(FXBitmap* bitmap);
550 
551  /// Set window shape by means of icon
552  virtual void setShape(FXIcon* icon);
553 
554  /// Clear window shape
555  virtual void clearShape();
556 
557  /// Raise this window to the top of the stacking order
558  virtual void raise();
559 
560  /// Lower this window to the bottom of the stacking order
561  virtual void lower();
562 
563  /**
564  * Move the window immediately, in the parent's coordinate system.
565  * Update the server representation as well if the window is realized.
566  * Perform layout of the children when necessary.
567  */
568  virtual void move(FXint x,FXint y);
569 
570  /**
571  * Resize the window to the specified width and height immediately,
572  * updating the server representation as well, if the window was realized.
573  * Perform layout of the children when necessary.
574  */
575  virtual void resize(FXint w,FXint h);
576 
577  /**
578  * Move and resize the window immediately, in the parent's coordinate system.
579  * Update the server representation as well if the window is realized.
580  * Perform layout of the children when necessary.
581  */
582  virtual void position(FXint x,FXint y,FXint w,FXint h);
583 
584  /// Mark this window's layout as dirty for later layout
585  virtual void recalc();
586 
587  /// Perform layout immediately
588  virtual void layout();
589 
590  /// Generate a SEL_UPDATE message for the window and its children
591  void forceRefresh();
592 
593  /// Reparent this window under new father before other
594  virtual void reparent(FXWindow* father,FXWindow *other=NULL);
595 
596  /// Scroll rectangle x,y,w,h by a shift of dx,dy
597  void scroll(FXint x,FXint y,FXint w,FXint h,FXint dx,FXint dy) const;
598 
599  /// Mark the specified rectangle to be repainted later
600  void update(FXint x,FXint y,FXint w,FXint h) const;
601 
602  /// Mark the entire window to be repainted later
603  void update() const;
604 
605  /// Process any outstanding repaint messages immediately, for the given rectangle
606  void repaint(FXint x,FXint y,FXint w,FXint h) const;
607 
608  /// Process any outstanding repaint messages immediately
609  void repaint() const;
610 
611  /**
612  * Grab the mouse to this window; future mouse events will be
613  * reported to this window even while the cursor goes outside of this window
614  */
615  void grab();
616 
617  /// Release the mouse grab
618  void ungrab();
619 
620  /// Return true if the window has been grabbed
621  bool grabbed() const;
622 
623  /// Grab keyboard device
624  void grabKeyboard();
625 
626  /// Ungrab keyboard device
627  void ungrabKeyboard();
628 
629  /// Return true if active grab is in effect
630  bool grabbedKeyboard() const;
631 
632  /// Show this window
633  virtual void show();
634 
635  /// Hide this window
636  virtual void hide();
637 
638  /// Return true if the window is shown
639  bool shown() const;
640 
641  /// Return true if the window is composite
642  virtual bool isComposite() const;
643 
644  /// Return true if the window is under the cursor
645  bool underCursor() const;
646 
647  /// Return true if this window owns the primary selection
648  bool hasSelection() const;
649 
650  /// Try to acquire the primary selection, given a list of drag types
651  bool acquireSelection(const FXDragType *types,FXuint numtypes);
652 
653  /// Release the primary selection
654  bool releaseSelection();
655 
656  /// Return true if this window owns the clipboard
657  bool hasClipboard() const;
658 
659  /// Try to acquire the clipboard, given a list of drag types
660  bool acquireClipboard(const FXDragType *types,FXuint numtypes);
661 
662  /// Release the clipboard
663  bool releaseClipboard();
664 
665  /// Enable this window to receive drops
666  virtual void dropEnable();
667 
668  /// Disable this window from receiving drops
669  virtual void dropDisable();
670 
671  /// Return true if this window is able to receive drops
672  bool isDropEnabled() const;
673 
674  /// Return true if a drag operaion has been initiated from this window
675  bool isDragging() const;
676 
677  /// Initiate a drag operation with a list of previously registered drag types
678  bool beginDrag(const FXDragType *types,FXuint numtypes);
679 
680  /**
681  * When dragging, inform the drop-target of the new position and
682  * the drag action
683  */
684  bool handleDrag(FXint x,FXint y,FXDragAction action=DRAG_COPY);
685 
686  /**
687  * Terminate the drag operation with or without actually dropping the data
688  * Returns the action performed by the target
689  */
690  FXDragAction endDrag(bool drop=true);
691 
692  /// Return true if this window is the target of a drop
693  bool isDropTarget() const;
694 
695  /**
696  * When being dragged over, indicate that no further SEL_DND_MOTION messages
697  * are required while the cursor is inside the given rectangle
698  */
699  void setDragRectangle(FXint x,FXint y,FXint w,FXint h,bool wantupdates=true) const;
700 
701  /**
702  * When being dragged over, indicate we want to receive SEL_DND_MOTION messages
703  * every time the cursor moves
704  */
705  void clearDragRectangle() const;
706 
707  /// When being dragged over, indicate acceptance or rejection of the dragged data
708  void acceptDrop(FXDragAction action=DRAG_ACCEPT) const;
709 
710  /// The target accepted our drop
711  FXDragAction didAccept() const;
712 
713  /**
714  * Sent by the drop target in response to SEL_DND_DROP. The drag action
715  * should be the same as the action the drop target reported to the drag
716  * source in reponse to the SEL_DND_MOTION message.
717  * This function notifies the drag source that its part of the drop transaction
718  * is finished, and that it is free to release any resources involved in the
719  * drag operation.
720  * Calling dropFinished() is advisable in cases where the drop target needs
721  * to perform complex processing on the data received from the drag source,
722  * prior to returning from the SEL_DND_DROP message handler.
723  */
724  void dropFinished(FXDragAction action=DRAG_REJECT) const;
725 
726  /// When being dragged over, inquire the drag types which are being offered
727  bool inquireDNDTypes(FXDNDOrigin origin,FXDragType*& types,FXuint& numtypes) const;
728 
729  /// When being dragged over, return true if we are offered the given drag type
730  bool offeredDNDType(FXDNDOrigin origin,FXDragType type) const;
731 
732  /// When being dragged over, return the drag action
733  FXDragAction inquireDNDAction() const;
734 
735  /**
736  * Set DND data; the array must be allocated with FXMALLOC and ownership is
737  * transferred to the system
738  */
739  bool setDNDData(FXDNDOrigin origin,FXDragType type,FXuchar* data,FXuint size) const;
740 
741  /**
742  * Set DND data from string value.
743  */
744  bool setDNDData(FXDNDOrigin origin,FXDragType type,const FXString& string) const;
745 
746  /**
747  * Get DND data; the caller becomes the owner of the array and must free it
748  * with FXFREE
749  */
750  bool getDNDData(FXDNDOrigin origin,FXDragType type,FXuchar*& data,FXuint& size) const;
751 
752  /**
753  * Get DND data into string value.
754  */
755  bool getDNDData(FXDNDOrigin origin,FXDragType type,FXString& string) const;
756 
757  /// Return true if window logically contains the given point
758  virtual bool contains(FXint parentx,FXint parenty) const;
759 
760  /// Translate coordinates from fromwindow's coordinate space to this window's coordinate space
761  void translateCoordinatesFrom(FXint& tox,FXint& toy,const FXWindow* fromwindow,FXint fromx,FXint fromy) const;
762 
763  /// Translate coordinates from this window's coordinate space to towindow's coordinate space
764  void translateCoordinatesTo(FXint& tox,FXint& toy,const FXWindow* towindow,FXint fromx,FXint fromy) const;
765 
766  /// Set window background color
767  virtual void setBackColor(FXColor clr);
768 
769  /// Get background color
770  FXColor getBackColor() const { return backColor; }
771 
772  virtual bool doesSaveUnder() const;
773 
774  /**
775  * Translate message for localization; using the current FXTranslator,
776  * an attempt is made to translate the given message into the current
777  * language. An optional hint may be passed to break any ties in case
778  * more than one tranlation is possible for the given message text.
779  * In addition, the name of the widget is passed as context name so
780  * that controls in a single dialog may be grouped together.
781  */
782  virtual const FXchar* tr(const FXchar* message,const FXchar* hint=NULL) const;
783 
784  /// Save window to stream
785  virtual void save(FXStream& store) const;
786 
787  /// Restore window from stream
788  virtual void load(FXStream& store);
789 
790  /// Destroy window
791  virtual ~FXWindow();
792  };
793 
794 }
795 
796 #endif
Pack on top side (default)
Definition: FXWindow.h:41
Accept any drop action.
Definition: fxdefs.h:332
FXDragAction
Drag and drop actions.
Definition: fxdefs.h:330
unsigned long FXID
Definition: fxdefs.h:442
Default layout mode.
Definition: FXWindow.h:40
Width fixed.
Definition: FXWindow.h:58
char FXchar
Definition: fxdefs.h:387
Default is no frame.
Definition: FXWindow.h:75
#define TRUE
Definition: fxdefs.h:32
X fixed.
Definition: FXWindow.h:50
Base class for all windows.
Definition: FXWindow.h:115
Uniform width.
Definition: FXWindow.h:94
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXHotKey
Definition: fxdefs.h:457
FXuint FXSelector
Association key.
Definition: FXObject.h:53
The accelerator table sends a message to a specific target object when the indicated key and modifier...
Definition: FXAccelTable.h:39
#define FXAPI
Definition: fxdefs.h:122
Copy.
Definition: fxdefs.h:333
FXuchar FXbool
Definition: fxdefs.h:393
Stretch or shrink horizontally.
Definition: FXWindow.h:62
Stick on bottom.
Definition: FXWindow.h:52
Application Object.
Definition: FXApp.h:158
Sunken border.
Definition: FXWindow.h:76
Reject all drop actions.
Definition: fxdefs.h:331
Default is each its own size.
Definition: FXWindow.h:92
Base composite.
Definition: FXComposite.h:35
FXDNDOrigin
Origin of data.
Definition: fxdefs.h:345
#define NULL
Definition: fxdefs.h:41
Matrix row is stretchable.
Definition: FXWindow.h:46
FXuint FXColor
Definition: fxdefs.h:454
Stick on top (default)
Definition: FXWindow.h:51
Minimum height is the default.
Definition: FXWindow.h:61
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
Pack on left side.
Definition: FXWindow.h:43
Center horizontally.
Definition: FXWindow.h:49
Matrix column is stretchable.
Definition: FXWindow.h:45
Uniform height.
Definition: FXWindow.h:93
Dock on same galley if it fits.
Definition: FXWindow.h:55
Stick on right.
Definition: FXWindow.h:48
Center vertically.
Definition: FXWindow.h:53
int FXint
Definition: fxdefs.h:397
Y fixed.
Definition: FXWindow.h:54
Compose Context manages the state of an input method if input method support is enabled.
Definition: FXComposeContext.h:42
Cursor class.
Definition: FXCursor.h:68
Raised border.
Definition: FXWindow.h:77
Stretch or shrink in both directions.
Definition: FXWindow.h:64
Visual describes pixel format of a drawable.
Definition: FXVisual.h:84
Stick on left (default)
Definition: FXWindow.h:47
Definition: FXWindow.h:57
Pack on bottom side.
Definition: FXWindow.h:42
height fixed
Definition: FXWindow.h:59
Minimum width is the default.
Definition: FXWindow.h:60
Regular raised/thick border.
Definition: FXWindow.h:82
Pack on right side.
Definition: FXWindow.h:44
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
unsigned char FXuchar
Definition: fxdefs.h:392
Thick border.
Definition: FXWindow.h:78
Explicit placement.
Definition: FXWindow.h:65
FXID FXDragType
Definition: fxdefs.h:461
A ridge or embossed border.
Definition: FXWindow.h:80
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
Simple line border.
Definition: FXWindow.h:81
Stretch or shrink vertically.
Definition: FXWindow.h:63
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
A groove or etched-in border.
Definition: FXWindow.h:79
Drawable is an abstract base class for any surface that can be drawn upon, such as a FXWindow...
Definition: FXDrawable.h:41
Dock on next galley.
Definition: FXWindow.h:56

Copyright © 1997-2005 Jeroen van der Zijp