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 #if wxUSE_MENUS_NATIVE
114 virtual void InternalSetMenuBar();
115 #endif // wxUSE_MENUS_NATIVE
117 virtual WXHICON
GetDefaultIcon() const;
119 // set the size of the MDI client window to match the frame size
120 void UpdateClientSize();
123 // common part of all ctors
127 // "Window" menu commands event handlers
128 void OnMDICommand(wxCommandEvent
& event
);
129 void OnMDIChild(wxCommandEvent
& event
);
132 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
133 void AddWindowMenu();
134 void RemoveWindowMenu();
136 // update the window menu (if we have it) to enable or disable the commands
137 // which only make sense when we have more than one child
138 void UpdateWindowMenu(bool enable
);
141 wxAcceleratorTable
*m_accelWindowMenu
;
142 #endif // wxUSE_ACCEL
143 #endif // wxUSE_MENUS
145 // return the number of child frames we currently have (maybe 0)
146 int GetChildFramesCount() const;
149 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
151 DECLARE_EVENT_TABLE()
152 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
153 wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame
);
156 // ---------------------------------------------------------------------------
158 // ---------------------------------------------------------------------------
160 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxMDIChildFrameBase
163 wxMDIChildFrame() { Init(); }
164 wxMDIChildFrame(wxMDIParentFrame
*parent
,
166 const wxString
& title
,
167 const wxPoint
& pos
= wxDefaultPosition
,
168 const wxSize
& size
= wxDefaultSize
,
169 long style
= wxDEFAULT_FRAME_STYLE
,
170 const wxString
& name
= wxFrameNameStr
)
174 Create(parent
, id
, title
, pos
, size
, style
, name
);
177 bool Create(wxMDIParentFrame
*parent
,
179 const wxString
& title
,
180 const wxPoint
& pos
= wxDefaultPosition
,
181 const wxSize
& size
= wxDefaultSize
,
182 long style
= wxDEFAULT_FRAME_STYLE
,
183 const wxString
& name
= wxFrameNameStr
);
185 virtual ~wxMDIChildFrame();
187 // implement MDI operations
188 virtual void Activate();
190 // Override some frame operations too
191 virtual void Maximize(bool maximize
= true);
192 virtual void Restore();
194 virtual bool Show(bool show
= true);
196 // Implementation only from now on
197 // -------------------------------
200 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
201 bool HandleWindowPosChanging(void *lpPos
);
202 bool HandleGetMinMaxInfo(void *mmInfo
);
204 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
205 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
206 virtual bool MSWTranslateMessage(WXMSG
*msg
);
208 virtual void MSWDestroyWindow();
210 bool ResetWindowStyle(void *vrect
);
212 void OnIdle(wxIdleEvent
& event
);
215 virtual void DoGetScreenPosition(int *x
, int *y
) const;
216 virtual void DoGetPosition(int *x
, int *y
) const;
217 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
);
218 virtual void DoSetClientSize(int width
, int height
);
219 virtual void InternalSetMenuBar();
220 virtual bool IsMDIChild() const { return true; }
221 virtual void DetachMenuBar();
223 virtual WXHICON
GetDefaultIcon() const;
225 // common part of all ctors
229 bool m_needsInitialShow
; // Show must be called in idle time after Creation
230 bool m_needsResize
; // flag which tells us to artificially resize the frame
232 DECLARE_EVENT_TABLE()
233 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
236 // ---------------------------------------------------------------------------
238 // ---------------------------------------------------------------------------
240 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxMDIClientWindowBase
243 wxMDIClientWindow() { Init(); }
245 // Note: this is virtual, to allow overridden behaviour.
246 virtual bool CreateClient(wxMDIParentFrame
*parent
,
247 long style
= wxVSCROLL
| wxHSCROLL
);
249 // Explicitly call default scroll behaviour
250 void OnScroll(wxScrollEvent
& event
);
253 virtual void DoSetSize(int x
, int y
,
254 int width
, int height
,
255 int sizeFlags
= wxSIZE_AUTO
);
257 void Init() { m_scrollX
= m_scrollY
= 0; }
259 int m_scrollX
, m_scrollY
;
262 DECLARE_EVENT_TABLE()
263 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)
266 #endif // _WX_MSW_MDI_H_