]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.h | |
e54c96f1 | 3 | // Purpose: interface of wxWindow |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
e25cd775 | 8 | |
e25cd775 FM |
9 | /** |
10 | Valid values for wxWindow::ShowWithEffect() and wxWindow::HideWithEffect(). | |
11 | */ | |
12 | enum wxShowEffect | |
13 | { | |
ffa50e73 VZ |
14 | /** |
15 | No effect, equivalent to normal wxWindow::Show() or Hide() call. | |
16 | ||
17 | @since 2.9.1 | |
18 | */ | |
19 | wxSHOW_EFFECT_NONE, | |
20 | ||
e25cd775 FM |
21 | /// Roll window to the left |
22 | wxSHOW_EFFECT_ROLL_TO_LEFT, | |
23 | ||
24 | /// Roll window to the right | |
25 | wxSHOW_EFFECT_ROLL_TO_RIGHT, | |
26 | ||
27 | /// Roll window to the top | |
28 | wxSHOW_EFFECT_ROLL_TO_TOP, | |
29 | ||
30 | /// Roll window to the bottom | |
31 | wxSHOW_EFFECT_ROLL_TO_BOTTOM, | |
32 | ||
33 | /// Slide window to the left | |
34 | wxSHOW_EFFECT_SLIDE_TO_LEFT, | |
35 | ||
36 | /// Slide window to the right | |
37 | wxSHOW_EFFECT_SLIDE_TO_RIGHT, | |
38 | ||
39 | /// Slide window to the top | |
40 | wxSHOW_EFFECT_SLIDE_TO_TOP, | |
41 | ||
42 | /// Slide window to the bottom | |
43 | wxSHOW_EFFECT_SLIDE_TO_BOTTOM, | |
44 | ||
45 | /// Fade in or out effect | |
46 | wxSHOW_EFFECT_BLEND, | |
47 | ||
48 | /// Expanding or collapsing effect | |
89eeba54 RD |
49 | wxSHOW_EFFECT_EXPAND, |
50 | ||
51 | wxSHOW_EFFECT_MAX | |
e25cd775 FM |
52 | }; |
53 | ||
05b0355a | 54 | |
6b3b86fe RD |
55 | /** |
56 | flags for SendSizeEvent() | |
57 | */ | |
58 | enum | |
59 | { | |
60 | wxSEND_EVENT_POST = 1 | |
61 | }; | |
62 | ||
63 | ||
64 | ||
05b0355a RD |
65 | |
66 | /** | |
1995d517 | 67 | Struct containing all the visual attributes of a control. |
05b0355a RD |
68 | */ |
69 | struct wxVisualAttributes | |
70 | { | |
1995d517 | 71 | /// The font used for control label/text inside it. |
05b0355a RD |
72 | wxFont font; |
73 | ||
1995d517 | 74 | /// The foreground colour. |
05b0355a RD |
75 | wxColour colFg; |
76 | ||
1995d517 VZ |
77 | /** |
78 | The background colour. | |
79 | ||
80 | May be wxNullColour if the controls background colour is not solid. | |
81 | */ | |
05b0355a RD |
82 | wxColour colBg; |
83 | }; | |
84 | ||
85 | ||
e25cd775 FM |
86 | /** |
87 | Different window variants, on platforms like eg mac uses different | |
88 | rendering sizes. | |
89 | */ | |
90 | enum wxWindowVariant | |
91 | { | |
92 | wxWINDOW_VARIANT_NORMAL, //!< Normal size | |
93 | wxWINDOW_VARIANT_SMALL, //!< Smaller size (about 25 % smaller than normal) | |
94 | wxWINDOW_VARIANT_MINI, //!< Mini size (about 33 % smaller than normal) | |
95 | wxWINDOW_VARIANT_LARGE, //!< Large size (about 25 % larger than normal) | |
96 | wxWINDOW_VARIANT_MAX | |
97 | }; | |
98 | ||
99 | ||
23324ae1 FM |
100 | /** |
101 | @class wxWindow | |
7c913512 | 102 | |
e25cd775 | 103 | wxWindow is the base class for all windows and represents any visible object |
ccd4e1bc | 104 | on screen. All controls, top level windows and so on are windows. Sizers and |
23324ae1 | 105 | device contexts are not, however, as they don't appear on screen themselves. |
7c913512 | 106 | |
23324ae1 FM |
107 | Please note that all children of the window will be deleted automatically by |
108 | the destructor before the window itself is deleted which means that you don't | |
109 | have to worry about deleting them manually. Please see the @ref | |
962fb6d2 | 110 | overview_windowdeletion "window deletion overview" for more information. |
7c913512 | 111 | |
23324ae1 FM |
112 | Also note that in this, and many others, wxWidgets classes some |
113 | @c GetXXX() methods may be overloaded (as, for example, | |
962fb6d2 | 114 | wxWindow::GetSize or wxWindow::GetClientSize). In this case, the overloads |
23324ae1 FM |
115 | are non-virtual because having multiple virtual functions with the same name |
116 | results in a virtual function name hiding at the derived class level (in | |
117 | English, this means that the derived class has to override all overloaded | |
118 | variants if it overrides any of them). To allow overriding them in the derived | |
119 | class, wxWidgets uses a unique protected virtual @c DoGetXXX() method | |
120 | and all @c GetXXX() ones are forwarded to it, so overriding the former | |
121 | changes the behaviour of the latter. | |
7c913512 | 122 | |
23324ae1 | 123 | @beginStyleTable |
8c6791e4 | 124 | @style{wxBORDER_DEFAULT} |
23324ae1 | 125 | The window class will decide the kind of border to show, if any. |
8c6791e4 | 126 | @style{wxBORDER_SIMPLE} |
23324ae1 FM |
127 | Displays a thin border around the window. wxSIMPLE_BORDER is the |
128 | old name for this style. | |
8c6791e4 | 129 | @style{wxBORDER_SUNKEN} |
23324ae1 FM |
130 | Displays a sunken border. wxSUNKEN_BORDER is the old name for this |
131 | style. | |
8c6791e4 | 132 | @style{wxBORDER_RAISED} |
23324ae1 FM |
133 | Displays a raised border. wxRAISED_BORDER is the old name for this |
134 | style. | |
8c6791e4 | 135 | @style{wxBORDER_STATIC} |
23324ae1 FM |
136 | Displays a border suitable for a static control. wxSTATIC_BORDER |
137 | is the old name for this style. Windows only. | |
8c6791e4 | 138 | @style{wxBORDER_THEME} |
23324ae1 FM |
139 | Displays a native border suitable for a control, on the current |
140 | platform. On Windows XP or Vista, this will be a themed border; on | |
141 | most other platforms a sunken border will be used. For more | |
142 | information for themed borders on Windows, please see Themed | |
143 | borders on Windows. | |
8c6791e4 | 144 | @style{wxBORDER_NONE} |
23324ae1 FM |
145 | Displays no border, overriding the default border style for the |
146 | window. wxNO_BORDER is the old name for this style. | |
8c6791e4 | 147 | @style{wxBORDER_DOUBLE} |
23324ae1 | 148 | This style is obsolete and should not be used. |
8c6791e4 | 149 | @style{wxTRANSPARENT_WINDOW} |
23324ae1 FM |
150 | The window is transparent, that is, it will not receive paint |
151 | events. Windows only. | |
8c6791e4 | 152 | @style{wxTAB_TRAVERSAL} |
23324ae1 | 153 | Use this to enable tab traversal for non-dialog windows. |
8c6791e4 | 154 | @style{wxWANTS_CHARS} |
23324ae1 FM |
155 | Use this to indicate that the window wants to get all char/key |
156 | events for all keys - even for keys like TAB or ENTER which are | |
157 | usually used for dialog navigation and which wouldn't be generated | |
158 | without this style. If you need to use this style in order to get | |
159 | the arrows or etc., but would still like to have normal keyboard | |
160 | navigation take place, you should call Navigate in response to the | |
161 | key events for Tab and Shift-Tab. | |
8c6791e4 | 162 | @style{wxNO_FULL_REPAINT_ON_RESIZE} |
23324ae1 FM |
163 | On Windows, this style used to disable repainting the window |
164 | completely when its size is changed. Since this behaviour is now | |
165 | the default, the style is now obsolete and no longer has an effect. | |
8c6791e4 | 166 | @style{wxVSCROLL} |
23324ae1 FM |
167 | Use this style to enable a vertical scrollbar. Notice that this |
168 | style cannot be used with native controls which don't support | |
169 | scrollbars nor with top-level windows in most ports. | |
8c6791e4 | 170 | @style{wxHSCROLL} |
23324ae1 FM |
171 | Use this style to enable a horizontal scrollbar. The same |
172 | limitations as for wxVSCROLL apply to this style. | |
8c6791e4 | 173 | @style{wxALWAYS_SHOW_SB} |
23324ae1 FM |
174 | If a window has scrollbars, disable them instead of hiding them |
175 | when they are not needed (i.e. when the size of the window is big | |
176 | enough to not require the scrollbars to navigate it). This style is | |
177 | currently implemented for wxMSW, wxGTK and wxUniversal and does | |
178 | nothing on the other platforms. | |
8c6791e4 | 179 | @style{wxCLIP_CHILDREN} |
23324ae1 FM |
180 | Use this style to eliminate flicker caused by the background being |
181 | repainted, then children being painted over them. Windows only. | |
8c6791e4 | 182 | @style{wxFULL_REPAINT_ON_RESIZE} |
23324ae1 FM |
183 | Use this style to force a complete redraw of the window whenever it |
184 | is resized instead of redrawing just the part of the window | |
185 | affected by resizing. Note that this was the behaviour by default | |
186 | before 2.5.1 release and that if you experience redraw problems | |
187 | with code which previously used to work you may want to try this. | |
188 | Currently this style applies on GTK+ 2 and Windows only, and full | |
189 | repainting is always done on other platforms. | |
190 | @endStyleTable | |
7c913512 | 191 | |
23324ae1 | 192 | @beginExtraStyleTable |
8c6791e4 | 193 | @style{wxWS_EX_VALIDATE_RECURSIVELY} |
141794f1 FM |
194 | By default, wxWindow::Validate(), wxWindow::TransferDataTo() and |
195 | wxWindow::TransferDataFromWindow() only work on | |
196 | direct children of the window (compatible behaviour). | |
197 | Set this flag to make them recursively descend into all subwindows. | |
8c6791e4 | 198 | @style{wxWS_EX_BLOCK_EVENTS} |
23324ae1 FM |
199 | wxCommandEvents and the objects of the derived classes are |
200 | forwarded to the parent window and so on recursively by default. | |
201 | Using this flag for the given window allows to block this | |
202 | propagation at this window, i.e. prevent the events from being | |
e25cd775 | 203 | propagated further upwards. Dialogs have this flag on by default |
3e083d65 | 204 | for the reasons explained in the @ref overview_events. |
8c6791e4 | 205 | @style{wxWS_EX_TRANSIENT} |
23324ae1 FM |
206 | Don't use this window as an implicit parent for the other windows: |
207 | this must be used with transient windows as otherwise there is the | |
ccd4e1bc VZ |
208 | risk of creating a dialog/frame with this window as a parent, which |
209 | would lead to a crash if the parent were destroyed before the child. | |
e25cd775 FM |
210 | @style{wxWS_EX_CONTEXTHELP} |
211 | Under Windows, puts a query button on the caption. When pressed, | |
212 | Windows will go into a context-sensitive help mode and wxWidgets | |
141794f1 | 213 | will send a @c wxEVT_HELP event if the user clicked on an application window. |
4c025875 FM |
214 | This style cannot be used (because of the underlying native behaviour) |
215 | together with @c wxMAXIMIZE_BOX or @c wxMINIMIZE_BOX, so these two styles | |
216 | are automatically turned off if this one is used. | |
8c6791e4 | 217 | @style{wxWS_EX_PROCESS_IDLE} |
23324ae1 | 218 | This window should always process idle events, even if the mode set |
141794f1 | 219 | by wxIdleEvent::SetMode is @c wxIDLE_PROCESS_SPECIFIED. |
8c6791e4 | 220 | @style{wxWS_EX_PROCESS_UI_UPDATES} |
23324ae1 | 221 | This window should always process UI update events, even if the |
141794f1 | 222 | mode set by wxUpdateUIEvent::SetMode is @c wxUPDATE_UI_PROCESS_SPECIFIED. |
23324ae1 | 223 | @endExtraStyleTable |
7c913512 | 224 | |
3051a44a FM |
225 | @beginEventEmissionTable |
226 | @event{EVT_ACTIVATE(id, func)} | |
227 | Process a @c wxEVT_ACTIVATE event. See wxActivateEvent. | |
228 | @event{EVT_CHILD_FOCUS(func)} | |
229 | Process a @c wxEVT_CHILD_FOCUS event. See wxChildFocusEvent. | |
230 | @event{EVT_CONTEXT_MENU(func)} | |
231 | A right click (or other context menu command depending on platform) has been detected. | |
232 | See wxContextMenuEvent. | |
233 | @event{EVT_HELP(id, func)} | |
234 | Process a @c wxEVT_HELP event. See wxHelpEvent. | |
235 | @event{EVT_HELP_RANGE(id1, id2, func)} | |
236 | Process a @c wxEVT_HELP event for a range of ids. See wxHelpEvent. | |
237 | @event{EVT_DROP_FILES(func)} | |
238 | Process a @c wxEVT_DROP_FILES event. See wxDropFilesEvent. | |
239 | @event{EVT_ERASE_BACKGROUND(func)} | |
240 | Process a @c wxEVT_ERASE_BACKGROUND event. See wxEraseEvent. | |
241 | @event{EVT_SET_FOCUS(func)} | |
242 | Process a @c wxEVT_SET_FOCUS event. See wxFocusEvent. | |
243 | @event{EVT_KILL_FOCUS(func)} | |
244 | Process a @c wxEVT_KILL_FOCUS event. See wxFocusEvent. | |
245 | @event{EVT_IDLE(func)} | |
246 | Process a @c wxEVT_IDLE event. See wxIdleEvent. | |
247 | @event{EVT_JOY_*(func)} | |
248 | Processes joystick events. See wxJoystickEvent. | |
249 | @event{EVT_KEY_DOWN(func)} | |
250 | Process a @c wxEVT_KEY_DOWN event (any key has been pressed). | |
251 | See wxKeyEvent. | |
252 | @event{EVT_KEY_UP(func)} | |
253 | Process a @c wxEVT_KEY_UP event (any key has been released). | |
ff450486 | 254 | See wxKeyEvent. |
3051a44a FM |
255 | @event{EVT_CHAR(func)} |
256 | Process a @c wxEVT_CHAR event. | |
257 | See wxKeyEvent. | |
ff450486 VZ |
258 | @event{EVT_CHAR_HOOK(func)} |
259 | Process a @c wxEVT_CHAR_HOOK event. | |
260 | See wxKeyEvent. | |
3051a44a FM |
261 | @event{EVT_MOUSE_CAPTURE_LOST(func)} |
262 | Process a @c wxEVT_MOUSE_CAPTURE_LOST event. See wxMouseCaptureLostEvent. | |
263 | @event{EVT_MOUSE_CAPTURE_CHANGED(func)} | |
264 | Process a @c wxEVT_MOUSE_CAPTURE_CHANGED event. See wxMouseCaptureChangedEvent. | |
265 | @event{EVT_MOUSE_*(func)} | |
266 | See wxMouseEvent. | |
267 | @event{EVT_PAINT(func)} | |
268 | Process a @c wxEVT_PAINT event. See wxPaintEvent. | |
269 | @event{EVT_POWER_*(func)} | |
270 | The system power state changed. See wxPowerEvent. | |
271 | @event{EVT_SCROLLWIN_*(func)} | |
272 | Process scroll events. See wxScrollWinEvent. | |
273 | @event{EVT_SET_CURSOR(func)} | |
274 | Process a @c wxEVT_SET_CURSOR event. See wxSetCursorEvent. | |
3051a44a FM |
275 | @event{EVT_SIZE(func)} |
276 | Process a @c wxEVT_SIZE event. See wxSizeEvent. | |
277 | @event{EVT_SYS_COLOUR_CHANGED(func)} | |
278 | Process a @c wxEVT_SYS_COLOUR_CHANGED event. See wxSysColourChangedEvent. | |
279 | @endEventTable | |
280 | ||
23324ae1 | 281 | @library{wxcore} |
e25cd775 | 282 | @category{miscwnd} |
7c913512 | 283 | |
3051a44a | 284 | @see @ref overview_events, @ref overview_windowsizing |
23324ae1 FM |
285 | */ |
286 | class wxWindow : public wxEvtHandler | |
287 | { | |
288 | public: | |
1c7910c3 RR |
289 | /** |
290 | Default constructor | |
291 | */ | |
292 | wxWindow(); | |
a3ac93e3 | 293 | |
23324ae1 FM |
294 | /** |
295 | Constructs a window, which can be a child of a frame, dialog or any other | |
296 | non-control window. | |
3c4f71cc | 297 | |
7c913512 | 298 | @param parent |
4cc4bfaf | 299 | Pointer to a parent window. |
7c913512 | 300 | @param id |
4cc4bfaf | 301 | Window identifier. If wxID_ANY, will automatically create an identifier. |
7c913512 | 302 | @param pos |
4cc4bfaf | 303 | Window position. wxDefaultPosition indicates that wxWidgets |
e25cd775 FM |
304 | should generate a default position for the window. |
305 | If using the wxWindow class directly, supply an actual position. | |
7c913512 | 306 | @param size |
e25cd775 FM |
307 | Window size. wxDefaultSize indicates that wxWidgets should generate |
308 | a default size for the window. If no suitable size can be found, the | |
4cc4bfaf | 309 | window will be sized to 20x20 pixels so that the window is visible but |
e25cd775 | 310 | obviously not correctly sized. |
7c913512 | 311 | @param style |
4cc4bfaf | 312 | Window style. For generic window styles, please see wxWindow. |
7c913512 | 313 | @param name |
4cc4bfaf | 314 | Window name. |
23324ae1 | 315 | */ |
7c913512 FM |
316 | wxWindow(wxWindow* parent, wxWindowID id, |
317 | const wxPoint& pos = wxDefaultPosition, | |
318 | const wxSize& size = wxDefaultSize, | |
319 | long style = 0, | |
320 | const wxString& name = wxPanelNameStr); | |
23324ae1 FM |
321 | |
322 | /** | |
e25cd775 FM |
323 | Destructor. |
324 | ||
325 | Deletes all sub-windows, then deletes itself. Instead of using | |
326 | the @b delete operator explicitly, you should normally use Destroy() | |
327 | so that wxWidgets can delete a window only when it is safe to do so, in idle time. | |
3c4f71cc | 328 | |
75b00cf8 | 329 | @see @ref overview_windowdeletion "Window Deletion Overview", |
4cc4bfaf | 330 | Destroy(), wxCloseEvent |
23324ae1 | 331 | */ |
adaaa686 | 332 | virtual ~wxWindow(); |
23324ae1 | 333 | |
d0a67157 | 334 | |
05b0355a RD |
335 | bool Create(wxWindow *parent, |
336 | wxWindowID id, | |
337 | const wxPoint& pos = wxDefaultPosition, | |
338 | const wxSize& size = wxDefaultSize, | |
339 | long style = 0, | |
340 | const wxString& name = wxPanelNameStr); | |
341 | ||
d0a67157 FM |
342 | /** |
343 | @name Focus functions | |
344 | ||
345 | See also the static function FindFocus(). | |
346 | */ | |
347 | //@{ | |
348 | ||
23324ae1 FM |
349 | /** |
350 | This method may be overridden in the derived classes to return @false to | |
0824e369 VZ |
351 | indicate that this control doesn't accept input at all (i.e.\ behaves like |
352 | e.g.\ wxStaticText) and so doesn't need focus. | |
3c4f71cc | 353 | |
4cc4bfaf | 354 | @see AcceptsFocusFromKeyboard() |
23324ae1 | 355 | */ |
962fb6d2 | 356 | virtual bool AcceptsFocus() const; |
23324ae1 FM |
357 | |
358 | /** | |
359 | This method may be overridden in the derived classes to return @false to | |
360 | indicate that while this control can, in principle, have focus if the user | |
361 | clicks it with the mouse, it shouldn't be included in the TAB traversal chain | |
362 | when using the keyboard. | |
363 | */ | |
962fb6d2 | 364 | virtual bool AcceptsFocusFromKeyboard() const; |
23324ae1 | 365 | |
962fb6d2 | 366 | /** |
ccd4e1bc | 367 | Overridden to indicate whether this window or one of its children accepts |
962fb6d2 | 368 | focus. Usually it's the same as AcceptsFocus() but is overridden for |
e25cd775 | 369 | container windows. |
962fb6d2 RR |
370 | */ |
371 | virtual bool AcceptsFocusRecursively() const; | |
0c3140ca RD |
372 | |
373 | /** | |
374 | Can this window itself have focus? | |
375 | */ | |
376 | bool IsFocusable() const; | |
377 | ||
378 | /** | |
379 | Can this window have focus right now? | |
380 | ||
381 | If this method returns true, it means that calling SetFocus() will | |
382 | put focus either to this window or one of its children, if you need | |
383 | to know whether this window accepts focus itself, use IsFocusable() | |
384 | */ | |
385 | bool CanAcceptFocus() const; | |
386 | ||
387 | /** | |
388 | Can this window be assigned focus from keyboard right now? | |
389 | */ | |
390 | bool CanAcceptFocusFromKeyboard() const; | |
391 | ||
a3ac93e3 | 392 | |
23324ae1 | 393 | /** |
d0a67157 FM |
394 | Returns @true if the window (or in case of composite controls, its main |
395 | child window) has focus. | |
3c4f71cc | 396 | |
b9fc07ba VZ |
397 | @since 2.9.0 |
398 | ||
d0a67157 | 399 | @see FindFocus() |
23324ae1 | 400 | */ |
d0a67157 | 401 | virtual bool HasFocus() const; |
23324ae1 FM |
402 | |
403 | /** | |
d0a67157 FM |
404 | This method is only implemented by ports which have support for |
405 | native TAB traversal (such as GTK+ 2.0). | |
3c4f71cc | 406 | |
d0a67157 FM |
407 | It is called by wxWidgets' container control code to give the native |
408 | system a hint when doing TAB traversal. A call to this does not disable | |
409 | or change the effect of programmatically calling SetFocus(). | |
3c4f71cc | 410 | |
d0a67157 FM |
411 | @see wxFocusEvent, wxPanel::SetFocus, wxPanel::SetFocusIgnoringChildren |
412 | */ | |
413 | virtual void SetCanFocus(bool canFocus); | |
3c4f71cc | 414 | |
d0a67157 FM |
415 | /** |
416 | This sets the window to receive keyboard input. | |
417 | ||
418 | @see HasFocus(), wxFocusEvent, wxPanel::SetFocus, | |
419 | wxPanel::SetFocusIgnoringChildren | |
23324ae1 | 420 | */ |
d0a67157 | 421 | virtual void SetFocus(); |
23324ae1 FM |
422 | |
423 | /** | |
d0a67157 FM |
424 | This function is called by wxWidgets keyboard navigation code when the user |
425 | gives the focus to this window from keyboard (e.g. using @c TAB key). | |
426 | ||
427 | By default this method simply calls SetFocus() but | |
428 | can be overridden to do something in addition to this in the derived classes. | |
23324ae1 | 429 | */ |
d0a67157 FM |
430 | virtual void SetFocusFromKbd(); |
431 | ||
432 | //@} | |
433 | ||
23324ae1 FM |
434 | |
435 | /** | |
d0a67157 | 436 | @name Child management functions |
23324ae1 | 437 | */ |
d0a67157 | 438 | //@{ |
23324ae1 FM |
439 | |
440 | /** | |
d0a67157 FM |
441 | Adds a child window. This is called automatically by window creation |
442 | functions so should not be required by the application programmer. | |
443 | Notice that this function is mostly internal to wxWidgets and shouldn't be | |
444 | called by the user code. | |
e25cd775 | 445 | |
d0a67157 FM |
446 | @param child |
447 | Child window to add. | |
448 | */ | |
449 | virtual void AddChild(wxWindow* child); | |
e25cd775 | 450 | |
d0a67157 FM |
451 | /** |
452 | Destroys all children of a window. Called automatically by the destructor. | |
453 | */ | |
454 | bool DestroyChildren(); | |
3c4f71cc | 455 | |
d0a67157 FM |
456 | /** |
457 | Find a child of this window, by @a id. | |
458 | May return @a this if it matches itself. | |
23324ae1 | 459 | */ |
d0a67157 | 460 | wxWindow* FindWindow(long id) const; |
23324ae1 FM |
461 | |
462 | /** | |
d0a67157 FM |
463 | Find a child of this window, by name. |
464 | May return @a this if it matches itself. | |
23324ae1 | 465 | */ |
d0a67157 | 466 | wxWindow* FindWindow(const wxString& name) const; |
23324ae1 FM |
467 | |
468 | /** | |
d0a67157 FM |
469 | Returns a reference to the list of the window's children. @c wxWindowList |
470 | is a type-safe wxList-like class whose elements are of type @c wxWindow*. | |
23324ae1 | 471 | */ |
d0a67157 | 472 | wxWindowList& GetChildren(); |
23324ae1 FM |
473 | |
474 | /** | |
d0a67157 FM |
475 | @overload |
476 | */ | |
477 | const wxWindowList& GetChildren() const; | |
3c4f71cc | 478 | |
d0a67157 FM |
479 | /** |
480 | Removes a child window. | |
3c4f71cc | 481 | |
d0a67157 FM |
482 | This is called automatically by window deletion functions so should not |
483 | be required by the application programmer. | |
484 | Notice that this function is mostly internal to wxWidgets and shouldn't be | |
485 | called by the user code. | |
3c4f71cc | 486 | |
d0a67157 FM |
487 | @param child |
488 | Child window to remove. | |
23324ae1 | 489 | */ |
d0a67157 | 490 | virtual void RemoveChild(wxWindow* child); |
3c4f71cc | 491 | |
d0a67157 | 492 | //@} |
3c4f71cc | 493 | |
3c4f71cc | 494 | |
d0a67157 FM |
495 | /** |
496 | @name Sibling and parent management functions | |
23324ae1 | 497 | */ |
d0a67157 | 498 | //@{ |
23324ae1 FM |
499 | |
500 | /** | |
d0a67157 | 501 | Returns the grandparent of a window, or @NULL if there isn't one. |
23324ae1 | 502 | */ |
d0a67157 | 503 | wxWindow* GetGrandParent() const; |
23324ae1 | 504 | |
23324ae1 | 505 | /** |
ccd4e1bc | 506 | Returns the next window after this one among the parent's children or @NULL |
d0a67157 | 507 | if this window is the last child. |
3c4f71cc | 508 | |
d0a67157 | 509 | @since 2.8.8 |
e25cd775 | 510 | |
d0a67157 | 511 | @see GetPrevSibling() |
23324ae1 | 512 | */ |
d0a67157 | 513 | wxWindow* GetNextSibling() const; |
f41d6c8c FM |
514 | |
515 | /** | |
d0a67157 | 516 | Returns the parent of the window, or @NULL if there is no parent. |
f41d6c8c | 517 | */ |
d0a67157 | 518 | wxWindow* GetParent() const; |
23324ae1 FM |
519 | |
520 | /** | |
ccd4e1bc | 521 | Returns the previous window before this one among the parent's children or @c |
d0a67157 | 522 | @NULL if this window is the first child. |
491a5ece VS |
523 | |
524 | @since 2.8.8 | |
525 | ||
d0a67157 | 526 | @see GetNextSibling() |
23324ae1 | 527 | */ |
d0a67157 | 528 | wxWindow* GetPrevSibling() const; |
8b2f64c6 VZ |
529 | |
530 | /** | |
531 | Check if the specified window is a descendant of this one. | |
532 | ||
533 | Returns @true if the window is a descendant (i.e. a child or | |
534 | grand-child or grand-grand-child or ...) of this one. | |
535 | ||
536 | Notice that a window can never be a descendant of another one if they | |
537 | are in different top level windows, i.e. a child of a wxDialog is not | |
538 | considered to be a descendant of dialogs parent wxFrame. | |
539 | ||
540 | @param win Any window, possible @NULL (@false is always returned then). | |
541 | ||
542 | @since 2.9.4 | |
543 | */ | |
544 | bool IsDescendant(wxWindowBase* win) const; | |
545 | ||
491a5ece | 546 | /** |
0824e369 | 547 | Reparents the window, i.e.\ the window will be removed from its |
d0a67157 FM |
548 | current parent window (e.g. a non-standard toolbar in a wxFrame) |
549 | and then re-inserted into another. | |
491a5ece | 550 | |
013b0209 VZ |
551 | Notice that currently you need to explicitly call |
552 | wxNotebook::RemovePage() before reparenting a notebook page. | |
553 | ||
d0a67157 FM |
554 | @param newParent |
555 | New parent. | |
556 | */ | |
557 | virtual bool Reparent(wxWindow* newParent); | |
491a5ece | 558 | |
d0a67157 | 559 | //@} |
491a5ece | 560 | |
d0a67157 FM |
561 | |
562 | /** | |
47009083 | 563 | @name Scrolling and scrollbars functions |
d9ced90b FM |
564 | |
565 | Note that these methods don't work with native controls which don't use | |
566 | wxWidgets scrolling framework (i.e. don't derive from wxScrolledWindow). | |
491a5ece | 567 | */ |
d0a67157 | 568 | //@{ |
491a5ece | 569 | |
23324ae1 | 570 | /** |
d0a67157 FM |
571 | Call this function to force one or both scrollbars to be always shown, even if |
572 | the window is big enough to show its entire contents without scrolling. | |
491a5ece | 573 | |
d0a67157 | 574 | @since 2.9.0 |
3c4f71cc | 575 | |
d0a67157 FM |
576 | @param hflag |
577 | Whether the horizontal scroll bar should always be visible. | |
578 | @param vflag | |
579 | Whether the vertical scroll bar should always be visible. | |
3c4f71cc | 580 | |
d0a67157 | 581 | @remarks This function is currently only implemented under Mac/Carbon. |
23324ae1 | 582 | */ |
d0a67157 | 583 | virtual void AlwaysShowScrollbars(bool hflag = true, bool vflag = true); |
23324ae1 | 584 | |
23324ae1 | 585 | /** |
d0a67157 | 586 | Returns the built-in scrollbar position. |
e25cd775 | 587 | |
d9ced90b | 588 | @see SetScrollbar() |
d0a67157 FM |
589 | */ |
590 | virtual int GetScrollPos(int orientation) const; | |
3c4f71cc | 591 | |
d0a67157 FM |
592 | /** |
593 | Returns the built-in scrollbar range. | |
3c4f71cc | 594 | |
d0a67157 | 595 | @see SetScrollbar() |
23324ae1 | 596 | */ |
d0a67157 | 597 | virtual int GetScrollRange(int orientation) const; |
23324ae1 | 598 | |
23324ae1 | 599 | /** |
d0a67157 | 600 | Returns the built-in scrollbar thumb size. |
3c4f71cc | 601 | |
d0a67157 | 602 | @see SetScrollbar() |
23324ae1 | 603 | */ |
d0a67157 | 604 | virtual int GetScrollThumb(int orientation) const; |
23324ae1 FM |
605 | |
606 | /** | |
c5cc7fbd VZ |
607 | Returns @true if this window can have a scroll bar in this orientation. |
608 | ||
609 | @param orient | |
610 | Orientation to check, either wxHORIZONTAL or wxVERTICAL. | |
611 | ||
612 | @since 2.9.1 | |
613 | */ | |
614 | bool CanScroll(int orient) const; | |
615 | ||
616 | /** | |
617 | Returns @true if this window currently has a scroll bar for this | |
618 | orientation. | |
619 | ||
620 | This method may return @false even when CanScroll() for the same | |
621 | orientation returns @true, but if CanScroll() returns @false, i.e. | |
622 | scrolling in this direction is not enabled at all, HasScrollbar() | |
623 | always returns @false as well. | |
3c4f71cc | 624 | |
d0a67157 FM |
625 | @param orient |
626 | Orientation to check, either wxHORIZONTAL or wxVERTICAL. | |
23324ae1 | 627 | */ |
d0a67157 | 628 | bool HasScrollbar(int orient) const; |
23324ae1 FM |
629 | |
630 | /** | |
d0a67157 FM |
631 | Return whether a scrollbar is always shown. |
632 | ||
633 | @param orient | |
634 | Orientation to check, either wxHORIZONTAL or wxVERTICAL. | |
635 | ||
636 | @see AlwaysShowScrollbars() | |
23324ae1 | 637 | */ |
d0a67157 | 638 | virtual bool IsScrollbarAlwaysShown(int orient) const; |
23324ae1 | 639 | |
a3ac93e3 | 640 | /** |
d0a67157 FM |
641 | Scrolls the window by the given number of lines down (if @a lines is |
642 | positive) or up. | |
a3ac93e3 | 643 | |
d0a67157 FM |
644 | @return Returns @true if the window was scrolled, @false if it was already |
645 | on top/bottom and nothing was done. | |
a3ac93e3 | 646 | |
d0a67157 FM |
647 | @remarks This function is currently only implemented under MSW and |
648 | wxTextCtrl under wxGTK (it also works for wxScrolled classes | |
649 | under all platforms). | |
650 | ||
651 | @see ScrollPages() | |
652 | */ | |
653 | virtual bool ScrollLines(int lines); | |
a3ac93e3 | 654 | |
23324ae1 | 655 | /** |
d0a67157 FM |
656 | Scrolls the window by the given number of pages down (if @a pages is |
657 | positive) or up. | |
3c4f71cc | 658 | |
d0a67157 FM |
659 | @return Returns @true if the window was scrolled, @false if it was already |
660 | on top/bottom and nothing was done. | |
661 | ||
662 | @remarks This function is currently only implemented under MSW and wxGTK. | |
663 | ||
664 | @see ScrollLines() | |
23324ae1 | 665 | */ |
d0a67157 | 666 | virtual bool ScrollPages(int pages); |
23324ae1 | 667 | |
23324ae1 | 668 | /** |
d0a67157 | 669 | Physically scrolls the pixels in the window and move child windows accordingly. |
e25cd775 | 670 | |
d0a67157 FM |
671 | @param dx |
672 | Amount to scroll horizontally. | |
673 | @param dy | |
674 | Amount to scroll vertically. | |
675 | @param rect | |
676 | Rectangle to scroll, if it is @NULL, the whole window is | |
677 | scrolled (this is always the case under wxGTK which doesn't support this | |
678 | parameter) | |
e25cd775 | 679 | |
d0a67157 FM |
680 | @remarks Note that you can often use wxScrolled instead of using this |
681 | function directly. | |
23324ae1 | 682 | */ |
d0a67157 FM |
683 | virtual void ScrollWindow(int dx, int dy, |
684 | const wxRect* rect = NULL); | |
23324ae1 FM |
685 | |
686 | /** | |
d0a67157 FM |
687 | Same as #ScrollLines (-1). |
688 | */ | |
689 | bool LineUp(); | |
3c4f71cc | 690 | |
d0a67157 FM |
691 | /** |
692 | Same as #ScrollLines (1). | |
693 | */ | |
694 | bool LineDown(); | |
3c4f71cc | 695 | |
d0a67157 FM |
696 | /** |
697 | Same as #ScrollPages (-1). | |
698 | */ | |
699 | bool PageUp(); | |
4f24cbbd | 700 | |
d0a67157 FM |
701 | /** |
702 | Same as #ScrollPages (1). | |
23324ae1 | 703 | */ |
d0a67157 | 704 | bool PageDown(); |
23324ae1 FM |
705 | |
706 | /** | |
d0a67157 | 707 | Sets the position of one of the built-in scrollbars. |
3c4f71cc | 708 | |
d0a67157 FM |
709 | @param orientation |
710 | Determines the scrollbar whose position is to be set. | |
711 | May be wxHORIZONTAL or wxVERTICAL. | |
712 | @param pos | |
713 | Position in scroll units. | |
714 | @param refresh | |
715 | @true to redraw the scrollbar, @false otherwise. | |
3c4f71cc | 716 | |
d0a67157 FM |
717 | @remarks This function does not directly affect the contents of the |
718 | window: it is up to the application to take note of | |
719 | scrollbar attributes and redraw contents accordingly. | |
3c4f71cc | 720 | |
d0a67157 FM |
721 | @see SetScrollbar(), GetScrollPos(), GetScrollThumb(), wxScrollBar, |
722 | wxScrolled | |
23324ae1 | 723 | */ |
d0a67157 FM |
724 | virtual void SetScrollPos(int orientation, int pos, |
725 | bool refresh = true); | |
23324ae1 FM |
726 | |
727 | /** | |
d0a67157 | 728 | Sets the scrollbar properties of a built-in scrollbar. |
3c4f71cc | 729 | |
d0a67157 FM |
730 | @param orientation |
731 | Determines the scrollbar whose page size is to be set. | |
732 | May be wxHORIZONTAL or wxVERTICAL. | |
733 | @param position | |
734 | The position of the scrollbar in scroll units. | |
735 | @param thumbSize | |
736 | The size of the thumb, or visible portion of the scrollbar, in scroll units. | |
737 | @param range | |
738 | The maximum position of the scrollbar. Value of -1 can be used to | |
739 | ask for the scrollbar to be shown but in the disabled state: this | |
740 | can be used to avoid removing the scrollbar even when it is not | |
741 | needed (currently this is only implemented in wxMSW port). | |
742 | @param refresh | |
743 | @true to redraw the scrollbar, @false otherwise. | |
3c4f71cc | 744 | |
d0a67157 FM |
745 | @remarks |
746 | Let's say you wish to display 50 lines of text, using the same font. | |
747 | The window is sized so that you can only see 16 lines at a time. | |
748 | You would use: | |
749 | @code | |
750 | SetScrollbar(wxVERTICAL, 0, 16, 50); | |
751 | @endcode | |
752 | Note that with the window at this size, the thumb position can never | |
753 | go above 50 minus 16, or 34. You can determine how many lines are | |
754 | currently visible by dividing the current view size by the character | |
755 | height in pixels. | |
756 | When defining your own scrollbar behaviour, you will always need | |
757 | to recalculate the scrollbar settings when the window size changes. | |
758 | You could therefore put your scrollbar calculations and SetScrollbar | |
759 | call into a function named AdjustScrollbars, which can be called | |
760 | initially and also from your wxSizeEvent handler function. | |
23324ae1 | 761 | |
d0a67157 | 762 | @see @ref overview_scrolling, wxScrollBar, wxScrolled, wxScrollWinEvent |
23324ae1 | 763 | */ |
d0a67157 FM |
764 | virtual void SetScrollbar(int orientation, int position, |
765 | int thumbSize, int range, | |
766 | bool refresh = true); | |
767 | //@} | |
a3ac93e3 | 768 | |
23324ae1 FM |
769 | |
770 | /** | |
47009083 | 771 | @name Sizing functions |
e25cd775 | 772 | |
386279c3 VZ |
773 | See also the protected functions DoGetBestSize() and |
774 | DoGetBestClientSize(). | |
d0a67157 FM |
775 | */ |
776 | //@{ | |
3c4f71cc | 777 | |
1a986642 VZ |
778 | /** |
779 | Helper for ensuring EndRepositioningChildren() is called correctly. | |
780 | ||
781 | This class wraps the calls to BeginRepositioningChildren() and | |
782 | EndRepositioningChildren() by performing the former in its constructor | |
783 | and the latter in its destructor if, and only if, the first call | |
784 | returned @true. This is the simplest way to call these methods and if | |
785 | this class is created as a local variable, it also ensures that | |
786 | EndRepositioningChildren() is correctly called (or not) on scope exit, | |
787 | so its use instead of calling these methods manually is highly | |
788 | recommended. | |
789 | ||
790 | @since 2.9.5 | |
791 | */ | |
792 | class ChildrenRepositioningGuard | |
793 | { | |
794 | public: | |
795 | /** | |
796 | Constructor calls wxWindow::BeginRepositioningChildren(). | |
797 | ||
798 | @param win The window to call BeginRepositioningChildren() on. If | |
799 | it is @NULL, nothing is done. | |
800 | */ | |
801 | explicit ChildrenRepositioningGuard(wxWindow* win); | |
802 | ||
803 | /** | |
804 | Destructor calls wxWindow::EndRepositioningChildren() if necessary. | |
805 | ||
806 | EndRepositioningChildren() is called only if a valid window was | |
807 | passed to the constructor and if BeginRepositioningChildren() | |
808 | returned @true. | |
809 | */ | |
810 | ~ChildrenRepositioningGuard(); | |
811 | }; | |
812 | ||
813 | /** | |
814 | Prepare for changing positions of multiple child windows. | |
815 | ||
816 | This method should be called before changing positions of multiple | |
817 | child windows to reduce flicker and, in MSW case, even avoid display | |
818 | corruption in some cases. It is used internally by wxWidgets and called | |
819 | automatically when the window size changes but it can also be useful to | |
820 | call it from outside of the library if a repositioning involving | |
821 | multiple children is done without changing the window size. | |
822 | ||
823 | If this method returns @true, then EndRepositioningChildren() must be | |
824 | called after setting all children positions. Use | |
825 | ChildrenRepositioningGuard class to ensure that this requirement is | |
826 | satisfied. | |
827 | ||
828 | @since 2.9.5 | |
829 | */ | |
830 | bool BeginRepositioningChildren(); | |
831 | ||
832 | /** | |
833 | Fix child window positions after setting all of them at once. | |
834 | ||
835 | This method must be called if and only if the previous call to | |
836 | BeginRepositioningChildren() returned @true. | |
837 | ||
838 | @since 2.9.5 | |
839 | */ | |
840 | void EndRepositioningChildren(); | |
841 | ||
d0a67157 FM |
842 | /** |
843 | Sets the cached best size value. | |
d9ced90b FM |
844 | |
845 | @see GetBestSize() | |
23324ae1 | 846 | */ |
d0a67157 | 847 | void CacheBestSize(const wxSize& size) const; |
23324ae1 FM |
848 | |
849 | /** | |
d0a67157 | 850 | Converts client area size @a size to corresponding window size. |
e25cd775 | 851 | |
d0a67157 FM |
852 | In other words, the returned value is what would GetSize() return if this |
853 | window had client area of given size. Components with wxDefaultCoord | |
854 | value are left unchanged. Note that the conversion is not always | |
855 | exact, it assumes that non-client area doesn't change and so doesn't | |
856 | take into account things like menu bar (un)wrapping or (dis)appearance | |
857 | of the scrollbars. | |
3c4f71cc | 858 | |
d0a67157 FM |
859 | @since 2.8.8 |
860 | ||
861 | @see WindowToClientSize() | |
23324ae1 | 862 | */ |
d0a67157 | 863 | virtual wxSize ClientToWindowSize(const wxSize& size) const; |
23324ae1 FM |
864 | |
865 | /** | |
d0a67157 FM |
866 | Converts window size @a size to corresponding client area size |
867 | In other words, the returned value is what would GetClientSize() return if | |
868 | this window had given window size. Components with wxDefaultCoord value | |
869 | are left unchanged. | |
e25cd775 | 870 | |
d0a67157 FM |
871 | Note that the conversion is not always exact, it assumes that |
872 | non-client area doesn't change and so doesn't take into account things | |
873 | like menu bar (un)wrapping or (dis)appearance of the scrollbars. | |
e25cd775 | 874 | |
d0a67157 | 875 | @since 2.8.8 |
3c4f71cc | 876 | |
d0a67157 | 877 | @see ClientToWindowSize() |
23324ae1 | 878 | */ |
d0a67157 | 879 | virtual wxSize WindowToClientSize(const wxSize& size) const; |
23324ae1 FM |
880 | |
881 | /** | |
cded6aa1 FM |
882 | Sizes the window so that it fits around its subwindows. |
883 | ||
884 | This function won't do anything if there are no subwindows and will only really | |
885 | work correctly if sizers are used for the subwindows layout. | |
886 | ||
887 | Also, if the window has exactly one subwindow it is better (faster and the result | |
888 | is more precise as Fit() adds some margin to account for fuzziness of its calculations) | |
889 | to call: | |
890 | ||
75b00cf8 | 891 | @code |
e25cd775 | 892 | window->SetClientSize(child->GetSize()); |
cded6aa1 FM |
893 | @endcode |
894 | ||
895 | instead of calling Fit(). | |
3c4f71cc | 896 | |
cded6aa1 | 897 | @see @ref overview_windowsizing |
23324ae1 | 898 | */ |
4cc4bfaf | 899 | virtual void Fit(); |
23324ae1 FM |
900 | |
901 | /** | |
e25cd775 FM |
902 | Similar to Fit(), but sizes the interior (virtual) size of a window. |
903 | ||
904 | Mainly useful with scrolled windows to reset scrollbars after sizing | |
905 | changes that do not trigger a size event, and/or scrolled windows without | |
906 | an interior sizer. This function similarly won't do anything if there are | |
907 | no subwindows. | |
23324ae1 FM |
908 | */ |
909 | virtual void FitInside(); | |
910 | ||
23324ae1 | 911 | /** |
e25cd775 FM |
912 | This functions returns the best acceptable minimal size for the window. |
913 | ||
914 | For example, for a static control, it will be the minimal size such that the | |
23324ae1 | 915 | control label is not truncated. For windows containing subwindows (typically |
e25cd775 FM |
916 | wxPanel), the size returned by this function will be the same as the size |
917 | the window would have had after calling Fit(). | |
d9ced90b | 918 | |
386279c3 VZ |
919 | Override virtual DoGetBestSize() or, better, because it's usually more |
920 | convenient, DoGetBestClientSize() when writing your own custom window | |
921 | class to change the value returned by this public non-virtual method. | |
d9ced90b | 922 | |
054fdb68 VZ |
923 | Notice that the best size respects the minimal and maximal size |
924 | explicitly set for the window, if any. So even if some window believes | |
925 | that it needs 200 pixels horizontally, calling SetMaxSize() with a | |
926 | width of 100 would ensure that GetBestSize() returns the width of at | |
927 | most 100 pixels. | |
928 | ||
d9ced90b | 929 | @see CacheBestSize(), @ref overview_windowsizing |
23324ae1 | 930 | */ |
328f5751 | 931 | wxSize GetBestSize() const; |
23324ae1 | 932 | |
d1199839 VZ |
933 | /** |
934 | Returns the best height needed by this window if it had the given width. | |
935 | ||
936 | @see DoGetBestClientHeight() | |
937 | ||
938 | @since 2.9.4 | |
939 | */ | |
940 | int GetBestHeight(int width) const; | |
941 | ||
942 | /** | |
943 | Returns the best width needed by this window if it had the given height. | |
944 | ||
945 | @see DoGetBestClientWidth() | |
946 | ||
947 | @since 2.9.4 | |
948 | */ | |
949 | int GetBestWidth(int height) const; | |
950 | ||
23324ae1 | 951 | /** |
e25cd775 | 952 | Returns the size of the window 'client area' in pixels. |
76e9224e | 953 | |
e25cd775 FM |
954 | The client area is the area which may be drawn on by the programmer, |
955 | excluding title bar, border, scrollbars, etc. | |
23324ae1 FM |
956 | Note that if this window is a top-level one and it is currently minimized, the |
957 | return size is empty (both width and height are 0). | |
3c4f71cc | 958 | |
1058f652 MB |
959 | @beginWxPerlOnly |
960 | In wxPerl this method takes no parameters and returns | |
961 | a 2-element list (width, height). | |
962 | @endWxPerlOnly | |
963 | ||
4cc4bfaf | 964 | @see GetSize(), GetVirtualSize() |
23324ae1 | 965 | */ |
328f5751 | 966 | void GetClientSize(int* width, int* height) const; |
23324ae1 FM |
967 | |
968 | /** | |
d0a67157 | 969 | @overload |
23324ae1 | 970 | */ |
d0a67157 | 971 | wxSize GetClientSize() const; |
23324ae1 FM |
972 | |
973 | /** | |
cded6aa1 FM |
974 | Merges the window's best size into the min size and returns the result. |
975 | This is the value used by sizers to determine the appropriate | |
ccd4e1bc | 976 | amount of space to allocate for the widget. |
d9ced90b | 977 | |
ccd4e1bc VZ |
978 | This is the method called by a wxSizer when it queries the size |
979 | of a window or control. | |
3c4f71cc | 980 | |
cded6aa1 | 981 | @see GetBestSize(), SetInitialSize(), @ref overview_windowsizing |
23324ae1 | 982 | */ |
a20a357d | 983 | virtual wxSize GetEffectiveMinSize() const; |
23324ae1 | 984 | |
23324ae1 | 985 | /** |
7c913512 | 986 | Returns the maximum size of window's client area. |
e25cd775 | 987 | |
23324ae1 FM |
988 | This is an indication to the sizer layout mechanism that this is the maximum |
989 | possible size as well as the upper bound on window's size settable using | |
7c913512 | 990 | SetClientSize(). |
3c4f71cc | 991 | |
d9ced90b | 992 | @see GetMaxSize(), @ref overview_windowsizing |
23324ae1 | 993 | */ |
adaaa686 | 994 | virtual wxSize GetMaxClientSize() const; |
23324ae1 FM |
995 | |
996 | /** | |
e25cd775 FM |
997 | Returns the maximum size of the window. |
998 | ||
999 | This is an indication to the sizer layout mechanism that this is the maximum | |
1000 | possible size as well as the upper bound on window's size settable using SetSize(). | |
3c4f71cc | 1001 | |
d9ced90b | 1002 | @see GetMaxClientSize(), @ref overview_windowsizing |
23324ae1 | 1003 | */ |
adaaa686 | 1004 | virtual wxSize GetMaxSize() const; |
23324ae1 FM |
1005 | |
1006 | /** | |
1007 | Returns the minimum size of window's client area, an indication to the sizer | |
e25cd775 FM |
1008 | layout mechanism that this is the minimum required size of its client area. |
1009 | ||
1010 | It normally just returns the value set by SetMinClientSize(), but it can be | |
1011 | overridden to do the calculation on demand. | |
3c4f71cc | 1012 | |
d9ced90b | 1013 | @see GetMinSize(), @ref overview_windowsizing |
23324ae1 | 1014 | */ |
328f5751 | 1015 | virtual wxSize GetMinClientSize() const; |
23324ae1 FM |
1016 | |
1017 | /** | |
1018 | Returns the minimum size of the window, an indication to the sizer layout | |
5af86f4d VZ |
1019 | mechanism that this is the minimum required size. |
1020 | ||
1021 | This method normally just returns the value set by SetMinSize(), but it | |
1022 | can be overridden to do the calculation on demand. | |
3c4f71cc | 1023 | |
d9ced90b | 1024 | @see GetMinClientSize(), @ref overview_windowsizing |
23324ae1 | 1025 | */ |
328f5751 | 1026 | virtual wxSize GetMinSize() const; |
23324ae1 | 1027 | |
84c6c212 VZ |
1028 | /** |
1029 | Returns the horizontal component of window minimal size. | |
1030 | ||
1031 | The returned value is wxDefaultCoord if the minimal width was not set. | |
1032 | ||
1033 | @see GetMinSize() | |
1034 | */ | |
05b0355a | 1035 | int GetMinWidth() const; |
84c6c212 VZ |
1036 | |
1037 | /** | |
1038 | Returns the vertical component of window minimal size. | |
1039 | ||
1040 | The returned value is wxDefaultCoord if the minimal height was not set. | |
1041 | ||
1042 | @see GetMinSize() | |
1043 | */ | |
05b0355a | 1044 | int GetMinHeight() const; |
84c6c212 VZ |
1045 | |
1046 | /** | |
1047 | Returns the horizontal component of window maximal size. | |
1048 | ||
1049 | The returned value is wxDefaultCoord if the maximal width was not set. | |
1050 | ||
1051 | @see GetMaxSize() | |
1052 | */ | |
05b0355a | 1053 | int GetMaxWidth() const; |
84c6c212 VZ |
1054 | |
1055 | /** | |
1056 | Returns the vertical component of window maximal size. | |
1057 | ||
1058 | The returned value is wxDefaultCoord if the maximal width was not set. | |
1059 | ||
1060 | @see GetMaxSize() | |
1061 | */ | |
05b0355a RD |
1062 | int GetMaxHeight() const; |
1063 | ||
23324ae1 | 1064 | /** |
d0a67157 FM |
1065 | Returns the size of the entire window in pixels, including title bar, border, |
1066 | scrollbars, etc. | |
3c4f71cc | 1067 | |
d0a67157 FM |
1068 | Note that if this window is a top-level one and it is currently minimized, the |
1069 | returned size is the restored window size, not the size of the window icon. | |
3c4f71cc | 1070 | |
d0a67157 FM |
1071 | @param width |
1072 | Receives the window width. | |
1073 | @param height | |
1074 | Receives the window height. | |
1075 | ||
1058f652 MB |
1076 | @beginWxPerlOnly |
1077 | In wxPerl this method is implemented as GetSizeWH() returning | |
1078 | a 2-element list (width, height). | |
1079 | @endWxPerlOnly | |
1080 | ||
d9ced90b | 1081 | @see GetClientSize(), GetVirtualSize(), @ref overview_windowsizing |
23324ae1 | 1082 | */ |
d0a67157 | 1083 | void GetSize(int* width, int* height) const; |
23324ae1 FM |
1084 | |
1085 | /** | |
d0a67157 | 1086 | See the GetSize(int*,int*) overload for more info. |
23324ae1 | 1087 | */ |
d0a67157 | 1088 | wxSize GetSize() const; |
23324ae1 FM |
1089 | |
1090 | /** | |
d0a67157 FM |
1091 | This gets the virtual size of the window in pixels. |
1092 | By default it returns the client size of the window, but after a call to | |
1093 | SetVirtualSize() it will return the size set with that method. | |
d9ced90b FM |
1094 | |
1095 | @see @ref overview_windowsizing | |
23324ae1 | 1096 | */ |
d0a67157 | 1097 | wxSize GetVirtualSize() const; |
23324ae1 | 1098 | |
23324ae1 | 1099 | /** |
d0a67157 | 1100 | Like the other GetVirtualSize() overload but uses pointers instead. |
f41d6c8c | 1101 | |
d0a67157 FM |
1102 | @param width |
1103 | Receives the window virtual width. | |
1104 | @param height | |
1105 | Receives the window virtual height. | |
f41d6c8c | 1106 | */ |
d0a67157 | 1107 | void GetVirtualSize(int* width, int* height) const; |
23324ae1 | 1108 | |
05b0355a RD |
1109 | /** |
1110 | Return the largest of ClientSize and BestSize (as determined | |
1111 | by a sizer, interior children, or other means) | |
1112 | */ | |
1113 | virtual wxSize GetBestVirtualSize() const; | |
1114 | ||
96691fca RD |
1115 | /** |
1116 | Returns the magnification of the backing store of this window, eg 2.0 | |
1117 | for a window on a retina screen. | |
1118 | ||
1119 | @since 2.9.5 | |
1120 | */ | |
6481f4ab | 1121 | virtual double GetContentScaleFactor() const; |
96691fca | 1122 | |
23324ae1 | 1123 | /** |
d0a67157 FM |
1124 | Returns the size of the left/right and top/bottom borders of this window in x |
1125 | and y components of the result respectively. | |
23324ae1 | 1126 | */ |
d0a67157 | 1127 | virtual wxSize GetWindowBorderSize() const; |
f41d6c8c | 1128 | |
05b0355a RD |
1129 | /** |
1130 | wxSizer and friends use this to give a chance to a component to recalc | |
1131 | its min size once one of the final size components is known. Override | |
1132 | this function when that is useful (such as for wxStaticText which can | |
1133 | stretch over several lines). Parameter availableOtherDir | |
1134 | tells the item how much more space there is available in the opposite | |
1135 | direction (-1 if unknown). | |
1136 | */ | |
1137 | virtual bool | |
1138 | InformFirstDirection(int direction, | |
1139 | int size, | |
1140 | int availableOtherDir); | |
1141 | ||
23324ae1 | 1142 | /** |
d0a67157 FM |
1143 | Resets the cached best size value so it will be recalculated the next time it |
1144 | is needed. | |
d9ced90b FM |
1145 | |
1146 | @see CacheBestSize() | |
23324ae1 | 1147 | */ |
d0a67157 | 1148 | void InvalidateBestSize(); |
d9ced90b | 1149 | |
23324ae1 | 1150 | /** |
d0a67157 | 1151 | Posts a size event to the window. |
3c4f71cc | 1152 | |
d0a67157 FM |
1153 | This is the same as SendSizeEvent() with @c wxSEND_EVENT_POST argument. |
1154 | */ | |
1155 | void PostSizeEvent(); | |
f41d6c8c FM |
1156 | |
1157 | /** | |
d0a67157 | 1158 | Posts a size event to the parent of this window. |
f41d6c8c | 1159 | |
d0a67157 FM |
1160 | This is the same as SendSizeEventToParent() with @c wxSEND_EVENT_POST |
1161 | argument. | |
1162 | */ | |
1163 | void PostSizeEventToParent(); | |
23324ae1 FM |
1164 | |
1165 | /** | |
d0a67157 FM |
1166 | This function sends a dummy @ref wxSizeEvent "size event" to |
1167 | the window allowing it to re-layout its children positions. | |
3c4f71cc | 1168 | |
d0a67157 FM |
1169 | It is sometimes useful to call this function after adding or deleting a |
1170 | children after the frame creation or if a child size changes. Note that | |
1171 | if the frame is using either sizers or constraints for the children | |
1172 | layout, it is enough to call wxWindow::Layout() directly and this | |
1173 | function should not be used in this case. | |
23324ae1 | 1174 | |
d0a67157 FM |
1175 | If @a flags includes @c wxSEND_EVENT_POST value, this function posts |
1176 | the event, i.e. schedules it for later processing, instead of | |
1177 | dispatching it directly. You can also use PostSizeEvent() as a more | |
1178 | readable equivalent of calling this function with this flag. | |
3c4f71cc | 1179 | |
d0a67157 FM |
1180 | @param flags |
1181 | May include @c wxSEND_EVENT_POST. Default value is 0. | |
23324ae1 | 1182 | */ |
d0a67157 | 1183 | virtual void SendSizeEvent(int flags = 0); |
23324ae1 FM |
1184 | |
1185 | /** | |
d0a67157 | 1186 | Safe wrapper for GetParent()->SendSizeEvent(). |
3c4f71cc | 1187 | |
d0a67157 FM |
1188 | This function simply checks that the window has a valid parent which is |
1189 | not in process of being deleted and calls SendSizeEvent() on it. It is | |
1190 | used internally by windows such as toolbars changes to whose state | |
1191 | should result in parent re-layout (e.g. when a toolbar is added to the | |
1192 | top of the window, all the other windows must be shifted down). | |
23324ae1 | 1193 | |
d0a67157 | 1194 | @see PostSizeEventToParent() |
3c4f71cc | 1195 | |
d0a67157 FM |
1196 | @param flags |
1197 | See description of this parameter in SendSizeEvent() documentation. | |
1198 | */ | |
1199 | void SendSizeEventToParent(int flags = 0); | |
23324ae1 | 1200 | |
23324ae1 | 1201 | /** |
d0a67157 | 1202 | This sets the size of the window client area in pixels. |
3c4f71cc | 1203 | |
d0a67157 FM |
1204 | Using this function to size a window tends to be more device-independent |
1205 | than SetSize(), since the application need not worry about what dimensions | |
1206 | the border or title bar have when trying to fit the window around panel | |
1207 | items, for example. | |
d9ced90b FM |
1208 | |
1209 | @see @ref overview_windowsizing | |
23324ae1 | 1210 | */ |
75504144 | 1211 | void SetClientSize(int width, int height); |
f41d6c8c FM |
1212 | |
1213 | /** | |
d0a67157 | 1214 | @overload |
f41d6c8c | 1215 | */ |
75504144 | 1216 | void SetClientSize(const wxSize& size); |
23324ae1 | 1217 | |
05b0355a RD |
1218 | /** |
1219 | @overload | |
1220 | */ | |
1221 | void SetClientSize(const wxRect& rect); | |
1222 | ||
23324ae1 | 1223 | /** |
d0a67157 FM |
1224 | This normally does not need to be called by user code. |
1225 | It is called when a window is added to a sizer, and is used so the window | |
1226 | can remove itself from the sizer when it is destroyed. | |
23324ae1 | 1227 | */ |
d0a67157 | 1228 | void SetContainingSizer(wxSizer* sizer); |
23324ae1 | 1229 | |
23324ae1 | 1230 | /** |
d0a67157 FM |
1231 | A @e smart SetSize that will fill in default size components with the |
1232 | window's @e best size values. | |
e25cd775 | 1233 | |
d0a67157 FM |
1234 | Also sets the window's minsize to the value passed in for use with sizers. |
1235 | This means that if a full or partial size is passed to this function then | |
1236 | the sizers will use that size instead of the results of GetBestSize() to | |
1237 | determine the minimum needs of the window for layout. | |
3c4f71cc | 1238 | |
d0a67157 FM |
1239 | Most controls will use this to set their initial size, and their min |
1240 | size to the passed in value (if any.) | |
e25cd775 | 1241 | |
d0a67157 FM |
1242 | @see SetSize(), GetBestSize(), GetEffectiveMinSize(), |
1243 | @ref overview_windowsizing | |
e25cd775 | 1244 | */ |
d0a67157 | 1245 | void SetInitialSize(const wxSize& size = wxDefaultSize); |
23324ae1 FM |
1246 | |
1247 | /** | |
d0a67157 FM |
1248 | Sets the maximum client size of the window, to indicate to the sizer |
1249 | layout mechanism that this is the maximum possible size of its client area. | |
1250 | ||
d9ced90b FM |
1251 | Note that this method is just a shortcut for: |
1252 | @code | |
1253 | SetMaxSize(ClientToWindowSize(size)); | |
1254 | @endcode | |
1255 | ||
1256 | @see SetMaxSize(), @ref overview_windowsizing | |
23324ae1 | 1257 | */ |
d0a67157 | 1258 | virtual void SetMaxClientSize(const wxSize& size); |
23324ae1 FM |
1259 | |
1260 | /** | |
d0a67157 FM |
1261 | Sets the maximum size of the window, to indicate to the sizer layout mechanism |
1262 | that this is the maximum possible size. | |
3c4f71cc | 1263 | |
d9ced90b | 1264 | @see SetMaxClientSize(), @ref overview_windowsizing |
23324ae1 | 1265 | */ |
d0a67157 | 1266 | virtual void SetMaxSize(const wxSize& size); |
23324ae1 FM |
1267 | |
1268 | /** | |
d0a67157 FM |
1269 | Sets the minimum client size of the window, to indicate to the sizer |
1270 | layout mechanism that this is the minimum required size of window's client | |
1271 | area. | |
23324ae1 | 1272 | |
d0a67157 FM |
1273 | You may need to call this if you change the window size after |
1274 | construction and before adding to its parent sizer. | |
76e9224e | 1275 | |
d0a67157 FM |
1276 | Note, that just as with SetMinSize(), calling this method doesn't |
1277 | prevent the program from explicitly making the window smaller than the | |
1278 | specified size. | |
3c4f71cc | 1279 | |
d9ced90b FM |
1280 | Note that this method is just a shortcut for: |
1281 | @code | |
1282 | SetMinSize(ClientToWindowSize(size)); | |
1283 | @endcode | |
1284 | ||
1285 | @see SetMinSize(), @ref overview_windowsizing | |
23324ae1 | 1286 | */ |
d0a67157 | 1287 | virtual void SetMinClientSize(const wxSize& size); |
23324ae1 FM |
1288 | |
1289 | /** | |
d0a67157 FM |
1290 | Sets the minimum size of the window, to indicate to the sizer layout |
1291 | mechanism that this is the minimum required size. | |
23324ae1 | 1292 | |
d0a67157 FM |
1293 | You may need to call this if you change the window size after |
1294 | construction and before adding to its parent sizer. | |
1295 | ||
1296 | Notice that calling this method doesn't prevent the program from making | |
1297 | the window explicitly smaller than the specified size by calling | |
1298 | SetSize(), it just ensures that it won't become smaller than this size | |
1299 | during the automatic layout. | |
1300 | ||
d9ced90b | 1301 | @see SetMinClientSize(), @ref overview_windowsizing |
23324ae1 | 1302 | */ |
d0a67157 | 1303 | virtual void SetMinSize(const wxSize& size); |
23324ae1 FM |
1304 | |
1305 | /** | |
d0a67157 FM |
1306 | Sets the size of the window in pixels. |
1307 | ||
1308 | @param x | |
1309 | Required x position in pixels, or wxDefaultCoord to indicate that the | |
1310 | existing value should be used. | |
1311 | @param y | |
1312 | Required y position in pixels, or wxDefaultCoord to indicate that the | |
1313 | existing value should be used. | |
1314 | @param width | |
1315 | Required width in pixels, or wxDefaultCoord to indicate that the existing | |
1316 | value should be used. | |
1317 | @param height | |
1318 | Required height position in pixels, or wxDefaultCoord to indicate that the | |
1319 | existing value should be used. | |
1320 | @param sizeFlags | |
1321 | Indicates the interpretation of other parameters. | |
1322 | It is a bit list of the following: | |
1323 | - @c wxSIZE_AUTO_WIDTH: a wxDefaultCoord width value is taken to indicate | |
1324 | a wxWidgets-supplied default width. | |
1325 | - @c wxSIZE_AUTO_HEIGHT: a wxDefaultCoord height value is taken to indicate | |
1326 | a wxWidgets-supplied default height. | |
1327 | - @c wxSIZE_AUTO: wxDefaultCoord size values are taken to indicate | |
1328 | a wxWidgets-supplied default size. | |
1329 | - @c wxSIZE_USE_EXISTING: existing dimensions should be used | |
1330 | if wxDefaultCoord values are supplied. | |
1331 | - @c wxSIZE_ALLOW_MINUS_ONE: allow negative dimensions (i.e. value of | |
1332 | wxDefaultCoord) to be interpreted as real | |
1333 | dimensions, not default values. | |
1334 | - @c wxSIZE_FORCE: normally, if the position and the size of the window are | |
1335 | already the same as the parameters of this function, | |
1336 | nothing is done. but with this flag a window resize may | |
1337 | be forced even in this case (supported in wx 2.6.2 and | |
1338 | later and only implemented for MSW and ignored elsewhere | |
1339 | currently). | |
1340 | ||
1341 | @remarks This overload sets the position and optionally size, of the window. | |
1342 | Parameters may be wxDefaultCoord to indicate either that a default | |
1343 | should be supplied by wxWidgets, or that the current value of the | |
1344 | dimension should be used. | |
1345 | ||
d9ced90b | 1346 | @see Move(), @ref overview_windowsizing |
23324ae1 | 1347 | */ |
d0a67157 FM |
1348 | void SetSize(int x, int y, int width, int height, |
1349 | int sizeFlags = wxSIZE_AUTO); | |
23324ae1 FM |
1350 | |
1351 | /** | |
d0a67157 FM |
1352 | Sets the size of the window in pixels. |
1353 | The size is specified using a wxRect, wxSize or by a couple of @c int objects. | |
3c4f71cc | 1354 | |
d0a67157 | 1355 | @remarks This form must be used with non-default width and height values. |
3c4f71cc | 1356 | |
d9ced90b | 1357 | @see Move(), @ref overview_windowsizing |
23324ae1 | 1358 | */ |
75504144 | 1359 | void SetSize(const wxRect& rect); |
23324ae1 FM |
1360 | |
1361 | /** | |
d0a67157 | 1362 | @overload |
23324ae1 | 1363 | */ |
75504144 | 1364 | void SetSize(const wxSize& size); |
23324ae1 FM |
1365 | |
1366 | /** | |
d0a67157 | 1367 | @overload |
23324ae1 | 1368 | */ |
75504144 | 1369 | void SetSize(int width, int height); |
23324ae1 FM |
1370 | |
1371 | /** | |
d0a67157 FM |
1372 | Use of this function for windows which are not toplevel windows |
1373 | (such as wxDialog or wxFrame) is discouraged. | |
1374 | Please use SetMinSize() and SetMaxSize() instead. | |
3c4f71cc | 1375 | |
d9ced90b | 1376 | @see wxTopLevelWindow::SetSizeHints, @ref overview_windowsizing |
23324ae1 | 1377 | */ |
05b0355a RD |
1378 | virtual void SetSizeHints( const wxSize& minSize, |
1379 | const wxSize& maxSize=wxDefaultSize, | |
1380 | const wxSize& incSize=wxDefaultSize); | |
1381 | virtual void SetSizeHints( int minW, int minH, | |
1382 | int maxW = -1, int maxH = -1, | |
1383 | int incW = -1, int incH = -1 ); | |
23324ae1 | 1384 | |
23324ae1 | 1385 | /** |
d0a67157 | 1386 | Sets the virtual size of the window in pixels. |
d9ced90b FM |
1387 | |
1388 | @see @ref overview_windowsizing | |
d0a67157 FM |
1389 | */ |
1390 | void SetVirtualSize(int width, int height); | |
3c4f71cc | 1391 | |
d0a67157 FM |
1392 | /** |
1393 | @overload | |
23324ae1 | 1394 | */ |
d0a67157 FM |
1395 | void SetVirtualSize(const wxSize& size); |
1396 | ||
1397 | //@} | |
1398 | ||
23324ae1 FM |
1399 | |
1400 | /** | |
47009083 | 1401 | @name Positioning functions |
d0a67157 FM |
1402 | */ |
1403 | //@{ | |
e25cd775 | 1404 | |
d0a67157 FM |
1405 | /** |
1406 | A synonym for Centre(). | |
23324ae1 | 1407 | */ |
d0a67157 | 1408 | void Center(int dir = wxBOTH); |
23324ae1 FM |
1409 | |
1410 | /** | |
d0a67157 | 1411 | A synonym for CentreOnParent(). |
23324ae1 | 1412 | */ |
d0a67157 | 1413 | void CenterOnParent(int dir = wxBOTH); |
23324ae1 FM |
1414 | |
1415 | /** | |
d0a67157 | 1416 | Centres the window. |
eed04c99 | 1417 | |
d0a67157 | 1418 | @param direction |
ccd4e1bc | 1419 | Specifies the direction for the centring. May be wxHORIZONTAL, wxVERTICAL |
e4390488 | 1420 | or wxBOTH. It may also include the wxCENTRE_ON_SCREEN flag |
ccd4e1bc | 1421 | if you want to centre the window on the entire screen and not on its |
d0a67157 | 1422 | parent window. |
3c4f71cc | 1423 | |
d0a67157 | 1424 | @remarks If the window is a top level one (i.e. doesn't have a parent), |
ccd4e1bc | 1425 | it will be centred relative to the screen anyhow. |
d0a67157 FM |
1426 | |
1427 | @see Center() | |
23324ae1 | 1428 | */ |
d0a67157 | 1429 | void Centre(int direction = wxBOTH); |
23324ae1 FM |
1430 | |
1431 | /** | |
d0a67157 | 1432 | Centres the window on its parent. This is a more readable synonym for Centre(). |
e25cd775 | 1433 | |
d0a67157 | 1434 | @param direction |
ccd4e1bc | 1435 | Specifies the direction for the centring. May be wxHORIZONTAL, wxVERTICAL |
d0a67157 | 1436 | or wxBOTH. |
e25cd775 | 1437 | |
ccd4e1bc | 1438 | @remarks This methods provides for a way to centre top level windows over |
d0a67157 FM |
1439 | their parents instead of the entire screen. If there |
1440 | is no parent or if the window is not a top level | |
1441 | window, then behaviour is the same as Centre(). | |
23324ae1 | 1442 | |
d0a67157 FM |
1443 | @see wxTopLevelWindow::CentreOnScreen |
1444 | */ | |
1445 | void CentreOnParent(int direction = wxBOTH); | |
e4390488 | 1446 | |
23324ae1 | 1447 | /** |
d0a67157 FM |
1448 | This gets the position of the window in pixels, relative to the parent window |
1449 | for the child windows or relative to the display origin for the top level windows. | |
1450 | ||
1451 | @param x | |
1452 | Receives the x position of the window if non-@NULL. | |
1453 | @param y | |
1454 | Receives the y position of the window if non-@NULL. | |
1455 | ||
1058f652 MB |
1456 | @beginWxPerlOnly |
1457 | In wxPerl this method is implemented as GetPositionXY() returning | |
1458 | a 2-element list (x, y). | |
1459 | @endWxPerlOnly | |
1460 | ||
d0a67157 | 1461 | @see GetScreenPosition() |
23324ae1 | 1462 | */ |
d0a67157 | 1463 | void GetPosition(int* x, int* y) const; |
23324ae1 FM |
1464 | |
1465 | /** | |
d0a67157 FM |
1466 | This gets the position of the window in pixels, relative to the parent window |
1467 | for the child windows or relative to the display origin for the top level windows. | |
1468 | ||
1469 | @see GetScreenPosition() | |
23324ae1 | 1470 | */ |
d0a67157 | 1471 | wxPoint GetPosition() const; |
23324ae1 FM |
1472 | |
1473 | /** | |
d0a67157 | 1474 | Returns the position and size of the window as a wxRect object. |
3c4f71cc | 1475 | |
d0a67157 | 1476 | @see GetScreenRect() |
23324ae1 | 1477 | */ |
d0a67157 | 1478 | wxRect GetRect() const; |
23324ae1 FM |
1479 | |
1480 | /** | |
d0a67157 FM |
1481 | Returns the window position in screen coordinates, whether the window is a |
1482 | child window or a top level one. | |
e25cd775 | 1483 | |
d0a67157 FM |
1484 | @param x |
1485 | Receives the x position of the window on the screen if non-@NULL. | |
1486 | @param y | |
1487 | Receives the y position of the window on the screen if non-@NULL. | |
3c4f71cc | 1488 | |
d0a67157 | 1489 | @see GetPosition() |
23324ae1 | 1490 | */ |
d0a67157 | 1491 | void GetScreenPosition(int* x, int* y) const; |
23324ae1 | 1492 | |
23324ae1 | 1493 | /** |
d0a67157 FM |
1494 | Returns the window position in screen coordinates, whether the window is a |
1495 | child window or a top level one. | |
2b4367d5 | 1496 | |
d0a67157 | 1497 | @see GetPosition() |
23324ae1 | 1498 | */ |
d0a67157 | 1499 | wxPoint GetScreenPosition() const; |
23324ae1 FM |
1500 | |
1501 | /** | |
d0a67157 | 1502 | Returns the position and size of the window on the screen as a wxRect object. |
3c4f71cc | 1503 | |
d0a67157 | 1504 | @see GetRect() |
23324ae1 | 1505 | */ |
d0a67157 | 1506 | wxRect GetScreenRect() const; |
23324ae1 | 1507 | |
05b0355a RD |
1508 | /** |
1509 | Get the origin of the client area of the window relative to the | |
1510 | window top left corner (the client area may be shifted because of | |
1511 | the borders, scrollbars, other decorations...) | |
1512 | */ | |
1513 | virtual wxPoint GetClientAreaOrigin() const; | |
1514 | ||
1515 | /** | |
0824e369 | 1516 | Get the client rectangle in window (i.e.\ client) coordinates |
05b0355a RD |
1517 | */ |
1518 | wxRect GetClientRect() const; | |
1519 | ||
1520 | ||
1521 | ||
23324ae1 FM |
1522 | /** |
1523 | Moves the window to the given position. | |
3c4f71cc | 1524 | |
7c913512 | 1525 | @param x |
4cc4bfaf | 1526 | Required x position. |
7c913512 | 1527 | @param y |
4cc4bfaf | 1528 | Required y position. |
77bfb902 FM |
1529 | @param flags |
1530 | See SetSize() for more info about this parameter. | |
3c4f71cc | 1531 | |
23324ae1 | 1532 | @remarks Implementations of SetSize can also implicitly implement the |
e25cd775 FM |
1533 | Move() function, which is defined in the base wxWindow class as the call: |
1534 | @code | |
1535 | SetSize(x, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING); | |
1536 | @endcode | |
3c4f71cc | 1537 | |
4cc4bfaf | 1538 | @see SetSize() |
23324ae1 | 1539 | */ |
77bfb902 | 1540 | void Move(int x, int y, int flags = wxSIZE_USE_EXISTING); |
e25cd775 FM |
1541 | |
1542 | /** | |
1543 | Moves the window to the given position. | |
1544 | ||
1545 | @param pt | |
1546 | wxPoint object representing the position. | |
77bfb902 FM |
1547 | @param flags |
1548 | See SetSize() for more info about this parameter. | |
e25cd775 FM |
1549 | |
1550 | @remarks Implementations of SetSize() can also implicitly implement the | |
1551 | Move() function, which is defined in the base wxWindow class as the call: | |
1552 | @code | |
1553 | SetSize(x, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING); | |
1554 | @endcode | |
1555 | ||
1556 | @see SetSize() | |
1557 | */ | |
77bfb902 | 1558 | void Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING); |
23324ae1 | 1559 | |
05b0355a RD |
1560 | void SetPosition(const wxPoint& pt); |
1561 | ||
d0a67157 FM |
1562 | //@} |
1563 | ||
1564 | ||
23324ae1 | 1565 | /** |
47009083 | 1566 | @name Coordinate conversion functions |
d0a67157 FM |
1567 | */ |
1568 | //@{ | |
e25cd775 | 1569 | |
d0a67157 FM |
1570 | /** |
1571 | Converts to screen coordinates from coordinates relative to this window. | |
3c4f71cc | 1572 | |
d0a67157 FM |
1573 | @param x |
1574 | A pointer to a integer value for the x coordinate. Pass the client | |
1575 | coordinate in, and a screen coordinate will be passed out. | |
1576 | @param y | |
1577 | A pointer to a integer value for the y coordinate. Pass the client | |
1578 | coordinate in, and a screen coordinate will be passed out. | |
1579 | ||
1058f652 MB |
1580 | @beginWxPerlOnly |
1581 | In wxPerl this method returns a 2-element list instead of | |
1582 | modifying its parameters. | |
1583 | @endWxPerlOnly | |
23324ae1 | 1584 | */ |
d0a67157 | 1585 | void ClientToScreen(int* x, int* y) const; |
23324ae1 FM |
1586 | |
1587 | /** | |
d0a67157 FM |
1588 | Converts to screen coordinates from coordinates relative to this window. |
1589 | ||
1590 | @param pt | |
1591 | The client position for the second form of the function. | |
23324ae1 | 1592 | */ |
d0a67157 | 1593 | wxPoint ClientToScreen(const wxPoint& pt) const; |
23324ae1 FM |
1594 | |
1595 | /** | |
d0a67157 | 1596 | Converts a point or size from dialog units to pixels. |
3c4f71cc | 1597 | |
d0a67157 FM |
1598 | For the x dimension, the dialog units are multiplied by the average character |
1599 | width and then divided by 4. | |
1600 | For the y dimension, the dialog units are multiplied by the average character | |
1601 | height and then divided by 8. | |
3c4f71cc | 1602 | |
d0a67157 FM |
1603 | @remarks Dialog units are used for maintaining a dialog's proportions |
1604 | even if the font changes. | |
1605 | You can also use these functions programmatically. | |
1606 | A convenience macro is defined: | |
1607 | @code | |
1608 | #define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt) | |
1609 | @endcode | |
3c4f71cc | 1610 | |
d0a67157 | 1611 | @see ConvertPixelsToDialog() |
23324ae1 | 1612 | */ |
0e7f59ab | 1613 | wxPoint ConvertDialogToPixels(const wxPoint& pt) const; |
23324ae1 FM |
1614 | |
1615 | /** | |
d0a67157 | 1616 | @overload |
23324ae1 | 1617 | */ |
0e7f59ab | 1618 | wxSize ConvertDialogToPixels(const wxSize& sz) const; |
23324ae1 FM |
1619 | |
1620 | /** | |
d0a67157 | 1621 | Converts a point or size from pixels to dialog units. |
e25cd775 | 1622 | |
d0a67157 FM |
1623 | For the x dimension, the pixels are multiplied by 4 and then divided by the |
1624 | average character width. | |
1625 | For the y dimension, the pixels are multiplied by 8 and then divided by the | |
1626 | average character height. | |
3c4f71cc | 1627 | |
d0a67157 FM |
1628 | @remarks Dialog units are used for maintaining a dialog's proportions |
1629 | even if the font changes. | |
3c4f71cc | 1630 | |
d0a67157 FM |
1631 | @see ConvertDialogToPixels() |
1632 | */ | |
0e7f59ab | 1633 | wxPoint ConvertPixelsToDialog(const wxPoint& pt) const; |
3c4f71cc | 1634 | |
d0a67157 FM |
1635 | /** |
1636 | @overload | |
23324ae1 | 1637 | */ |
0e7f59ab | 1638 | wxSize ConvertPixelsToDialog(const wxSize& sz) const; |
23324ae1 FM |
1639 | |
1640 | /** | |
d0a67157 | 1641 | Converts from screen to client window coordinates. |
e25cd775 | 1642 | |
d0a67157 FM |
1643 | @param x |
1644 | Stores the screen x coordinate and receives the client x coordinate. | |
1645 | @param y | |
1646 | Stores the screen x coordinate and receives the client x coordinate. | |
23324ae1 | 1647 | */ |
d0a67157 | 1648 | void ScreenToClient(int* x, int* y) const; |
23324ae1 FM |
1649 | |
1650 | /** | |
d0a67157 FM |
1651 | Converts from screen to client window coordinates. |
1652 | ||
1653 | @param pt | |
1654 | The screen position. | |
592584e4 | 1655 | */ |
d0a67157 FM |
1656 | wxPoint ScreenToClient(const wxPoint& pt) const; |
1657 | ||
1658 | //@} | |
1659 | ||
592584e4 VS |
1660 | |
1661 | /** | |
d0a67157 | 1662 | @name Drawing-related functions |
23324ae1 | 1663 | */ |
d0a67157 | 1664 | //@{ |
23324ae1 | 1665 | |
592584e4 | 1666 | /** |
f6b4a1b9 VZ |
1667 | Clears the window by filling it with the current background colour. |
1668 | ||
1669 | Does not cause an erase background event to be generated. | |
1670 | ||
1671 | Notice that this uses wxClientDC to draw on the window and the results | |
1672 | of doing it while also drawing on wxPaintDC for this window are | |
1673 | undefined. Hence this method shouldn't be used from EVT_PAINT handlers, | |
1674 | just use wxDC::Clear() on the wxPaintDC you already use there instead. | |
592584e4 | 1675 | */ |
d0a67157 | 1676 | virtual void ClearBackground(); |
23324ae1 FM |
1677 | |
1678 | /** | |
d0a67157 FM |
1679 | Freezes the window or, in other words, prevents any updates from taking |
1680 | place on screen, the window is not redrawn at all. | |
23324ae1 | 1681 | |
d0a67157 FM |
1682 | Thaw() must be called to reenable window redrawing. Calls to these two |
1683 | functions may be nested but to ensure that the window is properly | |
1684 | repainted again, you must thaw it exactly as many times as you froze it. | |
23324ae1 | 1685 | |
d0a67157 | 1686 | If the window has any children, they are recursively frozen too. |
3c4f71cc | 1687 | |
d0a67157 FM |
1688 | This method is useful for visual appearance optimization (for example, |
1689 | it is a good idea to use it before doing many large text insertions in | |
1690 | a row into a wxTextCtrl under wxGTK) but is not implemented on all | |
1691 | platforms nor for all controls so it is mostly just a hint to wxWidgets | |
1692 | and not a mandatory directive. | |
3c4f71cc | 1693 | |
d0a67157 | 1694 | @see wxWindowUpdateLocker, Thaw(), IsFrozen() |
23324ae1 | 1695 | */ |
d0a67157 | 1696 | void Freeze(); |
23324ae1 | 1697 | |
23324ae1 | 1698 | /** |
ccd4e1bc | 1699 | Re-enables window updating after a previous call to Freeze(). |
e25cd775 | 1700 | |
d0a67157 FM |
1701 | To really thaw the control, it must be called exactly the same number |
1702 | of times as Freeze(). | |
3c4f71cc | 1703 | |
ccd4e1bc | 1704 | If the window has any children, they are recursively thawed too. |
76e9224e | 1705 | |
d0a67157 FM |
1706 | @see wxWindowUpdateLocker, Freeze(), IsFrozen() |
1707 | */ | |
1708 | void Thaw(); | |
3c4f71cc | 1709 | |
d0a67157 FM |
1710 | /** |
1711 | Returns @true if the window is currently frozen by a call to Freeze(). | |
3c4f71cc | 1712 | |
d0a67157 | 1713 | @see Freeze(), Thaw() |
23324ae1 | 1714 | */ |
d0a67157 | 1715 | bool IsFrozen() const; |
23324ae1 | 1716 | |
ecdc1183 | 1717 | /** |
d0a67157 | 1718 | Returns the background colour of the window. |
ecdc1183 | 1719 | |
d0a67157 FM |
1720 | @see SetBackgroundColour(), SetForegroundColour(), GetForegroundColour() |
1721 | */ | |
1722 | wxColour GetBackgroundColour() const; | |
ecdc1183 VZ |
1723 | |
1724 | /** | |
d0a67157 | 1725 | Returns the background style of the window. |
ecdc1183 | 1726 | |
d0a67157 FM |
1727 | @see SetBackgroundColour(), GetForegroundColour(), |
1728 | SetBackgroundStyle(), SetTransparent() | |
1729 | */ | |
1730 | virtual wxBackgroundStyle GetBackgroundStyle() const; | |
9c61c5b0 | 1731 | |
d0a67157 FM |
1732 | /** |
1733 | Returns the character height for this window. | |
1734 | */ | |
1735 | virtual int GetCharHeight() const; | |
ecdc1183 | 1736 | |
23324ae1 | 1737 | /** |
d0a67157 FM |
1738 | Returns the average character width for this window. |
1739 | */ | |
1740 | virtual int GetCharWidth() const; | |
3c4f71cc | 1741 | |
d0a67157 FM |
1742 | /** |
1743 | Currently this is the same as calling | |
1744 | wxWindow::GetClassDefaultAttributes(wxWindow::GetWindowVariant()). | |
3c4f71cc | 1745 | |
d0a67157 FM |
1746 | One advantage of using this function compared to the static version is that |
1747 | the call is automatically dispatched to the correct class (as usual with | |
1748 | virtual functions) and you don't have to specify the class name explicitly. | |
3c4f71cc | 1749 | |
d0a67157 FM |
1750 | The other one is that in the future this function could return different |
1751 | results, for example it might return a different font for an "Ok" button | |
1752 | than for a generic button if the users GUI is configured to show such buttons | |
1753 | in bold font. Of course, the down side is that it is impossible to call this | |
1754 | function without actually having an object to apply it to whereas the static | |
1755 | version can be used without having to create an object first. | |
23324ae1 | 1756 | */ |
d0a67157 | 1757 | virtual wxVisualAttributes GetDefaultAttributes() const; |
23324ae1 FM |
1758 | |
1759 | /** | |
d0a67157 | 1760 | Returns the font for this window. |
2b4367d5 | 1761 | |
d0a67157 FM |
1762 | @see SetFont() |
1763 | */ | |
1764 | wxFont GetFont() const; | |
3c4f71cc | 1765 | |
d0a67157 FM |
1766 | /** |
1767 | Returns the foreground colour of the window. | |
1768 | ||
ccd4e1bc VZ |
1769 | @remarks The meaning of foreground colour varies according to the window class; |
1770 | it may be the text colour or other colour, or it may not be used at all. | |
d0a67157 FM |
1771 | |
1772 | @see SetForegroundColour(), SetBackgroundColour(), | |
1773 | GetBackgroundColour() | |
23324ae1 | 1774 | */ |
d0a67157 FM |
1775 | wxColour GetForegroundColour() const; |
1776 | ||
1777 | /** | |
1778 | Gets the dimensions of the string as it would be drawn on the | |
1779 | window with the currently selected font. | |
1780 | ||
ccd4e1bc | 1781 | The text extent is returned in the @a w and @a h pointers. |
d0a67157 FM |
1782 | |
1783 | @param string | |
1784 | String whose extent is to be measured. | |
1785 | @param w | |
1786 | Return value for width. | |
1787 | @param h | |
1788 | Return value for height. | |
1789 | @param descent | |
1790 | Return value for descent (optional). | |
1791 | @param externalLeading | |
1792 | Return value for external leading (optional). | |
1793 | @param font | |
1794 | Font to use instead of the current window font (optional). | |
1058f652 MB |
1795 | |
1796 | @beginWxPerlOnly | |
1797 | In wxPerl this method takes only the @a string and optionally | |
1798 | @a font parameters, and returns a 4-element list | |
1799 | (x, y, descent, externalLeading). | |
1800 | @endWxPerlOnly | |
d0a67157 | 1801 | */ |
522c3404 | 1802 | void GetTextExtent(const wxString& string, |
05b0355a | 1803 | int* w, int* h, |
522c3404 VZ |
1804 | int* descent = NULL, |
1805 | int* externalLeading = NULL, | |
1806 | const wxFont* font = NULL) const; | |
d0a67157 FM |
1807 | |
1808 | /** | |
1809 | Gets the dimensions of the string as it would be drawn on the | |
1810 | window with the currently selected font. | |
1811 | */ | |
1812 | wxSize GetTextExtent(const wxString& string) const; | |
1813 | ||
1814 | /** | |
1815 | Returns the region specifying which parts of the window have been damaged. | |
1816 | Should only be called within an wxPaintEvent handler. | |
1817 | ||
1818 | @see wxRegion, wxRegionIterator | |
1819 | */ | |
1820 | const wxRegion& GetUpdateRegion() const; | |
1821 | ||
05b0355a RD |
1822 | /** |
1823 | Get the update rectangle bounding box in client coords | |
1824 | */ | |
1825 | wxRect GetUpdateClientRect() const; | |
1826 | ||
d0a67157 FM |
1827 | /** |
1828 | Returns @true if this window background is transparent (as, for example, | |
1829 | for wxStaticText) and should show the parent window background. | |
1830 | ||
1831 | This method is mostly used internally by the library itself and you normally | |
1832 | shouldn't have to call it. You may, however, have to override it in your | |
1833 | wxWindow-derived class to ensure that background is painted correctly. | |
1834 | */ | |
1835 | virtual bool HasTransparentBackground(); | |
23324ae1 FM |
1836 | |
1837 | /** | |
1838 | Causes this window, and all of its children recursively (except under wxGTK1 | |
1839 | where this is not implemented), to be repainted. Note that repainting doesn't | |
1840 | happen immediately but only during the next event loop iteration, if you need | |
e25cd775 | 1841 | to update the window immediately you should use Update() instead. |
3c4f71cc | 1842 | |
7c913512 | 1843 | @param eraseBackground |
e25cd775 | 1844 | If @true, the background will be erased. |
7c913512 | 1845 | @param rect |
e25cd775 | 1846 | If non-@NULL, only the given rectangle will be treated as damaged. |
3c4f71cc | 1847 | |
4cc4bfaf | 1848 | @see RefreshRect() |
23324ae1 | 1849 | */ |
4cc4bfaf FM |
1850 | virtual void Refresh(bool eraseBackground = true, |
1851 | const wxRect* rect = NULL); | |
23324ae1 FM |
1852 | |
1853 | /** | |
1854 | Redraws the contents of the given rectangle: only the area inside it will be | |
1855 | repainted. | |
e25cd775 FM |
1856 | |
1857 | This is the same as Refresh() but has a nicer syntax as it can be called | |
1858 | with a temporary wxRect object as argument like this @c RefreshRect(wxRect(x, y, w, h)). | |
23324ae1 | 1859 | */ |
4cc4bfaf | 1860 | void RefreshRect(const wxRect& rect, bool eraseBackground = true); |
23324ae1 FM |
1861 | |
1862 | /** | |
d0a67157 | 1863 | Calling this method immediately repaints the invalidated area of the window and |
ccd4e1bc VZ |
1864 | all of its children recursively (this normally only happens when the |
1865 | flow of control returns to the event loop). | |
e25cd775 | 1866 | |
d0a67157 FM |
1867 | Notice that this function doesn't invalidate any area of the window so |
1868 | nothing happens if nothing has been invalidated (i.e. marked as requiring | |
1869 | a redraw). Use Refresh() first if you want to immediately redraw the | |
1870 | window unconditionally. | |
1871 | */ | |
1872 | virtual void Update(); | |
3c4f71cc | 1873 | |
d0a67157 FM |
1874 | /** |
1875 | Sets the background colour of the window. | |
bf799728 VZ |
1876 | |
1877 | Notice that as with SetForegroundColour(), setting the background | |
1878 | colour of a native control may not affect the entire control and could | |
1879 | be not supported at all depending on the control and platform. | |
1880 | ||
d0a67157 FM |
1881 | Please see InheritAttributes() for explanation of the difference between |
1882 | this method and SetOwnBackgroundColour(). | |
3c4f71cc | 1883 | |
d0a67157 | 1884 | @param colour |
ccd4e1bc | 1885 | The colour to be used as the background colour; pass |
d0a67157 | 1886 | wxNullColour to reset to the default colour. |
bf799728 | 1887 | Note that you may want to use wxSystemSettings::GetColour() to retrieve |
9b756edd | 1888 | a suitable colour to use rather than setting an hard-coded one. |
3c4f71cc | 1889 | |
d0a67157 FM |
1890 | @remarks The background colour is usually painted by the default |
1891 | wxEraseEvent event handler function under Windows and | |
1892 | automatically under GTK. | |
1893 | Note that setting the background colour does not cause an | |
1894 | immediate refresh, so you may wish to call wxWindow::ClearBackground | |
1895 | or wxWindow::Refresh after calling this function. | |
1896 | Using this function will disable attempts to use themes for | |
1897 | this window, if the system supports them. Use with care since | |
1898 | usually the themes represent the appearance chosen by the user | |
1899 | to be used for all applications on the system. | |
3c4f71cc | 1900 | |
464c1f94 VZ |
1901 | @return @true if the colour was really changed, @false if it was already set |
1902 | to this colour and nothing was done. | |
1903 | ||
d0a67157 FM |
1904 | @see GetBackgroundColour(), SetForegroundColour(), |
1905 | GetForegroundColour(), ClearBackground(), | |
9b756edd | 1906 | Refresh(), wxEraseEvent, wxSystemSettings |
23324ae1 | 1907 | */ |
d0a67157 | 1908 | virtual bool SetBackgroundColour(const wxColour& colour); |
23324ae1 FM |
1909 | |
1910 | /** | |
9c61c5b0 VZ |
1911 | Sets the background style of the window. |
1912 | ||
9b756edd FM |
1913 | The default background style is @c wxBG_STYLE_ERASE which indicates that |
1914 | the window background may be erased in @c EVT_ERASE_BACKGROUND handler. | |
ccd4e1bc | 1915 | This is a safe, compatibility default; however you may want to change it |
9b756edd | 1916 | to @c wxBG_STYLE_SYSTEM if you don't define any erase background event |
ccd4e1bc | 1917 | handlers at all, to avoid unnecessary generation of erase background |
9c61c5b0 | 1918 | events and always let system erase the background. And you should |
9b756edd FM |
1919 | change the background style to @c wxBG_STYLE_PAINT if you define an |
1920 | @c EVT_PAINT handler which completely overwrites the window background as | |
1921 | in this case erasing it previously, either in @c EVT_ERASE_BACKGROUND | |
9c61c5b0 VZ |
1922 | handler or in the system default handler, would result in flicker as |
1923 | the background pixels will be repainted twice every time the window is | |
1924 | redrawn. Do ensure that the background is entirely erased by your | |
9b756edd | 1925 | @c EVT_PAINT handler in this case however as otherwise garbage may be left |
9c61c5b0 VZ |
1926 | on screen. |
1927 | ||
1928 | Notice that in previous versions of wxWidgets a common way to work | |
1929 | around the above mentioned flickering problem was to define an empty | |
9b756edd FM |
1930 | @c EVT_ERASE_BACKGROUND handler. Setting background style to |
1931 | @c wxBG_STYLE_PAINT is a simpler and more efficient solution to the same | |
9c61c5b0 | 1932 | problem. |
3c4f71cc | 1933 | |
14421681 VZ |
1934 | |
1935 | Under wxGTK and wxOSX, you can use ::wxBG_STYLE_TRANSPARENT to obtain | |
1936 | full transparency of the window background. Note that wxGTK supports | |
1937 | this only since GTK 2.12 with a compositing manager enabled, call | |
1938 | IsTransparentBackgroundSupported() to check whether this is the case. | |
1939 | ||
1940 | Also, on order for @c SetBackgroundStyle(wxBG_STYLE_TRANSPARENT) to | |
1941 | work, it must be called before Create(). If you're using your own | |
1942 | wxWindow-derived class you should write your code in the following way: | |
1943 | @code | |
1944 | class MyWidget : public wxWindow | |
1945 | { | |
1946 | public: | |
1947 | MyWidget(wxWindow* parent, ...) | |
1948 | : wxWindow() // Use default ctor here! | |
1949 | { | |
1950 | // Do this first: | |
1951 | SetBackgroundStyle(wxBG_STYLE_TRANSPARENT); | |
1952 | ||
1953 | // And really create the window afterwards: | |
1954 | Create(parent, ...); | |
1955 | } | |
1956 | }; | |
1957 | @endcode | |
1958 | ||
d0a67157 | 1959 | @see SetBackgroundColour(), GetForegroundColour(), |
14421681 | 1960 | SetTransparent(), IsTransparentBackgroundSupported() |
23324ae1 | 1961 | */ |
d0a67157 | 1962 | virtual bool SetBackgroundStyle(wxBackgroundStyle style); |
23324ae1 | 1963 | |
14421681 VZ |
1964 | /** |
1965 | Checks whether using transparent background might work. | |
1966 | ||
1967 | If this function returns @false, calling SetBackgroundStyle() with | |
1968 | ::wxBG_STYLE_TRANSPARENT is not going to work. If it returns @true, | |
1969 | setting transparent style should normally succeed. | |
1970 | ||
1971 | Notice that this function would typically be called on the parent of a | |
1972 | window you want to set transparent background style for as the window | |
1973 | for which this method is called must be fully created. | |
1974 | ||
1975 | @param reason | |
1976 | If not @NULL, a reason message is provided if transparency is not | |
1977 | supported. | |
1978 | ||
1979 | @return @true if background transparency is supported. | |
1980 | ||
1981 | @since 2.9.4 | |
1982 | */ | |
1983 | virtual bool IsTransparentBackgroundSupported(wxString *reason = NULL) const; | |
1984 | ||
23324ae1 | 1985 | /** |
d0a67157 FM |
1986 | Sets the font for this window. This function should not be called for the |
1987 | parent window if you don't want its font to be inherited by its children, | |
1988 | use SetOwnFont() instead in this case and see InheritAttributes() for more | |
1989 | explanations. | |
e25cd775 | 1990 | |
d0a67157 FM |
1991 | Please notice that the given font is not automatically used for |
1992 | wxPaintDC objects associated with this window, you need to | |
1993 | call wxDC::SetFont too. However this font is used by | |
1994 | any standard controls for drawing their text as well as by | |
1995 | GetTextExtent(). | |
3c4f71cc | 1996 | |
d0a67157 FM |
1997 | @param font |
1998 | Font to associate with this window, pass | |
1999 | wxNullFont to reset to the default font. | |
2000 | ||
464c1f94 VZ |
2001 | @return @true if the font was really changed, @false if it was already set |
2002 | to this font and nothing was done. | |
d0a67157 FM |
2003 | |
2004 | @see GetFont(), InheritAttributes() | |
23324ae1 | 2005 | */ |
d0a67157 | 2006 | virtual bool SetFont(const wxFont& font); |
23324ae1 FM |
2007 | |
2008 | /** | |
d0a67157 | 2009 | Sets the foreground colour of the window. |
bf799728 VZ |
2010 | |
2011 | The meaning of foreground colour varies according to the window class; | |
2012 | it may be the text colour or other colour, or it may not be used at | |
2013 | all. Additionally, not all native controls support changing their | |
2014 | foreground colour so this method may change their colour only partially | |
2015 | or even not at all. | |
2016 | ||
d0a67157 FM |
2017 | Please see InheritAttributes() for explanation of the difference between |
2018 | this method and SetOwnForegroundColour(). | |
3c4f71cc | 2019 | |
d0a67157 | 2020 | @param colour |
ccd4e1bc | 2021 | The colour to be used as the foreground colour; pass |
d0a67157 | 2022 | wxNullColour to reset to the default colour. |
3c4f71cc | 2023 | |
464c1f94 VZ |
2024 | @return @true if the colour was really changed, @false if it was already set |
2025 | to this colour and nothing was done. | |
2026 | ||
d0a67157 FM |
2027 | @see GetForegroundColour(), SetBackgroundColour(), |
2028 | GetBackgroundColour(), ShouldInheritColours() | |
23324ae1 | 2029 | */ |
d0a67157 | 2030 | virtual bool SetForegroundColour(const wxColour& colour); |
23324ae1 FM |
2031 | |
2032 | /** | |
d0a67157 FM |
2033 | Sets the background colour of the window but prevents it from being inherited |
2034 | by the children of this window. | |
3c4f71cc | 2035 | |
d0a67157 | 2036 | @see SetBackgroundColour(), InheritAttributes() |
23324ae1 | 2037 | */ |
d0a67157 | 2038 | void SetOwnBackgroundColour(const wxColour& colour); |
23324ae1 | 2039 | |
5eea1681 VZ |
2040 | /** |
2041 | Return @true if this window inherits the background colour from its parent. | |
2042 | ||
2043 | @see SetOwnBackgroundColour(), InheritAttributes() | |
2044 | */ | |
0c3140ca | 2045 | bool InheritsBackgroundColour() const; |
5eea1681 VZ |
2046 | |
2047 | /** | |
2048 | Return @true if a background colour has been set for this window. | |
2049 | */ | |
0c3140ca RD |
2050 | bool UseBgCol() const; |
2051 | ||
23324ae1 | 2052 | /** |
d0a67157 FM |
2053 | Sets the font of the window but prevents it from being inherited by the |
2054 | children of this window. | |
3c4f71cc | 2055 | |
d0a67157 | 2056 | @see SetFont(), InheritAttributes() |
23324ae1 | 2057 | */ |
d0a67157 | 2058 | void SetOwnFont(const wxFont& font); |
76e9224e FM |
2059 | |
2060 | /** | |
d0a67157 FM |
2061 | Sets the foreground colour of the window but prevents it from being inherited |
2062 | by the children of this window. | |
76e9224e | 2063 | |
d0a67157 | 2064 | @see SetForegroundColour(), InheritAttributes() |
76e9224e | 2065 | */ |
d0a67157 | 2066 | void SetOwnForegroundColour(const wxColour& colour); |
23324ae1 FM |
2067 | |
2068 | /** | |
d0a67157 | 2069 | @deprecated use wxDC::SetPalette instead. |
23324ae1 | 2070 | */ |
d0a67157 | 2071 | void SetPalette(const wxPalette& pal); |
23324ae1 FM |
2072 | |
2073 | /** | |
d0a67157 | 2074 | Return @true from here to allow the colours of this window to be changed by |
ccd4e1bc | 2075 | InheritAttributes(). Returning @false forbids inheriting them from the parent window. |
3c4f71cc | 2076 | |
d0a67157 FM |
2077 | The base class version returns @false, but this method is overridden in |
2078 | wxControl where it returns @true. | |
23324ae1 | 2079 | */ |
d0a67157 | 2080 | virtual bool ShouldInheritColours() const; |
23324ae1 FM |
2081 | |
2082 | /** | |
d0a67157 | 2083 | This function tells a window if it should use the system's "theme" code |
ccd4e1bc | 2084 | to draw the windows' background instead of its own background drawing |
d0a67157 FM |
2085 | code. This does not always have any effect since the underlying platform |
2086 | obviously needs to support the notion of themes in user defined windows. | |
2087 | One such platform is GTK+ where windows can have (very colourful) backgrounds | |
2088 | defined by a user's selected theme. | |
3c4f71cc | 2089 | |
d0a67157 FM |
2090 | Dialogs, notebook pages and the status bar have this flag set to @true |
2091 | by default so that the default look and feel is simulated best. | |
2092 | */ | |
2093 | virtual void SetThemeEnabled(bool enable); | |
3c4f71cc | 2094 | |
05b0355a RD |
2095 | /** |
2096 | */ | |
2097 | virtual bool GetThemeEnabled() const; | |
2098 | ||
d0a67157 FM |
2099 | /** |
2100 | Returns @true if the system supports transparent windows and calling | |
2101 | SetTransparent() may succeed. If this function returns @false, transparent | |
2102 | windows are definitely not supported by the current system. | |
23324ae1 | 2103 | */ |
d0a67157 | 2104 | virtual bool CanSetTransparent(); |
23324ae1 | 2105 | |
0dba08dd | 2106 | /** |
d0a67157 FM |
2107 | Set the transparency of the window. If the system supports transparent windows, |
2108 | returns @true, otherwise returns @false and the window remains fully opaque. | |
2109 | See also CanSetTransparent(). | |
0dba08dd | 2110 | |
d0a67157 FM |
2111 | The parameter @a alpha is in the range 0..255 where 0 corresponds to a |
2112 | fully transparent window and 255 to the fully opaque one. The constants | |
2113 | @c wxIMAGE_ALPHA_TRANSPARENT and @c wxIMAGE_ALPHA_OPAQUE can be used. | |
2114 | */ | |
2115 | virtual bool SetTransparent(wxByte alpha); | |
ecdc1183 | 2116 | |
d0a67157 | 2117 | //@} |
ecdc1183 | 2118 | |
d0a67157 FM |
2119 | |
2120 | /** | |
2121 | @name Event-handling functions | |
7f853dd0 FM |
2122 | |
2123 | wxWindow allows you to build a (sort of) stack of event handlers which | |
2124 | can be used to override the window's own event handling. | |
0dba08dd | 2125 | */ |
d0a67157 | 2126 | //@{ |
0dba08dd VZ |
2127 | |
2128 | /** | |
d0a67157 FM |
2129 | Returns the event handler for this window. |
2130 | By default, the window is its own event handler. | |
0dba08dd | 2131 | |
d0a67157 FM |
2132 | @see SetEventHandler(), PushEventHandler(), |
2133 | PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler | |
2134 | */ | |
2135 | wxEvtHandler* GetEventHandler() const; | |
ecdc1183 | 2136 | |
d0a67157 | 2137 | /** |
7f853dd0 FM |
2138 | This function will generate the appropriate call to Navigate() if the key |
2139 | event is one normally used for keyboard navigation and return @true in this case. | |
ecdc1183 | 2140 | |
d0a67157 FM |
2141 | @return Returns @true if the key pressed was for navigation and was |
2142 | handled, @false otherwise. | |
0dba08dd | 2143 | |
d0a67157 | 2144 | @see Navigate() |
23324ae1 | 2145 | */ |
d0a67157 | 2146 | bool HandleAsNavigationKey(const wxKeyEvent& event); |
23324ae1 FM |
2147 | |
2148 | /** | |
d0a67157 FM |
2149 | Shorthand for: |
2150 | @code | |
2151 | GetEventHandler()->SafelyProcessEvent(event); | |
2152 | @endcode | |
3b7fa206 VZ |
2153 | |
2154 | @see ProcessWindowEvent() | |
23324ae1 | 2155 | */ |
d0a67157 | 2156 | bool HandleWindowEvent(wxEvent& event) const; |
23324ae1 | 2157 | |
3b7fa206 VZ |
2158 | /** |
2159 | Convenient wrapper for ProcessEvent(). | |
2160 | ||
2161 | This is the same as writing @code GetEventHandler()->ProcessEvent(event); | |
2162 | @endcode but more convenient. Notice that ProcessEvent() itself can't | |
2163 | be called for wxWindow objects as it ignores the event handlers | |
ccd4e1bc | 2164 | associated with the window; use this function instead. |
3b7fa206 VZ |
2165 | */ |
2166 | bool ProcessWindowEvent(wxEvent& event); | |
2167 | ||
396e9eb8 VZ |
2168 | /** |
2169 | Wrapper for wxEvtHandler::ProcessEventLocally(). | |
2170 | ||
2171 | This method is similar to ProcessWindowEvent() but can be used to | |
2172 | search for the event handler only in this window and any event handlers | |
2173 | pushed on top of it. Unlike ProcessWindowEvent() it won't propagate the | |
512220b6 VZ |
2174 | event upwards. But it will use the validator and event handlers |
2175 | associated with this window, if any. | |
396e9eb8 VZ |
2176 | |
2177 | @since 2.9.1 | |
2178 | */ | |
2179 | bool ProcessWindowEventLocally(wxEvent& event); | |
2180 | ||
23324ae1 | 2181 | /** |
d0a67157 | 2182 | Removes and returns the top-most event handler on the event handler stack. |
3c4f71cc | 2183 | |
7f853dd0 | 2184 | E.g. in the case of: |
830b7aa7 | 2185 | @image html overview_events_winstack.png |
7f853dd0 FM |
2186 | when calling @c W->PopEventHandler(), the event handler @c A will be |
2187 | removed and @c B will be the first handler of the stack. | |
2188 | ||
2189 | Note that it's an error to call this function when no event handlers | |
2190 | were pushed on this window (i.e. when the window itself is its only | |
2191 | event handler). | |
2192 | ||
d0a67157 | 2193 | @param deleteHandler |
7f853dd0 FM |
2194 | If this is @true, the handler will be deleted after it is removed |
2195 | (and the returned value will be @NULL). | |
3c4f71cc | 2196 | |
3e083d65 | 2197 | @see @ref overview_events_processing |
23324ae1 | 2198 | */ |
d0a67157 | 2199 | wxEvtHandler* PopEventHandler(bool deleteHandler = false); |
23324ae1 FM |
2200 | |
2201 | /** | |
d0a67157 | 2202 | Pushes this event handler onto the event stack for the window. |
3c4f71cc | 2203 | |
7f853dd0 FM |
2204 | An event handler is an object that is capable of processing the events sent |
2205 | to a window. By default, the window is its own event handler, but an application | |
2206 | may wish to substitute another, for example to allow central implementation | |
2207 | of event-handling for a variety of different window classes. | |
2208 | ||
2209 | wxWindow::PushEventHandler allows an application to set up a @e stack | |
2210 | of event handlers, where an event not handled by one event handler is | |
2211 | handed to the next one in the chain. | |
2212 | ||
2213 | E.g. if you have two event handlers @c A and @c B and a wxWindow instance | |
2214 | @c W and you call: | |
2215 | @code | |
2216 | W->PushEventHandler(A); | |
2217 | W->PushEventHandler(B); | |
2218 | @endcode | |
2219 | you will end up with the following situation: | |
830b7aa7 | 2220 | @image html overview_events_winstack.png |
7f853dd0 FM |
2221 | |
2222 | Note that you can use wxWindow::PopEventHandler to remove the event handler. | |
2223 | ||
d0a67157 FM |
2224 | @param handler |
2225 | Specifies the handler to be pushed. | |
7f853dd0 FM |
2226 | It must not be part of a wxEvtHandler chain; an assert will fail |
2227 | if it's not unlinked (see wxEvtHandler::IsUnlinked). | |
3c4f71cc | 2228 | |
3e083d65 | 2229 | @see @ref overview_events_processing |
23324ae1 | 2230 | */ |
d0a67157 | 2231 | void PushEventHandler(wxEvtHandler* handler); |
23324ae1 FM |
2232 | |
2233 | /** | |
3e083d65 VZ |
2234 | Find the given @a handler in the windows event handler stack and |
2235 | removes (but does not delete) it from the stack. | |
2236 | ||
2237 | See wxEvtHandler::Unlink() for more info. | |
3c4f71cc | 2238 | |
d0a67157 FM |
2239 | @param handler |
2240 | The event handler to remove, must be non-@NULL and | |
7f853dd0 | 2241 | must be present in this windows event handlers stack. |
d0a67157 FM |
2242 | |
2243 | @return Returns @true if it was found and @false otherwise (this also | |
2244 | results in an assert failure so this function should | |
2245 | only be called when the handler is supposed to be there). | |
2246 | ||
2247 | @see PushEventHandler(), PopEventHandler() | |
23324ae1 | 2248 | */ |
d0a67157 | 2249 | bool RemoveEventHandler(wxEvtHandler* handler); |
23324ae1 FM |
2250 | |
2251 | /** | |
d0a67157 | 2252 | Sets the event handler for this window. |
e25cd775 | 2253 | |
7f853dd0 FM |
2254 | Note that if you use this function you may want to use as the "next" handler |
2255 | of @a handler the window itself; in this way when @a handler doesn't process | |
2256 | an event, the window itself will have a chance to do it. | |
2257 | ||
d0a67157 | 2258 | @param handler |
7f853dd0 FM |
2259 | Specifies the handler to be set. Cannot be @NULL. |
2260 | ||
3e083d65 | 2261 | @see @ref overview_events_processing |
23324ae1 | 2262 | */ |
d0a67157 FM |
2263 | void SetEventHandler(wxEvtHandler* handler); |
2264 | ||
7f853dd0 FM |
2265 | /** |
2266 | wxWindows cannot be used to form event handler chains; this function | |
2267 | thus will assert when called. | |
2268 | ||
2269 | Note that instead you can use PushEventHandler() or SetEventHandler() to | |
2270 | implement a stack of event handlers to override wxWindow's own | |
2271 | event handling mechanism. | |
2272 | */ | |
2273 | virtual void SetNextHandler(wxEvtHandler* handler); | |
2274 | ||
2275 | /** | |
2276 | wxWindows cannot be used to form event handler chains; this function | |
2277 | thus will assert when called. | |
2278 | ||
2279 | Note that instead you can use PushEventHandler() or SetEventHandler() to | |
2280 | implement a stack of event handlers to override wxWindow's own | |
2281 | event handling mechanism. | |
2282 | */ | |
2283 | virtual void SetPreviousHandler(wxEvtHandler* handler); | |
2284 | ||
d0a67157 FM |
2285 | //@} |
2286 | ||
23324ae1 | 2287 | |
7f853dd0 | 2288 | |
23324ae1 | 2289 | /** |
47009083 | 2290 | @name Window styles functions |
23324ae1 | 2291 | */ |
23324ae1 | 2292 | //@{ |
d0a67157 | 2293 | |
23324ae1 | 2294 | /** |
d0a67157 | 2295 | Returns the extra style bits for the window. |
23324ae1 | 2296 | */ |
d0a67157 | 2297 | long GetExtraStyle() const; |
23324ae1 FM |
2298 | |
2299 | /** | |
d0a67157 FM |
2300 | Gets the window style that was passed to the constructor or Create() |
2301 | method. GetWindowStyle() is another name for the same function. | |
23324ae1 | 2302 | */ |
d0a67157 | 2303 | virtual long GetWindowStyleFlag() const; |
23324ae1 FM |
2304 | |
2305 | /** | |
d0a67157 | 2306 | See GetWindowStyleFlag() for more info. |
23324ae1 | 2307 | */ |
d0a67157 | 2308 | long GetWindowStyle() const; |
23324ae1 FM |
2309 | |
2310 | /** | |
d0a67157 FM |
2311 | Returns @true if the window has the given @a exFlag bit set in its |
2312 | extra styles. | |
3c4f71cc | 2313 | |
d0a67157 | 2314 | @see SetExtraStyle() |
23324ae1 | 2315 | */ |
d0a67157 | 2316 | bool HasExtraStyle(int exFlag) const; |
23324ae1 FM |
2317 | |
2318 | /** | |
d0a67157 | 2319 | Returns @true if the window has the given @a flag bit set. |
23324ae1 | 2320 | */ |
d0a67157 | 2321 | bool HasFlag(int flag) const; |
23324ae1 FM |
2322 | |
2323 | /** | |
e25cd775 FM |
2324 | Sets the extra style bits for the window. |
2325 | The currently defined extra style bits are reported in the class | |
2326 | description. | |
23324ae1 | 2327 | */ |
adaaa686 | 2328 | virtual void SetExtraStyle(long exStyle); |
23324ae1 FM |
2329 | |
2330 | /** | |
d0a67157 | 2331 | Sets the style of the window. Please note that some styles cannot be changed |
d13b34d3 | 2332 | after the window creation and that Refresh() might need to be called |
d0a67157 | 2333 | after changing the others for the change to take place immediately. |
23324ae1 | 2334 | |
d0a67157 | 2335 | See @ref overview_windowstyles "Window styles" for more information about flags. |
e25cd775 | 2336 | |
d0a67157 | 2337 | @see GetWindowStyleFlag() |
23324ae1 | 2338 | */ |
d0a67157 | 2339 | virtual void SetWindowStyleFlag(long style); |
23324ae1 FM |
2340 | |
2341 | /** | |
d0a67157 FM |
2342 | See SetWindowStyleFlag() for more info. |
2343 | */ | |
2344 | void SetWindowStyle(long style); | |
3c4f71cc | 2345 | |
47009083 FM |
2346 | /** |
2347 | Turns the given @a flag on if it's currently turned off and vice versa. | |
2348 | This function cannot be used if the value of the flag is 0 (which is often | |
2349 | the case for default flags). | |
2350 | ||
2351 | Also, please notice that not all styles can be changed after the control | |
2352 | creation. | |
2353 | ||
2354 | @return Returns @true if the style was turned on by this function, @false | |
2355 | if it was switched off. | |
2356 | ||
2357 | @see SetWindowStyleFlag(), HasFlag() | |
2358 | */ | |
2359 | bool ToggleWindowStyle(int flag); | |
2360 | ||
d0a67157 | 2361 | //@} |
3c4f71cc | 2362 | |
3c4f71cc | 2363 | |
d0a67157 | 2364 | /** |
47009083 | 2365 | @name Tab order functions |
23324ae1 | 2366 | */ |
d0a67157 | 2367 | //@{ |
23324ae1 FM |
2368 | |
2369 | /** | |
d0a67157 FM |
2370 | Moves this window in the tab navigation order after the specified @e win. |
2371 | This means that when the user presses @c TAB key on that other window, | |
2372 | the focus switches to this window. | |
3c4f71cc | 2373 | |
d0a67157 FM |
2374 | Default tab order is the same as creation order, this function and |
2375 | MoveBeforeInTabOrder() allow to change | |
2376 | it after creating all the windows. | |
3c4f71cc | 2377 | |
d0a67157 FM |
2378 | @param win |
2379 | A sibling of this window which should precede it in tab order, | |
2380 | must not be @NULL | |
23324ae1 | 2381 | */ |
d0a67157 | 2382 | void MoveAfterInTabOrder(wxWindow* win); |
23324ae1 FM |
2383 | |
2384 | /** | |
d0a67157 FM |
2385 | Same as MoveAfterInTabOrder() except that it inserts this window just |
2386 | before @a win instead of putting it right after it. | |
23324ae1 | 2387 | */ |
d0a67157 | 2388 | void MoveBeforeInTabOrder(wxWindow* win); |
23324ae1 FM |
2389 | |
2390 | /** | |
d0a67157 FM |
2391 | Performs a keyboard navigation action starting from this window. |
2392 | This method is equivalent to calling NavigateIn() method on the | |
2393 | parent window. | |
3c4f71cc | 2394 | |
d0a67157 FM |
2395 | @param flags |
2396 | A combination of wxNavigationKeyEvent::IsForward and | |
2397 | wxNavigationKeyEvent::WinChange. | |
3c4f71cc | 2398 | |
d0a67157 FM |
2399 | @return Returns @true if the focus was moved to another window or @false |
2400 | if nothing changed. | |
2401 | ||
2402 | @remarks You may wish to call this from a text control custom keypress | |
2403 | handler to do the default navigation behaviour for the | |
2404 | tab key, since the standard default behaviour for a | |
2405 | multiline text control with the wxTE_PROCESS_TAB style | |
2406 | is to insert a tab and not navigate to the next | |
2407 | control. See also wxNavigationKeyEvent and | |
2408 | HandleAsNavigationKey. | |
23324ae1 | 2409 | */ |
05b0355a | 2410 | bool Navigate(int flags = wxNavigationKeyEvent::IsForward); |
23324ae1 FM |
2411 | |
2412 | /** | |
d0a67157 FM |
2413 | Performs a keyboard navigation action inside this window. |
2414 | See Navigate() for more information. | |
2415 | */ | |
05b0355a | 2416 | bool NavigateIn(int flags = wxNavigationKeyEvent::IsForward); |
cded6aa1 | 2417 | |
d0a67157 | 2418 | //@} |
cded6aa1 | 2419 | |
3c4f71cc | 2420 | |
d0a67157 FM |
2421 | |
2422 | /** | |
47009083 | 2423 | @name Z order functions |
23324ae1 | 2424 | */ |
d0a67157 | 2425 | //@{ |
23324ae1 FM |
2426 | |
2427 | /** | |
d0a67157 | 2428 | Lowers the window to the bottom of the window hierarchy (Z-order). |
3c4f71cc | 2429 | |
d0a67157 FM |
2430 | @remarks |
2431 | This function only works for wxTopLevelWindow-derived classes. | |
3c4f71cc | 2432 | |
d0a67157 | 2433 | @see Raise() |
23324ae1 | 2434 | */ |
d0a67157 | 2435 | virtual void Lower(); |
23324ae1 FM |
2436 | |
2437 | /** | |
d0a67157 | 2438 | Raises the window to the top of the window hierarchy (Z-order). |
3c4f71cc | 2439 | |
4582ed94 VZ |
2440 | Notice that this function only requests the window manager to raise |
2441 | this window to the top of Z-order. Depending on its configuration, the | |
2442 | window manager may raise the window, not do it at all or indicate that | |
2443 | a window requested to be raised in some other way, e.g. by flashing its | |
2444 | icon if it is minimized. | |
2445 | ||
d0a67157 FM |
2446 | @remarks |
2447 | This function only works for wxTopLevelWindow-derived classes. | |
2448 | ||
2449 | @see Lower() | |
23324ae1 | 2450 | */ |
d0a67157 | 2451 | virtual void Raise(); |
23324ae1 | 2452 | |
d0a67157 | 2453 | //@} |
3c4f71cc | 2454 | |
23324ae1 FM |
2455 | |
2456 | /** | |
47009083 | 2457 | @name Window status functions |
d0a67157 FM |
2458 | */ |
2459 | //@{ | |
3c4f71cc | 2460 | |
5af86f4d | 2461 | |
d0a67157 FM |
2462 | /** |
2463 | Equivalent to calling wxWindow::Show(@false). | |
23324ae1 | 2464 | */ |
d0a67157 | 2465 | bool Hide(); |
23324ae1 FM |
2466 | |
2467 | /** | |
d0a67157 FM |
2468 | This function hides a window, like Hide(), but using a special visual |
2469 | effect if possible. | |
5af86f4d | 2470 | |
d0a67157 FM |
2471 | The parameters of this function are the same as for ShowWithEffect(), |
2472 | please see their description there. | |
3c4f71cc | 2473 | |
d0a67157 | 2474 | @since 2.9.0 |
23324ae1 | 2475 | */ |
d0a67157 FM |
2476 | virtual bool HideWithEffect(wxShowEffect effect, |
2477 | unsigned int timeout = 0); | |
23324ae1 | 2478 | /** |
0824e369 | 2479 | Returns @true if the window is enabled, i.e.\ if it accepts user input, |
d0a67157 | 2480 | @false otherwise. |
3c4f71cc | 2481 | |
d0a67157 FM |
2482 | Notice that this method can return @false even if this window itself hadn't |
2483 | been explicitly disabled when one of its parent windows is disabled. | |
2484 | To get the intrinsic status of this window, use IsThisEnabled() | |
3c4f71cc | 2485 | |
d0a67157 | 2486 | @see Enable() |
23324ae1 | 2487 | */ |
d0a67157 | 2488 | bool IsEnabled() const; |
23324ae1 FM |
2489 | |
2490 | /** | |
d0a67157 FM |
2491 | Returns @true if the given point or rectangle area has been exposed since the |
2492 | last repaint. Call this in an paint event handler to optimize redrawing by | |
2493 | only redrawing those areas, which have been exposed. | |
2494 | */ | |
2495 | bool IsExposed(int x, int y) const; | |
3c4f71cc | 2496 | |
d0a67157 FM |
2497 | /** |
2498 | @overload | |
23324ae1 | 2499 | */ |
d0a67157 | 2500 | bool IsExposed(wxPoint& pt) const; |
23324ae1 FM |
2501 | |
2502 | /** | |
d0a67157 FM |
2503 | @overload |
2504 | */ | |
2505 | bool IsExposed(int x, int y, int w, int h) const; | |
3c4f71cc | 2506 | |
d0a67157 FM |
2507 | /** |
2508 | @overload | |
23324ae1 | 2509 | */ |
d0a67157 FM |
2510 | bool IsExposed(wxRect& rect) const; |
2511 | /** | |
2512 | Returns @true if the window is shown, @false if it has been hidden. | |
2513 | ||
2514 | @see IsShownOnScreen() | |
2515 | */ | |
2516 | virtual bool IsShown() const; | |
23324ae1 FM |
2517 | |
2518 | /** | |
0824e369 | 2519 | Returns @true if the window is physically visible on the screen, i.e.\ it |
d0a67157 | 2520 | is shown and all its parents up to the toplevel window are shown as well. |
3c4f71cc | 2521 | |
d0a67157 | 2522 | @see IsShown() |
23324ae1 | 2523 | */ |
d0a67157 | 2524 | virtual bool IsShownOnScreen() const; |
23324ae1 FM |
2525 | |
2526 | /** | |
d0a67157 FM |
2527 | Disables the window. Same as @ref Enable() Enable(@false). |
2528 | ||
2529 | @return Returns @true if the window has been disabled, @false if it had | |
2530 | been already disabled before the call to this function. | |
23324ae1 | 2531 | */ |
d0a67157 | 2532 | bool Disable(); |
23324ae1 FM |
2533 | |
2534 | /** | |
d0a67157 FM |
2535 | Enable or disable the window for user input. Note that when a parent window is |
2536 | disabled, all of its children are disabled as well and they are reenabled again | |
2537 | when the parent is. | |
3c4f71cc | 2538 | |
d0a67157 FM |
2539 | @param enable |
2540 | If @true, enables the window for input. If @false, disables the window. | |
3c4f71cc | 2541 | |
d0a67157 FM |
2542 | @return Returns @true if the window has been enabled or disabled, @false |
2543 | if nothing was done, i.e. if the window had already | |
2544 | been in the specified state. | |
3c4f71cc | 2545 | |
d0a67157 | 2546 | @see IsEnabled(), Disable(), wxRadioBox::Enable |
23324ae1 | 2547 | */ |
d0a67157 | 2548 | virtual bool Enable(bool enable = true); |
23324ae1 FM |
2549 | |
2550 | /** | |
d0a67157 FM |
2551 | Shows or hides the window. You may need to call Raise() |
2552 | for a top level window if you want to bring it to top, although this is not | |
2553 | needed if Show() is called immediately after the frame creation. | |
3c4f71cc | 2554 | |
a183ec70 VZ |
2555 | Notice that the default state of newly created top level windows is hidden |
2556 | (to allow you to create their contents without flicker) unlike for | |
2557 | all the other, not derived from wxTopLevelWindow, windows that | |
2558 | are by default created in the shown state. | |
2559 | ||
d0a67157 FM |
2560 | @param show |
2561 | If @true displays the window. Otherwise, hides it. | |
3c4f71cc | 2562 | |
d0a67157 FM |
2563 | @return @true if the window has been shown or hidden or @false if nothing |
2564 | was done because it already was in the requested state. | |
3c4f71cc | 2565 | |
d0a67157 | 2566 | @see IsShown(), Hide(), wxRadioBox::Show, wxShowEvent. |
23324ae1 | 2567 | */ |
d0a67157 | 2568 | virtual bool Show(bool show = true); |
23324ae1 | 2569 | |
23324ae1 | 2570 | /** |
d0a67157 FM |
2571 | This function shows a window, like Show(), but using a special visual |
2572 | effect if possible. | |
3c4f71cc | 2573 | |
d0a67157 FM |
2574 | @param effect |
2575 | The effect to use. | |
3c4f71cc | 2576 | |
d0a67157 FM |
2577 | @param timeout |
2578 | The @a timeout parameter specifies the time of the animation, in | |
2579 | milliseconds. If the default value of 0 is used, the default | |
2580 | animation time for the current platform is used. | |
3c4f71cc | 2581 | |
ab9a0b84 VZ |
2582 | @note Currently this function is only implemented in wxMSW and wxOSX |
2583 | (for wxTopLevelWindows only in Carbon version and for any kind of | |
2584 | windows in Cocoa) and does the same thing as Show() in the other | |
2585 | ports. | |
d0a67157 FM |
2586 | |
2587 | @since 2.9.0 | |
2588 | ||
2589 | @see HideWithEffect() | |
23324ae1 | 2590 | */ |
d0a67157 FM |
2591 | virtual bool ShowWithEffect(wxShowEffect effect, |
2592 | unsigned int timeout = 0); | |
2593 | ||
2594 | //@} | |
f41d6c8c | 2595 | |
d0a67157 | 2596 | |
d0a67157 | 2597 | /** |
47009083 | 2598 | @name Context-sensitive help functions |
d0a67157 | 2599 | */ |
f41d6c8c | 2600 | //@{ |
d0a67157 | 2601 | |
f41d6c8c | 2602 | /** |
47009083 FM |
2603 | Gets the help text to be used as context-sensitive help for this window. |
2604 | Note that the text is actually stored by the current wxHelpProvider | |
2605 | implementation, and not in the window object itself. | |
d0a67157 | 2606 | |
47009083 | 2607 | @see SetHelpText(), GetHelpTextAtPoint(), wxHelpProvider |
d0a67157 | 2608 | */ |
47009083 | 2609 | wxString GetHelpText() const; |
d0a67157 FM |
2610 | |
2611 | /** | |
47009083 FM |
2612 | Sets the help text to be used as context-sensitive help for this window. |
2613 | Note that the text is actually stored by the current wxHelpProvider | |
2614 | implementation, and not in the window object itself. | |
d0a67157 | 2615 | |
47009083 | 2616 | @see GetHelpText(), wxHelpProvider::AddHelp() |
d0a67157 | 2617 | */ |
47009083 | 2618 | void SetHelpText(const wxString& helpText); |
d0a67157 FM |
2619 | |
2620 | /** | |
47009083 FM |
2621 | Gets the help text to be used as context-sensitive help for this window. |
2622 | This method should be overridden if the help message depends on the position | |
2623 | inside the window, otherwise GetHelpText() can be used. | |
d0a67157 | 2624 | |
47009083 FM |
2625 | @param point |
2626 | Coordinates of the mouse at the moment of help event emission. | |
2627 | @param origin | |
2628 | Help event origin, see also wxHelpEvent::GetOrigin. | |
d0a67157 | 2629 | */ |
47009083 FM |
2630 | virtual wxString GetHelpTextAtPoint(const wxPoint& point, |
2631 | wxHelpEvent::Origin origin) const; | |
d0a67157 FM |
2632 | |
2633 | /** | |
2634 | Get the associated tooltip or @NULL if none. | |
2635 | */ | |
2636 | wxToolTip* GetToolTip() const; | |
2637 | ||
a16a2338 VZ |
2638 | /** |
2639 | Get the text of the associated tooltip or empty string if none. | |
2640 | */ | |
2641 | wxString GetToolTipText() const; | |
2642 | ||
d0a67157 FM |
2643 | /** |
2644 | Attach a tooltip to the window. | |
2645 | ||
2646 | wxToolTip pointer can be @NULL in the overload taking the pointer, | |
ccd4e1bc | 2647 | meaning to unset any existing tooltips; however UnsetToolTip() provides |
d0a67157 FM |
2648 | a more readable alternative to this operation. |
2649 | ||
2650 | Notice that these methods are always available, even if wxWidgets was | |
2651 | compiled with @c wxUSE_TOOLTIPS set to 0, but don't do anything in this | |
2652 | case. | |
2653 | ||
2654 | @see GetToolTip(), wxToolTip | |
2655 | */ | |
86381d42 | 2656 | void SetToolTip(const wxString& tipString); |
d0a67157 FM |
2657 | |
2658 | /** | |
2659 | @overload | |
2660 | */ | |
2661 | void SetToolTip(wxToolTip* tip); | |
2662 | ||
2663 | /** | |
2664 | Unset any existing tooltip. | |
2665 | ||
2666 | @since 2.9.0 | |
2667 | ||
2668 | @see SetToolTip() | |
2669 | */ | |
2670 | void UnsetToolTip(); | |
2671 | ||
2672 | //@} | |
2673 | ||
2674 | ||
2675 | /** | |
2676 | @name Popup/context menu functions | |
2677 | */ | |
2678 | //@{ | |
2679 | ||
2680 | /** | |
2681 | This function shows a popup menu at the given position in this window and | |
2682 | returns the selected id. | |
2683 | ||
2684 | It can be more convenient than the general purpose PopupMenu() function | |
2685 | for simple menus proposing a choice in a list of strings to the user. | |
2686 | ||
2687 | Notice that to avoid unexpected conflicts between the (usually | |
2688 | consecutive range of) ids used by the menu passed to this function and | |
2689 | the existing EVT_UPDATE_UI() handlers, this function temporarily | |
2690 | disables UI updates for the window, so you need to manually disable | |
2691 | (or toggle or ...) any items which should be disabled in the menu | |
2692 | before showing it. | |
2693 | ||
2694 | The parameter @a menu is the menu to show. | |
2695 | The parameter @a pos (or the parameters @a x and @a y) is the | |
2696 | position at which to show the menu in client coordinates. | |
51b729af VZ |
2697 | It is recommended to not explicitly specify coordinates when |
2698 | calling this method in response to mouse click, because some of | |
2699 | the ports (namely, wxGTK) can do a better job of positioning | |
2700 | the menu in that case. | |
d0a67157 FM |
2701 | |
2702 | @return | |
2703 | The selected menu item id or @c wxID_NONE if none selected or an | |
2704 | error occurred. | |
2705 | ||
2706 | @since 2.9.0 | |
2707 | */ | |
51b729af VZ |
2708 | int GetPopupMenuSelectionFromUser(wxMenu& menu, |
2709 | const wxPoint& pos = wxDefaultPosition); | |
d0a67157 FM |
2710 | |
2711 | /** | |
2712 | @overload | |
2713 | */ | |
2714 | int GetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y); | |
2715 | ||
2716 | /** | |
2717 | Pops up the given menu at the specified coordinates, relative to this | |
2718 | window, and returns control when the user has dismissed the menu. | |
2719 | ||
2720 | If a menu item is selected, the corresponding menu event is generated and will be | |
ccd4e1bc | 2721 | processed as usual. If coordinates are not specified, the current mouse |
d0a67157 FM |
2722 | cursor position is used. |
2723 | ||
2724 | @a menu is the menu to pop up. | |
2725 | ||
2726 | The position where the menu will appear can be specified either as a | |
2727 | wxPoint @a pos or by two integers (@a x and @a y). | |
2728 | ||
2729 | @remarks Just before the menu is popped up, wxMenu::UpdateUI is called to | |
2730 | ensure that the menu items are in the correct state. | |
2731 | The menu does not get deleted by the window. | |
2732 | It is recommended to not explicitly specify coordinates when | |
2733 | calling PopupMenu in response to mouse click, because some of | |
2734 | the ports (namely, wxGTK) can do a better job of positioning | |
2735 | the menu in that case. | |
2736 | ||
2737 | @see wxMenu | |
2738 | */ | |
2739 | bool PopupMenu(wxMenu* menu, | |
2740 | const wxPoint& pos = wxDefaultPosition); | |
2741 | ||
2742 | /** | |
2743 | @overload | |
2744 | */ | |
2745 | bool PopupMenu(wxMenu* menu, int x, int y); | |
2746 | ||
2747 | //@} | |
2748 | ||
2749 | ||
d0a67157 | 2750 | /** |
47009083 | 2751 | Validator functions |
d0a67157 FM |
2752 | */ |
2753 | //@{ | |
2754 | ||
2755 | /** | |
47009083 FM |
2756 | Returns a pointer to the current validator for the window, or @NULL if |
2757 | there is none. | |
2758 | */ | |
2759 | virtual wxValidator* GetValidator(); | |
d0a67157 | 2760 | |
47009083 FM |
2761 | /** |
2762 | Deletes the current validator (if any) and sets the window validator, having | |
2763 | called wxValidator::Clone to create a new validator of this type. | |
2764 | */ | |
2765 | virtual void SetValidator(const wxValidator& validator); | |
d0a67157 | 2766 | |
47009083 FM |
2767 | /** |
2768 | Transfers values from child controls to data areas specified by their | |
2769 | validators. Returns @false if a transfer failed. | |
d0a67157 | 2770 | |
47009083 FM |
2771 | If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, |
2772 | the method will also call TransferDataFromWindow() of all child windows. | |
2773 | ||
2774 | @see TransferDataToWindow(), wxValidator, Validate() | |
d0a67157 | 2775 | */ |
47009083 | 2776 | virtual bool TransferDataFromWindow(); |
d0a67157 FM |
2777 | |
2778 | /** | |
47009083 FM |
2779 | Transfers values to child controls from data areas specified by their |
2780 | validators. | |
d0a67157 | 2781 | |
47009083 FM |
2782 | If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, |
2783 | the method will also call TransferDataToWindow() of all child windows. | |
d0a67157 | 2784 | |
47009083 | 2785 | @return Returns @false if a transfer failed. |
d0a67157 | 2786 | |
47009083 | 2787 | @see TransferDataFromWindow(), wxValidator, Validate() |
d0a67157 | 2788 | */ |
47009083 | 2789 | virtual bool TransferDataToWindow(); |
d0a67157 FM |
2790 | |
2791 | /** | |
47009083 FM |
2792 | Validates the current values of the child controls using their validators. |
2793 | If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, | |
2794 | the method will also call Validate() of all child windows. | |
d0a67157 | 2795 | |
47009083 | 2796 | @return Returns @false if any of the validations failed. |
d0a67157 | 2797 | |
47009083 FM |
2798 | @see TransferDataFromWindow(), TransferDataToWindow(), |
2799 | wxValidator | |
d0a67157 | 2800 | */ |
47009083 | 2801 | virtual bool Validate(); |
d0a67157 | 2802 | |
47009083 | 2803 | //@} |
d0a67157 | 2804 | |
d0a67157 FM |
2805 | |
2806 | /** | |
47009083 | 2807 | @name wxWindow properties functions |
d0a67157 | 2808 | */ |
47009083 | 2809 | //@{ |
d0a67157 FM |
2810 | |
2811 | /** | |
2812 | Returns the identifier of the window. | |
2813 | ||
2814 | @remarks Each window has an integer identifier. If the application | |
ccd4e1bc | 2815 | has not provided one (or the default wxID_ANY) a unique |
d0a67157 FM |
2816 | identifier with a negative value will be generated. |
2817 | ||
2818 | @see SetId(), @ref overview_windowids | |
2819 | */ | |
2820 | wxWindowID GetId() const; | |
2821 | ||
2822 | /** | |
2823 | Generic way of getting a label from any window, for | |
2824 | identification purposes. | |
2825 | ||
2826 | @remarks The interpretation of this function differs from class to class. | |
2827 | For frames and dialogs, the value returned is the | |
2828 | title. For buttons or static text controls, it is the | |
2829 | button text. This function can be useful for | |
2830 | meta-programs (such as testing tools or special-needs | |
2831 | access programs) which need to identify windows by name. | |
2832 | */ | |
2833 | virtual wxString GetLabel() const; | |
2834 | ||
51c0d02b FM |
2835 | /** |
2836 | Returns the layout direction for this window, | |
2837 | Note that @c wxLayout_Default is returned if layout direction is not supported. | |
2838 | */ | |
2839 | virtual wxLayoutDirection GetLayoutDirection() const; | |
2840 | ||
0c3140ca RD |
2841 | /** |
2842 | Mirror coordinates for RTL layout if this window uses it and if the | |
2843 | mirroring is not done automatically like Win32. | |
2844 | */ | |
2845 | virtual wxCoord AdjustForLayoutDirection(wxCoord x, | |
2846 | wxCoord width, | |
2847 | wxCoord widthTotal) const; | |
2848 | ||
d0a67157 FM |
2849 | /** |
2850 | Returns the window's name. | |
2851 | ||
2852 | @remarks This name is not guaranteed to be unique; it is up to the | |
2853 | programmer to supply an appropriate name in the window | |
2854 | constructor or via SetName(). | |
2855 | ||
2856 | @see SetName() | |
2857 | */ | |
2858 | virtual wxString GetName() const; | |
2859 | ||
d0a67157 FM |
2860 | /** |
2861 | Returns the value previously passed to SetWindowVariant(). | |
2862 | */ | |
2863 | wxWindowVariant GetWindowVariant() const; | |
2864 | ||
2865 | /** | |
47009083 | 2866 | Sets the identifier of the window. |
d0a67157 | 2867 | |
47009083 FM |
2868 | @remarks Each window has an integer identifier. If the application has |
2869 | not provided one, an identifier will be generated. | |
2870 | Normally, the identifier should be provided on creation | |
2871 | and should not be modified subsequently. | |
d0a67157 | 2872 | |
47009083 | 2873 | @see GetId(), @ref overview_windowids |
d0a67157 | 2874 | */ |
47009083 | 2875 | void SetId(wxWindowID winid); |
d0a67157 FM |
2876 | |
2877 | /** | |
47009083 | 2878 | Sets the window's label. |
d0a67157 | 2879 | |
47009083 FM |
2880 | @param label |
2881 | The window label. | |
d0a67157 | 2882 | |
47009083 | 2883 | @see GetLabel() |
d0a67157 | 2884 | */ |
47009083 | 2885 | virtual void SetLabel(const wxString& label); |
d0a67157 | 2886 | |
51c0d02b FM |
2887 | /** |
2888 | Sets the layout direction for this window. | |
2889 | */ | |
2890 | virtual void SetLayoutDirection(wxLayoutDirection dir); | |
2891 | ||
d0a67157 | 2892 | /** |
47009083 | 2893 | Sets the window's name. |
d0a67157 | 2894 | |
47009083 FM |
2895 | @param name |
2896 | A name to set for the window. | |
d0a67157 | 2897 | |
47009083 | 2898 | @see GetName() |
d0a67157 | 2899 | */ |
47009083 | 2900 | virtual void SetName(const wxString& name); |
d0a67157 FM |
2901 | |
2902 | /** | |
47009083 FM |
2903 | This function can be called under all platforms but only does anything under |
2904 | Mac OS X 10.3+ currently. Under this system, each of the standard control can | |
2905 | exist in several sizes which correspond to the elements of wxWindowVariant enum. | |
d0a67157 | 2906 | |
47009083 FM |
2907 | By default the controls use the normal size, of course, but this function can |
2908 | be used to change this. | |
d0a67157 | 2909 | */ |
47009083 FM |
2910 | void SetWindowVariant(wxWindowVariant variant); |
2911 | ||
d0a67157 | 2912 | /** |
47009083 | 2913 | Gets the accelerator table for this window. See wxAcceleratorTable. |
d0a67157 | 2914 | */ |
47009083 | 2915 | wxAcceleratorTable* GetAcceleratorTable(); |
d0a67157 FM |
2916 | |
2917 | /** | |
47009083 FM |
2918 | Returns the accessible object for this window, if any. |
2919 | See also wxAccessible. | |
d0a67157 | 2920 | */ |
47009083 | 2921 | wxAccessible* GetAccessible(); |
d0a67157 FM |
2922 | |
2923 | /** | |
47009083 | 2924 | Sets the accelerator table for this window. See wxAcceleratorTable. |
d0a67157 | 2925 | */ |
47009083 | 2926 | virtual void SetAcceleratorTable(const wxAcceleratorTable& accel); |
d0a67157 FM |
2927 | |
2928 | /** | |
47009083 FM |
2929 | Sets the accessible for this window. Any existing accessible for this window |
2930 | will be deleted first, if not identical to @e accessible. | |
2931 | See also wxAccessible. | |
d0a67157 | 2932 | */ |
47009083 | 2933 | void SetAccessible(wxAccessible* accessible); |
d0a67157 | 2934 | |
47009083 | 2935 | //@} |
d0a67157 | 2936 | |
47009083 FM |
2937 | |
2938 | /** | |
2939 | @name Window deletion functions | |
d0a67157 | 2940 | */ |
47009083 | 2941 | //@{ |
d0a67157 FM |
2942 | |
2943 | /** | |
47009083 FM |
2944 | This function simply generates a wxCloseEvent whose handler usually tries |
2945 | to close the window. It doesn't close the window itself, however. | |
d0a67157 | 2946 | |
47009083 FM |
2947 | @param force |
2948 | @false if the window's close handler should be able to veto the destruction | |
2949 | of this window, @true if it cannot. | |
d0a67157 | 2950 | |
958eb28b | 2951 | @return @true if the event was handled and not vetoed, @false otherwise. |
bf12aaa5 | 2952 | |
47009083 FM |
2953 | @remarks Close calls the close handler for the window, providing an |
2954 | opportunity for the window to choose whether to destroy | |
2955 | the window. Usually it is only used with the top level | |
2956 | windows (wxFrame and wxDialog classes) as the others | |
2957 | are not supposed to have any special OnClose() logic. | |
2958 | The close handler should check whether the window is being deleted | |
2959 | forcibly, using wxCloseEvent::CanVeto, in which case it should | |
2960 | destroy the window using wxWindow::Destroy. | |
2961 | Note that calling Close does not guarantee that the window will | |
2962 | be destroyed; but it provides a way to simulate a manual close | |
2963 | of a window, which may or may not be implemented by destroying | |
2964 | the window. The default implementation of wxDialog::OnCloseWindow | |
2965 | does not necessarily delete the dialog, since it will simply | |
2966 | simulate an wxID_CANCEL event which is handled by the appropriate | |
2967 | button event handler and may do anything at all. | |
2968 | To guarantee that the window will be destroyed, call | |
2969 | wxWindow::Destroy instead | |
23324ae1 | 2970 | |
47009083 FM |
2971 | @see @ref overview_windowdeletion "Window Deletion Overview", |
2972 | Destroy(), wxCloseEvent | |
2973 | */ | |
2974 | bool Close(bool force = false); | |
3e0e3895 | 2975 | |
47009083 FM |
2976 | /** |
2977 | Destroys the window safely. Use this function instead of the delete operator, | |
2978 | since different window classes can be destroyed differently. Frames and dialogs | |
2979 | are not destroyed immediately when this function is called -- they are added | |
2980 | to a list of windows to be deleted on idle time, when all the window's events | |
2981 | have been processed. This prevents problems with events being sent to | |
2982 | non-existent windows. | |
d0a67157 | 2983 | |
47009083 FM |
2984 | @return @true if the window has either been successfully deleted, or it |
2985 | has been added to the list of windows pending real deletion. | |
3e0e3895 | 2986 | */ |
47009083 | 2987 | virtual bool Destroy(); |
3e0e3895 | 2988 | |
23324ae1 | 2989 | /** |
47009083 | 2990 | Returns true if this window is in process of being destroyed. |
e25cd775 | 2991 | |
ccd4e1bc | 2992 | Top level windows are not deleted immediately but are rather |
47009083 | 2993 | scheduled for later destruction to give them time to process any |
ccd4e1bc | 2994 | pending messages; see Destroy() description. |
47009083 FM |
2995 | |
2996 | This function returns @true if this window, or one of its parent | |
2997 | windows, is scheduled for destruction and can be useful to avoid | |
2998 | manipulating it as it's usually useless to do something with a window | |
2999 | which is on the point of disappearing anyhow. | |
3000 | */ | |
3001 | bool IsBeingDeleted() const; | |
3002 | ||
3003 | //@} | |
3004 | ||
3005 | ||
3006 | ||
3007 | /** | |
3008 | @name Drag and drop functions | |
23324ae1 | 3009 | */ |
47009083 | 3010 | //@{ |
23324ae1 FM |
3011 | |
3012 | /** | |
47009083 FM |
3013 | Returns the associated drop target, which may be @NULL. |
3014 | ||
3015 | @see SetDropTarget(), @ref overview_dnd | |
23324ae1 | 3016 | */ |
47009083 | 3017 | virtual wxDropTarget* GetDropTarget() const; |
23324ae1 FM |
3018 | |
3019 | /** | |
47009083 FM |
3020 | Associates a drop target with this window. |
3021 | If the window already has a drop target, it is deleted. | |
3022 | ||
3023 | @see GetDropTarget(), @ref overview_dnd | |
23324ae1 | 3024 | */ |
47009083 | 3025 | virtual void SetDropTarget(wxDropTarget* target); |
23324ae1 | 3026 | |
23324ae1 | 3027 | /** |
47009083 | 3028 | Enables or disables eligibility for drop file events (OnDropFiles). |
410201d9 | 3029 | |
47009083 FM |
3030 | @param accept |
3031 | If @true, the window is eligible for drop file events. | |
3032 | If @false, the window will not accept drop file events. | |
410201d9 | 3033 | |
47009083 FM |
3034 | @remarks Windows only until version 2.8.9, available on all platforms |
3035 | since 2.8.10. Cannot be used together with SetDropTarget() on | |
3036 | non-Windows platforms. | |
410201d9 | 3037 | |
47009083 | 3038 | @see SetDropTarget() |
23324ae1 | 3039 | */ |
47009083 FM |
3040 | virtual void DragAcceptFiles(bool accept); |
3041 | ||
3042 | //@} | |
3043 | ||
23324ae1 FM |
3044 | |
3045 | /** | |
d13b34d3 | 3046 | @name Constraints, sizers and window layout functions |
23324ae1 | 3047 | */ |
47009083 FM |
3048 | //@{ |
3049 | ||
3050 | /** | |
ccd4e1bc | 3051 | Returns the sizer of which this window is a member, if any, otherwise @NULL. |
47009083 FM |
3052 | */ |
3053 | wxSizer* GetContainingSizer() const; | |
3054 | ||
3055 | /** | |
ccd4e1bc VZ |
3056 | Returns the sizer associated with the window by a previous call to |
3057 | SetSizer(), or @NULL. | |
47009083 FM |
3058 | */ |
3059 | wxSizer* GetSizer() const; | |
3060 | ||
3061 | /** | |
3062 | Sets the window to have the given layout sizer. | |
6528a7f1 | 3063 | |
47009083 FM |
3064 | The window will then own the object, and will take care of its deletion. |
3065 | If an existing layout constraints object is already owned by the | |
6528a7f1 | 3066 | window, it will be deleted if the @a deleteOld parameter is @true. |
47009083 FM |
3067 | |
3068 | Note that this function will also call SetAutoLayout() implicitly with @true | |
6528a7f1 VZ |
3069 | parameter if the @a sizer is non-@NULL and @false otherwise so that the |
3070 | sizer will be effectively used to layout the window children whenever | |
3071 | it is resized. | |
47009083 FM |
3072 | |
3073 | @param sizer | |
3074 | The sizer to set. Pass @NULL to disassociate and conditionally delete | |
3075 | the window's sizer. See below. | |
3076 | @param deleteOld | |
3077 | If @true (the default), this will delete any pre-existing sizer. | |
6528a7f1 VZ |
3078 | Pass @false if you wish to handle deleting the old sizer yourself |
3079 | but remember to do it yourself in this case to avoid memory leaks. | |
47009083 FM |
3080 | |
3081 | @remarks SetSizer enables and disables Layout automatically. | |
3082 | */ | |
3083 | void SetSizer(wxSizer* sizer, bool deleteOld = true); | |
3084 | ||
3085 | /** | |
3086 | This method calls SetSizer() and then wxSizer::SetSizeHints which sets the initial | |
3087 | window size to the size needed to accommodate all sizer elements and sets the | |
3088 | size hints which, if this window is a top level one, prevent the user from | |
d13b34d3 | 3089 | resizing it to be less than this minimal size. |
47009083 FM |
3090 | */ |
3091 | void SetSizerAndFit(wxSizer* sizer, bool deleteOld = true); | |
3092 | ||
3093 | /** | |
3094 | Returns a pointer to the window's layout constraints, or @NULL if there are none. | |
3095 | */ | |
3096 | wxLayoutConstraints* GetConstraints() const; | |
23324ae1 FM |
3097 | |
3098 | /** | |
d0a67157 FM |
3099 | Sets the window to have the given layout constraints. The window |
3100 | will then own the object, and will take care of its deletion. | |
3101 | If an existing layout constraints object is already owned by the | |
3102 | window, it will be deleted. | |
23324ae1 | 3103 | |
d0a67157 FM |
3104 | @param constraints |
3105 | The constraints to set. Pass @NULL to disassociate and delete the window's | |
3106 | constraints. | |
3107 | ||
3108 | @remarks You must call SetAutoLayout() to tell a window to use | |
3109 | the constraints automatically in OnSize; otherwise, you | |
3110 | must override OnSize and call Layout() explicitly. When | |
3111 | setting both a wxLayoutConstraints and a wxSizer, only | |
3112 | the sizer will have effect. | |
23324ae1 | 3113 | */ |
d0a67157 | 3114 | void SetConstraints(wxLayoutConstraints* constraints); |
23324ae1 | 3115 | |
47009083 FM |
3116 | /** |
3117 | Invokes the constraint-based layout algorithm or the sizer-based algorithm | |
3118 | for this window. | |
3119 | ||
3120 | This function does not get called automatically when the window is resized | |
3121 | because lots of windows deriving from wxWindow does not need this functionality. | |
3122 | If you want to have Layout() called automatically, you should derive | |
3123 | from wxPanel (see wxPanel::Layout). | |
3124 | ||
3125 | @see @ref overview_windowsizing | |
3126 | */ | |
3127 | virtual bool Layout(); | |
3128 | ||
3129 | /** | |
3130 | Determines whether the Layout() function will be called automatically | |
6528a7f1 | 3131 | when the window is resized. |
47009083 FM |
3132 | |
3133 | This method is called implicitly by SetSizer() but if you use SetConstraints() | |
3134 | you should call it manually or otherwise the window layout won't be correctly | |
3135 | updated when its size changes. | |
3136 | ||
3137 | @param autoLayout | |
6528a7f1 VZ |
3138 | Set this to @true if you wish the Layout() function to be called |
3139 | automatically when the window is resized. | |
47009083 | 3140 | |
6528a7f1 | 3141 | @see SetSizer(), SetConstraints() |
47009083 FM |
3142 | */ |
3143 | void SetAutoLayout(bool autoLayout); | |
3144 | ||
05b0355a RD |
3145 | bool GetAutoLayout() const; |
3146 | ||
47009083 FM |
3147 | //@} |
3148 | ||
3149 | ||
3150 | ||
3151 | /** | |
3152 | @name Mouse functions | |
3153 | */ | |
3154 | //@{ | |
3155 | ||
3156 | /** | |
3157 | Directs all mouse input to this window. | |
3158 | Call ReleaseMouse() to release the capture. | |
3159 | ||
3160 | Note that wxWidgets maintains the stack of windows having captured the mouse | |
3161 | and when the mouse is released the capture returns to the window which had had | |
3162 | captured it previously and it is only really released if there were no previous | |
3163 | window. In particular, this means that you must release the mouse as many times | |
3164 | as you capture it, unless the window receives the wxMouseCaptureLostEvent event. | |
3165 | ||
3166 | Any application which captures the mouse in the beginning of some operation | |
3167 | must handle wxMouseCaptureLostEvent and cancel this operation when it receives | |
3168 | the event. The event handler must not recapture mouse. | |
3169 | ||
3170 | @see ReleaseMouse(), wxMouseCaptureLostEvent | |
3171 | */ | |
3172 | void CaptureMouse(); | |
3173 | ||
3174 | /** | |
3175 | Returns the caret() associated with the window. | |
3176 | */ | |
3177 | wxCaret* GetCaret() const; | |
3178 | ||
3179 | /** | |
3180 | Return the cursor associated with this window. | |
3181 | ||
3182 | @see SetCursor() | |
3183 | */ | |
3184 | const wxCursor& GetCursor() const; | |
3185 | ||
3186 | /** | |
3187 | Returns @true if this window has the current mouse capture. | |
3188 | ||
3189 | @see CaptureMouse(), ReleaseMouse(), wxMouseCaptureLostEvent, | |
3190 | wxMouseCaptureChangedEvent | |
3191 | */ | |
3192 | virtual bool HasCapture() const; | |
3193 | ||
3194 | /** | |
3195 | Releases mouse input captured with CaptureMouse(). | |
3196 | ||
3197 | @see CaptureMouse(), HasCapture(), ReleaseMouse(), | |
3198 | wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent | |
3199 | */ | |
3200 | void ReleaseMouse(); | |
3201 | ||
3202 | /** | |
3203 | Sets the caret() associated with the window. | |
3204 | */ | |
3205 | void SetCaret(wxCaret* caret); | |
3206 | ||
23324ae1 | 3207 | /** |
d0a67157 FM |
3208 | Sets the window's cursor. Notice that the window cursor also sets it for the |
3209 | children of the window implicitly. | |
e25cd775 | 3210 | |
d0a67157 FM |
3211 | The @a cursor may be @c wxNullCursor in which case the window cursor will |
3212 | be reset back to default. | |
3c4f71cc | 3213 | |
d0a67157 FM |
3214 | @param cursor |
3215 | Specifies the cursor that the window should normally display. | |
3216 | ||
3217 | @see ::wxSetCursor, wxCursor | |
23324ae1 | 3218 | */ |
d0a67157 | 3219 | virtual bool SetCursor(const wxCursor& cursor); |
23324ae1 FM |
3220 | |
3221 | /** | |
47009083 | 3222 | Moves the pointer to the given position on the window. |
3c4f71cc | 3223 | |
5f2b0d85 VZ |
3224 | @note Apple Human Interface Guidelines forbid moving the mouse cursor |
3225 | programmatically so you should avoid using this function in Mac | |
3226 | applications (and probably avoid using it under the other | |
3227 | platforms without good reason as well). | |
47009083 FM |
3228 | |
3229 | @param x | |
3230 | The new x position for the cursor. | |
3231 | @param y | |
3232 | The new y position for the cursor. | |
23324ae1 | 3233 | */ |
47009083 FM |
3234 | virtual void WarpPointer(int x, int y); |
3235 | ||
3236 | //@} | |
3237 | ||
3238 | ||
3239 | ||
23324ae1 FM |
3240 | |
3241 | /** | |
47009083 FM |
3242 | @name Miscellaneous functions |
3243 | */ | |
3244 | //@{ | |
e25cd775 | 3245 | |
05b0355a RD |
3246 | wxHitTest HitTest(wxCoord x, wxCoord y) const; |
3247 | wxHitTest HitTest(const wxPoint& pt) const; | |
3248 | ||
3249 | /** | |
3250 | Get the window border style from the given flags: this is different from | |
3251 | simply doing flags & wxBORDER_MASK because it uses GetDefaultBorder() to | |
3252 | translate wxBORDER_DEFAULT to something reasonable | |
3253 | */ | |
3254 | wxBorder GetBorder(long flags) const; | |
3255 | ||
3256 | /** | |
3257 | Get border for the flags of this window | |
3258 | */ | |
3259 | wxBorder GetBorder() const; | |
3260 | ||
3261 | ||
47009083 FM |
3262 | /** |
3263 | Does the window-specific updating after processing the update event. | |
3264 | This function is called by UpdateWindowUI() in order to check return | |
3265 | values in the wxUpdateUIEvent and act appropriately. | |
3266 | For example, to allow frame and dialog title updating, wxWidgets | |
3267 | implements this function as follows: | |
3268 | ||
3269 | @code | |
3270 | // do the window-specific processing after processing the update event | |
3271 | void wxTopLevelWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event) | |
3272 | { | |
3273 | if ( event.GetSetEnabled() ) | |
3274 | Enable(event.GetEnabled()); | |
3275 | ||
3276 | if ( event.GetSetText() ) | |
3277 | { | |
3278 | if ( event.GetText() != GetTitle() ) | |
3279 | SetTitle(event.GetText()); | |
3280 | } | |
3281 | } | |
3282 | @endcode | |
3283 | */ | |
3284 | virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); | |
3285 | ||
3286 | /** | |
3287 | Returns the platform-specific handle of the physical window. | |
3288 | Cast it to an appropriate handle, such as @b HWND for Windows, | |
bd362275 | 3289 | @b Widget for Motif or @b GtkWidget for GTK. |
1058f652 MB |
3290 | |
3291 | @beginWxPerlOnly | |
3292 | This method will return an integer in wxPerl. | |
3293 | @endWxPerlOnly | |
47009083 FM |
3294 | */ |
3295 | virtual WXWidget GetHandle() const; | |
3296 | ||
3297 | /** | |
3298 | This method should be overridden to return @true if this window has | |
3299 | multiple pages. All standard class with multiple pages such as | |
3300 | wxNotebook, wxListbook and wxTreebook already override it to return @true | |
ccd4e1bc | 3301 | and user-defined classes with similar behaviour should also do so, to |
47009083 FM |
3302 | allow the library to handle such windows appropriately. |
3303 | */ | |
3304 | virtual bool HasMultiplePages() const; | |
3305 | ||
3306 | /** | |
3307 | This function is (or should be, in case of custom controls) called during | |
3308 | window creation to intelligently set up the window visual attributes, that is | |
3309 | the font and the foreground and background colours. | |
3310 | ||
3311 | By "intelligently" the following is meant: by default, all windows use their | |
3312 | own @ref GetClassDefaultAttributes() default attributes. | |
3313 | However if some of the parents attributes are explicitly (that is, using | |
3314 | SetFont() and not wxWindow::SetOwnFont) changed and if the corresponding | |
3315 | attribute hadn't been explicitly set for this window itself, then this | |
3316 | window takes the same value as used by the parent. | |
3317 | In addition, if the window overrides ShouldInheritColours() to return @false, | |
3318 | the colours will not be changed no matter what and only the font might. | |
3319 | ||
3320 | This rather complicated logic is necessary in order to accommodate the | |
3321 | different usage scenarios. The most common one is when all default attributes | |
3322 | are used and in this case, nothing should be inherited as in modern GUIs | |
3323 | different controls use different fonts (and colours) than their siblings so | |
3324 | they can't inherit the same value from the parent. However it was also deemed | |
3325 | desirable to allow to simply change the attributes of all children at once by | |
3326 | just changing the font or colour of their common parent, hence in this case we | |
3327 | do inherit the parents attributes. | |
23324ae1 | 3328 | */ |
47009083 | 3329 | virtual void InheritAttributes(); |
23324ae1 FM |
3330 | |
3331 | /** | |
47009083 FM |
3332 | Sends an @c wxEVT_INIT_DIALOG event, whose handler usually transfers data |
3333 | to the dialog via validators. | |
23324ae1 | 3334 | */ |
47009083 | 3335 | virtual void InitDialog(); |
23324ae1 FM |
3336 | |
3337 | /** | |
0824e369 | 3338 | Returns @true if the window contents is double-buffered by the system, i.e.\ if |
47009083 FM |
3339 | any drawing done on the window is really done on a temporary backing surface |
3340 | and transferred to the screen all at once later. | |
3c4f71cc | 3341 | |
47009083 | 3342 | @see wxBufferedDC |
d0a67157 | 3343 | */ |
47009083 | 3344 | virtual bool IsDoubleBuffered() const; |
3c4f71cc | 3345 | |
b83b7724 RD |
3346 | /** |
3347 | Turn on or off double buffering of the window if the system supports it. | |
3348 | */ | |
05b0355a RD |
3349 | void SetDoubleBuffered(bool on); |
3350 | ||
d0a67157 | 3351 | /** |
47009083 | 3352 | Returns @true if the window is retained, @false otherwise. |
3c4f71cc | 3353 | |
47009083 | 3354 | @remarks Retained windows are only available on X platforms. |
23324ae1 | 3355 | */ |
47009083 | 3356 | virtual bool IsRetained() const; |
23324ae1 FM |
3357 | |
3358 | /** | |
47009083 | 3359 | Returns @true if this window is intrinsically enabled, @false otherwise, |
0824e369 | 3360 | i.e.\ if @ref Enable() Enable(@false) had been called. This method is |
47009083 FM |
3361 | mostly used for wxWidgets itself, user code should normally use |
3362 | IsEnabled() instead. | |
d0a67157 | 3363 | */ |
47009083 | 3364 | bool IsThisEnabled() const; |
a7c01bb1 | 3365 | |
d0a67157 | 3366 | /** |
47009083 FM |
3367 | Returns @true if the given window is a top-level one. Currently all frames and |
3368 | dialogs are considered to be top-level windows (even if they have a parent | |
3369 | window). | |
23324ae1 | 3370 | */ |
47009083 | 3371 | virtual bool IsTopLevel() const; |
23324ae1 | 3372 | |
05b0355a | 3373 | |
23324ae1 | 3374 | /** |
47009083 FM |
3375 | This virtual function is normally only used internally, but |
3376 | sometimes an application may need it to implement functionality | |
3377 | that should not be disabled by an application defining an OnIdle | |
3378 | handler in a derived class. | |
3c4f71cc | 3379 | |
47009083 FM |
3380 | This function may be used to do delayed painting, for example, |
3381 | and most implementations call UpdateWindowUI() | |
3382 | in order to send update events to the window in idle time. | |
23324ae1 | 3383 | */ |
47009083 | 3384 | virtual void OnInternalIdle(); |
23324ae1 | 3385 | |
0c3140ca RD |
3386 | /** |
3387 | Send idle event to window and all subwindows. Returns true if more idle | |
3388 | time is requested. | |
3389 | */ | |
3390 | virtual bool SendIdleEvents(wxIdleEvent& event); | |
3391 | ||
23324ae1 | 3392 | /** |
47009083 FM |
3393 | Registers a system wide hotkey. Every time the user presses the hotkey |
3394 | registered here, this window will receive a hotkey event. | |
e25cd775 | 3395 | |
47009083 FM |
3396 | It will receive the event even if the application is in the background |
3397 | and does not have the input focus because the user is working with some | |
3398 | other application. | |
3c4f71cc | 3399 | |
47009083 FM |
3400 | @param hotkeyId |
3401 | Numeric identifier of the hotkey. For applications this must be between 0 | |
3402 | and 0xBFFF. If this function is called from a shared DLL, it must be a | |
3403 | system wide unique identifier between 0xC000 and 0xFFFF. | |
3404 | This is a MSW specific detail. | |
3405 | @param modifiers | |
3406 | A bitwise combination of wxMOD_SHIFT, wxMOD_CONTROL, wxMOD_ALT | |
3407 | or wxMOD_WIN specifying the modifier keys that have to be pressed along | |
3408 | with the key. | |
3409 | @param virtualKeyCode | |
3410 | The virtual key code of the hotkey. | |
3c4f71cc | 3411 | |
47009083 FM |
3412 | @return @true if the hotkey was registered successfully. @false if some |
3413 | other application already registered a hotkey with this | |
3414 | modifier/virtualKeyCode combination. | |
3415 | ||
3416 | @remarks Use EVT_HOTKEY(hotkeyId, fnc) in the event table to capture the | |
3417 | event. This function is currently only implemented | |
3418 | under Windows. It is used in the Windows CE port for | |
3419 | detecting hardware button presses. | |
3420 | ||
3421 | @see UnregisterHotKey() | |
23324ae1 | 3422 | */ |
47009083 FM |
3423 | virtual bool RegisterHotKey(int hotkeyId, int modifiers, |
3424 | int virtualKeyCode); | |
23324ae1 FM |
3425 | |
3426 | /** | |
3427 | Unregisters a system wide hotkey. | |
3c4f71cc | 3428 | |
7c913512 | 3429 | @param hotkeyId |
4cc4bfaf | 3430 | Numeric identifier of the hotkey. Must be the same id that was passed to |
e25cd775 | 3431 | RegisterHotKey(). |
3c4f71cc | 3432 | |
d29a9a8a | 3433 | @return @true if the hotkey was unregistered successfully, @false if the |
e25cd775 | 3434 | id was invalid. |
3c4f71cc | 3435 | |
23324ae1 | 3436 | @remarks This function is currently only implemented under MSW. |
3c4f71cc | 3437 | |
4cc4bfaf | 3438 | @see RegisterHotKey() |
23324ae1 | 3439 | */ |
da1ed74c | 3440 | virtual bool UnregisterHotKey(int hotkeyId); |
23324ae1 | 3441 | |
23324ae1 | 3442 | /** |
e25cd775 FM |
3443 | This function sends one or more wxUpdateUIEvent to the window. |
3444 | The particular implementation depends on the window; for example a | |
3445 | wxToolBar will send an update UI event for each toolbar button, | |
23324ae1 | 3446 | and a wxFrame will send an update UI event for each menubar menu item. |
e25cd775 | 3447 | |
23324ae1 FM |
3448 | You can call this function from your application to ensure that your |
3449 | UI is up-to-date at this point (as far as your wxUpdateUIEvent handlers | |
3450 | are concerned). This may be necessary if you have called | |
e25cd775 FM |
3451 | wxUpdateUIEvent::SetMode() or wxUpdateUIEvent::SetUpdateInterval() to limit |
3452 | the overhead that wxWidgets incurs by sending update UI events in idle time. | |
99d82720 | 3453 | @a flags should be a bitlist of one or more of the ::wxUpdateUI enumeration. |
3c4f71cc | 3454 | |
23324ae1 FM |
3455 | If you are calling this function from an OnInternalIdle or OnIdle |
3456 | function, make sure you pass the wxUPDATE_UI_FROMIDLE flag, since | |
3457 | this tells the window to only update the UI elements that need | |
3458 | to be updated in idle time. Some windows update their elements | |
3459 | only when necessary, for example when a menu is about to be shown. | |
3460 | The following is an example of how to call UpdateWindowUI from | |
3461 | an idle function. | |
3c4f71cc | 3462 | |
e25cd775 FM |
3463 | @code |
3464 | void MyWindow::OnInternalIdle() | |
3465 | { | |
3466 | if (wxUpdateUIEvent::CanUpdate(this)) | |
3467 | UpdateWindowUI(wxUPDATE_UI_FROMIDLE); | |
3468 | } | |
3469 | @endcode | |
3470 | ||
4cc4bfaf | 3471 | @see wxUpdateUIEvent, DoUpdateWindowUI(), OnInternalIdle() |
23324ae1 FM |
3472 | */ |
3473 | virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE); | |
3474 | ||
47009083 FM |
3475 | //@} |
3476 | ||
3477 | ||
3478 | // NOTE: static functions must have their own group or Doxygen will screw | |
3479 | // up the ordering of the member groups | |
3480 | ||
23324ae1 | 3481 | /** |
47009083 FM |
3482 | @name Miscellaneous static functions |
3483 | */ | |
3484 | //@{ | |
3c4f71cc | 3485 | |
47009083 FM |
3486 | /** |
3487 | Returns the default font and colours which are used by the control. | |
3c4f71cc | 3488 | |
47009083 FM |
3489 | This is useful if you want to use the same font or colour in your own control |
3490 | as in a standard control -- which is a much better idea than hard coding specific | |
3491 | colours or fonts which might look completely out of place on the users | |
3492 | system, especially if it uses themes. | |
3493 | ||
3494 | The @a variant parameter is only relevant under Mac currently and is | |
3495 | ignore under other platforms. Under Mac, it will change the size of the | |
3496 | returned font. See SetWindowVariant() for more about this. | |
3497 | ||
3498 | This static method is "overridden" in many derived classes and so calling, | |
3499 | for example, wxButton::GetClassDefaultAttributes() will typically | |
3500 | return the values appropriate for a button which will be normally different | |
3501 | from those returned by, say, wxListCtrl::GetClassDefaultAttributes(). | |
3502 | ||
3503 | The @c wxVisualAttributes structure has at least the fields | |
3504 | @c font, @c colFg and @c colBg. All of them may be invalid | |
3505 | if it was not possible to determine the default control appearance or, | |
3506 | especially for the background colour, if the field doesn't make sense as is | |
3507 | the case for @c colBg for the controls with themed background. | |
3508 | ||
3509 | @see InheritAttributes() | |
23324ae1 | 3510 | */ |
47009083 | 3511 | static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); |
23324ae1 FM |
3512 | |
3513 | /** | |
47009083 | 3514 | Finds the window or control which currently has the keyboard focus. |
e25cd775 | 3515 | |
47009083 FM |
3516 | @remarks Note that this is a static function, so it can be called without |
3517 | needing a wxWindow pointer. | |
3c4f71cc | 3518 | |
47009083 | 3519 | @see SetFocus(), HasFocus() |
23324ae1 | 3520 | */ |
47009083 FM |
3521 | static wxWindow* FindFocus(); |
3522 | ||
3523 | /** | |
3524 | Find the first window with the given @e id. | |
3525 | ||
3526 | If @a parent is @NULL, the search will start from all top-level frames | |
3527 | and dialog boxes; if non-@NULL, the search will be limited to the given | |
3528 | window hierarchy. | |
3529 | The search is recursive in both cases. | |
3530 | ||
3531 | @see FindWindow() | |
d9c83ba8 VZ |
3532 | |
3533 | @return Window with the given @a id or @NULL if not found. | |
47009083 FM |
3534 | */ |
3535 | static wxWindow* FindWindowById(long id, const wxWindow* parent = 0); | |
3536 | ||
3537 | /** | |
3538 | Find a window by its label. | |
3539 | ||
3540 | Depending on the type of window, the label may be a window title | |
3541 | or panel item label. If @a parent is @NULL, the search will start from all | |
3542 | top-level frames and dialog boxes; if non-@NULL, the search will be | |
3543 | limited to the given window hierarchy. | |
3544 | The search is recursive in both cases. | |
3545 | ||
3546 | @see FindWindow() | |
d9c83ba8 VZ |
3547 | |
3548 | @return Window with the given @a label or @NULL if not found. | |
47009083 FM |
3549 | */ |
3550 | static wxWindow* FindWindowByLabel(const wxString& label, | |
3551 | const wxWindow* parent = 0); | |
3552 | ||
3553 | /** | |
3554 | Find a window by its name (as given in a window constructor or Create() | |
3555 | function call). | |
3556 | ||
3557 | If @a parent is @NULL, the search will start from all top-level frames | |
3558 | and dialog boxes; if non-@NULL, the search will be limited to the given | |
3559 | window hierarchy. | |
3560 | ||
3561 | The search is recursive in both cases. If no window with such name is found, | |
3562 | FindWindowByLabel() is called. | |
3563 | ||
3564 | @see FindWindow() | |
d9c83ba8 VZ |
3565 | |
3566 | @return Window with the given @a name or @NULL if not found. | |
47009083 FM |
3567 | */ |
3568 | static wxWindow* FindWindowByName(const wxString& name, | |
3569 | const wxWindow* parent = 0); | |
3570 | ||
3571 | /** | |
3572 | Returns the currently captured window. | |
3573 | ||
3574 | @see HasCapture(), CaptureMouse(), ReleaseMouse(), | |
3575 | wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent | |
3576 | */ | |
3577 | static wxWindow* GetCapture(); | |
3578 | ||
3579 | /** | |
3580 | Create a new ID or range of IDs that are not currently in use. | |
3581 | The IDs will be reserved until assigned to a wxWindow ID | |
3582 | or unreserved with UnreserveControlId(). | |
3583 | ||
3584 | See @ref overview_windowids for more information. | |
3585 | ||
3586 | @param count | |
3587 | The number of sequential IDs to reserve. | |
3588 | ||
ccd4e1bc VZ |
3589 | @return Returns the ID or the first ID of the range (i.e. the most negative), |
3590 | or wxID_NONE if the specified number of identifiers couldn't be allocated. | |
47009083 FM |
3591 | |
3592 | @see UnreserveControlId(), wxIdManager, | |
3593 | @ref overview_windowids | |
3594 | */ | |
3595 | static wxWindowID NewControlId(int count = 1); | |
3596 | ||
3597 | /** | |
3598 | Unreserve an ID or range of IDs that was reserved by NewControlId(). | |
3599 | See @ref overview_windowids for more information. | |
3600 | ||
3601 | @param id | |
3602 | The starting ID of the range of IDs to unreserve. | |
3603 | @param count | |
3604 | The number of sequential IDs to unreserve. | |
3605 | ||
3606 | @see NewControlId(), wxIdManager, @ref overview_windowids | |
3607 | */ | |
3608 | static void UnreserveControlId(wxWindowID id, int count = 1); | |
95b4a59e | 3609 | |
d0a67157 | 3610 | //@} |
95b4a59e | 3611 | |
47009083 FM |
3612 | |
3613 | ||
95b4a59e FM |
3614 | protected: |
3615 | ||
05b0355a RD |
3616 | /** |
3617 | Centres the window. | |
3618 | ||
3619 | @param direction | |
3620 | Specifies the direction for the centring. May be wxHORIZONTAL, | |
3621 | wxVERTICAL or wxBOTH. It may also include the wxCENTRE_ON_SCREEN | |
3622 | flag. | |
3623 | ||
3624 | @remarks This function is not meant to be called directly by user code, | |
3625 | but via Centre, Center, CentreOnParent, or CenterOnParent. | |
4c51a665 | 3626 | This function can be overridden to fine-tune centring behaviour. |
05b0355a RD |
3627 | */ |
3628 | virtual void DoCentre(int direction); | |
3629 | ||
95b4a59e | 3630 | /** |
386279c3 VZ |
3631 | Implementation of GetBestSize() that can be overridden. |
3632 | ||
3633 | Notice that it is usually more convenient to override | |
3634 | DoGetBestClientSize() rather than this method itself as you need to | |
3635 | explicitly account for the window borders size if you do the latter. | |
95b4a59e FM |
3636 | |
3637 | The default implementation of this function is designed for use in container | |
3638 | windows, such as wxPanel, and works something like this: | |
3639 | -# If the window has a sizer then it is used to calculate the best size. | |
3640 | -# Otherwise if the window has layout constraints then those are used to | |
3641 | calculate the best size. | |
3642 | -# Otherwise if the window has children then the best size is set to be large | |
3643 | enough to show all the children. | |
3644 | -# Otherwise if there are no children then the window's minimal size will be | |
3645 | used as its best size. | |
3646 | -# Otherwise if there is no minimal size set, then the current size is used | |
3647 | for the best size. | |
3648 | ||
3649 | @see @ref overview_windowsizing | |
3650 | */ | |
3651 | virtual wxSize DoGetBestSize() const; | |
3652 | ||
386279c3 VZ |
3653 | /** |
3654 | Override this method to return the best size for a custom control. | |
3655 | ||
3656 | A typical implementation of this method should compute the minimal size | |
3657 | needed to fully display the control contents taking into account the | |
3658 | current font size. | |
3659 | ||
3660 | The default implementation simply returns ::wxDefaultSize and | |
3661 | GetBestSize() returns an arbitrary hardcoded size for the window, so | |
3662 | you must override it when implementing a custom window class. | |
3663 | ||
705c834b VZ |
3664 | Notice that the best size returned by this function is cached |
3665 | internally, so if anything that results in the best size changing (e.g. | |
3666 | change to the control contents) happens, you need to call | |
3667 | InvalidateBestSize() to notify wxWidgets about it. | |
3668 | ||
386279c3 VZ |
3669 | @see @ref overview_windowsizing |
3670 | ||
3671 | @since 2.9.0 | |
3672 | */ | |
3673 | virtual wxSize DoGetBestClientSize() const; | |
3674 | ||
d1199839 VZ |
3675 | /** |
3676 | Override this method to implement height-for-width best size | |
3677 | calculation. | |
3678 | ||
3679 | Return the height needed to fully display the control contents if its | |
3680 | width is fixed to the given value. Custom classes implementing | |
3681 | wrapping should override this method and return the height | |
3682 | corresponding to the number of lines needed to lay out the control | |
3683 | contents at this width. | |
3684 | ||
3685 | Currently this method is not used by wxWidgets yet, however it is | |
3686 | planned that it will be used by the new sizer classes implementing | |
3687 | height-for-width layout strategy in the future. | |
3688 | ||
3689 | Notice that implementing this method or even implementing both it and | |
3690 | DoGetBestClientWidth() doesn't replace overriding DoGetBestClientSize(), | |
3691 | i.e. you still need to implement the latter as well in order to provide | |
3692 | the best size when neither width nor height are constrained. | |
3693 | ||
3694 | By default returns ::wxDefaultCoord meaning that the vertical component | |
3695 | of DoGetBestClientSize() return value should be used. | |
3696 | ||
3697 | @since 2.9.4 | |
3698 | */ | |
3699 | virtual int DoGetBestClientHeight(int width) const; | |
3700 | ||
3701 | /** | |
3702 | Override this method to implement width-for-height best size | |
3703 | calculation. | |
3704 | ||
3705 | This method is exactly the same as DoGetBestClientHeight() except that | |
3706 | it determines the width assuming the height is fixed instead of vice | |
3707 | versa. | |
3708 | ||
3709 | @since 2.9.4 | |
3710 | */ | |
3711 | virtual int DoGetBestClientWidth(int height) const; | |
95b4a59e FM |
3712 | |
3713 | /** | |
0824e369 | 3714 | Sets the initial window size if none is given (i.e.\ at least one of the |
95b4a59e | 3715 | components of the size passed to ctor/Create() is wxDefaultCoord). |
386279c3 | 3716 | @deprecated Use SetInitialSize() instead. |
95b4a59e FM |
3717 | */ |
3718 | virtual void SetInitialBestSize(const wxSize& size); | |
a79a6671 VZ |
3719 | |
3720 | /** | |
3721 | Generate wxWindowDestroyEvent for this window. | |
3722 | ||
3723 | This is called by the window itself when it is being destroyed and | |
3724 | usually there is no need to call it but see wxWindowDestroyEvent for | |
3725 | explanations of when you might want to do it. | |
3726 | */ | |
3727 | void SendDestroyEvent(); | |
004867db | 3728 | |
004867db | 3729 | /** |
4fde860e FM |
3730 | This function is public in wxEvtHandler but protected in wxWindow |
3731 | because for wxWindows you should always call ProcessEvent() on the | |
3b7fa206 VZ |
3732 | pointer returned by GetEventHandler() and not on the wxWindow object |
3733 | itself. | |
3734 | ||
3735 | For convenience, a ProcessWindowEvent() method is provided as a synonym | |
ccd4e1bc | 3736 | for @code GetEventHandler()->ProcessEvent() @endcode |
004867db FM |
3737 | |
3738 | Note that it's still possible to call these functions directly on the | |
3b7fa206 VZ |
3739 | wxWindow object (e.g. casting it to wxEvtHandler) but doing that will |
3740 | create subtle bugs when windows with event handlers pushed on them are | |
3741 | involved. | |
4fde860e FM |
3742 | |
3743 | This holds also for all other wxEvtHandler functions. | |
004867db FM |
3744 | */ |
3745 | virtual bool ProcessEvent(wxEvent& event); | |
4fde860e FM |
3746 | |
3747 | //@{ | |
3748 | /** | |
3749 | See ProcessEvent() for more info about why you shouldn't use this function | |
3750 | and the reason for making this function protected in wxWindow. | |
3751 | */ | |
004867db FM |
3752 | bool SafelyProcessEvent(wxEvent& event); |
3753 | virtual void QueueEvent(wxEvent *event); | |
3754 | virtual void AddPendingEvent(const wxEvent& event); | |
3755 | void ProcessPendingEvents(); | |
3756 | bool ProcessThreadEvent(const wxEvent& event); | |
3757 | //@} | |
23324ae1 FM |
3758 | }; |
3759 | ||
3760 | ||
e54c96f1 | 3761 | |
23324ae1 FM |
3762 | // ============================================================================ |
3763 | // Global functions/macros | |
3764 | // ============================================================================ | |
3765 | ||
b21126db | 3766 | /** @addtogroup group_funcmacro_misc */ |
7fa7088e | 3767 | //@{ |
23324ae1 FM |
3768 | |
3769 | /** | |
3770 | Find the deepest window at the mouse pointer position, returning the window | |
3771 | and current pointer position in screen coordinates. | |
7fa7088e BP |
3772 | |
3773 | @header{wx/window.h} | |
23324ae1 | 3774 | */ |
4cc4bfaf | 3775 | wxWindow* wxFindWindowAtPointer(wxPoint& pt); |
23324ae1 FM |
3776 | |
3777 | /** | |
7fa7088e BP |
3778 | Gets the currently active window (implemented for MSW and GTK only |
3779 | currently, always returns @NULL in the other ports). | |
3780 | ||
3781 | @header{wx/window.h} | |
23324ae1 | 3782 | */ |
4cc4bfaf | 3783 | wxWindow* wxGetActiveWindow(); |
23324ae1 FM |
3784 | |
3785 | /** | |
7fa7088e BP |
3786 | Returns the first top level parent of the given window, or in other words, |
3787 | the frame or dialog containing it, or @NULL. | |
3788 | ||
3789 | @header{wx/window.h} | |
23324ae1 | 3790 | */ |
7fa7088e BP |
3791 | wxWindow* wxGetTopLevelParent(wxWindow* window); |
3792 | ||
3793 | //@} | |
23324ae1 | 3794 |