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