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