]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/msw/mdi.h | |
3 | // Purpose: MDI (Multiple Document Interface) classes | |
4 | // Author: Julian Smart | |
5 | // Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1997 Julian Smart | |
9 | // (c) 2008 Vadim Zeitlin | |
10 | // Licence: wxWindows licence | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef _WX_MSW_MDI_H_ | |
14 | #define _WX_MSW_MDI_H_ | |
15 | ||
16 | #include "wx/frame.h" | |
17 | ||
18 | class WXDLLIMPEXP_FWD_CORE wxAcceleratorTable; | |
19 | ||
20 | // --------------------------------------------------------------------------- | |
21 | // wxMDIParentFrame | |
22 | // --------------------------------------------------------------------------- | |
23 | ||
24 | class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase | |
25 | { | |
26 | public: | |
27 | wxMDIParentFrame() { Init(); } | |
28 | wxMDIParentFrame(wxWindow *parent, | |
29 | wxWindowID id, | |
30 | const wxString& title, | |
31 | const wxPoint& pos = wxDefaultPosition, | |
32 | const wxSize& size = wxDefaultSize, | |
33 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
34 | const wxString& name = wxFrameNameStr) | |
35 | { | |
36 | Init(); | |
37 | ||
38 | Create(parent, id, title, pos, size, style, name); | |
39 | } | |
40 | ||
41 | virtual ~wxMDIParentFrame(); | |
42 | ||
43 | bool Create(wxWindow *parent, | |
44 | wxWindowID id, | |
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); | |
50 | ||
51 | // override/implement base class [pure] virtual methods | |
52 | // ---------------------------------------------------- | |
53 | ||
54 | static bool IsTDI() { return false; } | |
55 | ||
56 | // we don't store the active child in m_currentChild so override this | |
57 | // function to find it dynamically | |
58 | virtual wxMDIChildFrame *GetActiveChild() const; | |
59 | ||
60 | virtual void Cascade(); | |
61 | virtual void Tile(wxOrientation orient = wxHORIZONTAL); | |
62 | virtual void ArrangeIcons(); | |
63 | virtual void ActivateNext(); | |
64 | virtual void ActivatePrevious(); | |
65 | ||
66 | #if wxUSE_MENUS | |
67 | virtual void SetWindowMenu(wxMenu* menu); | |
68 | ||
69 | virtual void DoMenuUpdates(wxMenu* menu = NULL); | |
70 | ||
71 | // return the active child menu, if any | |
72 | virtual WXHMENU MSWGetActiveMenu() const; | |
73 | #endif // wxUSE_MENUS | |
74 | ||
75 | ||
76 | // implementation only from now on | |
77 | ||
78 | // MDI helpers | |
79 | // ----------- | |
80 | ||
81 | #if wxUSE_MENUS | |
82 | // called by wxMDIChildFrame after it was successfully created | |
83 | virtual void AddMDIChild(wxMDIChildFrame *child); | |
84 | ||
85 | // called by wxMDIChildFrame just before it is destroyed | |
86 | virtual void RemoveMDIChild(wxMDIChildFrame *child); | |
87 | #endif // wxUSE_MENUS | |
88 | ||
89 | // handlers | |
90 | // -------- | |
91 | ||
92 | // Responds to colour changes | |
93 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
94 | ||
95 | void OnSize(wxSizeEvent& event); | |
96 | void OnIconized(wxIconizeEvent& event); | |
97 | ||
98 | bool HandleActivate(int state, bool minimized, WXHWND activate); | |
99 | ||
100 | // override window proc for MDI-specific message processing | |
101 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
102 | ||
103 | virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM); | |
104 | virtual bool MSWTranslateMessage(WXMSG* msg); | |
105 | ||
106 | #if wxUSE_MENUS | |
107 | // override wxFrameBase function to also look in the active child menu bar | |
108 | // and the "Window" menu | |
109 | virtual wxMenuItem *FindItemInMenuBar(int menuId) const; | |
110 | #endif // wxUSE_MENUS | |
111 | ||
112 | protected: | |
113 | #if wxUSE_MENUS_NATIVE | |
114 | virtual void InternalSetMenuBar(); | |
115 | #endif // wxUSE_MENUS_NATIVE | |
116 | ||
117 | virtual WXHICON GetDefaultIcon() const; | |
118 | ||
119 | // set the size of the MDI client window to match the frame size | |
120 | void UpdateClientSize(); | |
121 | ||
122 | private: | |
123 | // common part of all ctors | |
124 | void Init(); | |
125 | ||
126 | #if wxUSE_MENUS | |
127 | // "Window" menu commands event handlers | |
128 | void OnMDICommand(wxCommandEvent& event); | |
129 | void OnMDIChild(wxCommandEvent& event); | |
130 | ||
131 | ||
132 | // add/remove window menu if we have it (i.e. m_windowMenu != NULL) | |
133 | void AddWindowMenu(); | |
134 | void RemoveWindowMenu(); | |
135 | ||
136 | // update the window menu (if we have it) to enable or disable the commands | |
137 | // which only make sense when we have more than one child | |
138 | void UpdateWindowMenu(bool enable); | |
139 | ||
140 | #if wxUSE_ACCEL | |
141 | wxAcceleratorTable *m_accelWindowMenu; | |
142 | #endif // wxUSE_ACCEL | |
143 | #endif // wxUSE_MENUS | |
144 | ||
145 | // return the number of child frames we currently have (maybe 0) | |
146 | int GetChildFramesCount() const; | |
147 | ||
148 | ||
149 | friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; | |
150 | ||
151 | DECLARE_EVENT_TABLE() | |
152 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) | |
153 | wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame); | |
154 | }; | |
155 | ||
156 | // --------------------------------------------------------------------------- | |
157 | // wxMDIChildFrame | |
158 | // --------------------------------------------------------------------------- | |
159 | ||
160 | class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase | |
161 | { | |
162 | public: | |
163 | wxMDIChildFrame() { Init(); } | |
164 | wxMDIChildFrame(wxMDIParentFrame *parent, | |
165 | wxWindowID id, | |
166 | const wxString& title, | |
167 | const wxPoint& pos = wxDefaultPosition, | |
168 | const wxSize& size = wxDefaultSize, | |
169 | long style = wxDEFAULT_FRAME_STYLE, | |
170 | const wxString& name = wxFrameNameStr) | |
171 | { | |
172 | Init(); | |
173 | ||
174 | Create(parent, id, title, pos, size, style, name); | |
175 | } | |
176 | ||
177 | bool Create(wxMDIParentFrame *parent, | |
178 | wxWindowID id, | |
179 | const wxString& title, | |
180 | const wxPoint& pos = wxDefaultPosition, | |
181 | const wxSize& size = wxDefaultSize, | |
182 | long style = wxDEFAULT_FRAME_STYLE, | |
183 | const wxString& name = wxFrameNameStr); | |
184 | ||
185 | virtual ~wxMDIChildFrame(); | |
186 | ||
187 | // implement MDI operations | |
188 | virtual void Activate(); | |
189 | ||
190 | // Override some frame operations too | |
191 | virtual void Maximize(bool maximize = true); | |
192 | virtual void Restore(); | |
193 | ||
194 | virtual bool Show(bool show = true); | |
195 | ||
196 | // Implementation only from now on | |
197 | // ------------------------------- | |
198 | ||
199 | // Handlers | |
200 | bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); | |
201 | bool HandleWindowPosChanging(void *lpPos); | |
202 | bool HandleGetMinMaxInfo(void *mmInfo); | |
203 | ||
204 | virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
205 | virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
206 | virtual bool MSWTranslateMessage(WXMSG *msg); | |
207 | ||
208 | virtual void MSWDestroyWindow(); | |
209 | ||
210 | bool ResetWindowStyle(void *vrect); | |
211 | ||
212 | void OnIdle(wxIdleEvent& event); | |
213 | ||
214 | protected: | |
215 | virtual void DoGetScreenPosition(int *x, int *y) const; | |
216 | virtual void DoGetPosition(int *x, int *y) const; | |
217 | virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags); | |
218 | virtual void DoSetClientSize(int width, int height); | |
219 | virtual void InternalSetMenuBar(); | |
220 | virtual bool IsMDIChild() const { return true; } | |
221 | virtual void DetachMenuBar(); | |
222 | ||
223 | virtual WXHICON GetDefaultIcon() const; | |
224 | ||
225 | // common part of all ctors | |
226 | void Init(); | |
227 | ||
228 | private: | |
229 | bool m_needsInitialShow; // Show must be called in idle time after Creation | |
230 | bool m_needsResize; // flag which tells us to artificially resize the frame | |
231 | ||
232 | DECLARE_EVENT_TABLE() | |
233 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame) | |
234 | }; | |
235 | ||
236 | // --------------------------------------------------------------------------- | |
237 | // wxMDIClientWindow | |
238 | // --------------------------------------------------------------------------- | |
239 | ||
240 | class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase | |
241 | { | |
242 | public: | |
243 | wxMDIClientWindow() { Init(); } | |
244 | ||
245 | // Note: this is virtual, to allow overridden behaviour. | |
246 | virtual bool CreateClient(wxMDIParentFrame *parent, | |
247 | long style = wxVSCROLL | wxHSCROLL); | |
248 | ||
249 | // Explicitly call default scroll behaviour | |
250 | void OnScroll(wxScrollEvent& event); | |
251 | ||
252 | protected: | |
253 | virtual void DoSetSize(int x, int y, | |
254 | int width, int height, | |
255 | int sizeFlags = wxSIZE_AUTO); | |
256 | ||
257 | void Init() { m_scrollX = m_scrollY = 0; } | |
258 | ||
259 | int m_scrollX, m_scrollY; | |
260 | ||
261 | private: | |
262 | DECLARE_EVENT_TABLE() | |
263 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow) | |
264 | }; | |
265 | ||
266 | #endif // _WX_MSW_MDI_H_ |