]>
Commit | Line | Data |
---|---|---|
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 WXDLLEXPORT_DATA(const wxChar) wxStatusLineNameStr[]; | |
18 | ||
19 | class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow; | |
20 | class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; | |
21 | ||
22 | // --------------------------------------------------------------------------- | |
23 | // wxMDIParentFrame | |
24 | // --------------------------------------------------------------------------- | |
25 | ||
26 | class WXDLLEXPORT 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 (Windows only) | |
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(void); | |
63 | ||
64 | // MDI windows menu | |
65 | wxMenu* GetWindowMenu() const { return m_windowMenu; } | |
66 | void SetWindowMenu(wxMenu* menu) ; | |
67 | virtual void DoMenuUpdates(wxMenu* menu = NULL); | |
68 | ||
69 | // MDI operations | |
70 | // -------------- | |
71 | virtual void Cascade(); | |
72 | virtual void Tile(wxOrientation orient = wxHORIZONTAL); | |
73 | virtual void ArrangeIcons(); | |
74 | virtual void ActivateNext(); | |
75 | virtual void ActivatePrevious(); | |
76 | ||
77 | // handlers | |
78 | // -------- | |
79 | ||
80 | // Responds to colour changes | |
81 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
82 | ||
83 | void OnSize(wxSizeEvent& event); | |
84 | void OnIconized(wxIconizeEvent& event); | |
85 | ||
86 | bool HandleActivate(int state, bool minimized, WXHWND activate); | |
87 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
88 | ||
89 | // override window proc for MDI-specific message processing | |
90 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
91 | ||
92 | virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM); | |
93 | virtual bool MSWTranslateMessage(WXMSG* msg); | |
94 | ||
95 | // override wxFrameBase function to also look in the active child menu bar | |
96 | virtual const wxMenuItem *FindItemInMenuBar(int menuId) const; | |
97 | ||
98 | protected: | |
99 | #if wxUSE_MENUS_NATIVE | |
100 | virtual void InternalSetMenuBar(); | |
101 | #endif // wxUSE_MENUS_NATIVE | |
102 | ||
103 | virtual WXHICON GetDefaultIcon() const; | |
104 | ||
105 | // set the size of the MDI client window to match the frame size | |
106 | void UpdateClientSize(); | |
107 | ||
108 | ||
109 | wxMDIClientWindow * m_clientWindow; | |
110 | wxMDIChildFrame * m_currentChild; | |
111 | wxMenu* m_windowMenu; | |
112 | ||
113 | // true if MDI Frame is intercepting commands, not child | |
114 | bool m_parentFrameActive; | |
115 | ||
116 | private: | |
117 | friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; | |
118 | ||
119 | DECLARE_EVENT_TABLE() | |
120 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) | |
121 | DECLARE_NO_COPY_CLASS(wxMDIParentFrame) | |
122 | }; | |
123 | ||
124 | // --------------------------------------------------------------------------- | |
125 | // wxMDIChildFrame | |
126 | // --------------------------------------------------------------------------- | |
127 | ||
128 | class WXDLLEXPORT wxMDIChildFrame : public wxFrame | |
129 | { | |
130 | public: | |
131 | wxMDIChildFrame() { Init(); } | |
132 | wxMDIChildFrame(wxMDIParentFrame *parent, | |
133 | wxWindowID id, | |
134 | const wxString& title, | |
135 | const wxPoint& pos = wxDefaultPosition, | |
136 | const wxSize& size = wxDefaultSize, | |
137 | long style = wxDEFAULT_FRAME_STYLE, | |
138 | const wxString& name = wxFrameNameStr) | |
139 | { | |
140 | Init(); | |
141 | ||
142 | Create(parent, id, title, pos, size, style, name); | |
143 | } | |
144 | ||
145 | virtual ~wxMDIChildFrame(); | |
146 | ||
147 | bool Create(wxMDIParentFrame *parent, | |
148 | wxWindowID id, | |
149 | const wxString& title, | |
150 | const wxPoint& pos = wxDefaultPosition, | |
151 | const wxSize& size = wxDefaultSize, | |
152 | long style = wxDEFAULT_FRAME_STYLE, | |
153 | const wxString& name = wxFrameNameStr); | |
154 | ||
155 | virtual bool IsTopLevel() const { return false; } | |
156 | ||
157 | // MDI operations | |
158 | virtual void Maximize(bool maximize = true); | |
159 | virtual void Restore(); | |
160 | virtual void Activate(); | |
161 | ||
162 | // Implementation only from now on | |
163 | // ------------------------------- | |
164 | ||
165 | // Handlers | |
166 | bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); | |
167 | bool HandleWindowPosChanging(void *lpPos); | |
168 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
169 | bool HandleGetMinMaxInfo(void *mmInfo); | |
170 | ||
171 | virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
172 | virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
173 | virtual bool MSWTranslateMessage(WXMSG *msg); | |
174 | ||
175 | virtual void MSWDestroyWindow(); | |
176 | ||
177 | bool ResetWindowStyle(void *vrect); | |
178 | ||
179 | void OnIdle(wxIdleEvent& event); | |
180 | ||
181 | virtual bool Show(bool show = true); | |
182 | ||
183 | protected: | |
184 | virtual void DoGetScreenPosition(int *x, int *y) const; | |
185 | virtual void DoGetPosition(int *x, int *y) const; | |
186 | virtual void DoSetClientSize(int width, int height); | |
187 | virtual void InternalSetMenuBar(); | |
188 | virtual bool IsMDIChild() const { return true; } | |
189 | virtual void DetachMenuBar(); | |
190 | ||
191 | virtual WXHICON GetDefaultIcon() const; | |
192 | ||
193 | // common part of all ctors | |
194 | void Init(); | |
195 | ||
196 | private: | |
197 | bool m_needsInitialShow; // Show must be called in idle time after Creation | |
198 | bool m_needsResize; // flag which tells us to artificially resize the frame | |
199 | ||
200 | DECLARE_EVENT_TABLE() | |
201 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame) | |
202 | }; | |
203 | ||
204 | // --------------------------------------------------------------------------- | |
205 | // wxMDIClientWindow | |
206 | // --------------------------------------------------------------------------- | |
207 | ||
208 | class WXDLLEXPORT wxMDIClientWindow : public wxWindow | |
209 | { | |
210 | public: | |
211 | wxMDIClientWindow() { Init(); } | |
212 | wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) | |
213 | { | |
214 | Init(); | |
215 | ||
216 | CreateClient(parent, style); | |
217 | } | |
218 | ||
219 | // Note: this is virtual, to allow overridden behaviour. | |
220 | virtual bool CreateClient(wxMDIParentFrame *parent, | |
221 | long style = wxVSCROLL | wxHSCROLL); | |
222 | ||
223 | // Explicitly call default scroll behaviour | |
224 | void OnScroll(wxScrollEvent& event); | |
225 | ||
226 | protected: | |
227 | virtual void DoSetSize(int x, int y, | |
228 | int width, int height, | |
229 | int sizeFlags = wxSIZE_AUTO); | |
230 | ||
231 | void Init() { m_scrollX = m_scrollY = 0; } | |
232 | ||
233 | int m_scrollX, m_scrollY; | |
234 | ||
235 | private: | |
236 | DECLARE_EVENT_TABLE() | |
237 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow) | |
238 | }; | |
239 | ||
240 | #endif | |
241 | // _WX_MDI_H_ |