]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/mdi.h
implemented Freeze/Thaw in wxGTK
[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 WXDLLEXPORT_DATA(const char) 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 wxMDIParentFrame* GetMDIParent() const
166 {
167 return wxStaticCast(wxFrame::GetParent(), wxMDIParentFrame);
168 }
169
170 // Handlers
171 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
172 bool HandleWindowPosChanging(void *lpPos);
173 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
174 bool HandleGetMinMaxInfo(void *mmInfo);
175
176 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
177 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
178 virtual bool MSWTranslateMessage(WXMSG *msg);
179
180 virtual void MSWDestroyWindow();
181
182 bool ResetWindowStyle(void *vrect);
183
184 void OnIdle(wxIdleEvent& event);
185
186 virtual bool Show(bool show = true);
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 WXDLLEXPORT wxMDIClientWindow : public wxWindow
214 {
215 public:
216 wxMDIClientWindow() { Init(); }
217 wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
218 {
219 Init();
220
221 CreateClient(parent, style);
222 }
223
224 // Note: this is virtual, to allow overridden behaviour.
225 virtual bool CreateClient(wxMDIParentFrame *parent,
226 long style = wxVSCROLL | wxHSCROLL);
227
228 // Explicitly call default scroll behaviour
229 void OnScroll(wxScrollEvent& event);
230
231 protected:
232 virtual void DoSetSize(int x, int y,
233 int width, int height,
234 int sizeFlags = wxSIZE_AUTO);
235
236 void Init() { m_scrollX = m_scrollY = 0; }
237
238 int m_scrollX, m_scrollY;
239
240 private:
241 DECLARE_EVENT_TABLE()
242 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
243 };
244
245 #endif
246 // _WX_MDI_H_