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