1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI (Multiple Document Interface) classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusLineNameStr
[];
19 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow
;
20 class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
22 // ---------------------------------------------------------------------------
24 // ---------------------------------------------------------------------------
26 class WXDLLIMPEXP_CORE wxMDIParentFrame
: public wxFrame
30 wxMDIParentFrame(wxWindow
*parent
,
32 const wxString
& title
,
33 const wxPoint
& pos
= wxDefaultPosition
,
34 const wxSize
& size
= wxDefaultSize
,
35 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
36 const wxString
& name
= wxFrameNameStr
)
38 Create(parent
, id
, title
, pos
, size
, style
, name
);
41 virtual ~wxMDIParentFrame();
43 bool Create(wxWindow
*parent
,
45 const wxString
& title
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
48 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
49 const wxString
& name
= wxFrameNameStr
);
54 // Get the active MDI child window
55 wxMDIChildFrame
*GetActiveChild() const;
57 // Get the client window
58 wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; }
60 // Create the client window class (don't Create the window,
61 // just return a new class)
62 virtual wxMDIClientWindow
*OnCreateClient();
64 // MDI windows menu functions
65 // --------------------------
67 // return the pointer to the current window menu or NULL if we don't have
68 // because of wxFRAME_NO_WINDOW_MENU style
69 wxMenu
*GetWindowMenu() const { return m_windowMenu
; }
71 // use the given menu instead of the default window menu
73 // menu can be NULL to disable the window menu completely
74 void SetWindowMenu(wxMenu
* menu
) ;
76 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
80 virtual void Cascade();
81 virtual void Tile(wxOrientation orient
= wxHORIZONTAL
);
82 virtual void ArrangeIcons();
83 virtual void ActivateNext();
84 virtual void ActivatePrevious();
87 // implementation only from now on
92 // called by wxMDIChildFrame after it was successfully created
93 virtual void AddMDIChild(wxMDIChildFrame
*child
);
95 // called by wxMDIChildFrame just before it is destroyed
96 virtual void RemoveMDIChild(wxMDIChildFrame
*child
);
101 // Responds to colour changes
102 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
104 void OnSize(wxSizeEvent
& event
);
105 void OnIconized(wxIconizeEvent
& event
);
107 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
108 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
110 // override window proc for MDI-specific message processing
111 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
113 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
114 virtual bool MSWTranslateMessage(WXMSG
* msg
);
116 // override wxFrameBase function to also look in the active child menu bar
117 virtual const wxMenuItem
*FindItemInMenuBar(int menuId
) const;
120 #if wxUSE_MENUS_NATIVE
121 virtual void InternalSetMenuBar();
122 #endif // wxUSE_MENUS_NATIVE
124 virtual WXHICON
GetDefaultIcon() const;
126 // set the size of the MDI client window to match the frame size
127 void UpdateClientSize();
130 wxMDIClientWindow
* m_clientWindow
;
131 wxMDIChildFrame
* m_currentChild
;
133 // the current window menu or NULL if we are not using it
134 wxMenu
*m_windowMenu
;
136 // true if MDI Frame is intercepting commands, not child
137 bool m_parentFrameActive
;
140 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
141 void AddWindowMenu();
142 void RemoveWindowMenu();
144 // return the number of child frames we currently have (maybe 0)
145 int GetChildFramesCount() const;
147 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
149 DECLARE_EVENT_TABLE()
150 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
151 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
154 // ---------------------------------------------------------------------------
156 // ---------------------------------------------------------------------------
158 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxFrame
161 wxMDIChildFrame() { Init(); }
162 wxMDIChildFrame(wxMDIParentFrame
*parent
,
164 const wxString
& title
,
165 const wxPoint
& pos
= wxDefaultPosition
,
166 const wxSize
& size
= wxDefaultSize
,
167 long style
= wxDEFAULT_FRAME_STYLE
,
168 const wxString
& name
= wxFrameNameStr
)
172 Create(parent
, id
, title
, pos
, size
, style
, name
);
175 virtual ~wxMDIChildFrame();
177 bool Create(wxMDIParentFrame
*parent
,
179 const wxString
& title
,
180 const wxPoint
& pos
= wxDefaultPosition
,
181 const wxSize
& size
= wxDefaultSize
,
182 long style
= wxDEFAULT_FRAME_STYLE
,
183 const wxString
& name
= wxFrameNameStr
);
185 virtual bool IsTopLevel() const { return false; }
188 virtual void Maximize(bool maximize
= true);
189 virtual void Restore();
190 virtual void Activate();
192 // Implementation only from now on
193 // -------------------------------
195 wxMDIParentFrame
* GetMDIParent() const
197 return wxStaticCast(wxFrame::GetParent(), wxMDIParentFrame
);
201 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
202 bool HandleWindowPosChanging(void *lpPos
);
203 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
204 bool HandleGetMinMaxInfo(void *mmInfo
);
206 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
207 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
208 virtual bool MSWTranslateMessage(WXMSG
*msg
);
210 virtual void MSWDestroyWindow();
212 bool ResetWindowStyle(void *vrect
);
214 void OnIdle(wxIdleEvent
& event
);
216 virtual bool Show(bool show
= true);
219 virtual void DoGetScreenPosition(int *x
, int *y
) const;
220 virtual void DoGetPosition(int *x
, int *y
) const;
221 virtual void DoSetClientSize(int width
, int height
);
222 virtual void InternalSetMenuBar();
223 virtual bool IsMDIChild() const { return true; }
224 virtual void DetachMenuBar();
226 virtual WXHICON
GetDefaultIcon() const;
228 // common part of all ctors
232 bool m_needsInitialShow
; // Show must be called in idle time after Creation
233 bool m_needsResize
; // flag which tells us to artificially resize the frame
235 DECLARE_EVENT_TABLE()
236 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
239 // ---------------------------------------------------------------------------
241 // ---------------------------------------------------------------------------
243 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxWindow
246 wxMDIClientWindow() { Init(); }
247 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
251 CreateClient(parent
, style
);
254 // Note: this is virtual, to allow overridden behaviour.
255 virtual bool CreateClient(wxMDIParentFrame
*parent
,
256 long style
= wxVSCROLL
| wxHSCROLL
);
258 // Explicitly call default scroll behaviour
259 void OnScroll(wxScrollEvent
& event
);
262 virtual void DoSetSize(int x
, int y
,
263 int width
, int height
,
264 int sizeFlags
= wxSIZE_AUTO
);
266 void Init() { m_scrollX
= m_scrollY
= 0; }
268 int m_scrollX
, m_scrollY
;
271 DECLARE_EVENT_TABLE()
272 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)