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
);
97 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
99 // override window proc for MDI-specific message processing
100 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
102 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
103 virtual bool MSWTranslateMessage(WXMSG
* msg
);
106 // override wxFrameBase function to also look in the active child menu bar
107 // and the "Window" menu
108 virtual wxMenuItem
*FindItemInMenuBar(int menuId
) const;
109 #endif // wxUSE_MENUS
112 #if wxUSE_MENUS_NATIVE
113 virtual void InternalSetMenuBar();
114 #endif // wxUSE_MENUS_NATIVE
116 virtual WXHICON
GetDefaultIcon() const;
118 // set the size of the MDI client window to match the frame size
119 void UpdateClientSize();
123 // "Window" menu commands event handlers
124 void OnMDICommand(wxCommandEvent
& event
);
125 void OnMDIChild(wxCommandEvent
& event
);
128 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
129 void AddWindowMenu();
130 void RemoveWindowMenu();
132 // update the window menu (if we have it) to enable or disable the commands
133 // which only make sense when we have more than one child
134 void UpdateWindowMenu(bool enable
);
137 wxAcceleratorTable
*m_accelWindowMenu
;
138 #endif // wxUSE_ACCEL
139 #endif // wxUSE_MENUS
141 // return the number of child frames we currently have (maybe 0)
142 int GetChildFramesCount() const;
145 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
147 DECLARE_EVENT_TABLE()
148 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
149 wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame
);
152 // ---------------------------------------------------------------------------
154 // ---------------------------------------------------------------------------
156 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxMDIChildFrameBase
159 wxMDIChildFrame() { Init(); }
160 wxMDIChildFrame(wxMDIParentFrame
*parent
,
162 const wxString
& title
,
163 const wxPoint
& pos
= wxDefaultPosition
,
164 const wxSize
& size
= wxDefaultSize
,
165 long style
= wxDEFAULT_FRAME_STYLE
,
166 const wxString
& name
= wxFrameNameStr
)
170 Create(parent
, id
, title
, pos
, size
, style
, name
);
173 bool Create(wxMDIParentFrame
*parent
,
175 const wxString
& title
,
176 const wxPoint
& pos
= wxDefaultPosition
,
177 const wxSize
& size
= wxDefaultSize
,
178 long style
= wxDEFAULT_FRAME_STYLE
,
179 const wxString
& name
= wxFrameNameStr
);
181 virtual ~wxMDIChildFrame();
183 // implement MDI operations
184 virtual void Activate();
186 // Override some frame operations too
187 virtual void Maximize(bool maximize
= true);
188 virtual void Restore();
190 virtual bool Show(bool show
= true);
192 // Implementation only from now on
193 // -------------------------------
196 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
197 bool HandleWindowPosChanging(void *lpPos
);
198 bool HandleGetMinMaxInfo(void *mmInfo
);
200 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
201 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
202 virtual bool MSWTranslateMessage(WXMSG
*msg
);
204 virtual void MSWDestroyWindow();
206 bool ResetWindowStyle(void *vrect
);
208 void OnIdle(wxIdleEvent
& event
);
211 virtual void DoGetScreenPosition(int *x
, int *y
) const;
212 virtual void DoGetPosition(int *x
, int *y
) const;
213 virtual void DoSetClientSize(int width
, int height
);
214 virtual void InternalSetMenuBar();
215 virtual bool IsMDIChild() const { return true; }
216 virtual void DetachMenuBar();
218 virtual WXHICON
GetDefaultIcon() const;
220 // common part of all ctors
224 bool m_needsInitialShow
; // Show must be called in idle time after Creation
225 bool m_needsResize
; // flag which tells us to artificially resize the frame
227 DECLARE_EVENT_TABLE()
228 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
231 // ---------------------------------------------------------------------------
233 // ---------------------------------------------------------------------------
235 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxMDIClientWindowBase
238 wxMDIClientWindow() { Init(); }
240 // Note: this is virtual, to allow overridden behaviour.
241 virtual bool CreateClient(wxMDIParentFrame
*parent
,
242 long style
= wxVSCROLL
| wxHSCROLL
);
244 // Explicitly call default scroll behaviour
245 void OnScroll(wxScrollEvent
& event
);
248 virtual void DoSetSize(int x
, int y
,
249 int width
, int height
,
250 int sizeFlags
= wxSIZE_AUTO
);
252 void Init() { m_scrollX
= m_scrollY
= 0; }
254 int m_scrollX
, m_scrollY
;
257 DECLARE_EVENT_TABLE()
258 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)
261 #endif // _WX_MSW_MDI_H_