]> git.saurik.com Git - wxWidgets.git/blame - include/wx/toplevel.h
Updated translations manual page with latest status given by the website translations...
[wxWidgets.git] / include / wx / toplevel.h
CommitLineData
ec4f95c4
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/toplevel.h
3// Purpose: declares wxTopLevelWindow class, the base class for all
4// top level windows (such as frames and dialogs)
7d9f12f3 5// Author: Vadim Zeitlin, Vaclav Slavik
ec4f95c4
VZ
6// Modified by:
7// Created: 06.08.01
8// RCS-ID: $Id$
9// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
77ffb593 10// Vaclav Slavik <vaclav@wxwidgets.org>
65571936 11// Licence: wxWindows licence
ec4f95c4
VZ
12///////////////////////////////////////////////////////////////////////////////
13
7d9f12f3
VS
14#ifndef _WX_TOPLEVEL_BASE_H_
15#define _WX_TOPLEVEL_BASE_H_
16
17// ----------------------------------------------------------------------------
18// headers
19// ----------------------------------------------------------------------------
20
42b0d8b9 21#include "wx/nonownedwnd.h"
f618020a 22#include "wx/iconbndl.h"
049908c5 23#include "wx/containr.h"
3e040a29 24#include "wx/weakref.h"
7d9f12f3 25
63ec432b 26// the default names for various classes
53a2db12 27extern WXDLLIMPEXP_DATA_CORE(const char) wxFrameNameStr[];
7d9f12f3 28
b5dbe15d 29class WXDLLIMPEXP_FWD_CORE wxTopLevelWindowBase;
7d9f12f3 30
b22d16ad
VS
31// ----------------------------------------------------------------------------
32// constants
33// ----------------------------------------------------------------------------
34
8b5ef6cf
VZ
35// style common to both wxFrame and wxDialog
36#define wxSTAY_ON_TOP 0x8000
37#define wxICONIZE 0x4000
38#define wxMINIMIZE wxICONIZE
39#define wxMAXIMIZE 0x2000
40#define wxCLOSE_BOX 0x1000
41
42#define wxSYSTEM_MENU 0x0800
43#define wxMINIMIZE_BOX 0x0400
44#define wxMAXIMIZE_BOX 0x0200
45#define wxTINY_CAPTION_HORIZ 0x0100
46#define wxTINY_CAPTION_VERT 0x0080
47#define wxRESIZE_BORDER 0x0040
48
1c067fe3
WS
49#if WXWIN_COMPATIBILITY_2_6
50
51 // deprecated versions defined for compatibility reasons
52 #define wxRESIZE_BOX wxMAXIMIZE_BOX
53 #define wxTHICK_FRAME wxRESIZE_BORDER
54
55 // obsolete styles, unused any more
56 #define wxDIALOG_MODAL 0
57 #define wxDIALOG_MODELESS 0
58 #define wxNO_3D 0
59 #define wxUSER_COLOURS 0
60
61#endif // WXWIN_COMPATIBILITY_2_6
8b5ef6cf
VZ
62
63// default style
64//
65// under Windows CE (at least when compiling with eVC 4) we should create
66// top level windows without any styles at all for them to appear
67// "correctly", i.e. as full screen windows with a "hide" button (same as
68// "close" but round instead of squared and just hides the applications
69// instead of closing it) in the title bar
a9928e9d 70#if defined(__WXWINCE__)
cb719f2e
WS
71 #if defined(__SMARTPHONE__)
72 #define wxDEFAULT_FRAME_STYLE (wxMAXIMIZE)
a9928e9d 73 #elif defined(__WINCE_STANDARDSDK__)
cb719f2e
WS
74 #define wxDEFAULT_FRAME_STYLE (wxMAXIMIZE|wxCLOSE_BOX)
75 #else
30dfe2ff 76 #define wxDEFAULT_FRAME_STYLE (wxNO_BORDER)
cb719f2e 77 #endif
8b5ef6cf
VZ
78#else // !__WXWINCE__
79 #define wxDEFAULT_FRAME_STYLE \
80 (wxSYSTEM_MENU | \
81 wxRESIZE_BORDER | \
82 wxMINIMIZE_BOX | \
83 wxMAXIMIZE_BOX | \
84 wxCLOSE_BOX | \
85 wxCAPTION | \
86 wxCLIP_CHILDREN)
87#endif
88
89
7d9f12f3 90// Dialogs are created in a special way
21f4383a 91#define wxTOPLEVEL_EX_DIALOG 0x00000008
7d9f12f3
VS
92
93// Styles for ShowFullScreen
94// (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
95// wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
b22d16ad
VS
96enum
97{
98 wxFULLSCREEN_NOMENUBAR = 0x0001,
99 wxFULLSCREEN_NOTOOLBAR = 0x0002,
100 wxFULLSCREEN_NOSTATUSBAR = 0x0004,
101 wxFULLSCREEN_NOBORDER = 0x0008,
102 wxFULLSCREEN_NOCAPTION = 0x0010,
d4597e13
VZ
103
104 wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR |
105 wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER |
b22d16ad
VS
106 wxFULLSCREEN_NOCAPTION
107};
108
dc92adaf
VZ
109// Styles for RequestUserAttention
110enum
111{
112 wxUSER_ATTENTION_INFO = 1,
113 wxUSER_ATTENTION_ERROR = 2
114};
115
ec4f95c4
VZ
116// ----------------------------------------------------------------------------
117// wxTopLevelWindow: a top level (as opposed to child) window
118// ----------------------------------------------------------------------------
119
53a2db12 120class WXDLLIMPEXP_CORE wxTopLevelWindowBase : public wxNonOwnedWindow
ec4f95c4
VZ
121{
122public:
7d9f12f3
VS
123 // construction
124 wxTopLevelWindowBase();
799ea011 125 virtual ~wxTopLevelWindowBase();
b22d16ad 126
7d9f12f3
VS
127 // top level wnd state
128 // --------------------
129
cb719f2e
WS
130 // maximize = true => maximize, otherwise - restore
131 virtual void Maximize(bool maximize = true) = 0;
7d9f12f3
VS
132
133 // undo Maximize() or Iconize()
134 virtual void Restore() = 0;
135
cb719f2e
WS
136 // iconize = true => iconize, otherwise - restore
137 virtual void Iconize(bool iconize = true) = 0;
7d9f12f3 138
cb719f2e 139 // return true if the frame is maximized
7d9f12f3
VS
140 virtual bool IsMaximized() const = 0;
141
979a0320
WS
142 // return true if the frame is always maximized
143 // due to native guidelines or current policy
144 virtual bool IsAlwaysMaximized() const;
145
cb719f2e 146 // return true if the frame is iconized
7d9f12f3
VS
147 virtual bool IsIconized() const = 0;
148
149 // get the frame icon
ea098413 150 wxIcon GetIcon() const;
f618020a
MB
151
152 // get the frame icons
153 const wxIconBundle& GetIcons() const { return m_icons; }
7d9f12f3 154
ea098413
VZ
155 // set the frame icon: implemented in terms of SetIcons()
156 void SetIcon(const wxIcon& icon);
f618020a
MB
157
158 // set the frame icons
ea098413 159 virtual void SetIcons(const wxIconBundle& icons) { m_icons = icons; }
7d9f12f3 160
c8e8ae85
VS
161 // maximize the window to cover entire screen
162 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
d4597e13 163
cb719f2e 164 // return true if the frame is in fullscreen mode
c8e8ae85
VS
165 virtual bool IsFullScreen() const = 0;
166
ffd84c94
WS
167 // the title of the top level window: the text which the
168 // window shows usually at the top of the frame/dialog in dedicated bar
7d9f12f3 169 virtual void SetTitle(const wxString& title) = 0;
ec4f95c4 170 virtual wxString GetTitle() const = 0;
7d9f12f3 171
a43ec16b
RR
172 // enable/disable close button [x]
173 virtual bool EnableCloseButton(bool WXUNUSED(enable) ) { return false; }
174
1542ea39 175 // Set the shape of the window to the given region.
cb719f2e 176 // Returns true if the platform supports this feature (and the
1542ea39 177 // operation is successful.)
cb719f2e 178 virtual bool SetShape(const wxRegion& WXUNUSED(region)) { return false; }
1542ea39 179
dc92adaf
VZ
180 // Attracts the users attention to this window if the application is
181 // inactive (should be called when a background event occurs)
182 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
9b141468 183
35ff90a0 184 // Is this the active frame (highlighted in the taskbar)?
171a1afe
VZ
185 virtual bool IsActive() { return wxGetTopLevelParent(FindFocus()) == this; }
186
187 // this function may be overridden to return false to allow closing the
188 // application even when this top level window is still open
189 //
190 // notice that the window is still closed prior to the application exit and
191 // so it can still veto it even if it returns false from here
192 virtual bool ShouldPreventAppExit() const { return true; }
193
dc92adaf 194
9b141468
WS
195#if defined(__SMARTPHONE__)
196 virtual void SetLeftMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL) = 0;
197 virtual void SetRightMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL) = 0;
198#endif // __SMARTPHONE__
199
1f464296
VZ
200 // centre the window on screen: this is just a shortcut
201 void CentreOnScreen(int dir = wxBOTH) { DoCentre(dir | wxCENTRE_ON_SCREEN); }
202 void CenterOnScreen(int dir = wxBOTH) { CentreOnScreen(dir); }
203
6c20e8f8
VZ
204
205 // default item access: we have a permanent default item which is the one
206 // set by the user code but we may also have a temporary default item which
207 // would be chosen if the user pressed "Enter" now but the default action
208 // reverts to the "permanent" default as soon as this temporary default
209 // item loses focus
210
6c20e8f8
VZ
211 // get the default item, temporary or permanent
212 wxWindow *GetDefaultItem() const
213 { return m_winTmpDefault ? m_winTmpDefault : m_winDefault; }
214
215 // set the permanent default item, return the old default
216 wxWindow *SetDefaultItem(wxWindow *win)
217 { wxWindow *old = GetDefaultItem(); m_winDefault = win; return old; }
218
219 // return the temporary default item, can be NULL
220 wxWindow *GetTmpDefaultItem() const { return m_winTmpDefault; }
221
222 // set a temporary default item, SetTmpDefaultItem(NULL) should be called
223 // soon after a call to SetTmpDefaultItem(window), return the old default
224 wxWindow *SetTmpDefaultItem(wxWindow *win)
225 { wxWindow *old = GetDefaultItem(); m_winTmpDefault = win; return old; }
226
227
7d9f12f3
VS
228 // implementation only from now on
229 // -------------------------------
230
231 // override some base class virtuals
232 virtual bool Destroy();
cb719f2e 233 virtual bool IsTopLevel() const { return true; }
9c72cf76 234 virtual bool IsVisible() const { return IsShown(); }
7d9f12f3
VS
235
236 // event handlers
237 void OnCloseWindow(wxCloseEvent& event);
5e62d4a5 238 void OnSize(wxSizeEvent& WXUNUSED(event)) { DoLayout(); }
7d9f12f3 239
0bba37f5
DE
240 // Get rect to be used to center top-level children
241 virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
242
7d9f12f3
VS
243 // this should go away, but for now it's called from docview.cpp,
244 // so should be there for all platforms
245 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
246
e39af974
JS
247 // do the window-specific processing after processing the update event
248 virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
249
cda5834e
RR
250 // a different API for SetSizeHints
251 virtual void SetMinSize(const wxSize& minSize);
252 virtual void SetMaxSize(const wxSize& maxSize);
253
3498362e 254protected:
7d9f12f3
VS
255 // the frame client to screen translation should take account of the
256 // toolbar which may shift the origin of the client area
257 virtual void DoClientToScreen(int *x, int *y) const;
258 virtual void DoScreenToClient(int *x, int *y) const;
259
1f464296
VZ
260 // add support for wxCENTRE_ON_SCREEN
261 virtual void DoCentre(int dir);
262
3c81c9aa
VZ
263 // no need to do client to screen translation to get our position in screen
264 // coordinates: this is already the case
265 virtual void DoGetScreenPosition(int *x, int *y) const
266 {
74af7bcf 267 DoGetPosition(x, y);
3c81c9aa 268 }
1f464296 269
1cbee0b4
VZ
270 // test whether this window makes part of the frame
271 // (menubar, toolbar and statusbar are excluded from automatic layout)
272 virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const
cb719f2e 273 { return false; }
1cbee0b4 274
65afac3f 275 // check if we should exit the program after deleting this window
5c363878 276 bool IsLastBeforeExit() const;
1cbee0b4 277
cb719f2e
WS
278 // send the iconize event, return true if processed
279 bool SendIconizeEvent(bool iconized = true);
7d9f12f3 280
5e62d4a5
VZ
281 // do TLW-specific layout: we resize our unique child to fill the entire
282 // client area
283 void DoLayout();
284
66202a7e
RD
285 // Get the default size for the new window if no explicit size given. If
286 // there are better default sizes then these can be changed, just as long
0c089c08
VZ
287 // as they are not too small for TLWs (and not larger than screen).
288 static wxSize GetDefaultSize();
cb719f2e
WS
289 static int WidthDefault(int w) { return w == wxDefaultCoord ? GetDefaultSize().x : w; }
290 static int HeightDefault(int h) { return h == wxDefaultCoord ? GetDefaultSize().y : h; }
66202a7e 291
f8ab85ae 292
7d9f12f3 293 // the frame icon
f618020a 294 wxIconBundle m_icons;
7d9f12f3 295
6c20e8f8 296 // a default window (usually a button) or NULL
3e040a29 297 wxWindowRef m_winDefault;
6c20e8f8
VZ
298
299 // a temporary override of m_winDefault, use the latter if NULL
3e040a29 300 wxWindowRef m_winTmpDefault;
6c20e8f8 301
fc7a2a60 302 DECLARE_NO_COPY_CLASS(wxTopLevelWindowBase)
7d9f12f3 303 DECLARE_EVENT_TABLE()
049908c5 304 WX_DECLARE_CONTROL_CONTAINER();
ec4f95c4
VZ
305};
306
7d9f12f3
VS
307
308// include the real class declaration
4055ed82 309#if defined(__WXPALMOS__)
ffecfa5a
JS
310 #include "wx/palmos/toplevel.h"
311 #define wxTopLevelWindowNative wxTopLevelWindowPalm
312#elif defined(__WXMSW__)
82c9f85c
VZ
313 #include "wx/msw/toplevel.h"
314 #define wxTopLevelWindowNative wxTopLevelWindowMSW
1be7a35c 315#elif defined(__WXGTK20__)
7d9f12f3
VS
316 #include "wx/gtk/toplevel.h"
317 #define wxTopLevelWindowNative wxTopLevelWindowGTK
1be7a35c
MR
318#elif defined(__WXGTK__)
319 #include "wx/gtk1/toplevel.h"
320 #define wxTopLevelWindowNative wxTopLevelWindowGTK
83df96d6
JS
321#elif defined(__WXX11__)
322 #include "wx/x11/toplevel.h"
323 #define wxTopLevelWindowNative wxTopLevelWindowX11
7d9f12f3
VS
324#elif defined(__WXMGL__)
325 #include "wx/mgl/toplevel.h"
326 #define wxTopLevelWindowNative wxTopLevelWindowMGL
b3c86150
VS
327#elif defined(__WXDFB__)
328 #include "wx/dfb/toplevel.h"
329 #define wxTopLevelWindowNative wxTopLevelWindowDFB
93b4dc4b 330#elif defined(__WXMAC__)
ef0e9220 331 #include "wx/osx/toplevel.h"
93b4dc4b 332 #define wxTopLevelWindowNative wxTopLevelWindowMac
e64df9bc
DE
333#elif defined(__WXCOCOA__)
334 #include "wx/cocoa/toplevel.h"
335 #define wxTopLevelWindowNative wxTopLevelWindowCocoa
c9782ca3
DW
336#elif defined(__WXPM__)
337 #include "wx/os2/toplevel.h"
338 #define wxTopLevelWindowNative wxTopLevelWindowOS2
798a4529
MB
339#elif defined(__WXMOTIF__)
340 #include "wx/motif/toplevel.h"
341 #define wxTopLevelWindowNative wxTopLevelWindowMotif
7d9f12f3
VS
342#endif
343
344#ifdef __WXUNIVERSAL__
345 #include "wx/univ/toplevel.h"
346#else // !__WXUNIVERSAL__
347 #ifdef wxTopLevelWindowNative
53a2db12 348 class WXDLLIMPEXP_CORE wxTopLevelWindow : public wxTopLevelWindowNative
7d9f12f3
VS
349 {
350 public:
351 // construction
352 wxTopLevelWindow() { Init(); }
353 wxTopLevelWindow(wxWindow *parent,
d9e2e4c2 354 wxWindowID winid,
7d9f12f3
VS
355 const wxString& title,
356 const wxPoint& pos = wxDefaultPosition,
357 const wxSize& size = wxDefaultSize,
358 long style = wxDEFAULT_FRAME_STYLE,
359 const wxString& name = wxFrameNameStr)
360 {
361 Init();
d9e2e4c2 362 Create(parent, winid, title, pos, size, style, name);
7d9f12f3
VS
363 }
364
fc7a2a60 365 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTopLevelWindow)
7d9f12f3
VS
366 };
367 #endif // wxTopLevelWindowNative
368#endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
369
370
371#endif // _WX_TOPLEVEL_BASE_H_