1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI (Multiple Document Interface) classes.
4 // This doesn't have to be implemented just like Windows,
5 // it could be a tabbed design as in wxGTK.
6 // Author: David Webster
10 // Copyright: (c) David Webster
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
19 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow
;
20 class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
22 class WXDLLIMPEXP_CORE wxMDIParentFrame
: public wxFrame
24 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
26 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
30 inline wxMDIParentFrame(wxWindow
*parent
,
32 const wxString
& title
,
33 const wxPoint
& pos
= wxDefaultPosition
,
34 const wxSize
& size
= wxDefaultSize
,
35 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
, // Scrolling refers to client window
36 const wxString
& name
= wxFrameNameStr
)
38 Create(parent
, id
, title
, pos
, size
, style
, name
);
41 virtual ~wxMDIParentFrame();
43 bool Create(wxWindow
*parent
,
45 const wxString
& title
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
48 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
49 const wxString
& name
= wxFrameNameStr
);
54 // Get the active MDI child window (Windows only)
55 wxMDIChildFrame
*GetActiveChild() const;
57 // Get the client window
58 wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; }
60 // Create the client window class (don't Create the window,
61 // just return a new class)
62 virtual wxMDIClientWindow
*OnCreateClient(void);
64 wxMenu
* GetWindowMenu() const { return m_windowMenu
; }
65 // void SetWindowMenu(wxMwnu* pMenu);
69 virtual void Cascade();
71 virtual void ArrangeIcons();
72 virtual void ActivateNext();
73 virtual void ActivatePrevious();
78 // Responds to colour changes
79 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
81 void OnSize(wxSizeEvent
& event
);
83 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
84 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
86 // override window proc for MDI-specific message processing
87 virtual MRESULT
OS2WindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
89 virtual MRESULT
OS2DefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
90 virtual bool OS2TranslateMessage(WXMSG
* msg
);
93 virtual void InternalSetMenuBar();
95 wxMDIClientWindow
* m_clientWindow
;
96 wxMDIChildFrame
* m_currentChild
;
99 // TRUE if MDI Frame is intercepting commands, not child
100 bool m_parentFrameActive
;
103 DECLARE_EVENT_TABLE()
106 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxFrame
108 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
112 inline wxMDIChildFrame(wxMDIParentFrame
*parent
,
114 const wxString
& title
,
115 const wxPoint
& pos
= wxDefaultPosition
,
116 const wxSize
& size
= wxDefaultSize
,
117 long style
= wxDEFAULT_FRAME_STYLE
,
118 const wxString
& name
= wxFrameNameStr
)
120 Create(parent
, id
, title
, pos
, size
, style
, name
);
123 virtual ~wxMDIChildFrame();
125 bool Create(wxMDIParentFrame
*parent
,
127 const wxString
& title
,
128 const wxPoint
& pos
= wxDefaultPosition
,
129 const wxSize
& size
= wxDefaultSize
,
130 long style
= wxDEFAULT_FRAME_STYLE
,
131 const wxString
& name
= wxFrameNameStr
);
134 virtual void Maximize(bool maximize
= TRUE
);
135 virtual void Restore();
136 virtual void Activate();
140 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
141 bool HandleSize(int x
, int y
, WXUINT
);
142 bool HandleWindowPosChanging(void *lpPos
);
143 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
145 virtual MRESULT
OS2WindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
146 virtual MRESULT
OS2DefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
147 virtual bool OS2TranslateMessage(WXMSG
*msg
);
149 virtual void OS2DestroyWindow();
152 bool ResetWindowStyle(void *vrect
);
155 virtual void DoGetPosition(int *x
, int *y
) const;
156 virtual void DoSetClientSize(int width
, int height
);
157 virtual void InternalSetMenuBar();
160 /* The client window is a child of the parent MDI frame, and itself
161 * contains the child MDI frames.
162 * However, you create the MDI children as children of the MDI parent:
163 * only in the implementation does the client window become the parent
164 * of the children. Phew! So the children are sort of 'adopted'...
167 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxWindow
169 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
173 wxMDIClientWindow() { Init(); }
174 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
178 CreateClient(parent
, style
);
181 // Note: this is virtual, to allow overridden behaviour.
182 virtual bool CreateClient(wxMDIParentFrame
*parent
,
183 long style
= wxVSCROLL
| wxHSCROLL
);
185 // Explicitly call default scroll behaviour
186 void OnScroll(wxScrollEvent
& event
);
189 void Init() { m_scrollX
= m_scrollY
= 0; }
191 int m_scrollX
, m_scrollY
;
194 DECLARE_EVENT_TABLE()