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

FXWindow.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                            W i n d o w   O b j e c t                          *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2010 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
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 // Forward declarations
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 /// Layout hints for child widgets
00044 enum {
00045   LAYOUT_NORMAL      = 0,                                   /// Default layout mode
00046   LAYOUT_SIDE_TOP    = 0,                                   /// Pack on top side (default)
00047   LAYOUT_SIDE_BOTTOM = 0x00000001,                          /// Pack on bottom side
00048   LAYOUT_SIDE_LEFT   = 0x00000002,                          /// Pack on left side
00049   LAYOUT_SIDE_RIGHT  = LAYOUT_SIDE_LEFT|LAYOUT_SIDE_BOTTOM, /// Pack on right side
00050   LAYOUT_FILL_COLUMN = 0x00000001,                          /// Matrix column is stretchable
00051   LAYOUT_FILL_ROW    = 0x00000002,                          /// Matrix row is stretchable
00052   LAYOUT_LEFT        = 0,                                   /// Stick on left (default)
00053   LAYOUT_RIGHT       = 0x00000004,                          /// Stick on right
00054   LAYOUT_CENTER_X    = 0x00000008,                          /// Center horizontally
00055   LAYOUT_FIX_X       = LAYOUT_RIGHT|LAYOUT_CENTER_X,        /// X fixed
00056   LAYOUT_TOP         = 0,                                   /// Stick on top (default)
00057   LAYOUT_BOTTOM      = 0x00000010,                          /// Stick on bottom
00058   LAYOUT_CENTER_Y    = 0x00000020,                          /// Center vertically
00059   LAYOUT_FIX_Y       = LAYOUT_BOTTOM|LAYOUT_CENTER_Y,       /// Y fixed
00060   LAYOUT_DOCK_SAME   = 0,                                   /// Dock on same galley if it fits
00061   LAYOUT_DOCK_NEXT   = 0x00000040,                          /// Dock on next galley
00062   LAYOUT_RESERVED_1  = 0x00000080,
00063   LAYOUT_FIX_WIDTH   = 0x00000100,                          /// Width fixed
00064   LAYOUT_FIX_HEIGHT  = 0x00000200,                          /// height fixed
00065   LAYOUT_MIN_WIDTH   = 0,                                   /// Minimum width is the default
00066   LAYOUT_MIN_HEIGHT  = 0,                                   /// Minimum height is the default
00067   LAYOUT_FILL_X      = 0x00000400,                          /// Stretch or shrink horizontally
00068   LAYOUT_FILL_Y      = 0x00000800,                          /// Stretch or shrink vertically
00069   LAYOUT_FILL        = LAYOUT_FILL_X|LAYOUT_FILL_Y,         /// Stretch or shrink in both directions
00070   LAYOUT_EXPLICIT    = LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT   /// Explicit placement
00071   };
00072 
00073 
00074 /// Frame border appearance styles (for subclasses)
00075 enum {
00076   FRAME_NONE   = 0,                                     /// Default is no frame
00077   FRAME_SUNKEN = 0x00001000,                            /// Sunken border
00078   FRAME_RAISED = 0x00002000,                            /// Raised border
00079   FRAME_THICK  = 0x00004000,                            /// Thick border
00080   FRAME_GROOVE = FRAME_THICK,                           /// A groove or etched-in border
00081   FRAME_RIDGE  = FRAME_THICK|FRAME_RAISED|FRAME_SUNKEN, /// A ridge or embossed border
00082   FRAME_LINE   = FRAME_RAISED|FRAME_SUNKEN,             /// Simple line border
00083   FRAME_NORMAL = FRAME_SUNKEN|FRAME_THICK               /// Regular raised/thick border
00084   };
00085 
00086 
00087 /// Packing style (for packers)
00088 enum {
00089   PACK_NORMAL         = 0,              /// Default is each its own size
00090   PACK_UNIFORM_HEIGHT = 0x00008000,     /// Uniform height
00091   PACK_UNIFORM_WIDTH  = 0x00010000      /// Uniform width
00092   };
00093 
00094 
00095 /// Data exchange modes
00096 enum FXDNDOrigin {
00097   FROM_SELECTION  = 0,              /// Primary selection
00098   FROM_CLIPBOARD  = 1,              /// Clipboard
00099   FROM_DRAGNDROP  = 2               /// Drag and drop source
00100   };
00101 
00102 
00103 /// Drag and drop actions
00104 enum FXDragAction {
00105   DRAG_REJECT  = 0,             /// Reject all drop actions
00106   DRAG_ASK     = 1,             /// Ask
00107   DRAG_COPY    = 2,             /// Copy
00108   DRAG_MOVE    = 3,             /// Move
00109   DRAG_LINK    = 4,             /// Link
00110   DRAG_PRIVATE = 5,             /// Private
00111   DRAG_ACCEPT  = 6              /// Accept any drop action
00112   };
00113 
00114 
00115 /**
00116 * Window is the base class for all widgets in FOX.
00117 * All widgets are organized in a tree structure, with a single root window
00118 * at the top.
00119 * Each window links to its parent window, next and previous siblings windows,
00120 * as well as its first and last child windows.  A window also has an owner window,
00121 * which is the window responsible for its creation and destruction.  In most cases,
00122 * the owner window will be the same as the parent window, except for top-level windows.
00123 * The focus window determines to which child keyboard messages are delegated if the
00124 * window is a composite window (i.e. if it has children).
00125 * Windows are geometrically arranged by their immediate parent window; the actual
00126 * method of placement is determined by the type of layout supported by the parent
00127 * window, as well as the window's layout hints.
00128 * The position of a window is determined relative to its immediate parent window;
00129 * A window can send a message to its target object when an event happens.
00130 */
00131 class FXAPI FXWindow : public FXDrawable {
00132   FXDECLARE(FXWindow)
00133   friend class FXApp;
00134 private:
00135   FXWindow         *parent;             // Parent Window
00136   FXWindow         *owner;              // Owner Window
00137   FXWindow         *first;              // First Child
00138   FXWindow         *last;               // Last Child
00139   FXWindow         *next;               // Next Sibling
00140   FXWindow         *prev;               // Previous Sibling
00141   FXWindow         *focus;              // Focus Child
00142   FXuint            wk;                 // Window Key
00143 protected:
00144   FXComposeContext *composeContext;     // Compose context
00145   FXCursor         *defaultCursor;      // Normal Cursor
00146   FXCursor         *dragCursor;         // Cursor during drag
00147   FXAccelTable     *accelTable;         // Accelerator table
00148   FXObject         *target;             // Target object
00149   FXSelector        message;            // Message ID
00150   FXint             xpos;               // Window X Position
00151   FXint             ypos;               // Window Y Position
00152   FXColor           backColor;          // Window background color
00153   FXString          tag;                // Help tag
00154   FXuint            flags;              // Window state flags
00155   FXuint            options;            // Window options
00156 public:
00157   static FXDragType       octetType;    // Raw octet stream
00158   static FXDragType       deleteType;   // Delete request
00159   static FXDragType       textType;     // Ascii text request
00160   static FXDragType       colorType;    // Color request
00161   static FXDragType       urilistType;  // URI list request
00162   static FXDragType       utf8Type;     // UTF-8 text request
00163   static FXDragType       utf16Type;    // UTF-16 text request
00164   static FXDragType       actionType;   // Clipboard action
00165   static const FXDragType stringType;   // Clipboard text type (pre-registered)
00166   static const FXDragType imageType;    // Clipboard image type (pre-registered)
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   // Window state flags
00187   enum {
00188     FLAG_SHOWN        = 0x00000001,     // Is shown
00189     FLAG_ENABLED      = 0x00000002,     // Able to receive input
00190     FLAG_UPDATE       = 0x00000004,     // Is subject to GUI update
00191     FLAG_DROPTARGET   = 0x00000008,     // Drop target
00192     FLAG_FOCUSED      = 0x00000010,     // Has focus
00193     FLAG_DIRTY        = 0x00000020,     // Needs layout
00194     FLAG_RECALC       = 0x00000040,     // Needs recalculation
00195     FLAG_TIP          = 0x00000080,     // Show tip
00196     FLAG_HELP         = 0x00000100,     // Show help
00197     FLAG_DEFAULT      = 0x00000200,     // Default widget
00198     FLAG_INITIAL      = 0x00000400,     // Initial widget
00199     FLAG_SHELL        = 0x00000800,     // Shell window
00200     FLAG_ACTIVE       = 0x00001000,     // Window is active
00201     FLAG_PRESSED      = 0x00002000,     // Button has been pressed
00202     FLAG_KEY          = 0x00004000,     // Keyboard key pressed
00203     FLAG_CARET        = 0x00008000,     // Caret is on
00204     FLAG_CHANGED      = 0x00010000,     // Window data changed
00205     FLAG_LASSO        = 0x00020000,     // Lasso mode
00206     FLAG_TRYDRAG      = 0x00040000,     // Tentative drag mode
00207     FLAG_DODRAG       = 0x00080000,     // Doing drag mode
00208     FLAG_SCROLLINSIDE = 0x00100000,     // Scroll only when inside
00209     FLAG_SCROLLING    = 0x00200000,     // Right mouse scrolling
00210     FLAG_OWNED        = 0x00400000,     // Owned window handle
00211     FLAG_CURSOR       = 0x00800000      // Showing cursor
00212     };
00213 
00214 public:
00215 
00216   /// Window classes
00217   enum WindowClass {
00218     ClassNormal,        /// Normal child window
00219     ClassGraphic,       /// Graphics child window
00220     ClassSpecial,       /// Special child window
00221     ClassRoot,          /// Root window
00222     ClassShell,         /// Shell window
00223     ClassPopup,         /// Popup window
00224     ClassToolTip,       /// Tooltip window
00225     ClassMain,          /// Main application window
00226     ClassDialog,        /// Dialog box window
00227     ClassToolBar,       /// Toolbar window
00228     ClassSplash,        /// Splash window
00229     ClassNotify,        /// Notify window
00230     ClassPanel,         /// Panel window
00231     ClassDesktop        /// Desktop backdrop window
00232     };
00233 
00234 public:
00235 
00236   // Message handlers
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   // Message ID's common to most Windows
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   // Common DND type names
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   /// Constructor
00367   FXWindow(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00368 
00369   /// Return a pointer to the parent window
00370   FXWindow* getParent() const { return parent; }
00371 
00372   /// Return a pointer to the owner window
00373   FXWindow* getOwner() const { return owner; }
00374 
00375   /// Return a pointer to the shell window
00376   FXWindow* getShell() const;
00377 
00378   /// Return a pointer to the root window
00379   FXWindow* getRoot() const;
00380 
00381   /// Return a pointer to the next (sibling) window, if any
00382   FXWindow* getNext() const { return next; }
00383 
00384   /// Return a pointer to the previous (sibling) window , if any
00385   FXWindow* getPrev() const { return prev; }
00386 
00387   /// Return a pointer to this window's first child window , if any
00388   FXWindow* getFirst() const { return first; }
00389 
00390   /// Return a pointer to this window's last child window, if any
00391   FXWindow* getLast() const { return last; }
00392 
00393   /// Return a pointer to the currently focused child window
00394   FXWindow* getFocus() const { return focus; }
00395 
00396   /// Get window class
00397   virtual WindowClass getWindowClass() const;
00398 
00399   /// Change window key
00400   void setKey(FXuint k){ wk=k; }
00401 
00402   /// Return window key
00403   FXuint getKey() const { return wk; }
00404 
00405   /// Return child window with given window key
00406   FXWindow* getChildWithKey(FXuint k) const;
00407 
00408   /// Set the message target object for this window
00409   void setTarget(FXObject *t){ target=t; }
00410 
00411   /// Get the message target object for this window, if any
00412   FXObject* getTarget() const { return target; }
00413 
00414   /// Set the message identifier for this window
00415   void setSelector(FXSelector sel){ message=sel; }
00416 
00417   /// Get the message identifier for this window
00418   FXSelector getSelector() const { return message; }
00419 
00420   /// Get this window's x-coordinate, in the parent's coordinate system
00421   FXint getX() const { return xpos; }
00422 
00423   /// Get this window's y-coordinate, in the parent's coordinate system
00424   FXint getY() const { return ypos; }
00425 
00426   /// Return the default width of this window
00427   virtual FXint getDefaultWidth();
00428 
00429   /// Return the default height of this window
00430   virtual FXint getDefaultHeight();
00431 
00432   /// Return width for given height
00433   virtual FXint getWidthForHeight(FXint givenheight);
00434 
00435   /// Return height for given width
00436   virtual FXint getHeightForWidth(FXint givenwidth);
00437 
00438   /// Set this window's x-coordinate, in the parent's coordinate system
00439   void setX(FXint x);
00440 
00441   /// Set this window's y-coordinate, in the parent's coordinate system
00442   void setY(FXint y);
00443 
00444   /**
00445   * Set the window width; and flag the widget as being in need of
00446   * layout by its parent.  This does not immediately update the server-
00447   * side representation of the widget.
00448   */
00449   void setWidth(FXint w);
00450 
00451   /**
00452   * Set the window height; and flag the widget as being in need of
00453   * layout by its parent.  This does not immediately update the server-
00454   * side representation of the widget.
00455   */
00456   void setHeight(FXint h);
00457 
00458   /// Set layout hints for this window
00459   void setLayoutHints(FXuint lout);
00460 
00461   /// Get layout hints for this window
00462   FXuint getLayoutHints() const;
00463 
00464   /// Return a pointer to the accelerator table
00465   FXAccelTable* getAccelTable() const { return accelTable; }
00466 
00467   /// Set the accelerator table
00468   void setAccelTable(FXAccelTable* acceltable){ accelTable=acceltable; }
00469 
00470   /// Add a hot key
00471   void addHotKey(FXHotKey code);
00472 
00473   /// Remove a hot key
00474   void remHotKey(FXHotKey code);
00475 
00476   /// Change help tag for this widget
00477   void setHelpTag(const FXString&  text){ tag=text; }
00478 
00479   /// Get the help tag for this widget
00480   const FXString& getHelpTag() const { return tag; }
00481 
00482   /// Return true if window is a shell window
00483   FXbool isShell() const;
00484 
00485   /// Return true if specified window is owned by this window
00486   FXbool isOwnerOf(const FXWindow* window) const;
00487 
00488   /// Return true if specified window is ancestor of this window
00489   FXbool isChildOf(const FXWindow* window) const;
00490 
00491   /// Return true if this window contains child in its subtree
00492   FXbool containsChild(const FXWindow* child) const;
00493 
00494   /// Return the child window at specified coordinates
00495   FXWindow* getChildAt(FXint x,FXint y) const;
00496 
00497   /// Return the number of child windows for this window
00498   FXint numChildren() const;
00499 
00500   /**
00501   * Return the index (starting from zero) of the specified child window,
00502   * or -1 if the window is not a child or NULL
00503   */
00504   FXint indexOfChild(const FXWindow *window) const;
00505 
00506   /**
00507   * Return the child window at specified index,
00508   * or NULL if the index is negative or out of range
00509   */
00510   FXWindow* childAtIndex(FXint index) const;
00511 
00512   /// Return the common ancestor of window a and window b
00513   static FXWindow* commonAncestor(FXWindow* a,FXWindow* b);
00514 
00515   /// Return true if sibling a <= sibling b in list
00516   static FXbool before(const FXWindow *a,const FXWindow* b);
00517 
00518   /// Return true if sibling a >= sibling b in list
00519   static FXbool after(const FXWindow *a,const FXWindow* b);
00520 
00521   /// Return compose context
00522   FXComposeContext* getComposeContext() const { return composeContext; }
00523 
00524   /// Create compose context
00525   void createComposeContext();
00526 
00527   /// Destroy compose context
00528   void destroyComposeContext();
00529 
00530   /// Is cursor shown
00531   FXbool cursorShown() const;
00532 
00533   /// Show or hide the cursor
00534   void showCursor(FXbool flag=true);
00535 
00536   /// Set the default cursor for this window
00537   void setDefaultCursor(FXCursor* cur);
00538 
00539   /// Return the default cursor for this window
00540   FXCursor* getDefaultCursor() const { return defaultCursor; }
00541 
00542   /// Set the drag cursor for this window
00543   void setDragCursor(FXCursor* cur);
00544 
00545   /// Return the drag cursor for this window
00546   FXCursor* getDragCursor() const { return dragCursor; }
00547 
00548   /// Return the cursor position and mouse button-state
00549   FXbool getCursorPosition(FXint& x,FXint& y,FXuint& buttons) const;
00550 
00551   /// Warp the cursor to the new position
00552   FXbool setCursorPosition(FXint x,FXint y);
00553 
00554   /// Return true if the window is active
00555   FXbool isActive() const;
00556 
00557   /// Return true if this window is a control capable of receiving the focus
00558   virtual FXbool canFocus() const;
00559 
00560   /// Return true if this window has the focus
00561   FXbool hasFocus() const;
00562 
00563   /// Return true if this window is in focus chain
00564   FXbool inFocusChain() const;
00565 
00566   /// Move the focus to this window
00567   virtual void setFocus();
00568 
00569   /// Remove the focus from this window
00570   virtual void killFocus();
00571 
00572   /// Notification that focus moved to new child
00573   virtual void changeFocus(FXWindow *child);
00574 
00575   /// Return true if this is the default window
00576   FXbool isDefault() const;
00577 
00578   /**
00579   * This changes the default window which responds to the Return
00580   * key in a dialog. If the flag is TRUE, this window becomes the default
00581   * window; when the flag is FALSE, this window will be no longer the
00582   * default window.  Finally, when the flag is MAYBE, the default window
00583   * will revert to the initial default window.
00584   */
00585   virtual void setDefault(FXuchar flag=TRUE);
00586 
00587   /// Find default window among this window's children
00588   FXWindow* findDefault() const;
00589 
00590   /// Return true if this is the initial default window
00591   FXbool isInitial() const;
00592 
00593   /// Make this window the initial default window
00594   void setInitial(FXbool flag=true);
00595 
00596   /// Find inital default window among this window's children
00597   FXWindow* findInitial() const;
00598 
00599   /// Return true if this window is able to receive mouse and keyboard events
00600   FXbool isEnabled() const;
00601 
00602   /// Enable the window to receive mouse and keyboard events
00603   virtual void enable();
00604 
00605   /// Disable the window from receiving mouse and keyboard events
00606   virtual void disable();
00607 
00608   /// Create all of the server-side resources for this window
00609   virtual void create();
00610 
00611   /// Attach foreign window handle to this window
00612   virtual void attach(FXID w);
00613 
00614   /// Detach the server-side resources for this window
00615   virtual void detach();
00616 
00617   /// Destroy the server-side resources for this window
00618   virtual void destroy();
00619 
00620   /// Set window shape by means of region
00621   virtual void setShape(const FXRegion& region);
00622 
00623   /// Set window shape by means of bitmap
00624   virtual void setShape(FXBitmap* bitmap);
00625 
00626   /// Set window shape by means of icon
00627   virtual void setShape(FXIcon* icon);
00628 
00629   /// Clear window shape
00630   virtual void clearShape();
00631 
00632   /// Raise this window to the top of the stacking order
00633   virtual void raise();
00634 
00635   /// Lower this window to the bottom of the stacking order
00636   virtual void lower();
00637 
00638   /**
00639   * Move the window immediately, in the parent's coordinate system.
00640   * Update the server representation as well if the window is realized.
00641   * Perform layout of the children when necessary.
00642   */
00643   virtual void move(FXint x,FXint y);
00644 
00645   /**
00646   * Resize the window to the specified width and height immediately,
00647   * updating the server representation as well, if the window was realized.
00648   * Perform layout of the children when necessary.
00649   */
00650   virtual void resize(FXint w,FXint h);
00651 
00652   /**
00653   * Move and resize the window immediately, in the parent's coordinate system.
00654   * Update the server representation as well if the window is realized.
00655   * Perform layout of the children when necessary.
00656   */
00657   virtual void position(FXint x,FXint y,FXint w,FXint h);
00658 
00659   /// Mark this window's layout as dirty for later layout
00660   virtual void recalc();
00661 
00662   /// Perform layout immediately
00663   virtual void layout();
00664 
00665   /// Generate a SEL_UPDATE message for the window and its children
00666   void forceRefresh();
00667 
00668   /// Reparent this window under new father before other
00669   virtual void reparent(FXWindow* father,FXWindow *other=NULL);
00670 
00671   /// Scroll rectangle x,y,w,h by a shift of dx,dy
00672   void scroll(FXint x,FXint y,FXint w,FXint h,FXint dx,FXint dy) const;
00673 
00674   /// Mark the specified rectangle to be repainted later
00675   void update(FXint x,FXint y,FXint w,FXint h) const;
00676 
00677   /// Mark the entire window to be repainted later
00678   void update() const;
00679 
00680   /// Process any outstanding repaint messages immediately, for the given rectangle
00681   void repaint(FXint x,FXint y,FXint w,FXint h) const;
00682 
00683   /// Process any outstanding repaint messages immediately
00684   void repaint() const;
00685 
00686   /// Return true if the window has been grabbed
00687   FXbool grabbed() const;
00688 
00689   /**
00690   * Grab the mouse to this window; future mouse events will be
00691   * reported to this window even while the cursor goes outside of this window
00692   */
00693   void grab();
00694 
00695   /// Release the mouse grab
00696   void ungrab();
00697 
00698   /// Return true if active grab is in effect
00699   FXbool grabbedKeyboard() const;
00700 
00701   /// Grab keyboard device
00702   void grabKeyboard();
00703 
00704   /// Ungrab keyboard device
00705   void ungrabKeyboard();
00706 
00707   /// Return true if the window is shown
00708   FXbool shown() const;
00709 
00710   /// Show this window
00711   virtual void show();
00712 
00713   /// Hide this window
00714   virtual void hide();
00715 
00716   /// Return true if the window is composite
00717   virtual FXbool isComposite() const;
00718 
00719   /// Return true if the window is under the cursor
00720   FXbool underCursor() const;
00721 
00722   /// Return true if this window owns the primary selection
00723   FXbool hasSelection() const;
00724 
00725   /// Try to acquire the primary selection, given a list of drag types
00726   FXbool acquireSelection(const FXDragType *types,FXuint numtypes);
00727 
00728   /// Release the primary selection
00729   FXbool releaseSelection();
00730 
00731   /// Return true if this window owns the clipboard
00732   FXbool hasClipboard() const;
00733 
00734   /// Try to acquire the clipboard, given a list of drag types
00735   FXbool acquireClipboard(const FXDragType *types,FXuint numtypes);
00736 
00737   /// Release the clipboard
00738   FXbool releaseClipboard();
00739 
00740   /// Return true if this window is able to receive drops
00741   FXbool isDropEnabled() const;
00742 
00743   /// Enable this window to receive drops
00744   virtual void dropEnable();
00745 
00746   /// Disable this window from receiving drops
00747   virtual void dropDisable();
00748 
00749   /// Return true if a drag operaion has been initiated from this window
00750   FXbool isDragging() const;
00751 
00752   /// Initiate a drag operation with a list of previously registered drag types
00753   FXbool beginDrag(const FXDragType *types,FXuint numtypes);
00754 
00755   /**
00756   * When dragging, inform the drop-target of the new position and
00757   * the drag action
00758   */
00759   FXbool handleDrag(FXint x,FXint y,FXDragAction action=DRAG_COPY);
00760 
00761   /**
00762   * Terminate the drag operation with or without actually dropping the data
00763   * Returns the action performed by the target
00764   */
00765   FXDragAction endDrag(FXbool drop=true);
00766 
00767   /// Return true if this window is the target of a drop
00768   FXbool isDropTarget() const;
00769 
00770   /**
00771   * When being dragged over, indicate that no further SEL_DND_MOTION messages
00772   * are required while the cursor is inside the given rectangle
00773   */
00774   void setDragRectangle(FXint x,FXint y,FXint w,FXint h,FXbool wantupdates=true) const;
00775 
00776   /**
00777   * When being dragged over, indicate we want to receive SEL_DND_MOTION messages
00778   * every time the cursor moves
00779   */
00780   void clearDragRectangle() const;
00781 
00782   /// When being dragged over, indicate acceptance or rejection of the dragged data
00783   void acceptDrop(FXDragAction action=DRAG_ACCEPT) const;
00784 
00785   /// The target accepted our drop
00786   FXDragAction didAccept() const;
00787 
00788   /**
00789   * Sent by the drop target in response to SEL_DND_DROP.  The drag action
00790   * should be the same as the action the drop target reported to the drag
00791   * source in reponse to the SEL_DND_MOTION message.
00792   * This function notifies the drag source that its part of the drop transaction
00793   * is finished, and that it is free to release any resources involved in the
00794   * drag operation.
00795   * Calling dropFinished() is advisable in cases where the drop target needs
00796   * to perform complex processing on the data received from the drag source,
00797   * prior to returning from the SEL_DND_DROP message handler.
00798   */
00799   void dropFinished(FXDragAction action=DRAG_REJECT) const;
00800 
00801   /// When being dragged over, inquire the drag types which are being offered
00802   FXbool inquireDNDTypes(FXDNDOrigin origin,FXDragType*& types,FXuint& numtypes) const;
00803 
00804   /// When being dragged over, return true if we are offered the given drag type
00805   FXbool offeredDNDType(FXDNDOrigin origin,FXDragType type) const;
00806 
00807   /// When being dragged over, return the drag action
00808   FXDragAction inquireDNDAction() const;
00809 
00810   /**
00811   * Set DND data; the array must be allocated with FXMALLOC and ownership is
00812   * transferred to the system
00813   */
00814   FXbool setDNDData(FXDNDOrigin origin,FXDragType type,FXuchar* data,FXuint size) const;
00815 
00816   /**
00817   * Set DND data from string value.
00818   */
00819   FXbool setDNDData(FXDNDOrigin origin,FXDragType type,const FXString& string) const;
00820 
00821   /**
00822   * Get DND data; the caller becomes the owner of the array and must free it
00823   * with FXFREE
00824   */
00825   FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXuchar*& data,FXuint& size) const;
00826 
00827   /**
00828   * Get DND data into string value.
00829   */
00830   FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXString& string) const;
00831 
00832   /// Return true if window logically contains the given point
00833   virtual FXbool contains(FXint parentx,FXint parenty) const;
00834 
00835   /// Translate coordinates from fromwindow's coordinate space to this window's coordinate space
00836   void translateCoordinatesFrom(FXint& tox,FXint& toy,const FXWindow* fromwindow,FXint fromx,FXint fromy) const;
00837 
00838   /// Translate coordinates from this window's coordinate space to towindow's coordinate space
00839   void translateCoordinatesTo(FXint& tox,FXint& toy,const FXWindow* towindow,FXint fromx,FXint fromy) const;
00840 
00841   /// Set window background color
00842   virtual void setBackColor(FXColor clr);
00843 
00844   /// Get background color
00845   FXColor getBackColor() const { return backColor; }
00846 
00847   /// Does save-unders
00848   virtual FXbool doesSaveUnder() const;
00849 
00850   /**
00851   * Translate message for localization; using the current FXTranslator,
00852   * an attempt is made to translate the given message into the current
00853   * language.  An optional hint may be passed to break any ties in case
00854   * more than one tranlation is possible for the given message text.
00855   * In addition, the name of the widget is passed as context name so
00856   * that translations for a single dialog may be grouped together.
00857   */
00858   virtual const FXchar* tr(const FXchar* text,const FXchar* hint=NULL,FXint count=-1) const FX_FORMAT(2) ;
00859 
00860   /// Save window to stream
00861   virtual void save(FXStream& store) const;
00862 
00863   /// Restore window from stream
00864   virtual void load(FXStream& store);
00865 
00866   /// Destroy window
00867   virtual ~FXWindow();
00868   };
00869 
00870 }
00871 
00872 #endif

Copyright © 1997-2010 Jeroen van der Zijp