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 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
) ;
72 virtual void DoMenuUpdates(wxMenu
* menu
= NULL
);
76 virtual void Cascade();
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
);
90 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
91 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
93 // override window proc for MDI-specific message processing
94 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
96 virtual WXLRESULT
MSWDefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
97 virtual bool MSWTranslateMessage(WXMSG
* msg
);
100 #if wxUSE_MENUS_NATIVE
101 virtual void InternalSetMenuBar();
102 #endif // wxUSE_MENUS_NATIVE
104 virtual WXHICON
GetDefaultIcon() const;
106 wxMDIClientWindow
* m_clientWindow
;
107 wxMDIChildFrame
* m_currentChild
;
108 wxMenu
* m_windowMenu
;
110 // true if MDI Frame is intercepting commands, not child
111 bool m_parentFrameActive
;
114 friend class WXDLLEXPORT wxMDIChildFrame
;
116 DECLARE_EVENT_TABLE()
117 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
118 DECLARE_NO_COPY_CLASS(wxMDIParentFrame
)
121 // ---------------------------------------------------------------------------
123 // ---------------------------------------------------------------------------
125 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
128 wxMDIChildFrame() { Init(); }
129 wxMDIChildFrame(wxMDIParentFrame
*parent
,
131 const wxString
& title
,
132 const wxPoint
& pos
= wxDefaultPosition
,
133 const wxSize
& size
= wxDefaultSize
,
134 long style
= wxDEFAULT_FRAME_STYLE
,
135 const wxString
& name
= wxFrameNameStr
)
139 Create(parent
, id
, title
, pos
, size
, style
, name
);
144 bool Create(wxMDIParentFrame
*parent
,
146 const wxString
& title
,
147 const wxPoint
& pos
= wxDefaultPosition
,
148 const wxSize
& size
= wxDefaultSize
,
149 long style
= wxDEFAULT_FRAME_STYLE
,
150 const wxString
& name
= wxFrameNameStr
);
152 virtual bool IsTopLevel() const { return false; }
155 virtual void Maximize(bool maximize
= true);
156 virtual void Restore();
157 virtual void Activate();
159 // Implementation only from now on
160 // -------------------------------
163 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
164 bool HandleWindowPosChanging(void *lpPos
);
165 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
166 bool HandleGetMinMaxInfo(void *mmInfo
);
168 virtual WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
169 virtual WXLRESULT
MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
170 virtual bool MSWTranslateMessage(WXMSG
*msg
);
172 virtual void MSWDestroyWindow();
174 bool ResetWindowStyle(void *vrect
);
176 void OnIdle(wxIdleEvent
& event
);
179 virtual void DoGetPosition(int *x
, int *y
) const;
180 virtual void DoSetClientSize(int width
, int height
);
181 virtual void InternalSetMenuBar();
182 virtual bool IsMDIChild() const { return true; }
184 virtual WXHICON
GetDefaultIcon() const;
186 // common part of all ctors
190 bool m_needsResize
; // flag which tells us to artificially resize the frame
192 DECLARE_EVENT_TABLE()
193 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame
)
196 // ---------------------------------------------------------------------------
198 // ---------------------------------------------------------------------------
200 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
203 wxMDIClientWindow() { Init(); }
204 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
208 CreateClient(parent
, style
);
211 // Note: this is virtual, to allow overridden behaviour.
212 virtual bool CreateClient(wxMDIParentFrame
*parent
,
213 long style
= wxVSCROLL
| wxHSCROLL
);
215 // Explicitly call default scroll behaviour
216 void OnScroll(wxScrollEvent
& event
);
218 virtual void DoSetSize(int x
, int y
,
219 int width
, int height
,
220 int sizeFlags
= wxSIZE_AUTO
);
222 void Init() { m_scrollX
= m_scrollY
= 0; }
224 int m_scrollX
, m_scrollY
;
227 DECLARE_EVENT_TABLE()
228 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow
)