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
);
68 // implementation only from now on
73 // called by wxMDIChildFrame after it was successfully created
74 virtual void AddMDIChild(wxMDIChildFrame
*child
);
76 // called by wxMDIChildFrame just before it is destroyed
77 virtual void RemoveMDIChild(wxMDIChildFrame
*child
);
82 // Responds to colour changes
83 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
85 void OnSize(wxSizeEvent
& event
);
86 void OnIconized(wxIconizeEvent
& event
);
88 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
89 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
91 // override window proc for MDI-specific message processing
92 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
94 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
95 virtual bool MSWTranslateMessage(WXMSG
* msg
);
97 // override wxFrameBase function to also look in the active child menu bar
98 virtual const wxMenuItem
*FindItemInMenuBar(int menuId
) const;
101 #if wxUSE_MENUS_NATIVE
102 virtual void InternalSetMenuBar();
103 #endif // wxUSE_MENUS_NATIVE
105 virtual WXHICON
GetDefaultIcon() const;
107 // set the size of the MDI client window to match the frame size
108 void UpdateClientSize();
111 // true if MDI Frame is intercepting commands, not child
112 bool m_parentFrameActive
;
115 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
116 void AddWindowMenu();
117 void RemoveWindowMenu();
119 // return the number of child frames we currently have (maybe 0)
120 int GetChildFramesCount() const;
122 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
124 DECLARE_EVENT_TABLE()
125 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
126 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
129 // ---------------------------------------------------------------------------
131 // ---------------------------------------------------------------------------
133 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxMDIChildFrameBase
136 wxMDIChildFrame() { Init(); }
137 wxMDIChildFrame(wxMDIParentFrame
*parent
,
139 const wxString
& title
,
140 const wxPoint
& pos
= wxDefaultPosition
,
141 const wxSize
& size
= wxDefaultSize
,
142 long style
= wxDEFAULT_FRAME_STYLE
,
143 const wxString
& name
= wxFrameNameStr
)
147 Create(parent
, id
, title
, pos
, size
, style
, name
);
150 bool Create(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
);
158 virtual ~wxMDIChildFrame();
160 // implement MDI operations
161 virtual void Activate();
163 // Override some frame operations too
164 virtual void Maximize(bool maximize
= true);
165 virtual void Restore();
167 virtual bool Show(bool show
= true);
169 // Implementation only from now on
170 // -------------------------------
173 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
174 bool HandleWindowPosChanging(void *lpPos
);
175 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
176 bool HandleGetMinMaxInfo(void *mmInfo
);
178 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
179 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
180 virtual bool MSWTranslateMessage(WXMSG
*msg
);
182 virtual void MSWDestroyWindow();
184 bool ResetWindowStyle(void *vrect
);
186 void OnIdle(wxIdleEvent
& event
);
189 virtual void DoGetScreenPosition(int *x
, int *y
) const;
190 virtual void DoGetPosition(int *x
, int *y
) const;
191 virtual void DoSetClientSize(int width
, int height
);
192 virtual void InternalSetMenuBar();
193 virtual bool IsMDIChild() const { return true; }
194 virtual void DetachMenuBar();
196 virtual WXHICON
GetDefaultIcon() const;
198 // common part of all ctors
202 bool m_needsInitialShow
; // Show must be called in idle time after Creation
203 bool m_needsResize
; // flag which tells us to artificially resize the frame
205 DECLARE_EVENT_TABLE()
206 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
209 // ---------------------------------------------------------------------------
211 // ---------------------------------------------------------------------------
213 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxMDIClientWindowBase
216 wxMDIClientWindow() { Init(); }
218 // Note: this is virtual, to allow overridden behaviour.
219 virtual bool CreateClient(wxMDIParentFrame
*parent
,
220 long style
= wxVSCROLL
| wxHSCROLL
);
222 // Explicitly call default scroll behaviour
223 void OnScroll(wxScrollEvent
& event
);
226 virtual void DoSetSize(int x
, int y
,
227 int width
, int height
,
228 int sizeFlags
= wxSIZE_AUTO
);
230 void Init() { m_scrollX
= m_scrollY
= 0; }
232 int m_scrollX
, m_scrollY
;
235 DECLARE_EVENT_TABLE()
236 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)
239 #endif // _WX_MSW_MDI_H_