]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/toplevel.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxTopLevelWindow
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 Styles used with wxTopLevelWindow::RequestUserAttention().
13 wxUSER_ATTENTION_INFO
= 1, ///< Requests user attention,
14 wxUSER_ATTENTION_ERROR
= 2 ///< Results in a more drastic action.
18 Styles used with wxTopLevelWindow::ShowFullScreen().
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.
29 Combination of all above, will display the least possible.
31 wxFULLSCREEN_ALL
= wxFULLSCREEN_NOMENUBAR
| wxFULLSCREEN_NOTOOLBAR
|
32 wxFULLSCREEN_NOSTATUSBAR
| wxFULLSCREEN_NOBORDER
|
33 wxFULLSCREEN_NOCAPTION
36 #define wxDEFAULT_FRAME_STYLE (wxSYSTEM_MENU | \
45 @class wxTopLevelWindow
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
52 Note that the instances of wxTopLevelWindow are managed by wxWidgets in the
53 internal top level window list.
55 @beginEventEmissionTable
56 @event{EVT_MAXIMIZE(id, func)}
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.
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.
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.
69 @event{EVT_SHOW(func)}
70 Process a @c wxEVT_SHOW event. See wxShowEvent.
76 @see wxDialog, wxFrame
78 class wxTopLevelWindow
: public wxNonOwnedWindow
87 Constructor creating the top level window.
89 wxTopLevelWindow(wxWindow
*parent
,
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
);
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.
102 See @ref overview_windowdeletion for more info.
104 virtual ~wxTopLevelWindow();
107 Creates the top level window.
109 bool Create(wxWindow
*parent
,
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
);
118 Returns @true if the platform supports making the window translucent.
120 @see SetTransparent()
122 virtual bool CanSetTransparent();
125 A synonym for CentreOnScreen().
127 void CenterOnScreen(int direction
= wxBOTH
);
130 Centres the window on screen.
133 Specifies the direction for the centering. May be @c wxHORIZONTAL,
134 @c wxVERTICAL or @c wxBOTH.
136 @see wxWindow::CentreOnParent()
138 void CentreOnScreen(int direction
= wxBOTH
);
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).
145 Currently only implemented for wxMSW and wxGTK.
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.
151 virtual bool EnableCloseButton(bool enable
= true);
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
158 wxWindow
* GetDefaultItem() const;
161 Get the default size for a new top level window.
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
171 static wxSize
GetDefaultSize();
174 Returns the standard icon of the window. The icon will be invalid if it
175 hadn't been previously set by SetIcon().
179 wxIcon
GetIcon() const;
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.
188 const wxIconBundle
& GetIcons() const;
191 Gets a string containing the window title.
195 virtual wxString
GetTitle() const;
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.
202 virtual bool HandleSettingChange(WXWPARAM wParam
,
206 Iconizes or restores the window.
209 If @true, iconizes the window; if @false, shows and restores it.
211 @see IsIconized(), Maximize(), wxIconizeEvent.
213 virtual void Iconize(bool iconize
= true);
216 Returns @true if this window is currently active, i.e.\ if the user is
217 currently working with it.
219 virtual bool IsActive();
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
226 virtual bool IsAlwaysMaximized() const;
229 Returns @true if the window is in fullscreen mode.
231 @see ShowFullScreen()
233 virtual bool IsFullScreen() const;
236 Returns @true if the window is iconized.
238 virtual bool IsIconized() const;
241 Returns @true if the window is maximized.
243 virtual bool IsMaximized() const;
246 This method is specific to wxUniversal port.
248 Returns @true if this window is using native decorations, @false if we
251 @see UseNativeDecorations(),
252 UseNativeDecorationsByDefault()
254 bool IsUsingNativeDecorations() const;
257 See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
258 called automatically when the window is resized.
260 virtual bool Layout();
263 Maximizes or restores the window.
266 If @true, maximizes the window, otherwise it restores it.
270 virtual void Maximize(bool maximize
= true);
273 MSW-specific function for accessing the system menu.
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
277 extra items to the system menu. The usual @c wxEVT_MENU
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
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.
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.
291 This function is not available in the other ports by design, any
292 occurrences of it in the portable code must be guarded by
293 @code #ifdef __WXMSW__ @endcode preprocessor guards.
297 wxMenu
*MSWGetSystemMenu() const;
300 Use a system-dependent way to attract users attention to the window when
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
305 action. When in doubt, use the default value.
308 @note This function should normally be only used when the application
309 is not already in foreground.
311 This function is currently implemented for Win32 where it flashes
312 the window icon in the taskbar, and for wxGTK with task bars
316 virtual void RequestUserAttention(int flags
= wxUSER_ATTENTION_INFO
);
319 Changes the default item for the panel, usually @a win is a button.
321 @see GetDefaultItem()
323 wxWindow
* SetDefaultItem(wxWindow
* win
);
326 wxWindow
* SetTmpDefaultItem(wxWindow
* win
);
327 wxWindow
* GetTmpDefaultItem() const;
331 Sets the icon for this window.
334 The wxIcon to associate with this window.
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.
340 @note In wxMSW, @a icon must be either 16x16 or 32x32 icon.
342 @see wxIcon, SetIcons()
344 void SetIcon(const wxIcon
& icon
);
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().
353 The icons to associate with this window.
355 @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon,
360 virtual void SetIcons(const wxIconBundle
& icons
);
363 Sets action or menu activated by pressing left hardware button on the
364 smart phones. Unavailable on full keyboard machines.
367 Identifier for this button.
369 Text to be displayed on the screen area dedicated to this hardware
372 The menu to be opened after pressing this hardware button.
376 void SetLeftMenu(int id
= wxID_ANY
,
377 const wxString
& label
= wxEmptyString
,
378 wxMenu
* subMenu
= NULL
);
381 A simpler interface for setting the size hints than SetSizeHints().
383 virtual void SetMaxSize(const wxSize
& size
);
386 A simpler interface for setting the size hints than SetSizeHints().
388 virtual void SetMinSize(const wxSize
& size
);
391 Sets action or menu activated by pressing right hardware button on the
392 smart phones. Unavailable on full keyboard machines.
395 Identifier for this button.
397 Text to be displayed on the screen area dedicated to this hardware
400 The menu to be opened after pressing this hardware button.
404 void SetRightMenu(int id
= wxID_ANY
,
405 const wxString
& label
= wxEmptyString
,
406 wxMenu
* subMenu
= NULL
);
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.
422 Specifies the increment for sizing the width (GTK/Motif/Xt only).
424 Specifies the increment for sizing the height (GTK/Motif/Xt only).
426 @remarks Notice that this function not only prevents the user from
427 resizing the window outside the given bounds but it also
428 prevents the program itself from doing it using
432 virtual void SetSizeHints(int minW
, int minH
,
433 int maxW
= -1, int maxH
= -1,
434 int incW
= -1, int incH
= -1);
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.
442 The minimum size of the window.
444 The maximum size of the window.
446 Increment size (only taken into account under X11-based ports such
447 as wxGTK/wxMotif/wxX11).
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
454 void SetSizeHints(const wxSize
& minSize
,
455 const wxSize
& maxSize
= wxDefaultSize
,
456 const wxSize
& incSize
= wxDefaultSize
);
459 Sets the window title.
466 virtual void SetTitle(const wxString
& title
);
469 If the platform supports it will set the window to be translucent.
472 Determines how opaque or transparent the window will be, if the
473 platform supports the operation. A value of 0 sets the window to be
474 fully transparent, and a value of 255 sets the window to be fully
477 virtual bool SetTransparent(wxByte alpha
);
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.
486 virtual bool ShouldPreventAppExit() const;
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.
495 virtual void OSXSetModified(bool modified
);
498 Returns the current modified state of the wxTopLevelWindow on OS X.
499 On other platforms, this method does nothing.
501 @see OSXSetModified()
503 virtual bool OSXIsModified() const;
506 Sets the file name represented by this wxTopLevelWindow.
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.
517 virtual void SetRepresentedFilename(const wxString
& filename
);
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
524 virtual void ShowWithoutActivating();
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:
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)
539 This function has not been tested with MDI frames.
541 @note Showing a window full screen also actually @ref wxWindow::Show()
542 "Show()"s the window if it isn't shown.
546 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
549 This method is specific to wxUniversal port.
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:
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
561 @see UseNativeDecorationsByDefault(),
562 IsUsingNativeDecorations()
564 void UseNativeDecorations(bool native
= true);
567 This method is specific to wxUniversal port.
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.
576 Also note that if @c WXDECOR environment variable is set, then custom
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.
581 @see UseNativeDecorations()
583 void UseNativeDecorationsByDefault(bool native
= true);