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);
69 // WXHMENU GetWindowHMENU() const { return m_windowMenu; }
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
)
119 // ---------------------------------------------------------------------------
121 // ---------------------------------------------------------------------------
123 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
126 wxMDIChildFrame() { Init(); }
127 wxMDIChildFrame(wxMDIParentFrame
*parent
,
129 const wxString
& title
,
130 const wxPoint
& pos
= wxDefaultPosition
,
131 const wxSize
& size
= wxDefaultSize
,
132 long style
= wxDEFAULT_FRAME_STYLE
,
133 const wxString
& name
= wxFrameNameStr
)
137 Create(parent
, id
, title
, pos
, size
, style
, name
);
142 bool Create(wxMDIParentFrame
*parent
,
144 const wxString
& title
,
145 const wxPoint
& pos
= wxDefaultPosition
,
146 const wxSize
& size
= wxDefaultSize
,
147 long style
= wxDEFAULT_FRAME_STYLE
,
148 const wxString
& name
= wxFrameNameStr
);
150 virtual bool IsTopLevel() const { return FALSE
; }
153 virtual void Maximize(bool maximize
= TRUE
);
154 virtual void Restore();
155 virtual void Activate();
157 // Implementation only from now on
158 // -------------------------------
161 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
162 bool HandleWindowPosChanging(void *lpPos
);
163 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
164 bool HandleGetMinMaxInfo(void *mmInfo
);
166 virtual long MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
167 virtual long MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
168 virtual bool MSWTranslateMessage(WXMSG
*msg
);
170 virtual void MSWDestroyWindow();
172 bool ResetWindowStyle(void *vrect
);
174 void OnIdle(wxIdleEvent
& event
);
177 virtual void DoGetPosition(int *x
, int *y
) const;
178 virtual void DoSetClientSize(int width
, int height
);
179 virtual void InternalSetMenuBar();
180 virtual bool IsMDIChild() const { return TRUE
; }
182 virtual WXHICON
GetDefaultIcon() const;
184 // common part of all ctors
188 bool m_needsResize
; // flag which tells us to artificially resize the frame
190 DECLARE_EVENT_TABLE()
191 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
194 // ---------------------------------------------------------------------------
196 // ---------------------------------------------------------------------------
198 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
201 wxMDIClientWindow() { Init(); }
202 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
206 CreateClient(parent
, style
);
209 // Note: this is virtual, to allow overridden behaviour.
210 virtual bool CreateClient(wxMDIParentFrame
*parent
,
211 long style
= wxVSCROLL
| wxHSCROLL
);
213 // Explicitly call default scroll behaviour
214 void OnScroll(wxScrollEvent
& event
);
216 virtual void DoSetSize(int x
, int y
,
217 int width
, int height
,
218 int sizeFlags
= wxSIZE_AUTO
);
220 void Init() { m_scrollX
= m_scrollY
= 0; }
222 int m_scrollX
, m_scrollY
;
225 DECLARE_EVENT_TABLE()
226 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)