]> git.saurik.com Git - wxWidgets.git/blame - include/wx/toplevel.h
Get/SetTitle only for wxTopLevelWindow (wxCocoa part).
[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
ec4f95c4 21#include "wx/window.h"
f618020a 22#include "wx/iconbndl.h"
7d9f12f3
VS
23
24// the default names for various classs
16cba29d 25extern WXDLLEXPORT_DATA(const wxChar*) wxFrameNameStr;
7d9f12f3
VS
26
27class WXDLLEXPORT wxTopLevelWindowBase;
28
b22d16ad
VS
29// ----------------------------------------------------------------------------
30// constants
31// ----------------------------------------------------------------------------
32
8b5ef6cf
VZ
33// style common to both wxFrame and wxDialog
34#define wxSTAY_ON_TOP 0x8000
35#define wxICONIZE 0x4000
36#define wxMINIMIZE wxICONIZE
37#define wxMAXIMIZE 0x2000
38#define wxCLOSE_BOX 0x1000
39
40#define wxSYSTEM_MENU 0x0800
41#define wxMINIMIZE_BOX 0x0400
42#define wxMAXIMIZE_BOX 0x0200
43#define wxTINY_CAPTION_HORIZ 0x0100
44#define wxTINY_CAPTION_VERT 0x0080
45#define wxRESIZE_BORDER 0x0040
46
47// deprecated versions defined for compatibility reasons
48#define wxRESIZE_BOX wxMAXIMIZE_BOX
49#define wxTHICK_FRAME wxRESIZE_BORDER
50
51// obsolete styles, unused any more
52#define wxDIALOG_MODAL 0
53#define wxDIALOG_MODELESS 0
54#define wxNO_3D 0
55#define wxUSER_COLOURS 0
56
57// default style
58//
59// under Windows CE (at least when compiling with eVC 4) we should create
60// top level windows without any styles at all for them to appear
61// "correctly", i.e. as full screen windows with a "hide" button (same as
62// "close" but round instead of squared and just hides the applications
63// instead of closing it) in the title bar
a9928e9d 64#if defined(__WXWINCE__)
cb719f2e
WS
65 #if defined(__SMARTPHONE__)
66 #define wxDEFAULT_FRAME_STYLE (wxMAXIMIZE)
a9928e9d 67 #elif defined(__WINCE_STANDARDSDK__)
cb719f2e
WS
68 #define wxDEFAULT_FRAME_STYLE (wxMAXIMIZE|wxCLOSE_BOX)
69 #else
30dfe2ff 70 #define wxDEFAULT_FRAME_STYLE (wxNO_BORDER)
cb719f2e 71 #endif
8b5ef6cf
VZ
72#else // !__WXWINCE__
73 #define wxDEFAULT_FRAME_STYLE \
74 (wxSYSTEM_MENU | \
75 wxRESIZE_BORDER | \
76 wxMINIMIZE_BOX | \
77 wxMAXIMIZE_BOX | \
78 wxCLOSE_BOX | \
79 wxCAPTION | \
80 wxCLIP_CHILDREN)
81#endif
82
83
7d9f12f3 84// Dialogs are created in a special way
21f4383a 85#define wxTOPLEVEL_EX_DIALOG 0x00000008
7d9f12f3
VS
86
87// Styles for ShowFullScreen
88// (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
89// wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
b22d16ad
VS
90enum
91{
92 wxFULLSCREEN_NOMENUBAR = 0x0001,
93 wxFULLSCREEN_NOTOOLBAR = 0x0002,
94 wxFULLSCREEN_NOSTATUSBAR = 0x0004,
95 wxFULLSCREEN_NOBORDER = 0x0008,
96 wxFULLSCREEN_NOCAPTION = 0x0010,
d4597e13
VZ
97
98 wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR |
99 wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER |
b22d16ad
VS
100 wxFULLSCREEN_NOCAPTION
101};
102
dc92adaf
VZ
103// Styles for RequestUserAttention
104enum
105{
106 wxUSER_ATTENTION_INFO = 1,
107 wxUSER_ATTENTION_ERROR = 2
108};
109
ec4f95c4
VZ
110// ----------------------------------------------------------------------------
111// wxTopLevelWindow: a top level (as opposed to child) window
112// ----------------------------------------------------------------------------
113
7d9f12f3 114class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow
ec4f95c4
VZ
115{
116public:
7d9f12f3
VS
117 // construction
118 wxTopLevelWindowBase();
799ea011 119 virtual ~wxTopLevelWindowBase();
b22d16ad 120
7d9f12f3
VS
121 // top level wnd state
122 // --------------------
123
cb719f2e
WS
124 // maximize = true => maximize, otherwise - restore
125 virtual void Maximize(bool maximize = true) = 0;
7d9f12f3
VS
126
127 // undo Maximize() or Iconize()
128 virtual void Restore() = 0;
129
cb719f2e
WS
130 // iconize = true => iconize, otherwise - restore
131 virtual void Iconize(bool iconize = true) = 0;
7d9f12f3 132
cb719f2e 133 // return true if the frame is maximized
7d9f12f3
VS
134 virtual bool IsMaximized() const = 0;
135
cb719f2e 136 // return true if the frame is iconized
7d9f12f3
VS
137 virtual bool IsIconized() const = 0;
138
139 // get the frame icon
f618020a
MB
140 const wxIcon& GetIcon() const { return m_icons.GetIcon( -1 ); }
141
142 // get the frame icons
143 const wxIconBundle& GetIcons() const { return m_icons; }
7d9f12f3
VS
144
145 // set the frame icon
f618020a
MB
146 virtual void SetIcon(const wxIcon& icon) { m_icons = wxIconBundle( icon ); }
147
148 // set the frame icons
149 virtual void SetIcons(const wxIconBundle& icons ) { m_icons = icons; }
7d9f12f3 150
c8e8ae85
VS
151 // maximize the window to cover entire screen
152 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
d4597e13 153
cb719f2e 154 // return true if the frame is in fullscreen mode
c8e8ae85
VS
155 virtual bool IsFullScreen() const = 0;
156
d40209bb 157#if defined(__WXMSW__) || \
46ae103b 158 defined(__WXMGL__) || \
cb8cc250 159 defined(__WXMOTIF__) || \
743e24aa 160 defined(__WXPM__) || \
fb5246be 161 defined(__WXMAC__) || \
8d8d3633 162 defined(__WXCOCOA__) || \
cb8cc250 163 defined(__WXGTK__)
34097680 164
faa49bfd
WS
165 // FIXME: This is work in progress about moving SetTitle/GetTitle from wxWindow
166 // to wxTopLevelWindow so initially enabled in wxMSW only to observe results
167 // and continue on other platforms
ec4f95c4 168
faa49bfd
WS
169 // the title (or label, see below) of the window: the text which the
170 // window shows
7d9f12f3 171 virtual void SetTitle(const wxString& title) = 0;
ec4f95c4 172 virtual wxString GetTitle() const = 0;
faa49bfd 173#endif
7d9f12f3 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)?
6b30a44e 185 virtual bool IsActive()
35ff90a0 186 { return (wxGetTopLevelParent(FindFocus()) == this); }
dc92adaf 187
9b141468
WS
188#if defined(__SMARTPHONE__)
189 virtual void SetLeftMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL) = 0;
190 virtual void SetRightMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL) = 0;
191#endif // __SMARTPHONE__
192
7d9f12f3
VS
193 // implementation only from now on
194 // -------------------------------
195
196 // override some base class virtuals
197 virtual bool Destroy();
cb719f2e 198 virtual bool IsTopLevel() const { return true; }
34c3ffca 199 virtual wxSize GetMaxSize() const;
7d9f12f3
VS
200
201 // event handlers
202 void OnCloseWindow(wxCloseEvent& event);
5e62d4a5 203 void OnSize(wxSizeEvent& WXUNUSED(event)) { DoLayout(); }
7d9f12f3 204
0bba37f5
DE
205 // Get rect to be used to center top-level children
206 virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
207
7d9f12f3
VS
208 // this should go away, but for now it's called from docview.cpp,
209 // so should be there for all platforms
210 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
211
e39af974
JS
212 // do the window-specific processing after processing the update event
213 virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
214
48710795
RR
215 // Reserved for future use
216 virtual void ReservedTopLevelWindowFunc1() {}
217 virtual void ReservedTopLevelWindowFunc2() {}
218 virtual void ReservedTopLevelWindowFunc3() {}
219 virtual void ReservedTopLevelWindowFunc4() {}
220 virtual void ReservedTopLevelWindowFunc5() {}
221 virtual void ReservedTopLevelWindowFunc6() {}
222 virtual void ReservedTopLevelWindowFunc7() {}
223 virtual void ReservedTopLevelWindowFunc8() {}
224 virtual void ReservedTopLevelWindowFunc9() {}
225
7d9f12f3
VS
226protected:
227 // the frame client to screen translation should take account of the
228 // toolbar which may shift the origin of the client area
229 virtual void DoClientToScreen(int *x, int *y) const;
230 virtual void DoScreenToClient(int *x, int *y) const;
231
1cbee0b4
VZ
232 // test whether this window makes part of the frame
233 // (menubar, toolbar and statusbar are excluded from automatic layout)
234 virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const
cb719f2e 235 { return false; }
1cbee0b4 236
5c363878 237 // check if we should exit the program after deleting this top level
1cbee0b4 238 // window (this is used in common dtor and wxMSW code)
5c363878 239 bool IsLastBeforeExit() const;
1cbee0b4 240
cb719f2e
WS
241 // send the iconize event, return true if processed
242 bool SendIconizeEvent(bool iconized = true);
7d9f12f3 243
5e62d4a5
VZ
244 // do TLW-specific layout: we resize our unique child to fill the entire
245 // client area
246 void DoLayout();
247
66202a7e
RD
248 // Get the default size for the new window if no explicit size given. If
249 // there are better default sizes then these can be changed, just as long
0c089c08
VZ
250 // as they are not too small for TLWs (and not larger than screen).
251 static wxSize GetDefaultSize();
cb719f2e
WS
252 static int WidthDefault(int w) { return w == wxDefaultCoord ? GetDefaultSize().x : w; }
253 static int HeightDefault(int h) { return h == wxDefaultCoord ? GetDefaultSize().y : h; }
66202a7e 254
7d9f12f3 255 // the frame icon
f618020a 256 wxIconBundle m_icons;
7d9f12f3 257
fc7a2a60 258 DECLARE_NO_COPY_CLASS(wxTopLevelWindowBase)
7d9f12f3 259 DECLARE_EVENT_TABLE()
ec4f95c4
VZ
260};
261
7d9f12f3
VS
262
263// include the real class declaration
4055ed82 264#if defined(__WXPALMOS__)
ffecfa5a
JS
265 #include "wx/palmos/toplevel.h"
266 #define wxTopLevelWindowNative wxTopLevelWindowPalm
267#elif defined(__WXMSW__)
82c9f85c
VZ
268 #include "wx/msw/toplevel.h"
269 #define wxTopLevelWindowNative wxTopLevelWindowMSW
270#elif defined(__WXGTK__)
7d9f12f3
VS
271 #include "wx/gtk/toplevel.h"
272 #define wxTopLevelWindowNative wxTopLevelWindowGTK
83df96d6
JS
273#elif defined(__WXX11__)
274 #include "wx/x11/toplevel.h"
275 #define wxTopLevelWindowNative wxTopLevelWindowX11
7d9f12f3
VS
276#elif defined(__WXMGL__)
277 #include "wx/mgl/toplevel.h"
278 #define wxTopLevelWindowNative wxTopLevelWindowMGL
93b4dc4b
SC
279#elif defined(__WXMAC__)
280 #include "wx/mac/toplevel.h"
281 #define wxTopLevelWindowNative wxTopLevelWindowMac
e64df9bc
DE
282#elif defined(__WXCOCOA__)
283 #include "wx/cocoa/toplevel.h"
284 #define wxTopLevelWindowNative wxTopLevelWindowCocoa
c9782ca3
DW
285#elif defined(__WXPM__)
286 #include "wx/os2/toplevel.h"
287 #define wxTopLevelWindowNative wxTopLevelWindowOS2
798a4529
MB
288#elif defined(__WXMOTIF__)
289 #include "wx/motif/toplevel.h"
290 #define wxTopLevelWindowNative wxTopLevelWindowMotif
7d9f12f3
VS
291#endif
292
293#ifdef __WXUNIVERSAL__
294 #include "wx/univ/toplevel.h"
295#else // !__WXUNIVERSAL__
296 #ifdef wxTopLevelWindowNative
297 class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative
298 {
299 public:
300 // construction
301 wxTopLevelWindow() { Init(); }
302 wxTopLevelWindow(wxWindow *parent,
d9e2e4c2 303 wxWindowID winid,
7d9f12f3
VS
304 const wxString& title,
305 const wxPoint& pos = wxDefaultPosition,
306 const wxSize& size = wxDefaultSize,
307 long style = wxDEFAULT_FRAME_STYLE,
308 const wxString& name = wxFrameNameStr)
309 {
310 Init();
d9e2e4c2 311 Create(parent, winid, title, pos, size, style, name);
7d9f12f3
VS
312 }
313
fc7a2a60 314 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTopLevelWindow)
7d9f12f3
VS
315 };
316 #endif // wxTopLevelWindowNative
317#endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
318
319
320#endif // _WX_TOPLEVEL_BASE_H_