]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/toplevel.h
Make wxTopLevelWindow::GetDefaultSize() public and document it.
[wxWidgets.git] / interface / wx / toplevel.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: toplevel.h
3 // Purpose: interface of wxTopLevelWindow
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 Styles used with wxTopLevelWindow::RequestUserAttention().
11 */
12 enum
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 */
21 enum
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
37 /**
38 @class wxTopLevelWindow
39
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.
44
45 Note that the instances of wxTopLevelWindow are managed by wxWidgets in the
46 internal top level window list.
47
48 @beginEventEmissionTable
49 @event{EVT_ACTIVATE(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.
53 See wxMoveEvent.
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.
57 See wxMoveEvent.
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.
61 See wxMoveEvent.
62 @endEventTable
63
64 @library{wxcore}
65 @category{managedwnd}
66
67 @see wxDialog, wxFrame
68 */
69 class wxTopLevelWindow : public wxWindow
70 {
71 public:
72 /**
73 Default ctor.
74 */
75 wxTopLevelWindow();
76
77 /**
78 Constructor creating the top level window.
79 */
80 wxTopLevelWindow(wxWindow *parent,
81 wxWindowID winid,
82 const wxString& title,
83 const wxPoint& pos = wxDefaultPosition,
84 const wxSize& size = wxDefaultSize,
85 long style = wxDEFAULT_FRAME_STYLE,
86 const wxString& name = wxFrameNameStr);
87
88 /**
89 Destructor. Remember that wxTopLevelWindows do not get immediately
90 destroyed when the user (or the app) closes them; they have a
91 @b delayed destruction.
92
93 See @ref overview_windowdeletion for more info.
94 */
95 virtual ~wxTopLevelWindow();
96
97 /**
98 Creates the top level window.
99 */
100 bool Create(wxWindow *parent,
101 wxWindowID id,
102 const wxString& title,
103 const wxPoint& pos = wxDefaultPosition,
104 const wxSize& size = wxDefaultSize,
105 long style = wxDEFAULT_FRAME_STYLE,
106 const wxString& name = wxFrameNameStr);
107
108 /**
109 Returns @true if the platform supports making the window translucent.
110
111 @see SetTransparent()
112 */
113 virtual bool CanSetTransparent();
114
115 /**
116 A synonym for CentreOnScreen().
117 */
118 void CenterOnScreen(int direction);
119
120 /**
121 Centres the window on screen.
122
123 @param direction
124 Specifies the direction for the centering. May be @c wxHORIZONTAL,
125 @c wxVERTICAL or @c wxBOTH.
126
127 @see wxWindow::CentreOnParent()
128 */
129 void CentreOnScreen(int direction = wxBOTH);
130
131 /**
132 Enables or disables the Close button (most often in the right upper
133 corner of a dialog) and the Close entry of the system menu (most often
134 in the left upper corner of the dialog).
135
136 Currently only implemented for wxMSW and wxGTK.
137
138 Returns @true if operation was successful. This may be wrong on X11
139 (including GTK+) where the window manager may not support this operation
140 and there is no way to find out.
141 */
142 virtual bool EnableCloseButton(bool enable = true);
143
144 /**
145 Returns a pointer to the button which is the default for this window, or
146 @c @NULL. The default button is the one activated by pressing the Enter
147 key.
148 */
149 wxWindow* GetDefaultItem() const;
150
151 /**
152 Get the default size for a new top level window.
153
154 This is used internally by wxWidgets on some platforms to determine the
155 default size for a window created using ::wxDefaultSize so it is not
156 necessary to use it when creating a wxTopLevelWindow, however it may be
157 useful if a rough estimation of the window size is needed for some
158 other reason.
159
160 @since 2.9.2
161 */
162 static wxSize GetDefaultSize();
163
164 /**
165 Returns the standard icon of the window. The icon will be invalid if it
166 hadn't been previously set by SetIcon().
167
168 @see GetIcons()
169 */
170 wxIcon GetIcon() const;
171
172 /**
173 Returns all icons associated with the window, there will be none of them
174 if neither SetIcon() nor SetIcons() had been called before. Use
175 GetIcon() to get the main icon of the window.
176
177 @see wxIconBundle
178 */
179 const wxIconBundle& GetIcons() const;
180
181 /**
182 Gets a string containing the window title.
183
184 @see SetTitle()
185 */
186 virtual wxString GetTitle() const;
187
188 /**
189 Unique to the wxWinCE port. Responds to showing/hiding SIP (soft input
190 panel) area and resize window accordingly. Override this if you want to
191 avoid resizing or do additional operations.
192 */
193 virtual bool HandleSettingChange(WXWPARAM wParam,
194 WXLPARAM lParam);
195
196 /**
197 Iconizes or restores the window.
198
199 @param iconize
200 If @true, iconizes the window; if @false, shows and restores it.
201
202 @see IsIconized(), Maximize(), wxIconizeEvent.
203 */
204 virtual void Iconize(bool iconize = true);
205
206 /**
207 Returns @true if this window is currently active, i.e. if the user is
208 currently working with it.
209 */
210 virtual bool IsActive();
211
212 /**
213 Returns @true if this window is expected to be always maximized, either
214 due to platform policy or due to local policy regarding particular
215 class.
216 */
217 virtual bool IsAlwaysMaximized() const;
218
219 /**
220 Returns @true if the window is in fullscreen mode.
221
222 @see ShowFullScreen()
223 */
224 virtual bool IsFullScreen() const;
225
226 /**
227 Returns @true if the window is iconized.
228 */
229 virtual bool IsIconized() const;
230
231 /**
232 Returns @true if the window is maximized.
233 */
234 virtual bool IsMaximized() const;
235
236 /**
237 This method is specific to wxUniversal port.
238
239 Returns @true if this window is using native decorations, @false if we
240 draw them ourselves.
241
242 @see UseNativeDecorations(),
243 UseNativeDecorationsByDefault()
244 */
245 bool IsUsingNativeDecorations() const;
246
247 /**
248 See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
249 called automatically when the window is resized.
250 */
251 virtual bool Layout();
252
253 /**
254 Maximizes or restores the window.
255
256 @param maximize
257 If @true, maximizes the window, otherwise it restores it.
258
259 @see Iconize()
260 */
261 virtual void Maximize(bool maximize = true);
262
263 /**
264 Use a system-dependent way to attract users attention to the window when
265 it is in background.
266
267 @a flags may have the value of either @c ::wxUSER_ATTENTION_INFO
268 (default) or @c ::wxUSER_ATTENTION_ERROR which results in a more drastic
269 action. When in doubt, use the default value.
270
271
272 @note This function should normally be only used when the application
273 is not already in foreground.
274
275 This function is currently implemented for Win32 where it flashes
276 the window icon in the taskbar, and for wxGTK with task bars
277 supporting it.
278
279 */
280 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
281
282 /**
283 Changes the default item for the panel, usually @a win is a button.
284
285 @see GetDefaultItem()
286 */
287 wxWindow* SetDefaultItem(wxWindow* win);
288
289 /**
290 Sets the icon for this window.
291
292 @param icon
293 The wxIcon to associate with this window.
294
295 @remarks The window takes a 'copy' of @a icon, but since it uses
296 reference counting, the copy is very quick. It is safe to
297 delete @a icon after calling this function.
298
299 @note In wxMSW, @a icon must be either 16x16 or 32x32 icon.
300
301 @see wxIcon, SetIcons()
302 */
303 void SetIcon(const wxIcon& icon);
304
305 /**
306 Sets several icons of different sizes for this window: this allows to
307 use different icons for different situations (e.g. task switching bar,
308 taskbar, window title bar) instead of scaling, with possibly bad looking
309 results, the only icon set by SetIcon().
310
311 @param icons
312 The icons to associate with this window.
313
314 @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon,
315 preferably both.
316
317 @see wxIconBundle
318 */
319 virtual void SetIcons(const wxIconBundle& icons);
320
321 /**
322 Sets action or menu activated by pressing left hardware button on the
323 smart phones. Unavailable on full keyboard machines.
324
325 @param id
326 Identifier for this button.
327 @param label
328 Text to be displayed on the screen area dedicated to this hardware
329 button.
330 @param subMenu
331 The menu to be opened after pressing this hardware button.
332
333 @see SetRightMenu().
334 */
335 void SetLeftMenu(int id = wxID_ANY,
336 const wxString& label = wxEmptyString,
337 wxMenu* subMenu = NULL);
338
339 /**
340 A simpler interface for setting the size hints than SetSizeHints().
341 */
342 virtual void SetMaxSize(const wxSize& size);
343
344 /**
345 A simpler interface for setting the size hints than SetSizeHints().
346 */
347 virtual void SetMinSize(const wxSize& size);
348
349 /**
350 Sets action or menu activated by pressing right hardware button on the
351 smart phones. Unavailable on full keyboard machines.
352
353 @param id
354 Identifier for this button.
355 @param label
356 Text to be displayed on the screen area dedicated to this hardware
357 button.
358 @param subMenu
359 The menu to be opened after pressing this hardware button.
360
361 @see SetLeftMenu().
362 */
363 void SetRightMenu(int id = wxID_ANY,
364 const wxString& label = wxEmptyString,
365 wxMenu* subMenu = NULL);
366
367 /**
368 If the platform supports it, sets the shape of the window to that
369 depicted by @a region. The system will not display or respond to any
370 mouse event for the pixels that lie outside of the region. To reset the
371 window to the normal rectangular shape simply call SetShape() again with
372 an empty wxRegion. Returns @true if the operation is successful.
373 */
374 virtual bool SetShape(const wxRegion& region);
375
376 /**
377 Allows specification of minimum and maximum window sizes, and window
378 size increments. If a pair of values is not set (or set to -1), no
379 constraints will be used.
380
381 @param minW
382 The minimum width.
383 @param minH
384 The minimum height.
385 @param maxW
386 The maximum width.
387 @param maxH
388 The maximum height.
389 @param incW
390 Specifies the increment for sizing the width (GTK/Motif/Xt only).
391 @param incH
392 Specifies the increment for sizing the height (GTK/Motif/Xt only).
393
394 @remarks Notice that this function not only prevents the user from
395 resizing the window outside the given bounds but it also
396 prevents the program itself from doing it using
397 wxWindow::SetSize().
398
399 */
400 virtual void SetSizeHints(int minW, int minH,
401 int maxW = -1, int maxH = -1,
402 int incW = -1, int incH = -1);
403
404 /**
405 Allows specification of minimum and maximum window sizes, and window
406 size increments. If a pair of values is not set (or set to -1), no
407 constraints will be used.
408
409 @param minSize
410 The minimum size of the window.
411 @param maxSize
412 The maximum size of the window.
413 @param incSize
414 Increment size (only taken into account under X11-based ports such
415 as wxGTK/wxMotif/wxX11).
416
417 @remarks Notice that this function not only prevents the user from
418 resizing the window outside the given bounds but it also
419 prevents the program itself from doing it using
420 wxWindow::SetSize().
421 */
422 void SetSizeHints(const wxSize& minSize,
423 const wxSize& maxSize = wxDefaultSize,
424 const wxSize& incSize = wxDefaultSize);
425
426 /**
427 Sets the window title.
428
429 @param title
430 The window title.
431
432 @see GetTitle()
433 */
434 virtual void SetTitle(const wxString& title);
435
436 /**
437 If the platform supports it will set the window to be translucent.
438
439 @param alpha
440 Determines how opaque or transparent the window will be, if the
441 platform supports the opreration. A value of 0 sets the window to be
442 fully transparent, and a value of 255 sets the window to be fully
443 opaque.
444 */
445 virtual bool SetTransparent(wxByte alpha);
446
447 /**
448 This virtual function is not meant to be called directly but can be
449 overridden to return @false (it returns @true by default) to allow the
450 application to close even if this, presumably not very important, window
451 is still opened. By default, the application stays alive as long as
452 there are any open top level windows.
453 */
454 virtual bool ShouldPreventAppExit() const;
455
456 /**
457 This function sets the wxTopLevelWindow's modified state on OS X,
458 which currently draws a black dot in the wxTopLevelWindow's close button.
459 On other platforms, this method does nothing.
460
461 @see OSXIsModified()
462 */
463 virtual void OSXSetModified(bool modified);
464
465 /**
466 Returns the current modified state of the wxTopLevelWindow on OS X.
467 On other platforms, this method does nothing.
468
469 @see OSXSetModified()
470 */
471 virtual bool OSXIsModified() const;
472
473 /**
474 Depending on the value of @a show parameter the window is either shown
475 full screen or restored to its normal state. @a style is a bit list
476 containing some or all of the following values, which indicate what
477 elements of the window to hide in full-screen mode:
478
479 - @c ::wxFULLSCREEN_NOMENUBAR
480 - @c ::wxFULLSCREEN_NOTOOLBAR
481 - @c ::wxFULLSCREEN_NOSTATUSBAR
482 - @c ::wxFULLSCREEN_NOBORDER
483 - @c ::wxFULLSCREEN_NOCAPTION
484 - @c ::wxFULLSCREEN_ALL (all of the above)
485
486 This function has not been tested with MDI frames.
487
488 @note Showing a window full screen also actually @ref wxWindow::Show()
489 "Show()"s the window if it isn't shown.
490
491 @see IsFullScreen()
492 */
493 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
494
495 /**
496 This method is specific to wxUniversal port.
497
498 Use native or custom-drawn decorations for this window only. Notice that
499 to have any effect this method must be called before really creating the
500 window, i.e. two step creation must be used:
501
502 @code
503 MyFrame *frame = new MyFrame; // use default ctor
504 frame->UseNativeDecorations(false); // change from default "true"
505 frame->Create(parent, title, ...); // really create the frame
506 @endcode
507
508 @see UseNativeDecorationsByDefault(),
509 IsUsingNativeDecorations()
510 */
511 void UseNativeDecorations(bool native = true);
512
513 /**
514 This method is specific to wxUniversal port.
515
516 Top level windows in wxUniversal port can use either system-provided
517 window decorations (i.e. title bar and various icons, buttons and menus
518 in it) or draw the decorations themselves. By default the system
519 decorations are used if they are available, but this method can be
520 called with @a native set to @false to change this for all windows
521 created after this point.
522
523 Also note that if @c WXDECOR environment variable is set, then custom
524 decorations are used by default and so it may make sense to call this
525 method with default argument if the application can't use custom
526 decorations at all for some reason.
527
528 @see UseNativeDecorations()
529 */
530 void UseNativeDecorationsByDefault(bool native = true);
531 };
532