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 char) 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 // -------------------------------
165 wxMDIParentFrame
* GetMDIParent() const
167 return wxStaticCast(wxFrame::GetParent(), wxMDIParentFrame
);
171 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
172 bool HandleWindowPosChanging(void *lpPos
);
173 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
174 bool HandleGetMinMaxInfo(void *mmInfo
);
176 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
177 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
178 virtual bool MSWTranslateMessage(WXMSG
*msg
);
180 virtual void MSWDestroyWindow();
182 bool ResetWindowStyle(void *vrect
);
184 void OnIdle(wxIdleEvent
& event
);
186 virtual bool Show(bool show
= true);
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 WXDLLEXPORT wxMDIClientWindow
: public wxWindow
216 wxMDIClientWindow() { Init(); }
217 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
221 CreateClient(parent
, style
);
224 // Note: this is virtual, to allow overridden behaviour.
225 virtual bool CreateClient(wxMDIParentFrame
*parent
,
226 long style
= wxVSCROLL
| wxHSCROLL
);
228 // Explicitly call default scroll behaviour
229 void OnScroll(wxScrollEvent
& event
);
232 virtual void DoSetSize(int x
, int y
,
233 int width
, int height
,
234 int sizeFlags
= wxSIZE_AUTO
);
236 void Init() { m_scrollX
= m_scrollY
= 0; }
238 int m_scrollX
, m_scrollY
;
241 DECLARE_EVENT_TABLE()
242 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)