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
8 // Copyright: (c) 2002 Hans Van Leemputten
9 // (c) 2008 Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_GENERIC_MDIG_H_
14 #define _WX_GENERIC_MDIG_H_
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
22 class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase
;
23 class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent
;
24 class WXDLLIMPEXP_FWD_CORE wxIcon
;
25 class WXDLLIMPEXP_FWD_CORE wxIconBundle
;
26 class WXDLLIMPEXP_FWD_CORE wxNotebook
;
28 #if wxUSE_GENERIC_MDI_AS_NATIVE
29 #define wxGenericMDIParentFrame wxMDIParentFrame
30 #define wxGenericMDIChildFrame wxMDIChildFrame
31 #define wxGenericMDIClientWindow wxMDIClientWindow
32 #else // !wxUSE_GENERIC_MDI_AS_NATIVE
33 class WXDLLIMPEXP_FWD_CORE wxGenericMDIParentFrame
;
34 class WXDLLIMPEXP_FWD_CORE wxGenericMDIChildFrame
;
35 class WXDLLIMPEXP_FWD_CORE wxGenericMDIClientWindow
;
36 #endif // wxUSE_GENERIC_MDI_AS_NATIVE/!wxUSE_GENERIC_MDI_AS_NATIVE
38 // ----------------------------------------------------------------------------
39 // wxGenericMDIParentFrame
40 // ----------------------------------------------------------------------------
42 class WXDLLIMPEXP_CORE wxGenericMDIParentFrame
: public wxMDIParentFrameBase
45 wxGenericMDIParentFrame() { Init(); }
46 wxGenericMDIParentFrame(wxWindow
*parent
,
48 const wxString
& title
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
51 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
52 const wxString
& name
= wxFrameNameStr
)
56 Create(parent
, winid
, title
, pos
, size
, style
, name
);
59 bool Create(wxWindow
*parent
,
61 const wxString
& title
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
64 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
65 const wxString
& name
= wxFrameNameStr
);
67 virtual ~wxGenericMDIParentFrame();
69 // implement base class pure virtuals
70 static bool IsTDI() { return true; }
72 virtual void ActivateNext() { AdvanceActive(true); }
73 virtual void ActivatePrevious() { AdvanceActive(false); }
76 virtual void SetWindowMenu(wxMenu
* pMenu
);
78 virtual void SetMenuBar(wxMenuBar
*pMenuBar
);
81 virtual bool ProcessEvent(wxEvent
& event
);
83 virtual wxGenericMDIClientWindow
*OnCreateGenericClient();
86 // implementation only from now on
87 void WXSetChildMenuBar(wxGenericMDIChildFrame
*child
);
88 void WXUpdateChildTitle(wxGenericMDIChildFrame
*child
);
89 void WXActivateChild(wxGenericMDIChildFrame
*child
);
90 void WXRemoveChild(wxGenericMDIChildFrame
*child
);
91 bool WXIsActiveChild(wxGenericMDIChildFrame
*child
) const;
92 bool WXIsInsideChildHandler(wxGenericMDIChildFrame
*child
) const;
94 // return the book control used by the client window to manage the pages
95 wxBookCtrlBase
*GetBookCtrl() const;
99 wxMenuBar
*m_pMyMenuBar
;
100 #endif // wxUSE_MENUS
102 // advance the activation forward or backwards
103 void AdvanceActive(bool forward
);
109 void RemoveWindowMenu(wxMenuBar
*pMenuBar
);
110 void AddWindowMenu(wxMenuBar
*pMenuBar
);
112 void OnWindowMenu(wxCommandEvent
& event
);
113 #endif // wxUSE_MENUS
115 void OnClose(wxCloseEvent
& event
);
117 // return the client window, may be NULL if we hadn't been created yet
118 wxGenericMDIClientWindow
*GetGenericClientWindow() const;
120 // close all children, return false if any of them vetoed it
124 // this pointer is non-NULL if we're currently inside our ProcessEvent()
125 // and we forwarded the event to this child (as we do with menu events)
126 wxMDIChildFrameBase
*m_childHandler
;
128 DECLARE_EVENT_TABLE()
129 DECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame
)
132 // ----------------------------------------------------------------------------
133 // wxGenericMDIChildFrame
134 // ----------------------------------------------------------------------------
136 class WXDLLIMPEXP_CORE wxGenericMDIChildFrame
: public wxTDIChildFrame
139 wxGenericMDIChildFrame() { Init(); }
140 wxGenericMDIChildFrame(wxGenericMDIParentFrame
*parent
,
142 const wxString
& title
,
143 const wxPoint
& pos
= wxDefaultPosition
,
144 const wxSize
& size
= wxDefaultSize
,
145 long style
= wxDEFAULT_FRAME_STYLE
,
146 const wxString
& name
= wxFrameNameStr
)
150 Create(parent
, winid
, title
, pos
, size
, style
, name
);
153 bool Create(wxGenericMDIParentFrame
*parent
,
155 const wxString
& title
,
156 const wxPoint
& pos
= wxDefaultPosition
,
157 const wxSize
& size
= wxDefaultSize
,
158 long style
= wxDEFAULT_FRAME_STYLE
,
159 const wxString
& name
= wxFrameNameStr
);
161 virtual ~wxGenericMDIChildFrame();
163 // implement MDI operations
164 virtual void Activate();
168 virtual void SetMenuBar( wxMenuBar
*menu_bar
);
169 virtual wxMenuBar
*GetMenuBar() const;
170 #endif // wxUSE_MENUS
172 virtual wxString
GetTitle() const { return m_title
; }
173 virtual void SetTitle(const wxString
& title
);
175 virtual bool TryParent(wxEvent
& event
);
177 // implementation only from now on
179 wxGenericMDIParentFrame
* GetGenericMDIParent() const
181 #if wxUSE_GENERIC_MDI_AS_NATIVE
182 return GetMDIParent();
183 #else // generic != native
184 return m_mdiParentGeneric
;
192 wxMenuBar
*m_pMenuBar
;
193 #endif // wxUSE_MENUS
195 #if !wxUSE_GENERIC_MDI_AS_NATIVE
196 wxGenericMDIParentFrame
*m_mdiParentGeneric
;
203 void OnMenuHighlight(wxMenuEvent
& event
);
204 void OnClose(wxCloseEvent
& event
);
206 DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame
)
207 DECLARE_EVENT_TABLE()
209 friend class wxGenericMDIClientWindow
;
212 // ----------------------------------------------------------------------------
213 // wxGenericMDIClientWindow
214 // ----------------------------------------------------------------------------
216 class WXDLLIMPEXP_CORE wxGenericMDIClientWindow
: public wxMDIClientWindowBase
219 wxGenericMDIClientWindow() { }
221 // unfortunately we need to provide our own version of CreateClient()
222 // because of the difference in the type of the first parameter and
223 // implement the base class pure virtual method in terms of it
224 // (CreateGenericClient() is virtual itself to allow customizing the client
225 // window creation by overriding it in the derived classes)
226 virtual bool CreateGenericClient(wxWindow
*parent
);
227 virtual bool CreateClient(wxMDIParentFrame
*parent
,
228 long WXUNUSED(style
) = wxVSCROLL
| wxHSCROLL
)
230 return CreateGenericClient(parent
);
233 // implementation only
234 wxBookCtrlBase
*GetBookCtrl() const;
235 wxGenericMDIChildFrame
*GetChild(size_t pos
) const;
236 int FindChild(wxGenericMDIChildFrame
*child
) const;
239 void PageChanged(int OldSelection
, int newSelection
);
241 void OnPageChanged(wxBookCtrlEvent
& event
);
242 void OnSize(wxSizeEvent
& event
);
244 // the notebook containing all MDI children as its pages
245 wxNotebook
*m_notebook
;
247 DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow
)
250 // ----------------------------------------------------------------------------
251 // inline functions implementation
252 // ----------------------------------------------------------------------------
255 wxGenericMDIParentFrame::
256 WXIsInsideChildHandler(wxGenericMDIChildFrame
*child
) const
258 return child
== m_childHandler
;
261 #endif // _WX_GENERIC_MDIG_H_