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