]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/mdi.h
Increase version to 2.9.5.
[wxWidgets.git] / include / wx / msw / mdi.h
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 // override to pass menu/toolbar events to the active child first
114 virtual bool TryBefore(wxEvent& event);
115
116 #if wxUSE_MENUS_NATIVE
117 virtual void InternalSetMenuBar();
118 #endif // wxUSE_MENUS_NATIVE
119
120 virtual WXHICON GetDefaultIcon() const;
121
122 // set the size of the MDI client window to match the frame size
123 void UpdateClientSize();
124
125 private:
126 // common part of all ctors
127 void Init();
128
129 #if wxUSE_MENUS
130 // "Window" menu commands event handlers
131 void OnMDICommand(wxCommandEvent& event);
132 void OnMDIChild(wxCommandEvent& event);
133
134
135 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
136 void AddWindowMenu();
137 void RemoveWindowMenu();
138
139 // update the window menu (if we have it) to enable or disable the commands
140 // which only make sense when we have more than one child
141 void UpdateWindowMenu(bool enable);
142
143 #if wxUSE_ACCEL
144 wxAcceleratorTable *m_accelWindowMenu;
145 #endif // wxUSE_ACCEL
146 #endif // wxUSE_MENUS
147
148 // return the number of child frames we currently have (maybe 0)
149 int GetChildFramesCount() const;
150
151
152 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
153
154 DECLARE_EVENT_TABLE()
155 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
156 wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame);
157 };
158
159 // ---------------------------------------------------------------------------
160 // wxMDIChildFrame
161 // ---------------------------------------------------------------------------
162
163 class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase
164 {
165 public:
166 wxMDIChildFrame() { Init(); }
167 wxMDIChildFrame(wxMDIParentFrame *parent,
168 wxWindowID id,
169 const wxString& title,
170 const wxPoint& pos = wxDefaultPosition,
171 const wxSize& size = wxDefaultSize,
172 long style = wxDEFAULT_FRAME_STYLE,
173 const wxString& name = wxFrameNameStr)
174 {
175 Init();
176
177 Create(parent, id, title, pos, size, style, name);
178 }
179
180 bool Create(wxMDIParentFrame *parent,
181 wxWindowID id,
182 const wxString& title,
183 const wxPoint& pos = wxDefaultPosition,
184 const wxSize& size = wxDefaultSize,
185 long style = wxDEFAULT_FRAME_STYLE,
186 const wxString& name = wxFrameNameStr);
187
188 virtual ~wxMDIChildFrame();
189
190 // implement MDI operations
191 virtual void Activate();
192
193 // Override some frame operations too
194 virtual void Maximize(bool maximize = true);
195 virtual void Restore();
196
197 virtual bool Show(bool show = true);
198
199 // Implementation only from now on
200 // -------------------------------
201
202 // Handlers
203 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
204 bool HandleWindowPosChanging(void *lpPos);
205 bool HandleGetMinMaxInfo(void *mmInfo);
206
207 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
208 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
209 virtual bool MSWTranslateMessage(WXMSG *msg);
210
211 virtual void MSWDestroyWindow();
212
213 bool ResetWindowStyle(void *vrect);
214
215 void OnIdle(wxIdleEvent& event);
216
217 protected:
218 virtual void DoGetScreenPosition(int *x, int *y) const;
219 virtual void DoGetPosition(int *x, int *y) const;
220 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
221 virtual void DoSetClientSize(int width, int height);
222 virtual void InternalSetMenuBar();
223 virtual bool IsMDIChild() const { return true; }
224 virtual void DetachMenuBar();
225
226 virtual WXHICON GetDefaultIcon() const;
227
228 // common part of all ctors
229 void Init();
230
231 private:
232 bool m_needsInitialShow; // Show must be called in idle time after Creation
233 bool m_needsResize; // flag which tells us to artificially resize the frame
234
235 DECLARE_EVENT_TABLE()
236 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame)
237 };
238
239 // ---------------------------------------------------------------------------
240 // wxMDIClientWindow
241 // ---------------------------------------------------------------------------
242
243 class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase
244 {
245 public:
246 wxMDIClientWindow() { Init(); }
247
248 // Note: this is virtual, to allow overridden behaviour.
249 virtual bool CreateClient(wxMDIParentFrame *parent,
250 long style = wxVSCROLL | wxHSCROLL);
251
252 // Explicitly call default scroll behaviour
253 void OnScroll(wxScrollEvent& event);
254
255 protected:
256 virtual void DoSetSize(int x, int y,
257 int width, int height,
258 int sizeFlags = wxSIZE_AUTO);
259
260 void Init() { m_scrollX = m_scrollY = 0; }
261
262 int m_scrollX, m_scrollY;
263
264 private:
265 DECLARE_EVENT_TABLE()
266 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
267 };
268
269 #endif // _WX_MSW_MDI_H_