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
77 // called by wxMDIChildFrame after it was successfully created
78 virtual void AddMDIChild(wxMDIChildFrame
*child
);
80 // called by wxMDIChildFrame just before it is destroyed
81 virtual void RemoveMDIChild(wxMDIChildFrame
*child
);
86 // Responds to colour changes
87 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
89 void OnSize(wxSizeEvent
& event
);
90 void OnIconized(wxIconizeEvent
& event
);
92 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
93 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
95 // override window proc for MDI-specific message processing
96 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
98 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
99 virtual bool MSWTranslateMessage(WXMSG
* msg
);
102 // override wxFrameBase function to also look in the active child menu bar
103 virtual const wxMenuItem
*FindItemInMenuBar(int menuId
) const;
104 #endif // wxUSE_MENUS
107 #if wxUSE_MENUS_NATIVE
108 virtual void InternalSetMenuBar();
109 #endif // wxUSE_MENUS_NATIVE
111 virtual WXHICON
GetDefaultIcon() const;
113 // set the size of the MDI client window to match the frame size
114 void UpdateClientSize();
117 // true if MDI Frame is intercepting commands, not child
118 bool m_parentFrameActive
;
122 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
123 void AddWindowMenu();
124 void RemoveWindowMenu();
126 // update the window menu (if we have it) to enable or disable the commands
127 // which only make sense when we have more than one child
128 void UpdateWindowMenu(bool enable
);
129 #endif // wxUSE_MENUS
131 // return the number of child frames we currently have (maybe 0)
132 int GetChildFramesCount() const;
135 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
137 DECLARE_EVENT_TABLE()
138 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
139 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
142 // ---------------------------------------------------------------------------
144 // ---------------------------------------------------------------------------
146 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxMDIChildFrameBase
149 wxMDIChildFrame() { Init(); }
150 wxMDIChildFrame(wxMDIParentFrame
*parent
,
152 const wxString
& title
,
153 const wxPoint
& pos
= wxDefaultPosition
,
154 const wxSize
& size
= wxDefaultSize
,
155 long style
= wxDEFAULT_FRAME_STYLE
,
156 const wxString
& name
= wxFrameNameStr
)
160 Create(parent
, id
, title
, pos
, size
, style
, name
);
163 bool Create(wxMDIParentFrame
*parent
,
165 const wxString
& title
,
166 const wxPoint
& pos
= wxDefaultPosition
,
167 const wxSize
& size
= wxDefaultSize
,
168 long style
= wxDEFAULT_FRAME_STYLE
,
169 const wxString
& name
= wxFrameNameStr
);
171 virtual ~wxMDIChildFrame();
173 // implement MDI operations
174 virtual void Activate();
176 // Override some frame operations too
177 virtual void Maximize(bool maximize
= true);
178 virtual void Restore();
180 virtual bool Show(bool show
= true);
182 // Implementation only from now on
183 // -------------------------------
186 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
187 bool HandleWindowPosChanging(void *lpPos
);
188 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
189 bool HandleGetMinMaxInfo(void *mmInfo
);
191 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
192 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
193 virtual bool MSWTranslateMessage(WXMSG
*msg
);
195 virtual void MSWDestroyWindow();
197 bool ResetWindowStyle(void *vrect
);
199 void OnIdle(wxIdleEvent
& event
);
202 virtual void DoGetScreenPosition(int *x
, int *y
) const;
203 virtual void DoGetPosition(int *x
, int *y
) const;
204 virtual void DoSetClientSize(int width
, int height
);
205 virtual void InternalSetMenuBar();
206 virtual bool IsMDIChild() const { return true; }
207 virtual void DetachMenuBar();
209 virtual WXHICON
GetDefaultIcon() const;
211 // common part of all ctors
215 bool m_needsInitialShow
; // Show must be called in idle time after Creation
216 bool m_needsResize
; // flag which tells us to artificially resize the frame
218 DECLARE_EVENT_TABLE()
219 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
222 // ---------------------------------------------------------------------------
224 // ---------------------------------------------------------------------------
226 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxMDIClientWindowBase
229 wxMDIClientWindow() { Init(); }
231 // Note: this is virtual, to allow overridden behaviour.
232 virtual bool CreateClient(wxMDIParentFrame
*parent
,
233 long style
= wxVSCROLL
| wxHSCROLL
);
235 // Explicitly call default scroll behaviour
236 void OnScroll(wxScrollEvent
& event
);
239 virtual void DoSetSize(int x
, int y
,
240 int width
, int height
,
241 int sizeFlags
= wxSIZE_AUTO
);
243 void Init() { m_scrollX
= m_scrollY
= 0; }
245 int m_scrollX
, m_scrollY
;
248 DECLARE_EVENT_TABLE()
249 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)
252 #endif // _WX_MSW_MDI_H_