added orient parameter to wxMDIParentFrame::Tile()
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "mdi.h"
17 #endif
18
19 #include "wx/frame.h"
20
21 extern WXDLLEXPORT_DATA(const wxChar*) wxFrameNameStr;
22 extern WXDLLEXPORT_DATA(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 virtual void DoMenuUpdates(wxMenu* menu = NULL);
73
74 // MDI operations
75 // --------------
76 virtual void Cascade();
77 virtual void Tile(wxOrientation orient = wxHORIZONTAL);
78 virtual void ArrangeIcons();
79 virtual void ActivateNext();
80 virtual void ActivatePrevious();
81
82 // handlers
83 // --------
84
85 // Responds to colour changes
86 void OnSysColourChanged(wxSysColourChangedEvent& event);
87
88 void OnSize(wxSizeEvent& event);
89
90 bool HandleActivate(int state, bool minimized, WXHWND activate);
91 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
92
93 // override window proc for MDI-specific message processing
94 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
95
96 virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
97 virtual bool MSWTranslateMessage(WXMSG* msg);
98
99 protected:
100 #if wxUSE_MENUS_NATIVE
101 virtual void InternalSetMenuBar();
102 #endif // wxUSE_MENUS_NATIVE
103
104 virtual WXHICON GetDefaultIcon() const;
105
106 wxMDIClientWindow * m_clientWindow;
107 wxMDIChildFrame * m_currentChild;
108 wxMenu* m_windowMenu;
109
110 // true if MDI Frame is intercepting commands, not child
111 bool m_parentFrameActive;
112
113 private:
114 friend class WXDLLEXPORT wxMDIChildFrame;
115
116 DECLARE_EVENT_TABLE()
117 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
118 DECLARE_NO_COPY_CLASS(wxMDIParentFrame)
119 };
120
121 // ---------------------------------------------------------------------------
122 // wxMDIChildFrame
123 // ---------------------------------------------------------------------------
124
125 class WXDLLEXPORT wxMDIChildFrame : public wxFrame
126 {
127 public:
128 wxMDIChildFrame() { Init(); }
129 wxMDIChildFrame(wxMDIParentFrame *parent,
130 wxWindowID id,
131 const wxString& title,
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize,
134 long style = wxDEFAULT_FRAME_STYLE,
135 const wxString& name = wxFrameNameStr)
136 {
137 Init();
138
139 Create(parent, id, title, pos, size, style, name);
140 }
141
142 ~wxMDIChildFrame();
143
144 bool Create(wxMDIParentFrame *parent,
145 wxWindowID id,
146 const wxString& title,
147 const wxPoint& pos = wxDefaultPosition,
148 const wxSize& size = wxDefaultSize,
149 long style = wxDEFAULT_FRAME_STYLE,
150 const wxString& name = wxFrameNameStr);
151
152 virtual bool IsTopLevel() const { return false; }
153
154 // MDI operations
155 virtual void Maximize(bool maximize = true);
156 virtual void Restore();
157 virtual void Activate();
158
159 // Implementation only from now on
160 // -------------------------------
161
162 // Handlers
163 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
164 bool HandleWindowPosChanging(void *lpPos);
165 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
166 bool HandleGetMinMaxInfo(void *mmInfo);
167
168 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
169 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
170 virtual bool MSWTranslateMessage(WXMSG *msg);
171
172 virtual void MSWDestroyWindow();
173
174 bool ResetWindowStyle(void *vrect);
175
176 void OnIdle(wxIdleEvent& event);
177
178 virtual bool Show(bool show = true);
179
180 protected:
181 virtual void DoGetPosition(int *x, int *y) const;
182 virtual void DoSetClientSize(int width, int height);
183 virtual void InternalSetMenuBar();
184 virtual bool IsMDIChild() const { return true; }
185
186 virtual WXHICON GetDefaultIcon() const;
187
188 // common part of all ctors
189 void Init();
190
191 private:
192 bool m_needsInitialShow; // Show must be called in idle time after Creation
193 bool m_needsResize; // flag which tells us to artificially resize the frame
194
195 DECLARE_EVENT_TABLE()
196 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame)
197 };
198
199 // ---------------------------------------------------------------------------
200 // wxMDIClientWindow
201 // ---------------------------------------------------------------------------
202
203 class WXDLLEXPORT wxMDIClientWindow : public wxWindow
204 {
205 public:
206 wxMDIClientWindow() { Init(); }
207 wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
208 {
209 Init();
210
211 CreateClient(parent, style);
212 }
213
214 // Note: this is virtual, to allow overridden behaviour.
215 virtual bool CreateClient(wxMDIParentFrame *parent,
216 long style = wxVSCROLL | wxHSCROLL);
217
218 // Explicitly call default scroll behaviour
219 void OnScroll(wxScrollEvent& event);
220
221 virtual void DoSetSize(int x, int y,
222 int width, int height,
223 int sizeFlags = wxSIZE_AUTO);
224 protected:
225 void Init() { m_scrollX = m_scrollY = 0; }
226
227 int m_scrollX, m_scrollY;
228
229 private:
230 DECLARE_EVENT_TABLE()
231 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
232 };
233
234 #endif
235 // _WX_MDI_H_