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