]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/mdi.h
include wx/menu.h as we delete wxMenu pointer in this header (and creating a separate...
[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 #endif // wxUSE_MENUS
67
68 // implementation only from now on
69
70 // MDI helpers
71 // -----------
72
73 // called by wxMDIChildFrame after it was successfully created
74 virtual void AddMDIChild(wxMDIChildFrame *child);
75
76 // called by wxMDIChildFrame just before it is destroyed
77 virtual void RemoveMDIChild(wxMDIChildFrame *child);
78
79 // handlers
80 // --------
81
82 // Responds to colour changes
83 void OnSysColourChanged(wxSysColourChangedEvent& event);
84
85 void OnSize(wxSizeEvent& event);
86 void OnIconized(wxIconizeEvent& event);
87
88 bool HandleActivate(int state, bool minimized, WXHWND activate);
89 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
90
91 // override window proc for MDI-specific message processing
92 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
93
94 virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
95 virtual bool MSWTranslateMessage(WXMSG* msg);
96
97 // override wxFrameBase function to also look in the active child menu bar
98 virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
99
100 protected:
101 #if wxUSE_MENUS_NATIVE
102 virtual void InternalSetMenuBar();
103 #endif // wxUSE_MENUS_NATIVE
104
105 virtual WXHICON GetDefaultIcon() const;
106
107 // set the size of the MDI client window to match the frame size
108 void UpdateClientSize();
109
110
111 // true if MDI Frame is intercepting commands, not child
112 bool m_parentFrameActive;
113
114 private:
115 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
116 void AddWindowMenu();
117 void RemoveWindowMenu();
118
119 // return the number of child frames we currently have (maybe 0)
120 int GetChildFramesCount() const;
121
122 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
123
124 DECLARE_EVENT_TABLE()
125 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
126 DECLARE_NO_COPY_CLASS(wxMDIParentFrame)
127 };
128
129 // ---------------------------------------------------------------------------
130 // wxMDIChildFrame
131 // ---------------------------------------------------------------------------
132
133 class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase
134 {
135 public:
136 wxMDIChildFrame() { Init(); }
137 wxMDIChildFrame(wxMDIParentFrame *parent,
138 wxWindowID id,
139 const wxString& title,
140 const wxPoint& pos = wxDefaultPosition,
141 const wxSize& size = wxDefaultSize,
142 long style = wxDEFAULT_FRAME_STYLE,
143 const wxString& name = wxFrameNameStr)
144 {
145 Init();
146
147 Create(parent, id, title, pos, size, style, name);
148 }
149
150 bool Create(wxMDIParentFrame *parent,
151 wxWindowID id,
152 const wxString& title,
153 const wxPoint& pos = wxDefaultPosition,
154 const wxSize& size = wxDefaultSize,
155 long style = wxDEFAULT_FRAME_STYLE,
156 const wxString& name = wxFrameNameStr);
157
158 virtual ~wxMDIChildFrame();
159
160 // implement MDI operations
161 virtual void Activate();
162
163 // Override some frame operations too
164 virtual void Maximize(bool maximize = true);
165 virtual void Restore();
166
167 virtual bool Show(bool show = true);
168
169 // Implementation only from now on
170 // -------------------------------
171
172 // Handlers
173 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
174 bool HandleWindowPosChanging(void *lpPos);
175 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
176 bool HandleGetMinMaxInfo(void *mmInfo);
177
178 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
179 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
180 virtual bool MSWTranslateMessage(WXMSG *msg);
181
182 virtual void MSWDestroyWindow();
183
184 bool ResetWindowStyle(void *vrect);
185
186 void OnIdle(wxIdleEvent& event);
187
188 protected:
189 virtual void DoGetScreenPosition(int *x, int *y) const;
190 virtual void DoGetPosition(int *x, int *y) const;
191 virtual void DoSetClientSize(int width, int height);
192 virtual void InternalSetMenuBar();
193 virtual bool IsMDIChild() const { return true; }
194 virtual void DetachMenuBar();
195
196 virtual WXHICON GetDefaultIcon() const;
197
198 // common part of all ctors
199 void Init();
200
201 private:
202 bool m_needsInitialShow; // Show must be called in idle time after Creation
203 bool m_needsResize; // flag which tells us to artificially resize the frame
204
205 DECLARE_EVENT_TABLE()
206 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame)
207 };
208
209 // ---------------------------------------------------------------------------
210 // wxMDIClientWindow
211 // ---------------------------------------------------------------------------
212
213 class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase
214 {
215 public:
216 wxMDIClientWindow() { Init(); }
217
218 // Note: this is virtual, to allow overridden behaviour.
219 virtual bool CreateClient(wxMDIParentFrame *parent,
220 long style = wxVSCROLL | wxHSCROLL);
221
222 // Explicitly call default scroll behaviour
223 void OnScroll(wxScrollEvent& event);
224
225 protected:
226 virtual void DoSetSize(int x, int y,
227 int width, int height,
228 int sizeFlags = wxSIZE_AUTO);
229
230 void Init() { m_scrollX = m_scrollY = 0; }
231
232 int m_scrollX, m_scrollY;
233
234 private:
235 DECLARE_EVENT_TABLE()
236 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
237 };
238
239 #endif // _WX_MSW_MDI_H_