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