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