1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/mdig.h
3 // Purpose: Generic MDI (Multiple Document Interface) classes
4 // Author: Hans Van Leemputten
8 // Copyright: (c) Hans Van Leemputten
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
21 #include "wx/notebook.h"
23 extern WXDLLEXPORT_DATA(const wxChar
) wxFrameNameStr
[];
24 extern WXDLLEXPORT_DATA(const wxChar
) wxStatusLineNameStr
[];
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31 class WXDLLEXPORT wxGenericMDIParentFrame
;
32 class WXDLLEXPORT wxGenericMDIClientWindow
;
33 class WXDLLEXPORT wxGenericMDIChildFrame
;
35 //-----------------------------------------------------------------------------
36 // wxGenericMDIParentFrame
37 //-----------------------------------------------------------------------------
39 class WXDLLEXPORT wxGenericMDIParentFrame
: public wxFrame
42 wxGenericMDIParentFrame();
43 wxGenericMDIParentFrame(wxWindow
*parent
,
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
);
51 ~wxGenericMDIParentFrame();
52 bool Create( wxWindow
*parent
,
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
);
61 wxMenu
* GetWindowMenu() const { return m_pWindowMenu
; };
62 void SetWindowMenu(wxMenu
* pMenu
);
64 virtual void SetMenuBar(wxMenuBar
*pMenuBar
);
67 void SetChildMenuBar(wxGenericMDIChildFrame
*pChild
);
69 virtual bool ProcessEvent(wxEvent
& event
);
71 wxGenericMDIChildFrame
*GetActiveChild() const;
72 inline void SetActiveChild(wxGenericMDIChildFrame
* pChildFrame
);
74 wxGenericMDIClientWindow
*GetClientWindow() const;
75 virtual wxGenericMDIClientWindow
*OnCreateClient();
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();
84 wxGenericMDIClientWindow
*m_pClientWindow
;
85 wxGenericMDIChildFrame
*m_pActiveChild
;
87 wxMenu
*m_pWindowMenu
;
88 wxMenuBar
*m_pMyMenuBar
;
95 void RemoveWindowMenu(wxMenuBar
*pMenuBar
);
96 void AddWindowMenu(wxMenuBar
*pMenuBar
);
98 void DoHandleMenu(wxCommandEvent
&event
);
101 virtual void DoGetClientSize(int *width
, int *height
) const;
104 DECLARE_EVENT_TABLE()
105 DECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame
)
108 //-----------------------------------------------------------------------------
109 // wxGenericMDIChildFrame
110 //-----------------------------------------------------------------------------
112 class WXDLLEXPORT wxGenericMDIChildFrame
: public wxPanel
115 wxGenericMDIChildFrame();
116 wxGenericMDIChildFrame( wxGenericMDIParentFrame
*parent
,
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
);
124 virtual ~wxGenericMDIChildFrame();
125 bool Create( wxGenericMDIParentFrame
*parent
,
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
);
134 virtual void SetMenuBar( wxMenuBar
*menu_bar
);
135 virtual wxMenuBar
*GetMenuBar() const;
136 #endif // wxUSE_MENUS
138 virtual void SetTitle(const wxString
& title
);
139 virtual wxString
GetTitle() const;
141 virtual void Activate();
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
; }
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
)[] ) {}
157 virtual void DoSetSizeHints( int WXUNUSED(minW
),
159 int WXUNUSED(maxW
) = wxDefaultCoord
,
160 int WXUNUSED(maxH
) = wxDefaultCoord
,
161 int WXUNUSED(incW
) = wxDefaultCoord
,
162 int WXUNUSED(incH
) = wxDefaultCoord
) {}
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
; }
174 void SetIcon( const wxIcon
& WXUNUSED(icon
) ) { }
175 void SetIcons( const wxIconBundle
& WXUNUSED(icons
) ) { }
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; }
186 virtual bool IsTopLevel() const { return false; }
188 void OnMenuHighlight(wxMenuEvent
& event
);
189 void OnActivate(wxActivateEvent
& event
);
191 // The next 2 are copied from top level...
192 void OnCloseWindow(wxCloseEvent
& event
);
193 void OnSize(wxSizeEvent
& event
);
195 void SetMDIParentFrame(wxGenericMDIParentFrame
* parentFrame
);
196 wxGenericMDIParentFrame
* GetMDIParentFrame() const;
199 wxGenericMDIParentFrame
*m_pMDIParentFrame
;
204 wxMenuBar
*m_pMenuBar
;
205 #endif // wxUSE_MENUS
210 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
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();
218 DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame
)
219 DECLARE_EVENT_TABLE()
221 friend class wxGenericMDIClientWindow
;
224 //-----------------------------------------------------------------------------
225 // wxGenericMDIClientWindow
226 //-----------------------------------------------------------------------------
228 class WXDLLEXPORT wxGenericMDIClientWindow
: public wxNotebook
231 wxGenericMDIClientWindow();
232 wxGenericMDIClientWindow( wxGenericMDIParentFrame
*parent
, long style
= 0 );
233 ~wxGenericMDIClientWindow();
234 virtual bool CreateClient( wxGenericMDIParentFrame
*parent
, long style
= wxVSCROLL
| wxHSCROLL
);
236 virtual int SetSelection(size_t nPage
);
239 void PageChanged(int OldSelection
, int newSelection
);
241 void OnPageChanged(wxNotebookEvent
& event
);
242 void OnSize(wxSizeEvent
& event
);
245 DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow
)
246 DECLARE_EVENT_TABLE()
251 * Define normal wxMDI classes based on wxGenericMDI
254 #ifndef wxUSE_GENERIC_MDI_AS_NATIVE
255 #if defined(__WXUNIVERSAL__) || defined(__WXPM__) || defined(__WXCOCOA__)
256 #define wxUSE_GENERIC_MDI_AS_NATIVE 1
258 #define wxUSE_GENERIC_MDI_AS_NATIVE 0
260 #endif // wxUSE_GENERIC_MDI_AS_NATIVE
262 #if wxUSE_GENERIC_MDI_AS_NATIVE
264 class wxMDIChildFrame
;
266 //-----------------------------------------------------------------------------
268 //-----------------------------------------------------------------------------
270 class WXDLLEXPORT wxMDIParentFrame
: public wxGenericMDIParentFrame
273 wxMDIParentFrame() {}
274 wxMDIParentFrame(wxWindow
*parent
,
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
)
285 wxMDIChildFrame
* GetActiveChild() const ;
289 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
292 //-----------------------------------------------------------------------------
294 //-----------------------------------------------------------------------------
296 class WXDLLEXPORT wxMDIChildFrame
: public wxGenericMDIChildFrame
301 wxMDIChildFrame( wxGenericMDIParentFrame
*parent
,
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
)
312 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
315 //-----------------------------------------------------------------------------
317 //-----------------------------------------------------------------------------
319 class WXDLLEXPORT wxMDIClientWindow
: public wxGenericMDIClientWindow
322 wxMDIClientWindow() {}
324 wxMDIClientWindow( wxGenericMDIParentFrame
*parent
, long style
= 0 )
325 :wxGenericMDIClientWindow(parent
, style
)
330 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)