]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
f6bcfd97 | 2 | // Name: wx/msw/mdi.h |
2bda0e17 KB |
3 | // Purpose: MDI (Multiple Document Interface) classes |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_MDI_H_ |
13 | #define _WX_MDI_H_ | |
2bda0e17 | 14 | |
2bda0e17 KB |
15 | #include "wx/frame.h" |
16 | ||
63ec432b MR |
17 | extern WXDLLEXPORT_DATA(const wxChar) wxFrameNameStr[]; |
18 | extern WXDLLEXPORT_DATA(const wxChar) wxStatusLineNameStr[]; | |
2bda0e17 KB |
19 | |
20 | class WXDLLEXPORT wxMDIClientWindow; | |
21 | class WXDLLEXPORT wxMDIChildFrame; | |
22 | ||
a23fd0e1 VZ |
23 | // --------------------------------------------------------------------------- |
24 | // wxMDIParentFrame | |
25 | // --------------------------------------------------------------------------- | |
26 | ||
27 | class WXDLLEXPORT wxMDIParentFrame : public wxFrame | |
2bda0e17 | 28 | { |
a23fd0e1 VZ |
29 | public: |
30 | wxMDIParentFrame(); | |
31 | wxMDIParentFrame(wxWindow *parent, | |
32 | wxWindowID id, | |
33 | const wxString& title, | |
34 | const wxPoint& pos = wxDefaultPosition, | |
35 | const wxSize& size = wxDefaultSize, | |
36 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
37 | const wxString& name = wxFrameNameStr) | |
38 | { | |
39 | Create(parent, id, title, pos, size, style, name); | |
40 | } | |
41 | ||
42 | ~wxMDIParentFrame(); | |
43 | ||
44 | bool Create(wxWindow *parent, | |
45 | wxWindowID id, | |
46 | const wxString& title, | |
47 | const wxPoint& pos = wxDefaultPosition, | |
48 | const wxSize& size = wxDefaultSize, | |
49 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
50 | const wxString& name = wxFrameNameStr); | |
51 | ||
52 | // accessors | |
53 | // --------- | |
54 | ||
a23fd0e1 | 55 | // Get the active MDI child window (Windows only) |
42e69d6b | 56 | wxMDIChildFrame *GetActiveChild() const; |
2bda0e17 | 57 | |
a23fd0e1 VZ |
58 | // Get the client window |
59 | wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; } | |
2bda0e17 | 60 | |
a23fd0e1 VZ |
61 | // Create the client window class (don't Create the window, |
62 | // just return a new class) | |
42e69d6b | 63 | virtual wxMDIClientWindow *OnCreateClient(void); |
2bda0e17 | 64 | |
4e152a23 | 65 | // MDI windows menu |
df61c009 JS |
66 | wxMenu* GetWindowMenu() const { return m_windowMenu; }; |
67 | void SetWindowMenu(wxMenu* menu) ; | |
6aca4628 | 68 | virtual void DoMenuUpdates(wxMenu* menu = NULL); |
ef359b43 | 69 | |
a23fd0e1 VZ |
70 | // MDI operations |
71 | // -------------- | |
72 | virtual void Cascade(); | |
0d97c090 | 73 | virtual void Tile(wxOrientation orient = wxHORIZONTAL); |
a23fd0e1 VZ |
74 | virtual void ArrangeIcons(); |
75 | virtual void ActivateNext(); | |
76 | virtual void ActivatePrevious(); | |
2bda0e17 | 77 | |
a23fd0e1 VZ |
78 | // handlers |
79 | // -------- | |
2bda0e17 | 80 | |
a23fd0e1 VZ |
81 | // Responds to colour changes |
82 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
2bda0e17 | 83 | |
a23fd0e1 | 84 | void OnSize(wxSizeEvent& event); |
6bbe97b7 | 85 | void OnIconized(wxIconizeEvent& event); |
2bda0e17 | 86 | |
42e69d6b VZ |
87 | bool HandleActivate(int state, bool minimized, WXHWND activate); |
88 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
2bda0e17 | 89 | |
a23fd0e1 | 90 | // override window proc for MDI-specific message processing |
c140b7e7 | 91 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
2bda0e17 | 92 | |
c140b7e7 | 93 | virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM); |
a23fd0e1 | 94 | virtual bool MSWTranslateMessage(WXMSG* msg); |
cc2b7472 | 95 | |
a23fd0e1 | 96 | protected: |
1e6feb95 | 97 | #if wxUSE_MENUS_NATIVE |
42e69d6b | 98 | virtual void InternalSetMenuBar(); |
1e6feb95 | 99 | #endif // wxUSE_MENUS_NATIVE |
42e69d6b | 100 | |
82c9f85c VZ |
101 | virtual WXHICON GetDefaultIcon() const; |
102 | ||
6bbe97b7 VZ |
103 | // set the size of the MDI client window to match the frame size |
104 | void UpdateClientSize(); | |
105 | ||
106 | ||
2bda0e17 KB |
107 | wxMDIClientWindow * m_clientWindow; |
108 | wxMDIChildFrame * m_currentChild; | |
df61c009 | 109 | wxMenu* m_windowMenu; |
a23fd0e1 | 110 | |
598ddd96 | 111 | // true if MDI Frame is intercepting commands, not child |
42e69d6b | 112 | bool m_parentFrameActive; |
a23fd0e1 VZ |
113 | |
114 | private: | |
115 | friend class WXDLLEXPORT wxMDIChildFrame; | |
116 | ||
117 | DECLARE_EVENT_TABLE() | |
82c9f85c | 118 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) |
22f3361e | 119 | DECLARE_NO_COPY_CLASS(wxMDIParentFrame) |
2bda0e17 KB |
120 | }; |
121 | ||
a23fd0e1 VZ |
122 | // --------------------------------------------------------------------------- |
123 | // wxMDIChildFrame | |
124 | // --------------------------------------------------------------------------- | |
2bda0e17 | 125 | |
a23fd0e1 | 126 | class WXDLLEXPORT wxMDIChildFrame : public wxFrame |
2bda0e17 | 127 | { |
a23fd0e1 | 128 | public: |
f6bcfd97 | 129 | wxMDIChildFrame() { Init(); } |
a23fd0e1 VZ |
130 | wxMDIChildFrame(wxMDIParentFrame *parent, |
131 | wxWindowID id, | |
132 | const wxString& title, | |
133 | const wxPoint& pos = wxDefaultPosition, | |
134 | const wxSize& size = wxDefaultSize, | |
135 | long style = wxDEFAULT_FRAME_STYLE, | |
136 | const wxString& name = wxFrameNameStr) | |
137 | { | |
f6bcfd97 BP |
138 | Init(); |
139 | ||
a23fd0e1 VZ |
140 | Create(parent, id, title, pos, size, style, name); |
141 | } | |
142 | ||
143 | ~wxMDIChildFrame(); | |
144 | ||
145 | bool Create(wxMDIParentFrame *parent, | |
146 | wxWindowID id, | |
147 | const wxString& title, | |
148 | const wxPoint& pos = wxDefaultPosition, | |
149 | const wxSize& size = wxDefaultSize, | |
150 | long style = wxDEFAULT_FRAME_STYLE, | |
151 | const wxString& name = wxFrameNameStr); | |
152 | ||
598ddd96 | 153 | virtual bool IsTopLevel() const { return false; } |
225fe9d6 | 154 | |
a23fd0e1 | 155 | // MDI operations |
598ddd96 | 156 | virtual void Maximize(bool maximize = true); |
a23fd0e1 VZ |
157 | virtual void Restore(); |
158 | virtual void Activate(); | |
159 | ||
f6bcfd97 BP |
160 | // Implementation only from now on |
161 | // ------------------------------- | |
a23fd0e1 | 162 | |
f6bcfd97 | 163 | // Handlers |
42e69d6b | 164 | bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); |
42e69d6b VZ |
165 | bool HandleWindowPosChanging(void *lpPos); |
166 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
3ebcfb76 | 167 | bool HandleGetMinMaxInfo(void *mmInfo); |
42e69d6b | 168 | |
c140b7e7 JS |
169 | virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
170 | virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
42e69d6b VZ |
171 | virtual bool MSWTranslateMessage(WXMSG *msg); |
172 | ||
173 | virtual void MSWDestroyWindow(); | |
2bda0e17 | 174 | |
2bda0e17 | 175 | bool ResetWindowStyle(void *vrect); |
cc2b7472 | 176 | |
f6bcfd97 | 177 | void OnIdle(wxIdleEvent& event); |
ef359b43 | 178 | |
2596e9fb | 179 | virtual bool Show(bool show = true); |
f6bcfd97 | 180 | |
cc2b7472 | 181 | protected: |
42e69d6b | 182 | virtual void DoGetPosition(int *x, int *y) const; |
a23fd0e1 | 183 | virtual void DoSetClientSize(int width, int height); |
42e69d6b | 184 | virtual void InternalSetMenuBar(); |
598ddd96 | 185 | virtual bool IsMDIChild() const { return true; } |
6f02a879 | 186 | virtual void DetachMenuBar(); |
225fe9d6 | 187 | |
82c9f85c VZ |
188 | virtual WXHICON GetDefaultIcon() const; |
189 | ||
f6bcfd97 BP |
190 | // common part of all ctors |
191 | void Init(); | |
192 | ||
193 | private: | |
2596e9fb | 194 | bool m_needsInitialShow; // Show must be called in idle time after Creation |
f6bcfd97 BP |
195 | bool m_needsResize; // flag which tells us to artificially resize the frame |
196 | ||
197 | DECLARE_EVENT_TABLE() | |
fc7a2a60 | 198 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame) |
2bda0e17 KB |
199 | }; |
200 | ||
a23fd0e1 VZ |
201 | // --------------------------------------------------------------------------- |
202 | // wxMDIClientWindow | |
203 | // --------------------------------------------------------------------------- | |
2bda0e17 | 204 | |
a23fd0e1 VZ |
205 | class WXDLLEXPORT wxMDIClientWindow : public wxWindow |
206 | { | |
a23fd0e1 | 207 | public: |
42e69d6b | 208 | wxMDIClientWindow() { Init(); } |
a23fd0e1 VZ |
209 | wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) |
210 | { | |
42e69d6b VZ |
211 | Init(); |
212 | ||
a23fd0e1 VZ |
213 | CreateClient(parent, style); |
214 | } | |
2bda0e17 | 215 | |
a23fd0e1 VZ |
216 | // Note: this is virtual, to allow overridden behaviour. |
217 | virtual bool CreateClient(wxMDIParentFrame *parent, | |
218 | long style = wxVSCROLL | wxHSCROLL); | |
2bda0e17 | 219 | |
a23fd0e1 VZ |
220 | // Explicitly call default scroll behaviour |
221 | void OnScroll(wxScrollEvent& event); | |
2bda0e17 | 222 | |
6f02a879 | 223 | protected: |
ec06b234 JS |
224 | virtual void DoSetSize(int x, int y, |
225 | int width, int height, | |
226 | int sizeFlags = wxSIZE_AUTO); | |
6f02a879 | 227 | |
42e69d6b VZ |
228 | void Init() { m_scrollX = m_scrollY = 0; } |
229 | ||
a23fd0e1 VZ |
230 | int m_scrollX, m_scrollY; |
231 | ||
232 | private: | |
233 | DECLARE_EVENT_TABLE() | |
fc7a2a60 | 234 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow) |
2bda0e17 KB |
235 | }; |
236 | ||
237 | #endif | |
bbcdf8bc | 238 | // _WX_MDI_H_ |