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