]>
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 | |
d2824cdb | 5 | // Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes |
6c70a9b5 | 6 | // Created: 29/07/2002 |
d2824cdb VZ |
7 | // Copyright: (c) 2002 Hans Van Leemputten |
8 | // (c) 2008 Vadim Zeitlin | |
65571936 | 9 | // Licence: wxWindows licence |
6c70a9b5 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
d2824cdb VZ |
12 | #ifndef _WX_GENERIC_MDIG_H_ |
13 | #define _WX_GENERIC_MDIG_H_ | |
6c70a9b5 | 14 | |
6c70a9b5 JS |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
6c70a9b5 | 19 | #include "wx/panel.h" |
6c70a9b5 | 20 | |
d2824cdb VZ |
21 | class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase; |
22 | class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent; | |
75aea0d8 VZ |
23 | class WXDLLIMPEXP_FWD_CORE wxIcon; |
24 | class WXDLLIMPEXP_FWD_CORE wxIconBundle; | |
d2824cdb | 25 | class WXDLLIMPEXP_FWD_CORE wxNotebook; |
75aea0d8 | 26 | |
d2824cdb VZ |
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 | |
6c70a9b5 | 36 | |
d2824cdb | 37 | // ---------------------------------------------------------------------------- |
6c70a9b5 | 38 | // wxGenericMDIParentFrame |
d2824cdb | 39 | // ---------------------------------------------------------------------------- |
6c70a9b5 | 40 | |
d2824cdb | 41 | class WXDLLIMPEXP_CORE wxGenericMDIParentFrame : public wxMDIParentFrameBase |
6c70a9b5 JS |
42 | { |
43 | public: | |
d2824cdb | 44 | wxGenericMDIParentFrame() { Init(); } |
6c70a9b5 | 45 | wxGenericMDIParentFrame(wxWindow *parent, |
aa6f64c7 | 46 | wxWindowID winid, |
6c70a9b5 JS |
47 | const wxString& title, |
48 | const wxPoint& pos = wxDefaultPosition, | |
49 | const wxSize& size = wxDefaultSize, | |
50 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
d2824cdb VZ |
51 | const wxString& name = wxFrameNameStr) |
52 | { | |
53 | Init(); | |
54 | ||
55 | Create(parent, winid, title, pos, size, style, name); | |
56 | } | |
57 | ||
58 | bool Create(wxWindow *parent, | |
59 | wxWindowID winid, | |
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); | |
6c70a9b5 | 65 | |
d3c7fc99 | 66 | virtual ~wxGenericMDIParentFrame(); |
d2824cdb VZ |
67 | |
68 | // implement base class pure virtuals | |
69 | static bool IsTDI() { return true; } | |
70 | ||
71 | virtual void ActivateNext() { AdvanceActive(true); } | |
72 | virtual void ActivatePrevious() { AdvanceActive(false); } | |
6c70a9b5 JS |
73 | |
74 | #if wxUSE_MENUS | |
d2824cdb | 75 | virtual void SetWindowMenu(wxMenu* pMenu); |
6c70a9b5 JS |
76 | |
77 | virtual void SetMenuBar(wxMenuBar *pMenuBar); | |
78 | #endif // wxUSE_MENUS | |
79 | ||
d2824cdb | 80 | virtual wxGenericMDIClientWindow *OnCreateGenericClient(); |
6c70a9b5 | 81 | |
6c70a9b5 | 82 | |
d2824cdb VZ |
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; | |
90 | ||
91 | // return the book control used by the client window to manage the pages | |
92 | wxBookCtrlBase *GetBookCtrl() const; | |
6c70a9b5 JS |
93 | |
94 | protected: | |
6c70a9b5 | 95 | #if wxUSE_MENUS |
d2824cdb | 96 | wxMenuBar *m_pMyMenuBar; |
6c70a9b5 JS |
97 | #endif // wxUSE_MENUS |
98 | ||
d2824cdb VZ |
99 | // advance the activation forward or backwards |
100 | void AdvanceActive(bool forward); | |
101 | ||
102 | private: | |
6c70a9b5 JS |
103 | void Init(); |
104 | ||
105 | #if wxUSE_MENUS | |
106 | void RemoveWindowMenu(wxMenuBar *pMenuBar); | |
107 | void AddWindowMenu(wxMenuBar *pMenuBar); | |
108 | ||
d2824cdb | 109 | void OnWindowMenu(wxCommandEvent& event); |
6c70a9b5 JS |
110 | #endif // wxUSE_MENUS |
111 | ||
004867db FM |
112 | virtual bool ProcessEvent(wxEvent& event); |
113 | ||
d2824cdb VZ |
114 | void OnClose(wxCloseEvent& event); |
115 | ||
116 | // return the client window, may be NULL if we hadn't been created yet | |
117 | wxGenericMDIClientWindow *GetGenericClientWindow() const; | |
118 | ||
119 | // close all children, return false if any of them vetoed it | |
120 | bool CloseAll(); | |
121 | ||
122 | ||
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; | |
6c70a9b5 | 126 | |
6c70a9b5 JS |
127 | DECLARE_EVENT_TABLE() |
128 | DECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame) | |
129 | }; | |
130 | ||
d2824cdb | 131 | // ---------------------------------------------------------------------------- |
6c70a9b5 | 132 | // wxGenericMDIChildFrame |
d2824cdb | 133 | // ---------------------------------------------------------------------------- |
6c70a9b5 | 134 | |
d2824cdb | 135 | class WXDLLIMPEXP_CORE wxGenericMDIChildFrame : public wxTDIChildFrame |
6c70a9b5 JS |
136 | { |
137 | public: | |
d2824cdb VZ |
138 | wxGenericMDIChildFrame() { Init(); } |
139 | wxGenericMDIChildFrame(wxGenericMDIParentFrame *parent, | |
140 | wxWindowID winid, | |
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) | |
146 | { | |
147 | Init(); | |
148 | ||
149 | Create(parent, winid, title, pos, size, style, name); | |
150 | } | |
151 | ||
152 | bool Create(wxGenericMDIParentFrame *parent, | |
153 | wxWindowID winid, | |
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); | |
6c70a9b5 JS |
159 | |
160 | virtual ~wxGenericMDIChildFrame(); | |
d2824cdb VZ |
161 | |
162 | // implement MDI operations | |
163 | virtual void Activate(); | |
164 | ||
6c70a9b5 | 165 | |
923b48fc | 166 | #if wxUSE_MENUS |
6c70a9b5 JS |
167 | virtual void SetMenuBar( wxMenuBar *menu_bar ); |
168 | virtual wxMenuBar *GetMenuBar() const; | |
923b48fc | 169 | #endif // wxUSE_MENUS |
6c70a9b5 | 170 | |
d2824cdb | 171 | virtual wxString GetTitle() const { return m_title; } |
6c70a9b5 | 172 | virtual void SetTitle(const wxString& title); |
6c70a9b5 | 173 | |
8cc208e3 | 174 | virtual bool TryAfter(wxEvent& event); |
6c70a9b5 | 175 | |
d2824cdb | 176 | // implementation only from now on |
6c70a9b5 | 177 | |
d2824cdb VZ |
178 | wxGenericMDIParentFrame* GetGenericMDIParent() const |
179 | { | |
180 | #if wxUSE_GENERIC_MDI_AS_NATIVE | |
181 | return GetMDIParent(); | |
182 | #else // generic != native | |
183 | return m_mdiParentGeneric; | |
6c70a9b5 | 184 | #endif |
d2824cdb | 185 | } |
6c70a9b5 JS |
186 | |
187 | protected: | |
d2824cdb | 188 | wxString m_title; |
6c70a9b5 JS |
189 | |
190 | #if wxUSE_MENUS | |
191 | wxMenuBar *m_pMenuBar; | |
923b48fc | 192 | #endif // wxUSE_MENUS |
6c70a9b5 | 193 | |
d2824cdb VZ |
194 | #if !wxUSE_GENERIC_MDI_AS_NATIVE |
195 | wxGenericMDIParentFrame *m_mdiParentGeneric; | |
196 | #endif | |
197 | ||
6c70a9b5 JS |
198 | protected: |
199 | void Init(); | |
200 | ||
6c70a9b5 | 201 | private: |
d2824cdb VZ |
202 | void OnMenuHighlight(wxMenuEvent& event); |
203 | void OnClose(wxCloseEvent& event); | |
204 | ||
6c70a9b5 JS |
205 | DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame) |
206 | DECLARE_EVENT_TABLE() | |
207 | ||
208 | friend class wxGenericMDIClientWindow; | |
209 | }; | |
210 | ||
d2824cdb | 211 | // ---------------------------------------------------------------------------- |
6c70a9b5 | 212 | // wxGenericMDIClientWindow |
d2824cdb | 213 | // ---------------------------------------------------------------------------- |
6c70a9b5 | 214 | |
d2824cdb | 215 | class WXDLLIMPEXP_CORE wxGenericMDIClientWindow : public wxMDIClientWindowBase |
6c70a9b5 JS |
216 | { |
217 | public: | |
d2824cdb VZ |
218 | wxGenericMDIClientWindow() { } |
219 | ||
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) | |
228 | { | |
229 | return CreateGenericClient(parent); | |
230 | } | |
6c70a9b5 | 231 | |
d2824cdb VZ |
232 | // implementation only |
233 | wxBookCtrlBase *GetBookCtrl() const; | |
234 | wxGenericMDIChildFrame *GetChild(size_t pos) const; | |
235 | int FindChild(wxGenericMDIChildFrame *child) const; | |
6c70a9b5 | 236 | |
d2824cdb | 237 | private: |
6c70a9b5 JS |
238 | void PageChanged(int OldSelection, int newSelection); |
239 | ||
3e97a905 | 240 | void OnPageChanged(wxBookCtrlEvent& event); |
6c70a9b5 JS |
241 | void OnSize(wxSizeEvent& event); |
242 | ||
d2824cdb VZ |
243 | // the notebook containing all MDI children as its pages |
244 | wxNotebook *m_notebook; | |
6c70a9b5 | 245 | |
d2824cdb | 246 | DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow) |
6c70a9b5 JS |
247 | }; |
248 | ||
d2824cdb VZ |
249 | // ---------------------------------------------------------------------------- |
250 | // inline functions implementation | |
251 | // ---------------------------------------------------------------------------- | |
6c70a9b5 | 252 | |
d2824cdb VZ |
253 | inline bool |
254 | wxGenericMDIParentFrame:: | |
255 | WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const | |
6c70a9b5 | 256 | { |
d2824cdb VZ |
257 | return child == m_childHandler; |
258 | } | |
6c70a9b5 | 259 | |
d2824cdb | 260 | #endif // _WX_GENERIC_MDIG_H_ |