1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/mdig.h
3 // Purpose: Generic MDI (Multiple Document Interface) classes
4 // Author: Hans Van Leemputten
5 // Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
7 // Copyright: (c) 2002 Hans Van Leemputten
8 // (c) 2008 Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GENERIC_MDIG_H_
13 #define _WX_GENERIC_MDIG_H_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
21 class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase
;
22 class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent
;
23 class WXDLLIMPEXP_FWD_CORE wxIcon
;
24 class WXDLLIMPEXP_FWD_CORE wxIconBundle
;
25 class WXDLLIMPEXP_FWD_CORE wxNotebook
;
27 #if wxUSE_GENERIC_MDI_AS_NATIVE
28 #define wxGenericMDIParentFrame wxMDIParentFrame
29 #define wxGenericMDIChildFrame wxMDIChildFrame
30 #define wxGenericMDIClientWindow wxMDIClientWindow
31 #else // !wxUSE_GENERIC_MDI_AS_NATIVE
32 class WXDLLIMPEXP_FWD_CORE wxGenericMDIParentFrame
;
33 class WXDLLIMPEXP_FWD_CORE wxGenericMDIChildFrame
;
34 class WXDLLIMPEXP_FWD_CORE wxGenericMDIClientWindow
;
35 #endif // wxUSE_GENERIC_MDI_AS_NATIVE/!wxUSE_GENERIC_MDI_AS_NATIVE
37 // ----------------------------------------------------------------------------
38 // wxGenericMDIParentFrame
39 // ----------------------------------------------------------------------------
41 class WXDLLIMPEXP_CORE wxGenericMDIParentFrame
: public wxMDIParentFrameBase
44 wxGenericMDIParentFrame() { Init(); }
45 wxGenericMDIParentFrame(wxWindow
*parent
,
47 const wxString
& title
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
,
50 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
51 const wxString
& name
= wxFrameNameStr
)
55 Create(parent
, winid
, title
, pos
, size
, style
, name
);
58 bool Create(wxWindow
*parent
,
60 const wxString
& title
,
61 const wxPoint
& pos
= wxDefaultPosition
,
62 const wxSize
& size
= wxDefaultSize
,
63 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
64 const wxString
& name
= wxFrameNameStr
);
66 virtual ~wxGenericMDIParentFrame();
68 // implement base class pure virtuals
69 static bool IsTDI() { return true; }
71 virtual void ActivateNext() { AdvanceActive(true); }
72 virtual void ActivatePrevious() { AdvanceActive(false); }
75 virtual void SetWindowMenu(wxMenu
* pMenu
);
77 virtual void SetMenuBar(wxMenuBar
*pMenuBar
);
80 virtual wxGenericMDIClientWindow
*OnCreateGenericClient();
83 // implementation only from now on
84 void WXSetChildMenuBar(wxGenericMDIChildFrame
*child
);
85 void WXUpdateChildTitle(wxGenericMDIChildFrame
*child
);
86 void WXActivateChild(wxGenericMDIChildFrame
*child
);
87 void WXRemoveChild(wxGenericMDIChildFrame
*child
);
88 bool WXIsActiveChild(wxGenericMDIChildFrame
*child
) const;
89 bool WXIsInsideChildHandler(wxGenericMDIChildFrame
*child
) const;
91 // return the book control used by the client window to manage the pages
92 wxBookCtrlBase
*GetBookCtrl() const;
96 wxMenuBar
*m_pMyMenuBar
;
99 // advance the activation forward or backwards
100 void AdvanceActive(bool forward
);
106 void RemoveWindowMenu(wxMenuBar
*pMenuBar
);
107 void AddWindowMenu(wxMenuBar
*pMenuBar
);
109 void OnWindowMenu(wxCommandEvent
& event
);
110 #endif // wxUSE_MENUS
112 virtual bool ProcessEvent(wxEvent
& event
);
114 void OnClose(wxCloseEvent
& event
);
116 // return the client window, may be NULL if we hadn't been created yet
117 wxGenericMDIClientWindow
*GetGenericClientWindow() const;
119 // close all children, return false if any of them vetoed it
123 // this pointer is non-NULL if we're currently inside our ProcessEvent()
124 // and we forwarded the event to this child (as we do with menu events)
125 wxMDIChildFrameBase
*m_childHandler
;
127 DECLARE_EVENT_TABLE()
128 DECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame
)
131 // ----------------------------------------------------------------------------
132 // wxGenericMDIChildFrame
133 // ----------------------------------------------------------------------------
135 class WXDLLIMPEXP_CORE wxGenericMDIChildFrame
: public wxTDIChildFrame
138 wxGenericMDIChildFrame() { Init(); }
139 wxGenericMDIChildFrame(wxGenericMDIParentFrame
*parent
,
141 const wxString
& title
,
142 const wxPoint
& pos
= wxDefaultPosition
,
143 const wxSize
& size
= wxDefaultSize
,
144 long style
= wxDEFAULT_FRAME_STYLE
,
145 const wxString
& name
= wxFrameNameStr
)
149 Create(parent
, winid
, title
, pos
, size
, style
, name
);
152 bool Create(wxGenericMDIParentFrame
*parent
,
154 const wxString
& title
,
155 const wxPoint
& pos
= wxDefaultPosition
,
156 const wxSize
& size
= wxDefaultSize
,
157 long style
= wxDEFAULT_FRAME_STYLE
,
158 const wxString
& name
= wxFrameNameStr
);
160 virtual ~wxGenericMDIChildFrame();
162 // implement MDI operations
163 virtual void Activate();
167 virtual void SetMenuBar( wxMenuBar
*menu_bar
);
168 virtual wxMenuBar
*GetMenuBar() const;
169 #endif // wxUSE_MENUS
171 virtual wxString
GetTitle() const { return m_title
; }
172 virtual void SetTitle(const wxString
& title
);
174 virtual bool TryAfter(wxEvent
& event
);
176 // implementation only from now on
178 wxGenericMDIParentFrame
* GetGenericMDIParent() const
180 #if wxUSE_GENERIC_MDI_AS_NATIVE
181 return GetMDIParent();
182 #else // generic != native
183 return m_mdiParentGeneric
;
191 wxMenuBar
*m_pMenuBar
;
192 #endif // wxUSE_MENUS
194 #if !wxUSE_GENERIC_MDI_AS_NATIVE
195 wxGenericMDIParentFrame
*m_mdiParentGeneric
;
202 void OnMenuHighlight(wxMenuEvent
& event
);
203 void OnClose(wxCloseEvent
& event
);
205 DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame
)
206 DECLARE_EVENT_TABLE()
208 friend class wxGenericMDIClientWindow
;
211 // ----------------------------------------------------------------------------
212 // wxGenericMDIClientWindow
213 // ----------------------------------------------------------------------------
215 class WXDLLIMPEXP_CORE wxGenericMDIClientWindow
: public wxMDIClientWindowBase
218 wxGenericMDIClientWindow() { }
220 // unfortunately we need to provide our own version of CreateClient()
221 // because of the difference in the type of the first parameter and
222 // implement the base class pure virtual method in terms of it
223 // (CreateGenericClient() is virtual itself to allow customizing the client
224 // window creation by overriding it in the derived classes)
225 virtual bool CreateGenericClient(wxWindow
*parent
);
226 virtual bool CreateClient(wxMDIParentFrame
*parent
,
227 long WXUNUSED(style
) = wxVSCROLL
| wxHSCROLL
)
229 return CreateGenericClient(parent
);
232 // implementation only
233 wxBookCtrlBase
*GetBookCtrl() const;
234 wxGenericMDIChildFrame
*GetChild(size_t pos
) const;
235 int FindChild(wxGenericMDIChildFrame
*child
) const;
238 void PageChanged(int OldSelection
, int newSelection
);
240 void OnPageChanged(wxBookCtrlEvent
& event
);
241 void OnSize(wxSizeEvent
& event
);
243 // the notebook containing all MDI children as its pages
244 wxNotebook
*m_notebook
;
246 DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow
)
249 // ----------------------------------------------------------------------------
250 // inline functions implementation
251 // ----------------------------------------------------------------------------
254 wxGenericMDIParentFrame::
255 WXIsInsideChildHandler(wxGenericMDIChildFrame
*child
) const
257 return child
== m_childHandler
;
260 #endif // _WX_GENERIC_MDIG_H_