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