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