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() { }
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
)
36 Create(parent
, id
, title
, pos
, size
, style
, name
);
39 virtual ~wxMDIParentFrame();
41 bool Create(wxWindow
*parent
,
43 const wxString
& title
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
,
46 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
47 const wxString
& name
= wxFrameNameStr
);
49 // override/implement base class [pure] virtual methods
50 // ----------------------------------------------------
52 static bool IsTDI() { return false; }
54 // we don't store the active child in m_currentChild so override this
55 // function to find it dynamically
56 virtual wxMDIChildFrame
*GetActiveChild() const;
58 virtual void Cascade();
59 virtual void Tile(wxOrientation orient
= wxHORIZONTAL
);
60 virtual void ArrangeIcons();
61 virtual void ActivateNext();
62 virtual void ActivatePrevious();
65 virtual void SetWindowMenu(wxMenu
* menu
);
67 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
69 // return the active child menu, if any
70 virtual WXHMENU
MSWGetActiveMenu() const;
74 // implementation only from now on
80 // called by wxMDIChildFrame after it was successfully created
81 virtual void AddMDIChild(wxMDIChildFrame
*child
);
83 // called by wxMDIChildFrame just before it is destroyed
84 virtual void RemoveMDIChild(wxMDIChildFrame
*child
);
90 // Responds to colour changes
91 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
93 void OnSize(wxSizeEvent
& event
);
94 void OnIconized(wxIconizeEvent
& event
);
96 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
98 // override window proc for MDI-specific message processing
99 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
101 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
102 virtual bool MSWTranslateMessage(WXMSG
* msg
);
105 // override wxFrameBase function to also look in the active child menu bar
106 // and the "Window" menu
107 virtual wxMenuItem
*FindItemInMenuBar(int menuId
) const;
108 #endif // wxUSE_MENUS
111 // override to pass menu/toolbar events to the active child first
112 virtual bool TryBefore(wxEvent
& event
);
114 #if wxUSE_MENUS_NATIVE
115 virtual void InternalSetMenuBar();
116 #endif // wxUSE_MENUS_NATIVE
118 virtual WXHICON
GetDefaultIcon() const;
120 // set the size of the MDI client window to match the frame size
121 void UpdateClientSize();
125 // "Window" menu commands event handlers
126 void OnMDICommand(wxCommandEvent
& event
);
127 void OnMDIChild(wxCommandEvent
& event
);
130 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
131 void AddWindowMenu();
132 void RemoveWindowMenu();
134 // update the window menu (if we have it) to enable or disable the commands
135 // which only make sense when we have more than one child
136 void UpdateWindowMenu(bool enable
);
139 wxAcceleratorTable
*m_accelWindowMenu
;
140 #endif // wxUSE_ACCEL
141 #endif // wxUSE_MENUS
143 // return the number of child frames we currently have (maybe 0)
144 int GetChildFramesCount() const;
147 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
149 DECLARE_EVENT_TABLE()
150 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
151 wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame
);
154 // ---------------------------------------------------------------------------
156 // ---------------------------------------------------------------------------
158 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxMDIChildFrameBase
161 wxMDIChildFrame() { Init(); }
162 wxMDIChildFrame(wxMDIParentFrame
*parent
,
164 const wxString
& title
,
165 const wxPoint
& pos
= wxDefaultPosition
,
166 const wxSize
& size
= wxDefaultSize
,
167 long style
= wxDEFAULT_FRAME_STYLE
,
168 const wxString
& name
= wxFrameNameStr
)
172 Create(parent
, id
, title
, pos
, size
, style
, name
);
175 bool Create(wxMDIParentFrame
*parent
,
177 const wxString
& title
,
178 const wxPoint
& pos
= wxDefaultPosition
,
179 const wxSize
& size
= wxDefaultSize
,
180 long style
= wxDEFAULT_FRAME_STYLE
,
181 const wxString
& name
= wxFrameNameStr
);
183 virtual ~wxMDIChildFrame();
185 // implement MDI operations
186 virtual void Activate();
188 // Override some frame operations too
189 virtual void Maximize(bool maximize
= true);
190 virtual void Restore();
192 virtual bool Show(bool show
= true);
194 // Implementation only from now on
195 // -------------------------------
198 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
199 bool HandleWindowPosChanging(void *lpPos
);
200 bool HandleGetMinMaxInfo(void *mmInfo
);
202 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
203 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
204 virtual bool MSWTranslateMessage(WXMSG
*msg
);
206 virtual void MSWDestroyWindow();
208 bool ResetWindowStyle(void *vrect
);
210 void OnIdle(wxIdleEvent
& event
);
213 virtual void DoGetScreenPosition(int *x
, int *y
) const;
214 virtual void DoGetPosition(int *x
, int *y
) const;
215 virtual void DoSetClientSize(int width
, int height
);
216 virtual void InternalSetMenuBar();
217 virtual bool IsMDIChild() const { return true; }
218 virtual void DetachMenuBar();
220 virtual WXHICON
GetDefaultIcon() const;
222 // common part of all ctors
226 bool m_needsInitialShow
; // Show must be called in idle time after Creation
227 bool m_needsResize
; // flag which tells us to artificially resize the frame
229 DECLARE_EVENT_TABLE()
230 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
233 // ---------------------------------------------------------------------------
235 // ---------------------------------------------------------------------------
237 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxMDIClientWindowBase
240 wxMDIClientWindow() { Init(); }
242 // Note: this is virtual, to allow overridden behaviour.
243 virtual bool CreateClient(wxMDIParentFrame
*parent
,
244 long style
= wxVSCROLL
| wxHSCROLL
);
246 // Explicitly call default scroll behaviour
247 void OnScroll(wxScrollEvent
& event
);
250 virtual void DoSetSize(int x
, int y
,
251 int width
, int height
,
252 int sizeFlags
= wxSIZE_AUTO
);
254 void Init() { m_scrollX
= m_scrollY
= 0; }
256 int m_scrollX
, m_scrollY
;
259 DECLARE_EVENT_TABLE()
260 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)
263 #endif // _WX_MSW_MDI_H_