]>
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
37 #define wxDEFAULT_FRAME_STYLE (wxSYSTEM_MENU | \
46 @class wxTopLevelWindow
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
53 Note that the instances of wxTopLevelWindow are managed by wxWidgets in the
54 internal top level window list.
56 @beginEventEmissionTable
57 @event{EVT_MAXIMIZE(id, func)}
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.
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.
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.
70 @event{EVT_SHOW(func)}
71 Process a @c wxEVT_SHOW event. See wxShowEvent.
77 @see wxDialog, wxFrame
79 class wxTopLevelWindow
: public wxNonOwnedWindow
88 Constructor creating the top level window.
90 wxTopLevelWindow(wxWindow
*parent
,
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
);
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.
103 See @ref overview_windowdeletion for more info.
105 virtual ~wxTopLevelWindow();
108 Creates the top level window.
110 bool Create(wxWindow
*parent
,
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
);
119 Returns @true if the platform supports making the window translucent.
121 @see SetTransparent()
123 virtual bool CanSetTransparent();
126 A synonym for CentreOnScreen().
128 void CenterOnScreen(int direction
= wxBOTH
);
131 Centres the window on screen.
134 Specifies the direction for the centering. May be @c wxHORIZONTAL,
135 @c wxVERTICAL or @c wxBOTH.
137 @see wxWindow::CentreOnParent()
139 void CentreOnScreen(int direction
= wxBOTH
);
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).
146 Currently only implemented for wxMSW and wxGTK.
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.
152 virtual bool EnableCloseButton(bool enable
= true);
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
159 wxWindow
* GetDefaultItem() const;
162 Get the default size for a new top level window.
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
172 static wxSize
GetDefaultSize();
175 Returns the standard icon of the window. The icon will be invalid if it
176 hadn't been previously set by SetIcon().
180 wxIcon
GetIcon() const;
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.
189 const wxIconBundle
& GetIcons() const;
192 Gets a string containing the window title.
196 virtual wxString
GetTitle() const;
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.
203 virtual bool HandleSettingChange(WXWPARAM wParam
,
207 Iconizes or restores the window.
210 If @true, iconizes the window; if @false, shows and restores it.
212 @see IsIconized(), Maximize(), wxIconizeEvent.
214 virtual void Iconize(bool iconize
= true);
217 Returns @true if this window is currently active, i.e.\ if the user is
218 currently working with it.
220 virtual bool IsActive();
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
227 virtual bool IsAlwaysMaximized() const;
230 Returns @true if the window is in fullscreen mode.
232 @see ShowFullScreen()
234 virtual bool IsFullScreen() const;
237 Returns @true if the window is iconized.
239 virtual bool IsIconized() const;
242 Returns @true if the window is maximized.
244 virtual bool IsMaximized() const;
247 This method is specific to wxUniversal port.
249 Returns @true if this window is using native decorations, @false if we
252 @see UseNativeDecorations(),
253 UseNativeDecorationsByDefault()
255 bool IsUsingNativeDecorations() const;
258 See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
259 called automatically when the window is resized.
261 virtual bool Layout();
264 Maximizes or restores the window.
267 If @true, maximizes the window, otherwise it restores it.
271 virtual void Maximize(bool maximize
= true);
274 MSW-specific function for accessing the system menu.
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
278 extra items to the system menu. The usual @c wxEVT_COMMAND_MENU_SELECTED
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
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.
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.
292 This function is not available in the other ports by design, any
293 occurrences of it in the portable code must be guarded by
294 @code #ifdef __WXMSW__ @endcode preprocessor guards.
298 wxMenu
*MSWGetSystemMenu() const;
301 Use a system-dependent way to attract users attention to the window when
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
306 action. When in doubt, use the default value.
309 @note This function should normally be only used when the application
310 is not already in foreground.
312 This function is currently implemented for Win32 where it flashes
313 the window icon in the taskbar, and for wxGTK with task bars
317 virtual void RequestUserAttention(int flags
= wxUSER_ATTENTION_INFO
);
320 Changes the default item for the panel, usually @a win is a button.
322 @see GetDefaultItem()
324 wxWindow
* SetDefaultItem(wxWindow
* win
);
327 wxWindow
* SetTmpDefaultItem(wxWindow
* win
);
328 wxWindow
* GetTmpDefaultItem() const;
332 Sets the icon for this window.
335 The wxIcon to associate with this window.
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.
341 @note In wxMSW, @a icon must be either 16x16 or 32x32 icon.
343 @see wxIcon, SetIcons()
345 void SetIcon(const wxIcon
& icon
);
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().
354 The icons to associate with this window.
356 @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon,
361 virtual void SetIcons(const wxIconBundle
& icons
);
364 Sets action or menu activated by pressing left hardware button on the
365 smart phones. Unavailable on full keyboard machines.
368 Identifier for this button.
370 Text to be displayed on the screen area dedicated to this hardware
373 The menu to be opened after pressing this hardware button.
377 void SetLeftMenu(int id
= wxID_ANY
,
378 const wxString
& label
= wxEmptyString
,
379 wxMenu
* subMenu
= NULL
);
382 A simpler interface for setting the size hints than SetSizeHints().
384 virtual void SetMaxSize(const wxSize
& size
);
387 A simpler interface for setting the size hints than SetSizeHints().
389 virtual void SetMinSize(const wxSize
& size
);
392 Sets action or menu activated by pressing right hardware button on the
393 smart phones. Unavailable on full keyboard machines.
396 Identifier for this button.
398 Text to be displayed on the screen area dedicated to this hardware
401 The menu to be opened after pressing this hardware button.
405 void SetRightMenu(int id
= wxID_ANY
,
406 const wxString
& label
= wxEmptyString
,
407 wxMenu
* subMenu
= NULL
);
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.
423 Specifies the increment for sizing the width (GTK/Motif/Xt only).
425 Specifies the increment for sizing the height (GTK/Motif/Xt only).
427 @remarks Notice that this function not only prevents the user from
428 resizing the window outside the given bounds but it also
429 prevents the program itself from doing it using
433 virtual void SetSizeHints(int minW
, int minH
,
434 int maxW
= -1, int maxH
= -1,
435 int incW
= -1, int incH
= -1);
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.
443 The minimum size of the window.
445 The maximum size of the window.
447 Increment size (only taken into account under X11-based ports such
448 as wxGTK/wxMotif/wxX11).
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
455 void SetSizeHints(const wxSize
& minSize
,
456 const wxSize
& maxSize
= wxDefaultSize
,
457 const wxSize
& incSize
= wxDefaultSize
);
460 Sets the window title.
467 virtual void SetTitle(const wxString
& title
);
470 If the platform supports it will set the window to be translucent.
473 Determines how opaque or transparent the window will be, if the
474 platform supports the operation. A value of 0 sets the window to be
475 fully transparent, and a value of 255 sets the window to be fully
478 virtual bool SetTransparent(wxByte alpha
);
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.
487 virtual bool ShouldPreventAppExit() const;
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.
496 virtual void OSXSetModified(bool modified
);
499 Returns the current modified state of the wxTopLevelWindow on OS X.
500 On other platforms, this method does nothing.
502 @see OSXSetModified()
504 virtual bool OSXIsModified() const;
507 Sets the file name represented by this wxTopLevelWindow.
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.
518 virtual void SetRepresentedFilename(const wxString
& filename
);
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
525 virtual void ShowWithoutActivating();
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:
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)
540 This function has not been tested with MDI frames.
542 @note Showing a window full screen also actually @ref wxWindow::Show()
543 "Show()"s the window if it isn't shown.
547 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
550 This method is specific to wxUniversal port.
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:
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
562 @see UseNativeDecorationsByDefault(),
563 IsUsingNativeDecorations()
565 void UseNativeDecorations(bool native
= true);
568 This method is specific to wxUniversal port.
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.
577 Also note that if @c WXDECOR environment variable is set, then custom
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.
582 @see UseNativeDecorations()
584 void UseNativeDecorationsByDefault(bool native
= true);