1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI (Multiple Document Interface) classes
4 // Author: Julian Smart
5 // Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
8 // Copyright: (c) 1997 Julian Smart
9 // (c) 2008 Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_MSW_MDI_H_
14 #define _WX_MSW_MDI_H_
18 class WXDLLIMPEXP_FWD_CORE wxAcceleratorTable
;
20 // ---------------------------------------------------------------------------
22 // ---------------------------------------------------------------------------
24 class WXDLLIMPEXP_CORE wxMDIParentFrame
: public wxMDIParentFrameBase
27 wxMDIParentFrame() { Init(); }
28 wxMDIParentFrame(wxWindow
*parent
,
30 const wxString
& title
,
31 const wxPoint
& pos
= wxDefaultPosition
,
32 const wxSize
& size
= wxDefaultSize
,
33 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
34 const wxString
& name
= wxFrameNameStr
)
38 Create(parent
, id
, title
, pos
, size
, style
, name
);
41 virtual ~wxMDIParentFrame();
43 bool Create(wxWindow
*parent
,
45 const wxString
& title
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
48 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
49 const wxString
& name
= wxFrameNameStr
);
51 // override/implement base class [pure] virtual methods
52 // ----------------------------------------------------
54 static bool IsTDI() { return false; }
56 // we don't store the active child in m_currentChild so override this
57 // function to find it dynamically
58 virtual wxMDIChildFrame
*GetActiveChild() const;
60 virtual void Cascade();
61 virtual void Tile(wxOrientation orient
= wxHORIZONTAL
);
62 virtual void ArrangeIcons();
63 virtual void ActivateNext();
64 virtual void ActivatePrevious();
67 virtual void SetWindowMenu(wxMenu
* menu
);
69 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
71 // return the active child menu, if any
72 virtual WXHMENU
MSWGetActiveMenu() const;
76 // implementation only from now on
82 // called by wxMDIChildFrame after it was successfully created
83 virtual void AddMDIChild(wxMDIChildFrame
*child
);
85 // called by wxMDIChildFrame just before it is destroyed
86 virtual void RemoveMDIChild(wxMDIChildFrame
*child
);
92 // Responds to colour changes
93 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
95 void OnSize(wxSizeEvent
& event
);
96 void OnIconized(wxIconizeEvent
& event
);
98 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
100 // override window proc for MDI-specific message processing
101 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
103 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
104 virtual bool MSWTranslateMessage(WXMSG
* msg
);
107 // override wxFrameBase function to also look in the active child menu bar
108 // and the "Window" menu
109 virtual wxMenuItem
*FindItemInMenuBar(int menuId
) const;
110 #endif // wxUSE_MENUS
113 // override to pass menu/toolbar events to the active child first
114 virtual bool TryBefore(wxEvent
& event
);
116 #if wxUSE_MENUS_NATIVE
117 virtual void InternalSetMenuBar();
118 #endif // wxUSE_MENUS_NATIVE
120 virtual WXHICON
GetDefaultIcon() const;
122 // set the size of the MDI client window to match the frame size
123 void UpdateClientSize();
126 // common part of all ctors
130 // "Window" menu commands event handlers
131 void OnMDICommand(wxCommandEvent
& event
);
132 void OnMDIChild(wxCommandEvent
& event
);
135 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
136 void AddWindowMenu();
137 void RemoveWindowMenu();
139 // update the window menu (if we have it) to enable or disable the commands
140 // which only make sense when we have more than one child
141 void UpdateWindowMenu(bool enable
);
144 wxAcceleratorTable
*m_accelWindowMenu
;
145 #endif // wxUSE_ACCEL
146 #endif // wxUSE_MENUS
148 // return the number of child frames we currently have (maybe 0)
149 int GetChildFramesCount() const;
152 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
154 DECLARE_EVENT_TABLE()
155 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
156 wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame
);
159 // ---------------------------------------------------------------------------
161 // ---------------------------------------------------------------------------
163 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxMDIChildFrameBase
166 wxMDIChildFrame() { Init(); }
167 wxMDIChildFrame(wxMDIParentFrame
*parent
,
169 const wxString
& title
,
170 const wxPoint
& pos
= wxDefaultPosition
,
171 const wxSize
& size
= wxDefaultSize
,
172 long style
= wxDEFAULT_FRAME_STYLE
,
173 const wxString
& name
= wxFrameNameStr
)
177 Create(parent
, id
, title
, pos
, size
, style
, name
);
180 bool Create(wxMDIParentFrame
*parent
,
182 const wxString
& title
,
183 const wxPoint
& pos
= wxDefaultPosition
,
184 const wxSize
& size
= wxDefaultSize
,
185 long style
= wxDEFAULT_FRAME_STYLE
,
186 const wxString
& name
= wxFrameNameStr
);
188 virtual ~wxMDIChildFrame();
190 // implement MDI operations
191 virtual void Activate();
193 // Override some frame operations too
194 virtual void Maximize(bool maximize
= true);
195 virtual void Restore();
197 virtual bool Show(bool show
= true);
199 // Implementation only from now on
200 // -------------------------------
203 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
204 bool HandleWindowPosChanging(void *lpPos
);
205 bool HandleGetMinMaxInfo(void *mmInfo
);
207 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
208 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
209 virtual bool MSWTranslateMessage(WXMSG
*msg
);
211 virtual void MSWDestroyWindow();
213 bool ResetWindowStyle(void *vrect
);
215 void OnIdle(wxIdleEvent
& event
);
218 virtual void DoGetScreenPosition(int *x
, int *y
) const;
219 virtual void DoGetPosition(int *x
, int *y
) const;
220 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
);
221 virtual void DoSetClientSize(int width
, int height
);
222 virtual void InternalSetMenuBar();
223 virtual bool IsMDIChild() const { return true; }
224 virtual void DetachMenuBar();
226 virtual WXHICON
GetDefaultIcon() const;
228 // common part of all ctors
232 bool m_needsInitialShow
; // Show must be called in idle time after Creation
233 bool m_needsResize
; // flag which tells us to artificially resize the frame
235 DECLARE_EVENT_TABLE()
236 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
239 // ---------------------------------------------------------------------------
241 // ---------------------------------------------------------------------------
243 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxMDIClientWindowBase
246 wxMDIClientWindow() { Init(); }
248 // Note: this is virtual, to allow overridden behaviour.
249 virtual bool CreateClient(wxMDIParentFrame
*parent
,
250 long style
= wxVSCROLL
| wxHSCROLL
);
252 // Explicitly call default scroll behaviour
253 void OnScroll(wxScrollEvent
& event
);
256 virtual void DoSetSize(int x
, int y
,
257 int width
, int height
,
258 int sizeFlags
= wxSIZE_AUTO
);
260 void Init() { m_scrollX
= m_scrollY
= 0; }
262 int m_scrollX
, m_scrollY
;
265 DECLARE_EVENT_TABLE()
266 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)
269 #endif // _WX_MSW_MDI_H_