1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI (Multiple Document Interface) classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 extern WXDLLEXPORT_DATA(const wxChar
) wxStatusLineNameStr
[];
19 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow
;
20 class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
22 // ---------------------------------------------------------------------------
24 // ---------------------------------------------------------------------------
26 class WXDLLEXPORT 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 (Windows only)
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(void);
65 wxMenu
* GetWindowMenu() const { return m_windowMenu
; }
66 void SetWindowMenu(wxMenu
* menu
) ;
67 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
71 virtual void Cascade();
72 virtual void Tile(wxOrientation orient
= wxHORIZONTAL
);
73 virtual void ArrangeIcons();
74 virtual void ActivateNext();
75 virtual void ActivatePrevious();
80 // Responds to colour changes
81 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
83 void OnSize(wxSizeEvent
& event
);
84 void OnIconized(wxIconizeEvent
& event
);
86 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
87 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
89 // override window proc for MDI-specific message processing
90 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
92 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
93 virtual bool MSWTranslateMessage(WXMSG
* msg
);
95 // override wxFrameBase function to also look in the active child menu bar
96 virtual const wxMenuItem
*FindItemInMenuBar(int menuId
) const;
99 #if wxUSE_MENUS_NATIVE
100 virtual void InternalSetMenuBar();
101 #endif // wxUSE_MENUS_NATIVE
103 virtual WXHICON
GetDefaultIcon() const;
105 // set the size of the MDI client window to match the frame size
106 void UpdateClientSize();
109 wxMDIClientWindow
* m_clientWindow
;
110 wxMDIChildFrame
* m_currentChild
;
111 wxMenu
* m_windowMenu
;
113 // true if MDI Frame is intercepting commands, not child
114 bool m_parentFrameActive
;
117 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
119 DECLARE_EVENT_TABLE()
120 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
121 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
124 // ---------------------------------------------------------------------------
126 // ---------------------------------------------------------------------------
128 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
131 wxMDIChildFrame() { Init(); }
132 wxMDIChildFrame(wxMDIParentFrame
*parent
,
134 const wxString
& title
,
135 const wxPoint
& pos
= wxDefaultPosition
,
136 const wxSize
& size
= wxDefaultSize
,
137 long style
= wxDEFAULT_FRAME_STYLE
,
138 const wxString
& name
= wxFrameNameStr
)
142 Create(parent
, id
, title
, pos
, size
, style
, name
);
145 virtual ~wxMDIChildFrame();
147 bool Create(wxMDIParentFrame
*parent
,
149 const wxString
& title
,
150 const wxPoint
& pos
= wxDefaultPosition
,
151 const wxSize
& size
= wxDefaultSize
,
152 long style
= wxDEFAULT_FRAME_STYLE
,
153 const wxString
& name
= wxFrameNameStr
);
155 virtual bool IsTopLevel() const { return false; }
158 virtual void Maximize(bool maximize
= true);
159 virtual void Restore();
160 virtual void Activate();
162 // Implementation only from now on
163 // -------------------------------
166 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
167 bool HandleWindowPosChanging(void *lpPos
);
168 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
169 bool HandleGetMinMaxInfo(void *mmInfo
);
171 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
172 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
173 virtual bool MSWTranslateMessage(WXMSG
*msg
);
175 virtual void MSWDestroyWindow();
177 bool ResetWindowStyle(void *vrect
);
179 void OnIdle(wxIdleEvent
& event
);
181 virtual bool Show(bool show
= true);
184 virtual void DoGetScreenPosition(int *x
, int *y
) const;
185 virtual void DoGetPosition(int *x
, int *y
) const;
186 virtual void DoSetClientSize(int width
, int height
);
187 virtual void InternalSetMenuBar();
188 virtual bool IsMDIChild() const { return true; }
189 virtual void DetachMenuBar();
191 virtual WXHICON
GetDefaultIcon() const;
193 // common part of all ctors
197 bool m_needsInitialShow
; // Show must be called in idle time after Creation
198 bool m_needsResize
; // flag which tells us to artificially resize the frame
200 DECLARE_EVENT_TABLE()
201 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
204 // ---------------------------------------------------------------------------
206 // ---------------------------------------------------------------------------
208 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
211 wxMDIClientWindow() { Init(); }
212 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
216 CreateClient(parent
, style
);
219 // Note: this is virtual, to allow overridden behaviour.
220 virtual bool CreateClient(wxMDIParentFrame
*parent
,
221 long style
= wxVSCROLL
| wxHSCROLL
);
223 // Explicitly call default scroll behaviour
224 void OnScroll(wxScrollEvent
& event
);
227 virtual void DoSetSize(int x
, int y
,
228 int width
, int height
,
229 int sizeFlags
= wxSIZE_AUTO
);
231 void Init() { m_scrollX
= m_scrollY
= 0; }
233 int m_scrollX
, m_scrollY
;
236 DECLARE_EVENT_TABLE()
237 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)