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 // ---------------------------------------------------------------------------
20 // ---------------------------------------------------------------------------
22 class WXDLLIMPEXP_CORE wxMDIParentFrame
: public wxMDIParentFrameBase
26 wxMDIParentFrame(wxWindow
*parent
,
28 const wxString
& title
,
29 const wxPoint
& pos
= wxDefaultPosition
,
30 const wxSize
& size
= wxDefaultSize
,
31 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
32 const wxString
& name
= wxFrameNameStr
)
34 Create(parent
, id
, title
, pos
, size
, style
, name
);
37 virtual ~wxMDIParentFrame();
39 bool Create(wxWindow
*parent
,
41 const wxString
& title
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
44 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
45 const wxString
& name
= wxFrameNameStr
);
47 // override/implement base class [pure] virtual methods
48 // ----------------------------------------------------
50 static bool IsTDI() { return false; }
52 // we don't store the active child in m_currentChild so override this
53 // function to find it dynamically
54 virtual wxMDIChildFrame
*GetActiveChild() const;
56 virtual void Cascade();
57 virtual void Tile(wxOrientation orient
= wxHORIZONTAL
);
58 virtual void ArrangeIcons();
59 virtual void ActivateNext();
60 virtual void ActivatePrevious();
63 virtual void SetWindowMenu(wxMenu
* menu
);
65 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
67 // return the active child menu, if any
68 virtual WXHMENU
MSWGetActiveMenu() const;
72 // implementation only from now on
78 // called by wxMDIChildFrame after it was successfully created
79 virtual void AddMDIChild(wxMDIChildFrame
*child
);
81 // called by wxMDIChildFrame just before it is destroyed
82 virtual void RemoveMDIChild(wxMDIChildFrame
*child
);
88 // Responds to colour changes
89 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
91 void OnSize(wxSizeEvent
& event
);
92 void OnIconized(wxIconizeEvent
& event
);
94 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
95 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
97 // override window proc for MDI-specific message processing
98 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
100 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
101 virtual bool MSWTranslateMessage(WXMSG
* msg
);
104 // override wxFrameBase function to also look in the active child menu bar
105 virtual const wxMenuItem
*FindItemInMenuBar(int menuId
) const;
106 #endif // wxUSE_MENUS
109 #if wxUSE_MENUS_NATIVE
110 virtual void InternalSetMenuBar();
111 #endif // wxUSE_MENUS_NATIVE
113 virtual WXHICON
GetDefaultIcon() const;
115 // set the size of the MDI client window to match the frame size
116 void UpdateClientSize();
119 // true if MDI Frame is intercepting commands, not child
120 bool m_parentFrameActive
;
124 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
125 void AddWindowMenu();
126 void RemoveWindowMenu();
128 // update the window menu (if we have it) to enable or disable the commands
129 // which only make sense when we have more than one child
130 void UpdateWindowMenu(bool enable
);
131 #endif // wxUSE_MENUS
133 // return the number of child frames we currently have (maybe 0)
134 int GetChildFramesCount() const;
137 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
139 DECLARE_EVENT_TABLE()
140 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
141 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
144 // ---------------------------------------------------------------------------
146 // ---------------------------------------------------------------------------
148 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxMDIChildFrameBase
151 wxMDIChildFrame() { Init(); }
152 wxMDIChildFrame(wxMDIParentFrame
*parent
,
154 const wxString
& title
,
155 const wxPoint
& pos
= wxDefaultPosition
,
156 const wxSize
& size
= wxDefaultSize
,
157 long style
= wxDEFAULT_FRAME_STYLE
,
158 const wxString
& name
= wxFrameNameStr
)
162 Create(parent
, id
, title
, pos
, size
, style
, name
);
165 bool Create(wxMDIParentFrame
*parent
,
167 const wxString
& title
,
168 const wxPoint
& pos
= wxDefaultPosition
,
169 const wxSize
& size
= wxDefaultSize
,
170 long style
= wxDEFAULT_FRAME_STYLE
,
171 const wxString
& name
= wxFrameNameStr
);
173 virtual ~wxMDIChildFrame();
175 // implement MDI operations
176 virtual void Activate();
178 // Override some frame operations too
179 virtual void Maximize(bool maximize
= true);
180 virtual void Restore();
182 virtual bool Show(bool show
= true);
184 // Implementation only from now on
185 // -------------------------------
188 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
189 bool HandleWindowPosChanging(void *lpPos
);
190 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
191 bool HandleGetMinMaxInfo(void *mmInfo
);
193 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
194 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
195 virtual bool MSWTranslateMessage(WXMSG
*msg
);
197 virtual void MSWDestroyWindow();
199 bool ResetWindowStyle(void *vrect
);
201 void OnIdle(wxIdleEvent
& event
);
204 virtual void DoGetScreenPosition(int *x
, int *y
) const;
205 virtual void DoGetPosition(int *x
, int *y
) const;
206 virtual void DoSetClientSize(int width
, int height
);
207 virtual void InternalSetMenuBar();
208 virtual bool IsMDIChild() const { return true; }
209 virtual void DetachMenuBar();
211 virtual WXHICON
GetDefaultIcon() const;
213 // common part of all ctors
217 bool m_needsInitialShow
; // Show must be called in idle time after Creation
218 bool m_needsResize
; // flag which tells us to artificially resize the frame
220 DECLARE_EVENT_TABLE()
221 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
224 // ---------------------------------------------------------------------------
226 // ---------------------------------------------------------------------------
228 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxMDIClientWindowBase
231 wxMDIClientWindow() { Init(); }
233 // Note: this is virtual, to allow overridden behaviour.
234 virtual bool CreateClient(wxMDIParentFrame
*parent
,
235 long style
= wxVSCROLL
| wxHSCROLL
);
237 // Explicitly call default scroll behaviour
238 void OnScroll(wxScrollEvent
& event
);
241 virtual void DoSetSize(int x
, int y
,
242 int width
, int height
,
243 int sizeFlags
= wxSIZE_AUTO
);
245 void Init() { m_scrollX
= m_scrollY
= 0; }
247 int m_scrollX
, m_scrollY
;
250 DECLARE_EVENT_TABLE()
251 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)
254 #endif // _WX_MSW_MDI_H_