]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/toplevel.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxTopLevelWindow
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
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
45 Note that the instances of wxTopLevelWindow are managed by wxWidgets in the
46 internal top level window list.
48 @beginEventEmissionTable
49 @event{EVT_MAXIMIZE(id, func)}
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.
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.
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.
62 @event{EVT_SHOW(func)}
63 Process a @c wxEVT_SHOW event. See wxShowEvent.
69 @see wxDialog, wxFrame
71 class wxTopLevelWindow
: public wxWindow
80 Constructor creating the top level window.
82 wxTopLevelWindow(wxWindow
*parent
,
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
);
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.
95 See @ref overview_windowdeletion for more info.
97 virtual ~wxTopLevelWindow();
100 Creates the top level window.
102 bool Create(wxWindow
*parent
,
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
);
111 Returns @true if the platform supports making the window translucent.
113 @see SetTransparent()
115 virtual bool CanSetTransparent();
118 A synonym for CentreOnScreen().
120 void CenterOnScreen(int direction
);
123 Centres the window on screen.
126 Specifies the direction for the centering. May be @c wxHORIZONTAL,
127 @c wxVERTICAL or @c wxBOTH.
129 @see wxWindow::CentreOnParent()
131 void CentreOnScreen(int direction
= wxBOTH
);
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).
138 Currently only implemented for wxMSW and wxGTK.
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.
144 virtual bool EnableCloseButton(bool enable
= true);
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
151 wxWindow
* GetDefaultItem() const;
154 Get the default size for a new top level window.
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
164 static wxSize
GetDefaultSize();
167 Returns the standard icon of the window. The icon will be invalid if it
168 hadn't been previously set by SetIcon().
172 wxIcon
GetIcon() const;
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.
181 const wxIconBundle
& GetIcons() const;
184 Gets a string containing the window title.
188 virtual wxString
GetTitle() const;
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.
195 virtual bool HandleSettingChange(WXWPARAM wParam
,
199 Iconizes or restores the window.
202 If @true, iconizes the window; if @false, shows and restores it.
204 @see IsIconized(), Maximize(), wxIconizeEvent.
206 virtual void Iconize(bool iconize
= true);
209 Returns @true if this window is currently active, i.e. if the user is
210 currently working with it.
212 virtual bool IsActive();
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
219 virtual bool IsAlwaysMaximized() const;
222 Returns @true if the window is in fullscreen mode.
224 @see ShowFullScreen()
226 virtual bool IsFullScreen() const;
229 Returns @true if the window is iconized.
231 virtual bool IsIconized() const;
234 Returns @true if the window is maximized.
236 virtual bool IsMaximized() const;
239 This method is specific to wxUniversal port.
241 Returns @true if this window is using native decorations, @false if we
244 @see UseNativeDecorations(),
245 UseNativeDecorationsByDefault()
247 bool IsUsingNativeDecorations() const;
250 See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
251 called automatically when the window is resized.
253 virtual bool Layout();
256 Maximizes or restores the window.
259 If @true, maximizes the window, otherwise it restores it.
263 virtual void Maximize(bool maximize
= true);
266 Use a system-dependent way to attract users attention to the window when
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
271 action. When in doubt, use the default value.
274 @note This function should normally be only used when the application
275 is not already in foreground.
277 This function is currently implemented for Win32 where it flashes
278 the window icon in the taskbar, and for wxGTK with task bars
282 virtual void RequestUserAttention(int flags
= wxUSER_ATTENTION_INFO
);
285 Changes the default item for the panel, usually @a win is a button.
287 @see GetDefaultItem()
289 wxWindow
* SetDefaultItem(wxWindow
* win
);
292 wxWindow
* SetTmpDefaultItem(wxWindow
* win
);
293 wxWindow
* GetTmpDefaultItem() const;
297 Sets the icon for this window.
300 The wxIcon to associate with this window.
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.
306 @note In wxMSW, @a icon must be either 16x16 or 32x32 icon.
308 @see wxIcon, SetIcons()
310 void SetIcon(const wxIcon
& icon
);
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().
319 The icons to associate with this window.
321 @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon,
326 virtual void SetIcons(const wxIconBundle
& icons
);
329 Sets action or menu activated by pressing left hardware button on the
330 smart phones. Unavailable on full keyboard machines.
333 Identifier for this button.
335 Text to be displayed on the screen area dedicated to this hardware
338 The menu to be opened after pressing this hardware button.
342 void SetLeftMenu(int id
= wxID_ANY
,
343 const wxString
& label
= wxEmptyString
,
344 wxMenu
* subMenu
= NULL
);
347 A simpler interface for setting the size hints than SetSizeHints().
349 virtual void SetMaxSize(const wxSize
& size
);
352 A simpler interface for setting the size hints than SetSizeHints().
354 virtual void SetMinSize(const wxSize
& size
);
357 Sets action or menu activated by pressing right hardware button on the
358 smart phones. Unavailable on full keyboard machines.
361 Identifier for this button.
363 Text to be displayed on the screen area dedicated to this hardware
366 The menu to be opened after pressing this hardware button.
370 void SetRightMenu(int id
= wxID_ANY
,
371 const wxString
& label
= wxEmptyString
,
372 wxMenu
* subMenu
= NULL
);
375 If the platform supports it, sets the shape of the window to that
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.
381 virtual bool SetShape(const wxRegion
& region
);
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.
397 Specifies the increment for sizing the width (GTK/Motif/Xt only).
399 Specifies the increment for sizing the height (GTK/Motif/Xt only).
401 @remarks Notice that this function not only prevents the user from
402 resizing the window outside the given bounds but it also
403 prevents the program itself from doing it using
407 virtual void SetSizeHints(int minW
, int minH
,
408 int maxW
= -1, int maxH
= -1,
409 int incW
= -1, int incH
= -1);
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.
417 The minimum size of the window.
419 The maximum size of the window.
421 Increment size (only taken into account under X11-based ports such
422 as wxGTK/wxMotif/wxX11).
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
429 void SetSizeHints(const wxSize
& minSize
,
430 const wxSize
& maxSize
= wxDefaultSize
,
431 const wxSize
& incSize
= wxDefaultSize
);
434 Sets the window title.
441 virtual void SetTitle(const wxString
& title
);
444 If the platform supports it will set the window to be translucent.
447 Determines how opaque or transparent the window will be, if the
448 platform supports the opreration. A value of 0 sets the window to be
449 fully transparent, and a value of 255 sets the window to be fully
452 virtual bool SetTransparent(wxByte alpha
);
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.
461 virtual bool ShouldPreventAppExit() const;
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.
470 virtual void OSXSetModified(bool modified
);
473 Returns the current modified state of the wxTopLevelWindow on OS X.
474 On other platforms, this method does nothing.
476 @see OSXSetModified()
478 virtual bool OSXIsModified() const;
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:
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)
493 This function has not been tested with MDI frames.
495 @note Showing a window full screen also actually @ref wxWindow::Show()
496 "Show()"s the window if it isn't shown.
500 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
503 This method is specific to wxUniversal port.
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:
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
515 @see UseNativeDecorationsByDefault(),
516 IsUsingNativeDecorations()
518 void UseNativeDecorations(bool native
= true);
521 This method is specific to wxUniversal port.
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.
530 Also note that if @c WXDECOR environment variable is set, then custom
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.
535 @see UseNativeDecorations()
537 void UseNativeDecorationsByDefault(bool native
= true);