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
9 // Copyright: (c) David Webster
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
18 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow
;
19 class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
21 class WXDLLIMPEXP_CORE wxMDIParentFrame
: public wxFrame
23 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
25 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
29 inline wxMDIParentFrame(wxWindow
*parent
,
31 const wxString
& title
,
32 const wxPoint
& pos
= wxDefaultPosition
,
33 const wxSize
& size
= wxDefaultSize
,
34 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
, // Scrolling refers to client window
35 const wxString
& name
= wxFrameNameStr
)
37 Create(parent
, id
, title
, pos
, size
, style
, name
);
40 virtual ~wxMDIParentFrame();
42 bool Create(wxWindow
*parent
,
44 const wxString
& title
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
,
47 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
48 const wxString
& name
= wxFrameNameStr
);
53 // Get the active MDI child window (Windows only)
54 wxMDIChildFrame
*GetActiveChild() const;
56 // Get the client window
57 wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; }
59 // Create the client window class (don't Create the window,
60 // just return a new class)
61 virtual wxMDIClientWindow
*OnCreateClient(void);
63 wxMenu
* GetWindowMenu() const { return m_windowMenu
; }
64 // void SetWindowMenu(wxMwnu* pMenu);
68 virtual void Cascade();
70 virtual void ArrangeIcons();
71 virtual void ActivateNext();
72 virtual void ActivatePrevious();
77 // Responds to colour changes
78 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
80 void OnSize(wxSizeEvent
& event
);
82 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
83 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
85 // override window proc for MDI-specific message processing
86 virtual MRESULT
OS2WindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
88 virtual MRESULT
OS2DefWindowProc(WXUINT
, WXWPARAM
, WXLPARAM
);
89 virtual bool OS2TranslateMessage(WXMSG
* msg
);
92 virtual void InternalSetMenuBar();
94 wxMDIClientWindow
* m_clientWindow
;
95 wxMDIChildFrame
* m_currentChild
;
98 // TRUE if MDI Frame is intercepting commands, not child
99 bool m_parentFrameActive
;
102 DECLARE_EVENT_TABLE()
105 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxFrame
107 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
111 inline wxMDIChildFrame(wxMDIParentFrame
*parent
,
113 const wxString
& title
,
114 const wxPoint
& pos
= wxDefaultPosition
,
115 const wxSize
& size
= wxDefaultSize
,
116 long style
= wxDEFAULT_FRAME_STYLE
,
117 const wxString
& name
= wxFrameNameStr
)
119 Create(parent
, id
, title
, pos
, size
, style
, name
);
122 virtual ~wxMDIChildFrame();
124 bool Create(wxMDIParentFrame
*parent
,
126 const wxString
& title
,
127 const wxPoint
& pos
= wxDefaultPosition
,
128 const wxSize
& size
= wxDefaultSize
,
129 long style
= wxDEFAULT_FRAME_STYLE
,
130 const wxString
& name
= wxFrameNameStr
);
133 virtual void Maximize(bool maximize
= TRUE
);
134 virtual void Restore();
135 virtual void Activate();
139 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
140 bool HandleSize(int x
, int y
, WXUINT
);
141 bool HandleWindowPosChanging(void *lpPos
);
142 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
144 virtual MRESULT
OS2WindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
145 virtual MRESULT
OS2DefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
146 virtual bool OS2TranslateMessage(WXMSG
*msg
);
148 virtual void OS2DestroyWindow();
151 bool ResetWindowStyle(void *vrect
);
154 virtual void DoGetPosition(int *x
, int *y
) const;
155 virtual void DoSetClientSize(int width
, int height
);
156 virtual void InternalSetMenuBar();
159 /* The client window is a child of the parent MDI frame, and itself
160 * contains the child MDI frames.
161 * However, you create the MDI children as children of the MDI parent:
162 * only in the implementation does the client window become the parent
163 * of the children. Phew! So the children are sort of 'adopted'...
166 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxWindow
168 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
172 wxMDIClientWindow() { Init(); }
173 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
177 CreateClient(parent
, style
);
180 // Note: this is virtual, to allow overridden behaviour.
181 virtual bool CreateClient(wxMDIParentFrame
*parent
,
182 long style
= wxVSCROLL
| wxHSCROLL
);
184 // Explicitly call default scroll behaviour
185 void OnScroll(wxScrollEvent
& event
);
188 void Init() { m_scrollX
= m_scrollY
= 0; }
190 int m_scrollX
, m_scrollY
;
193 DECLARE_EVENT_TABLE()