1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxWindow
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 wxWindow is the base class for all windows and represents any visible object on
13 screen. All controls, top level windows and so on are windows. Sizers and
14 device contexts are not, however, as they don't appear on screen themselves.
16 Please note that all children of the window will be deleted automatically by
17 the destructor before the window itself is deleted which means that you don't
18 have to worry about deleting them manually. Please see the @ref
19 overview_windowdeletion "window deletion overview" for more information.
21 Also note that in this, and many others, wxWidgets classes some
22 @c GetXXX() methods may be overloaded (as, for example,
23 wxWindow::GetSize or wxWindow::GetClientSize). In this case, the overloads
24 are non-virtual because having multiple virtual functions with the same name
25 results in a virtual function name hiding at the derived class level (in
26 English, this means that the derived class has to override all overloaded
27 variants if it overrides any of them). To allow overriding them in the derived
28 class, wxWidgets uses a unique protected virtual @c DoGetXXX() method
29 and all @c GetXXX() ones are forwarded to it, so overriding the former
30 changes the behaviour of the latter.
33 @style{wxBORDER_DEFAULT}
34 The window class will decide the kind of border to show, if any.
35 @style{wxBORDER_SIMPLE}
36 Displays a thin border around the window. wxSIMPLE_BORDER is the
37 old name for this style.
38 @style{wxBORDER_SUNKEN}
39 Displays a sunken border. wxSUNKEN_BORDER is the old name for this
41 @style{wxBORDER_RAISED}
42 Displays a raised border. wxRAISED_BORDER is the old name for this
44 @style{wxBORDER_STATIC}
45 Displays a border suitable for a static control. wxSTATIC_BORDER
46 is the old name for this style. Windows only.
47 @style{wxBORDER_THEME}
48 Displays a native border suitable for a control, on the current
49 platform. On Windows XP or Vista, this will be a themed border; on
50 most other platforms a sunken border will be used. For more
51 information for themed borders on Windows, please see Themed
54 Displays no border, overriding the default border style for the
55 window. wxNO_BORDER is the old name for this style.
56 @style{wxBORDER_DOUBLE}
57 This style is obsolete and should not be used.
58 @style{wxTRANSPARENT_WINDOW}
59 The window is transparent, that is, it will not receive paint
61 @style{wxTAB_TRAVERSAL}
62 Use this to enable tab traversal for non-dialog windows.
64 Use this to indicate that the window wants to get all char/key
65 events for all keys - even for keys like TAB or ENTER which are
66 usually used for dialog navigation and which wouldn't be generated
67 without this style. If you need to use this style in order to get
68 the arrows or etc., but would still like to have normal keyboard
69 navigation take place, you should call Navigate in response to the
70 key events for Tab and Shift-Tab.
71 @style{wxNO_FULL_REPAINT_ON_RESIZE}
72 On Windows, this style used to disable repainting the window
73 completely when its size is changed. Since this behaviour is now
74 the default, the style is now obsolete and no longer has an effect.
76 Use this style to enable a vertical scrollbar. Notice that this
77 style cannot be used with native controls which don't support
78 scrollbars nor with top-level windows in most ports.
80 Use this style to enable a horizontal scrollbar. The same
81 limitations as for wxVSCROLL apply to this style.
82 @style{wxALWAYS_SHOW_SB}
83 If a window has scrollbars, disable them instead of hiding them
84 when they are not needed (i.e. when the size of the window is big
85 enough to not require the scrollbars to navigate it). This style is
86 currently implemented for wxMSW, wxGTK and wxUniversal and does
87 nothing on the other platforms.
88 @style{wxCLIP_CHILDREN}
89 Use this style to eliminate flicker caused by the background being
90 repainted, then children being painted over them. Windows only.
91 @style{wxFULL_REPAINT_ON_RESIZE}
92 Use this style to force a complete redraw of the window whenever it
93 is resized instead of redrawing just the part of the window
94 affected by resizing. Note that this was the behaviour by default
95 before 2.5.1 release and that if you experience redraw problems
96 with code which previously used to work you may want to try this.
97 Currently this style applies on GTK+ 2 and Windows only, and full
98 repainting is always done on other platforms.
101 @beginExtraStyleTable
102 @style{wxWS_EX_VALIDATE_RECURSIVELY}
103 By default, Validate/TransferDataTo/FromWindow() only work on
104 direct children of the window (compatible behaviour). Set this flag
105 to make them recursively descend into all subwindows.
106 @style{wxWS_EX_BLOCK_EVENTS}
107 wxCommandEvents and the objects of the derived classes are
108 forwarded to the parent window and so on recursively by default.
109 Using this flag for the given window allows to block this
110 propagation at this window, i.e. prevent the events from being
111 propagated further upwards. Dialogs have this flag on by default.
112 @style{wxWS_EX_TRANSIENT}
113 Don't use this window as an implicit parent for the other windows:
114 this must be used with transient windows as otherwise there is the
115 risk of creating a dialog/frame with this window as a parent which
116 would lead to a crash if the parent is destroyed before the child.
117 @style{wxWS_EX_PROCESS_IDLE}
118 This window should always process idle events, even if the mode set
119 by wxIdleEvent::SetMode is wxIDLE_PROCESS_SPECIFIED.
120 @style{wxWS_EX_PROCESS_UI_UPDATES}
121 This window should always process UI update events, even if the
122 mode set by wxUpdateUIEvent::SetMode is
123 wxUPDATE_UI_PROCESS_SPECIFIED.
129 @see @ref overview_eventhandling "Event handling overview",
130 @ref overview_windowsizing "Window sizing overview"
132 class wxWindow
: public wxEvtHandler
141 Constructs a window, which can be a child of a frame, dialog or any other
145 Pointer to a parent window.
147 Window identifier. If wxID_ANY, will automatically create an identifier.
149 Window position. wxDefaultPosition indicates that wxWidgets
150 should generate a default position for the window. If using the wxWindow
151 class directly, supply
154 Window size. wxDefaultSize indicates that wxWidgets
155 should generate a default size for the window. If no suitable size can be
157 window will be sized to 20x20 pixels so that the window is visible but
161 Window style. For generic window styles, please see wxWindow.
165 wxWindow(wxWindow
* parent
, wxWindowID id
,
166 const wxPoint
& pos
= wxDefaultPosition
,
167 const wxSize
& size
= wxDefaultSize
,
169 const wxString
& name
= wxPanelNameStr
);
172 Destructor. Deletes all sub-windows, then deletes itself. Instead of using
173 the @b delete operator explicitly, you should normally
174 use Destroy() so that wxWidgets
175 can delete a window only when it is safe to do so, in idle time.
177 @see @ref overview_windowdeletion "Window Deletion Overview",
178 Destroy(), wxCloseEvent
183 This method may be overridden in the derived classes to return @false to
184 indicate that this control doesn't accept input at all (i.e. behaves like e.g.
185 wxStaticText) and so doesn't need focus.
187 @see AcceptsFocusFromKeyboard()
189 virtual bool AcceptsFocus() const;
192 This method may be overridden in the derived classes to return @false to
193 indicate that while this control can, in principle, have focus if the user
194 clicks it with the mouse, it shouldn't be included in the TAB traversal chain
195 when using the keyboard.
197 virtual bool AcceptsFocusFromKeyboard() const;
200 Overridden to indicate wehter this window or one of its children accepts
201 focus. Usually it's the same as AcceptsFocus() but is overridden for
204 virtual bool AcceptsFocusRecursively() const;
207 Adds a child window. This is called automatically by window creation
208 functions so should not be required by the application programmer.
209 Notice that this function is mostly internal to wxWidgets and shouldn't be
210 called by the user code.
215 virtual void AddChild(wxWindow
* child
);
218 Call this function to force one or both scrollbars to be always shown, even if
219 the window is big enough to show its entire contents without scrolling.
224 Whether the horizontal scroll bar should always be visible.
226 Whether the vertical scroll bar should always be visible.
228 @remarks This function is currently only implemented under Mac/Carbon.
230 void AlwaysShowScrollbars(bool hflag
, bool vflag
);
233 Sets the cached best size value.
235 void CacheBestSize(const wxSize
& size
) const;
238 Returns @true if the system supports transparent windows and calling
239 SetTransparent() may succeed. If this function
240 returns @false, transparent windows are definitely not supported by the
244 bool CanSetTransparent();
247 Directs all mouse input to this window. Call ReleaseMouse() to
249 Note that wxWidgets maintains the stack of windows having captured the mouse
250 and when the mouse is released the capture returns to the window which had had
251 captured it previously and it is only really released if there were no previous
252 window. In particular, this means that you must release the mouse as many times
253 as you capture it, unless the window receives
254 the wxMouseCaptureLostEvent event.
255 Any application which captures the mouse in the beginning of some operation
256 must handle wxMouseCaptureLostEvent
257 and cancel this operation when it receives the event. The event handler must
260 @see ReleaseMouse(), wxMouseCaptureLostEvent
262 virtual void CaptureMouse();
265 A synonym for Centre().
267 void Center(int direction
);
270 A synonym for CentreOnParent().
272 void CenterOnParent(int direction
);
278 Specifies the direction for the centering. May be wxHORIZONTAL, wxVERTICAL
279 or wxBOTH. It may also include wxCENTRE_ON_SCREEN flag
280 if you want to center the window on the entire screen and not on its
283 @remarks If the window is a top level one (i.e. doesn't have a parent),
284 it will be centered relative to the screen anyhow.
288 void Centre(int direction
= wxBOTH
);
291 Centres the window on its parent. This is a more readable synonym for
295 Specifies the direction for the centering. May be wxHORIZONTAL, wxVERTICAL
298 @remarks This methods provides for a way to center top level windows over
299 their parents instead of the entire screen. If there
300 is no parent or if the window is not a top level
301 window, then behaviour is the same as Centre().
303 @see wxTopLevelWindow::CentreOnScreen
305 void CentreOnParent(int direction
= wxBOTH
);
308 Clears the window by filling it with the current background colour. Does not
309 cause an erase background event to be generated.
311 void ClearBackground();
315 Converts to screen coordinates from coordinates relative to this window.
318 A pointer to a integer value for the x coordinate. Pass the client
320 a screen coordinate will be passed out.
322 A pointer to a integer value for the y coordinate. Pass the client
324 a screen coordinate will be passed out.
326 The client position for the second form of the function.
328 void ClientToScreen(int* x
, int* y
) const;
329 wxPoint
ClientToScreen(const wxPoint
& pt
) const;
333 Converts client area size @a size to corresponding window size. In
334 other words, the returned value is what would GetSize() return if this
335 window had client area of given size. Components with wxDefaultCoord
336 value are left unchanged. Note that the conversion is not always
337 exact, it assumes that non-client area doesn't change and so doesn't
338 take into account things like menu bar (un)wrapping or (dis)appearance
343 @see WindowToClientSize()
345 virtual wxSize
ClientToWindowSize(const wxSize
& size
);
348 Converts window size @a size to corresponding client area size. In
349 other words, the returned value is what would GetClientSize() return if
350 this window had given window size. Components with wxDefaultCoord value
353 Note that the conversion is not always exact, it assumes that
354 non-client area doesn't change and so doesn't take into account things
355 like menu bar (un)wrapping or (dis)appearance of the scrollbars.
359 @see ClientToWindowSize()
361 virtual wxSize
WindowToClientSize(const wxSize
& size
);
364 This function simply generates a wxCloseEvent whose
365 handler usually tries to close the window. It doesn't close the window
369 @false if the window's close handler should be able to veto the destruction
370 of this window, @true if it cannot.
372 @remarks Close calls the close handler for the window, providing an
373 opportunity for the window to choose whether to destroy
374 the window. Usually it is only used with the top level
375 windows (wxFrame and wxDialog classes) as the others
376 are not supposed to have any special OnClose() logic.
378 @see @ref overview_windowdeletion "Window Deletion Overview",
379 Destroy(), wxCloseEvent
381 bool Close(bool force
= false);
385 Converts a point or size from dialog units to pixels.
386 For the x dimension, the dialog units are multiplied by the average character
388 and then divided by 4.
389 For the y dimension, the dialog units are multiplied by the average character
391 and then divided by 8.
393 @remarks Dialog units are used for maintaining a dialog's proportions
394 even if the font changes.
396 @see ConvertPixelsToDialog()
398 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
);
399 wxSize
ConvertDialogToPixels(const wxSize
& sz
);
404 Converts a point or size from pixels to dialog units.
405 For the x dimension, the pixels are multiplied by 4 and then divided by the
408 For the y dimension, the pixels are multiplied by 8 and then divided by the
412 @remarks Dialog units are used for maintaining a dialog's proportions
413 even if the font changes.
415 @see ConvertDialogToPixels()
417 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
);
418 wxSize
ConvertPixelsToDialog(const wxSize
& sz
);
422 Destroys the window safely. Use this function instead of the delete operator,
424 different window classes can be destroyed differently. Frames and dialogs
425 are not destroyed immediately when this function is called -- they are added
426 to a list of windows to be deleted on idle time, when all the window's events
427 have been processed. This prevents problems with events being sent to
431 @return @true if the window has either been successfully deleted, or it
432 has been added to the list of windows pending real
435 virtual bool Destroy();
438 Destroys all children of a window. Called automatically by the destructor.
440 virtual void DestroyChildren();
443 Disables the window. Same as @ref Enable() Enable(@false).
445 @return Returns @true if the window has been disabled, @false if it had
446 been already disabled before the call to this function.
451 Gets the size which best suits the window: for a control, it would be
452 the minimal size which doesn't truncate the control, for a panel - the
453 same size as it would have after a call to Fit().
455 The default implementation of this function is designed for use in container
456 windows, such as wxPanel, and works something like this:
457 -# If the window has a sizer then it is used to calculate the best size.
458 -# Otherwise if the window has layout constraints then those are used to
459 calculate the best size.
460 -# Otherwise if the window has children then the best size is set to be large
461 enough to show all the children.
462 -# Otherwise if there are no children then the window's minimal size will be
463 used as its best size.
464 -# Otherwise if there is no minimal size set, then the current size is used
467 @see @ref overview_windowsizing
469 virtual wxSize
DoGetBestSize() const;
472 Does the window-specific updating after processing the update event.
473 This function is called by UpdateWindowUI() in order to check return
474 values in the wxUpdateUIEvent and act appropriately.
476 virtual void DoUpdateWindowUI(wxUpdateUIEvent
& event
);
479 Enables or disables eligibility for drop file events (OnDropFiles).
482 If @true, the window is eligible for drop file events. If @false, the window
483 will not accept drop file events.
485 @remarks Windows only.
487 virtual void DragAcceptFiles(bool accept
);
490 Enable or disable the window for user input. Note that when a parent window is
491 disabled, all of its children are disabled as well and they are reenabled again
495 If @true, enables the window for input. If @false, disables the window.
497 @return Returns @true if the window has been enabled or disabled, @false
498 if nothing was done, i.e. if the window had already
499 been in the specified state.
501 @see IsEnabled(), Disable(), wxRadioBox::Enable
503 virtual bool Enable(bool enable
= true);
506 Finds the window or control which currently has the keyboard focus.
508 @remarks Note that this is a static function, so it can be called without
509 needing a wxWindow pointer.
511 @see SetFocus(), HasFocus()
513 static wxWindow
* FindFocus();
516 Find a child of this window, by @a id. May return @a this if
519 wxWindow
* FindWindow(long id
) const;
523 Find a child of this window, by name. May return @a this if
526 wxWindow
* FindWindow(const wxString
& name
) const;
529 Find the first window with the given @e id.
530 If @a parent is @NULL, the search will start from all top-level
531 frames and dialog boxes; if non-@NULL, the search will be limited to the given
533 The search is recursive in both cases.
537 static wxWindow
* FindWindowById(long id
, wxWindow
* parent
= NULL
);
540 Find a window by its label. Depending on the type of window, the label may be a
542 or panel item label. If @a parent is @NULL, the search will start from all
544 frames and dialog boxes; if non-@NULL, the search will be limited to the given
546 The search is recursive in both cases.
550 static wxWindow
* FindWindowByLabel(const wxString
& label
,
551 wxWindow
* parent
= NULL
);
554 Find a window by its name (as given in a window constructor or @b Create
556 If @a parent is @NULL, the search will start from all top-level
557 frames and dialog boxes; if non-@NULL, the search will be limited to the given
559 The search is recursive in both cases.
560 If no window with such name is found,
561 FindWindowByLabel() is called.
565 static wxWindow
* FindWindowByName(const wxString
& name
,
566 wxWindow
* parent
= NULL
);
569 Sizes the window so that it fits around its subwindows.
571 This function won't do anything if there are no subwindows and will only really
572 work correctly if sizers are used for the subwindows layout.
574 Also, if the window has exactly one subwindow it is better (faster and the result
575 is more precise as Fit() adds some margin to account for fuzziness of its calculations)
579 window->SetClientSize(child->GetSize());
582 instead of calling Fit().
584 @see @ref overview_windowsizing
589 Similar to Fit(), but sizes the interior (virtual) size
590 of a window. Mainly useful with scrolled windows to reset scrollbars after
591 sizing changes that do not trigger a size event, and/or scrolled windows without
592 an interior sizer. This function similarly won't do anything if there are no
595 virtual void FitInside();
598 Freezes the window or, in other words, prevents any updates from taking
599 place on screen, the window is not redrawn at all.
601 Thaw() must be called to reenable window redrawing. Calls to these two
602 functions may be nested but to ensure that the window is properly
603 repainted again, you must thaw it exactly as many times as you froze
606 If the window has any children, they are recursively frozen too.
608 This method is useful for visual appearance optimization (for example,
609 it is a good idea to use it before doing many large text insertions in
610 a row into a wxTextCtrl under wxGTK) but is not implemented on all
611 platforms nor for all controls so it is mostly just a hint to wxWidgets
612 and not a mandatory directive.
614 @see wxWindowUpdateLocker, Thaw(), IsFrozen()
616 virtual void Freeze();
619 Gets the accelerator table for this window. See wxAcceleratorTable.
621 wxAcceleratorTable
* GetAcceleratorTable() const;
624 Returns the accessible object for this window, if any.
625 See also wxAccessible.
627 wxAccessible
* GetAccessible();
630 This method is deprecated, use GetEffectiveMinSize() instead.
632 wxSize
GetAdjustedBestSize() const;
635 Returns the background colour of the window.
637 @see SetBackgroundColour(), SetForegroundColour(),
638 GetForegroundColour()
640 wxColour
GetBackgroundColour() const;
643 Returns the background style of the window. The background style can be one of:
647 Use the default background, as determined by
648 the system or the current theme.
652 Use a solid colour for the background, this
653 style is set automatically if you call
654 SetBackgroundColour() so you only need to
655 set it explicitly if you had changed the background style to something else
660 Don't draw the background at all, it's
661 supposed that it is drawn by the user-defined erase background event handler.
662 This style should be used to avoid flicker when the background is entirely
665 wxBG_STYLE_TRANSPARET
667 The background is (partially) transparent,
668 this style is automatically set if you call
669 SetTransparent() which is used to set the
672 @see SetBackgroundColour(), GetForegroundColour(),
673 SetBackgroundStyle(), SetTransparent()
675 virtual wxBackgroundStyle
GetBackgroundStyle() const;
678 This functions returns the best acceptable minimal size for the window. For
679 example, for a static control, it will be the minimal size such that the
680 control label is not truncated. For windows containing subwindows (typically
681 wxPanel), the size returned by this function will be the
682 same as the size the window would have had after calling
685 wxSize
GetBestSize() const;
688 Returns the currently captured window.
690 @see HasCapture(), CaptureMouse(), ReleaseMouse(),
691 wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent
693 static wxWindow
* GetCapture();
696 Returns the caret() associated with the window.
698 wxCaret
* GetCaret() const;
701 Returns the character height for this window.
703 virtual int GetCharHeight() const;
706 Returns the average character width for this window.
708 virtual int GetCharWidth() const;
712 Returns a reference to the list of the window's children. @c wxWindowList
713 is a type-safe wxList-like class whose elements are of type @c wxWindow*.
715 wxWindowList
& GetChildren();
716 const wxWindowList
& GetChildren() const;
720 Returns the default font and colours which are used by the control. This is
721 useful if you want to use the same font or colour in your own control as in a
722 standard control -- which is a much better idea than hard coding specific
723 colours or fonts which might look completely out of place on the users
724 system, especially if it uses themes.
725 The @a variant parameter is only relevant under Mac currently and is
726 ignore under other platforms. Under Mac, it will change the size of the
727 returned font. See SetWindowVariant()
729 This static method is "overridden" in many derived classes and so calling,
730 for example, wxButton::GetClassDefaultAttributes() will typically
731 return the values appropriate for a button which will be normally different
732 from those returned by, say, wxListCtrl::GetClassDefaultAttributes().
733 The @c wxVisualAttributes structure has at least the fields
734 @c font, @c colFg and @c colBg. All of them may be invalid
735 if it was not possible to determine the default control appearance or,
736 especially for the background colour, if the field doesn't make sense as is
737 the case for @c colBg for the controls with themed background.
739 @see InheritAttributes()
741 static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
745 Returns the size of the window 'client area' in pixels. The client area is the
746 area which may be drawn on by the programmer, excluding title bar, border,
748 Note that if this window is a top-level one and it is currently minimized, the
749 return size is empty (both width and height are 0).
752 Receives the client width in pixels.
754 Receives the client height in pixels.
756 @see GetSize(), GetVirtualSize()
758 void GetClientSize(int* width
, int* height
) const;
759 wxSize
GetClientSize() const;
763 Returns a pointer to the window's layout constraints, or @NULL if there are none.
765 wxLayoutConstraints
* GetConstraints() const;
768 Return the sizer that this window is a member of, if any, otherwise
771 wxSizer
* GetContainingSizer() const;
774 Return the cursor associated with this window.
778 const wxCursor
& GetCursor() const;
781 Currently this is the same as calling
782 wxWindow::GetClassDefaultAttributes(wxWindow::GetWindowVariant()).
783 One advantage of using this function compared to the static version is that
784 the call is automatically dispatched to the correct class (as usual with
785 virtual functions) and you don't have to specify the class name explicitly.
786 The other one is that in the future this function could return different
787 results, for example it might return a different font for an "Ok" button
788 than for a generic button if the users GUI is configured to show such buttons
789 in bold font. Of course, the down side is that it is impossible to call this
790 function without actually having an object to apply it to whereas the static
791 version can be used without having to create an object first.
793 virtual wxVisualAttributes
GetDefaultAttributes() const;
796 Returns the associated drop target, which may be @NULL.
798 @see SetDropTarget(), @ref overview_dnd
800 wxDropTarget
* GetDropTarget() const;
803 Merges the window's best size into the min size and returns the result.
804 This is the value used by sizers to determine the appropriate
805 ammount of space to allocate for the widget.
807 @see GetBestSize(), SetInitialSize(), @ref overview_windowsizing
809 wxSize
GetEffectiveMinSize() const;
812 Returns the event handler for this window. By default, the window is its
815 @see SetEventHandler(), PushEventHandler(),
816 PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
818 wxEvtHandler
* GetEventHandler() const;
821 Returns the extra style bits for the window.
823 long GetExtraStyle() const;
826 Returns the font for this window.
830 wxFont
GetFont() const;
833 Returns the foreground colour of the window.
835 @remarks The interpretation of foreground colour is open to
836 interpretation according to the window class; it may be
837 the text colour or other colour, or it may not be used
840 @see SetForegroundColour(), SetBackgroundColour(),
841 GetBackgroundColour()
843 wxColour
GetForegroundColour();
846 Returns the grandparent of a window, or @NULL if there isn't one.
848 wxWindow
* GetGrandParent() const;
851 Returns the platform-specific handle of the physical window. Cast it to an
853 handle, such as @b HWND for Windows, @b Widget for Motif, @b GtkWidget for GTK
854 or @b WinHandle for PalmOS.
856 void* GetHandle() const;
859 Gets the help text to be used as context-sensitive help for this window.
860 Note that the text is actually stored by the current wxHelpProvider
862 and not in the window object itself.
864 @see SetHelpText(), GetHelpTextAtPoint(), wxHelpProvider
866 virtual wxString
GetHelpText() const;
869 Gets the help text to be used as context-sensitive help for this window. This
870 method should be overridden if the help message depends on the position inside
871 the window, otherwise GetHelpText() can be used.
874 Coordinates of the mouse at the moment of help event emission.
876 Help event origin, see also wxHelpEvent::GetOrigin.
878 virtual wxString
GetHelpTextAtPoint(const wxPoint point
,
879 wxHelpEvent::Origin origin
) const;
882 Returns the identifier of the window.
884 @remarks Each window has an integer identifier. If the application has
885 not provided one (or the default wxID_ANY) an unique
886 identifier with a negative value will be generated.
888 @see SetId(), @ref overview_windowids "Window identifiers"
893 Generic way of getting a label from any window, for
894 identification purposes.
896 @remarks The interpretation of this function differs from class to class.
897 For frames and dialogs, the value returned is the
898 title. For buttons or static text controls, it is the
899 button text. This function can be useful for
900 meta-programs (such as testing tools or special-needs
901 access programs) which need to identify windows by name.
903 virtual wxString
GetLabel() const;
906 Returns the maximum size of window's client area.
907 This is an indication to the sizer layout mechanism that this is the maximum
908 possible size as well as the upper bound on window's size settable using
913 wxSize
GetMaxClientSize() const;
916 Returns the maximum size of the window. This is an indication to the sizer
917 layout mechanism that this is the maximum possible size as well as the upper
918 bound on window's size settable using SetSize().
920 @see GetMaxClientSize()
922 wxSize
GetMaxSize() const;
925 Returns the minimum size of window's client area, an indication to the sizer
926 layout mechanism that this is the minimum required size of its client area. It
927 normally just returns the value set by
928 SetMinClientSize(), but it can be overridden
929 to do the calculation on demand.
933 virtual wxSize
GetMinClientSize() const;
936 Returns the minimum size of the window, an indication to the sizer layout
937 mechanism that this is the minimum required size.
939 This method normally just returns the value set by SetMinSize(), but it
940 can be overridden to do the calculation on demand.
942 @see GetMinClientSize()
944 virtual wxSize
GetMinSize() const;
947 Returns the window's name.
949 @remarks This name is not guaranteed to be unique; it is up to the
950 programmer to supply an appropriate name in the window
951 constructor or via SetName().
955 virtual wxString
GetName() const;
958 Returns the next window after this one among the parent children or @NULL if
959 this window is the last child.
963 @see GetPrevSibling()
965 wxWindow
* GetNextSibling() const;
968 Returns the parent of the window, or @NULL if there is no parent.
970 virtual wxWindow
* GetParent() const;
974 This function shows a popup menu at the given position in this window and
975 returns the selected id. It can be more convenient than the general purpose
976 PopupMenu() function for simple menus proposing a
977 choice in a list of strings to the user.
982 The position at which to show the menu in client coordinates
984 The horizontal position of the menu
986 The vertical position of the menu
988 @return The selected menu item id or wxID_NONE if none selected or an
991 int GetPopupMenuSelectionFromUser(wxMenu
& menu
,
993 int GetPopupMenuSelectionFromUser(wxMenu
& menu
, int x
, int y
);
998 This gets the position of the window in pixels, relative to the parent window
999 for the child windows or relative to the display origin for the top level
1003 Receives the x position of the window if non-@NULL.
1005 Receives the y position of the window if non-@NULL.
1007 @see GetScreenPosition()
1009 void GetPosition(int* x
, int* y
) const;
1010 wxPoint
GetPosition() const;
1014 Returns the previous window before this one among the parent children or @c
1016 this window is the first child.
1020 @see GetNextSibling()
1022 wxWindow
* GetPrevSibling() const;
1025 Returns the position and size of the window as a wxRect object.
1027 @see GetScreenRect()
1029 wxRect
GetRect() const;
1033 Returns the window position in screen coordinates, whether the window is a
1034 child window or a top level one.
1037 Receives the x position of the window on the screen if non-@NULL.
1039 Receives the y position of the window on the screen if non-@NULL.
1043 void GetScreenPosition(int* x
, int* y
) const;
1044 wxPoint
GetScreenPosition() const;
1048 Returns the position and size of the window on the screen as a
1053 wxRect
GetScreenRect() const;
1056 Returns the built-in scrollbar position.
1058 @see See SetScrollbar()
1060 virtual int GetScrollPos(int orientation
);
1063 Returns the built-in scrollbar range.
1067 virtual int GetScrollRange(int orientation
);
1070 Returns the built-in scrollbar thumb size.
1074 virtual int GetScrollThumb(int orientation
);
1078 Returns the size of the entire window in pixels, including title bar, border,
1080 Note that if this window is a top-level one and it is currently minimized, the
1081 returned size is the restored window size, not the size of the window icon.
1084 Receives the window width.
1086 Receives the window height.
1088 @see GetClientSize(), GetVirtualSize()
1090 void GetSize(int* width
, int* height
) const;
1091 const wxSize
GetSize() const;
1095 Return the sizer associated with the window by a previous call to
1096 SetSizer() or @NULL.
1098 wxSizer
* GetSizer() const;
1102 Gets the dimensions of the string as it would be drawn on the
1103 window with the currently selected font.
1104 The text extent is returned in @a w and @a h pointers (first form) or as a
1105 wxSize object (second form).
1108 String whose extent is to be measured.
1110 Return value for width.
1112 Return value for height.
1114 Return value for descent (optional).
1115 @param externalLeading
1116 Return value for external leading (optional).
1118 Font to use instead of the current window font (optional).
1120 If @true, string contains 16-bit characters. The default is @false.
1122 virtual void GetTextExtent(const wxString
& string
, int* w
,
1124 int* descent
= NULL
,
1125 int* externalLeading
= NULL
,
1126 const wxFont
* font
= NULL
,
1127 bool use16
= false) const;
1128 const wxSize
GetTextExtent(const wxString
& string
) const;
1132 Get the associated tooltip or @NULL if none.
1134 wxToolTip
* GetToolTip() const;
1137 Returns the region specifying which parts of the window have been damaged.
1139 only be called within an wxPaintEvent handler.
1141 @see wxRegion, wxRegionIterator
1143 virtual wxRegion
GetUpdateRegion() const;
1146 Returns a pointer to the current validator for the window, or @NULL if there is
1149 wxValidator
* GetValidator() const;
1153 This gets the virtual size of the window in pixels. By default it
1154 returns the client size of the window, but after a call to
1155 SetVirtualSize() it will return
1159 Receives the window virtual width.
1161 Receives the window virtual height.
1163 void GetVirtualSize(int* width
, int* height
) const;
1164 const wxSize
GetVirtualSize() const;
1168 Returns the size of the left/right and top/bottom borders of this window in x
1169 and y components of the result respectively.
1171 wxSize
GetWindowBorderSize() const;
1174 Gets the window style that was passed to the constructor or @b Create
1175 method. @b GetWindowStyle() is another name for the same function.
1177 long GetWindowStyleFlag() const;
1180 Returns the value previously passed to
1183 wxWindowVariant
GetWindowVariant() const;
1186 This function will generate the appropriate call to
1187 Navigate() if the key event is one normally used for
1188 keyboard navigation and return @true in this case.
1190 @return Returns @true if the key pressed was for navigation and was
1191 handled, @false otherwise.
1195 bool HandleAsNavigationKey(const wxKeyEvent
& event
);
1199 wxWindow::GetEventHandler()-wxEvtHandler::SafelyProcessEvent(event).
1201 bool HandleWindowEvent(wxEvent
& event
);
1204 Returns @true if this window has the current mouse capture.
1206 @see CaptureMouse(), ReleaseMouse(), wxMouseCaptureLostEvent,
1207 wxMouseCaptureChangedEvent
1209 virtual bool HasCapture() const;
1212 Returns @true if the window has the given @a exFlag bit set in its
1215 @see SetExtraStyle()
1217 bool HasExtraStyle(int exFlag
) const;
1220 Returns @true if the window has the given @a flag bit set.
1222 bool HasFlag(int flag
) const;
1225 Returns @true if the window (or in case of composite controls, its main
1226 child window) has focus.
1230 virtual bool HasFocus() const;
1233 This method should be overridden to return @true if this window has
1234 multiple pages. All standard class with multiple pages such as
1235 wxNotebook, wxListbook and
1236 wxTreebook already override it to return @true
1237 and user-defined classes with similar behaviour should do it as well to allow
1238 the library to handle such windows appropriately.
1240 virtual bool HasMultiplePages() const;
1243 Returns @true if this window has a scroll bar for this orientation.
1246 Orientation to check, either wxHORIZONTAL or wxVERTICAL.
1248 virtual bool HasScrollbar(int orient
) const;
1251 Returns @true if this window background is transparent (as, for example, for
1252 wxStaticText) and should show the parent window background.
1253 This method is mostly used internally by the library itself and you normally
1254 shouldn't have to call it. You may, however, have to override it in your
1255 wxWindow-derived class to ensure that background is painted correctly.
1257 virtual bool HasTransparentBackground() const;
1260 Equivalent to calling wxWindow::Show(@false).
1265 This function hides a window, like Hide(), but using a special visual
1268 The parameters of this function are the same as for ShowWithEffect(),
1269 please see their description there.
1273 virtual bool HideWithEffect(wxShowEffect effect
,
1274 unsigned timeout
= 0);
1277 This function is (or should be, in case of custom controls) called during
1278 window creation to intelligently set up the window visual attributes, that is
1279 the font and the foreground and background colours.
1280 By "intelligently" the following is meant: by default, all windows use their
1281 own @ref GetClassDefaultAttributes() default attributes. However
1282 if some of the parents attributes are explicitly (that is, using
1284 wxWindow::SetOwnFont) changed and if the
1285 corresponding attribute hadn't been explicitly set for this window itself,
1286 then this window takes the same value as used by the parent. In addition, if
1287 the window overrides ShouldInheritColours()
1288 to return @false, the colours will not be changed no matter what and only the
1290 This rather complicated logic is necessary in order to accommodate the
1291 different usage scenarios. The most common one is when all default attributes
1292 are used and in this case, nothing should be inherited as in modern GUIs
1293 different controls use different fonts (and colours) than their siblings so
1294 they can't inherit the same value from the parent. However it was also deemed
1295 desirable to allow to simply change the attributes of all children at once by
1296 just changing the font or colour of their common parent, hence in this case we
1297 do inherit the parents attributes.
1299 void InheritAttributes();
1302 Sends an @c wxEVT_INIT_DIALOG event, whose handler usually transfers data
1303 to the dialog via validators.
1308 Resets the cached best size value so it will be recalculated the next time it
1311 void InvalidateBestSize();
1314 Returns @true if the window contents is double-buffered by the system, i.e. if
1315 any drawing done on the window is really done on a temporary backing surface
1316 and transferred to the screen all at once later.
1320 virtual bool IsDoubleBuffered() const;
1323 Returns @true if the window is enabled, i.e. if it accepts user input, @c
1326 Notice that this method can return @false even if this window itself hadn't
1327 been explicitly disabled when one of its parent windows is disabled. To get the
1328 intrinsic status of this window, use
1333 virtual bool IsEnabled() const;
1337 Returns @true if the given point or rectangle area has been exposed since the
1338 last repaint. Call this in an paint event handler to optimize redrawing by
1339 only redrawing those areas, which have been exposed.
1341 bool IsExposed(int x
, int y
) const;
1342 const bool IsExposed(wxPoint amp
;pt
) const;
1343 const bool IsExposed(int x
, int y
, int w
, int h
) const;
1344 const bool IsExposed(wxRect amp
;rect
) const;
1348 Returns @true if the window is currently frozen by a call to
1351 @see Freeze(), Thaw()
1353 virtual bool IsFrozen() const;
1356 Returns @true if the window is retained, @false otherwise.
1358 @remarks Retained windows are only available on X platforms.
1360 virtual bool IsRetained() const;
1363 Return whether a scrollbar is always shown.
1366 Orientation to check, either wxHORIZONTAL or wxVERTICAL.
1368 @see AlwaysShowScrollbars()
1370 bool IsScrollbarAlwaysShown(int orient
);
1373 Returns @true if the window is shown, @false if it has been hidden.
1375 @see IsShownOnScreen()
1377 virtual bool IsShown() const;
1380 Returns @true if the window is physically visible on the screen, i.e. it
1381 is shown and all its parents up to the toplevel window are shown as well.
1385 virtual bool IsShownOnScreen() const;
1388 Returns @true if this window is intrinsically enabled, @false otherwise,
1390 if @ref Enable() Enable(@false) had been called. This method is
1391 mostly used for wxWidgets itself, user code should normally use
1392 IsEnabled() instead.
1394 bool IsThisEnabled() const;
1397 Returns @true if the given window is a top-level one. Currently all frames and
1398 dialogs are considered to be top-level windows (even if they have a parent
1401 bool IsTopLevel() const;
1404 Invokes the constraint-based layout algorithm or the sizer-based algorithm
1407 See SetAutoLayout(): when auto layout is on, this function gets called automatically
1408 when the window is resized.
1410 @see @ref overview_windowsizing
1415 Lowers the window to the bottom of the window hierarchy (Z-order).
1422 Disables all other windows in the application so that
1423 the user can only interact with this window.
1426 If @true, this call disables all other windows in the application so that
1427 the user can only interact with this window. If @false, the effect is
1430 virtual void MakeModal(bool flag
);
1434 Moves the window to the given position.
1437 Required x position.
1439 Required y position.
1441 wxPoint object representing the position.
1443 @remarks Implementations of SetSize can also implicitly implement the
1444 Move() function, which is defined in the base
1445 wxWindow class as the call:
1449 void Move(int x
, int y
);
1450 void Move(const wxPoint
& pt
);
1454 Moves this window in the tab navigation order after the specified @e win.
1455 This means that when the user presses @c TAB key on that other window,
1456 the focus switches to this window.
1457 Default tab order is the same as creation order, this function and
1458 MoveBeforeInTabOrder() allow to change
1459 it after creating all the windows.
1462 A sibling of this window which should precede it in tab order,
1465 void MoveAfterInTabOrder(wxWindow
* win
);
1468 Same as MoveAfterInTabOrder() except that
1469 it inserts this window just before @a win instead of putting it right after
1472 void MoveBeforeInTabOrder(wxWindow
* win
);
1475 Performs a keyboard navigation action starting from this window. This method is
1476 equivalent to calling NavigateIn() method on the
1480 A combination of wxNavigationKeyEvent::IsForward and
1481 wxNavigationKeyEvent::WinChange.
1483 @return Returns @true if the focus was moved to another window or @false
1486 @remarks You may wish to call this from a text control custom keypress
1487 handler to do the default navigation behaviour for the
1488 tab key, since the standard default behaviour for a
1489 multiline text control with the wxTE_PROCESS_TAB style
1490 is to insert a tab and not navigate to the next
1491 control. See also wxNavigationKeyEvent and
1492 HandleAsNavigationKey.
1494 bool Navigate(int flags
= wxNavigationKeyEvent::IsForward
);
1497 Performs a keyboard navigation action inside this window.
1498 See Navigate() for more information.
1500 bool NavigateIn(int flags
= wxNavigationKeyEvent::IsForward
);
1503 Create a new ID or range of IDs that are not currently in use. The
1504 IDs will be reserved until assigned to a wxWindowIDRef()
1505 or unreserved with UnreserveControlId().
1506 See @ref overview_windowids "Window IDs Overview" for more information.
1509 The number of sequential IDs to reserve.
1511 @return Returns the ID or the first ID of the range, or wxID_NONE if the
1512 specified number of identifiers couldn't be allocated.
1514 @see UnreserveControlId(), wxIdManager, @ref overview_windowids
1515 "Window IDs Overview"
1517 static wxWindowID
NewControlId(int count
= 1);
1520 This virtual function is normally only used internally, but
1521 sometimes an application may need it to implement functionality
1522 that should not be disabled by an application defining an OnIdle
1523 handler in a derived class.
1524 This function may be used to do delayed painting, for example,
1525 and most implementations call UpdateWindowUI()
1526 in order to send update events to the window in idle time.
1528 virtual void OnInternalIdle();
1531 Same as #ScrollLines (-1).
1536 Same as #ScrollLines (1).
1541 Same as #ScrollPages (-1).
1546 Same as #ScrollPages (1).
1552 Removes and returns the top-most event handler on the event handler stack.
1554 @param deleteHandler
1555 If this is @true, the handler will be deleted after it is removed. The
1556 default value is @false.
1558 @see SetEventHandler(), GetEventHandler(),
1559 PushEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
1561 wxEvtHandler
* PopEventHandler(bool deleteHandler
= false) const;
1565 Pops up the given menu at the specified coordinates, relative to this
1566 window, and returns control when the user has dismissed the menu. If a
1567 menu item is selected, the corresponding menu event is generated and will be
1568 processed as usually. If the coordinates are not specified, current mouse
1569 cursor position is used.
1574 The position where the menu will appear.
1576 Required x position for the menu to appear.
1578 Required y position for the menu to appear.
1580 @remarks Just before the menu is popped up, wxMenu::UpdateUI is called to
1581 ensure that the menu items are in the correct state.
1582 The menu does not get deleted by the window.
1586 bool PopupMenu(wxMenu
* menu
,
1587 const wxPoint
& pos
= wxDefaultPosition
);
1588 bool PopupMenu(wxMenu
* menu
, int x
, int y
);
1592 Pushes this event handler onto the event stack for the window.
1595 Specifies the handler to be pushed.
1597 @remarks An event handler is an object that is capable of processing the
1598 events sent to a window. By default, the window is its
1599 own event handler, but an application may wish to
1600 substitute another, for example to allow central
1601 implementation of event-handling for a variety of
1602 different window classes.
1604 @see SetEventHandler(), GetEventHandler(),
1605 PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
1607 void PushEventHandler(wxEvtHandler
* handler
);
1610 Raises the window to the top of the window hierarchy (Z-order).
1611 In current version of wxWidgets this works both for managed and child windows.
1618 Causes this window, and all of its children recursively (except under wxGTK1
1619 where this is not implemented), to be repainted. Note that repainting doesn't
1620 happen immediately but only during the next event loop iteration, if you need
1621 to update the window immediately you should use Update()
1624 @param eraseBackground
1625 If @true, the background will be
1628 If non-@NULL, only the given rectangle will
1629 be treated as damaged.
1633 virtual void Refresh(bool eraseBackground
= true,
1634 const wxRect
* rect
= NULL
);
1637 Redraws the contents of the given rectangle: only the area inside it will be
1639 This is the same as Refresh() but has a nicer syntax
1640 as it can be called with a temporary wxRect object as argument like this
1641 @c RefreshRect(wxRect(x, y, w, h)).
1643 void RefreshRect(const wxRect
& rect
, bool eraseBackground
= true);
1646 Registers a system wide hotkey. Every time the user presses the hotkey
1647 registered here, this window
1648 will receive a hotkey event. It will receive the event even if the application
1649 is in the background
1650 and does not have the input focus because the user is working with some other
1654 Numeric identifier of the hotkey. For applications this must be between 0
1656 this function is called from a shared DLL, it must be a system wide unique
1657 identifier between 0xC000 and 0xFFFF.
1658 This is a MSW specific detail.
1660 A bitwise combination of wxMOD_SHIFT, wxMOD_CONTROL, wxMOD_ALT
1661 or wxMOD_WIN specifying the modifier keys that have to be pressed along
1663 @param virtualKeyCode
1664 The virtual key code of the hotkey.
1666 @return @true if the hotkey was registered successfully. @false if some
1667 other application already registered a hotkey with this
1668 modifier/virtualKeyCode combination.
1670 @remarks Use EVT_HOTKEY(hotkeyId, fnc) in the event table to capture the
1671 event. This function is currently only implemented
1672 under Windows. It is used in the Windows CE port for
1673 detecting hardware button presses.
1675 @see UnregisterHotKey()
1677 bool RegisterHotKey(int hotkeyId
, int modifiers
,
1678 int virtualKeyCode
);
1681 Releases mouse input captured with CaptureMouse().
1683 @see CaptureMouse(), HasCapture(), ReleaseMouse(),
1684 wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent
1686 virtual void ReleaseMouse();
1689 Removes a child window. This is called automatically by window deletion
1690 functions so should not be required by the application programmer.
1691 Notice that this function is mostly internal to wxWidgets and shouldn't be
1692 called by the user code.
1695 Child window to remove.
1697 virtual void RemoveChild(wxWindow
* child
);
1700 Find the given @a handler in the windows event handler chain and remove (but
1701 not delete) it from it.
1704 The event handler to remove, must be non-@NULL and
1705 must be present in this windows event handlers chain
1707 @return Returns @true if it was found and @false otherwise (this also
1708 results in an assert failure so this function should
1709 only be called when the handler is supposed to be
1712 @see PushEventHandler(), PopEventHandler()
1714 bool RemoveEventHandler(wxEvtHandler
* handler
);
1717 Reparents the window, i.e the window will be removed from its
1718 current parent window (e.g. a non-standard toolbar in a wxFrame)
1719 and then re-inserted into another.
1724 virtual bool Reparent(wxWindow
* newParent
);
1728 Converts from screen to client window coordinates.
1731 Stores the screen x coordinate and receives the client x coordinate.
1733 Stores the screen x coordinate and receives the client x coordinate.
1735 The screen position for the second form of the function.
1737 virtual void ScreenToClient(int* x
, int* y
) const;
1738 const virtual wxPoint
ScreenToClient(const wxPoint
& pt
) const;
1742 Scrolls the window by the given number of lines down (if @a lines is
1745 @return Returns @true if the window was scrolled, @false if it was already
1746 on top/bottom and nothing was done.
1748 @remarks This function is currently only implemented under MSW and
1749 wxTextCtrl under wxGTK (it also works for wxScrolled classes
1750 under all platforms).
1754 virtual bool ScrollLines(int lines
);
1757 Scrolls the window by the given number of pages down (if @a pages is
1760 @return Returns @true if the window was scrolled, @false if it was already
1761 on top/bottom and nothing was done.
1763 @remarks This function is currently only implemented under MSW and wxGTK.
1767 virtual bool ScrollPages(int pages
);
1770 Physically scrolls the pixels in the window and move child windows accordingly.
1773 Amount to scroll horizontally.
1775 Amount to scroll vertically.
1777 Rectangle to scroll, if it is @NULL, the whole window is
1778 scrolled (this is always the case under wxGTK which doesn't support this
1781 @remarks Note that you can often use wxScrolled instead of using this
1784 virtual void ScrollWindow(int dx
, int dy
,
1785 const wxRect
* rect
= NULL
);
1788 This function sends a dummy @ref overview_wxsizeevent "size event" to
1789 the window allowing it to re-layout its children positions.
1791 It is sometimes useful to call this function after adding or deleting a
1792 children after the frame creation or if a child size changes. Note that
1793 if the frame is using either sizers or constraints for the children
1794 layout, it is enough to call wxWindow::Layout() directly and this
1795 function should not be used in this case.
1797 void SendSizeEvent();
1800 Safe wrapper for GetParent()->SendSizeEvent().
1802 This function simply checks that the window has a valid parent which is
1803 not in process of being deleted and calls SendSizeEvent() on it. It is
1804 used internally by windows such as toolbars changes to whose state
1805 should result in parent re-layout (e.g. when a toolbar is added to the
1806 top of the window, all the other windows must be shifted down).
1808 void SendSizeEventToParent();
1811 Sets the accelerator table for this window. See wxAcceleratorTable.
1813 virtual void SetAcceleratorTable(const wxAcceleratorTable
& accel
);
1816 Sets the accessible for this window. Any existing accessible for this window
1817 will be deleted first, if not identical to @e accessible.
1818 See also wxAccessible.
1820 void SetAccessible(wxAccessible
* accessible
);
1823 Determines whether the Layout() function will
1824 be called automatically when the window is resized. Please note that this only
1825 happens for the windows usually used to contain children, namely
1826 wxPanel and wxTopLevelWindow
1827 (and the classes deriving from them).
1828 This method is called implicitly by
1829 SetSizer() but if you use
1830 SetConstraints() you should call it
1831 manually or otherwise the window layout won't be correctly updated when its
1835 Set this to @true if you wish the Layout function to be
1836 called automatically when the window is resized.
1838 @see SetConstraints()
1840 void SetAutoLayout(bool autoLayout
);
1843 Sets the background colour of the window.
1844 Please see InheritAttributes() for
1845 explanation of the difference between this method and
1846 SetOwnBackgroundColour().
1849 The colour to be used as the background colour, pass
1850 wxNullColour to reset to the default colour.
1852 @remarks The background colour is usually painted by the default
1853 wxEraseEvent event handler function under Windows and
1854 automatically under GTK.
1856 @see GetBackgroundColour(), SetForegroundColour(),
1857 GetForegroundColour(), ClearBackground(),
1858 Refresh(), wxEraseEvent
1860 virtual bool SetBackgroundColour(const wxColour
& colour
);
1863 Sets the background style of the window. see
1864 GetBackgroundStyle() for the description
1865 of the possible style values.
1867 @see SetBackgroundColour(), GetForegroundColour(),
1870 virtual void SetBackgroundStyle(wxBackgroundStyle style
);
1873 This method is only implemented by ports which have support for
1874 native TAB traversal (such as GTK+ 2.0). It is called by wxWidgets'
1875 container control code to give the native system a hint when
1876 doing TAB traversal. A call to this does not disable or change
1877 the effect of programmatically calling
1880 @see wxFocusEvent, wxPanel::SetFocus, wxPanel::SetFocusIgnoringChildren
1882 virtual void SetCanFocus(bool canFocus
);
1885 Sets the caret() associated with the window.
1887 void SetCaret(wxCaret
* caret
) const;
1891 This sets the size of the window client area in pixels. Using this function to
1893 tends to be more device-independent than SetSize(), since the application need
1895 worry about what dimensions the border or title bar have when trying to fit the
1897 around panel items, for example.
1900 The required client area width.
1902 The required client area height.
1904 The required client size.
1906 virtual void SetClientSize(int width
, int height
);
1907 virtual void SetClientSize(const wxSize
& size
);
1911 Sets the window to have the given layout constraints. The window
1912 will then own the object, and will take care of its deletion.
1913 If an existing layout constraints object is already owned by the
1914 window, it will be deleted.
1917 The constraints to set. Pass @NULL to disassociate and delete the window's
1920 @remarks You must call SetAutoLayout() to tell a window to use
1921 the constraints automatically in OnSize; otherwise, you
1922 must override OnSize and call Layout() explicitly. When
1923 setting both a wxLayoutConstraints and a wxSizer, only
1924 the sizer will have effect.
1926 void SetConstraints(wxLayoutConstraints
* constraints
);
1929 This normally does not need to be called by user code. It is called
1930 when a window is added to a sizer, and is used so the window can
1931 remove itself from the sizer when it is destroyed.
1933 void SetContainingSizer(wxSizer
* sizer
);
1936 Sets the window's cursor. Notice that the window cursor also sets it for the
1937 children of the window implicitly.
1938 The @a cursor may be @c wxNullCursor in which case the window cursor will
1939 be reset back to default.
1942 Specifies the cursor that the window should normally display.
1944 @see ::wxSetCursor, wxCursor
1946 virtual void SetCursor(const wxCursor
& cursor
);
1949 Associates a drop target with this window.
1950 If the window already has a drop target, it is deleted.
1952 @see GetDropTarget(), @ref overview_dnd
1954 void SetDropTarget(wxDropTarget
* target
);
1957 Sets the event handler for this window.
1960 Specifies the handler to be set.
1962 @remarks An event handler is an object that is capable of processing the
1963 events sent to a window. By default, the window is its
1964 own event handler, but an application may wish to
1965 substitute another, for example to allow central
1966 implementation of event-handling for a variety of
1967 different window classes.
1969 @see GetEventHandler(), PushEventHandler(),
1970 PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
1972 void SetEventHandler(wxEvtHandler
* handler
);
1975 Sets the extra style bits for the window. The currently defined extra style
1978 @b wxWS_EX_VALIDATE_RECURSIVELY
1980 TransferDataTo/FromWindow()
1981 and Validate() methods will recursively descend into all children of the
1982 window if it has this style flag set.
1984 @b wxWS_EX_BLOCK_EVENTS
1986 Normally, the command
1987 events are propagated upwards to the window parent recursively until a handler
1988 for them is found. Using this style allows to prevent them from being
1989 propagated beyond this window. Notice that wxDialog has this style on by
1990 default for the reasons explained in the
1991 @ref overview_eventhandling "Event Handling Overview".
1993 @b wxWS_EX_TRANSIENT
1995 This can be used to prevent a
1996 window from being used as an implicit parent for the dialogs which were
1997 created without a parent. It is useful for the windows which can disappear at
1998 any moment as creating children of such windows results in fatal problems.
2000 @b wxWS_EX_CONTEXTHELP
2002 Under Windows, puts a query
2003 button on the caption. When pressed, Windows will go into a context-sensitive
2004 help mode and wxWidgets will send a wxEVT_HELP event if the user clicked on an
2006 This style cannot be used together with wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so
2007 these two styles are automatically turned of if this one is used.
2009 @b wxWS_EX_PROCESS_IDLE
2011 This window should always process idle events, even
2012 if the mode set by wxIdleEvent::SetMode is wxIDLE_PROCESS_SPECIFIED.
2014 @b wxWS_EX_PROCESS_UI_UPDATES
2016 This window should always process UI update events,
2017 even if the mode set by wxUpdateUIEvent::SetMode is
2018 wxUPDATE_UI_PROCESS_SPECIFIED.
2020 void SetExtraStyle(long exStyle
);
2023 This sets the window to receive keyboard input.
2025 @see HasFocus(), wxFocusEvent, wxPanel::SetFocus,
2026 wxPanel::SetFocusIgnoringChildren
2028 virtual void SetFocus();
2031 This function is called by wxWidgets keyboard navigation code when the user
2032 gives the focus to this window from keyboard (e.g. using @c TAB key).
2033 By default this method simply calls SetFocus() but
2034 can be overridden to do something in addition to this in the derived classes.
2036 virtual void SetFocusFromKbd();
2039 Sets the font for this window. This function should not be called for the
2040 parent window if you don't want its font to be inherited by its children,
2041 use SetOwnFont() instead in this case and
2042 see InheritAttributes() for more
2044 Please notice that the given font is not automatically used for
2045 wxPaintDC objects associated with this window, you need to
2046 call wxDC::SetFont too. However this font is used by
2047 any standard controls for drawing their text as well as by
2051 Font to associate with this window, pass
2052 wxNullFont to reset to the default font.
2054 @return @true if the want was really changed, @false if it was already set
2055 to this font and so nothing was done.
2057 @see GetFont(), InheritAttributes()
2059 bool SetFont(const wxFont
& font
);
2062 Sets the foreground colour of the window.
2063 Please see InheritAttributes() for
2064 explanation of the difference between this method and
2065 SetOwnForegroundColour().
2068 The colour to be used as the foreground colour, pass
2069 wxNullColour to reset to the default colour.
2071 @remarks The interpretation of foreground colour is open to
2072 interpretation according to the window class; it may be
2073 the text colour or other colour, or it may not be used
2076 @see GetForegroundColour(), SetBackgroundColour(),
2077 GetBackgroundColour(), ShouldInheritColours()
2079 virtual void SetForegroundColour(const wxColour
& colour
);
2082 Sets the help text to be used as context-sensitive help for this window.
2083 Note that the text is actually stored by the current wxHelpProvider
2085 and not in the window object itself.
2087 @see GetHelpText(), wxHelpProvider::AddHelp()
2089 virtual void SetHelpText(const wxString
& helpText
);
2092 Sets the identifier of the window.
2094 @remarks Each window has an integer identifier. If the application has
2095 not provided one, an identifier will be generated.
2096 Normally, the identifier should be provided on creation
2097 and should not be modified subsequently.
2099 @see GetId(), @ref overview_windowids "Window identifiers"
2104 Sets the initial window size if none is given (i.e. at least one of the
2105 components of the size passed to ctor/Create() is wxDefaultCoord).
2107 virtual void SetInitialBestSize(const wxSize
& size
);
2110 A @e smart SetSize that will fill in default size components with the
2111 window's @e best size values.
2113 Also sets the window's minsize to the value passed in for use with sizers.
2114 This means that if a full or partial size is passed to this function then
2115 the sizers will use that size instead of the results of GetBestSize() to
2116 determine the minimum needs of the window for layout.
2118 Most controls will use this to set their initial size, and their min
2119 size to the passed in value (if any.)
2121 @see SetSize(), GetBestSize(), GetEffectiveMinSize(),
2122 @ref overview_windowsizing
2124 void SetInitialSize(const wxSize
& size
= wxDefaultSize
);
2127 Sets the window's label.
2134 virtual void SetLabel(const wxString
& label
);
2137 Sets the maximum client size of the window, to indicate to the sizer
2138 layout mechanism that this is the maximum possible size of its client area.
2142 void SetMaxClientSize(const wxSize
& size
);
2145 Sets the maximum size of the window, to indicate to the sizer layout mechanism
2146 that this is the maximum possible size.
2148 @see SetMaxClientSize()
2150 void SetMaxSize(const wxSize
& size
);
2153 Sets the minimum client size of the window, to indicate to the sizer
2154 layout mechanism that this is the minimum required size of window's client
2157 You may need to call this if you change the window size after
2158 construction and before adding to its parent sizer.
2160 Note, that just as with SetMinSize(), calling this method doesn't
2161 prevent the program from explicitly making the window smaller than the
2166 void SetMinClientSize(const wxSize
& size
);
2169 Sets the minimum size of the window, to indicate to the sizer layout
2170 mechanism that this is the minimum required size.
2172 You may need to call this if you change the window size after
2173 construction and before adding to its parent sizer.
2175 Notice that calling this method doesn't prevent the program from making
2176 the window explicitly smaller than the specified size by calling
2177 SetSize(), it just ensures that it won't become smaller than this size
2178 during the automatic layout.
2180 @see SetMinClientSize()
2182 void SetMinSize(const wxSize
& size
);
2185 Sets the window's name.
2188 A name to set for the window.
2192 virtual void SetName(const wxString
& name
);
2195 Sets the background colour of the window but prevents it from being inherited
2196 by the children of this window.
2198 @see SetBackgroundColour(), InheritAttributes()
2200 void SetOwnBackgroundColour(const wxColour
& colour
);
2203 Sets the font of the window but prevents it from being inherited by the
2204 children of this window.
2206 @see SetFont(), InheritAttributes()
2208 void SetOwnFont(const wxFont
& font
);
2211 Sets the foreground colour of the window but prevents it from being inherited
2212 by the children of this window.
2214 @see SetForegroundColour(), InheritAttributes()
2216 void SetOwnForegroundColour(const wxColour
& colour
);
2219 Obsolete - use wxDC::SetPalette instead.
2221 virtual void SetPalette(wxPalette
* palette
);
2224 Sets the position of one of the built-in scrollbars.
2227 Determines the scrollbar whose position is to be set. May be wxHORIZONTAL
2230 Position in scroll units.
2232 @true to redraw the scrollbar, @false otherwise.
2234 @remarks This function does not directly affect the contents of the
2235 window: it is up to the application to take note of
2236 scrollbar attributes and redraw contents accordingly.
2238 @see SetScrollbar(), GetScrollPos(), GetScrollThumb(), wxScrollBar,
2241 virtual void SetScrollPos(int orientation
, int pos
,
2242 bool refresh
= true);
2245 Sets the scrollbar properties of a built-in scrollbar.
2248 Determines the scrollbar whose page size is to be set. May be wxHORIZONTAL
2251 The position of the scrollbar in scroll units.
2253 The size of the thumb, or visible portion of the scrollbar, in scroll units.
2255 The maximum position of the scrollbar.
2257 @true to redraw the scrollbar, @false otherwise.
2259 @remarks Let's say you wish to display 50 lines of text, using the same
2260 font. The window is sized so that you can only see 16
2263 @see @ref overview_scrolling, wxScrollBar, wxScrolled, wxScrollWinEvent
2265 virtual void SetScrollbar(int orientation
, int position
,
2268 bool refresh
= true);
2272 Sets the size of the window in pixels.
2275 Required x position in pixels, or wxDefaultCoord to indicate that the
2277 value should be used.
2279 Required y position in pixels, or wxDefaultCoord to indicate that the
2281 value should be used.
2283 Required width in pixels, or wxDefaultCoord to indicate that the existing
2284 value should be used.
2286 Required height position in pixels, or wxDefaultCoord to indicate that the
2288 value should be used.
2290 wxSize object for setting the size.
2292 wxRect object for setting the position and size.
2294 Indicates the interpretation of other parameters. It is a bit list of the
2296 wxSIZE_AUTO_WIDTH: a wxDefaultCoord width value is taken to indicate
2297 a wxWidgets-supplied default width.
2299 wxSIZE_AUTO_HEIGHT: a wxDefaultCoord height value is taken to indicate
2300 a wxWidgets-supplied default height.
2302 wxSIZE_AUTO: wxDefaultCoord size values are taken to indicate
2303 a wxWidgets-supplied default size.
2305 wxSIZE_USE_EXISTING: existing dimensions should be used
2306 if wxDefaultCoord values are supplied.
2308 wxSIZE_ALLOW_MINUS_ONE: allow negative dimensions (i.e. value of
2309 wxDefaultCoord) to be interpreted
2310 as real dimensions, not default values.
2311 wxSIZE_FORCE: normally, if the position and the size of the window are
2312 already the same as the parameters of this function, nothing is done. but
2314 this flag a window resize may be forced even in this case (supported in wx
2315 2.6.2 and later and only implemented for MSW and ignored elsewhere
2318 @remarks The second form is a convenience for calling the first form with
2319 default x and y parameters, and must be used with
2320 non-default width and height values.
2324 virtual void SetSize(int x
, int y
, int width
, int height
,
2325 int sizeFlags
= wxSIZE_AUTO
);
2326 virtual void SetSize(const wxRect
& rect
);
2327 virtual void SetSize(int width
, int height
);
2328 virtual void SetSize(const wxSize
& size
);
2332 Sets the window to have the given layout sizer. The window
2333 will then own the object, and will take care of its deletion.
2334 If an existing layout constraints object is already owned by the
2335 window, it will be deleted if the deleteOld parameter is @true.
2336 Note that this function will also call
2337 SetAutoLayout() implicitly with @true
2338 parameter if the @a sizer is non-@NULL and @false otherwise.
2341 The sizer to set. Pass @NULL to disassociate and conditionally delete
2342 the window's sizer. See below.
2344 If @true (the default), this will delete any pre-existing sizer.
2345 Pass @false if you wish to handle deleting the old sizer yourself.
2346 @remarks SetSizer enables and disables Layout automatically.
2348 void SetSizer(wxSizer
* sizer
, bool deleteOld
= true);
2351 This method calls SetSizer() and then
2352 wxSizer::SetSizeHints which sets the initial
2353 window size to the size needed to accommodate all sizer elements and sets the
2354 size hints which, if this window is a top level one, prevent the user from
2355 resizing it to be less than this minimial size.
2357 void SetSizerAndFit(wxSizer
* sizer
, bool deleteOld
= true);
2360 This function tells a window if it should use the system's "theme" code
2361 to draw the windows' background instead if its own background drawing
2362 code. This does not always have any effect since the underlying platform
2363 obviously needs to support the notion of themes in user defined windows.
2364 One such platform is GTK+ where windows can have (very colourful) backgrounds
2365 defined by a user's selected theme.
2366 Dialogs, notebook pages and the status bar have this flag set to @true
2367 by default so that the default look and feel is simulated best.
2369 virtual void SetThemeEnabled(bool enable
);
2373 Attach a tooltip to the window.
2374 See also: GetToolTip(),
2377 void SetToolTip(const wxString
& tip
);
2378 void SetToolTip(wxToolTip
* tip
);
2382 Set the transparency of the window. If the system supports transparent windows,
2383 returns @true, otherwise returns @false and the window remains fully opaque.
2384 See also CanSetTransparent().
2385 The parameter @a alpha is in the range 0..255 where 0 corresponds to a
2386 fully transparent window and 255 to the fully opaque one. The constants
2387 @c wxIMAGE_ALPHA_TRANSPARENT and @c wxIMAGE_ALPHA_OPAQUE can be
2390 bool SetTransparent(wxByte alpha
);
2393 Deletes the current validator (if any) and sets the window validator, having
2394 called wxValidator::Clone to
2395 create a new validator of this type.
2397 virtual void SetValidator(const wxValidator
& validator
);
2401 Sets the virtual size of the window in pixels.
2403 void SetVirtualSize(int width
, int height
);
2404 void SetVirtualSize(const wxSize
& size
);
2408 Identical to SetWindowStyleFlag().
2410 void SetWindowStyle(long style
);
2413 Sets the style of the window. Please note that some styles cannot be changed
2414 after the window creation and that Refresh() might
2415 need to be be called after changing the others for the change to take place
2417 See @ref overview_windowstyles "Window styles" for more information about flags.
2419 @see GetWindowStyleFlag()
2421 virtual void SetWindowStyleFlag(long style
);
2424 This function can be called under all platforms but only does anything under
2425 Mac OS X 10.3+ currently. Under this system, each of the standard control can
2426 exist in several sizes which correspond to the elements of wxWindowVariant
2429 By default the controls use the normal size, of course, but this function can
2430 be used to change this.
2432 void SetWindowVariant(wxWindowVariant variant
);
2435 Return @true from here to allow the colours of this window to be changed by
2436 InheritAttributes(), returning @false
2437 forbids inheriting them from the parent window.
2438 The base class version returns @false, but this method is overridden in
2439 wxControl where it returns @true.
2441 virtual bool ShouldInheritColours();
2444 Shows or hides the window. You may need to call Raise()
2445 for a top level window if you want to bring it to top, although this is not
2446 needed if Show() is called immediately after the frame creation.
2449 If @true displays the window. Otherwise, hides it.
2451 @return @true if the window has been shown or hidden or @false if nothing
2452 was done because it already was in the requested state.
2454 @see IsShown(), Hide(), wxRadioBox::Show, wxShowEvent.
2456 virtual bool Show(bool show
= true);
2459 This function shows a window, like Show(), but using a special visual
2466 The @a timeout parameter specifies the time of the animation, in
2467 milliseconds. If the default value of 0 is used, the default
2468 animation time for the current platform is used.
2470 @note Currently this function is only implemented in wxMSW and does the
2471 same thing as Show() in the other ports.
2475 @see HideWithEffect()
2477 virtual bool ShowWithEffect(wxShowEffect effect
,
2478 unsigned timeout
= 0);
2481 Reenables window updating after a previous call to Freeze().
2483 To really thaw the control, it must be called exactly the same number
2484 of times as Freeze().
2486 If the window has any children, they are recursively thawn too.
2488 @see wxWindowUpdateLocker, Freeze(), IsFrozen()
2490 virtual void Thaw();
2493 Turns the given @a flag on if it's currently turned off and vice versa.
2494 This function cannot be used if the value of the flag is 0 (which is often
2495 the case for default flags).
2496 Also, please notice that not all styles can be changed after the control
2499 @return Returns @true if the style was turned on by this function, @false
2500 if it was switched off.
2502 @see SetWindowStyleFlag(), HasFlag()
2504 bool ToggleWindowStyle(int flag
);
2507 Transfers values from child controls to data areas specified by their
2509 @false if a transfer failed.
2510 If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
2511 the method will also call TransferDataFromWindow() of all child windows.
2513 @see TransferDataToWindow(), wxValidator, Validate()
2515 virtual bool TransferDataFromWindow();
2518 Transfers values to child controls from data areas specified by their
2520 If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
2521 the method will also call TransferDataToWindow() of all child windows.
2523 @return Returns @false if a transfer failed.
2525 @see TransferDataFromWindow(), wxValidator, Validate()
2527 virtual bool TransferDataToWindow();
2530 Unregisters a system wide hotkey.
2533 Numeric identifier of the hotkey. Must be the same id that was passed to
2536 @return @true if the hotkey was unregistered successfully, @false if the
2539 @remarks This function is currently only implemented under MSW.
2541 @see RegisterHotKey()
2543 bool UnregisterHotKey(int hotkeyId
);
2546 Unreserve an ID or range of IDs that was reserved by NewControlId().
2547 See @ref overview_windowids "Window IDs Overview" for more information.
2550 The starting ID of the range of IDs to unreserve.
2552 The number of sequential IDs to unreserve.
2554 @see NewControlId(), wxIdManager, @ref overview_windowids
2555 "Window IDs Overview"
2557 static void UnreserveControlId(wxWindowID id
, int count
= 1);
2560 Calling this method immediately repaints the invalidated area of the window and
2561 all of its children recursively while this would usually only happen when the
2562 flow of control returns to the event loop.
2563 Notice that this function doesn't invalidate any area of the window so
2564 nothing happens if nothing has been invalidated (i.e. marked as requiring
2565 a redraw). Use Refresh() first if you want to
2566 immediately redraw the window unconditionally.
2568 virtual void Update();
2571 This function sends wxUpdateUIEvents() to
2572 the window. The particular implementation depends on the window; for
2573 example a wxToolBar will send an update UI event for each toolbar button,
2574 and a wxFrame will send an update UI event for each menubar menu item.
2575 You can call this function from your application to ensure that your
2576 UI is up-to-date at this point (as far as your wxUpdateUIEvent handlers
2577 are concerned). This may be necessary if you have called
2578 wxUpdateUIEvent::SetMode or
2579 wxUpdateUIEvent::SetUpdateInterval to
2580 limit the overhead that wxWidgets incurs by sending update UI events in idle
2582 @a flags should be a bitlist of one or more of the following values.
2584 If you are calling this function from an OnInternalIdle or OnIdle
2585 function, make sure you pass the wxUPDATE_UI_FROMIDLE flag, since
2586 this tells the window to only update the UI elements that need
2587 to be updated in idle time. Some windows update their elements
2588 only when necessary, for example when a menu is about to be shown.
2589 The following is an example of how to call UpdateWindowUI from
2592 @see wxUpdateUIEvent, DoUpdateWindowUI(), OnInternalIdle()
2594 virtual void UpdateWindowUI(long flags
= wxUPDATE_UI_NONE
);
2597 Validates the current values of the child controls using their validators.
2598 If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
2599 the method will also call Validate() of all child windows.
2601 @return Returns @false if any of the validations failed.
2603 @see TransferDataFromWindow(), TransferDataToWindow(),
2606 virtual bool Validate();
2609 Moves the pointer to the given position on the window.
2610 @note This function is not supported under Mac because Apple Human
2611 Interface Guidelines forbid moving the mouse cursor programmatically.
2614 The new x position for the cursor.
2616 The new y position for the cursor.
2618 void WarpPointer(int x
, int y
);
2622 /// Valid values for wxWindow::ShowWithEffect() and wxWindow::HideWithEffect().
2625 /// Roll window to the left
2626 wxSHOW_EFFECT_ROLL_TO_LEFT
,
2627 /// Roll window to the right
2628 wxSHOW_EFFECT_ROLL_TO_RIGHT
,
2629 /// Roll window to the top
2630 wxSHOW_EFFECT_ROLL_TO_TOP
,
2631 /// Roll window to the bottom
2632 wxSHOW_EFFECT_ROLL_TO_BOTTOM
,
2633 /// Slide window to the left
2634 wxSHOW_EFFECT_SLIDE_TO_LEFT
,
2635 /// Slide window to the right
2636 wxSHOW_EFFECT_SLIDE_TO_RIGHT
,
2637 /// Slide window to the top
2638 wxSHOW_EFFECT_SLIDE_TO_TOP
,
2639 /// Slide window to the bottom
2640 wxSHOW_EFFECT_SLIDE_TO_BOTTOM
,
2641 /// Fade in or out effect
2642 wxSHOW_EFFECT_BLEND
,
2643 /// Expanding or collapsing effect
2644 wxSHOW_EFFECT_EXPAND
2649 // ============================================================================
2650 // Global functions/macros
2651 // ============================================================================
2653 /** @ingroup group_funcmacro_misc */
2657 Find the deepest window at the mouse pointer position, returning the window
2658 and current pointer position in screen coordinates.
2660 @header{wx/window.h}
2662 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
);
2665 Gets the currently active window (implemented for MSW and GTK only
2666 currently, always returns @NULL in the other ports).
2668 @header{wx/window.h}
2670 wxWindow
* wxGetActiveWindow();
2673 Returns the first top level parent of the given window, or in other words,
2674 the frame or dialog containing it, or @NULL.
2676 @header{wx/window.h}
2678 wxWindow
* wxGetTopLevelParent(wxWindow
* window
);