1 /******************************************************************************** 2 * * 3 * W i n d o w O b j e c t * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 1997,2020 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 42 /// Layout hints for child widgets 43 enum { 44 LAYOUT_NORMAL = 0, /// Default layout mode 45 LAYOUT_SIDE_TOP = 0, /// Pack on top side (default) 46 LAYOUT_SIDE_BOTTOM = 0x00000001, /// Pack on bottom side 47 LAYOUT_SIDE_LEFT = 0x00000002, /// Pack on left side 48 LAYOUT_SIDE_RIGHT = LAYOUT_SIDE_LEFT|LAYOUT_SIDE_BOTTOM, /// Pack on right side 49 LAYOUT_FILL_COLUMN = 0x00000001, /// Matrix column is stretchable 50 LAYOUT_FILL_ROW = 0x00000002, /// Matrix row is stretchable 51 LAYOUT_LEFT = 0, /// Stick on left (default) 52 LAYOUT_RIGHT = 0x00000004, /// Stick on right 53 LAYOUT_CENTER_X = 0x00000008, /// Center horizontally 54 LAYOUT_FIX_X = LAYOUT_RIGHT|LAYOUT_CENTER_X, /// X fixed 55 LAYOUT_TOP = 0, /// Stick on top (default) 56 LAYOUT_BOTTOM = 0x00000010, /// Stick on bottom 57 LAYOUT_CENTER_Y = 0x00000020, /// Center vertically 58 LAYOUT_FIX_Y = LAYOUT_BOTTOM|LAYOUT_CENTER_Y, /// Y fixed 59 LAYOUT_DOCK_SAME = 0, /// Dock on same galley if it fits 60 LAYOUT_DOCK_NEXT = 0x00000040, /// Dock on next galley 61 LAYOUT_RESERVED_1 = 0x00000080, 62 LAYOUT_FIX_WIDTH = 0x00000100, /// Width fixed 63 LAYOUT_FIX_HEIGHT = 0x00000200, /// height fixed 64 LAYOUT_MIN_WIDTH = 0, /// Minimum width is the default 65 LAYOUT_MIN_HEIGHT = 0, /// Minimum height is the default 66 LAYOUT_FILL_X = 0x00000400, /// Stretch or shrink horizontally 67 LAYOUT_FILL_Y = 0x00000800, /// Stretch or shrink vertically 68 LAYOUT_FILL = LAYOUT_FILL_X|LAYOUT_FILL_Y, /// Stretch or shrink in both directions 69 LAYOUT_EXPLICIT = LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT /// Explicit placement 70 }; 71 72 73 /// Frame border appearance styles (for subclasses) 74 enum { 75 FRAME_NONE = 0, /// Default is no frame 76 FRAME_SUNKEN = 0x00001000, /// Sunken border 77 FRAME_RAISED = 0x00002000, /// Raised border 78 FRAME_THICK = 0x00004000, /// Thick border 79 FRAME_GROOVE = FRAME_THICK, /// A groove or etched-in border 80 FRAME_RIDGE = FRAME_THICK|FRAME_RAISED|FRAME_SUNKEN, /// A ridge or embossed border 81 FRAME_LINE = FRAME_RAISED|FRAME_SUNKEN, /// Simple line border 82 FRAME_NORMAL = FRAME_SUNKEN|FRAME_THICK /// Regular raised/thick border 83 }; 84 85 86 /// Packing style (for packers) 87 enum { 88 PACK_NORMAL = 0, /// Default is each its own size 89 PACK_UNIFORM_HEIGHT = 0x00008000, /// Uniform height 90 PACK_UNIFORM_WIDTH = 0x00010000 /// Uniform width 91 }; 92 93 94 /// Data exchange modes 95 enum FXDNDOrigin { 96 FROM_SELECTION = 0, /// Primary selection 97 FROM_CLIPBOARD = 1, /// Clipboard 98 FROM_DRAGNDROP = 2 /// Drag and drop source 99 }; 100 101 102 /// Drag and drop actions 103 enum FXDragAction { 104 DRAG_REJECT = 0, /// Reject all drop actions 105 DRAG_ASK = 1, /// Ask 106 DRAG_COPY = 2, /// Copy 107 DRAG_MOVE = 3, /// Move 108 DRAG_LINK = 4, /// Link 109 DRAG_PRIVATE = 5, /// Private 110 DRAG_ACCEPT = 6 /// Accept any drop action 111 }; 112 113 114 /** 115 * Window is the base class for all widgets in FOX. 116 * All widgets are organized in a tree structure, with a single root window 117 * at the top. 118 * Each window links to its parent window, next and previous siblings windows, 119 * as well as its first and last child windows. A window also has an owner window, 120 * which is the window responsible for its creation and destruction. In most cases, 121 * the owner window will be the same as the parent window, except for top-level windows. 122 * The focus window determines to which child keyboard messages are delegated if the 123 * window is a composite window (i.e. if it has children). 124 * Windows are geometrically arranged by their immediate parent window; the actual 125 * method of placement is determined by the type of layout supported by the parent 126 * window, as well as the window's layout hints. 127 * The position of a window is determined relative to its immediate parent window; 128 * A window can send a message to its target object when an event happens. 129 */ 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 215 /// Window classes 216 enum WindowClass { 217 ClassNormal, /// Normal child window 218 ClassGraphic, /// Graphics child window 219 ClassSpecial, /// Special child window 220 ClassRoot, /// Root window 221 ClassShell, /// Shell window 222 ClassPopup, /// Popup window 223 ClassToolTip, /// Tooltip window 224 ClassMain, /// Main application window 225 ClassDialog, /// Dialog box window 226 ClassToolBar, /// Toolbar window 227 ClassSplash, /// Splash window 228 ClassNotify, /// Notify window 229 ClassPanel, /// Panel window 230 ClassDesktop /// Desktop backdrop window 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 365 /// Constructor 366 FXWindow(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 367 368 /// Return a pointer to the parent window getParent()369 FXWindow* getParent() const { return parent; } 370 371 /// Return a pointer to the owner window getOwner()372 FXWindow* getOwner() const { return owner; } 373 374 /// Return a pointer to the shell window 375 FXWindow* getShell() const; 376 377 /// Return a pointer to the root window 378 FXWindow* getRoot() const; 379 380 /// Return a pointer to the next (sibling) window, if any getNext()381 FXWindow* getNext() const { return next; } 382 383 /// Return a pointer to the previous (sibling) window , if any getPrev()384 FXWindow* getPrev() const { return prev; } 385 386 /// Return a pointer to this window's first child window , if any getFirst()387 FXWindow* getFirst() const { return first; } 388 389 /// Return a pointer to this window's last child window, if any getLast()390 FXWindow* getLast() const { return last; } 391 392 /// Return a pointer to the currently focused child window getFocus()393 FXWindow* getFocus() const { return focus; } 394 395 /// Get window class 396 virtual WindowClass getWindowClass() const; 397 398 /// Change window key setKey(FXuint k)399 void setKey(FXuint k){ wk=k; } 400 401 /// Return window key getKey()402 FXuint getKey() const { return wk; } 403 404 /// Return child window with given window key 405 FXWindow* getChildWithKey(FXuint k) const; 406 407 /// Set the message target object for this window setTarget(FXObject * t)408 void setTarget(FXObject *t){ target=t; } 409 410 /// Get the message target object for this window, if any getTarget()411 FXObject* getTarget() const { return target; } 412 413 /// Set the message identifier for this window setSelector(FXSelector sel)414 void setSelector(FXSelector sel){ message=sel; } 415 416 /// Get the message identifier for this window getSelector()417 FXSelector getSelector() const { return message; } 418 419 /// Get this window's x-coordinate, in the parent's coordinate system getX()420 FXint getX() const { return xpos; } 421 422 /// Get this window's y-coordinate, in the parent's coordinate system getY()423 FXint getY() const { return ypos; } 424 425 /// Return the default width of this window 426 virtual FXint getDefaultWidth(); 427 428 /// Return the default height of this window 429 virtual FXint getDefaultHeight(); 430 431 /// Return width for given height 432 virtual FXint getWidthForHeight(FXint givenheight); 433 434 /// Return height for given width 435 virtual FXint getHeightForWidth(FXint givenwidth); 436 437 /// Set this window's x-coordinate, in the parent's coordinate system 438 void setX(FXint x); 439 440 /// Set this window's y-coordinate, in the parent's coordinate system 441 void setY(FXint y); 442 443 /** 444 * Set the window width; and flag the widget as being in need of 445 * layout by its parent. This does not immediately update the server- 446 * side representation of the widget. 447 */ 448 void setWidth(FXint w); 449 450 /** 451 * Set the window height; and flag the widget as being in need of 452 * layout by its parent. This does not immediately update the server- 453 * side representation of the widget. 454 */ 455 void setHeight(FXint h); 456 457 /// Set layout hints for this window 458 void setLayoutHints(FXuint lout); 459 460 /// Get layout hints for this window 461 FXuint getLayoutHints() const; 462 463 /// Return a pointer to the accelerator table getAccelTable()464 FXAccelTable* getAccelTable() const { return accelTable; } 465 466 /// Set the accelerator table setAccelTable(FXAccelTable * acceltable)467 void setAccelTable(FXAccelTable* acceltable){ accelTable=acceltable; } 468 469 /// Add a hot key 470 void addHotKey(FXHotKey code); 471 472 /// Remove a hot key 473 void remHotKey(FXHotKey code); 474 475 /// Change help tag for this widget setHelpTag(const FXString & text)476 void setHelpTag(const FXString& text){ tag=text; } 477 478 /// Get the help tag for this widget getHelpTag()479 const FXString& getHelpTag() const { return tag; } 480 481 /// Return true if window is a shell window 482 FXbool isShell() const; 483 484 /// Return true if specified window is owned by this window 485 FXbool isOwnerOf(const FXWindow* window) const; 486 487 /// Return true if specified window is ancestor of this window 488 FXbool isChildOf(const FXWindow* window) const; 489 490 /// Return true if this window contains child in its subtree 491 FXbool containsChild(const FXWindow* child) const; 492 493 /// Return the child window at specified coordinates 494 FXWindow* getChildAt(FXint x,FXint y) const; 495 496 /// Return the number of child windows for this window 497 FXint numChildren() const; 498 499 /** 500 * Return the index (starting from zero) of the specified child window, 501 * or -1 if the window is not a child or NULL 502 */ 503 FXint indexOfChild(const FXWindow *window) const; 504 505 /** 506 * Return the child window at specified index, 507 * or NULL if the index is negative or out of range 508 */ 509 FXWindow* childAtIndex(FXint index) const; 510 511 /// Return the common ancestor of window a and window b 512 static FXWindow* commonAncestor(FXWindow* a,FXWindow* b); 513 514 /// Return true if sibling a <= sibling b in list 515 static FXbool before(const FXWindow *a,const FXWindow* b); 516 517 /// Return true if sibling a >= sibling b in list 518 static FXbool after(const FXWindow *a,const FXWindow* b); 519 520 /// Return compose context getComposeContext()521 FXComposeContext* getComposeContext() const { return composeContext; } 522 523 /// Create compose context 524 void createComposeContext(); 525 526 /// Destroy compose context 527 void destroyComposeContext(); 528 529 /// Is cursor shown 530 FXbool cursorShown() const; 531 532 /// Show or hide the cursor 533 void showCursor(FXbool flag=true); 534 535 /// Set the default cursor for this window 536 void setDefaultCursor(FXCursor* cur); 537 538 /// Return the default cursor for this window getDefaultCursor()539 FXCursor* getDefaultCursor() const { return defaultCursor; } 540 541 /// Set the drag cursor for this window 542 void setDragCursor(FXCursor* cur); 543 544 /// Return the drag cursor for this window getDragCursor()545 FXCursor* getDragCursor() const { return dragCursor; } 546 547 /// Return the cursor position and mouse button-state 548 FXbool getCursorPosition(FXint& x,FXint& y,FXuint& buttons) const; 549 550 /// Warp the cursor to the new position 551 FXbool setCursorPosition(FXint x,FXint y); 552 553 /// Return true if the window is active 554 FXbool isActive() const; 555 556 /// Return true if this window is a control capable of receiving the focus 557 virtual FXbool canFocus() const; 558 559 /// Return true if this window has the focus 560 FXbool hasFocus() const; 561 562 /// Return true if this window is in focus chain 563 FXbool inFocusChain() const; 564 565 /// Move the focus to this window 566 virtual void setFocus(); 567 568 /// Remove the focus from this window 569 virtual void killFocus(); 570 571 /// Notification that focus moved to new child 572 virtual void changeFocus(FXWindow *child); 573 574 /// Return true if this is the default window 575 FXbool isDefault() const; 576 577 /** 578 * This changes the default window which responds to the Return 579 * key in a dialog. If the flag is true, this window becomes the default 580 * window; when the flag is false, this window will be no longer the 581 * default window. Finally, when the flag is maybe, the default window 582 * will revert to the initial default window. 583 */ 584 virtual void setDefault(FXuchar flag=true); 585 586 /// Find default window among this window's children 587 FXWindow* findDefault() const; 588 589 /// Return true if this is the initial default window 590 FXbool isInitial() const; 591 592 /// Make this window the initial default window 593 void setInitial(FXbool flag=true); 594 595 /// Find inital default window among this window's children 596 FXWindow* findInitial() const; 597 598 /// Return true if this window is able to receive mouse and keyboard events 599 FXbool isEnabled() const; 600 601 /// Enable the window to receive mouse and keyboard events 602 virtual void enable(); 603 604 /// Disable the window from receiving mouse and keyboard events 605 virtual void disable(); 606 607 /// Create all of the server-side resources for this window 608 virtual void create(); 609 610 /// Attach foreign window handle to this window 611 virtual void attach(FXID w); 612 613 /// Detach the server-side resources for this window 614 virtual void detach(); 615 616 /// Destroy the server-side resources for this window 617 virtual void destroy(); 618 619 /// Set window shape by means of region 620 virtual void setShape(const FXRegion& region); 621 622 /// Set window shape by means of bitmap 623 virtual void setShape(FXBitmap* bitmap); 624 625 /// Set window shape by means of icon 626 virtual void setShape(FXIcon* icon); 627 628 /// Clear window shape 629 virtual void clearShape(); 630 631 /// Raise this window to the top of the stacking order 632 virtual void raise(); 633 634 /// Lower this window to the bottom of the stacking order 635 virtual void lower(); 636 637 /** 638 * Move the window immediately, in the parent's coordinate system. 639 * Update the server representation as well if the window is realized. 640 * Perform layout of the children when necessary. 641 */ 642 virtual void move(FXint x,FXint y); 643 644 /** 645 * Resize the window to the specified width and height immediately, 646 * updating the server representation as well, if the window was realized. 647 * Perform layout of the children when necessary. 648 */ 649 virtual void resize(FXint w,FXint h); 650 651 /** 652 * Move and resize the window immediately, in the parent's coordinate system. 653 * Update the server representation as well if the window is realized. 654 * Perform layout of the children when necessary. 655 */ 656 virtual void position(FXint x,FXint y,FXint w,FXint h); 657 658 /// Mark this window's layout as dirty for later layout 659 virtual void recalc(); 660 661 /// Perform layout immediately 662 virtual void layout(); 663 664 /// Generate a SEL_UPDATE message for the window and its children 665 void forceRefresh(); 666 667 /// Reparent this window under new father before other 668 virtual void reparent(FXWindow* father,FXWindow *other=NULL); 669 670 /// Scroll rectangle x,y,w,h by a shift of dx,dy 671 void scroll(FXint x,FXint y,FXint w,FXint h,FXint dx,FXint dy) const; 672 673 /// Mark the specified rectangle to be repainted later 674 void update(FXint x,FXint y,FXint w,FXint h) const; 675 676 /// Mark the entire window to be repainted later 677 void update() const; 678 679 /// Process any outstanding repaint messages immediately, for the given rectangle 680 void repaint(FXint x,FXint y,FXint w,FXint h) const; 681 682 /// Process any outstanding repaint messages immediately 683 void repaint() const; 684 685 /// Return true if the window has been grabbed 686 FXbool grabbed() const; 687 688 /** 689 * Grab the mouse to this window; future mouse events will be 690 * reported to this window even while the cursor goes outside of this window 691 */ 692 void grab(); 693 694 /// Release the mouse grab 695 void ungrab(); 696 697 /// Return true if active grab is in effect 698 FXbool grabbedKeyboard() const; 699 700 /// Grab keyboard device 701 void grabKeyboard(); 702 703 /// Ungrab keyboard device 704 void ungrabKeyboard(); 705 706 /// Return true if the window is shown 707 FXbool shown() const; 708 709 /// Show this window 710 virtual void show(); 711 712 /// Hide this window 713 virtual void hide(); 714 715 /// Return true if the window is composite 716 virtual FXbool isComposite() const; 717 718 /// Return true if the window is under the cursor 719 FXbool underCursor() const; 720 721 /// Return true if this window owns the primary selection 722 FXbool hasSelection() const; 723 724 /// Try to acquire the primary selection, given a list of drag types 725 FXbool acquireSelection(const FXDragType *types,FXuint numtypes); 726 727 /// Release the primary selection 728 FXbool releaseSelection(); 729 730 /// Return true if this window owns the clipboard 731 FXbool hasClipboard() const; 732 733 /// Try to acquire the clipboard, given a list of drag types 734 FXbool acquireClipboard(const FXDragType *types,FXuint numtypes); 735 736 /// Release the clipboard 737 FXbool releaseClipboard(); 738 739 /// Return true if this window is able to receive drops 740 FXbool isDropEnabled() const; 741 742 /// Enable this window to receive drops 743 virtual void dropEnable(); 744 745 /// Disable this window from receiving drops 746 virtual void dropDisable(); 747 748 /// Return true if a drag operaion has been initiated from this window 749 FXbool isDragging() const; 750 751 /// Initiate a drag operation with a list of previously registered drag types 752 FXbool beginDrag(const FXDragType *types,FXuint numtypes); 753 754 /** 755 * When dragging, inform the drop-target of the new position and 756 * the drag action 757 */ 758 FXbool handleDrag(FXint x,FXint y,FXDragAction action=DRAG_COPY); 759 760 /** 761 * Terminate the drag operation with or without actually dropping the data 762 * Returns the action performed by the target 763 */ 764 FXDragAction endDrag(FXbool drop=true); 765 766 /// Return true if this window is the target of a drop 767 FXbool isDropTarget() const; 768 769 /** 770 * When being dragged over, indicate that no further SEL_DND_MOTION messages 771 * are required while the cursor is inside the given rectangle 772 */ 773 void setDragRectangle(FXint x,FXint y,FXint w,FXint h,FXbool wantupdates=true) const; 774 775 /** 776 * When being dragged over, indicate we want to receive SEL_DND_MOTION messages 777 * every time the cursor moves 778 */ 779 void clearDragRectangle() const; 780 781 /// When being dragged over, indicate acceptance or rejection of the dragged data 782 void acceptDrop(FXDragAction action=DRAG_ACCEPT) const; 783 784 /// The target accepted our drop 785 FXDragAction didAccept() const; 786 787 /** 788 * Sent by the drop target in response to SEL_DND_DROP. The drag action 789 * should be the same as the action the drop target reported to the drag 790 * source in reponse to the SEL_DND_MOTION message. 791 * This function notifies the drag source that its part of the drop transaction 792 * is finished, and that it is free to release any resources involved in the 793 * drag operation. 794 * Calling dropFinished() is advisable in cases where the drop target needs 795 * to perform complex processing on the data received from the drag source, 796 * prior to returning from the SEL_DND_DROP message handler. 797 */ 798 void dropFinished(FXDragAction action=DRAG_REJECT) const; 799 800 /// When being dragged over, inquire the drag types which are being offered 801 FXbool inquireDNDTypes(FXDNDOrigin origin,FXDragType*& types,FXuint& numtypes) const; 802 803 /// When being dragged over, return true if we are offered the given drag type 804 FXbool offeredDNDType(FXDNDOrigin origin,FXDragType type) const; 805 806 /// When being dragged over, return the drag action 807 FXDragAction inquireDNDAction() const; 808 809 /** 810 * Set DND data; the array must be allocated with allocElms() and ownership is 811 * transferred to the system. 812 */ 813 FXbool setDNDData(FXDNDOrigin origin,FXDragType type,FXuchar* data,FXuint size) const; 814 815 /** 816 * Set DND data from string value. 817 */ 818 FXbool setDNDData(FXDNDOrigin origin,FXDragType type,const FXString& string) const; 819 820 /** 821 * Get DND data; the caller becomes the owner of the array and must free it 822 * with freeElms(). 823 */ 824 FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXuchar*& data,FXuint& size) const; 825 826 /** 827 * Get DND data into string value. 828 */ 829 FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXString& string) const; 830 831 /// Return true if window logically contains the given point 832 virtual FXbool contains(FXint parentx,FXint parenty) const; 833 834 /// Translate coordinates from fromwindow's coordinate space to this window's coordinate space 835 void translateCoordinatesFrom(FXint& tox,FXint& toy,const FXWindow* fromwindow,FXint fromx,FXint fromy) const; 836 837 /// Translate coordinates from this window's coordinate space to towindow's coordinate space 838 void translateCoordinatesTo(FXint& tox,FXint& toy,const FXWindow* towindow,FXint fromx,FXint fromy) const; 839 840 /// Set window background color 841 virtual void setBackColor(FXColor clr); 842 843 /// Get background color getBackColor()844 FXColor getBackColor() const { return backColor; } 845 846 /// Does save-unders 847 virtual FXbool doesSaveUnder() const; 848 849 /** 850 * Translate message for localization; using the current FXTranslator, 851 * an attempt is made to translate the given message into the current 852 * language. An optional hint may be passed to break any ties in case 853 * more than one tranlation is possible for the given message text. 854 * In addition, the name of the widget is passed as context name so 855 * that translations for a single dialog may be grouped together. 856 */ 857 virtual const FXchar* tr(const FXchar* text,const FXchar* hint=NULL,FXint count=-1) const FX_FORMAT(2) ; 858 859 /// Save window to stream 860 virtual void save(FXStream& store) const; 861 862 /// Restore window from stream 863 virtual void load(FXStream& store); 864 865 /// Destroy window 866 virtual ~FXWindow(); 867 }; 868 869 } 870 871 #endif 872