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
7 // Copyright: (c) 1997 Julian Smart
8 // (c) 2008 Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_MDI_H_
13 #define _WX_MSW_MDI_H_
17 class WXDLLIMPEXP_FWD_CORE wxAcceleratorTable
;
19 // ---------------------------------------------------------------------------
21 // ---------------------------------------------------------------------------
23 class WXDLLIMPEXP_CORE wxMDIParentFrame
: public wxMDIParentFrameBase
26 wxMDIParentFrame() { Init(); }
27 wxMDIParentFrame(wxWindow
*parent
,
29 const wxString
& title
,
30 const wxPoint
& pos
= wxDefaultPosition
,
31 const wxSize
& size
= wxDefaultSize
,
32 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
33 const wxString
& name
= wxFrameNameStr
)
37 Create(parent
, id
, title
, pos
, size
, style
, name
);
40 virtual ~wxMDIParentFrame();
42 bool Create(wxWindow
*parent
,
44 const wxString
& title
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
,
47 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
48 const wxString
& name
= wxFrameNameStr
);
50 // override/implement base class [pure] virtual methods
51 // ----------------------------------------------------
53 static bool IsTDI() { return false; }
55 // we don't store the active child in m_currentChild so override this
56 // function to find it dynamically
57 virtual wxMDIChildFrame
*GetActiveChild() const;
59 virtual void Cascade();
60 virtual void Tile(wxOrientation orient
= wxHORIZONTAL
);
61 virtual void ArrangeIcons();
62 virtual void ActivateNext();
63 virtual void ActivatePrevious();
66 virtual void SetWindowMenu(wxMenu
* menu
);
68 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
70 // return the active child menu, if any
71 virtual WXHMENU
MSWGetActiveMenu() const;
75 // implementation only from now on
81 // called by wxMDIChildFrame after it was successfully created
82 virtual void AddMDIChild(wxMDIChildFrame
*child
);
84 // called by wxMDIChildFrame just before it is destroyed
85 virtual void RemoveMDIChild(wxMDIChildFrame
*child
);
91 // Responds to colour changes
92 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
94 void OnSize(wxSizeEvent
& event
);
95 void OnIconized(wxIconizeEvent
& event
);
97 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
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();
122 // common part of all ctors
126 // "Window" menu commands event handlers
127 void OnMDICommand(wxCommandEvent
& event
);
128 void OnMDIChild(wxCommandEvent
& event
);
131 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
132 void AddWindowMenu();
133 void RemoveWindowMenu();
135 // update the window menu (if we have it) to enable or disable the commands
136 // which only make sense when we have more than one child
137 void UpdateWindowMenu(bool enable
);
140 wxAcceleratorTable
*m_accelWindowMenu
;
141 #endif // wxUSE_ACCEL
142 #endif // wxUSE_MENUS
144 // return the number of child frames we currently have (maybe 0)
145 int GetChildFramesCount() const;
148 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
150 DECLARE_EVENT_TABLE()
151 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
152 wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame
);
155 // ---------------------------------------------------------------------------
157 // ---------------------------------------------------------------------------
159 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxMDIChildFrameBase
162 wxMDIChildFrame() { Init(); }
163 wxMDIChildFrame(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
)
173 Create(parent
, id
, title
, pos
, size
, style
, name
);
176 bool Create(wxMDIParentFrame
*parent
,
178 const wxString
& title
,
179 const wxPoint
& pos
= wxDefaultPosition
,
180 const wxSize
& size
= wxDefaultSize
,
181 long style
= wxDEFAULT_FRAME_STYLE
,
182 const wxString
& name
= wxFrameNameStr
);
184 virtual ~wxMDIChildFrame();
186 // implement MDI operations
187 virtual void Activate();
189 // Override some frame operations too
190 virtual void Maximize(bool maximize
= true);
191 virtual void Restore();
193 virtual bool Show(bool show
= true);
195 // Implementation only from now on
196 // -------------------------------
199 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
200 bool HandleWindowPosChanging(void *lpPos
);
201 bool HandleGetMinMaxInfo(void *mmInfo
);
203 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
204 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
205 virtual bool MSWTranslateMessage(WXMSG
*msg
);
207 virtual void MSWDestroyWindow();
209 bool ResetWindowStyle(void *vrect
);
211 void OnIdle(wxIdleEvent
& event
);
214 virtual void DoGetScreenPosition(int *x
, int *y
) const;
215 virtual void DoGetPosition(int *x
, int *y
) const;
216 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
);
217 virtual void DoSetClientSize(int width
, int height
);
218 virtual void InternalSetMenuBar();
219 virtual bool IsMDIChild() const { return true; }
220 virtual void DetachMenuBar();
222 virtual WXHICON
GetDefaultIcon() const;
224 // common part of all ctors
228 bool m_needsInitialShow
; // Show must be called in idle time after Creation
229 bool m_needsResize
; // flag which tells us to artificially resize the frame
231 DECLARE_EVENT_TABLE()
232 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
235 // ---------------------------------------------------------------------------
237 // ---------------------------------------------------------------------------
239 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxMDIClientWindowBase
242 wxMDIClientWindow() { Init(); }
244 // Note: this is virtual, to allow overridden behaviour.
245 virtual bool CreateClient(wxMDIParentFrame
*parent
,
246 long style
= wxVSCROLL
| wxHSCROLL
);
248 // Explicitly call default scroll behaviour
249 void OnScroll(wxScrollEvent
& event
);
252 virtual void DoSetSize(int x
, int y
,
253 int width
, int height
,
254 int sizeFlags
= wxSIZE_AUTO
);
256 void Init() { m_scrollX
= m_scrollY
= 0; }
258 int m_scrollX
, m_scrollY
;
261 DECLARE_EVENT_TABLE()
262 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)
265 #endif // _WX_MSW_MDI_H_