]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/toplevel.h
Fixed typo in documentation string
[wxWidgets.git] / interface / wx / toplevel.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: toplevel.h
e54c96f1 3// Purpose: interface of wxTopLevelWindow
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
f992f2ae
BP
9/**
10 Styles used with wxTopLevelWindow::RequestUserAttention().
11*/
12enum
13{
14 wxUSER_ATTENTION_INFO = 1, ///< Requests user attention,
15 wxUSER_ATTENTION_ERROR = 2 ///< Results in a more drastic action.
16};
17
18/**
19 Styles used with wxTopLevelWindow::ShowFullScreen().
20*/
21enum
22{
23 wxFULLSCREEN_NOMENUBAR = 0x0001, ///< Don't display the menu bar.
24 wxFULLSCREEN_NOTOOLBAR = 0x0002, ///< Don't display toolbar bars.
25 wxFULLSCREEN_NOSTATUSBAR = 0x0004, ///< Don't display the status bar.
26 wxFULLSCREEN_NOBORDER = 0x0008, ///< Don't display any border.
27 wxFULLSCREEN_NOCAPTION = 0x0010, ///< Don't display a caption.
28
29 /**
30 Combination of all above, will display the least possible.
31 */
32 wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR |
33 wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER |
34 wxFULLSCREEN_NOCAPTION
35};
36
23324ae1
FM
37/**
38 @class wxTopLevelWindow
7c913512 39
f992f2ae
BP
40 wxTopLevelWindow is a common base class for wxDialog and wxFrame. It is an
41 abstract base class meaning that you never work with objects of this class
42 directly, but all of its methods are also applicable for the two classes
43 above.
7c913512 44
afc31d8a
FM
45 Note that the instances of wxTopLevelWindow are managed by wxWidgets in the
46 internal top level window list.
47
3051a44a
FM
48 @beginEventEmissionTable
49 @event{EVT_ACTIVATE(id, func)}
50 Process a @c wxEVT_MAXIMIZE event. See wxMaximizeEvent.
51 @event{EVT_MOVE(func)}
52 Process a @c wxEVT_MOVE event, which is generated when a window is moved.
53 See wxMoveEvent.
54 @event{EVT_MOVE_START(func)}
55 Process a @c wxEVT_MOVE_START event, which is generated when the user starts
56 to move or size a window. wxMSW only.
57 See wxMoveEvent.
58 @event{EVT_MOVE_END(func)}
59 Process a @c wxEVT_MOVE_END event, which is generated when the user stops
60 moving or sizing a window. wxMSW only.
61 See wxMoveEvent.
62 @endEventTable
63
23324ae1
FM
64 @library{wxcore}
65 @category{managedwnd}
7c913512 66
f992f2ae 67 @see wxDialog, wxFrame
23324ae1
FM
68*/
69class wxTopLevelWindow : public wxWindow
70{
71public:
2e4f32d7
FM
72 /**
73 Default ctor.
74 */
75 wxTopLevelWindow();
76
77 /**
78 Constructor creating the top level window.
79 */
80 wxTopLevelWindow(wxWindow *parent,
81 wxWindowID winid,
82 const wxString& title,
83 const wxPoint& pos = wxDefaultPosition,
84 const wxSize& size = wxDefaultSize,
85 long style = wxDEFAULT_FRAME_STYLE,
86 const wxString& name = wxFrameNameStr);
87
88 /**
89 Destructor. Remember that wxTopLevelWindows do not get immediately
90 destroyed when the user (or the app) closes them; they have a
91 @b delayed destruction.
92
93 See @ref overview_windowdeletion for more info.
94 */
95 virtual ~wxTopLevelWindow();
96
97 /**
98 Creates the top level window.
99 */
100 bool Create(wxWindow *parent,
101 wxWindowID id,
102 const wxString& title,
103 const wxPoint& pos = wxDefaultPosition,
104 const wxSize& size = wxDefaultSize,
105 long style = wxDEFAULT_FRAME_STYLE,
106 const wxString& name = wxFrameNameStr);
107
23324ae1
FM
108 /**
109 Returns @true if the platform supports making the window translucent.
3c4f71cc 110
4cc4bfaf 111 @see SetTransparent()
23324ae1
FM
112 */
113 virtual bool CanSetTransparent();
114
115 /**
116 A synonym for CentreOnScreen().
117 */
118 void CenterOnScreen(int direction);
119
120 /**
121 Centres the window on screen.
3c4f71cc 122
7c913512 123 @param direction
f992f2ae
BP
124 Specifies the direction for the centering. May be @c wxHORIZONTAL,
125 @c wxVERTICAL or @c wxBOTH.
3c4f71cc 126
f992f2ae 127 @see wxWindow::CentreOnParent()
23324ae1
FM
128 */
129 void CentreOnScreen(int direction = wxBOTH);
130
131 /**
f992f2ae
BP
132 Enables or disables the Close button (most often in the right upper
133 corner of a dialog) and the Close entry of the system menu (most often
134 in the left upper corner of the dialog).
135
136 Currently only implemented for wxMSW and wxGTK.
137
138 Returns @true if operation was successful. This may be wrong on X11
139 (including GTK+) where the window manager may not support this operation
140 and there is no way to find out.
23324ae1 141 */
0004982c 142 virtual bool EnableCloseButton(bool enable = true);
23324ae1
FM
143
144 /**
f992f2ae
BP
145 Returns a pointer to the button which is the default for this window, or
146 @c @NULL. The default button is the one activated by pressing the Enter
147 key.
23324ae1 148 */
328f5751 149 wxWindow* GetDefaultItem() const;
23324ae1
FM
150
151 /**
f992f2ae
BP
152 Returns the standard icon of the window. The icon will be invalid if it
153 hadn't been previously set by SetIcon().
3c4f71cc 154
4cc4bfaf 155 @see GetIcons()
23324ae1 156 */
cfbe5614 157 wxIcon GetIcon() const;
23324ae1
FM
158
159 /**
f992f2ae
BP
160 Returns all icons associated with the window, there will be none of them
161 if neither SetIcon() nor SetIcons() had been called before. Use
162 GetIcon() to get the main icon of the window.
3c4f71cc 163
4cc4bfaf 164 @see wxIconBundle
23324ae1 165 */
cfbe5614 166 const wxIconBundle& GetIcons() const;
23324ae1
FM
167
168 /**
169 Gets a string containing the window title.
3c4f71cc 170
4cc4bfaf 171 @see SetTitle()
23324ae1 172 */
0004982c 173 virtual wxString GetTitle() const;
23324ae1
FM
174
175 /**
f992f2ae
BP
176 Unique to the wxWinCE port. Responds to showing/hiding SIP (soft input
177 panel) area and resize window accordingly. Override this if you want to
178 avoid resizing or do additional operations.
23324ae1
FM
179 */
180 virtual bool HandleSettingChange(WXWPARAM wParam,
181 WXLPARAM lParam);
182
183 /**
184 Iconizes or restores the window.
3c4f71cc 185
7c913512 186 @param iconize
4cc4bfaf 187 If @true, iconizes the window; if @false, shows and restores it.
3c4f71cc 188
d317fdeb 189 @see IsIconized(), Maximize(), wxIconizeEvent.
23324ae1 190 */
cfbe5614 191 virtual void Iconize(bool iconize = true);
23324ae1
FM
192
193 /**
194 Returns @true if this window is currently active, i.e. if the user is
f992f2ae 195 currently working with it.
23324ae1 196 */
adaaa686 197 virtual bool IsActive();
23324ae1
FM
198
199 /**
f992f2ae
BP
200 Returns @true if this window is expected to be always maximized, either
201 due to platform policy or due to local policy regarding particular
202 class.
23324ae1 203 */
328f5751 204 virtual bool IsAlwaysMaximized() const;
23324ae1
FM
205
206 /**
207 Returns @true if the window is in fullscreen mode.
3c4f71cc 208
4cc4bfaf 209 @see ShowFullScreen()
23324ae1 210 */
0004982c 211 virtual bool IsFullScreen() const;
23324ae1
FM
212
213 /**
214 Returns @true if the window is iconized.
215 */
0004982c 216 virtual bool IsIconized() const;
23324ae1
FM
217
218 /**
219 Returns @true if the window is maximized.
220 */
0004982c 221 virtual bool IsMaximized() const;
23324ae1
FM
222
223 /**
f992f2ae
BP
224 This method is specific to wxUniversal port.
225
226 Returns @true if this window is using native decorations, @false if we
227 draw them ourselves.
3c4f71cc 228
4cc4bfaf
FM
229 @see UseNativeDecorations(),
230 UseNativeDecorationsByDefault()
23324ae1 231 */
328f5751 232 bool IsUsingNativeDecorations() const;
23324ae1 233
dcc5fcbf
FM
234 /**
235 See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
236 called automatically when the window is resized.
237 */
238 virtual bool Layout();
239
23324ae1
FM
240 /**
241 Maximizes or restores the window.
3c4f71cc 242
7c913512 243 @param maximize
4cc4bfaf 244 If @true, maximizes the window, otherwise it restores it.
3c4f71cc 245
4cc4bfaf 246 @see Iconize()
23324ae1 247 */
cfbe5614 248 virtual void Maximize(bool maximize = true);
23324ae1
FM
249
250 /**
f992f2ae
BP
251 Use a system-dependent way to attract users attention to the window when
252 it is in background.
253
254 @a flags may have the value of either @c ::wxUSER_ATTENTION_INFO
255 (default) or @c ::wxUSER_ATTENTION_ERROR which results in a more drastic
23324ae1 256 action. When in doubt, use the default value.
f992f2ae
BP
257
258
259 @note This function should normally be only used when the application
260 is not already in foreground.
261
262 This function is currently implemented for Win32 where it flashes
263 the window icon in the taskbar, and for wxGTK with task bars
264 supporting it.
265
23324ae1 266 */
adaaa686 267 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
23324ae1
FM
268
269 /**
4cc4bfaf 270 Changes the default item for the panel, usually @a win is a button.
3c4f71cc 271
4cc4bfaf 272 @see GetDefaultItem()
23324ae1 273 */
cfbe5614 274 wxWindow* SetDefaultItem(wxWindow* win);
23324ae1
FM
275
276 /**
277 Sets the icon for this window.
3c4f71cc 278
7c913512 279 @param icon
f992f2ae
BP
280 The wxIcon to associate with this window.
281
282 @remarks The window takes a 'copy' of @a icon, but since it uses
283 reference counting, the copy is very quick. It is safe to
284 delete @a icon after calling this function.
3c4f71cc 285
0f278d77
VS
286 @note In wxMSW, @a icon must be either 16x16 or 32x32 icon.
287
288 @see wxIcon, SetIcons()
23324ae1
FM
289 */
290 void SetIcon(const wxIcon& icon);
291
292 /**
f992f2ae
BP
293 Sets several icons of different sizes for this window: this allows to
294 use different icons for different situations (e.g. task switching bar,
295 taskbar, window title bar) instead of scaling, with possibly bad looking
296 results, the only icon set by SetIcon().
3c4f71cc 297
7c913512 298 @param icons
4cc4bfaf 299 The icons to associate with this window.
3c4f71cc 300
0f278d77
VS
301 @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon,
302 preferably both.
303
304 @see wxIconBundle
23324ae1 305 */
adaaa686 306 virtual void SetIcons(const wxIconBundle& icons);
23324ae1
FM
307
308 /**
f992f2ae
BP
309 Sets action or menu activated by pressing left hardware button on the
310 smart phones. Unavailable on full keyboard machines.
3c4f71cc 311
7c913512 312 @param id
4cc4bfaf 313 Identifier for this button.
7c913512 314 @param label
f992f2ae
BP
315 Text to be displayed on the screen area dedicated to this hardware
316 button.
7c913512 317 @param subMenu
4cc4bfaf 318 The menu to be opened after pressing this hardware button.
3c4f71cc 319
4cc4bfaf 320 @see SetRightMenu().
23324ae1
FM
321 */
322 void SetLeftMenu(int id = wxID_ANY,
323 const wxString& label = wxEmptyString,
4cc4bfaf 324 wxMenu* subMenu = NULL);
23324ae1
FM
325
326 /**
f992f2ae 327 A simpler interface for setting the size hints than SetSizeHints().
23324ae1 328 */
adaaa686 329 virtual void SetMaxSize(const wxSize& size);
23324ae1
FM
330
331 /**
f992f2ae 332 A simpler interface for setting the size hints than SetSizeHints().
23324ae1 333 */
adaaa686 334 virtual void SetMinSize(const wxSize& size);
23324ae1
FM
335
336 /**
f992f2ae
BP
337 Sets action or menu activated by pressing right hardware button on the
338 smart phones. Unavailable on full keyboard machines.
3c4f71cc 339
7c913512 340 @param id
4cc4bfaf 341 Identifier for this button.
7c913512 342 @param label
f992f2ae 343 Text to be displayed on the screen area dedicated to this hardware
77bfb902 344 button.
7c913512 345 @param subMenu
4cc4bfaf 346 The menu to be opened after pressing this hardware button.
3c4f71cc 347
4cc4bfaf 348 @see SetLeftMenu().
23324ae1
FM
349 */
350 void SetRightMenu(int id = wxID_ANY,
351 const wxString& label = wxEmptyString,
4cc4bfaf 352 wxMenu* subMenu = NULL);
23324ae1
FM
353
354 /**
355 If the platform supports it, sets the shape of the window to that
f992f2ae
BP
356 depicted by @a region. The system will not display or respond to any
357 mouse event for the pixels that lie outside of the region. To reset the
358 window to the normal rectangular shape simply call SetShape() again with
359 an empty wxRegion. Returns @true if the operation is successful.
23324ae1 360 */
adaaa686 361 virtual bool SetShape(const wxRegion& region);
23324ae1 362
23324ae1 363 /**
f992f2ae
BP
364 Allows specification of minimum and maximum window sizes, and window
365 size increments. If a pair of values is not set (or set to -1), no
366 constraints will be used.
3c4f71cc 367
77bfb902
FM
368 @param minW
369 The minimum width.
370 @param minH
371 The minimum height.
372 @param maxW
373 The maximum width.
374 @param maxH
375 The maximum height.
7c913512 376 @param incW
4cc4bfaf 377 Specifies the increment for sizing the width (GTK/Motif/Xt only).
7c913512 378 @param incH
4cc4bfaf 379 Specifies the increment for sizing the height (GTK/Motif/Xt only).
3c4f71cc 380
23324ae1 381 @remarks Notice that this function not only prevents the user from
f992f2ae
BP
382 resizing the window outside the given bounds but it also
383 prevents the program itself from doing it using
384 wxWindow::SetSize().
385
4cc4bfaf 386 */
77bfb902
FM
387 virtual void SetSizeHints(int minW, int minH,
388 int maxW = -1, int maxH = -1,
389 int incW = -1, int incH = -1);
f992f2ae
BP
390
391 /**
392 Allows specification of minimum and maximum window sizes, and window
393 size increments. If a pair of values is not set (or set to -1), no
394 constraints will be used.
395
77bfb902
FM
396 @param minSize
397 The minimum size of the window.
398 @param maxSize
399 The maximum size of the window.
f992f2ae
BP
400 @param incSize
401 Increment size (only taken into account under X11-based ports such
402 as wxGTK/wxMotif/wxX11).
403
404 @remarks Notice that this function not only prevents the user from
405 resizing the window outside the given bounds but it also
406 prevents the program itself from doing it using
407 wxWindow::SetSize().
408 */
7c913512 409 void SetSizeHints(const wxSize& minSize,
4cc4bfaf
FM
410 const wxSize& maxSize = wxDefaultSize,
411 const wxSize& incSize = wxDefaultSize);
23324ae1
FM
412
413 /**
414 Sets the window title.
3c4f71cc 415
7c913512 416 @param title
4cc4bfaf 417 The window title.
3c4f71cc 418
4cc4bfaf 419 @see GetTitle()
23324ae1
FM
420 */
421 virtual void SetTitle(const wxString& title);
422
423 /**
f992f2ae 424 If the platform supports it will set the window to be translucent.
3c4f71cc 425
7c913512 426 @param alpha
f992f2ae
BP
427 Determines how opaque or transparent the window will be, if the
428 platform supports the opreration. A value of 0 sets the window to be
429 fully transparent, and a value of 255 sets the window to be fully
430 opaque.
23324ae1 431 */
cfbe5614 432 virtual bool SetTransparent(wxByte alpha);
23324ae1
FM
433
434 /**
f992f2ae
BP
435 This virtual function is not meant to be called directly but can be
436 overridden to return @false (it returns @true by default) to allow the
437 application to close even if this, presumably not very important, window
438 is still opened. By default, the application stays alive as long as
439 there are any open top level windows.
23324ae1 440 */
328f5751 441 virtual bool ShouldPreventAppExit() const;
efb2fa41
KO
442
443 /**
ebf7d5c4
KO
444 This function sets the wxTopLevelWindow's modified state on OS X,
445 which currently draws a black dot in the wxTopLevelWindow's close button.
446 On other platforms, this method does nothing.
447
448 @see OSXIsModified()
efb2fa41 449 */
ebf7d5c4 450 virtual void OSXSetModified(bool modified);
efb2fa41
KO
451
452 /**
ebf7d5c4
KO
453 Returns the current modified state of the wxTopLevelWindow on OS X.
454 On other platforms, this method does nothing.
455
456 @see OSXSetModified()
efb2fa41 457 */
ebf7d5c4 458 virtual bool OSXIsModified() const;
23324ae1
FM
459
460 /**
f992f2ae
BP
461 Depending on the value of @a show parameter the window is either shown
462 full screen or restored to its normal state. @a style is a bit list
463 containing some or all of the following values, which indicate what
464 elements of the window to hide in full-screen mode:
465
466 - @c ::wxFULLSCREEN_NOMENUBAR
467 - @c ::wxFULLSCREEN_NOTOOLBAR
468 - @c ::wxFULLSCREEN_NOSTATUSBAR
469 - @c ::wxFULLSCREEN_NOBORDER
470 - @c ::wxFULLSCREEN_NOCAPTION
471 - @c ::wxFULLSCREEN_ALL (all of the above)
472
23324ae1 473 This function has not been tested with MDI frames.
f992f2ae
BP
474
475 @note Showing a window full screen also actually @ref wxWindow::Show()
476 "Show()"s the window if it isn't shown.
3c4f71cc 477
4cc4bfaf 478 @see IsFullScreen()
23324ae1 479 */
0004982c 480 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
23324ae1
FM
481
482 /**
f992f2ae
BP
483 This method is specific to wxUniversal port.
484
485 Use native or custom-drawn decorations for this window only. Notice that
486 to have any effect this method must be called before really creating the
487 window, i.e. two step creation must be used:
488
489 @code
490 MyFrame *frame = new MyFrame; // use default ctor
491 frame->UseNativeDecorations(false); // change from default "true"
492 frame->Create(parent, title, ...); // really create the frame
493 @endcode
3c4f71cc 494
4cc4bfaf
FM
495 @see UseNativeDecorationsByDefault(),
496 IsUsingNativeDecorations()
23324ae1 497 */
4cc4bfaf 498 void UseNativeDecorations(bool native = true);
23324ae1
FM
499
500 /**
f992f2ae
BP
501 This method is specific to wxUniversal port.
502
503 Top level windows in wxUniversal port can use either system-provided
504 window decorations (i.e. title bar and various icons, buttons and menus
505 in it) or draw the decorations themselves. By default the system
506 decorations are used if they are available, but this method can be
507 called with @a native set to @false to change this for all windows
508 created after this point.
509
23324ae1 510 Also note that if @c WXDECOR environment variable is set, then custom
f992f2ae
BP
511 decorations are used by default and so it may make sense to call this
512 method with default argument if the application can't use custom
513 decorations at all for some reason.
77bfb902 514
f992f2ae 515 @see UseNativeDecorations()
23324ae1 516 */
4cc4bfaf 517 void UseNativeDecorationsByDefault(bool native = true);
23324ae1 518};
e54c96f1 519