]>
Commit | Line | Data |
---|---|---|
7c0ea335 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/frame.h | |
3 | // Purpose: wxFrame class interface | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 15.11.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows team | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
34138703 JS |
12 | #ifndef _WX_FRAME_H_BASE_ |
13 | #define _WX_FRAME_H_BASE_ | |
c801d85f | 14 | |
7c0ea335 VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #ifdef __GNUG__ | |
20 | #pragma interface "framebase.h" | |
21 | #endif | |
22 | ||
23 | #include "wx/window.h" // the base class | |
24 | #include "wx/icon.h" // for m_icon | |
25 | ||
26 | // the default names for various classs | |
27 | WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; | |
28 | WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr; | |
29 | WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr; | |
30 | ||
1e6feb95 | 31 | class WXDLLEXPORT wxFrame; |
7c0ea335 VZ |
32 | class WXDLLEXPORT wxMenuBar; |
33 | class WXDLLEXPORT wxStatusBar; | |
34 | class WXDLLEXPORT wxToolBar; | |
35 | ||
a2327a9f JS |
36 | // Styles for ShowFullScreen |
37 | #define wxFULLSCREEN_NOMENUBAR 0x01 | |
38 | #define wxFULLSCREEN_NOTOOLBAR 0x02 | |
39 | #define wxFULLSCREEN_NOSTATUSBAR 0x04 | |
40 | #define wxFULLSCREEN_NOBORDER 0x08 | |
41 | #define wxFULLSCREEN_NOCAPTION 0x10 | |
42 | #define wxFULLSCREEN_ALL (wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR | wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION) | |
43 | ||
7c0ea335 VZ |
44 | // ---------------------------------------------------------------------------- |
45 | // wxFrame is a top-level window with optional menubar, statusbar and toolbar | |
46 | // | |
47 | // For each of *bars, a frame may have several of them, but only one is | |
48 | // managed by the frame, i.e. resized/moved when the frame is and whose size | |
49 | // is accounted for in client size calculations - all others should be taken | |
50 | // care of manually. The CreateXXXBar() functions create this, main, XXXBar, | |
51 | // but the actual creation is done in OnCreateXXXBar() functions which may be | |
52 | // overridden to create custom objects instead of standard ones when | |
53 | // CreateXXXBar() is called. | |
54 | // ---------------------------------------------------------------------------- | |
55 | ||
56 | class WXDLLEXPORT wxFrameBase : public wxWindow | |
57 | { | |
58 | public: | |
59 | // construction | |
60 | wxFrameBase(); | |
03e11df5 GD |
61 | #ifdef __WXMAC_X__ |
62 | virtual ~wxFrameBase() {} // Added min for Mac X | |
63 | #endif | |
7c0ea335 VZ |
64 | |
65 | wxFrame *New(wxWindow *parent, | |
66 | wxWindowID id, | |
67 | const wxString& title, | |
68 | const wxPoint& pos = wxDefaultPosition, | |
69 | const wxSize& size = wxDefaultSize, | |
70 | long style = wxDEFAULT_FRAME_STYLE, | |
71 | const wxString& name = wxFrameNameStr); | |
72 | ||
73 | // frame state | |
74 | // ----------- | |
75 | ||
76 | // maximize = TRUE => maximize, otherwise - restore | |
77 | virtual void Maximize(bool maximize = TRUE) = 0; | |
78 | ||
79 | // undo Maximize() or Iconize() | |
80 | virtual void Restore() = 0; | |
81 | ||
82 | // iconize = TRUE => iconize, otherwise - restore | |
83 | virtual void Iconize(bool iconize = TRUE) = 0; | |
84 | ||
85 | // return TRUE if the frame is maximized | |
86 | virtual bool IsMaximized() const = 0; | |
87 | ||
88 | // return TRUE if the frame is iconized | |
89 | virtual bool IsIconized() const = 0; | |
90 | ||
91 | // get the frame icon | |
92 | const wxIcon& GetIcon() const { return m_icon; } | |
93 | ||
94 | // set the frame icon | |
95 | virtual void SetIcon(const wxIcon& icon) { m_icon = icon; } | |
96 | ||
97 | // make the window modal (all other windows unresponsive) | |
98 | virtual void MakeModal(bool modal = TRUE); | |
99 | ||
1c4f8f8d VZ |
100 | // get the origin of the client area (which may be different from (0, 0) |
101 | // if the frame has a toolbar) in client coordinates | |
102 | virtual wxPoint GetClientAreaOrigin() const; | |
103 | ||
7c0ea335 VZ |
104 | // menu bar functions |
105 | // ------------------ | |
106 | ||
1e6feb95 | 107 | #if wxUSE_MENUS |
6522713c | 108 | virtual void SetMenuBar(wxMenuBar *menubar); |
7c0ea335 | 109 | virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; } |
1e6feb95 | 110 | #endif // wxUSE_MENUS |
7c0ea335 VZ |
111 | |
112 | // call this to simulate a menu command | |
113 | bool Command(int id) { return ProcessCommand(id); } | |
114 | ||
115 | // process menu command: returns TRUE if processed | |
116 | bool ProcessCommand(int id); | |
117 | ||
118 | // status bar functions | |
119 | // -------------------- | |
120 | #if wxUSE_STATUSBAR | |
121 | // create the main status bar by calling OnCreateStatusBar() | |
122 | virtual wxStatusBar* CreateStatusBar(int number = 1, | |
123 | long style = wxST_SIZEGRIP, | |
124 | wxWindowID id = 0, | |
125 | const wxString& name = | |
126 | wxStatusLineNameStr); | |
127 | // return a new status bar | |
128 | virtual wxStatusBar *OnCreateStatusBar(int number, | |
129 | long style, | |
130 | wxWindowID id, | |
131 | const wxString& name); | |
132 | // get the main status bar | |
133 | virtual wxStatusBar *GetStatusBar() const { return m_frameStatusBar; } | |
134 | ||
135 | // sets the main status bar | |
136 | void SetStatusBar(wxStatusBar *statBar) { m_frameStatusBar = statBar; } | |
137 | ||
138 | // forward these to status bar | |
139 | virtual void SetStatusText(const wxString &text, int number = 0); | |
140 | virtual void SetStatusWidths(int n, const int widths_field[]); | |
141 | #endif // wxUSE_STATUSBAR | |
142 | ||
143 | // toolbar functions | |
144 | // ----------------- | |
145 | #if wxUSE_TOOLBAR | |
146 | // create main toolbar bycalling OnCreateToolBar() | |
147 | virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, | |
148 | wxWindowID id = -1, | |
149 | const wxString& name = wxToolBarNameStr); | |
150 | // return a new toolbar | |
151 | virtual wxToolBar *OnCreateToolBar(long style, | |
152 | wxWindowID id, | |
153 | const wxString& name ); | |
154 | ||
155 | // get/set the main toolbar | |
156 | virtual wxToolBar *GetToolBar() const { return m_frameToolBar; } | |
157 | virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; } | |
158 | #endif // wxUSE_TOOLBAR | |
159 | ||
160 | // old functions, use the new ones instead! | |
161 | #if WXWIN_COMPATIBILITY_2 | |
162 | bool Iconized() const { return IsIconized(); } | |
163 | #endif // WXWIN_COMPATIBILITY_2 | |
164 | ||
165 | // implementation only from now on | |
166 | // ------------------------------- | |
167 | ||
168 | // override some base class virtuals | |
169 | virtual bool Destroy(); | |
170 | virtual bool IsTopLevel() const { return TRUE; } | |
171 | ||
172 | // event handlers | |
173 | void OnIdle(wxIdleEvent& event); | |
174 | void OnCloseWindow(wxCloseEvent& event); | |
175 | void OnMenuHighlight(wxMenuEvent& event); | |
176 | void OnSize(wxSizeEvent& event); | |
1e6feb95 | 177 | |
7c0ea335 VZ |
178 | // this should go away, but for now it's called from docview.cpp, |
179 | // so should be there for all platforms | |
180 | void OnActivate(wxActivateEvent &WXUNUSED(event)) { } | |
181 | ||
1e6feb95 | 182 | #if wxUSE_MENUS |
7c0ea335 VZ |
183 | // send wxUpdateUIEvents for all menu items (called from OnIdle()) |
184 | void DoMenuUpdates(); | |
185 | void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin); | |
1e6feb95 | 186 | #endif // wxUSE_MENUS |
7c0ea335 VZ |
187 | |
188 | protected: | |
189 | // the frame main menu/status/tool bars | |
190 | // ------------------------------------ | |
191 | ||
192 | // this (non virtual!) function should be called from dtor to delete the | |
193 | // main menubar, statusbar and toolbar (if any) | |
194 | void DeleteAllBars(); | |
195 | ||
1e6feb95 VZ |
196 | // test whether this window makes part of the frame |
197 | virtual bool IsOneOfBars(const wxWindow *win) const; | |
198 | ||
199 | #if wxUSE_MENUS | |
200 | // override to update menu bar position when the frame size changes | |
201 | virtual void PositionMenuBar() { } | |
202 | ||
6522713c VZ |
203 | // override to do something special when the menu bar is being removed |
204 | // from the frame | |
205 | virtual void DetachMenuBar(); | |
206 | ||
207 | // override to do something special when the menu bar is attached to the | |
208 | // frame | |
209 | virtual void AttachMenuBar(wxMenuBar *menubar); | |
210 | ||
7c0ea335 | 211 | wxMenuBar *m_frameMenuBar; |
1e6feb95 | 212 | #endif // wxUSE_MENUS |
7c0ea335 VZ |
213 | |
214 | #if wxUSE_STATUSBAR | |
215 | // override to update status bar position (or anything else) when | |
216 | // something changes | |
217 | virtual void PositionStatusBar() { } | |
218 | ||
f6bcfd97 BP |
219 | // show the help string for this menu item in the given status bar: the |
220 | // status bar pointer can be NULL; return TRUE if help was shown | |
221 | bool ShowMenuHelp(wxStatusBar *statbar, int id); | |
222 | ||
7c0ea335 VZ |
223 | wxStatusBar *m_frameStatusBar; |
224 | #endif // wxUSE_STATUSBAR | |
225 | ||
226 | #if wxUSE_TOOLBAR | |
227 | // override to update status bar position (or anything else) when | |
228 | // something changes | |
229 | virtual void PositionToolBar() { } | |
230 | ||
231 | wxToolBar *m_frameToolBar; | |
232 | #endif // wxUSE_TOOLBAR | |
233 | ||
1c4f8f8d VZ |
234 | // the frame client to screen translation should take account of the |
235 | // toolbar which may shift the origin of the client area | |
236 | virtual void DoClientToScreen(int *x, int *y) const; | |
237 | virtual void DoScreenToClient(int *x, int *y) const; | |
238 | ||
3dd9b88a VZ |
239 | // send the iconize event, return TRUE if processed |
240 | bool SendIconizeEvent(bool iconized = TRUE); | |
241 | ||
7c0ea335 VZ |
242 | // the frame icon |
243 | wxIcon m_icon; | |
244 | ||
245 | DECLARE_EVENT_TABLE() | |
246 | }; | |
247 | ||
248 | // include the real class declaration | |
2049ba38 | 249 | #if defined(__WXMSW__) |
3a12b404 | 250 | #include "wx/msw/frame.h" |
af8964c4 | 251 | #define wxFrameNative wxFrameMSW |
2049ba38 | 252 | #elif defined(__WXGTK__) |
3a12b404 | 253 | #include "wx/gtk/frame.h" |
af8964c4 VZ |
254 | #define wxFrameNative wxFrameGTK |
255 | #elif defined(__WXMOTIF__) | |
256 | #include "wx/motif/frame.h" | |
34138703 | 257 | #elif defined(__WXMAC__) |
7c0ea335 | 258 | #include "wx/mac/frame.h" |
af8964c4 VZ |
259 | #define wxFrameNative wxFrameMac |
260 | #elif defined(__WXMGL__) | |
261 | #include "wx/mgl/frame.h" | |
262 | #define wxFrameNative wxFrameMGL | |
1777b9bb | 263 | #elif defined(__WXPM__) |
7c0ea335 | 264 | #include "wx/os2/frame.h" |
af8964c4 | 265 | #define wxFrameNative wxFrameOS2 |
c801d85f KB |
266 | #endif |
267 | ||
1e6feb95 VZ |
268 | #ifdef __WXUNIVERSAL__ |
269 | #include "wx/univ/frame.h" | |
af8964c4 VZ |
270 | #else // !__WXUNIVERSAL__ |
271 | #ifdef wxFrameNative | |
272 | class WXDLLEXPORT wxFrame : public wxFrameNative | |
273 | { | |
274 | public: | |
275 | // construction | |
276 | wxFrame() { Init(); } | |
277 | wxFrame(wxWindow *parent, | |
278 | wxWindowID id, | |
279 | const wxString& title, | |
280 | const wxPoint& pos = wxDefaultPosition, | |
281 | const wxSize& size = wxDefaultSize, | |
282 | long style = wxDEFAULT_FRAME_STYLE, | |
283 | const wxString& name = wxFrameNameStr) | |
284 | { | |
285 | Init(); | |
286 | Create(parent, id, title, pos, size, style, name); | |
287 | } | |
288 | ||
289 | DECLARE_DYNAMIC_CLASS(wxFrame) | |
290 | }; | |
291 | #endif // wxFrameNative | |
292 | #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__ | |
1e6feb95 | 293 | |
c801d85f | 294 | #endif |
34138703 | 295 | // _WX_FRAME_H_BASE_ |