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