]>
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 | |
d2824cdb | 5 | // Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes |
2bda0e17 KB |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
d2824cdb VZ |
8 | // Copyright: (c) 1997 Julian Smart |
9 | // (c) 2008 Vadim Zeitlin | |
65571936 | 10 | // Licence: wxWindows licence |
2bda0e17 KB |
11 | ///////////////////////////////////////////////////////////////////////////// |
12 | ||
d2824cdb VZ |
13 | #ifndef _WX_MSW_MDI_H_ |
14 | #define _WX_MSW_MDI_H_ | |
2bda0e17 | 15 | |
2bda0e17 KB |
16 | #include "wx/frame.h" |
17 | ||
a23fd0e1 VZ |
18 | // --------------------------------------------------------------------------- |
19 | // wxMDIParentFrame | |
20 | // --------------------------------------------------------------------------- | |
21 | ||
d2824cdb | 22 | class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase |
2bda0e17 | 23 | { |
a23fd0e1 VZ |
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 | ||
d3c7fc99 | 37 | virtual ~wxMDIParentFrame(); |
a23fd0e1 VZ |
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 | ||
d2824cdb VZ |
47 | // override/implement base class [pure] virtual methods |
48 | // ---------------------------------------------------- | |
2bda0e17 | 49 | |
d2824cdb | 50 | static bool IsTDI() { return false; } |
2bda0e17 | 51 | |
d2824cdb VZ |
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; | |
ef359b43 | 55 | |
a23fd0e1 | 56 | virtual void Cascade(); |
0d97c090 | 57 | virtual void Tile(wxOrientation orient = wxHORIZONTAL); |
a23fd0e1 VZ |
58 | virtual void ArrangeIcons(); |
59 | virtual void ActivateNext(); | |
60 | virtual void ActivatePrevious(); | |
2bda0e17 | 61 | |
d2824cdb VZ |
62 | #if wxUSE_MENUS |
63 | virtual void SetWindowMenu(wxMenu* menu); | |
64 | ||
65 | virtual void DoMenuUpdates(wxMenu* menu = NULL); | |
66 | #endif // wxUSE_MENUS | |
ecc63060 VZ |
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 | ||
a23fd0e1 VZ |
79 | // handlers |
80 | // -------- | |
2bda0e17 | 81 | |
a23fd0e1 VZ |
82 | // Responds to colour changes |
83 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
2bda0e17 | 84 | |
a23fd0e1 | 85 | void OnSize(wxSizeEvent& event); |
6bbe97b7 | 86 | void OnIconized(wxIconizeEvent& event); |
2bda0e17 | 87 | |
42e69d6b VZ |
88 | bool HandleActivate(int state, bool minimized, WXHWND activate); |
89 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
2bda0e17 | 90 | |
a23fd0e1 | 91 | // override window proc for MDI-specific message processing |
c140b7e7 | 92 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
2bda0e17 | 93 | |
c140b7e7 | 94 | virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM); |
a23fd0e1 | 95 | virtual bool MSWTranslateMessage(WXMSG* msg); |
cc2b7472 | 96 | |
10816efb VZ |
97 | // override wxFrameBase function to also look in the active child menu bar |
98 | virtual const wxMenuItem *FindItemInMenuBar(int menuId) const; | |
99 | ||
a23fd0e1 | 100 | protected: |
1e6feb95 | 101 | #if wxUSE_MENUS_NATIVE |
42e69d6b | 102 | virtual void InternalSetMenuBar(); |
1e6feb95 | 103 | #endif // wxUSE_MENUS_NATIVE |
42e69d6b | 104 | |
82c9f85c VZ |
105 | virtual WXHICON GetDefaultIcon() const; |
106 | ||
6bbe97b7 VZ |
107 | // set the size of the MDI client window to match the frame size |
108 | void UpdateClientSize(); | |
109 | ||
110 | ||
598ddd96 | 111 | // true if MDI Frame is intercepting commands, not child |
42e69d6b | 112 | bool m_parentFrameActive; |
a23fd0e1 VZ |
113 | |
114 | private: | |
ecc63060 VZ |
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 | ||
b5dbe15d | 122 | friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; |
a23fd0e1 VZ |
123 | |
124 | DECLARE_EVENT_TABLE() | |
82c9f85c | 125 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) |
22f3361e | 126 | DECLARE_NO_COPY_CLASS(wxMDIParentFrame) |
2bda0e17 KB |
127 | }; |
128 | ||
a23fd0e1 VZ |
129 | // --------------------------------------------------------------------------- |
130 | // wxMDIChildFrame | |
131 | // --------------------------------------------------------------------------- | |
2bda0e17 | 132 | |
d2824cdb | 133 | class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase |
2bda0e17 | 134 | { |
a23fd0e1 | 135 | public: |
f6bcfd97 | 136 | wxMDIChildFrame() { Init(); } |
a23fd0e1 VZ |
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 | { | |
f6bcfd97 BP |
145 | Init(); |
146 | ||
a23fd0e1 VZ |
147 | Create(parent, id, title, pos, size, style, name); |
148 | } | |
149 | ||
a23fd0e1 VZ |
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 | ||
d2824cdb | 158 | virtual ~wxMDIChildFrame(); |
225fe9d6 | 159 | |
d2824cdb VZ |
160 | // implement MDI operations |
161 | virtual void Activate(); | |
162 | ||
163 | // Override some frame operations too | |
598ddd96 | 164 | virtual void Maximize(bool maximize = true); |
a23fd0e1 | 165 | virtual void Restore(); |
d2824cdb VZ |
166 | |
167 | virtual bool Show(bool show = true); | |
a23fd0e1 | 168 | |
f6bcfd97 BP |
169 | // Implementation only from now on |
170 | // ------------------------------- | |
a23fd0e1 | 171 | |
f6bcfd97 | 172 | // Handlers |
42e69d6b | 173 | bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); |
42e69d6b VZ |
174 | bool HandleWindowPosChanging(void *lpPos); |
175 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
3ebcfb76 | 176 | bool HandleGetMinMaxInfo(void *mmInfo); |
42e69d6b | 177 | |
c140b7e7 JS |
178 | virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
179 | virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
42e69d6b VZ |
180 | virtual bool MSWTranslateMessage(WXMSG *msg); |
181 | ||
182 | virtual void MSWDestroyWindow(); | |
2bda0e17 | 183 | |
2bda0e17 | 184 | bool ResetWindowStyle(void *vrect); |
cc2b7472 | 185 | |
f6bcfd97 | 186 | void OnIdle(wxIdleEvent& event); |
ef359b43 | 187 | |
cc2b7472 | 188 | protected: |
3e85709e | 189 | virtual void DoGetScreenPosition(int *x, int *y) const; |
42e69d6b | 190 | virtual void DoGetPosition(int *x, int *y) const; |
a23fd0e1 | 191 | virtual void DoSetClientSize(int width, int height); |
42e69d6b | 192 | virtual void InternalSetMenuBar(); |
598ddd96 | 193 | virtual bool IsMDIChild() const { return true; } |
6f02a879 | 194 | virtual void DetachMenuBar(); |
225fe9d6 | 195 | |
82c9f85c VZ |
196 | virtual WXHICON GetDefaultIcon() const; |
197 | ||
f6bcfd97 BP |
198 | // common part of all ctors |
199 | void Init(); | |
200 | ||
201 | private: | |
2596e9fb | 202 | bool m_needsInitialShow; // Show must be called in idle time after Creation |
f6bcfd97 BP |
203 | bool m_needsResize; // flag which tells us to artificially resize the frame |
204 | ||
205 | DECLARE_EVENT_TABLE() | |
fc7a2a60 | 206 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame) |
2bda0e17 KB |
207 | }; |
208 | ||
a23fd0e1 VZ |
209 | // --------------------------------------------------------------------------- |
210 | // wxMDIClientWindow | |
211 | // --------------------------------------------------------------------------- | |
2bda0e17 | 212 | |
d2824cdb | 213 | class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase |
a23fd0e1 | 214 | { |
a23fd0e1 | 215 | public: |
42e69d6b | 216 | wxMDIClientWindow() { Init(); } |
2bda0e17 | 217 | |
a23fd0e1 VZ |
218 | // Note: this is virtual, to allow overridden behaviour. |
219 | virtual bool CreateClient(wxMDIParentFrame *parent, | |
220 | long style = wxVSCROLL | wxHSCROLL); | |
2bda0e17 | 221 | |
a23fd0e1 VZ |
222 | // Explicitly call default scroll behaviour |
223 | void OnScroll(wxScrollEvent& event); | |
2bda0e17 | 224 | |
6f02a879 | 225 | protected: |
ec06b234 JS |
226 | virtual void DoSetSize(int x, int y, |
227 | int width, int height, | |
228 | int sizeFlags = wxSIZE_AUTO); | |
6f02a879 | 229 | |
42e69d6b VZ |
230 | void Init() { m_scrollX = m_scrollY = 0; } |
231 | ||
a23fd0e1 VZ |
232 | int m_scrollX, m_scrollY; |
233 | ||
234 | private: | |
235 | DECLARE_EVENT_TABLE() | |
fc7a2a60 | 236 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow) |
2bda0e17 KB |
237 | }; |
238 | ||
d2824cdb | 239 | #endif // _WX_MSW_MDI_H_ |