]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/mdi.h
fix the incoherence pointed out by ifacecheck between wx docs, that documents usage...
[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:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MDI_H_
13 #define _WX_MDI_H_
14
15 #include "wx/frame.h"
16
17 extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusLineNameStr[];
18
19 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow;
20 class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
21
22 // ---------------------------------------------------------------------------
23 // wxMDIParentFrame
24 // ---------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxFrame
27 {
28 public:
29 wxMDIParentFrame();
30 wxMDIParentFrame(wxWindow *parent,
31 wxWindowID id,
32 const wxString& title,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize,
35 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
36 const wxString& name = wxFrameNameStr)
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 // accessors
52 // ---------
53
54 // Get the active MDI child window
55 wxMDIChildFrame *GetActiveChild() const;
56
57 // Get the client window
58 wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }
59
60 // Create the client window class (don't Create the window,
61 // just return a new class)
62 virtual wxMDIClientWindow *OnCreateClient();
63
64 // MDI windows menu functions
65 // --------------------------
66
67 // return the pointer to the current window menu or NULL if we don't have
68 // because of wxFRAME_NO_WINDOW_MENU style
69 wxMenu *GetWindowMenu() const { return m_windowMenu; }
70
71 // use the given menu instead of the default window menu
72 //
73 // menu can be NULL to disable the window menu completely
74 void SetWindowMenu(wxMenu* menu) ;
75
76 virtual void DoMenuUpdates(wxMenu* menu = NULL);
77
78 // MDI operations
79 // --------------
80 virtual void Cascade();
81 virtual void Tile(wxOrientation orient = wxHORIZONTAL);
82 virtual void ArrangeIcons();
83 virtual void ActivateNext();
84 virtual void ActivatePrevious();
85
86
87 // implementation only from now on
88
89 // MDI helpers
90 // -----------
91
92 // called by wxMDIChildFrame after it was successfully created
93 virtual void AddMDIChild(wxMDIChildFrame *child);
94
95 // called by wxMDIChildFrame just before it is destroyed
96 virtual void RemoveMDIChild(wxMDIChildFrame *child);
97
98 // handlers
99 // --------
100
101 // Responds to colour changes
102 void OnSysColourChanged(wxSysColourChangedEvent& event);
103
104 void OnSize(wxSizeEvent& event);
105 void OnIconized(wxIconizeEvent& event);
106
107 bool HandleActivate(int state, bool minimized, WXHWND activate);
108 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
109
110 // override window proc for MDI-specific message processing
111 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
112
113 virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
114 virtual bool MSWTranslateMessage(WXMSG* msg);
115
116 // override wxFrameBase function to also look in the active child menu bar
117 virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
118
119 protected:
120 #if wxUSE_MENUS_NATIVE
121 virtual void InternalSetMenuBar();
122 #endif // wxUSE_MENUS_NATIVE
123
124 virtual WXHICON GetDefaultIcon() const;
125
126 // set the size of the MDI client window to match the frame size
127 void UpdateClientSize();
128
129
130 wxMDIClientWindow * m_clientWindow;
131 wxMDIChildFrame * m_currentChild;
132
133 // the current window menu or NULL if we are not using it
134 wxMenu *m_windowMenu;
135
136 // true if MDI Frame is intercepting commands, not child
137 bool m_parentFrameActive;
138
139 private:
140 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
141 void AddWindowMenu();
142 void RemoveWindowMenu();
143
144 // return the number of child frames we currently have (maybe 0)
145 int GetChildFramesCount() const;
146
147 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
148
149 DECLARE_EVENT_TABLE()
150 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
151 DECLARE_NO_COPY_CLASS(wxMDIParentFrame)
152 };
153
154 // ---------------------------------------------------------------------------
155 // wxMDIChildFrame
156 // ---------------------------------------------------------------------------
157
158 class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxFrame
159 {
160 public:
161 wxMDIChildFrame() { Init(); }
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 {
170 Init();
171
172 Create(parent, id, title, pos, size, style, name);
173 }
174
175 virtual ~wxMDIChildFrame();
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 bool IsTopLevel() const { return false; }
186
187 // MDI operations
188 virtual void Maximize(bool maximize = true);
189 virtual void Restore();
190 virtual void Activate();
191
192 // Implementation only from now on
193 // -------------------------------
194
195 wxMDIParentFrame* GetMDIParent() const
196 {
197 return wxStaticCast(wxFrame::GetParent(), wxMDIParentFrame);
198 }
199
200 // Handlers
201 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
202 bool HandleWindowPosChanging(void *lpPos);
203 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
204 bool HandleGetMinMaxInfo(void *mmInfo);
205
206 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
207 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
208 virtual bool MSWTranslateMessage(WXMSG *msg);
209
210 virtual void MSWDestroyWindow();
211
212 bool ResetWindowStyle(void *vrect);
213
214 void OnIdle(wxIdleEvent& event);
215
216 virtual bool Show(bool show = true);
217
218 protected:
219 virtual void DoGetScreenPosition(int *x, int *y) const;
220 virtual void DoGetPosition(int *x, int *y) const;
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 wxWindow
244 {
245 public:
246 wxMDIClientWindow() { Init(); }
247 wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
248 {
249 Init();
250
251 CreateClient(parent, style);
252 }
253
254 // Note: this is virtual, to allow overridden behaviour.
255 virtual bool CreateClient(wxMDIParentFrame *parent,
256 long style = wxVSCROLL | wxHSCROLL);
257
258 // Explicitly call default scroll behaviour
259 void OnScroll(wxScrollEvent& event);
260
261 protected:
262 virtual void DoSetSize(int x, int y,
263 int width, int height,
264 int sizeFlags = wxSIZE_AUTO);
265
266 void Init() { m_scrollX = m_scrollY = 0; }
267
268 int m_scrollX, m_scrollY;
269
270 private:
271 DECLARE_EVENT_TABLE()
272 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
273 };
274
275 #endif
276 // _WX_MDI_H_