add wxPosixPermissions enumeration; it provides more readable synonims for wxS_I...
[wxWidgets.git] / interface / wx / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: window.h
3 // Purpose: interface of wxWindow
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 /**
11 Background styles. See wxWindow::SetBackgroundStyle().
12 */
13 enum wxBackgroundStyle
14 {
15 /// Use the default background, as determined by
16 /// the system or the current theme.
17 wxBG_STYLE_SYSTEM,
18
19 /// Use a solid colour for the background, this style is set automatically if you call
20 /// SetBackgroundColour() so you only need to set it explicitly if you had
21 /// changed the background style to something else before.
22 wxBG_STYLE_COLOUR,
23
24 /// Don't draw the background at all, it's supposed that it is drawn by
25 /// the user-defined erase background event handler.
26 /// This style should be used to avoid flicker when the background is entirely
27 /// custom-drawn.
28 wxBG_STYLE_CUSTOM,
29
30 /// The background is (partially) transparent,this style is automatically set if you call
31 /// SetTransparent() which is used to set the transparency level.
32 wxBG_STYLE_TRANSPARENT
33 };
34
35
36 /**
37 Valid values for wxWindow::ShowWithEffect() and wxWindow::HideWithEffect().
38 */
39 enum wxShowEffect
40 {
41 /// Roll window to the left
42 wxSHOW_EFFECT_ROLL_TO_LEFT,
43
44 /// Roll window to the right
45 wxSHOW_EFFECT_ROLL_TO_RIGHT,
46
47 /// Roll window to the top
48 wxSHOW_EFFECT_ROLL_TO_TOP,
49
50 /// Roll window to the bottom
51 wxSHOW_EFFECT_ROLL_TO_BOTTOM,
52
53 /// Slide window to the left
54 wxSHOW_EFFECT_SLIDE_TO_LEFT,
55
56 /// Slide window to the right
57 wxSHOW_EFFECT_SLIDE_TO_RIGHT,
58
59 /// Slide window to the top
60 wxSHOW_EFFECT_SLIDE_TO_TOP,
61
62 /// Slide window to the bottom
63 wxSHOW_EFFECT_SLIDE_TO_BOTTOM,
64
65 /// Fade in or out effect
66 wxSHOW_EFFECT_BLEND,
67
68 /// Expanding or collapsing effect
69 wxSHOW_EFFECT_EXPAND
70 };
71
72 /**
73 Different window variants, on platforms like eg mac uses different
74 rendering sizes.
75 */
76 enum wxWindowVariant
77 {
78 wxWINDOW_VARIANT_NORMAL, //!< Normal size
79 wxWINDOW_VARIANT_SMALL, //!< Smaller size (about 25 % smaller than normal)
80 wxWINDOW_VARIANT_MINI, //!< Mini size (about 33 % smaller than normal)
81 wxWINDOW_VARIANT_LARGE, //!< Large size (about 25 % larger than normal)
82 wxWINDOW_VARIANT_MAX
83 };
84
85
86 /**
87 Flags which can be used in wxWindow::UpdateWindowUI().
88 */
89 enum wxUpdateUI
90 {
91 wxUPDATE_UI_NONE,
92 wxUPDATE_UI_RECURSE,
93 wxUPDATE_UI_FROMIDLE /**< Invoked from On(Internal)Idle */
94 };
95
96
97 /**
98 @class wxWindow
99
100 wxWindow is the base class for all windows and represents any visible object
101 om screen. All controls, top level windows and so on are windows. Sizers and
102 device contexts are not, however, as they don't appear on screen themselves.
103
104 Please note that all children of the window will be deleted automatically by
105 the destructor before the window itself is deleted which means that you don't
106 have to worry about deleting them manually. Please see the @ref
107 overview_windowdeletion "window deletion overview" for more information.
108
109 Also note that in this, and many others, wxWidgets classes some
110 @c GetXXX() methods may be overloaded (as, for example,
111 wxWindow::GetSize or wxWindow::GetClientSize). In this case, the overloads
112 are non-virtual because having multiple virtual functions with the same name
113 results in a virtual function name hiding at the derived class level (in
114 English, this means that the derived class has to override all overloaded
115 variants if it overrides any of them). To allow overriding them in the derived
116 class, wxWidgets uses a unique protected virtual @c DoGetXXX() method
117 and all @c GetXXX() ones are forwarded to it, so overriding the former
118 changes the behaviour of the latter.
119
120 @beginStyleTable
121 @style{wxBORDER_DEFAULT}
122 The window class will decide the kind of border to show, if any.
123 @style{wxBORDER_SIMPLE}
124 Displays a thin border around the window. wxSIMPLE_BORDER is the
125 old name for this style.
126 @style{wxBORDER_SUNKEN}
127 Displays a sunken border. wxSUNKEN_BORDER is the old name for this
128 style.
129 @style{wxBORDER_RAISED}
130 Displays a raised border. wxRAISED_BORDER is the old name for this
131 style.
132 @style{wxBORDER_STATIC}
133 Displays a border suitable for a static control. wxSTATIC_BORDER
134 is the old name for this style. Windows only.
135 @style{wxBORDER_THEME}
136 Displays a native border suitable for a control, on the current
137 platform. On Windows XP or Vista, this will be a themed border; on
138 most other platforms a sunken border will be used. For more
139 information for themed borders on Windows, please see Themed
140 borders on Windows.
141 @style{wxBORDER_NONE}
142 Displays no border, overriding the default border style for the
143 window. wxNO_BORDER is the old name for this style.
144 @style{wxBORDER_DOUBLE}
145 This style is obsolete and should not be used.
146 @style{wxTRANSPARENT_WINDOW}
147 The window is transparent, that is, it will not receive paint
148 events. Windows only.
149 @style{wxTAB_TRAVERSAL}
150 Use this to enable tab traversal for non-dialog windows.
151 @style{wxWANTS_CHARS}
152 Use this to indicate that the window wants to get all char/key
153 events for all keys - even for keys like TAB or ENTER which are
154 usually used for dialog navigation and which wouldn't be generated
155 without this style. If you need to use this style in order to get
156 the arrows or etc., but would still like to have normal keyboard
157 navigation take place, you should call Navigate in response to the
158 key events for Tab and Shift-Tab.
159 @style{wxNO_FULL_REPAINT_ON_RESIZE}
160 On Windows, this style used to disable repainting the window
161 completely when its size is changed. Since this behaviour is now
162 the default, the style is now obsolete and no longer has an effect.
163 @style{wxVSCROLL}
164 Use this style to enable a vertical scrollbar. Notice that this
165 style cannot be used with native controls which don't support
166 scrollbars nor with top-level windows in most ports.
167 @style{wxHSCROLL}
168 Use this style to enable a horizontal scrollbar. The same
169 limitations as for wxVSCROLL apply to this style.
170 @style{wxALWAYS_SHOW_SB}
171 If a window has scrollbars, disable them instead of hiding them
172 when they are not needed (i.e. when the size of the window is big
173 enough to not require the scrollbars to navigate it). This style is
174 currently implemented for wxMSW, wxGTK and wxUniversal and does
175 nothing on the other platforms.
176 @style{wxCLIP_CHILDREN}
177 Use this style to eliminate flicker caused by the background being
178 repainted, then children being painted over them. Windows only.
179 @style{wxFULL_REPAINT_ON_RESIZE}
180 Use this style to force a complete redraw of the window whenever it
181 is resized instead of redrawing just the part of the window
182 affected by resizing. Note that this was the behaviour by default
183 before 2.5.1 release and that if you experience redraw problems
184 with code which previously used to work you may want to try this.
185 Currently this style applies on GTK+ 2 and Windows only, and full
186 repainting is always done on other platforms.
187 @endStyleTable
188
189 @beginExtraStyleTable
190 @style{wxWS_EX_VALIDATE_RECURSIVELY}
191 By default, Validate/TransferDataTo/FromWindow() only work on
192 direct children of the window (compatible behaviour). Set this flag
193 to make them recursively descend into all subwindows.
194 @style{wxWS_EX_BLOCK_EVENTS}
195 wxCommandEvents and the objects of the derived classes are
196 forwarded to the parent window and so on recursively by default.
197 Using this flag for the given window allows to block this
198 propagation at this window, i.e. prevent the events from being
199 propagated further upwards. Dialogs have this flag on by default
200 for the reasons explained in the @ref overview_eventhandling "Event Handling Overview".
201 @style{wxWS_EX_TRANSIENT}
202 Don't use this window as an implicit parent for the other windows:
203 this must be used with transient windows as otherwise there is the
204 risk of creating a dialog/frame with this window as a parent which
205 would lead to a crash if the parent is destroyed before the child.
206 @style{wxWS_EX_CONTEXTHELP}
207 Under Windows, puts a query button on the caption. When pressed,
208 Windows will go into a context-sensitive help mode and wxWidgets
209 will send a wxEVT_HELP event if the user clicked on an application window.
210 This style cannot be used together with wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so
211 these two styles are automatically turned of if this one is used.
212 @style{wxWS_EX_PROCESS_IDLE}
213 This window should always process idle events, even if the mode set
214 by wxIdleEvent::SetMode is wxIDLE_PROCESS_SPECIFIED.
215 @style{wxWS_EX_PROCESS_UI_UPDATES}
216 This window should always process UI update events, even if the
217 mode set by wxUpdateUIEvent::SetMode is wxUPDATE_UI_PROCESS_SPECIFIED.
218 @endExtraStyleTable
219
220 @library{wxcore}
221 @category{miscwnd}
222
223 @see @ref overview_eventhandling "Event handling overview",
224 @ref overview_windowsizing "Window sizing overview"
225 */
226 class wxWindow : public wxEvtHandler
227 {
228 public:
229 /**
230 Default constructor
231 */
232 wxWindow();
233
234 /**
235 Constructs a window, which can be a child of a frame, dialog or any other
236 non-control window.
237
238 @param parent
239 Pointer to a parent window.
240 @param id
241 Window identifier. If wxID_ANY, will automatically create an identifier.
242 @param pos
243 Window position. wxDefaultPosition indicates that wxWidgets
244 should generate a default position for the window.
245 If using the wxWindow class directly, supply an actual position.
246 @param size
247 Window size. wxDefaultSize indicates that wxWidgets should generate
248 a default size for the window. If no suitable size can be found, the
249 window will be sized to 20x20 pixels so that the window is visible but
250 obviously not correctly sized.
251 @param style
252 Window style. For generic window styles, please see wxWindow.
253 @param name
254 Window name.
255 */
256 wxWindow(wxWindow* parent, wxWindowID id,
257 const wxPoint& pos = wxDefaultPosition,
258 const wxSize& size = wxDefaultSize,
259 long style = 0,
260 const wxString& name = wxPanelNameStr);
261
262 /**
263 Destructor.
264
265 Deletes all sub-windows, then deletes itself. Instead of using
266 the @b delete operator explicitly, you should normally use Destroy()
267 so that wxWidgets can delete a window only when it is safe to do so, in idle time.
268
269 @see @ref overview_windowdeletion "Window Deletion Overview",
270 Destroy(), wxCloseEvent
271 */
272 ~wxWindow();
273
274 /**
275 This method may be overridden in the derived classes to return @false to
276 indicate that this control doesn't accept input at all (i.e. behaves like
277 e.g. wxStaticText) and so doesn't need focus.
278
279 @see AcceptsFocusFromKeyboard()
280 */
281 virtual bool AcceptsFocus() const;
282
283 /**
284 This method may be overridden in the derived classes to return @false to
285 indicate that while this control can, in principle, have focus if the user
286 clicks it with the mouse, it shouldn't be included in the TAB traversal chain
287 when using the keyboard.
288 */
289 virtual bool AcceptsFocusFromKeyboard() const;
290
291 /**
292 Overridden to indicate wehter this window or one of its children accepts
293 focus. Usually it's the same as AcceptsFocus() but is overridden for
294 container windows.
295 */
296 virtual bool AcceptsFocusRecursively() const;
297
298 /**
299 Adds a child window. This is called automatically by window creation
300 functions so should not be required by the application programmer.
301 Notice that this function is mostly internal to wxWidgets and shouldn't be
302 called by the user code.
303
304 @param child
305 Child window to add.
306 */
307 virtual void AddChild(wxWindow* child);
308
309 /**
310 Call this function to force one or both scrollbars to be always shown, even if
311 the window is big enough to show its entire contents without scrolling.
312
313 @since 2.9.0
314
315 @param hflag
316 Whether the horizontal scroll bar should always be visible.
317 @param vflag
318 Whether the vertical scroll bar should always be visible.
319
320 @remarks This function is currently only implemented under Mac/Carbon.
321 */
322 void AlwaysShowScrollbars(bool hflag, bool vflag);
323
324 /**
325 Sets the cached best size value.
326 */
327 void CacheBestSize(const wxSize& size) const;
328
329 /**
330 Returns @true if the system supports transparent windows and calling
331 SetTransparent() may succeed. If this function returns @false, transparent
332 windows are definitely not supported by the current system.
333 */
334 bool CanSetTransparent();
335
336 /**
337 Directs all mouse input to this window.
338 Call ReleaseMouse() to release the capture.
339
340 Note that wxWidgets maintains the stack of windows having captured the mouse
341 and when the mouse is released the capture returns to the window which had had
342 captured it previously and it is only really released if there were no previous
343 window. In particular, this means that you must release the mouse as many times
344 as you capture it, unless the window receives the wxMouseCaptureLostEvent event.
345
346 Any application which captures the mouse in the beginning of some operation
347 must handle wxMouseCaptureLostEvent and cancel this operation when it receives
348 the event. The event handler must not recapture mouse.
349
350 @see ReleaseMouse(), wxMouseCaptureLostEvent
351 */
352 virtual void CaptureMouse();
353
354 /**
355 A synonym for Centre().
356 */
357 void Center(int direction);
358
359 /**
360 A synonym for CentreOnParent().
361 */
362 void CenterOnParent(int direction);
363
364 /**
365 Centres the window.
366
367 @param direction
368 Specifies the direction for the centering. May be wxHORIZONTAL, wxVERTICAL
369 or wxBOTH. It may also include wxCENTRE_ON_SCREEN flag
370 if you want to center the window on the entire screen and not on its
371 parent window.
372
373 @remarks If the window is a top level one (i.e. doesn't have a parent),
374 it will be centered relative to the screen anyhow.
375
376 @see Center()
377 */
378 void Centre(int direction = wxBOTH);
379
380 /**
381 Centres the window on its parent. This is a more readable synonym for Centre().
382
383 @param direction
384 Specifies the direction for the centering. May be wxHORIZONTAL, wxVERTICAL
385 or wxBOTH.
386
387 @remarks This methods provides for a way to center top level windows over
388 their parents instead of the entire screen. If there
389 is no parent or if the window is not a top level
390 window, then behaviour is the same as Centre().
391
392 @see wxTopLevelWindow::CentreOnScreen
393 */
394 void CentreOnParent(int direction = wxBOTH);
395
396 /**
397 Clears the window by filling it with the current background colour. Does not
398 cause an erase background event to be generated.
399 */
400 void ClearBackground();
401
402 /**
403 Converts to screen coordinates from coordinates relative to this window.
404
405 @param x
406 A pointer to a integer value for the x coordinate. Pass the client
407 coordinate in, and a screen coordinate will be passed out.
408 @param y
409 A pointer to a integer value for the y coordinate. Pass the client
410 coordinate in, and a screen coordinate will be passed out.
411
412 @beginWxPythonOnly
413 In place of a single overloaded method name, wxPython implements the following methods:
414 - ClientToScreen(point): Accepts and returns a wxPoint
415 - ClientToScreenXY(x, y): Returns a 2-tuple, (x, y)
416 @endWxPythonOnly
417 */
418 void ClientToScreen(int* x, int* y) const;
419
420 /**
421 Converts to screen coordinates from coordinates relative to this window.
422
423 @param pt
424 The client position for the second form of the function.
425 */
426 wxPoint ClientToScreen(const wxPoint& pt) const;
427
428 /**
429 Converts client area size @a size to corresponding window size.
430
431 In other words, the returned value is what would GetSize() return if this
432 window had client area of given size. Components with wxDefaultCoord
433 value are left unchanged. Note that the conversion is not always
434 exact, it assumes that non-client area doesn't change and so doesn't
435 take into account things like menu bar (un)wrapping or (dis)appearance
436 of the scrollbars.
437
438 @since 2.8.8
439
440 @see WindowToClientSize()
441 */
442 virtual wxSize ClientToWindowSize(const wxSize& size);
443
444 /**
445 Converts window size @a size to corresponding client area size
446 In other words, the returned value is what would GetClientSize() return if
447 this window had given window size. Components with wxDefaultCoord value
448 are left unchanged.
449
450 Note that the conversion is not always exact, it assumes that
451 non-client area doesn't change and so doesn't take into account things
452 like menu bar (un)wrapping or (dis)appearance of the scrollbars.
453
454 @since 2.8.8
455
456 @see ClientToWindowSize()
457 */
458 virtual wxSize WindowToClientSize(const wxSize& size);
459
460 /**
461 This function simply generates a wxCloseEvent whose handler usually tries
462 to close the window. It doesn't close the window itself, however.
463
464 @param force
465 @false if the window's close handler should be able to veto the destruction
466 of this window, @true if it cannot.
467
468 @remarks Close calls the close handler for the window, providing an
469 opportunity for the window to choose whether to destroy
470 the window. Usually it is only used with the top level
471 windows (wxFrame and wxDialog classes) as the others
472 are not supposed to have any special OnClose() logic.
473 The close handler should check whether the window is being deleted
474 forcibly, using wxCloseEvent::CanVeto, in which case it should
475 destroy the window using wxWindow::Destroy.
476 Note that calling Close does not guarantee that the window will
477 be destroyed; but it provides a way to simulate a manual close
478 of a window, which may or may not be implemented by destroying
479 the window. The default implementation of wxDialog::OnCloseWindow
480 does not necessarily delete the dialog, since it will simply
481 simulate an wxID_CANCEL event which is handled by the appropriate
482 button event handler and may do anything at all.
483 To guarantee that the window will be destroyed, call
484 wxWindow::Destroy instead
485
486 @see @ref overview_windowdeletion "Window Deletion Overview",
487 Destroy(), wxCloseEvent
488 */
489 bool Close(bool force = false);
490
491 //@{
492 /**
493 Converts a point or size from dialog units to pixels.
494
495 For the x dimension, the dialog units are multiplied by the average character
496 width and then divided by 4.
497 For the y dimension, the dialog units are multiplied by the average character
498 height and then divided by 8.
499
500 @remarks Dialog units are used for maintaining a dialog's proportions
501 even if the font changes.
502 You can also use these functions programmatically.
503 A convenience macro is defined:
504 @code
505 #define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt)
506 @endcode
507
508 @see ConvertPixelsToDialog()
509 */
510 wxPoint ConvertDialogToPixels(const wxPoint& pt);
511 wxSize ConvertDialogToPixels(const wxSize& sz);
512 //@}
513
514 //@{
515 /**
516 Converts a point or size from pixels to dialog units.
517
518 For the x dimension, the pixels are multiplied by 4 and then divided by the
519 average character width.
520 For the y dimension, the pixels are multiplied by 8 and then divided by the
521 average character height.
522
523 @remarks Dialog units are used for maintaining a dialog's proportions
524 even if the font changes.
525
526 @see ConvertDialogToPixels()
527 */
528 wxPoint ConvertPixelsToDialog(const wxPoint& pt);
529 wxSize ConvertPixelsToDialog(const wxSize& sz);
530 //@}
531
532 /**
533 Destroys the window safely. Use this function instead of the delete operator,
534 since different window classes can be destroyed differently. Frames and dialogs
535 are not destroyed immediately when this function is called -- they are added
536 to a list of windows to be deleted on idle time, when all the window's events
537 have been processed. This prevents problems with events being sent to
538 non-existent windows.
539
540 @return @true if the window has either been successfully deleted, or it
541 has been added to the list of windows pending real deletion.
542 */
543 virtual bool Destroy();
544
545 /**
546 Destroys all children of a window. Called automatically by the destructor.
547 */
548 virtual void DestroyChildren();
549
550 /**
551 Returns true if this window is in process of being destroyed.
552
553 The top level windows are not deleted immediately but are rather
554 scheduled for later destruction to give them time to process any
555 pending messages, see Destroy() description.
556
557 This function returns @true if this window, or one of its parent
558 windows, is scheduled for destruction and can be useful to avoid
559 manipulating it as it's usually useless to do something with a window
560 which is on the point of disappearing anyhow.
561 */
562 bool IsBeingDeleted() const;
563
564 /**
565 Disables the window. Same as @ref Enable() Enable(@false).
566
567 @return Returns @true if the window has been disabled, @false if it had
568 been already disabled before the call to this function.
569 */
570 bool Disable();
571
572 /**
573 Gets the size which best suits the window: for a control, it would be
574 the minimal size which doesn't truncate the control, for a panel - the
575 same size as it would have after a call to Fit().
576
577 The default implementation of this function is designed for use in container
578 windows, such as wxPanel, and works something like this:
579 -# If the window has a sizer then it is used to calculate the best size.
580 -# Otherwise if the window has layout constraints then those are used to
581 calculate the best size.
582 -# Otherwise if the window has children then the best size is set to be large
583 enough to show all the children.
584 -# Otherwise if there are no children then the window's minimal size will be
585 used as its best size.
586 -# Otherwise if there is no minimal size set, then the current size is used
587 for the best size.
588
589 @see @ref overview_windowsizing
590 */
591 virtual wxSize DoGetBestSize() const;
592
593 /**
594 Does the window-specific updating after processing the update event.
595 This function is called by UpdateWindowUI() in order to check return
596 values in the wxUpdateUIEvent and act appropriately.
597 For example, to allow frame and dialog title updating, wxWidgets
598 implements this function as follows:
599
600 @code
601 // do the window-specific processing after processing the update event
602 void wxTopLevelWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
603 {
604 if ( event.GetSetEnabled() )
605 Enable(event.GetEnabled());
606
607 if ( event.GetSetText() )
608 {
609 if ( event.GetText() != GetTitle() )
610 SetTitle(event.GetText());
611 }
612 }
613 @endcode
614 */
615 virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
616
617 /**
618 Enables or disables eligibility for drop file events (OnDropFiles).
619
620 @param accept
621 If @true, the window is eligible for drop file events.
622 If @false, the window will not accept drop file events.
623
624 @remarks Windows only.
625 */
626 virtual void DragAcceptFiles(bool accept);
627
628 /**
629 Enable or disable the window for user input. Note that when a parent window is
630 disabled, all of its children are disabled as well and they are reenabled again
631 when the parent is.
632
633 @param enable
634 If @true, enables the window for input. If @false, disables the window.
635
636 @return Returns @true if the window has been enabled or disabled, @false
637 if nothing was done, i.e. if the window had already
638 been in the specified state.
639
640 @see IsEnabled(), Disable(), wxRadioBox::Enable
641 */
642 virtual bool Enable(bool enable = true);
643
644 /**
645 Finds the window or control which currently has the keyboard focus.
646
647 @remarks Note that this is a static function, so it can be called without
648 needing a wxWindow pointer.
649
650 @see SetFocus(), HasFocus()
651 */
652 static wxWindow* FindFocus();
653
654 /**
655 Find a child of this window, by @a id.
656 May return @a this if it matches itself.
657 */
658 wxWindow* FindWindow(long id) const;
659
660 /**
661 Find a child of this window, by name.
662 May return @a this if it matches itself.
663 */
664 wxWindow* FindWindow(const wxString& name) const;
665
666 /**
667 Find the first window with the given @e id.
668
669 If @a parent is @NULL, the search will start from all top-level frames
670 and dialog boxes; if non-@NULL, the search will be limited to the given
671 window hierarchy.
672 The search is recursive in both cases.
673
674 @see FindWindow()
675 */
676 static wxWindow* FindWindowById(long id, wxWindow* parent = NULL);
677
678 /**
679 Find a window by its label.
680
681 Depending on the type of window, the label may be a window title
682 or panel item label. If @a parent is @NULL, the search will start from all
683 top-level frames and dialog boxes; if non-@NULL, the search will be
684 limited to the given window hierarchy.
685 The search is recursive in both cases.
686
687 @see FindWindow()
688 */
689 static wxWindow* FindWindowByLabel(const wxString& label,
690 wxWindow* parent = NULL);
691
692 /**
693 Find a window by its name (as given in a window constructor or @b Create
694 function call).
695
696 If @a parent is @NULL, the search will start from all top-level frames
697 and dialog boxes; if non-@NULL, the search will be limited to the given
698 window hierarchy.
699
700 The search is recursive in both cases. If no window with such name is found,
701 FindWindowByLabel() is called.
702
703 @see FindWindow()
704 */
705 static wxWindow* FindWindowByName(const wxString& name,
706 wxWindow* parent = NULL);
707
708 /**
709 Sizes the window so that it fits around its subwindows.
710
711 This function won't do anything if there are no subwindows and will only really
712 work correctly if sizers are used for the subwindows layout.
713
714 Also, if the window has exactly one subwindow it is better (faster and the result
715 is more precise as Fit() adds some margin to account for fuzziness of its calculations)
716 to call:
717
718 @code
719 window->SetClientSize(child->GetSize());
720 @endcode
721
722 instead of calling Fit().
723
724 @see @ref overview_windowsizing
725 */
726 virtual void Fit();
727
728 /**
729 Similar to Fit(), but sizes the interior (virtual) size of a window.
730
731 Mainly useful with scrolled windows to reset scrollbars after sizing
732 changes that do not trigger a size event, and/or scrolled windows without
733 an interior sizer. This function similarly won't do anything if there are
734 no subwindows.
735 */
736 virtual void FitInside();
737
738 /**
739 Freezes the window or, in other words, prevents any updates from taking
740 place on screen, the window is not redrawn at all.
741
742 Thaw() must be called to reenable window redrawing. Calls to these two
743 functions may be nested but to ensure that the window is properly
744 repainted again, you must thaw it exactly as many times as you froze it.
745
746 If the window has any children, they are recursively frozen too.
747
748 This method is useful for visual appearance optimization (for example,
749 it is a good idea to use it before doing many large text insertions in
750 a row into a wxTextCtrl under wxGTK) but is not implemented on all
751 platforms nor for all controls so it is mostly just a hint to wxWidgets
752 and not a mandatory directive.
753
754 @see wxWindowUpdateLocker, Thaw(), IsFrozen()
755 */
756 virtual void Freeze();
757
758 /**
759 Gets the accelerator table for this window. See wxAcceleratorTable.
760 */
761 wxAcceleratorTable* GetAcceleratorTable() const;
762
763 /**
764 Returns the accessible object for this window, if any.
765 See also wxAccessible.
766 */
767 wxAccessible* GetAccessible();
768
769 /**
770 @deprecated
771 This method is deprecated, use GetEffectiveMinSize() instead.
772 */
773 wxSize GetAdjustedBestSize() const;
774
775 /**
776 Returns the background colour of the window.
777
778 @see SetBackgroundColour(), SetForegroundColour(), GetForegroundColour()
779 */
780 wxColour GetBackgroundColour() const;
781
782 /**
783 Returns the background style of the window.
784 The background style can be one of the wxBackgroundStyle.
785
786 @see SetBackgroundColour(), GetForegroundColour(),
787 SetBackgroundStyle(), SetTransparent()
788 */
789 virtual wxBackgroundStyle GetBackgroundStyle() const;
790
791 /**
792 This functions returns the best acceptable minimal size for the window.
793
794 For example, for a static control, it will be the minimal size such that the
795 control label is not truncated. For windows containing subwindows (typically
796 wxPanel), the size returned by this function will be the same as the size
797 the window would have had after calling Fit().
798 */
799 wxSize GetBestSize() const;
800
801 /**
802 Returns the currently captured window.
803
804 @see HasCapture(), CaptureMouse(), ReleaseMouse(),
805 wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent
806 */
807 static wxWindow* GetCapture();
808
809 /**
810 Returns the caret() associated with the window.
811 */
812 wxCaret* GetCaret() const;
813
814 /**
815 Returns the character height for this window.
816 */
817 virtual int GetCharHeight() const;
818
819 /**
820 Returns the average character width for this window.
821 */
822 virtual int GetCharWidth() const;
823
824 //@{
825 /**
826 Returns a reference to the list of the window's children. @c wxWindowList
827 is a type-safe wxList-like class whose elements are of type @c wxWindow*.
828 */
829 wxWindowList& GetChildren();
830 const wxWindowList& GetChildren() const;
831 //@}
832
833 /**
834 Returns the default font and colours which are used by the control.
835
836 This is useful if you want to use the same font or colour in your own control
837 as in a standard control -- which is a much better idea than hard coding specific
838 colours or fonts which might look completely out of place on the users
839 system, especially if it uses themes.
840
841 The @a variant parameter is only relevant under Mac currently and is
842 ignore under other platforms. Under Mac, it will change the size of the
843 returned font. See SetWindowVariant() for more about this.
844
845 This static method is "overridden" in many derived classes and so calling,
846 for example, wxButton::GetClassDefaultAttributes() will typically
847 return the values appropriate for a button which will be normally different
848 from those returned by, say, wxListCtrl::GetClassDefaultAttributes().
849
850 The @c wxVisualAttributes structure has at least the fields
851 @c font, @c colFg and @c colBg. All of them may be invalid
852 if it was not possible to determine the default control appearance or,
853 especially for the background colour, if the field doesn't make sense as is
854 the case for @c colBg for the controls with themed background.
855
856 @see InheritAttributes()
857 */
858 static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
859
860 //@{
861 /**
862 Returns the size of the window 'client area' in pixels.
863 The client area is the area which may be drawn on by the programmer,
864 excluding title bar, border, scrollbars, etc.
865 Note that if this window is a top-level one and it is currently minimized, the
866 return size is empty (both width and height are 0).
867
868 @param width
869 Receives the client width in pixels.
870 @param height
871 Receives the client height in pixels.
872
873 @see GetSize(), GetVirtualSize()
874 */
875 void GetClientSize(int* width, int* height) const;
876 wxSize GetClientSize() const;
877 //@}
878
879 /**
880 Returns a pointer to the window's layout constraints, or @NULL if there are none.
881 */
882 wxLayoutConstraints* GetConstraints() const;
883
884 /**
885 Return the sizer that this window is a member of, if any, otherwise @NULL.
886 */
887 wxSizer* GetContainingSizer() const;
888
889 /**
890 Return the cursor associated with this window.
891
892 @see SetCursor()
893 */
894 const wxCursor& GetCursor() const;
895
896 /**
897 Currently this is the same as calling
898 wxWindow::GetClassDefaultAttributes(wxWindow::GetWindowVariant()).
899
900 One advantage of using this function compared to the static version is that
901 the call is automatically dispatched to the correct class (as usual with
902 virtual functions) and you don't have to specify the class name explicitly.
903
904 The other one is that in the future this function could return different
905 results, for example it might return a different font for an "Ok" button
906 than for a generic button if the users GUI is configured to show such buttons
907 in bold font. Of course, the down side is that it is impossible to call this
908 function without actually having an object to apply it to whereas the static
909 version can be used without having to create an object first.
910 */
911 virtual wxVisualAttributes GetDefaultAttributes() const;
912
913 /**
914 Returns the associated drop target, which may be @NULL.
915
916 @see SetDropTarget(), @ref overview_dnd
917 */
918 wxDropTarget* GetDropTarget() const;
919
920 /**
921 Merges the window's best size into the min size and returns the result.
922 This is the value used by sizers to determine the appropriate
923 ammount of space to allocate for the widget.
924
925 @see GetBestSize(), SetInitialSize(), @ref overview_windowsizing
926 */
927 wxSize GetEffectiveMinSize() const;
928
929 /**
930 Returns the event handler for this window.
931 By default, the window is its own event handler.
932
933 @see SetEventHandler(), PushEventHandler(),
934 PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
935 */
936 wxEvtHandler* GetEventHandler() const;
937
938 /**
939 Returns the extra style bits for the window.
940 */
941 long GetExtraStyle() const;
942
943 /**
944 Returns the font for this window.
945
946 @see SetFont()
947 */
948 wxFont GetFont() const;
949
950 /**
951 Returns the foreground colour of the window.
952
953 @remarks The interpretation of foreground colour is open to
954 interpretation according to the window class; it may be
955 the text colour or other colour, or it may not be used at all.
956
957 @see SetForegroundColour(), SetBackgroundColour(),
958 GetBackgroundColour()
959 */
960 wxColour GetForegroundColour();
961
962 /**
963 Returns the grandparent of a window, or @NULL if there isn't one.
964 */
965 wxWindow* GetGrandParent() const;
966
967 /**
968 Returns the platform-specific handle of the physical window.
969 Cast it to an appropriate handle, such as @b HWND for Windows,
970 @b Widget for Motif, @b GtkWidget for GTK or @b WinHandle for PalmOS.
971 */
972 void* GetHandle() const;
973
974 /**
975 Gets the help text to be used as context-sensitive help for this window.
976 Note that the text is actually stored by the current wxHelpProvider
977 implementation, and not in the window object itself.
978
979 @see SetHelpText(), GetHelpTextAtPoint(), wxHelpProvider
980 */
981 virtual wxString GetHelpText() const;
982
983 /**
984 Gets the help text to be used as context-sensitive help for this window.
985 This method should be overridden if the help message depends on the position
986 inside the window, otherwise GetHelpText() can be used.
987
988 @param point
989 Coordinates of the mouse at the moment of help event emission.
990 @param origin
991 Help event origin, see also wxHelpEvent::GetOrigin.
992 */
993 virtual wxString GetHelpTextAtPoint(const wxPoint point,
994 wxHelpEvent::Origin origin) const;
995
996 /**
997 Returns the identifier of the window.
998
999 @remarks Each window has an integer identifier. If the application
1000 has not provided one (or the default wxID_ANY) an unique
1001 identifier with a negative value will be generated.
1002
1003 @see SetId(), @ref overview_windowids
1004 */
1005 int GetId() const;
1006
1007 /**
1008 Generic way of getting a label from any window, for
1009 identification purposes.
1010
1011 @remarks The interpretation of this function differs from class to class.
1012 For frames and dialogs, the value returned is the
1013 title. For buttons or static text controls, it is the
1014 button text. This function can be useful for
1015 meta-programs (such as testing tools or special-needs
1016 access programs) which need to identify windows by name.
1017 */
1018 virtual wxString GetLabel() const;
1019
1020 /**
1021 Returns the maximum size of window's client area.
1022
1023 This is an indication to the sizer layout mechanism that this is the maximum
1024 possible size as well as the upper bound on window's size settable using
1025 SetClientSize().
1026
1027 @see GetMaxSize()
1028 */
1029 wxSize GetMaxClientSize() const;
1030
1031 /**
1032 Returns the maximum size of the window.
1033
1034 This is an indication to the sizer layout mechanism that this is the maximum
1035 possible size as well as the upper bound on window's size settable using SetSize().
1036
1037 @see GetMaxClientSize()
1038 */
1039 wxSize GetMaxSize() const;
1040
1041 /**
1042 Returns the minimum size of window's client area, an indication to the sizer
1043 layout mechanism that this is the minimum required size of its client area.
1044
1045 It normally just returns the value set by SetMinClientSize(), but it can be
1046 overridden to do the calculation on demand.
1047
1048 @see GetMinSize()
1049 */
1050 virtual wxSize GetMinClientSize() const;
1051
1052 /**
1053 Returns the minimum size of the window, an indication to the sizer layout
1054 mechanism that this is the minimum required size.
1055
1056 This method normally just returns the value set by SetMinSize(), but it
1057 can be overridden to do the calculation on demand.
1058
1059 @see GetMinClientSize()
1060 */
1061 virtual wxSize GetMinSize() const;
1062
1063 /**
1064 Returns the window's name.
1065
1066 @remarks This name is not guaranteed to be unique; it is up to the
1067 programmer to supply an appropriate name in the window
1068 constructor or via SetName().
1069
1070 @see SetName()
1071 */
1072 virtual wxString GetName() const;
1073
1074 /**
1075 Returns the next window after this one among the parent children or @NULL
1076 if this window is the last child.
1077
1078 @since 2.8.8
1079
1080 @see GetPrevSibling()
1081 */
1082 wxWindow* GetNextSibling() const;
1083
1084 /**
1085 Returns the parent of the window, or @NULL if there is no parent.
1086 */
1087 virtual wxWindow* GetParent() const;
1088
1089 /**
1090 This function shows a popup menu at the given position in this window and
1091 returns the selected id. It can be more convenient than the general purpose
1092 PopupMenu() function for simple menus proposing a choice in a list of
1093 strings to the user.
1094
1095 @param menu
1096 The menu to show
1097 @param pos
1098 The position at which to show the menu in client coordinates
1099
1100 @return The selected menu item id or wxID_NONE if none selected or an
1101 error occurred.
1102 */
1103 int GetPopupMenuSelectionFromUser(wxMenu& menu, const wxPoint& pos);
1104
1105 /**
1106 See the GetPopupMenuSelectionFromUser(wxMenu&, const wxPoint&) overload.
1107 This overload differs only because it takes two integers for the
1108 menu position instead of a wxPoint.
1109 */
1110 int GetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y);
1111
1112 /**
1113 This gets the position of the window in pixels, relative to the parent window
1114 for the child windows or relative to the display origin for the top level windows.
1115
1116 @param x
1117 Receives the x position of the window if non-@NULL.
1118 @param y
1119 Receives the y position of the window if non-@NULL.
1120
1121 @see GetScreenPosition()
1122 */
1123 void GetPosition(int* x, int* y) const;
1124
1125 /**
1126 This gets the position of the window in pixels, relative to the parent window
1127 for the child windows or relative to the display origin for the top level windows.
1128
1129 @see GetScreenPosition()
1130 */
1131 wxPoint GetPosition() const;
1132
1133 /**
1134 Returns the previous window before this one among the parent children or @c
1135 @NULL if this window is the first child.
1136
1137 @since 2.8.8
1138
1139 @see GetNextSibling()
1140 */
1141 wxWindow* GetPrevSibling() const;
1142
1143 /**
1144 Returns the position and size of the window as a wxRect object.
1145
1146 @see GetScreenRect()
1147 */
1148 wxRect GetRect() const;
1149
1150 /**
1151 Returns the window position in screen coordinates, whether the window is a
1152 child window or a top level one.
1153
1154 @param x
1155 Receives the x position of the window on the screen if non-@NULL.
1156 @param y
1157 Receives the y position of the window on the screen if non-@NULL.
1158
1159 @see GetPosition()
1160 */
1161 void GetScreenPosition(int* x, int* y) const;
1162
1163 /**
1164 Returns the window position in screen coordinates, whether the window is a
1165 child window or a top level one.
1166
1167 @see GetPosition()
1168 */
1169 wxPoint GetScreenPosition() const;
1170
1171 /**
1172 Returns the position and size of the window on the screen as a wxRect object.
1173
1174 @see GetRect()
1175 */
1176 wxRect GetScreenRect() const;
1177
1178 /**
1179 Returns the built-in scrollbar position.
1180
1181 @see See SetScrollbar()
1182 */
1183 virtual int GetScrollPos(int orientation);
1184
1185 /**
1186 Returns the built-in scrollbar range.
1187
1188 @see SetScrollbar()
1189 */
1190 virtual int GetScrollRange(int orientation);
1191
1192 /**
1193 Returns the built-in scrollbar thumb size.
1194
1195 @see SetScrollbar()
1196 */
1197 virtual int GetScrollThumb(int orientation);
1198
1199 /**
1200 Returns the size of the entire window in pixels, including title bar, border,
1201 scrollbars, etc.
1202
1203 Note that if this window is a top-level one and it is currently minimized, the
1204 returned size is the restored window size, not the size of the window icon.
1205
1206 @param width
1207 Receives the window width.
1208 @param height
1209 Receives the window height.
1210
1211 @see GetClientSize(), GetVirtualSize()
1212 */
1213 void GetSize(int* width, int* height) const;
1214
1215 /**
1216 See the GetSize(int*,int*) overload for more info.
1217 */
1218 wxSize GetSize() const;
1219
1220 /**
1221 Return the sizer associated with the window by a previous call to
1222 SetSizer() or @NULL.
1223 */
1224 wxSizer* GetSizer() const;
1225
1226 /**
1227 Gets the dimensions of the string as it would be drawn on the
1228 window with the currently selected font.
1229
1230 The text extent is returned in @a w and @a h pointers.
1231
1232 @param string
1233 String whose extent is to be measured.
1234 @param w
1235 Return value for width.
1236 @param h
1237 Return value for height.
1238 @param descent
1239 Return value for descent (optional).
1240 @param externalLeading
1241 Return value for external leading (optional).
1242 @param font
1243 Font to use instead of the current window font (optional).
1244 @param use16
1245 If @true, string contains 16-bit characters. The default is @false.
1246 */
1247 virtual void GetTextExtent(const wxString& string, int* w, int* h,
1248 int* descent = NULL,
1249 int* externalLeading = NULL,
1250 const wxFont* font = NULL,
1251 bool use16 = false) const;
1252
1253 /**
1254 Gets the dimensions of the string as it would be drawn on the
1255 window with the currently selected font.
1256 */
1257 wxSize GetTextExtent(const wxString& string) const;
1258
1259 /**
1260 Get the associated tooltip or @NULL if none.
1261 */
1262 wxToolTip* GetToolTip() const;
1263
1264 /**
1265 Returns the region specifying which parts of the window have been damaged.
1266 Should only be called within an wxPaintEvent handler.
1267
1268 @see wxRegion, wxRegionIterator
1269 */
1270 virtual wxRegion GetUpdateRegion() const;
1271
1272 /**
1273 Returns a pointer to the current validator for the window, or @NULL if
1274 there is none.
1275 */
1276 wxValidator* GetValidator() const;
1277
1278 //@{
1279 /**
1280 This gets the virtual size of the window in pixels.
1281 By default it returns the client size of the window, but after a call to
1282 SetVirtualSize() it will return that size.
1283
1284 @param width
1285 Receives the window virtual width.
1286 @param height
1287 Receives the window virtual height.
1288 */
1289 void GetVirtualSize(int* width, int* height) const;
1290 wxSize GetVirtualSize() const;
1291 //@}
1292
1293 /**
1294 Returns the size of the left/right and top/bottom borders of this window in x
1295 and y components of the result respectively.
1296 */
1297 wxSize GetWindowBorderSize() const;
1298
1299 /**
1300 Gets the window style that was passed to the constructor or @b Create
1301 method. @b GetWindowStyle() is another name for the same function.
1302 */
1303 long GetWindowStyleFlag() const;
1304
1305 /**
1306 Returns the value previously passed to SetWindowVariant().
1307 */
1308 wxWindowVariant GetWindowVariant() const;
1309
1310 /**
1311 This function will generate the appropriate call to
1312 Navigate() if the key event is one normally used for
1313 keyboard navigation and return @true in this case.
1314
1315 @return Returns @true if the key pressed was for navigation and was
1316 handled, @false otherwise.
1317
1318 @see Navigate()
1319 */
1320 bool HandleAsNavigationKey(const wxKeyEvent& event);
1321
1322 /**
1323 Shorthand for:
1324 @code
1325 GetEventHandler()->SafelyProcessEvent(event);
1326 @endcode
1327 */
1328 bool HandleWindowEvent(wxEvent& event);
1329
1330 /**
1331 Returns @true if this window has the current mouse capture.
1332
1333 @see CaptureMouse(), ReleaseMouse(), wxMouseCaptureLostEvent,
1334 wxMouseCaptureChangedEvent
1335 */
1336 virtual bool HasCapture() const;
1337
1338 /**
1339 Returns @true if the window has the given @a exFlag bit set in its
1340 extra styles.
1341
1342 @see SetExtraStyle()
1343 */
1344 bool HasExtraStyle(int exFlag) const;
1345
1346 /**
1347 Returns @true if the window has the given @a flag bit set.
1348 */
1349 bool HasFlag(int flag) const;
1350
1351 /**
1352 Returns @true if the window (or in case of composite controls, its main
1353 child window) has focus.
1354
1355 @see FindFocus()
1356 */
1357 virtual bool HasFocus() const;
1358
1359 /**
1360 This method should be overridden to return @true if this window has
1361 multiple pages. All standard class with multiple pages such as
1362 wxNotebook, wxListbook and wxTreebook already override it to return @true
1363 and user-defined classes with similar behaviour should do it as well to
1364 allow the library to handle such windows appropriately.
1365 */
1366 virtual bool HasMultiplePages() const;
1367
1368 /**
1369 Returns @true if this window has a scroll bar for this orientation.
1370
1371 @param orient
1372 Orientation to check, either wxHORIZONTAL or wxVERTICAL.
1373 */
1374 virtual bool HasScrollbar(int orient) const;
1375
1376 /**
1377 Returns @true if this window background is transparent (as, for example,
1378 for wxStaticText) and should show the parent window background.
1379
1380 This method is mostly used internally by the library itself and you normally
1381 shouldn't have to call it. You may, however, have to override it in your
1382 wxWindow-derived class to ensure that background is painted correctly.
1383 */
1384 virtual bool HasTransparentBackground() const;
1385
1386 /**
1387 Equivalent to calling wxWindow::Show(@false).
1388 */
1389 bool Hide();
1390
1391 /**
1392 This function hides a window, like Hide(), but using a special visual
1393 effect if possible.
1394
1395 The parameters of this function are the same as for ShowWithEffect(),
1396 please see their description there.
1397
1398 @since 2.9.0
1399 */
1400 virtual bool HideWithEffect(wxShowEffect effect,
1401 unsigned timeout = 0);
1402
1403 /**
1404 This function is (or should be, in case of custom controls) called during
1405 window creation to intelligently set up the window visual attributes, that is
1406 the font and the foreground and background colours.
1407
1408 By "intelligently" the following is meant: by default, all windows use their
1409 own @ref GetClassDefaultAttributes() default attributes.
1410 However if some of the parents attributes are explicitly (that is, using
1411 SetFont() and not wxWindow::SetOwnFont) changed and if the corresponding
1412 attribute hadn't been explicitly set for this window itself, then this
1413 window takes the same value as used by the parent.
1414 In addition, if the window overrides ShouldInheritColours() to return @false,
1415 the colours will not be changed no matter what and only the font might.
1416
1417 This rather complicated logic is necessary in order to accommodate the
1418 different usage scenarios. The most common one is when all default attributes
1419 are used and in this case, nothing should be inherited as in modern GUIs
1420 different controls use different fonts (and colours) than their siblings so
1421 they can't inherit the same value from the parent. However it was also deemed
1422 desirable to allow to simply change the attributes of all children at once by
1423 just changing the font or colour of their common parent, hence in this case we
1424 do inherit the parents attributes.
1425 */
1426 void InheritAttributes();
1427
1428 /**
1429 Sends an @c wxEVT_INIT_DIALOG event, whose handler usually transfers data
1430 to the dialog via validators.
1431 */
1432 void InitDialog();
1433
1434 /**
1435 Resets the cached best size value so it will be recalculated the next time it
1436 is needed.
1437 */
1438 void InvalidateBestSize();
1439
1440 /**
1441 Returns @true if the window contents is double-buffered by the system, i.e. if
1442 any drawing done on the window is really done on a temporary backing surface
1443 and transferred to the screen all at once later.
1444
1445 @see wxBufferedDC
1446 */
1447 virtual bool IsDoubleBuffered() const;
1448
1449 /**
1450 Returns @true if the window is enabled, i.e. if it accepts user input,
1451 @false otherwise.
1452
1453 Notice that this method can return @false even if this window itself hadn't
1454 been explicitly disabled when one of its parent windows is disabled.
1455 To get the intrinsic status of this window, use IsThisEnabled()
1456
1457 @see Enable()
1458 */
1459 virtual bool IsEnabled() const;
1460
1461 //@{
1462 /**
1463 Returns @true if the given point or rectangle area has been exposed since the
1464 last repaint. Call this in an paint event handler to optimize redrawing by
1465 only redrawing those areas, which have been exposed.
1466 */
1467 bool IsExposed(int x, int y) const;
1468 const bool IsExposed(wxPoint amp;pt) const;
1469 const bool IsExposed(int x, int y, int w, int h) const;
1470 const bool IsExposed(wxRect amp;rect) const;
1471 //@}
1472
1473 /**
1474 Returns @true if the window is currently frozen by a call to Freeze().
1475
1476 @see Freeze(), Thaw()
1477 */
1478 virtual bool IsFrozen() const;
1479
1480 /**
1481 Returns @true if the window is retained, @false otherwise.
1482
1483 @remarks Retained windows are only available on X platforms.
1484 */
1485 virtual bool IsRetained() const;
1486
1487 /**
1488 Return whether a scrollbar is always shown.
1489
1490 @param orient
1491 Orientation to check, either wxHORIZONTAL or wxVERTICAL.
1492
1493 @see AlwaysShowScrollbars()
1494 */
1495 bool IsScrollbarAlwaysShown(int orient);
1496
1497 /**
1498 Returns @true if the window is shown, @false if it has been hidden.
1499
1500 @see IsShownOnScreen()
1501 */
1502 virtual bool IsShown() const;
1503
1504 /**
1505 Returns @true if the window is physically visible on the screen, i.e. it
1506 is shown and all its parents up to the toplevel window are shown as well.
1507
1508 @see IsShown()
1509 */
1510 virtual bool IsShownOnScreen() const;
1511
1512 /**
1513 Returns @true if this window is intrinsically enabled, @false otherwise,
1514 i.e. if @ref Enable() Enable(@false) had been called. This method is
1515 mostly used for wxWidgets itself, user code should normally use
1516 IsEnabled() instead.
1517 */
1518 bool IsThisEnabled() const;
1519
1520 /**
1521 Returns @true if the given window is a top-level one. Currently all frames and
1522 dialogs are considered to be top-level windows (even if they have a parent
1523 window).
1524 */
1525 bool IsTopLevel() const;
1526
1527 /**
1528 Invokes the constraint-based layout algorithm or the sizer-based algorithm
1529 for this window.
1530
1531 See SetAutoLayout(): when auto layout is on, this function gets called automatically
1532 when the window is resized.
1533
1534 @see @ref overview_windowsizing
1535 */
1536 void Layout();
1537
1538 /**
1539 Lowers the window to the bottom of the window hierarchy (Z-order).
1540
1541 @see Raise()
1542 */
1543 void Lower();
1544
1545 /**
1546 Disables all other windows in the application so that
1547 the user can only interact with this window.
1548
1549 @param flag
1550 If @true, this call disables all other windows in the application so that
1551 the user can only interact with this window. If @false, the effect is
1552 reversed.
1553 */
1554 virtual void MakeModal(bool flag);
1555
1556 /**
1557 Moves the window to the given position.
1558
1559 @param x
1560 Required x position.
1561 @param y
1562 Required y position.
1563
1564 @remarks Implementations of SetSize can also implicitly implement the
1565 Move() function, which is defined in the base wxWindow class as the call:
1566 @code
1567 SetSize(x, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
1568 @endcode
1569
1570 @see SetSize()
1571 */
1572 void Move(int x, int y);
1573
1574 /**
1575 Moves the window to the given position.
1576
1577 @param pt
1578 wxPoint object representing the position.
1579
1580 @remarks Implementations of SetSize() can also implicitly implement the
1581 Move() function, which is defined in the base wxWindow class as the call:
1582 @code
1583 SetSize(x, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
1584 @endcode
1585
1586 @see SetSize()
1587 */
1588 void Move(const wxPoint& pt);
1589
1590 /**
1591 Moves this window in the tab navigation order after the specified @e win.
1592 This means that when the user presses @c TAB key on that other window,
1593 the focus switches to this window.
1594
1595 Default tab order is the same as creation order, this function and
1596 MoveBeforeInTabOrder() allow to change
1597 it after creating all the windows.
1598
1599 @param win
1600 A sibling of this window which should precede it in tab order,
1601 must not be @NULL
1602 */
1603 void MoveAfterInTabOrder(wxWindow* win);
1604
1605 /**
1606 Same as MoveAfterInTabOrder() except that it inserts this window just
1607 before @a win instead of putting it right after it.
1608 */
1609 void MoveBeforeInTabOrder(wxWindow* win);
1610
1611 /**
1612 Performs a keyboard navigation action starting from this window.
1613 This method is equivalent to calling NavigateIn() method on the
1614 parent window.
1615
1616 @param flags
1617 A combination of wxNavigationKeyEvent::IsForward and
1618 wxNavigationKeyEvent::WinChange.
1619
1620 @return Returns @true if the focus was moved to another window or @false
1621 if nothing changed.
1622
1623 @remarks You may wish to call this from a text control custom keypress
1624 handler to do the default navigation behaviour for the
1625 tab key, since the standard default behaviour for a
1626 multiline text control with the wxTE_PROCESS_TAB style
1627 is to insert a tab and not navigate to the next
1628 control. See also wxNavigationKeyEvent and
1629 HandleAsNavigationKey.
1630 */
1631 bool Navigate(int flags = wxNavigationKeyEvent::IsForward);
1632
1633 /**
1634 Performs a keyboard navigation action inside this window.
1635 See Navigate() for more information.
1636 */
1637 bool NavigateIn(int flags = wxNavigationKeyEvent::IsForward);
1638
1639 /**
1640 Create a new ID or range of IDs that are not currently in use.
1641 The IDs will be reserved until assigned to a wxWindow ID
1642 or unreserved with UnreserveControlId().
1643
1644 See @ref overview_windowids for more information.
1645
1646 @param count
1647 The number of sequential IDs to reserve.
1648
1649 @return Returns the ID or the first ID of the range, or wxID_NONE if the
1650 specified number of identifiers couldn't be allocated.
1651
1652 @see UnreserveControlId(), wxIdManager,
1653 @ref overview_windowids
1654 */
1655 static wxWindowID NewControlId(int count = 1);
1656
1657 /**
1658 This virtual function is normally only used internally, but
1659 sometimes an application may need it to implement functionality
1660 that should not be disabled by an application defining an OnIdle
1661 handler in a derived class.
1662
1663 This function may be used to do delayed painting, for example,
1664 and most implementations call UpdateWindowUI()
1665 in order to send update events to the window in idle time.
1666 */
1667 virtual void OnInternalIdle();
1668
1669 /**
1670 Same as #ScrollLines (-1).
1671 */
1672 bool LineUp();
1673
1674 /**
1675 Same as #ScrollLines (1).
1676 */
1677 bool LineDown();
1678
1679 /**
1680 Same as #ScrollPages (-1).
1681 */
1682 bool PageUp();
1683
1684 /**
1685 Same as #ScrollPages (1).
1686 */
1687 bool PageDown();
1688
1689
1690 /**
1691 Removes and returns the top-most event handler on the event handler stack.
1692
1693 @param deleteHandler
1694 If this is @true, the handler will be deleted after it is removed.
1695 The default value is @false.
1696
1697 @see SetEventHandler(), GetEventHandler(),
1698 PushEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
1699 */
1700 wxEvtHandler* PopEventHandler(bool deleteHandler = false) const;
1701
1702 //@{
1703 /**
1704 Pops up the given menu at the specified coordinates, relative to this
1705 window, and returns control when the user has dismissed the menu.
1706
1707 If a menu item is selected, the corresponding menu event is generated and will be
1708 processed as usually. If the coordinates are not specified, current mouse
1709 cursor position is used.
1710
1711 @param menu
1712 Menu to pop up.
1713 @param pos
1714 The position where the menu will appear.
1715 @param x
1716 Required x position for the menu to appear.
1717 @param y
1718 Required y position for the menu to appear.
1719
1720 @remarks Just before the menu is popped up, wxMenu::UpdateUI is called to
1721 ensure that the menu items are in the correct state.
1722 The menu does not get deleted by the window.
1723 It is recommended to not explicitly specify coordinates when
1724 calling PopupMenu in response to mouse click, because some of
1725 the ports (namely, wxGTK) can do a better job of positioning
1726 the menu in that case.
1727
1728 @see wxMenu
1729 */
1730 bool PopupMenu(wxMenu* menu,
1731 const wxPoint& pos = wxDefaultPosition);
1732 bool PopupMenu(wxMenu* menu, int x, int y);
1733 //@}
1734
1735 /**
1736 Posts a size event to the window.
1737
1738 This is the same as SendSizeEvent() with @c wxSEND_EVENT_POST argument.
1739 */
1740 void PostSizeEvent();
1741
1742 /**
1743 Posts a size event to the parent of this window.
1744
1745 This is the same as SendSizeEventToParent() with @c wxSEND_EVENT_POST
1746 argument.
1747 */
1748 void PostSizeEventToParent();
1749
1750 /**
1751 Pushes this event handler onto the event stack for the window.
1752
1753 @param handler
1754 Specifies the handler to be pushed.
1755
1756 @remarks An event handler is an object that is capable of processing the
1757 events sent to a window. By default, the window is its
1758 own event handler, but an application may wish to
1759 substitute another, for example to allow central
1760 implementation of event-handling for a variety of
1761 different window classes.
1762 wxWindow::PushEventHandler allows an application to set up a
1763 chain of event handlers, where an event not handled by one event
1764 handler is handed to the next one in the chain.
1765 Use wxWindow::PopEventHandler to remove the event handler.
1766
1767 @see SetEventHandler(), GetEventHandler(),
1768 PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
1769 */
1770 void PushEventHandler(wxEvtHandler* handler);
1771
1772 /**
1773 Raises the window to the top of the window hierarchy (Z-order).
1774 In current version of wxWidgets this works both for managed and child windows.
1775
1776 @see Lower()
1777 */
1778 void Raise();
1779
1780 /**
1781 Causes this window, and all of its children recursively (except under wxGTK1
1782 where this is not implemented), to be repainted. Note that repainting doesn't
1783 happen immediately but only during the next event loop iteration, if you need
1784 to update the window immediately you should use Update() instead.
1785
1786 @param eraseBackground
1787 If @true, the background will be erased.
1788 @param rect
1789 If non-@NULL, only the given rectangle will be treated as damaged.
1790
1791 @see RefreshRect()
1792 */
1793 virtual void Refresh(bool eraseBackground = true,
1794 const wxRect* rect = NULL);
1795
1796 /**
1797 Redraws the contents of the given rectangle: only the area inside it will be
1798 repainted.
1799
1800 This is the same as Refresh() but has a nicer syntax as it can be called
1801 with a temporary wxRect object as argument like this @c RefreshRect(wxRect(x, y, w, h)).
1802 */
1803 void RefreshRect(const wxRect& rect, bool eraseBackground = true);
1804
1805 /**
1806 Registers a system wide hotkey. Every time the user presses the hotkey
1807 registered here, this window will receive a hotkey event.
1808
1809 It will receive the event even if the application is in the background
1810 and does not have the input focus because the user is working with some
1811 other application.
1812
1813 @param hotkeyId
1814 Numeric identifier of the hotkey. For applications this must be between 0
1815 and 0xBFFF. If this function is called from a shared DLL, it must be a
1816 system wide unique identifier between 0xC000 and 0xFFFF.
1817 This is a MSW specific detail.
1818 @param modifiers
1819 A bitwise combination of wxMOD_SHIFT, wxMOD_CONTROL, wxMOD_ALT
1820 or wxMOD_WIN specifying the modifier keys that have to be pressed along
1821 with the key.
1822 @param virtualKeyCode
1823 The virtual key code of the hotkey.
1824
1825 @return @true if the hotkey was registered successfully. @false if some
1826 other application already registered a hotkey with this
1827 modifier/virtualKeyCode combination.
1828
1829 @remarks Use EVT_HOTKEY(hotkeyId, fnc) in the event table to capture the
1830 event. This function is currently only implemented
1831 under Windows. It is used in the Windows CE port for
1832 detecting hardware button presses.
1833
1834 @see UnregisterHotKey()
1835 */
1836 bool RegisterHotKey(int hotkeyId, int modifiers,
1837 int virtualKeyCode);
1838
1839 /**
1840 Releases mouse input captured with CaptureMouse().
1841
1842 @see CaptureMouse(), HasCapture(), ReleaseMouse(),
1843 wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent
1844 */
1845 virtual void ReleaseMouse();
1846
1847 /**
1848 Removes a child window.
1849
1850 This is called automatically by window deletion functions so should not
1851 be required by the application programmer.
1852 Notice that this function is mostly internal to wxWidgets and shouldn't be
1853 called by the user code.
1854
1855 @param child
1856 Child window to remove.
1857 */
1858 virtual void RemoveChild(wxWindow* child);
1859
1860 /**
1861 Find the given @a handler in the windows event handler chain and remove
1862 (but not delete) it from it.
1863
1864 @param handler
1865 The event handler to remove, must be non-@NULL and
1866 must be present in this windows event handlers chain
1867
1868 @return Returns @true if it was found and @false otherwise (this also
1869 results in an assert failure so this function should
1870 only be called when the handler is supposed to be there).
1871
1872 @see PushEventHandler(), PopEventHandler()
1873 */
1874 bool RemoveEventHandler(wxEvtHandler* handler);
1875
1876 /**
1877 Reparents the window, i.e the window will be removed from its
1878 current parent window (e.g. a non-standard toolbar in a wxFrame)
1879 and then re-inserted into another.
1880
1881 @param newParent
1882 New parent.
1883 */
1884 virtual bool Reparent(wxWindow* newParent);
1885
1886 //@{
1887 /**
1888 Converts from screen to client window coordinates.
1889
1890 @param x
1891 Stores the screen x coordinate and receives the client x coordinate.
1892 @param y
1893 Stores the screen x coordinate and receives the client x coordinate.
1894 @param pt
1895 The screen position for the second form of the function.
1896 */
1897 virtual void ScreenToClient(int* x, int* y) const;
1898 virtual wxPoint ScreenToClient(const wxPoint& pt) const;
1899 //@}
1900
1901 /**
1902 Scrolls the window by the given number of lines down (if @a lines is
1903 positive) or up.
1904
1905 @return Returns @true if the window was scrolled, @false if it was already
1906 on top/bottom and nothing was done.
1907
1908 @remarks This function is currently only implemented under MSW and
1909 wxTextCtrl under wxGTK (it also works for wxScrolled classes
1910 under all platforms).
1911
1912 @see ScrollPages()
1913 */
1914 virtual bool ScrollLines(int lines);
1915
1916 /**
1917 Scrolls the window by the given number of pages down (if @a pages is
1918 positive) or up.
1919
1920 @return Returns @true if the window was scrolled, @false if it was already
1921 on top/bottom and nothing was done.
1922
1923 @remarks This function is currently only implemented under MSW and wxGTK.
1924
1925 @see ScrollLines()
1926 */
1927 virtual bool ScrollPages(int pages);
1928
1929 /**
1930 Physically scrolls the pixels in the window and move child windows accordingly.
1931
1932 @param dx
1933 Amount to scroll horizontally.
1934 @param dy
1935 Amount to scroll vertically.
1936 @param rect
1937 Rectangle to scroll, if it is @NULL, the whole window is
1938 scrolled (this is always the case under wxGTK which doesn't support this
1939 parameter)
1940
1941 @remarks Note that you can often use wxScrolled instead of using this
1942 function directly.
1943 */
1944 virtual void ScrollWindow(int dx, int dy,
1945 const wxRect* rect = NULL);
1946
1947 /**
1948 This function sends a dummy @ref overview_wxsizeevent "size event" to
1949 the window allowing it to re-layout its children positions.
1950
1951 It is sometimes useful to call this function after adding or deleting a
1952 children after the frame creation or if a child size changes. Note that
1953 if the frame is using either sizers or constraints for the children
1954 layout, it is enough to call wxWindow::Layout() directly and this
1955 function should not be used in this case.
1956
1957 If @a flags includes @c wxSEND_EVENT_POST value, this function posts
1958 the event, i.e. schedules it for later processing, instead of
1959 dispatching it directly. You can also use PostSizeEvent() as a more
1960 readable equivalent of calling this function with this flag.
1961
1962 @param flags
1963 May include @c wxSEND_EVENT_POST. Default value is 0.
1964 */
1965 void SendSizeEvent(int flags = 0);
1966
1967 /**
1968 Safe wrapper for GetParent()->SendSizeEvent().
1969
1970 This function simply checks that the window has a valid parent which is
1971 not in process of being deleted and calls SendSizeEvent() on it. It is
1972 used internally by windows such as toolbars changes to whose state
1973 should result in parent re-layout (e.g. when a toolbar is added to the
1974 top of the window, all the other windows must be shifted down).
1975
1976 @see PostSizeEventToParent()
1977
1978 @param flags
1979 See description of this parameter in SendSizeEvent() documentation.
1980 */
1981 void SendSizeEventToParent(int flags = 0);
1982
1983 /**
1984 Sets the accelerator table for this window. See wxAcceleratorTable.
1985 */
1986 virtual void SetAcceleratorTable(const wxAcceleratorTable& accel);
1987
1988 /**
1989 Sets the accessible for this window. Any existing accessible for this window
1990 will be deleted first, if not identical to @e accessible.
1991 See also wxAccessible.
1992 */
1993 void SetAccessible(wxAccessible* accessible);
1994
1995 /**
1996 Determines whether the Layout() function will be called automatically
1997 when the window is resized. Please note that this only happens for the
1998 windows usually used to contain children, namely wxPanel and wxTopLevelWindow
1999 (and the classes deriving from them).
2000
2001 This method is called implicitly by SetSizer() but if you use SetConstraints()
2002 you should call it manually or otherwise the window layout won't be correctly
2003 updated when its size changes.
2004
2005 @param autoLayout
2006 Set this to @true if you wish the Layout function to be
2007 called automatically when the window is resized.
2008
2009 @see SetConstraints()
2010 */
2011 void SetAutoLayout(bool autoLayout);
2012
2013 /**
2014 Sets the background colour of the window.
2015 Please see InheritAttributes() for explanation of the difference between
2016 this method and SetOwnBackgroundColour().
2017
2018 @param colour
2019 The colour to be used as the background colour, pass
2020 wxNullColour to reset to the default colour.
2021
2022 @remarks The background colour is usually painted by the default
2023 wxEraseEvent event handler function under Windows and
2024 automatically under GTK.
2025 Note that setting the background colour does not cause an
2026 immediate refresh, so you may wish to call wxWindow::ClearBackground
2027 or wxWindow::Refresh after calling this function.
2028 Using this function will disable attempts to use themes for
2029 this window, if the system supports them. Use with care since
2030 usually the themes represent the appearance chosen by the user
2031 to be used for all applications on the system.
2032
2033 @see GetBackgroundColour(), SetForegroundColour(),
2034 GetForegroundColour(), ClearBackground(),
2035 Refresh(), wxEraseEvent
2036 */
2037 virtual bool SetBackgroundColour(const wxColour& colour);
2038
2039 /**
2040 Sets the background style of the window. see GetBackgroundStyle() for
2041 the description of the possible style values.
2042
2043 @see SetBackgroundColour(), GetForegroundColour(),
2044 SetTransparent()
2045 */
2046 virtual void SetBackgroundStyle(wxBackgroundStyle style);
2047
2048 /**
2049 This method is only implemented by ports which have support for
2050 native TAB traversal (such as GTK+ 2.0).
2051
2052 It is called by wxWidgets' container control code to give the native
2053 system a hint when doing TAB traversal. A call to this does not disable
2054 or change the effect of programmatically calling SetFocus().
2055
2056 @see wxFocusEvent, wxPanel::SetFocus, wxPanel::SetFocusIgnoringChildren
2057 */
2058 virtual void SetCanFocus(bool canFocus);
2059
2060 /**
2061 Sets the caret() associated with the window.
2062 */
2063 void SetCaret(wxCaret* caret) const;
2064
2065 //@{
2066 /**
2067 This sets the size of the window client area in pixels.
2068
2069 Using this function to size a window tends to be more device-independent
2070 than SetSize(), since the application need not worry about what dimensions
2071 the border or title bar have when trying to fit the window around panel
2072 items, for example.
2073
2074 @param width
2075 The required client area width.
2076 @param height
2077 The required client area height.
2078 @param size
2079 The required client size.
2080 */
2081 virtual void SetClientSize(int width, int height);
2082 virtual void SetClientSize(const wxSize& size);
2083 //@}
2084
2085 /**
2086 Sets the window to have the given layout constraints. The window
2087 will then own the object, and will take care of its deletion.
2088 If an existing layout constraints object is already owned by the
2089 window, it will be deleted.
2090
2091 @param constraints
2092 The constraints to set. Pass @NULL to disassociate and delete the window's
2093 constraints.
2094
2095 @remarks You must call SetAutoLayout() to tell a window to use
2096 the constraints automatically in OnSize; otherwise, you
2097 must override OnSize and call Layout() explicitly. When
2098 setting both a wxLayoutConstraints and a wxSizer, only
2099 the sizer will have effect.
2100 */
2101 void SetConstraints(wxLayoutConstraints* constraints);
2102
2103 /**
2104 This normally does not need to be called by user code.
2105 It is called when a window is added to a sizer, and is used so the window
2106 can remove itself from the sizer when it is destroyed.
2107 */
2108 void SetContainingSizer(wxSizer* sizer);
2109
2110 /**
2111 Sets the window's cursor. Notice that the window cursor also sets it for the
2112 children of the window implicitly.
2113
2114 The @a cursor may be @c wxNullCursor in which case the window cursor will
2115 be reset back to default.
2116
2117 @param cursor
2118 Specifies the cursor that the window should normally display.
2119
2120 @see ::wxSetCursor, wxCursor
2121 */
2122 virtual void SetCursor(const wxCursor& cursor);
2123
2124 /**
2125 Associates a drop target with this window.
2126 If the window already has a drop target, it is deleted.
2127
2128 @see GetDropTarget(), @ref overview_dnd
2129 */
2130 void SetDropTarget(wxDropTarget* target);
2131
2132 /**
2133 Sets the event handler for this window.
2134
2135 @param handler
2136 Specifies the handler to be set.
2137
2138 @remarks An event handler is an object that is capable of processing the
2139 events sent to a window. By default, the window is its
2140 own event handler, but an application may wish to
2141 substitute another, for example to allow central
2142 implementation of event-handling for a variety of
2143 different window classes.
2144 It is usually better to use wxWindow::PushEventHandler since
2145 this sets up a chain of event handlers, where an event not
2146 handled by one event handler is handed to the next one in the chain.
2147
2148 @see GetEventHandler(), PushEventHandler(),
2149 PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
2150 */
2151 void SetEventHandler(wxEvtHandler* handler);
2152
2153 /**
2154 Sets the extra style bits for the window.
2155 The currently defined extra style bits are reported in the class
2156 description.
2157 */
2158 void SetExtraStyle(long exStyle);
2159
2160 /**
2161 This sets the window to receive keyboard input.
2162
2163 @see HasFocus(), wxFocusEvent, wxPanel::SetFocus,
2164 wxPanel::SetFocusIgnoringChildren
2165 */
2166 virtual void SetFocus();
2167
2168 /**
2169 This function is called by wxWidgets keyboard navigation code when the user
2170 gives the focus to this window from keyboard (e.g. using @c TAB key).
2171
2172 By default this method simply calls SetFocus() but
2173 can be overridden to do something in addition to this in the derived classes.
2174 */
2175 virtual void SetFocusFromKbd();
2176
2177 /**
2178 Sets the font for this window. This function should not be called for the
2179 parent window if you don't want its font to be inherited by its children,
2180 use SetOwnFont() instead in this case and see InheritAttributes() for more
2181 explanations.
2182
2183 Please notice that the given font is not automatically used for
2184 wxPaintDC objects associated with this window, you need to
2185 call wxDC::SetFont too. However this font is used by
2186 any standard controls for drawing their text as well as by
2187 GetTextExtent().
2188
2189 @param font
2190 Font to associate with this window, pass
2191 wxNullFont to reset to the default font.
2192
2193 @return @true if the want was really changed, @false if it was already set
2194 to this font and so nothing was done.
2195
2196 @see GetFont(), InheritAttributes()
2197 */
2198 bool SetFont(const wxFont& font);
2199
2200 /**
2201 Sets the foreground colour of the window.
2202 Please see InheritAttributes() for explanation of the difference between
2203 this method and SetOwnForegroundColour().
2204
2205 @param colour
2206 The colour to be used as the foreground colour, pass
2207 wxNullColour to reset to the default colour.
2208
2209 @remarks The interpretation of foreground colour is open to
2210 interpretation according to the window class; it may be
2211 the text colour or other colour, or it may not be used at all.
2212
2213 @see GetForegroundColour(), SetBackgroundColour(),
2214 GetBackgroundColour(), ShouldInheritColours()
2215 */
2216 virtual void SetForegroundColour(const wxColour& colour);
2217
2218 /**
2219 Sets the help text to be used as context-sensitive help for this window.
2220 Note that the text is actually stored by the current wxHelpProvider
2221 implementation, and not in the window object itself.
2222
2223 @see GetHelpText(), wxHelpProvider::AddHelp()
2224 */
2225 virtual void SetHelpText(const wxString& helpText);
2226
2227 /**
2228 Sets the identifier of the window.
2229
2230 @remarks Each window has an integer identifier. If the application has
2231 not provided one, an identifier will be generated.
2232 Normally, the identifier should be provided on creation
2233 and should not be modified subsequently.
2234
2235 @see GetId(), @ref overview_windowids
2236 */
2237 void SetId(int id);
2238
2239 /**
2240 Sets the initial window size if none is given (i.e. at least one of the
2241 components of the size passed to ctor/Create() is wxDefaultCoord).
2242 */
2243 virtual void SetInitialBestSize(const wxSize& size);
2244
2245 /**
2246 A @e smart SetSize that will fill in default size components with the
2247 window's @e best size values.
2248
2249 Also sets the window's minsize to the value passed in for use with sizers.
2250 This means that if a full or partial size is passed to this function then
2251 the sizers will use that size instead of the results of GetBestSize() to
2252 determine the minimum needs of the window for layout.
2253
2254 Most controls will use this to set their initial size, and their min
2255 size to the passed in value (if any.)
2256
2257 @see SetSize(), GetBestSize(), GetEffectiveMinSize(),
2258 @ref overview_windowsizing
2259 */
2260 void SetInitialSize(const wxSize& size = wxDefaultSize);
2261
2262 /**
2263 Sets the window's label.
2264
2265 @param label
2266 The window label.
2267
2268 @see GetLabel()
2269 */
2270 virtual void SetLabel(const wxString& label);
2271
2272 /**
2273 Sets the maximum client size of the window, to indicate to the sizer
2274 layout mechanism that this is the maximum possible size of its client area.
2275
2276 @see SetMaxSize()
2277 */
2278 void SetMaxClientSize(const wxSize& size);
2279
2280 /**
2281 Sets the maximum size of the window, to indicate to the sizer layout mechanism
2282 that this is the maximum possible size.
2283
2284 @see SetMaxClientSize()
2285 */
2286 void SetMaxSize(const wxSize& size);
2287
2288 /**
2289 Sets the minimum client size of the window, to indicate to the sizer
2290 layout mechanism that this is the minimum required size of window's client
2291 area.
2292
2293 You may need to call this if you change the window size after
2294 construction and before adding to its parent sizer.
2295
2296 Note, that just as with SetMinSize(), calling this method doesn't
2297 prevent the program from explicitly making the window smaller than the
2298 specified size.
2299
2300 @see SetMinSize()
2301 */
2302 void SetMinClientSize(const wxSize& size);
2303
2304 /**
2305 Sets the minimum size of the window, to indicate to the sizer layout
2306 mechanism that this is the minimum required size.
2307
2308 You may need to call this if you change the window size after
2309 construction and before adding to its parent sizer.
2310
2311 Notice that calling this method doesn't prevent the program from making
2312 the window explicitly smaller than the specified size by calling
2313 SetSize(), it just ensures that it won't become smaller than this size
2314 during the automatic layout.
2315
2316 @see SetMinClientSize()
2317 */
2318 void SetMinSize(const wxSize& size);
2319
2320 /**
2321 Sets the window's name.
2322
2323 @param name
2324 A name to set for the window.
2325
2326 @see GetName()
2327 */
2328 virtual void SetName(const wxString& name);
2329
2330 /**
2331 Sets the background colour of the window but prevents it from being inherited
2332 by the children of this window.
2333
2334 @see SetBackgroundColour(), InheritAttributes()
2335 */
2336 void SetOwnBackgroundColour(const wxColour& colour);
2337
2338 /**
2339 Sets the font of the window but prevents it from being inherited by the
2340 children of this window.
2341
2342 @see SetFont(), InheritAttributes()
2343 */
2344 void SetOwnFont(const wxFont& font);
2345
2346 /**
2347 Sets the foreground colour of the window but prevents it from being inherited
2348 by the children of this window.
2349
2350 @see SetForegroundColour(), InheritAttributes()
2351 */
2352 void SetOwnForegroundColour(const wxColour& colour);
2353
2354 /**
2355 @deprecated use wxDC::SetPalette instead.
2356 */
2357 virtual void SetPalette(wxPalette* palette);
2358
2359 /**
2360 Sets the position of one of the built-in scrollbars.
2361
2362 @param orientation
2363 Determines the scrollbar whose position is to be set.
2364 May be wxHORIZONTAL or wxVERTICAL.
2365 @param pos
2366 Position in scroll units.
2367 @param refresh
2368 @true to redraw the scrollbar, @false otherwise.
2369
2370 @remarks This function does not directly affect the contents of the
2371 window: it is up to the application to take note of
2372 scrollbar attributes and redraw contents accordingly.
2373
2374 @see SetScrollbar(), GetScrollPos(), GetScrollThumb(), wxScrollBar,
2375 wxScrolled
2376 */
2377 virtual void SetScrollPos(int orientation, int pos,
2378 bool refresh = true);
2379
2380 /**
2381 Sets the scrollbar properties of a built-in scrollbar.
2382
2383 @param orientation
2384 Determines the scrollbar whose page size is to be set.
2385 May be wxHORIZONTAL or wxVERTICAL.
2386 @param position
2387 The position of the scrollbar in scroll units.
2388 @param thumbSize
2389 The size of the thumb, or visible portion of the scrollbar, in scroll units.
2390 @param range
2391 The maximum position of the scrollbar.
2392 @param refresh
2393 @true to redraw the scrollbar, @false otherwise.
2394
2395 @remarks
2396 Let's say you wish to display 50 lines of text, using the same font.
2397 The window is sized so that you can only see 16 lines at a time.
2398 You would use:
2399 @code
2400 SetScrollbar(wxVERTICAL, 0, 16, 50);
2401 @endcode
2402 Note that with the window at this size, the thumb position can never
2403 go above 50 minus 16, or 34. You can determine how many lines are
2404 currently visible by dividing the current view size by the character
2405 height in pixels.
2406 When defining your own scrollbar behaviour, you will always need
2407 to recalculate the scrollbar settings when the window size changes.
2408 You could therefore put your scrollbar calculations and SetScrollbar
2409 call into a function named AdjustScrollbars, which can be called
2410 initially and also from your wxSizeEvent handler function.
2411
2412 @see @ref overview_scrolling, wxScrollBar, wxScrolled, wxScrollWinEvent
2413 */
2414 virtual void SetScrollbar(int orientation, int position,
2415 int thumbSize, int range,
2416 bool refresh = true);
2417
2418 /**
2419 Sets the size of the window in pixels.
2420
2421 @param x
2422 Required x position in pixels, or wxDefaultCoord to indicate that the
2423 existing value should be used.
2424 @param y
2425 Required y position in pixels, or wxDefaultCoord to indicate that the
2426 existing value should be used.
2427 @param width
2428 Required width in pixels, or wxDefaultCoord to indicate that the existing
2429 value should be used.
2430 @param height
2431 Required height position in pixels, or wxDefaultCoord to indicate that the
2432 existing value should be used.
2433 @param sizeFlags
2434 Indicates the interpretation of other parameters.
2435 It is a bit list of the following:
2436 - @c wxSIZE_AUTO_WIDTH: a wxDefaultCoord width value is taken to indicate
2437 a wxWidgets-supplied default width.
2438 - @c wxSIZE_AUTO_HEIGHT: a wxDefaultCoord height value is taken to indicate
2439 a wxWidgets-supplied default height.
2440 - @c wxSIZE_AUTO: wxDefaultCoord size values are taken to indicate
2441 a wxWidgets-supplied default size.
2442 - @c wxSIZE_USE_EXISTING: existing dimensions should be used
2443 if wxDefaultCoord values are supplied.
2444 - @c wxSIZE_ALLOW_MINUS_ONE: allow negative dimensions (i.e. value of
2445 wxDefaultCoord) to be interpreted as real
2446 dimensions, not default values.
2447 - @c wxSIZE_FORCE: normally, if the position and the size of the window are
2448 already the same as the parameters of this function,
2449 nothing is done. but with this flag a window resize may
2450 be forced even in this case (supported in wx 2.6.2 and
2451 later and only implemented for MSW and ignored elsewhere
2452 currently).
2453
2454 @remarks This overload sets the position and optionally size, of the window.
2455 Parameters may be wxDefaultCoord to indicate either that a default
2456 should be supplied by wxWidgets, or that the current value of the
2457 dimension should be used.
2458
2459 @see Move()
2460 */
2461 virtual void SetSize(int x, int y, int width, int height,
2462 int sizeFlags = wxSIZE_AUTO);
2463
2464 //@{
2465 /**
2466 Sets the size of the window in pixels.
2467 The size is specified using a wxRect, wxSize or by a couple of @c int objects.
2468
2469 @remarks This form must be used with non-default width and height values.
2470
2471 @see Move()
2472 */
2473 virtual void SetSize(const wxRect& rect);
2474 virtual void SetSize(const wxSize& size);
2475 virtual void SetSize(int width, int height);
2476 //@}
2477
2478 /**
2479 Sets the window to have the given layout sizer.
2480 The window will then own the object, and will take care of its deletion.
2481 If an existing layout constraints object is already owned by the
2482 window, it will be deleted if the deleteOld parameter is @true.
2483
2484 Note that this function will also call SetAutoLayout() implicitly with @true
2485 parameter if the @a sizer is non-@NULL and @false otherwise.
2486
2487 @param sizer
2488 The sizer to set. Pass @NULL to disassociate and conditionally delete
2489 the window's sizer. See below.
2490 @param deleteOld
2491 If @true (the default), this will delete any pre-existing sizer.
2492 Pass @false if you wish to handle deleting the old sizer yourself.
2493
2494 @remarks SetSizer enables and disables Layout automatically.
2495 */
2496 void SetSizer(wxSizer* sizer, bool deleteOld = true);
2497
2498 /**
2499 This method calls SetSizer() and then wxSizer::SetSizeHints which sets the initial
2500 window size to the size needed to accommodate all sizer elements and sets the
2501 size hints which, if this window is a top level one, prevent the user from
2502 resizing it to be less than this minimial size.
2503 */
2504 void SetSizerAndFit(wxSizer* sizer, bool deleteOld = true);
2505
2506 /**
2507 This function tells a window if it should use the system's "theme" code
2508 to draw the windows' background instead if its own background drawing
2509 code. This does not always have any effect since the underlying platform
2510 obviously needs to support the notion of themes in user defined windows.
2511 One such platform is GTK+ where windows can have (very colourful) backgrounds
2512 defined by a user's selected theme.
2513
2514 Dialogs, notebook pages and the status bar have this flag set to @true
2515 by default so that the default look and feel is simulated best.
2516 */
2517 virtual void SetThemeEnabled(bool enable);
2518
2519 //@{
2520 /**
2521 Attach a tooltip to the window.
2522
2523 wxToolTip pointer can be @NULL in the overload taking the pointer,
2524 meaning to unset any existing tooltips, however UnsetToolTip() provides
2525 a more readable alternative to this operation.
2526
2527 Notice that these methods are always available, even if wxWidgets was
2528 compiled with @c wxUSE_TOOLTIPS set to 0, but don't do anything in this
2529 case.
2530
2531 @see GetToolTip(), wxToolTip
2532 */
2533 void SetToolTip(const wxString& tip);
2534 void SetToolTip(wxToolTip* tip);
2535 //@}
2536
2537 /**
2538 Set the transparency of the window. If the system supports transparent windows,
2539 returns @true, otherwise returns @false and the window remains fully opaque.
2540 See also CanSetTransparent().
2541
2542 The parameter @a alpha is in the range 0..255 where 0 corresponds to a
2543 fully transparent window and 255 to the fully opaque one. The constants
2544 @c wxIMAGE_ALPHA_TRANSPARENT and @c wxIMAGE_ALPHA_OPAQUE can be used.
2545 */
2546 bool SetTransparent(wxByte alpha);
2547
2548 /**
2549 Deletes the current validator (if any) and sets the window validator, having
2550 called wxValidator::Clone to create a new validator of this type.
2551 */
2552 virtual void SetValidator(const wxValidator& validator);
2553
2554 //@{
2555 /**
2556 Sets the virtual size of the window in pixels.
2557 */
2558 void SetVirtualSize(int width, int height);
2559 void SetVirtualSize(const wxSize& size);
2560 //@}
2561
2562 /**
2563 Identical to SetWindowStyleFlag().
2564 */
2565 void SetWindowStyle(long style);
2566
2567 /**
2568 Sets the style of the window. Please note that some styles cannot be changed
2569 after the window creation and that Refresh() might need to be be called
2570 after changing the others for the change to take place immediately.
2571
2572 See @ref overview_windowstyles "Window styles" for more information about flags.
2573
2574 @see GetWindowStyleFlag()
2575 */
2576 virtual void SetWindowStyleFlag(long style);
2577
2578 /**
2579 This function can be called under all platforms but only does anything under
2580 Mac OS X 10.3+ currently. Under this system, each of the standard control can
2581 exist in several sizes which correspond to the elements of wxWindowVariant enum.
2582
2583 By default the controls use the normal size, of course, but this function can
2584 be used to change this.
2585 */
2586 void SetWindowVariant(wxWindowVariant variant);
2587
2588 /**
2589 Return @true from here to allow the colours of this window to be changed by
2590 InheritAttributes(), returning @false forbids inheriting them from the parent window.
2591
2592 The base class version returns @false, but this method is overridden in
2593 wxControl where it returns @true.
2594 */
2595 virtual bool ShouldInheritColours();
2596
2597 /**
2598 Shows or hides the window. You may need to call Raise()
2599 for a top level window if you want to bring it to top, although this is not
2600 needed if Show() is called immediately after the frame creation.
2601
2602 @param show
2603 If @true displays the window. Otherwise, hides it.
2604
2605 @return @true if the window has been shown or hidden or @false if nothing
2606 was done because it already was in the requested state.
2607
2608 @see IsShown(), Hide(), wxRadioBox::Show, wxShowEvent.
2609 */
2610 virtual bool Show(bool show = true);
2611
2612 /**
2613 This function shows a window, like Show(), but using a special visual
2614 effect if possible.
2615
2616 @param effect
2617 The effect to use.
2618
2619 @param timeout
2620 The @a timeout parameter specifies the time of the animation, in
2621 milliseconds. If the default value of 0 is used, the default
2622 animation time for the current platform is used.
2623
2624 @note Currently this function is only implemented in wxMSW and does the
2625 same thing as Show() in the other ports.
2626
2627 @since 2.9.0
2628
2629 @see HideWithEffect()
2630 */
2631 virtual bool ShowWithEffect(wxShowEffect effect,
2632 unsigned timeout = 0);
2633
2634 /**
2635 Reenables window updating after a previous call to Freeze().
2636
2637 To really thaw the control, it must be called exactly the same number
2638 of times as Freeze().
2639
2640 If the window has any children, they are recursively thawn too.
2641
2642 @see wxWindowUpdateLocker, Freeze(), IsFrozen()
2643 */
2644 virtual void Thaw();
2645
2646 /**
2647 Turns the given @a flag on if it's currently turned off and vice versa.
2648 This function cannot be used if the value of the flag is 0 (which is often
2649 the case for default flags).
2650
2651 Also, please notice that not all styles can be changed after the control
2652 creation.
2653
2654 @return Returns @true if the style was turned on by this function, @false
2655 if it was switched off.
2656
2657 @see SetWindowStyleFlag(), HasFlag()
2658 */
2659 bool ToggleWindowStyle(int flag);
2660
2661 /**
2662 Transfers values from child controls to data areas specified by their
2663 validators. Returns @false if a transfer failed.
2664
2665 If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
2666 the method will also call TransferDataFromWindow() of all child windows.
2667
2668 @see TransferDataToWindow(), wxValidator, Validate()
2669 */
2670 virtual bool TransferDataFromWindow();
2671
2672 /**
2673 Transfers values to child controls from data areas specified by their
2674 validators.
2675
2676 If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
2677 the method will also call TransferDataToWindow() of all child windows.
2678
2679 @return Returns @false if a transfer failed.
2680
2681 @see TransferDataFromWindow(), wxValidator, Validate()
2682 */
2683 virtual bool TransferDataToWindow();
2684
2685 /**
2686 Unregisters a system wide hotkey.
2687
2688 @param hotkeyId
2689 Numeric identifier of the hotkey. Must be the same id that was passed to
2690 RegisterHotKey().
2691
2692 @return @true if the hotkey was unregistered successfully, @false if the
2693 id was invalid.
2694
2695 @remarks This function is currently only implemented under MSW.
2696
2697 @see RegisterHotKey()
2698 */
2699 bool UnregisterHotKey(int hotkeyId);
2700
2701 /**
2702 Unreserve an ID or range of IDs that was reserved by NewControlId().
2703 See @ref overview_windowids for more information.
2704
2705 @param id
2706 The starting ID of the range of IDs to unreserve.
2707 @param count
2708 The number of sequential IDs to unreserve.
2709
2710 @see NewControlId(), wxIdManager, @ref overview_windowids
2711 */
2712 static void UnreserveControlId(wxWindowID id, int count = 1);
2713
2714 /**
2715 Unset any existing tooltip.
2716
2717 @since 2.9.0
2718
2719 @see SetToolTip()
2720 */
2721 void UnsetToolTip();
2722
2723 /**
2724 Calling this method immediately repaints the invalidated area of the window and
2725 all of its children recursively while this would usually only happen when the
2726 flow of control returns to the event loop.
2727
2728 Notice that this function doesn't invalidate any area of the window so
2729 nothing happens if nothing has been invalidated (i.e. marked as requiring
2730 a redraw). Use Refresh() first if you want to immediately redraw the
2731 window unconditionally.
2732 */
2733 virtual void Update();
2734
2735 /**
2736 This function sends one or more wxUpdateUIEvent to the window.
2737 The particular implementation depends on the window; for example a
2738 wxToolBar will send an update UI event for each toolbar button,
2739 and a wxFrame will send an update UI event for each menubar menu item.
2740
2741 You can call this function from your application to ensure that your
2742 UI is up-to-date at this point (as far as your wxUpdateUIEvent handlers
2743 are concerned). This may be necessary if you have called
2744 wxUpdateUIEvent::SetMode() or wxUpdateUIEvent::SetUpdateInterval() to limit
2745 the overhead that wxWidgets incurs by sending update UI events in idle time.
2746 @a flags should be a bitlist of one or more of the wxUpdateUI enumeration.
2747
2748 If you are calling this function from an OnInternalIdle or OnIdle
2749 function, make sure you pass the wxUPDATE_UI_FROMIDLE flag, since
2750 this tells the window to only update the UI elements that need
2751 to be updated in idle time. Some windows update their elements
2752 only when necessary, for example when a menu is about to be shown.
2753 The following is an example of how to call UpdateWindowUI from
2754 an idle function.
2755
2756 @code
2757 void MyWindow::OnInternalIdle()
2758 {
2759 if (wxUpdateUIEvent::CanUpdate(this))
2760 UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
2761 }
2762 @endcode
2763
2764 @see wxUpdateUIEvent, DoUpdateWindowUI(), OnInternalIdle()
2765 */
2766 virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
2767
2768 /**
2769 Validates the current values of the child controls using their validators.
2770 If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
2771 the method will also call Validate() of all child windows.
2772
2773 @return Returns @false if any of the validations failed.
2774
2775 @see TransferDataFromWindow(), TransferDataToWindow(),
2776 wxValidator
2777 */
2778 virtual bool Validate();
2779
2780 /**
2781 Moves the pointer to the given position on the window.
2782
2783 @note This function is not supported under Mac because Apple Human
2784 Interface Guidelines forbid moving the mouse cursor programmatically.
2785
2786 @param x
2787 The new x position for the cursor.
2788 @param y
2789 The new y position for the cursor.
2790 */
2791 void WarpPointer(int x, int y);
2792 };
2793
2794
2795
2796 // ============================================================================
2797 // Global functions/macros
2798 // ============================================================================
2799
2800 /** @ingroup group_funcmacro_misc */
2801 //@{
2802
2803 /**
2804 Find the deepest window at the mouse pointer position, returning the window
2805 and current pointer position in screen coordinates.
2806
2807 @header{wx/window.h}
2808 */
2809 wxWindow* wxFindWindowAtPointer(wxPoint& pt);
2810
2811 /**
2812 Gets the currently active window (implemented for MSW and GTK only
2813 currently, always returns @NULL in the other ports).
2814
2815 @header{wx/window.h}
2816 */
2817 wxWindow* wxGetActiveWindow();
2818
2819 /**
2820 Returns the first top level parent of the given window, or in other words,
2821 the frame or dialog containing it, or @NULL.
2822
2823 @header{wx/window.h}
2824 */
2825 wxWindow* wxGetTopLevelParent(wxWindow* window);
2826
2827 //@}
2828