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
*) wxFrameNameStr
;
18 extern WXDLLEXPORT_DATA(const wxChar
*) wxStatusLineNameStr
;
20 class WXDLLEXPORT wxMDIClientWindow
;
21 class WXDLLEXPORT wxMDIChildFrame
;
23 // ---------------------------------------------------------------------------
25 // ---------------------------------------------------------------------------
27 class WXDLLEXPORT wxMDIParentFrame
: public wxFrame
31 wxMDIParentFrame(wxWindow
*parent
,
33 const wxString
& title
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
,
36 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
37 const wxString
& name
= wxFrameNameStr
)
39 Create(parent
, id
, title
, pos
, size
, style
, name
);
44 bool Create(wxWindow
*parent
,
46 const wxString
& title
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
49 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
50 const wxString
& name
= wxFrameNameStr
);
55 // Get the active MDI child window (Windows only)
56 wxMDIChildFrame
*GetActiveChild() const;
58 // Get the client window
59 wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; }
61 // Create the client window class (don't Create the window,
62 // just return a new class)
63 virtual wxMDIClientWindow
*OnCreateClient(void);
66 wxMenu
* GetWindowMenu() const { return m_windowMenu
; };
67 void SetWindowMenu(wxMenu
* menu
) ;
68 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
72 virtual void Cascade();
73 virtual void Tile(wxOrientation orient
= wxHORIZONTAL
);
74 virtual void ArrangeIcons();
75 virtual void ActivateNext();
76 virtual void ActivatePrevious();
81 // Responds to colour changes
82 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
84 void OnSize(wxSizeEvent
& event
);
85 void OnIconized(wxIconizeEvent
& event
);
87 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
88 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
90 // override window proc for MDI-specific message processing
91 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
93 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
94 virtual bool MSWTranslateMessage(WXMSG
* msg
);
97 #if wxUSE_MENUS_NATIVE
98 virtual void InternalSetMenuBar();
99 #endif // wxUSE_MENUS_NATIVE
101 virtual WXHICON
GetDefaultIcon() const;
103 // set the size of the MDI client window to match the frame size
104 void UpdateClientSize();
107 wxMDIClientWindow
* m_clientWindow
;
108 wxMDIChildFrame
* m_currentChild
;
109 wxMenu
* m_windowMenu
;
111 // true if MDI Frame is intercepting commands, not child
112 bool m_parentFrameActive
;
115 friend class WXDLLEXPORT wxMDIChildFrame
;
117 DECLARE_EVENT_TABLE()
118 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
119 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
122 // ---------------------------------------------------------------------------
124 // ---------------------------------------------------------------------------
126 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
129 wxMDIChildFrame() { Init(); }
130 wxMDIChildFrame(wxMDIParentFrame
*parent
,
132 const wxString
& title
,
133 const wxPoint
& pos
= wxDefaultPosition
,
134 const wxSize
& size
= wxDefaultSize
,
135 long style
= wxDEFAULT_FRAME_STYLE
,
136 const wxString
& name
= wxFrameNameStr
)
140 Create(parent
, id
, title
, pos
, size
, style
, name
);
145 bool Create(wxMDIParentFrame
*parent
,
147 const wxString
& title
,
148 const wxPoint
& pos
= wxDefaultPosition
,
149 const wxSize
& size
= wxDefaultSize
,
150 long style
= wxDEFAULT_FRAME_STYLE
,
151 const wxString
& name
= wxFrameNameStr
);
153 virtual bool IsTopLevel() const { return false; }
156 virtual void Maximize(bool maximize
= true);
157 virtual void Restore();
158 virtual void Activate();
160 // Implementation only from now on
161 // -------------------------------
164 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
165 bool HandleWindowPosChanging(void *lpPos
);
166 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
167 bool HandleGetMinMaxInfo(void *mmInfo
);
169 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
170 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
171 virtual bool MSWTranslateMessage(WXMSG
*msg
);
173 virtual void MSWDestroyWindow();
175 bool ResetWindowStyle(void *vrect
);
177 void OnIdle(wxIdleEvent
& event
);
179 virtual bool Show(bool show
= true);
182 virtual void DoGetPosition(int *x
, int *y
) const;
183 virtual void DoSetClientSize(int width
, int height
);
184 virtual void InternalSetMenuBar();
185 virtual bool IsMDIChild() const { return true; }
187 virtual WXHICON
GetDefaultIcon() const;
189 // common part of all ctors
193 bool m_needsInitialShow
; // Show must be called in idle time after Creation
194 bool m_needsResize
; // flag which tells us to artificially resize the frame
195 virtual void DetachMenuBar() ;
197 DECLARE_EVENT_TABLE()
198 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
201 // ---------------------------------------------------------------------------
203 // ---------------------------------------------------------------------------
205 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
208 wxMDIClientWindow() { Init(); }
209 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
213 CreateClient(parent
, style
);
216 // Note: this is virtual, to allow overridden behaviour.
217 virtual bool CreateClient(wxMDIParentFrame
*parent
,
218 long style
= wxVSCROLL
| wxHSCROLL
);
220 // Explicitly call default scroll behaviour
221 void OnScroll(wxScrollEvent
& event
);
223 virtual void DoSetSize(int x
, int y
,
224 int width
, int height
,
225 int sizeFlags
= wxSIZE_AUTO
);
227 void Init() { m_scrollX
= m_scrollY
= 0; }
229 int m_scrollX
, m_scrollY
;
232 DECLARE_EVENT_TABLE()
233 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)