1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI (Multiple Document Interface) classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "mdi.h"
21 WXDLLEXPORT_DATA(extern const wxChar
*) wxFrameNameStr
;
22 WXDLLEXPORT_DATA(extern 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
) ;
75 virtual void Cascade();
77 virtual void ArrangeIcons();
78 virtual void ActivateNext();
79 virtual void ActivatePrevious();
84 // Responds to colour changes
85 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
87 void OnSize(wxSizeEvent
& event
);
89 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
90 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
92 // override window proc for MDI-specific message processing
93 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
95 virtual long MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
96 virtual bool MSWTranslateMessage(WXMSG
* msg
);
99 #if wxUSE_MENUS_NATIVE
100 virtual void InternalSetMenuBar();
101 #endif // wxUSE_MENUS_NATIVE
103 virtual WXHICON
GetDefaultIcon() const;
105 wxMDIClientWindow
* m_clientWindow
;
106 wxMDIChildFrame
* m_currentChild
;
107 wxMenu
* m_windowMenu
;
109 // TRUE if MDI Frame is intercepting commands, not child
110 bool m_parentFrameActive
;
113 friend class WXDLLEXPORT wxMDIChildFrame
;
115 DECLARE_EVENT_TABLE()
116 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
117 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
120 // ---------------------------------------------------------------------------
122 // ---------------------------------------------------------------------------
124 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
127 wxMDIChildFrame() { Init(); }
128 wxMDIChildFrame(wxMDIParentFrame
*parent
,
130 const wxString
& title
,
131 const wxPoint
& pos
= wxDefaultPosition
,
132 const wxSize
& size
= wxDefaultSize
,
133 long style
= wxDEFAULT_FRAME_STYLE
,
134 const wxString
& name
= wxFrameNameStr
)
138 Create(parent
, id
, title
, pos
, size
, style
, name
);
143 bool Create(wxMDIParentFrame
*parent
,
145 const wxString
& title
,
146 const wxPoint
& pos
= wxDefaultPosition
,
147 const wxSize
& size
= wxDefaultSize
,
148 long style
= wxDEFAULT_FRAME_STYLE
,
149 const wxString
& name
= wxFrameNameStr
);
151 virtual bool IsTopLevel() const { return FALSE
; }
154 virtual void Maximize(bool maximize
= TRUE
);
155 virtual void Restore();
156 virtual void Activate();
158 // Implementation only from now on
159 // -------------------------------
162 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
163 bool HandleWindowPosChanging(void *lpPos
);
164 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
165 bool HandleGetMinMaxInfo(void *mmInfo
);
167 virtual long MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
168 virtual long MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
169 virtual bool MSWTranslateMessage(WXMSG
*msg
);
171 virtual void MSWDestroyWindow();
173 bool ResetWindowStyle(void *vrect
);
175 void OnIdle(wxIdleEvent
& event
);
178 virtual void DoGetPosition(int *x
, int *y
) const;
179 virtual void DoSetClientSize(int width
, int height
);
180 virtual void InternalSetMenuBar();
181 virtual bool IsMDIChild() const { return TRUE
; }
183 virtual WXHICON
GetDefaultIcon() const;
185 // common part of all ctors
189 bool m_needsResize
; // flag which tells us to artificially resize the frame
191 DECLARE_EVENT_TABLE()
192 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
195 // ---------------------------------------------------------------------------
197 // ---------------------------------------------------------------------------
199 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
202 wxMDIClientWindow() { Init(); }
203 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
207 CreateClient(parent
, style
);
210 // Note: this is virtual, to allow overridden behaviour.
211 virtual bool CreateClient(wxMDIParentFrame
*parent
,
212 long style
= wxVSCROLL
| wxHSCROLL
);
214 // Explicitly call default scroll behaviour
215 void OnScroll(wxScrollEvent
& event
);
217 virtual void DoSetSize(int x
, int y
,
218 int width
, int height
,
219 int sizeFlags
= wxSIZE_AUTO
);
221 void Init() { m_scrollX
= m_scrollY
= 0; }
223 int m_scrollX
, m_scrollY
;
226 DECLARE_EVENT_TABLE()
227 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)