]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/mdig.h
added Show/HideWithEffect() and implemented them using AnimateWindow() for Win32
[wxWidgets.git] / include / wx / generic / mdig.h
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 char) wxStatusLineNameStr[];
24
25
26 //-----------------------------------------------------------------------------
27 // classes
28 //-----------------------------------------------------------------------------
29
30 class WXDLLIMPEXP_FWD_CORE wxGenericMDIParentFrame;
31 class WXDLLIMPEXP_FWD_CORE wxGenericMDIClientWindow;
32 class WXDLLIMPEXP_FWD_CORE wxGenericMDIChildFrame;
33
34 //-----------------------------------------------------------------------------
35 // wxGenericMDIParentFrame
36 //-----------------------------------------------------------------------------
37
38 class WXDLLEXPORT wxGenericMDIParentFrame: public wxFrame
39 {
40 public:
41 wxGenericMDIParentFrame();
42 wxGenericMDIParentFrame(wxWindow *parent,
43 wxWindowID winid,
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
50 virtual ~wxGenericMDIParentFrame();
51 bool Create( wxWindow *parent,
52 wxWindowID winid,
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; };
61 void SetWindowMenu(wxMenu* pMenu);
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 */ }
77 virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL) { }
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,
116 wxWindowID winid,
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,
125 wxWindowID winid,
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
132 #if wxUSE_MENUS
133 virtual void SetMenuBar( wxMenuBar *menu_bar );
134 virtual wxMenuBar *GetMenuBar() const;
135 #endif // wxUSE_MENUS
136
137 virtual void SetTitle(const wxString& title);
138 virtual wxString GetTitle() const;
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,
146 wxWindowID WXUNUSED(winid) = 1,
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 #if wxUSE_TOOLBAR
156 // no toolbar bars
157 virtual wxToolBar* CreateToolBar( long WXUNUSED(style),
158 wxWindowID WXUNUSED(winid),
159 const wxString& WXUNUSED(name) )
160 { return (wxToolBar*)NULL; }
161 virtual wxToolBar *GetToolBar() const { return (wxToolBar*)NULL; }
162 #endif
163
164 // no icon
165 virtual void SetIcons( const wxIconBundle& WXUNUSED(icons) ) { }
166
167 // no maximize etc
168 virtual void Maximize( bool WXUNUSED(maximize) = true) { /* Has no effect */ }
169 virtual void Restore() { /* Has no effect */ }
170 virtual void Iconize(bool WXUNUSED(iconize) = true) { /* Has no effect */ }
171 virtual bool IsMaximized() const { return true; }
172 virtual bool IsIconized() const { return false; }
173 virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style)) { return false; }
174 virtual bool IsFullScreen() const { return false; }
175
176 virtual bool IsTopLevel() const { return false; }
177
178 void OnMenuHighlight(wxMenuEvent& event);
179 void OnActivate(wxActivateEvent& event);
180
181 // The next 2 are copied from top level...
182 void OnCloseWindow(wxCloseEvent& event);
183 void OnSize(wxSizeEvent& event);
184
185 void SetMDIParentFrame(wxGenericMDIParentFrame* parentFrame);
186 wxGenericMDIParentFrame* GetMDIParentFrame() const;
187
188 protected:
189 wxGenericMDIParentFrame *m_pMDIParentFrame;
190 wxRect m_MDIRect;
191 wxString m_Title;
192
193 #if wxUSE_MENUS
194 wxMenuBar *m_pMenuBar;
195 #endif // wxUSE_MENUS
196
197 protected:
198 void Init();
199
200 virtual void DoMoveWindow(int x, int y, int width, int height);
201
202 // no size hints
203 virtual void DoSetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH),
204 int WXUNUSED(maxW), int WXUNUSED(maxH),
205 int WXUNUSED(incW), int WXUNUSED(incH)) {}
206
207 // This function needs to be called when a size change is confirmed,
208 // we needed this function to prevent any body from the outside
209 // changing the panel... it messes the UI layout when we would allow it.
210 void ApplyMDIChildFrameRect();
211
212 private:
213 DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame)
214 DECLARE_EVENT_TABLE()
215
216 friend class wxGenericMDIClientWindow;
217 };
218
219 //-----------------------------------------------------------------------------
220 // wxGenericMDIClientWindow
221 //-----------------------------------------------------------------------------
222
223 class WXDLLEXPORT wxGenericMDIClientWindow: public wxNotebook
224 {
225 public:
226 wxGenericMDIClientWindow();
227 wxGenericMDIClientWindow( wxGenericMDIParentFrame *parent, long style = 0 );
228 virtual ~wxGenericMDIClientWindow();
229 virtual bool CreateClient( wxGenericMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL );
230
231 virtual int SetSelection(size_t nPage);
232
233 protected:
234 void PageChanged(int OldSelection, int newSelection);
235
236 void OnPageChanged(wxNotebookEvent& event);
237 void OnSize(wxSizeEvent& event);
238
239 private:
240 DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow)
241 DECLARE_EVENT_TABLE()
242 };
243
244
245 /*
246 * Define normal wxMDI classes based on wxGenericMDI
247 */
248
249 #ifndef wxUSE_GENERIC_MDI_AS_NATIVE
250 #if defined(__WXUNIVERSAL__) || defined(__WXPM__) || defined(__WXCOCOA__)
251 #define wxUSE_GENERIC_MDI_AS_NATIVE 1
252 #else
253 #define wxUSE_GENERIC_MDI_AS_NATIVE 0
254 #endif
255 #endif // wxUSE_GENERIC_MDI_AS_NATIVE
256
257 #if wxUSE_GENERIC_MDI_AS_NATIVE
258
259 class wxMDIChildFrame ;
260
261 //-----------------------------------------------------------------------------
262 // wxMDIParentFrame
263 //-----------------------------------------------------------------------------
264
265 class WXDLLEXPORT wxMDIParentFrame: public wxGenericMDIParentFrame
266 {
267 public:
268 wxMDIParentFrame() {}
269 wxMDIParentFrame(wxWindow *parent,
270 wxWindowID winid,
271 const wxString& title,
272 const wxPoint& pos = wxDefaultPosition,
273 const wxSize& size = wxDefaultSize,
274 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
275 const wxString& name = wxFrameNameStr)
276 :wxGenericMDIParentFrame(parent, winid, title, pos, size, style, name)
277 {
278 }
279
280 wxMDIChildFrame * GetActiveChild() const ;
281
282
283 private:
284 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
285 };
286
287 //-----------------------------------------------------------------------------
288 // wxMDIChildFrame
289 //-----------------------------------------------------------------------------
290
291 class WXDLLEXPORT wxMDIChildFrame: public wxGenericMDIChildFrame
292 {
293 public:
294 wxMDIChildFrame() {}
295
296 wxMDIChildFrame( wxGenericMDIParentFrame *parent,
297 wxWindowID winid,
298 const wxString& title,
299 const wxPoint& pos = wxDefaultPosition,
300 const wxSize& size = wxDefaultSize,
301 long style = wxDEFAULT_FRAME_STYLE,
302 const wxString& name = wxFrameNameStr )
303 :wxGenericMDIChildFrame(parent, winid, title, pos, size, style, name)
304 {
305 }
306 private:
307 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
308 };
309
310 //-----------------------------------------------------------------------------
311 // wxMDIClientWindow
312 //-----------------------------------------------------------------------------
313
314 class WXDLLEXPORT wxMDIClientWindow: public wxGenericMDIClientWindow
315 {
316 public:
317 wxMDIClientWindow() {}
318
319 wxMDIClientWindow( wxGenericMDIParentFrame *parent, long style = 0 )
320 :wxGenericMDIClientWindow(parent, style)
321 {
322 }
323
324 private:
325 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
326 };
327
328 #endif
329
330 #endif
331 // _WX_MDIG_H_