]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/toplevel.h
Fudge offset no longer required
[wxWidgets.git] / interface / wx / toplevel.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: toplevel.h
e54c96f1 3// Purpose: interface of wxTopLevelWindow
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
f992f2ae
BP
9/**
10 Styles used with wxTopLevelWindow::RequestUserAttention().
11*/
12enum
13{
14 wxUSER_ATTENTION_INFO = 1, ///< Requests user attention,
15 wxUSER_ATTENTION_ERROR = 2 ///< Results in a more drastic action.
16};
17
18/**
19 Styles used with wxTopLevelWindow::ShowFullScreen().
20*/
21enum
22{
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.
28
29 /**
30 Combination of all above, will display the least possible.
31 */
32 wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR |
33 wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER |
34 wxFULLSCREEN_NOCAPTION
35};
36
23324ae1
FM
37/**
38 @class wxTopLevelWindow
7c913512 39
f992f2ae
BP
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
43 above.
7c913512 44
23324ae1
FM
45 @library{wxcore}
46 @category{managedwnd}
7c913512 47
f992f2ae 48 @see wxDialog, wxFrame
23324ae1
FM
49*/
50class wxTopLevelWindow : public wxWindow
51{
52public:
53 /**
54 Returns @true if the platform supports making the window translucent.
3c4f71cc 55
4cc4bfaf 56 @see SetTransparent()
23324ae1
FM
57 */
58 virtual bool CanSetTransparent();
59
60 /**
61 A synonym for CentreOnScreen().
62 */
63 void CenterOnScreen(int direction);
64
65 /**
66 Centres the window on screen.
3c4f71cc 67
7c913512 68 @param direction
f992f2ae
BP
69 Specifies the direction for the centering. May be @c wxHORIZONTAL,
70 @c wxVERTICAL or @c wxBOTH.
3c4f71cc 71
f992f2ae 72 @see wxWindow::CentreOnParent()
23324ae1
FM
73 */
74 void CentreOnScreen(int direction = wxBOTH);
75
76 /**
f992f2ae
BP
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).
80
81 Currently only implemented for wxMSW and wxGTK.
82
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.
23324ae1 86 */
0004982c 87 virtual bool EnableCloseButton(bool enable = true);
23324ae1
FM
88
89 /**
f992f2ae
BP
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
92 key.
23324ae1 93 */
328f5751 94 wxWindow* GetDefaultItem() const;
23324ae1
FM
95
96 /**
f992f2ae
BP
97 Returns the standard icon of the window. The icon will be invalid if it
98 hadn't been previously set by SetIcon().
3c4f71cc 99
4cc4bfaf 100 @see GetIcons()
23324ae1 101 */
328f5751 102 const wxIcon GetIcon() const;
23324ae1
FM
103
104 /**
f992f2ae
BP
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.
3c4f71cc 108
4cc4bfaf 109 @see wxIconBundle
23324ae1 110 */
328f5751 111 const wxIconBundle GetIcons() const;
23324ae1
FM
112
113 /**
114 Gets a string containing the window title.
3c4f71cc 115
4cc4bfaf 116 @see SetTitle()
23324ae1 117 */
0004982c 118 virtual wxString GetTitle() const;
23324ae1
FM
119
120 /**
f992f2ae
BP
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.
23324ae1
FM
124 */
125 virtual bool HandleSettingChange(WXWPARAM wParam,
126 WXLPARAM lParam);
127
128 /**
129 Iconizes or restores the window.
3c4f71cc 130
7c913512 131 @param iconize
4cc4bfaf 132 If @true, iconizes the window; if @false, shows and restores it.
3c4f71cc 133
d317fdeb 134 @see IsIconized(), Maximize(), wxIconizeEvent.
23324ae1
FM
135 */
136 void Iconize(bool iconize);
137
138 /**
139 Returns @true if this window is currently active, i.e. if the user is
f992f2ae 140 currently working with it.
23324ae1 141 */
adaaa686 142 virtual bool IsActive();
23324ae1
FM
143
144 /**
f992f2ae
BP
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
147 class.
23324ae1 148 */
328f5751 149 virtual bool IsAlwaysMaximized() const;
23324ae1
FM
150
151 /**
152 Returns @true if the window is in fullscreen mode.
3c4f71cc 153
4cc4bfaf 154 @see ShowFullScreen()
23324ae1 155 */
0004982c 156 virtual bool IsFullScreen() const;
23324ae1
FM
157
158 /**
159 Returns @true if the window is iconized.
160 */
0004982c 161 virtual bool IsIconized() const;
23324ae1
FM
162
163 /**
164 Returns @true if the window is maximized.
165 */
0004982c 166 virtual bool IsMaximized() const;
23324ae1
FM
167
168 /**
f992f2ae
BP
169 This method is specific to wxUniversal port.
170
171 Returns @true if this window is using native decorations, @false if we
172 draw them ourselves.
3c4f71cc 173
4cc4bfaf
FM
174 @see UseNativeDecorations(),
175 UseNativeDecorationsByDefault()
23324ae1 176 */
328f5751 177 bool IsUsingNativeDecorations() const;
23324ae1
FM
178
179 /**
180 Maximizes or restores the window.
3c4f71cc 181
7c913512 182 @param maximize
4cc4bfaf 183 If @true, maximizes the window, otherwise it restores it.
3c4f71cc 184
4cc4bfaf 185 @see Iconize()
23324ae1
FM
186 */
187 void Maximize(bool maximize);
188
189 /**
f992f2ae
BP
190 Use a system-dependent way to attract users attention to the window when
191 it is in background.
192
193 @a flags may have the value of either @c ::wxUSER_ATTENTION_INFO
194 (default) or @c ::wxUSER_ATTENTION_ERROR which results in a more drastic
23324ae1 195 action. When in doubt, use the default value.
f992f2ae
BP
196
197
198 @note This function should normally be only used when the application
199 is not already in foreground.
200
201 This function is currently implemented for Win32 where it flashes
202 the window icon in the taskbar, and for wxGTK with task bars
203 supporting it.
204
23324ae1 205 */
adaaa686 206 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
23324ae1
FM
207
208 /**
4cc4bfaf 209 Changes the default item for the panel, usually @a win is a button.
3c4f71cc 210
4cc4bfaf 211 @see GetDefaultItem()
23324ae1 212 */
f992f2ae 213 void SetDefaultItem(wxWindow* win);
23324ae1
FM
214
215 /**
216 Sets the icon for this window.
3c4f71cc 217
7c913512 218 @param icon
f992f2ae
BP
219 The wxIcon to associate with this window.
220
221 @remarks The window takes a 'copy' of @a icon, but since it uses
222 reference counting, the copy is very quick. It is safe to
223 delete @a icon after calling this function.
3c4f71cc 224
f992f2ae 225 @see wxIcon
23324ae1
FM
226 */
227 void SetIcon(const wxIcon& icon);
228
229 /**
f992f2ae
BP
230 Sets several icons of different sizes for this window: this allows to
231 use different icons for different situations (e.g. task switching bar,
232 taskbar, window title bar) instead of scaling, with possibly bad looking
233 results, the only icon set by SetIcon().
3c4f71cc 234
7c913512 235 @param icons
4cc4bfaf 236 The icons to associate with this window.
3c4f71cc 237
4cc4bfaf 238 @see wxIconBundle.
23324ae1 239 */
adaaa686 240 virtual void SetIcons(const wxIconBundle& icons);
23324ae1
FM
241
242 /**
f992f2ae
BP
243 Sets action or menu activated by pressing left hardware button on the
244 smart phones. Unavailable on full keyboard machines.
3c4f71cc 245
7c913512 246 @param id
4cc4bfaf 247 Identifier for this button.
7c913512 248 @param label
f992f2ae
BP
249 Text to be displayed on the screen area dedicated to this hardware
250 button.
7c913512 251 @param subMenu
4cc4bfaf 252 The menu to be opened after pressing this hardware button.
3c4f71cc 253
4cc4bfaf 254 @see SetRightMenu().
23324ae1
FM
255 */
256 void SetLeftMenu(int id = wxID_ANY,
257 const wxString& label = wxEmptyString,
4cc4bfaf 258 wxMenu* subMenu = NULL);
23324ae1
FM
259
260 /**
f992f2ae 261 A simpler interface for setting the size hints than SetSizeHints().
23324ae1 262 */
adaaa686 263 virtual void SetMaxSize(const wxSize& size);
23324ae1
FM
264
265 /**
f992f2ae 266 A simpler interface for setting the size hints than SetSizeHints().
23324ae1 267 */
adaaa686 268 virtual void SetMinSize(const wxSize& size);
23324ae1
FM
269
270 /**
f992f2ae
BP
271 Sets action or menu activated by pressing right hardware button on the
272 smart phones. Unavailable on full keyboard machines.
3c4f71cc 273
7c913512 274 @param id
4cc4bfaf 275 Identifier for this button.
7c913512 276 @param label
f992f2ae 277 Text to be displayed on the screen area dedicated to this hardware
77bfb902 278 button.
7c913512 279 @param subMenu
4cc4bfaf 280 The menu to be opened after pressing this hardware button.
3c4f71cc 281
4cc4bfaf 282 @see SetLeftMenu().
23324ae1
FM
283 */
284 void SetRightMenu(int id = wxID_ANY,
285 const wxString& label = wxEmptyString,
4cc4bfaf 286 wxMenu* subMenu = NULL);
23324ae1
FM
287
288 /**
289 If the platform supports it, sets the shape of the window to that
f992f2ae
BP
290 depicted by @a region. The system will not display or respond to any
291 mouse event for the pixels that lie outside of the region. To reset the
292 window to the normal rectangular shape simply call SetShape() again with
293 an empty wxRegion. Returns @true if the operation is successful.
23324ae1 294 */
adaaa686 295 virtual bool SetShape(const wxRegion& region);
23324ae1 296
23324ae1 297 /**
f992f2ae
BP
298 Allows specification of minimum and maximum window sizes, and window
299 size increments. If a pair of values is not set (or set to -1), no
300 constraints will be used.
3c4f71cc 301
77bfb902
FM
302 @param minW
303 The minimum width.
304 @param minH
305 The minimum height.
306 @param maxW
307 The maximum width.
308 @param maxH
309 The maximum height.
7c913512 310 @param incW
4cc4bfaf 311 Specifies the increment for sizing the width (GTK/Motif/Xt only).
7c913512 312 @param incH
4cc4bfaf 313 Specifies the increment for sizing the height (GTK/Motif/Xt only).
3c4f71cc 314
23324ae1 315 @remarks Notice that this function not only prevents the user from
f992f2ae
BP
316 resizing the window outside the given bounds but it also
317 prevents the program itself from doing it using
318 wxWindow::SetSize().
319
4cc4bfaf 320 */
77bfb902
FM
321 virtual void SetSizeHints(int minW, int minH,
322 int maxW = -1, int maxH = -1,
323 int incW = -1, int incH = -1);
f992f2ae
BP
324
325 /**
326 Allows specification of minimum and maximum window sizes, and window
327 size increments. If a pair of values is not set (or set to -1), no
328 constraints will be used.
329
77bfb902
FM
330 @param minSize
331 The minimum size of the window.
332 @param maxSize
333 The maximum size of the window.
f992f2ae
BP
334 @param incSize
335 Increment size (only taken into account under X11-based ports such
336 as wxGTK/wxMotif/wxX11).
337
338 @remarks Notice that this function not only prevents the user from
339 resizing the window outside the given bounds but it also
340 prevents the program itself from doing it using
341 wxWindow::SetSize().
342 */
7c913512 343 void SetSizeHints(const wxSize& minSize,
4cc4bfaf
FM
344 const wxSize& maxSize = wxDefaultSize,
345 const wxSize& incSize = wxDefaultSize);
23324ae1
FM
346
347 /**
348 Sets the window title.
3c4f71cc 349
7c913512 350 @param title
4cc4bfaf 351 The window title.
3c4f71cc 352
4cc4bfaf 353 @see GetTitle()
23324ae1
FM
354 */
355 virtual void SetTitle(const wxString& title);
356
357 /**
f992f2ae 358 If the platform supports it will set the window to be translucent.
3c4f71cc 359
7c913512 360 @param alpha
f992f2ae
BP
361 Determines how opaque or transparent the window will be, if the
362 platform supports the opreration. A value of 0 sets the window to be
363 fully transparent, and a value of 255 sets the window to be fully
364 opaque.
23324ae1
FM
365 */
366 virtual bool SetTransparent(int alpha);
367
368 /**
f992f2ae
BP
369 This virtual function is not meant to be called directly but can be
370 overridden to return @false (it returns @true by default) to allow the
371 application to close even if this, presumably not very important, window
372 is still opened. By default, the application stays alive as long as
373 there are any open top level windows.
23324ae1 374 */
328f5751 375 virtual bool ShouldPreventAppExit() const;
23324ae1
FM
376
377 /**
f992f2ae
BP
378 Depending on the value of @a show parameter the window is either shown
379 full screen or restored to its normal state. @a style is a bit list
380 containing some or all of the following values, which indicate what
381 elements of the window to hide in full-screen mode:
382
383 - @c ::wxFULLSCREEN_NOMENUBAR
384 - @c ::wxFULLSCREEN_NOTOOLBAR
385 - @c ::wxFULLSCREEN_NOSTATUSBAR
386 - @c ::wxFULLSCREEN_NOBORDER
387 - @c ::wxFULLSCREEN_NOCAPTION
388 - @c ::wxFULLSCREEN_ALL (all of the above)
389
23324ae1 390 This function has not been tested with MDI frames.
f992f2ae
BP
391
392 @note Showing a window full screen also actually @ref wxWindow::Show()
393 "Show()"s the window if it isn't shown.
3c4f71cc 394
4cc4bfaf 395 @see IsFullScreen()
23324ae1 396 */
0004982c 397 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
23324ae1
FM
398
399 /**
f992f2ae
BP
400 This method is specific to wxUniversal port.
401
402 Use native or custom-drawn decorations for this window only. Notice that
403 to have any effect this method must be called before really creating the
404 window, i.e. two step creation must be used:
405
406 @code
407 MyFrame *frame = new MyFrame; // use default ctor
408 frame->UseNativeDecorations(false); // change from default "true"
409 frame->Create(parent, title, ...); // really create the frame
410 @endcode
3c4f71cc 411
4cc4bfaf
FM
412 @see UseNativeDecorationsByDefault(),
413 IsUsingNativeDecorations()
23324ae1 414 */
4cc4bfaf 415 void UseNativeDecorations(bool native = true);
23324ae1
FM
416
417 /**
f992f2ae
BP
418 This method is specific to wxUniversal port.
419
420 Top level windows in wxUniversal port can use either system-provided
421 window decorations (i.e. title bar and various icons, buttons and menus
422 in it) or draw the decorations themselves. By default the system
423 decorations are used if they are available, but this method can be
424 called with @a native set to @false to change this for all windows
425 created after this point.
426
23324ae1 427 Also note that if @c WXDECOR environment variable is set, then custom
f992f2ae
BP
428 decorations are used by default and so it may make sense to call this
429 method with default argument if the application can't use custom
430 decorations at all for some reason.
77bfb902 431
f992f2ae 432 @see UseNativeDecorations()
23324ae1 433 */
4cc4bfaf 434 void UseNativeDecorationsByDefault(bool native = true);
23324ae1 435};
e54c96f1 436