]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/toplevel.h
   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 
  45     Note that the instances of wxTopLevelWindow are managed by wxWidgets in the 
  46     internal top level window list. 
  51     @see wxDialog, wxFrame 
  53 class wxTopLevelWindow 
: public wxWindow
 
  62         Constructor creating the top level window. 
  64     wxTopLevelWindow(wxWindow 
*parent
, 
  66                     const wxString
& title
, 
  67                     const wxPoint
& pos 
= wxDefaultPosition
, 
  68                     const wxSize
& size 
= wxDefaultSize
, 
  69                     long style 
= wxDEFAULT_FRAME_STYLE
, 
  70                     const wxString
& name 
= wxFrameNameStr
); 
  73         Destructor. Remember that wxTopLevelWindows do not get immediately 
  74         destroyed when the user (or the app) closes them; they have a 
  75         @b delayed destruction. 
  77         See @ref overview_windowdeletion for more info. 
  79     virtual ~wxTopLevelWindow(); 
  82         Creates the top level window. 
  84     bool Create(wxWindow 
*parent
, 
  86                 const wxString
& title
, 
  87                 const wxPoint
& pos 
= wxDefaultPosition
, 
  88                 const wxSize
& size 
= wxDefaultSize
, 
  89                 long style 
= wxDEFAULT_FRAME_STYLE
, 
  90                 const wxString
& name 
= wxFrameNameStr
); 
  93         Returns @true if the platform supports making the window translucent. 
  97     virtual bool CanSetTransparent(); 
 100         A synonym for CentreOnScreen(). 
 102     void CenterOnScreen(int direction
); 
 105         Centres the window on screen. 
 108             Specifies the direction for the centering. May be @c wxHORIZONTAL, 
 109             @c wxVERTICAL or @c wxBOTH. 
 111         @see wxWindow::CentreOnParent() 
 113     void CentreOnScreen(int direction 
= wxBOTH
); 
 116         Enables or disables the Close button (most often in the right upper 
 117         corner of a dialog) and the Close entry of the system menu (most often 
 118         in the left upper corner of the dialog). 
 120         Currently only implemented for wxMSW and wxGTK. 
 122         Returns @true if operation was successful. This may be wrong on X11 
 123         (including GTK+) where the window manager may not support this operation 
 124         and there is no way to find out. 
 126     virtual bool EnableCloseButton(bool enable 
= true); 
 129         Returns a pointer to the button which is the default for this window, or 
 130         @c @NULL. The default button is the one activated by pressing the Enter 
 133     wxWindow
* GetDefaultItem() const; 
 136         Returns the standard icon of the window. The icon will be invalid if it 
 137         hadn't been previously set by SetIcon(). 
 141     wxIcon 
GetIcon() const; 
 144         Returns all icons associated with the window, there will be none of them 
 145         if neither SetIcon() nor SetIcons() had been called before. Use 
 146         GetIcon() to get the main icon of the window. 
 150     const wxIconBundle
& GetIcons() const; 
 153         Gets a string containing the window title. 
 157     virtual wxString 
GetTitle() const; 
 160         Unique to the wxWinCE port. Responds to showing/hiding SIP (soft input 
 161         panel) area and resize window accordingly. Override this if you want to 
 162         avoid resizing or do additional operations. 
 164     virtual bool HandleSettingChange(WXWPARAM wParam
, 
 168         Iconizes or restores the window. 
 171             If @true, iconizes the window; if @false, shows and restores it. 
 173         @see IsIconized(), Maximize(), wxIconizeEvent. 
 175     virtual void Iconize(bool iconize 
= true); 
 178         Returns @true if this window is currently active, i.e. if the user is 
 179         currently working with it. 
 181     virtual bool IsActive(); 
 184         Returns @true if this window is expected to be always maximized, either 
 185         due to platform policy or due to local policy regarding particular 
 188     virtual bool IsAlwaysMaximized() const; 
 191         Returns @true if the window is in fullscreen mode. 
 193         @see ShowFullScreen() 
 195     virtual bool IsFullScreen() const; 
 198         Returns @true if the window is iconized. 
 200     virtual bool IsIconized() const; 
 203         Returns @true if the window is maximized. 
 205     virtual bool IsMaximized() const; 
 208         This method is specific to wxUniversal port. 
 210         Returns @true if this window is using native decorations, @false if we 
 213         @see UseNativeDecorations(), 
 214              UseNativeDecorationsByDefault() 
 216     bool IsUsingNativeDecorations() const; 
 219         See wxWindow::SetAutoLayout(): when auto layout is on, this function gets 
 220         called automatically when the window is resized. 
 222     virtual bool Layout(); 
 225         Maximizes or restores the window. 
 228             If @true, maximizes the window, otherwise it restores it. 
 232     virtual void Maximize(bool maximize 
= true); 
 235         Use a system-dependent way to attract users attention to the window when 
 238         @a flags may have the value of either @c ::wxUSER_ATTENTION_INFO 
 239         (default) or @c ::wxUSER_ATTENTION_ERROR which results in a more drastic 
 240         action. When in doubt, use the default value. 
 243         @note This function should normally be only used when the application 
 244               is not already in foreground. 
 246         This function is currently implemented for Win32 where it flashes 
 247         the window icon in the taskbar, and for wxGTK with task bars 
 251     virtual void RequestUserAttention(int flags 
= wxUSER_ATTENTION_INFO
); 
 254         Changes the default item for the panel, usually @a win is a button. 
 256         @see GetDefaultItem() 
 258     wxWindow
* SetDefaultItem(wxWindow
* win
); 
 261         Sets the icon for this window. 
 264             The wxIcon to associate with this window. 
 266         @remarks The window takes a 'copy' of @a icon, but since it uses 
 267                  reference counting, the copy is very quick. It is safe to 
 268                  delete @a icon after calling this function. 
 270         @note In wxMSW, @a icon must be either 16x16 or 32x32 icon. 
 272         @see wxIcon, SetIcons() 
 274     void SetIcon(const wxIcon
& icon
); 
 277         Sets several icons of different sizes for this window: this allows to 
 278         use different icons for different situations (e.g. task switching bar, 
 279         taskbar, window title bar) instead of scaling, with possibly bad looking 
 280         results, the only icon set by SetIcon(). 
 283             The icons to associate with this window. 
 285         @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon, 
 290     virtual void SetIcons(const wxIconBundle
& icons
); 
 293         Sets action or menu activated by pressing left hardware button on the 
 294         smart phones. Unavailable on full keyboard machines. 
 297             Identifier for this button. 
 299             Text to be displayed on the screen area dedicated to this hardware 
 302             The menu to be opened after pressing this hardware button. 
 306     void SetLeftMenu(int id 
= wxID_ANY
, 
 307                      const wxString
& label 
= wxEmptyString
, 
 308                      wxMenu
* subMenu 
= NULL
); 
 311         A simpler interface for setting the size hints than SetSizeHints(). 
 313     virtual void SetMaxSize(const wxSize
& size
); 
 316         A simpler interface for setting the size hints than SetSizeHints(). 
 318     virtual void SetMinSize(const wxSize
& size
); 
 321         Sets action or menu activated by pressing right hardware button on the 
 322         smart phones. Unavailable on full keyboard machines. 
 325             Identifier for this button. 
 327             Text to be displayed on the screen area dedicated to this hardware 
 330             The menu to be opened after pressing this hardware button. 
 334     void SetRightMenu(int id 
= wxID_ANY
, 
 335                       const wxString
& label 
= wxEmptyString
, 
 336                       wxMenu
* subMenu 
= NULL
); 
 339         If the platform supports it, sets the shape of the window to that 
 340         depicted by @a region. The system will not display or respond to any 
 341         mouse event for the pixels that lie outside of the region. To reset the 
 342         window to the normal rectangular shape simply call SetShape() again with 
 343         an empty wxRegion. Returns @true if the operation is successful. 
 345     virtual bool SetShape(const wxRegion
& region
); 
 348         Allows specification of minimum and maximum window sizes, and window 
 349         size increments. If a pair of values is not set (or set to -1), no 
 350         constraints will be used. 
 361             Specifies the increment for sizing the width (GTK/Motif/Xt only). 
 363             Specifies the increment for sizing the height (GTK/Motif/Xt only). 
 365         @remarks Notice that this function not only prevents the user from 
 366                  resizing the window outside the given bounds but it also 
 367                  prevents the program itself from doing it using 
 371     virtual void SetSizeHints(int minW
, int minH
, 
 372                               int maxW 
= -1, int maxH 
= -1, 
 373                               int incW 
= -1, int incH 
= -1); 
 376         Allows specification of minimum and maximum window sizes, and window 
 377         size increments. If a pair of values is not set (or set to -1), no 
 378         constraints will be used. 
 381             The minimum size of the window. 
 383             The maximum size of the window. 
 385             Increment size (only taken into account under X11-based ports such 
 386             as wxGTK/wxMotif/wxX11). 
 388         @remarks Notice that this function not only prevents the user from 
 389                  resizing the window outside the given bounds but it also 
 390                  prevents the program itself from doing it using 
 393     void SetSizeHints(const wxSize
& minSize
, 
 394                       const wxSize
& maxSize 
= wxDefaultSize
, 
 395                       const wxSize
& incSize 
= wxDefaultSize
); 
 398         Sets the window title. 
 405     virtual void SetTitle(const wxString
& title
); 
 408         If the platform supports it will set the window to be translucent. 
 411             Determines how opaque or transparent the window will be, if the 
 412             platform supports the opreration. A value of 0 sets the window to be 
 413             fully transparent, and a value of 255 sets the window to be fully 
 416     virtual bool SetTransparent(wxByte alpha
); 
 419         This virtual function is not meant to be called directly but can be 
 420         overridden to return @false (it returns @true by default) to allow the 
 421         application to close even if this, presumably not very important, window 
 422         is still opened. By default, the application stays alive as long as 
 423         there are any open top level windows. 
 425     virtual bool ShouldPreventAppExit() const; 
 428         Depending on the value of @a show parameter the window is either shown 
 429         full screen or restored to its normal state. @a style is a bit list 
 430         containing some or all of the following values, which indicate what 
 431         elements of the window to hide in full-screen mode: 
 433         - @c ::wxFULLSCREEN_NOMENUBAR 
 434         - @c ::wxFULLSCREEN_NOTOOLBAR 
 435         - @c ::wxFULLSCREEN_NOSTATUSBAR 
 436         - @c ::wxFULLSCREEN_NOBORDER 
 437         - @c ::wxFULLSCREEN_NOCAPTION 
 438         - @c ::wxFULLSCREEN_ALL (all of the above) 
 440         This function has not been tested with MDI frames. 
 442         @note Showing a window full screen also actually @ref wxWindow::Show() 
 443               "Show()"s the window if it isn't shown. 
 447     virtual bool ShowFullScreen(bool show
, long style 
= wxFULLSCREEN_ALL
); 
 450         This method is specific to wxUniversal port. 
 452         Use native or custom-drawn decorations for this window only. Notice that 
 453         to have any effect this method must be called before really creating the 
 454         window, i.e. two step creation must be used: 
 457         MyFrame *frame = new MyFrame;       // use default ctor 
 458         frame->UseNativeDecorations(false); // change from default "true" 
 459         frame->Create(parent, title, ...);  // really create the frame 
 462         @see UseNativeDecorationsByDefault(), 
 463              IsUsingNativeDecorations() 
 465     void UseNativeDecorations(bool native 
= true); 
 468         This method is specific to wxUniversal port. 
 470         Top level windows in wxUniversal port can use either system-provided 
 471         window decorations (i.e. title bar and various icons, buttons and menus 
 472         in it) or draw the decorations themselves. By default the system 
 473         decorations are used if they are available, but this method can be 
 474         called with @a native set to @false to change this for all windows 
 475         created after this point. 
 477         Also note that if @c WXDECOR environment variable is set, then custom 
 478         decorations are used by default and so it may make sense to call this 
 479         method with default argument if the application can't use custom 
 480         decorations at all for some reason. 
 482         @see UseNativeDecorations() 
 484     void UseNativeDecorationsByDefault(bool native 
= true);