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