]> git.saurik.com Git - wxWidgets.git/blob - interface/toplevel.h
add wxShowEvent::IsShown() and wxIconizeEvent::IsIconized() instead of (now deprecate...
[wxWidgets.git] / interface / toplevel.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: toplevel.h
3 // Purpose: interface of wxTopLevelWindow
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
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 @wxheader{toplevel.h}
40
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.
45
46 @library{wxcore}
47 @category{managedwnd}
48
49 @see wxDialog, wxFrame
50 */
51 class wxTopLevelWindow : public wxWindow
52 {
53 public:
54 /**
55 Returns @true if the platform supports making the window translucent.
56
57 @see SetTransparent()
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.
68
69 @param direction
70 Specifies the direction for the centering. May be @c wxHORIZONTAL,
71 @c wxVERTICAL or @c wxBOTH.
72
73 @see wxWindow::CentreOnParent()
74 */
75 void CentreOnScreen(int direction = wxBOTH);
76
77 /**
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.
87 */
88 bool EnableCloseButton(bool enable = true);
89
90 /**
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.
94 */
95 wxWindow* GetDefaultItem() const;
96
97 /**
98 Returns the standard icon of the window. The icon will be invalid if it
99 hadn't been previously set by SetIcon().
100
101 @see GetIcons()
102 */
103 const wxIcon GetIcon() const;
104
105 /**
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.
109
110 @see wxIconBundle
111 */
112 const wxIconBundle GetIcons() const;
113
114 /**
115 Gets a string containing the window title.
116
117 @see SetTitle()
118 */
119 wxString GetTitle() const;
120
121 /**
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.
125 */
126 virtual bool HandleSettingChange(WXWPARAM wParam,
127 WXLPARAM lParam);
128
129 /**
130 Iconizes or restores the window.
131
132 @param iconize
133 If @true, iconizes the window; if @false, shows and restores it.
134
135 @see IsIconized(), Maximize(), wxIconizeEvent.
136 */
137 void Iconize(bool iconize);
138
139 /**
140 Returns @true if this window is currently active, i.e. if the user is
141 currently working with it.
142 */
143 bool IsActive() const;
144
145 /**
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.
149 */
150 virtual bool IsAlwaysMaximized() const;
151
152 /**
153 Returns @true if the window is in fullscreen mode.
154
155 @see ShowFullScreen()
156 */
157 bool IsFullScreen();
158
159 /**
160 Returns @true if the window is iconized.
161 */
162 bool IsIconized() const;
163
164 /**
165 Returns @true if the window is maximized.
166 */
167 bool IsMaximized() const;
168
169 /**
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.
174
175 @see UseNativeDecorations(),
176 UseNativeDecorationsByDefault()
177 */
178 bool IsUsingNativeDecorations() const;
179
180 /**
181 Maximizes or restores the window.
182
183 @param maximize
184 If @true, maximizes the window, otherwise it restores it.
185
186 @see Iconize()
187 */
188 void Maximize(bool maximize);
189
190 /**
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
196 action. When in doubt, use the default value.
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
206 */
207 void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
208
209 /**
210 Changes the default item for the panel, usually @a win is a button.
211
212 @see GetDefaultItem()
213 */
214 void SetDefaultItem(wxWindow* win);
215
216 /**
217 Sets the icon for this window.
218
219 @param icon
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.
225
226 @see wxIcon
227 */
228 void SetIcon(const wxIcon& icon);
229
230 /**
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().
235
236 @param icons
237 The icons to associate with this window.
238
239 @see wxIconBundle.
240 */
241 void SetIcons(const wxIconBundle& icons);
242
243 /**
244 Sets action or menu activated by pressing left hardware button on the
245 smart phones. Unavailable on full keyboard machines.
246
247 @param id
248 Identifier for this button.
249 @param label
250 Text to be displayed on the screen area dedicated to this hardware
251 button.
252 @param subMenu
253 The menu to be opened after pressing this hardware button.
254
255 @see SetRightMenu().
256 */
257 void SetLeftMenu(int id = wxID_ANY,
258 const wxString& label = wxEmptyString,
259 wxMenu* subMenu = NULL);
260
261 /**
262 A simpler interface for setting the size hints than SetSizeHints().
263 */
264 void SetMaxSize(const wxSize& size);
265
266 /**
267 A simpler interface for setting the size hints than SetSizeHints().
268 */
269 void SetMinSize(const wxSize& size);
270
271 /**
272 Sets action or menu activated by pressing right hardware button on the
273 smart phones. Unavailable on full keyboard machines.
274
275 @param id
276 Identifier for this button.
277 @param label
278 Text to be displayed on the screen area dedicated to this hardware
279 button.
280 @param subMenu
281 The menu to be opened after pressing this hardware button.
282
283 @see SetLeftMenu().
284 */
285 void SetRightMenu(int id = wxID_ANY,
286 const wxString& label = wxEmptyString,
287 wxMenu* subMenu = NULL);
288
289 /**
290 If the platform supports it, sets the shape of the window to that
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.
295 */
296 bool SetShape(const wxRegion& region);
297
298 /**
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.
302
303 @param incW
304 Specifies the increment for sizing the width (GTK/Motif/Xt only).
305 @param incH
306 Specifies the increment for sizing the height (GTK/Motif/Xt only).
307
308 @remarks Notice that this function not only prevents the user from
309 resizing the window outside the given bounds but it also
310 prevents the program itself from doing it using
311 wxWindow::SetSize().
312
313 */
314 virtual void SetSizeHints(int minW, int minH, int maxW = -1,
315 int maxH = -1,
316 int incW = -1,
317 int incH = -1);
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 */
333 void SetSizeHints(const wxSize& minSize,
334 const wxSize& maxSize = wxDefaultSize,
335 const wxSize& incSize = wxDefaultSize);
336
337 /**
338 Sets the window title.
339
340 @param title
341 The window title.
342
343 @see GetTitle()
344 */
345 virtual void SetTitle(const wxString& title);
346
347 /**
348 If the platform supports it will set the window to be translucent.
349
350 @param alpha
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.
355 */
356 virtual bool SetTransparent(int alpha);
357
358 /**
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.
364 */
365 virtual bool ShouldPreventAppExit() const;
366
367 /**
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
380 This function has not been tested with MDI frames.
381
382 @note Showing a window full screen also actually @ref wxWindow::Show()
383 "Show()"s the window if it isn't shown.
384
385 @see IsFullScreen()
386 */
387 bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
388
389 /**
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
401
402 @see UseNativeDecorationsByDefault(),
403 IsUsingNativeDecorations()
404 */
405 void UseNativeDecorations(bool native = true);
406
407 /**
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
417 Also note that if @c WXDECOR environment variable is set, then custom
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()
423 */
424 void UseNativeDecorationsByDefault(bool native = true);
425 };
426