]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/mdi.h
Corrected assertion
[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 #ifdef __GNUG__
16 #pragma interface "mdi.h"
17 #endif
18
19 #include "wx/frame.h"
20
21 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
22 WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
23
24 class WXDLLEXPORT wxMDIClientWindow;
25 class WXDLLEXPORT wxMDIChildFrame;
26
27 // ---------------------------------------------------------------------------
28 // wxMDIParentFrame
29 // ---------------------------------------------------------------------------
30
31 class WXDLLEXPORT wxMDIParentFrame : public wxFrame
32 {
33 public:
34 wxMDIParentFrame();
35 wxMDIParentFrame(wxWindow *parent,
36 wxWindowID id,
37 const wxString& title,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
41 const wxString& name = wxFrameNameStr)
42 {
43 Create(parent, id, title, pos, size, style, name);
44 }
45
46 ~wxMDIParentFrame();
47
48 bool Create(wxWindow *parent,
49 wxWindowID id,
50 const wxString& title,
51 const wxPoint& pos = wxDefaultPosition,
52 const wxSize& size = wxDefaultSize,
53 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
54 const wxString& name = wxFrameNameStr);
55
56 // accessors
57 // ---------
58
59 // Get the active MDI child window (Windows only)
60 wxMDIChildFrame *GetActiveChild() const;
61
62 // Get the client window
63 wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }
64
65 // Create the client window class (don't Create the window,
66 // just return a new class)
67 virtual wxMDIClientWindow *OnCreateClient(void);
68
69 // MDI windows menu
70 wxMenu* GetWindowMenu() const { return m_windowMenu; };
71 void SetWindowMenu(wxMenu* menu) ;
72
73 // MDI operations
74 // --------------
75 virtual void Cascade();
76 virtual void Tile();
77 virtual void ArrangeIcons();
78 virtual void ActivateNext();
79 virtual void ActivatePrevious();
80
81 // handlers
82 // --------
83
84 // Responds to colour changes
85 void OnSysColourChanged(wxSysColourChangedEvent& event);
86
87 void OnSize(wxSizeEvent& event);
88
89 bool HandleActivate(int state, bool minimized, WXHWND activate);
90 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
91
92 // override window proc for MDI-specific message processing
93 virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
94
95 virtual long MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
96 virtual bool MSWTranslateMessage(WXMSG* msg);
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 wxMDIClientWindow * m_clientWindow;
106 wxMDIChildFrame * m_currentChild;
107 wxMenu* m_windowMenu;
108
109 // TRUE if MDI Frame is intercepting commands, not child
110 bool m_parentFrameActive;
111
112 private:
113 friend class WXDLLEXPORT wxMDIChildFrame;
114
115 DECLARE_EVENT_TABLE()
116 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
117 };
118
119 // ---------------------------------------------------------------------------
120 // wxMDIChildFrame
121 // ---------------------------------------------------------------------------
122
123 class WXDLLEXPORT wxMDIChildFrame : public wxFrame
124 {
125 public:
126 wxMDIChildFrame() { Init(); }
127 wxMDIChildFrame(wxMDIParentFrame *parent,
128 wxWindowID id,
129 const wxString& title,
130 const wxPoint& pos = wxDefaultPosition,
131 const wxSize& size = wxDefaultSize,
132 long style = wxDEFAULT_FRAME_STYLE,
133 const wxString& name = wxFrameNameStr)
134 {
135 Init();
136
137 Create(parent, id, title, pos, size, style, name);
138 }
139
140 ~wxMDIChildFrame();
141
142 bool Create(wxMDIParentFrame *parent,
143 wxWindowID id,
144 const wxString& title,
145 const wxPoint& pos = wxDefaultPosition,
146 const wxSize& size = wxDefaultSize,
147 long style = wxDEFAULT_FRAME_STYLE,
148 const wxString& name = wxFrameNameStr);
149
150 virtual bool IsTopLevel() const { return FALSE; }
151
152 // MDI operations
153 virtual void Maximize(bool maximize = TRUE);
154 virtual void Restore();
155 virtual void Activate();
156
157 // Implementation only from now on
158 // -------------------------------
159
160 // Handlers
161 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
162 bool HandleWindowPosChanging(void *lpPos);
163 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
164 bool HandleGetMinMaxInfo(void *mmInfo);
165
166 virtual long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
167 virtual long MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
168 virtual bool MSWTranslateMessage(WXMSG *msg);
169
170 virtual void MSWDestroyWindow();
171
172 bool ResetWindowStyle(void *vrect);
173
174 void OnIdle(wxIdleEvent& event);
175
176 protected:
177 virtual void DoGetPosition(int *x, int *y) const;
178 virtual void DoSetClientSize(int width, int height);
179 virtual void InternalSetMenuBar();
180 virtual bool IsMDIChild() const { return TRUE; }
181
182 virtual WXHICON GetDefaultIcon() const;
183
184 // common part of all ctors
185 void Init();
186
187 private:
188 bool m_needsResize; // flag which tells us to artificially resize the frame
189
190 DECLARE_EVENT_TABLE()
191 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
192 };
193
194 // ---------------------------------------------------------------------------
195 // wxMDIClientWindow
196 // ---------------------------------------------------------------------------
197
198 class WXDLLEXPORT wxMDIClientWindow : public wxWindow
199 {
200 public:
201 wxMDIClientWindow() { Init(); }
202 wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
203 {
204 Init();
205
206 CreateClient(parent, style);
207 }
208
209 // Note: this is virtual, to allow overridden behaviour.
210 virtual bool CreateClient(wxMDIParentFrame *parent,
211 long style = wxVSCROLL | wxHSCROLL);
212
213 // Explicitly call default scroll behaviour
214 void OnScroll(wxScrollEvent& event);
215
216 virtual void DoSetSize(int x, int y,
217 int width, int height,
218 int sizeFlags = wxSIZE_AUTO);
219 protected:
220 void Init() { m_scrollX = m_scrollY = 0; }
221
222 int m_scrollX, m_scrollY;
223
224 private:
225 DECLARE_EVENT_TABLE()
226 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
227 };
228
229 #endif
230 // _WX_MDI_H_