implement out-of-line destructors where needed instead of using __DARWIN__
[wxWidgets.git] / include / wx / toplevel.h
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)
5 // Author: Vadim Zeitlin, Vaclav Slavik
6 // Modified by:
7 // Created: 06.08.01
8 // RCS-ID: $Id$
9 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Vaclav Slavik <vaclav@wxwindows.org>
11 // Licence: wxWindows licence
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #ifndef _WX_TOPLEVEL_BASE_H_
15 #define _WX_TOPLEVEL_BASE_H_
16
17 // ----------------------------------------------------------------------------
18 // headers
19 // ----------------------------------------------------------------------------
20
21 #ifdef __GNUG__
22 #pragma interface "toplevelbase.h"
23 #endif
24
25 #include "wx/window.h"
26 #include "wx/icon.h"
27
28 // the default names for various classs
29 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
30
31 class WXDLLEXPORT wxTopLevelWindowBase;
32
33 // ----------------------------------------------------------------------------
34 // constants
35 // ----------------------------------------------------------------------------
36
37 // Dialogs are created in a special way
38 #define wxTOPLEVEL_EX_DIALOG 0x00000008
39
40 // Styles for ShowFullScreen
41 // (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
42 // wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
43 enum
44 {
45 wxFULLSCREEN_NOMENUBAR = 0x0001,
46 wxFULLSCREEN_NOTOOLBAR = 0x0002,
47 wxFULLSCREEN_NOSTATUSBAR = 0x0004,
48 wxFULLSCREEN_NOBORDER = 0x0008,
49 wxFULLSCREEN_NOCAPTION = 0x0010,
50
51 wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR |
52 wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER |
53 wxFULLSCREEN_NOCAPTION
54 };
55
56 // Flags for interactive frame manipulation functions (only in wxUniversal):
57 enum
58 {
59 wxINTERACTIVE_MOVE = 0x00000001,
60 wxINTERACTIVE_RESIZE = 0x00000002,
61 wxINTERACTIVE_RESIZE_S = 0x00000010,
62 wxINTERACTIVE_RESIZE_N = 0x00000020,
63 wxINTERACTIVE_RESIZE_W = 0x00000040,
64 wxINTERACTIVE_RESIZE_E = 0x00000080,
65 wxINTERACTIVE_WAIT_FOR_INPUT = 0x10000000
66 };
67
68 // ----------------------------------------------------------------------------
69 // wxTopLevelWindow: a top level (as opposed to child) window
70 // ----------------------------------------------------------------------------
71
72 class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow
73 {
74 public:
75 // construction
76 wxTopLevelWindowBase();
77 virtual ~wxTopLevelWindowBase();
78
79 // top level wnd state
80 // --------------------
81
82 // maximize = TRUE => maximize, otherwise - restore
83 virtual void Maximize(bool maximize = TRUE) = 0;
84
85 // undo Maximize() or Iconize()
86 virtual void Restore() = 0;
87
88 // iconize = TRUE => iconize, otherwise - restore
89 virtual void Iconize(bool iconize = TRUE) = 0;
90
91 // return TRUE if the frame is maximized
92 virtual bool IsMaximized() const = 0;
93
94 // return TRUE if the frame is iconized
95 virtual bool IsIconized() const = 0;
96
97 // get the frame icon
98 const wxIcon& GetIcon() const { return m_icon; }
99
100 // set the frame icon
101 virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
102
103 // maximize the window to cover entire screen
104 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
105
106 // return TRUE if the frame is in fullscreen mode
107 virtual bool IsFullScreen() const = 0;
108
109 /*
110 for now we already have them in wxWindow, but this is wrong: these
111 methods really only make sense for wxTopLevelWindow!
112
113 virtual void SetTitle(const wxString& title) = 0;
114 virtual wxString GetTitle() const = 0;
115 */
116
117 // old functions, use the new ones instead!
118 #if WXWIN_COMPATIBILITY_2
119 bool Iconized() const { return IsIconized(); }
120 #endif // WXWIN_COMPATIBILITY_2
121
122
123 #ifdef __WXUNIVERSAL__
124 // move/resize the frame interactively, i.e. let the user do it
125 virtual void InteractiveMove(int flags = wxINTERACTIVE_MOVE);
126 #endif
127
128 // implementation only from now on
129 // -------------------------------
130
131 // override some base class virtuals
132 virtual bool Destroy();
133 virtual bool IsTopLevel() const { return TRUE; }
134
135 // event handlers
136 void OnCloseWindow(wxCloseEvent& event);
137 void OnSize(wxSizeEvent& event);
138
139 // this should go away, but for now it's called from docview.cpp,
140 // so should be there for all platforms
141 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
142
143 // Override in derived, platfrom specific, class if your OS coordinate
144 // system uses anything other than the top left as 0,0. The second
145 // method updates any internal sizing parameters such as OS/2's SWP struct
146 inline virtual void AlterChildPos(void) { }
147 inline virtual void UpdateInternalSize( wxWindow* WXUNUSED(pChild)
148 ,int WXUNUSED(nHeight)
149 ) { }
150
151 protected:
152 // the frame client to screen translation should take account of the
153 // toolbar which may shift the origin of the client area
154 virtual void DoClientToScreen(int *x, int *y) const;
155 virtual void DoScreenToClient(int *x, int *y) const;
156
157 // send the iconize event, return TRUE if processed
158 bool SendIconizeEvent(bool iconized = TRUE);
159
160 // the frame icon
161 wxIcon m_icon;
162
163 // test whether this window makes part of the frame
164 // (menubar, toolbar and statusbar are excluded from automatic layout)
165 virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const { return FALSE; }
166
167 DECLARE_EVENT_TABLE()
168 };
169
170
171 // include the real class declaration
172 #if defined(__WXMSW__)
173 #include "wx/msw/toplevel.h"
174 #define wxTopLevelWindowNative wxTopLevelWindowMSW
175 #elif defined(__WXGTK__)
176 #include "wx/gtk/toplevel.h"
177 #define wxTopLevelWindowNative wxTopLevelWindowGTK
178 #elif defined(__WXMGL__)
179 #include "wx/mgl/toplevel.h"
180 #define wxTopLevelWindowNative wxTopLevelWindowMGL
181 #elif defined(__WXMAC__)
182 #include "wx/mac/toplevel.h"
183 #define wxTopLevelWindowNative wxTopLevelWindowMac
184 #elif defined(__WXPM__)
185 #include "wx/os2/toplevel.h"
186 #define wxTopLevelWindowNative wxTopLevelWindowOS2
187 #endif
188
189 #ifdef __WXUNIVERSAL__
190 #include "wx/univ/toplevel.h"
191 #else // !__WXUNIVERSAL__
192 #ifdef wxTopLevelWindowNative
193 class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative
194 {
195 public:
196 // construction
197 wxTopLevelWindow() { Init(); }
198 wxTopLevelWindow(wxWindow *parent,
199 wxWindowID id,
200 const wxString& title,
201 const wxPoint& pos = wxDefaultPosition,
202 const wxSize& size = wxDefaultSize,
203 long style = wxDEFAULT_FRAME_STYLE,
204 const wxString& name = wxFrameNameStr)
205 {
206 Init();
207 Create(parent, id, title, pos, size, style, name);
208 }
209
210 DECLARE_DYNAMIC_CLASS(wxTopLevelWindow)
211 };
212 #endif // wxTopLevelWindowNative
213 #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
214
215
216 #endif // _WX_TOPLEVEL_BASE_H_