]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/mdi.h
Applied patch [ 1263950 ] wxConnection fixes for Unicode
[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 void OnIconized(wxIconizeEvent& 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 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
96
97 virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
98 virtual bool MSWTranslateMessage(WXMSG* msg);
99
100 protected:
101 #if wxUSE_MENUS_NATIVE
102 virtual void InternalSetMenuBar();
103 #endif // wxUSE_MENUS_NATIVE
104
105 virtual WXHICON GetDefaultIcon() const;
106
107 // set the size of the MDI client window to match the frame size
108 void UpdateClientSize();
109
110
111 wxMDIClientWindow * m_clientWindow;
112 wxMDIChildFrame * m_currentChild;
113 wxMenu* m_windowMenu;
114
115 // true if MDI Frame is intercepting commands, not child
116 bool m_parentFrameActive;
117
118 private:
119 friend class WXDLLEXPORT wxMDIChildFrame;
120
121 DECLARE_EVENT_TABLE()
122 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
123 DECLARE_NO_COPY_CLASS(wxMDIParentFrame)
124 };
125
126 // ---------------------------------------------------------------------------
127 // wxMDIChildFrame
128 // ---------------------------------------------------------------------------
129
130 class WXDLLEXPORT wxMDIChildFrame : public wxFrame
131 {
132 public:
133 wxMDIChildFrame() { Init(); }
134 wxMDIChildFrame(wxMDIParentFrame *parent,
135 wxWindowID id,
136 const wxString& title,
137 const wxPoint& pos = wxDefaultPosition,
138 const wxSize& size = wxDefaultSize,
139 long style = wxDEFAULT_FRAME_STYLE,
140 const wxString& name = wxFrameNameStr)
141 {
142 Init();
143
144 Create(parent, id, title, pos, size, style, name);
145 }
146
147 ~wxMDIChildFrame();
148
149 bool Create(wxMDIParentFrame *parent,
150 wxWindowID id,
151 const wxString& title,
152 const wxPoint& pos = wxDefaultPosition,
153 const wxSize& size = wxDefaultSize,
154 long style = wxDEFAULT_FRAME_STYLE,
155 const wxString& name = wxFrameNameStr);
156
157 virtual bool IsTopLevel() const { return false; }
158
159 // MDI operations
160 virtual void Maximize(bool maximize = true);
161 virtual void Restore();
162 virtual void Activate();
163
164 // Implementation only from now on
165 // -------------------------------
166
167 // Handlers
168 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
169 bool HandleWindowPosChanging(void *lpPos);
170 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
171 bool HandleGetMinMaxInfo(void *mmInfo);
172
173 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
174 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
175 virtual bool MSWTranslateMessage(WXMSG *msg);
176
177 virtual void MSWDestroyWindow();
178
179 bool ResetWindowStyle(void *vrect);
180
181 void OnIdle(wxIdleEvent& event);
182
183 virtual bool Show(bool show = true);
184
185 protected:
186 virtual void DoGetPosition(int *x, int *y) const;
187 virtual void DoSetClientSize(int width, int height);
188 virtual void InternalSetMenuBar();
189 virtual bool IsMDIChild() const { return true; }
190
191 virtual WXHICON GetDefaultIcon() const;
192
193 // common part of all ctors
194 void Init();
195
196 private:
197 bool m_needsInitialShow; // Show must be called in idle time after Creation
198 bool m_needsResize; // flag which tells us to artificially resize the frame
199 virtual void DetachMenuBar() ;
200
201 DECLARE_EVENT_TABLE()
202 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame)
203 };
204
205 // ---------------------------------------------------------------------------
206 // wxMDIClientWindow
207 // ---------------------------------------------------------------------------
208
209 class WXDLLEXPORT wxMDIClientWindow : public wxWindow
210 {
211 public:
212 wxMDIClientWindow() { Init(); }
213 wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
214 {
215 Init();
216
217 CreateClient(parent, style);
218 }
219
220 // Note: this is virtual, to allow overridden behaviour.
221 virtual bool CreateClient(wxMDIParentFrame *parent,
222 long style = wxVSCROLL | wxHSCROLL);
223
224 // Explicitly call default scroll behaviour
225 void OnScroll(wxScrollEvent& event);
226
227 virtual void DoSetSize(int x, int y,
228 int width, int height,
229 int sizeFlags = wxSIZE_AUTO);
230 protected:
231 void Init() { m_scrollX = m_scrollY = 0; }
232
233 int m_scrollX, m_scrollY;
234
235 private:
236 DECLARE_EVENT_TABLE()
237 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
238 };
239
240 #endif
241 // _WX_MDI_H_