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