1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI (Multiple Document Interface) classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "mdi.h"
21 extern WXDLLEXPORT_DATA(const wxChar
*) wxFrameNameStr
;
22 extern WXDLLEXPORT_DATA(const wxChar
*) wxStatusLineNameStr
;
24 class WXDLLEXPORT wxMDIClientWindow
;
25 class WXDLLEXPORT wxMDIChildFrame
;
27 // ---------------------------------------------------------------------------
29 // ---------------------------------------------------------------------------
31 class WXDLLEXPORT wxMDIParentFrame
: public wxFrame
35 wxMDIParentFrame(wxWindow
*parent
,
37 const wxString
& title
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
40 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
41 const wxString
& name
= wxFrameNameStr
)
43 Create(parent
, id
, title
, pos
, size
, style
, name
);
48 bool Create(wxWindow
*parent
,
50 const wxString
& title
,
51 const wxPoint
& pos
= wxDefaultPosition
,
52 const wxSize
& size
= wxDefaultSize
,
53 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
54 const wxString
& name
= wxFrameNameStr
);
59 // Get the active MDI child window (Windows only)
60 wxMDIChildFrame
*GetActiveChild() const;
62 // Get the client window
63 wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; }
65 // Create the client window class (don't Create the window,
66 // just return a new class)
67 virtual wxMDIClientWindow
*OnCreateClient(void);
70 wxMenu
* GetWindowMenu() const { return m_windowMenu
; };
71 void SetWindowMenu(wxMenu
* menu
) ;
72 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
76 virtual void Cascade();
77 virtual void Tile(wxOrientation orient
= wxHORIZONTAL
);
78 virtual void ArrangeIcons();
79 virtual void ActivateNext();
80 virtual void ActivatePrevious();
85 // Responds to colour changes
86 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
88 void OnSize(wxSizeEvent
& event
);
89 void OnIconized(wxIconizeEvent
& event
);
91 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
92 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
94 // override window proc for MDI-specific message processing
95 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
97 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
98 virtual bool MSWTranslateMessage(WXMSG
* msg
);
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 wxMDIClientWindow
* m_clientWindow
;
112 wxMDIChildFrame
* m_currentChild
;
113 wxMenu
* m_windowMenu
;
115 // true if MDI Frame is intercepting commands, not child
116 bool m_parentFrameActive
;
119 friend class WXDLLEXPORT wxMDIChildFrame
;
121 DECLARE_EVENT_TABLE()
122 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
123 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
126 // ---------------------------------------------------------------------------
128 // ---------------------------------------------------------------------------
130 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
133 wxMDIChildFrame() { Init(); }
134 wxMDIChildFrame(wxMDIParentFrame
*parent
,
136 const wxString
& title
,
137 const wxPoint
& pos
= wxDefaultPosition
,
138 const wxSize
& size
= wxDefaultSize
,
139 long style
= wxDEFAULT_FRAME_STYLE
,
140 const wxString
& name
= wxFrameNameStr
)
144 Create(parent
, id
, title
, pos
, size
, style
, name
);
149 bool Create(wxMDIParentFrame
*parent
,
151 const wxString
& title
,
152 const wxPoint
& pos
= wxDefaultPosition
,
153 const wxSize
& size
= wxDefaultSize
,
154 long style
= wxDEFAULT_FRAME_STYLE
,
155 const wxString
& name
= wxFrameNameStr
);
157 virtual bool IsTopLevel() const { return false; }
160 virtual void Maximize(bool maximize
= true);
161 virtual void Restore();
162 virtual void Activate();
164 // Implementation only from now on
165 // -------------------------------
168 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
169 bool HandleWindowPosChanging(void *lpPos
);
170 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
171 bool HandleGetMinMaxInfo(void *mmInfo
);
173 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
174 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
175 virtual bool MSWTranslateMessage(WXMSG
*msg
);
177 virtual void MSWDestroyWindow();
179 bool ResetWindowStyle(void *vrect
);
181 void OnIdle(wxIdleEvent
& event
);
183 virtual bool Show(bool show
= true);
186 virtual void DoGetPosition(int *x
, int *y
) const;
187 virtual void DoSetClientSize(int width
, int height
);
188 virtual void InternalSetMenuBar();
189 virtual bool IsMDIChild() const { return true; }
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
199 virtual void DetachMenuBar() ;
201 DECLARE_EVENT_TABLE()
202 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
205 // ---------------------------------------------------------------------------
207 // ---------------------------------------------------------------------------
209 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
212 wxMDIClientWindow() { Init(); }
213 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
217 CreateClient(parent
, style
);
220 // Note: this is virtual, to allow overridden behaviour.
221 virtual bool CreateClient(wxMDIParentFrame
*parent
,
222 long style
= wxVSCROLL
| wxHSCROLL
);
224 // Explicitly call default scroll behaviour
225 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
)