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