]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/toplevel.h
describe wxMemory* streams
[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
afc31d8a
FM
45 Note that the instances of wxTopLevelWindow are managed by wxWidgets in the
46 internal top level window list.
47
23324ae1
FM
48 @library{wxcore}
49 @category{managedwnd}
7c913512 50
f992f2ae 51 @see wxDialog, wxFrame
23324ae1
FM
52*/
53class wxTopLevelWindow : public wxWindow
54{
55public:
2e4f32d7
FM
56 /**
57 Default ctor.
58 */
59 wxTopLevelWindow();
60
61 /**
62 Constructor creating the top level window.
63 */
64 wxTopLevelWindow(wxWindow *parent,
65 wxWindowID winid,
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);
71
72 /**
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.
76
77 See @ref overview_windowdeletion for more info.
78 */
79 virtual ~wxTopLevelWindow();
80
81 /**
82 Creates the top level window.
83 */
84 bool Create(wxWindow *parent,
85 wxWindowID id,
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);
91
23324ae1
FM
92 /**
93 Returns @true if the platform supports making the window translucent.
3c4f71cc 94
4cc4bfaf 95 @see SetTransparent()
23324ae1
FM
96 */
97 virtual bool CanSetTransparent();
98
99 /**
100 A synonym for CentreOnScreen().
101 */
102 void CenterOnScreen(int direction);
103
104 /**
105 Centres the window on screen.
3c4f71cc 106
7c913512 107 @param direction
f992f2ae
BP
108 Specifies the direction for the centering. May be @c wxHORIZONTAL,
109 @c wxVERTICAL or @c wxBOTH.
3c4f71cc 110
f992f2ae 111 @see wxWindow::CentreOnParent()
23324ae1
FM
112 */
113 void CentreOnScreen(int direction = wxBOTH);
114
115 /**
f992f2ae
BP
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).
119
120 Currently only implemented for wxMSW and wxGTK.
121
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.
23324ae1 125 */
0004982c 126 virtual bool EnableCloseButton(bool enable = true);
23324ae1
FM
127
128 /**
f992f2ae
BP
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
131 key.
23324ae1 132 */
328f5751 133 wxWindow* GetDefaultItem() const;
23324ae1
FM
134
135 /**
f992f2ae
BP
136 Returns the standard icon of the window. The icon will be invalid if it
137 hadn't been previously set by SetIcon().
3c4f71cc 138
4cc4bfaf 139 @see GetIcons()
23324ae1 140 */
cfbe5614 141 wxIcon GetIcon() const;
23324ae1
FM
142
143 /**
f992f2ae
BP
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.
3c4f71cc 147
4cc4bfaf 148 @see wxIconBundle
23324ae1 149 */
cfbe5614 150 const wxIconBundle& GetIcons() const;
23324ae1
FM
151
152 /**
153 Gets a string containing the window title.
3c4f71cc 154
4cc4bfaf 155 @see SetTitle()
23324ae1 156 */
0004982c 157 virtual wxString GetTitle() const;
23324ae1
FM
158
159 /**
f992f2ae
BP
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.
23324ae1
FM
163 */
164 virtual bool HandleSettingChange(WXWPARAM wParam,
165 WXLPARAM lParam);
166
167 /**
168 Iconizes or restores the window.
3c4f71cc 169
7c913512 170 @param iconize
4cc4bfaf 171 If @true, iconizes the window; if @false, shows and restores it.
3c4f71cc 172
d317fdeb 173 @see IsIconized(), Maximize(), wxIconizeEvent.
23324ae1 174 */
cfbe5614 175 virtual void Iconize(bool iconize = true);
23324ae1
FM
176
177 /**
178 Returns @true if this window is currently active, i.e. if the user is
f992f2ae 179 currently working with it.
23324ae1 180 */
adaaa686 181 virtual bool IsActive();
23324ae1
FM
182
183 /**
f992f2ae
BP
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
186 class.
23324ae1 187 */
328f5751 188 virtual bool IsAlwaysMaximized() const;
23324ae1
FM
189
190 /**
191 Returns @true if the window is in fullscreen mode.
3c4f71cc 192
4cc4bfaf 193 @see ShowFullScreen()
23324ae1 194 */
0004982c 195 virtual bool IsFullScreen() const;
23324ae1
FM
196
197 /**
198 Returns @true if the window is iconized.
199 */
0004982c 200 virtual bool IsIconized() const;
23324ae1
FM
201
202 /**
203 Returns @true if the window is maximized.
204 */
0004982c 205 virtual bool IsMaximized() const;
23324ae1
FM
206
207 /**
f992f2ae
BP
208 This method is specific to wxUniversal port.
209
210 Returns @true if this window is using native decorations, @false if we
211 draw them ourselves.
3c4f71cc 212
4cc4bfaf
FM
213 @see UseNativeDecorations(),
214 UseNativeDecorationsByDefault()
23324ae1 215 */
328f5751 216 bool IsUsingNativeDecorations() const;
23324ae1 217
dcc5fcbf
FM
218 /**
219 See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
220 called automatically when the window is resized.
221 */
222 virtual bool Layout();
223
23324ae1
FM
224 /**
225 Maximizes or restores the window.
3c4f71cc 226
7c913512 227 @param maximize
4cc4bfaf 228 If @true, maximizes the window, otherwise it restores it.
3c4f71cc 229
4cc4bfaf 230 @see Iconize()
23324ae1 231 */
cfbe5614 232 virtual void Maximize(bool maximize = true);
23324ae1
FM
233
234 /**
f992f2ae
BP
235 Use a system-dependent way to attract users attention to the window when
236 it is in background.
237
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
23324ae1 240 action. When in doubt, use the default value.
f992f2ae
BP
241
242
243 @note This function should normally be only used when the application
244 is not already in foreground.
245
246 This function is currently implemented for Win32 where it flashes
247 the window icon in the taskbar, and for wxGTK with task bars
248 supporting it.
249
23324ae1 250 */
adaaa686 251 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
23324ae1
FM
252
253 /**
4cc4bfaf 254 Changes the default item for the panel, usually @a win is a button.
3c4f71cc 255
4cc4bfaf 256 @see GetDefaultItem()
23324ae1 257 */
cfbe5614 258 wxWindow* SetDefaultItem(wxWindow* win);
23324ae1
FM
259
260 /**
261 Sets the icon for this window.
3c4f71cc 262
7c913512 263 @param icon
f992f2ae
BP
264 The wxIcon to associate with this window.
265
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.
3c4f71cc 269
0f278d77
VS
270 @note In wxMSW, @a icon must be either 16x16 or 32x32 icon.
271
272 @see wxIcon, SetIcons()
23324ae1
FM
273 */
274 void SetIcon(const wxIcon& icon);
275
276 /**
f992f2ae
BP
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().
3c4f71cc 281
7c913512 282 @param icons
4cc4bfaf 283 The icons to associate with this window.
3c4f71cc 284
0f278d77
VS
285 @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon,
286 preferably both.
287
288 @see wxIconBundle
23324ae1 289 */
adaaa686 290 virtual void SetIcons(const wxIconBundle& icons);
23324ae1
FM
291
292 /**
f992f2ae
BP
293 Sets action or menu activated by pressing left hardware button on the
294 smart phones. Unavailable on full keyboard machines.
3c4f71cc 295
7c913512 296 @param id
4cc4bfaf 297 Identifier for this button.
7c913512 298 @param label
f992f2ae
BP
299 Text to be displayed on the screen area dedicated to this hardware
300 button.
7c913512 301 @param subMenu
4cc4bfaf 302 The menu to be opened after pressing this hardware button.
3c4f71cc 303
4cc4bfaf 304 @see SetRightMenu().
23324ae1
FM
305 */
306 void SetLeftMenu(int id = wxID_ANY,
307 const wxString& label = wxEmptyString,
4cc4bfaf 308 wxMenu* subMenu = NULL);
23324ae1
FM
309
310 /**
f992f2ae 311 A simpler interface for setting the size hints than SetSizeHints().
23324ae1 312 */
adaaa686 313 virtual void SetMaxSize(const wxSize& size);
23324ae1
FM
314
315 /**
f992f2ae 316 A simpler interface for setting the size hints than SetSizeHints().
23324ae1 317 */
adaaa686 318 virtual void SetMinSize(const wxSize& size);
23324ae1
FM
319
320 /**
f992f2ae
BP
321 Sets action or menu activated by pressing right hardware button on the
322 smart phones. Unavailable on full keyboard machines.
3c4f71cc 323
7c913512 324 @param id
4cc4bfaf 325 Identifier for this button.
7c913512 326 @param label
f992f2ae 327 Text to be displayed on the screen area dedicated to this hardware
77bfb902 328 button.
7c913512 329 @param subMenu
4cc4bfaf 330 The menu to be opened after pressing this hardware button.
3c4f71cc 331
4cc4bfaf 332 @see SetLeftMenu().
23324ae1
FM
333 */
334 void SetRightMenu(int id = wxID_ANY,
335 const wxString& label = wxEmptyString,
4cc4bfaf 336 wxMenu* subMenu = NULL);
23324ae1
FM
337
338 /**
339 If the platform supports it, sets the shape of the window to that
f992f2ae
BP
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.
23324ae1 344 */
adaaa686 345 virtual bool SetShape(const wxRegion& region);
23324ae1 346
23324ae1 347 /**
f992f2ae
BP
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.
3c4f71cc 351
77bfb902
FM
352 @param minW
353 The minimum width.
354 @param minH
355 The minimum height.
356 @param maxW
357 The maximum width.
358 @param maxH
359 The maximum height.
7c913512 360 @param incW
4cc4bfaf 361 Specifies the increment for sizing the width (GTK/Motif/Xt only).
7c913512 362 @param incH
4cc4bfaf 363 Specifies the increment for sizing the height (GTK/Motif/Xt only).
3c4f71cc 364
23324ae1 365 @remarks Notice that this function not only prevents the user from
f992f2ae
BP
366 resizing the window outside the given bounds but it also
367 prevents the program itself from doing it using
368 wxWindow::SetSize().
369
4cc4bfaf 370 */
77bfb902
FM
371 virtual void SetSizeHints(int minW, int minH,
372 int maxW = -1, int maxH = -1,
373 int incW = -1, int incH = -1);
f992f2ae
BP
374
375 /**
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.
379
77bfb902
FM
380 @param minSize
381 The minimum size of the window.
382 @param maxSize
383 The maximum size of the window.
f992f2ae
BP
384 @param incSize
385 Increment size (only taken into account under X11-based ports such
386 as wxGTK/wxMotif/wxX11).
387
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
391 wxWindow::SetSize().
392 */
7c913512 393 void SetSizeHints(const wxSize& minSize,
4cc4bfaf
FM
394 const wxSize& maxSize = wxDefaultSize,
395 const wxSize& incSize = wxDefaultSize);
23324ae1
FM
396
397 /**
398 Sets the window title.
3c4f71cc 399
7c913512 400 @param title
4cc4bfaf 401 The window title.
3c4f71cc 402
4cc4bfaf 403 @see GetTitle()
23324ae1
FM
404 */
405 virtual void SetTitle(const wxString& title);
406
407 /**
f992f2ae 408 If the platform supports it will set the window to be translucent.
3c4f71cc 409
7c913512 410 @param alpha
f992f2ae
BP
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
414 opaque.
23324ae1 415 */
cfbe5614 416 virtual bool SetTransparent(wxByte alpha);
23324ae1
FM
417
418 /**
f992f2ae
BP
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.
23324ae1 424 */
328f5751 425 virtual bool ShouldPreventAppExit() const;
23324ae1
FM
426
427 /**
f992f2ae
BP
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:
432
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)
439
23324ae1 440 This function has not been tested with MDI frames.
f992f2ae
BP
441
442 @note Showing a window full screen also actually @ref wxWindow::Show()
443 "Show()"s the window if it isn't shown.
3c4f71cc 444
4cc4bfaf 445 @see IsFullScreen()
23324ae1 446 */
0004982c 447 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
23324ae1
FM
448
449 /**
f992f2ae
BP
450 This method is specific to wxUniversal port.
451
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:
455
456 @code
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
460 @endcode
3c4f71cc 461
4cc4bfaf
FM
462 @see UseNativeDecorationsByDefault(),
463 IsUsingNativeDecorations()
23324ae1 464 */
4cc4bfaf 465 void UseNativeDecorations(bool native = true);
23324ae1
FM
466
467 /**
f992f2ae
BP
468 This method is specific to wxUniversal port.
469
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.
476
23324ae1 477 Also note that if @c WXDECOR environment variable is set, then custom
f992f2ae
BP
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.
77bfb902 481
f992f2ae 482 @see UseNativeDecorations()
23324ae1 483 */
4cc4bfaf 484 void UseNativeDecorationsByDefault(bool native = true);
23324ae1 485};
e54c96f1 486