1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxTopLevelWindow
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 Styles used with wxTopLevelWindow::RequestUserAttention().
14 wxUSER_ATTENTION_INFO
= 1, ///< Requests user attention,
15 wxUSER_ATTENTION_ERROR
= 2 ///< Results in a more drastic action.
19 Styles used with wxTopLevelWindow::ShowFullScreen().
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.
30 Combination of all above, will display the least possible.
32 wxFULLSCREEN_ALL
= wxFULLSCREEN_NOMENUBAR
| wxFULLSCREEN_NOTOOLBAR
|
33 wxFULLSCREEN_NOSTATUSBAR
| wxFULLSCREEN_NOBORDER
|
34 wxFULLSCREEN_NOCAPTION
38 @class wxTopLevelWindow
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
48 @see wxDialog, wxFrame
50 class wxTopLevelWindow
: public wxWindow
54 Returns @true if the platform supports making the window translucent.
58 virtual bool CanSetTransparent();
61 A synonym for CentreOnScreen().
63 void CenterOnScreen(int direction
);
66 Centres the window on screen.
69 Specifies the direction for the centering. May be @c wxHORIZONTAL,
70 @c wxVERTICAL or @c wxBOTH.
72 @see wxWindow::CentreOnParent()
74 void CentreOnScreen(int direction
= wxBOTH
);
77 Enables or disables the Close button (most often in the right upper
78 corner of a dialog) and the Close entry of the system menu (most often
79 in the left upper corner of the dialog).
81 Currently only implemented for wxMSW and wxGTK.
83 Returns @true if operation was successful. This may be wrong on X11
84 (including GTK+) where the window manager may not support this operation
85 and there is no way to find out.
87 virtual bool EnableCloseButton(bool enable
= true);
90 Returns a pointer to the button which is the default for this window, or
91 @c @NULL. The default button is the one activated by pressing the Enter
94 wxWindow
* GetDefaultItem() const;
97 Returns the standard icon of the window. The icon will be invalid if it
98 hadn't been previously set by SetIcon().
102 wxIcon
GetIcon() const;
105 Returns all icons associated with the window, there will be none of them
106 if neither SetIcon() nor SetIcons() had been called before. Use
107 GetIcon() to get the main icon of the window.
111 const wxIconBundle
& GetIcons() const;
114 Gets a string containing the window title.
118 virtual wxString
GetTitle() const;
121 Unique to the wxWinCE port. Responds to showing/hiding SIP (soft input
122 panel) area and resize window accordingly. Override this if you want to
123 avoid resizing or do additional operations.
125 virtual bool HandleSettingChange(WXWPARAM wParam
,
129 Iconizes or restores the window.
132 If @true, iconizes the window; if @false, shows and restores it.
134 @see IsIconized(), Maximize(), wxIconizeEvent.
136 virtual void Iconize(bool iconize
= true);
139 Returns @true if this window is currently active, i.e. if the user is
140 currently working with it.
142 virtual bool IsActive();
145 Returns @true if this window is expected to be always maximized, either
146 due to platform policy or due to local policy regarding particular
149 virtual bool IsAlwaysMaximized() const;
152 Returns @true if the window is in fullscreen mode.
154 @see ShowFullScreen()
156 virtual bool IsFullScreen() const;
159 Returns @true if the window is iconized.
161 virtual bool IsIconized() const;
164 Returns @true if the window is maximized.
166 virtual bool IsMaximized() const;
169 This method is specific to wxUniversal port.
171 Returns @true if this window is using native decorations, @false if we
174 @see UseNativeDecorations(),
175 UseNativeDecorationsByDefault()
177 bool IsUsingNativeDecorations() const;
180 See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
181 called automatically when the window is resized.
183 virtual bool Layout();
186 Maximizes or restores the window.
189 If @true, maximizes the window, otherwise it restores it.
193 virtual void Maximize(bool maximize
= true);
196 Use a system-dependent way to attract users attention to the window when
199 @a flags may have the value of either @c ::wxUSER_ATTENTION_INFO
200 (default) or @c ::wxUSER_ATTENTION_ERROR which results in a more drastic
201 action. When in doubt, use the default value.
204 @note This function should normally be only used when the application
205 is not already in foreground.
207 This function is currently implemented for Win32 where it flashes
208 the window icon in the taskbar, and for wxGTK with task bars
212 virtual void RequestUserAttention(int flags
= wxUSER_ATTENTION_INFO
);
215 Changes the default item for the panel, usually @a win is a button.
217 @see GetDefaultItem()
219 wxWindow
* SetDefaultItem(wxWindow
* win
);
222 Sets the icon for this window.
225 The wxIcon to associate with this window.
227 @remarks The window takes a 'copy' of @a icon, but since it uses
228 reference counting, the copy is very quick. It is safe to
229 delete @a icon after calling this function.
231 @note In wxMSW, @a icon must be either 16x16 or 32x32 icon.
233 @see wxIcon, SetIcons()
235 void SetIcon(const wxIcon
& icon
);
238 Sets several icons of different sizes for this window: this allows to
239 use different icons for different situations (e.g. task switching bar,
240 taskbar, window title bar) instead of scaling, with possibly bad looking
241 results, the only icon set by SetIcon().
244 The icons to associate with this window.
246 @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon,
251 virtual void SetIcons(const wxIconBundle
& icons
);
254 Sets action or menu activated by pressing left hardware button on the
255 smart phones. Unavailable on full keyboard machines.
258 Identifier for this button.
260 Text to be displayed on the screen area dedicated to this hardware
263 The menu to be opened after pressing this hardware button.
267 void SetLeftMenu(int id
= wxID_ANY
,
268 const wxString
& label
= wxEmptyString
,
269 wxMenu
* subMenu
= NULL
);
272 A simpler interface for setting the size hints than SetSizeHints().
274 virtual void SetMaxSize(const wxSize
& size
);
277 A simpler interface for setting the size hints than SetSizeHints().
279 virtual void SetMinSize(const wxSize
& size
);
282 Sets action or menu activated by pressing right hardware button on the
283 smart phones. Unavailable on full keyboard machines.
286 Identifier for this button.
288 Text to be displayed on the screen area dedicated to this hardware
291 The menu to be opened after pressing this hardware button.
295 void SetRightMenu(int id
= wxID_ANY
,
296 const wxString
& label
= wxEmptyString
,
297 wxMenu
* subMenu
= NULL
);
300 If the platform supports it, sets the shape of the window to that
301 depicted by @a region. The system will not display or respond to any
302 mouse event for the pixels that lie outside of the region. To reset the
303 window to the normal rectangular shape simply call SetShape() again with
304 an empty wxRegion. Returns @true if the operation is successful.
306 virtual bool SetShape(const wxRegion
& region
);
309 Allows specification of minimum and maximum window sizes, and window
310 size increments. If a pair of values is not set (or set to -1), no
311 constraints will be used.
322 Specifies the increment for sizing the width (GTK/Motif/Xt only).
324 Specifies the increment for sizing the height (GTK/Motif/Xt only).
326 @remarks Notice that this function not only prevents the user from
327 resizing the window outside the given bounds but it also
328 prevents the program itself from doing it using
332 virtual void SetSizeHints(int minW
, int minH
,
333 int maxW
= -1, int maxH
= -1,
334 int incW
= -1, int incH
= -1);
337 Allows specification of minimum and maximum window sizes, and window
338 size increments. If a pair of values is not set (or set to -1), no
339 constraints will be used.
342 The minimum size of the window.
344 The maximum size of the window.
346 Increment size (only taken into account under X11-based ports such
347 as wxGTK/wxMotif/wxX11).
349 @remarks Notice that this function not only prevents the user from
350 resizing the window outside the given bounds but it also
351 prevents the program itself from doing it using
354 void SetSizeHints(const wxSize
& minSize
,
355 const wxSize
& maxSize
= wxDefaultSize
,
356 const wxSize
& incSize
= wxDefaultSize
);
359 Sets the window title.
366 virtual void SetTitle(const wxString
& title
);
369 If the platform supports it will set the window to be translucent.
372 Determines how opaque or transparent the window will be, if the
373 platform supports the opreration. A value of 0 sets the window to be
374 fully transparent, and a value of 255 sets the window to be fully
377 virtual bool SetTransparent(wxByte alpha
);
380 This virtual function is not meant to be called directly but can be
381 overridden to return @false (it returns @true by default) to allow the
382 application to close even if this, presumably not very important, window
383 is still opened. By default, the application stays alive as long as
384 there are any open top level windows.
386 virtual bool ShouldPreventAppExit() const;
389 Depending on the value of @a show parameter the window is either shown
390 full screen or restored to its normal state. @a style is a bit list
391 containing some or all of the following values, which indicate what
392 elements of the window to hide in full-screen mode:
394 - @c ::wxFULLSCREEN_NOMENUBAR
395 - @c ::wxFULLSCREEN_NOTOOLBAR
396 - @c ::wxFULLSCREEN_NOSTATUSBAR
397 - @c ::wxFULLSCREEN_NOBORDER
398 - @c ::wxFULLSCREEN_NOCAPTION
399 - @c ::wxFULLSCREEN_ALL (all of the above)
401 This function has not been tested with MDI frames.
403 @note Showing a window full screen also actually @ref wxWindow::Show()
404 "Show()"s the window if it isn't shown.
408 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
411 This method is specific to wxUniversal port.
413 Use native or custom-drawn decorations for this window only. Notice that
414 to have any effect this method must be called before really creating the
415 window, i.e. two step creation must be used:
418 MyFrame *frame = new MyFrame; // use default ctor
419 frame->UseNativeDecorations(false); // change from default "true"
420 frame->Create(parent, title, ...); // really create the frame
423 @see UseNativeDecorationsByDefault(),
424 IsUsingNativeDecorations()
426 void UseNativeDecorations(bool native
= true);
429 This method is specific to wxUniversal port.
431 Top level windows in wxUniversal port can use either system-provided
432 window decorations (i.e. title bar and various icons, buttons and menus
433 in it) or draw the decorations themselves. By default the system
434 decorations are used if they are available, but this method can be
435 called with @a native set to @false to change this for all windows
436 created after this point.
438 Also note that if @c WXDECOR environment variable is set, then custom
439 decorations are used by default and so it may make sense to call this
440 method with default argument if the application can't use custom
441 decorations at all for some reason.
443 @see UseNativeDecorations()
445 void UseNativeDecorationsByDefault(bool native
= true);