]>
Commit | Line | Data |
---|---|---|
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> | |
7d9f12f3 | 10 | // Vaclav Slavik <vaclav@wxwindows.org> |
ec4f95c4 VZ |
11 | // Licence: wxWindows licence |
12 | /////////////////////////////////////////////////////////////////////////////// | |
13 | ||
7d9f12f3 VS |
14 | #ifndef _WX_TOPLEVEL_BASE_H_ |
15 | #define _WX_TOPLEVEL_BASE_H_ | |
16 | ||
af49c4b8 GD |
17 | #if defined(__GNUG__) && !defined(__APPLE__) |
18 | #pragma interface "toplevelbase.h" | |
19 | #endif | |
20 | ||
7d9f12f3 VS |
21 | // ---------------------------------------------------------------------------- |
22 | // headers | |
23 | // ---------------------------------------------------------------------------- | |
24 | ||
ec4f95c4 | 25 | #include "wx/window.h" |
f618020a | 26 | #include "wx/iconbndl.h" |
7d9f12f3 VS |
27 | |
28 | // the default names for various classs | |
29 | WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; | |
30 | ||
31 | class WXDLLEXPORT wxTopLevelWindowBase; | |
32 | ||
b22d16ad VS |
33 | // ---------------------------------------------------------------------------- |
34 | // constants | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
7d9f12f3 | 37 | // Dialogs are created in a special way |
21f4383a | 38 | #define wxTOPLEVEL_EX_DIALOG 0x00000008 |
7d9f12f3 VS |
39 | |
40 | // Styles for ShowFullScreen | |
41 | // (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and | |
42 | // wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow) | |
b22d16ad VS |
43 | enum |
44 | { | |
45 | wxFULLSCREEN_NOMENUBAR = 0x0001, | |
46 | wxFULLSCREEN_NOTOOLBAR = 0x0002, | |
47 | wxFULLSCREEN_NOSTATUSBAR = 0x0004, | |
48 | wxFULLSCREEN_NOBORDER = 0x0008, | |
49 | wxFULLSCREEN_NOCAPTION = 0x0010, | |
d4597e13 VZ |
50 | |
51 | wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR | | |
52 | wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER | | |
b22d16ad VS |
53 | wxFULLSCREEN_NOCAPTION |
54 | }; | |
55 | ||
ec4f95c4 VZ |
56 | // ---------------------------------------------------------------------------- |
57 | // wxTopLevelWindow: a top level (as opposed to child) window | |
58 | // ---------------------------------------------------------------------------- | |
59 | ||
7d9f12f3 | 60 | class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow |
ec4f95c4 VZ |
61 | { |
62 | public: | |
7d9f12f3 VS |
63 | // construction |
64 | wxTopLevelWindowBase(); | |
799ea011 | 65 | virtual ~wxTopLevelWindowBase(); |
b22d16ad | 66 | |
7d9f12f3 VS |
67 | // top level wnd state |
68 | // -------------------- | |
69 | ||
70 | // maximize = TRUE => maximize, otherwise - restore | |
71 | virtual void Maximize(bool maximize = TRUE) = 0; | |
72 | ||
73 | // undo Maximize() or Iconize() | |
74 | virtual void Restore() = 0; | |
75 | ||
76 | // iconize = TRUE => iconize, otherwise - restore | |
77 | virtual void Iconize(bool iconize = TRUE) = 0; | |
78 | ||
79 | // return TRUE if the frame is maximized | |
80 | virtual bool IsMaximized() const = 0; | |
81 | ||
82 | // return TRUE if the frame is iconized | |
83 | virtual bool IsIconized() const = 0; | |
84 | ||
85 | // get the frame icon | |
f618020a MB |
86 | const wxIcon& GetIcon() const { return m_icons.GetIcon( -1 ); } |
87 | ||
88 | // get the frame icons | |
89 | const wxIconBundle& GetIcons() const { return m_icons; } | |
7d9f12f3 VS |
90 | |
91 | // set the frame icon | |
f618020a MB |
92 | virtual void SetIcon(const wxIcon& icon) { m_icons = wxIconBundle( icon ); } |
93 | ||
94 | // set the frame icons | |
95 | virtual void SetIcons(const wxIconBundle& icons ) { m_icons = icons; } | |
7d9f12f3 | 96 | |
c8e8ae85 VS |
97 | // maximize the window to cover entire screen |
98 | virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0; | |
d4597e13 | 99 | |
c8e8ae85 VS |
100 | // return TRUE if the frame is in fullscreen mode |
101 | virtual bool IsFullScreen() const = 0; | |
102 | ||
ec4f95c4 VZ |
103 | /* |
104 | for now we already have them in wxWindow, but this is wrong: these | |
105 | methods really only make sense for wxTopLevelWindow! | |
106 | ||
7d9f12f3 | 107 | virtual void SetTitle(const wxString& title) = 0; |
ec4f95c4 VZ |
108 | virtual wxString GetTitle() const = 0; |
109 | */ | |
7d9f12f3 | 110 | |
1542ea39 RD |
111 | // Set the shape of the window to the given region. |
112 | // Returns TRUE if the platform supports this feature (and the | |
113 | // operation is successful.) | |
fc7a2a60 | 114 | virtual bool SetShape(const wxRegion& WXUNUSED(region)) { return FALSE; } |
1542ea39 | 115 | |
7d9f12f3 VS |
116 | // old functions, use the new ones instead! |
117 | #if WXWIN_COMPATIBILITY_2 | |
118 | bool Iconized() const { return IsIconized(); } | |
119 | #endif // WXWIN_COMPATIBILITY_2 | |
120 | ||
121 | // implementation only from now on | |
122 | // ------------------------------- | |
123 | ||
124 | // override some base class virtuals | |
125 | virtual bool Destroy(); | |
126 | virtual bool IsTopLevel() const { return TRUE; } | |
34c3ffca | 127 | virtual wxSize GetMaxSize() const; |
7d9f12f3 VS |
128 | |
129 | // event handlers | |
130 | void OnCloseWindow(wxCloseEvent& event); | |
131 | void OnSize(wxSizeEvent& event); | |
132 | ||
133 | // this should go away, but for now it's called from docview.cpp, | |
134 | // so should be there for all platforms | |
135 | void OnActivate(wxActivateEvent &WXUNUSED(event)) { } | |
136 | ||
e39af974 JS |
137 | // do the window-specific processing after processing the update event |
138 | virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ; | |
139 | ||
7d9f12f3 VS |
140 | protected: |
141 | // the frame client to screen translation should take account of the | |
142 | // toolbar which may shift the origin of the client area | |
143 | virtual void DoClientToScreen(int *x, int *y) const; | |
144 | virtual void DoScreenToClient(int *x, int *y) const; | |
145 | ||
1cbee0b4 VZ |
146 | // test whether this window makes part of the frame |
147 | // (menubar, toolbar and statusbar are excluded from automatic layout) | |
148 | virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const | |
149 | { return FALSE; } | |
150 | ||
5c363878 | 151 | // check if we should exit the program after deleting this top level |
1cbee0b4 | 152 | // window (this is used in common dtor and wxMSW code) |
5c363878 | 153 | bool IsLastBeforeExit() const; |
1cbee0b4 | 154 | |
7d9f12f3 VS |
155 | // send the iconize event, return TRUE if processed |
156 | bool SendIconizeEvent(bool iconized = TRUE); | |
157 | ||
158 | // the frame icon | |
f618020a | 159 | wxIconBundle m_icons; |
7d9f12f3 | 160 | |
fc7a2a60 | 161 | DECLARE_NO_COPY_CLASS(wxTopLevelWindowBase) |
7d9f12f3 | 162 | DECLARE_EVENT_TABLE() |
ec4f95c4 VZ |
163 | }; |
164 | ||
7d9f12f3 VS |
165 | |
166 | // include the real class declaration | |
82c9f85c VZ |
167 | #if defined(__WXMSW__) |
168 | #include "wx/msw/toplevel.h" | |
169 | #define wxTopLevelWindowNative wxTopLevelWindowMSW | |
170 | #elif defined(__WXGTK__) | |
7d9f12f3 VS |
171 | #include "wx/gtk/toplevel.h" |
172 | #define wxTopLevelWindowNative wxTopLevelWindowGTK | |
83df96d6 JS |
173 | #elif defined(__WXX11__) |
174 | #include "wx/x11/toplevel.h" | |
175 | #define wxTopLevelWindowNative wxTopLevelWindowX11 | |
7d9f12f3 VS |
176 | #elif defined(__WXMGL__) |
177 | #include "wx/mgl/toplevel.h" | |
178 | #define wxTopLevelWindowNative wxTopLevelWindowMGL | |
93b4dc4b SC |
179 | #elif defined(__WXMAC__) |
180 | #include "wx/mac/toplevel.h" | |
181 | #define wxTopLevelWindowNative wxTopLevelWindowMac | |
e64df9bc DE |
182 | #elif defined(__WXCOCOA__) |
183 | #include "wx/cocoa/toplevel.h" | |
184 | #define wxTopLevelWindowNative wxTopLevelWindowCocoa | |
c9782ca3 DW |
185 | #elif defined(__WXPM__) |
186 | #include "wx/os2/toplevel.h" | |
187 | #define wxTopLevelWindowNative wxTopLevelWindowOS2 | |
798a4529 MB |
188 | #elif defined(__WXMOTIF__) |
189 | #include "wx/motif/toplevel.h" | |
190 | #define wxTopLevelWindowNative wxTopLevelWindowMotif | |
7d9f12f3 VS |
191 | #endif |
192 | ||
193 | #ifdef __WXUNIVERSAL__ | |
194 | #include "wx/univ/toplevel.h" | |
195 | #else // !__WXUNIVERSAL__ | |
196 | #ifdef wxTopLevelWindowNative | |
197 | class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative | |
198 | { | |
199 | public: | |
200 | // construction | |
201 | wxTopLevelWindow() { Init(); } | |
202 | wxTopLevelWindow(wxWindow *parent, | |
d9e2e4c2 | 203 | wxWindowID winid, |
7d9f12f3 VS |
204 | const wxString& title, |
205 | const wxPoint& pos = wxDefaultPosition, | |
206 | const wxSize& size = wxDefaultSize, | |
207 | long style = wxDEFAULT_FRAME_STYLE, | |
208 | const wxString& name = wxFrameNameStr) | |
209 | { | |
210 | Init(); | |
d9e2e4c2 | 211 | Create(parent, winid, title, pos, size, style, name); |
7d9f12f3 VS |
212 | } |
213 | ||
fc7a2a60 | 214 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxTopLevelWindow) |
7d9f12f3 VS |
215 | }; |
216 | #endif // wxTopLevelWindowNative | |
217 | #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__ | |
218 | ||
219 | ||
220 | #endif // _WX_TOPLEVEL_BASE_H_ |