]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/generic/mdig.h | |
3 | // Purpose: Generic MDI (Multiple Document Interface) classes | |
4 | // Author: Hans Van Leemputten | |
5 | // Modified by: | |
6 | // Created: 29/07/2002 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Hans Van Leemputten | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_MDIG_H_ | |
13 | #define _WX_MDIG_H_ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/frame.h" | |
20 | #include "wx/panel.h" | |
21 | #include "wx/notebook.h" | |
22 | ||
23 | extern WXDLLEXPORT_DATA(const wxChar) wxFrameNameStr[]; | |
24 | extern WXDLLEXPORT_DATA(const wxChar) wxStatusLineNameStr[]; | |
25 | ||
26 | ||
27 | //----------------------------------------------------------------------------- | |
28 | // classes | |
29 | //----------------------------------------------------------------------------- | |
30 | ||
31 | class WXDLLEXPORT wxGenericMDIParentFrame; | |
32 | class WXDLLEXPORT wxGenericMDIClientWindow; | |
33 | class WXDLLEXPORT wxGenericMDIChildFrame; | |
34 | ||
35 | //----------------------------------------------------------------------------- | |
36 | // wxGenericMDIParentFrame | |
37 | //----------------------------------------------------------------------------- | |
38 | ||
39 | class WXDLLEXPORT wxGenericMDIParentFrame: public wxFrame | |
40 | { | |
41 | public: | |
42 | wxGenericMDIParentFrame(); | |
43 | wxGenericMDIParentFrame(wxWindow *parent, | |
44 | wxWindowID winid, | |
45 | const wxString& title, | |
46 | const wxPoint& pos = wxDefaultPosition, | |
47 | const wxSize& size = wxDefaultSize, | |
48 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
49 | const wxString& name = wxFrameNameStr); | |
50 | ||
51 | ~wxGenericMDIParentFrame(); | |
52 | bool Create( wxWindow *parent, | |
53 | wxWindowID winid, | |
54 | const wxString& title, | |
55 | const wxPoint& pos = wxDefaultPosition, | |
56 | const wxSize& size = wxDefaultSize, | |
57 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
58 | const wxString& name = wxFrameNameStr ); | |
59 | ||
60 | #if wxUSE_MENUS | |
61 | wxMenu* GetWindowMenu() const { return m_pWindowMenu; }; | |
62 | void SetWindowMenu(wxMenu* pMenu); | |
63 | ||
64 | virtual void SetMenuBar(wxMenuBar *pMenuBar); | |
65 | #endif // wxUSE_MENUS | |
66 | ||
67 | void SetChildMenuBar(wxGenericMDIChildFrame *pChild); | |
68 | ||
69 | virtual bool ProcessEvent(wxEvent& event); | |
70 | ||
71 | wxGenericMDIChildFrame *GetActiveChild() const; | |
72 | inline void SetActiveChild(wxGenericMDIChildFrame* pChildFrame); | |
73 | ||
74 | wxGenericMDIClientWindow *GetClientWindow() const; | |
75 | virtual wxGenericMDIClientWindow *OnCreateClient(); | |
76 | ||
77 | virtual void Cascade() { /* Has no effect */ } | |
78 | virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL) { } | |
79 | virtual void ArrangeIcons() { /* Has no effect */ } | |
80 | virtual void ActivateNext(); | |
81 | virtual void ActivatePrevious(); | |
82 | ||
83 | protected: | |
84 | wxGenericMDIClientWindow *m_pClientWindow; | |
85 | wxGenericMDIChildFrame *m_pActiveChild; | |
86 | #if wxUSE_MENUS | |
87 | wxMenu *m_pWindowMenu; | |
88 | wxMenuBar *m_pMyMenuBar; | |
89 | #endif // wxUSE_MENUS | |
90 | ||
91 | protected: | |
92 | void Init(); | |
93 | ||
94 | #if wxUSE_MENUS | |
95 | void RemoveWindowMenu(wxMenuBar *pMenuBar); | |
96 | void AddWindowMenu(wxMenuBar *pMenuBar); | |
97 | ||
98 | void DoHandleMenu(wxCommandEvent &event); | |
99 | #endif // wxUSE_MENUS | |
100 | ||
101 | virtual void DoGetClientSize(int *width, int *height) const; | |
102 | ||
103 | private: | |
104 | DECLARE_EVENT_TABLE() | |
105 | DECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame) | |
106 | }; | |
107 | ||
108 | //----------------------------------------------------------------------------- | |
109 | // wxGenericMDIChildFrame | |
110 | //----------------------------------------------------------------------------- | |
111 | ||
112 | class WXDLLEXPORT wxGenericMDIChildFrame: public wxPanel | |
113 | { | |
114 | public: | |
115 | wxGenericMDIChildFrame(); | |
116 | wxGenericMDIChildFrame( wxGenericMDIParentFrame *parent, | |
117 | wxWindowID winid, | |
118 | const wxString& title, | |
119 | const wxPoint& pos = wxDefaultPosition, | |
120 | const wxSize& size = wxDefaultSize, | |
121 | long style = wxDEFAULT_FRAME_STYLE, | |
122 | const wxString& name = wxFrameNameStr ); | |
123 | ||
124 | virtual ~wxGenericMDIChildFrame(); | |
125 | bool Create( wxGenericMDIParentFrame *parent, | |
126 | wxWindowID winid, | |
127 | const wxString& title, | |
128 | const wxPoint& pos = wxDefaultPosition, | |
129 | const wxSize& size = wxDefaultSize, | |
130 | long style = wxDEFAULT_FRAME_STYLE, | |
131 | const wxString& name = wxFrameNameStr ); | |
132 | ||
133 | #if wxUSE_MENUS | |
134 | virtual void SetMenuBar( wxMenuBar *menu_bar ); | |
135 | virtual wxMenuBar *GetMenuBar() const; | |
136 | #endif // wxUSE_MENUS | |
137 | ||
138 | virtual void SetTitle(const wxString& title); | |
139 | virtual wxString GetTitle() const; | |
140 | ||
141 | virtual void Activate(); | |
142 | ||
143 | #if wxUSE_STATUSBAR | |
144 | // no status bars | |
145 | virtual wxStatusBar* CreateStatusBar( int WXUNUSED(number) = 1, | |
146 | long WXUNUSED(style) = 1, | |
147 | wxWindowID WXUNUSED(winid) = 1, | |
148 | const wxString& WXUNUSED(name) = wxEmptyString) | |
149 | { return (wxStatusBar*)NULL; } | |
150 | ||
151 | virtual wxStatusBar *GetStatusBar() const { return (wxStatusBar*)NULL; } | |
152 | virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number)=0 ) {} | |
153 | virtual void SetStatusWidths( int WXUNUSED(n), const int WXUNUSED(widths_field)[] ) {} | |
154 | #endif | |
155 | ||
156 | // no size hints | |
157 | virtual void DoSetSizeHints( int WXUNUSED(minW), | |
158 | int WXUNUSED(minH), | |
159 | int WXUNUSED(maxW) = wxDefaultCoord, | |
160 | int WXUNUSED(maxH) = wxDefaultCoord, | |
161 | int WXUNUSED(incW) = wxDefaultCoord, | |
162 | int WXUNUSED(incH) = wxDefaultCoord) {} | |
163 | ||
164 | #if wxUSE_TOOLBAR | |
165 | // no toolbar bars | |
166 | virtual wxToolBar* CreateToolBar( long WXUNUSED(style), | |
167 | wxWindowID WXUNUSED(winid), | |
168 | const wxString& WXUNUSED(name) ) | |
169 | { return (wxToolBar*)NULL; } | |
170 | virtual wxToolBar *GetToolBar() const { return (wxToolBar*)NULL; } | |
171 | #endif | |
172 | ||
173 | // no icon | |
174 | void SetIcon( const wxIcon& WXUNUSED(icon) ) { } | |
175 | void SetIcons( const wxIconBundle& WXUNUSED(icons) ) { } | |
176 | ||
177 | // no maximize etc | |
178 | virtual void Maximize( bool WXUNUSED(maximize) = true) { /* Has no effect */ } | |
179 | virtual void Restore() { /* Has no effect */ } | |
180 | virtual void Iconize(bool WXUNUSED(iconize) = true) { /* Has no effect */ } | |
181 | virtual bool IsMaximized() const { return true; } | |
182 | virtual bool IsIconized() const { return false; } | |
183 | virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style)) { return false; } | |
184 | virtual bool IsFullScreen() const { return false; } | |
185 | ||
186 | virtual bool IsTopLevel() const { return false; } | |
187 | ||
188 | void OnMenuHighlight(wxMenuEvent& event); | |
189 | void OnActivate(wxActivateEvent& event); | |
190 | ||
191 | // The next 2 are copied from top level... | |
192 | void OnCloseWindow(wxCloseEvent& event); | |
193 | void OnSize(wxSizeEvent& event); | |
194 | ||
195 | void SetMDIParentFrame(wxGenericMDIParentFrame* parentFrame); | |
196 | wxGenericMDIParentFrame* GetMDIParentFrame() const; | |
197 | ||
198 | protected: | |
199 | wxGenericMDIParentFrame *m_pMDIParentFrame; | |
200 | wxRect m_MDIRect; | |
201 | wxString m_Title; | |
202 | ||
203 | #if wxUSE_MENUS | |
204 | wxMenuBar *m_pMenuBar; | |
205 | #endif // wxUSE_MENUS | |
206 | ||
207 | protected: | |
208 | void Init(); | |
209 | ||
210 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
211 | ||
212 | // This function needs to be called when a size change is confirmed, | |
213 | // we needed this function to prevent any body from the outside | |
214 | // changing the panel... it messes the UI layout when we would allow it. | |
215 | void ApplyMDIChildFrameRect(); | |
216 | ||
217 | private: | |
218 | DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame) | |
219 | DECLARE_EVENT_TABLE() | |
220 | ||
221 | friend class wxGenericMDIClientWindow; | |
222 | }; | |
223 | ||
224 | //----------------------------------------------------------------------------- | |
225 | // wxGenericMDIClientWindow | |
226 | //----------------------------------------------------------------------------- | |
227 | ||
228 | class WXDLLEXPORT wxGenericMDIClientWindow: public wxNotebook | |
229 | { | |
230 | public: | |
231 | wxGenericMDIClientWindow(); | |
232 | wxGenericMDIClientWindow( wxGenericMDIParentFrame *parent, long style = 0 ); | |
233 | ~wxGenericMDIClientWindow(); | |
234 | virtual bool CreateClient( wxGenericMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL ); | |
235 | ||
236 | virtual int SetSelection(size_t nPage); | |
237 | ||
238 | protected: | |
239 | void PageChanged(int OldSelection, int newSelection); | |
240 | ||
241 | void OnPageChanged(wxNotebookEvent& event); | |
242 | void OnSize(wxSizeEvent& event); | |
243 | ||
244 | private: | |
245 | DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow) | |
246 | DECLARE_EVENT_TABLE() | |
247 | }; | |
248 | ||
249 | ||
250 | /* | |
251 | * Define normal wxMDI classes based on wxGenericMDI | |
252 | */ | |
253 | ||
254 | #ifndef wxUSE_GENERIC_MDI_AS_NATIVE | |
255 | #if defined(__WXUNIVERSAL__) || defined(__WXPM__) || defined(__WXCOCOA__) | |
256 | #define wxUSE_GENERIC_MDI_AS_NATIVE 1 | |
257 | #else | |
258 | #define wxUSE_GENERIC_MDI_AS_NATIVE 0 | |
259 | #endif | |
260 | #endif // wxUSE_GENERIC_MDI_AS_NATIVE | |
261 | ||
262 | #if wxUSE_GENERIC_MDI_AS_NATIVE | |
263 | ||
264 | class wxMDIChildFrame ; | |
265 | ||
266 | //----------------------------------------------------------------------------- | |
267 | // wxMDIParentFrame | |
268 | //----------------------------------------------------------------------------- | |
269 | ||
270 | class WXDLLEXPORT wxMDIParentFrame: public wxGenericMDIParentFrame | |
271 | { | |
272 | public: | |
273 | wxMDIParentFrame() {} | |
274 | wxMDIParentFrame(wxWindow *parent, | |
275 | wxWindowID winid, | |
276 | const wxString& title, | |
277 | const wxPoint& pos = wxDefaultPosition, | |
278 | const wxSize& size = wxDefaultSize, | |
279 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
280 | const wxString& name = wxFrameNameStr) | |
281 | :wxGenericMDIParentFrame(parent, winid, title, pos, size, style, name) | |
282 | { | |
283 | } | |
284 | ||
285 | wxMDIChildFrame * GetActiveChild() const ; | |
286 | ||
287 | ||
288 | private: | |
289 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) | |
290 | }; | |
291 | ||
292 | //----------------------------------------------------------------------------- | |
293 | // wxMDIChildFrame | |
294 | //----------------------------------------------------------------------------- | |
295 | ||
296 | class WXDLLEXPORT wxMDIChildFrame: public wxGenericMDIChildFrame | |
297 | { | |
298 | public: | |
299 | wxMDIChildFrame() {} | |
300 | ||
301 | wxMDIChildFrame( wxGenericMDIParentFrame *parent, | |
302 | wxWindowID winid, | |
303 | const wxString& title, | |
304 | const wxPoint& pos = wxDefaultPosition, | |
305 | const wxSize& size = wxDefaultSize, | |
306 | long style = wxDEFAULT_FRAME_STYLE, | |
307 | const wxString& name = wxFrameNameStr ) | |
308 | :wxGenericMDIChildFrame(parent, winid, title, pos, size, style, name) | |
309 | { | |
310 | } | |
311 | private: | |
312 | DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) | |
313 | }; | |
314 | ||
315 | //----------------------------------------------------------------------------- | |
316 | // wxMDIClientWindow | |
317 | //----------------------------------------------------------------------------- | |
318 | ||
319 | class WXDLLEXPORT wxMDIClientWindow: public wxGenericMDIClientWindow | |
320 | { | |
321 | public: | |
322 | wxMDIClientWindow() {} | |
323 | ||
324 | wxMDIClientWindow( wxGenericMDIParentFrame *parent, long style = 0 ) | |
325 | :wxGenericMDIClientWindow(parent, style) | |
326 | { | |
327 | } | |
328 | ||
329 | private: | |
330 | DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) | |
331 | }; | |
332 | ||
333 | #endif | |
334 | ||
335 | #endif | |
336 | // _WX_MDIG_H_ |