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 WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr
;
20 WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr
;
22 class WXDLLEXPORT wxMDIClientWindow
;
23 class WXDLLEXPORT wxMDIChildFrame
;
25 class WXDLLEXPORT wxMDIParentFrame
: public wxFrame
27 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
29 friend class WXDLLEXPORT wxMDIChildFrame
;
33 inline wxMDIParentFrame(wxWindow
*parent
,
35 const wxString
& title
,
36 const wxPoint
& pos
= wxDefaultPosition
,
37 const wxSize
& size
= wxDefaultSize
,
38 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
, // Scrolling refers to client window
39 const wxString
& name
= wxFrameNameStr
)
41 Create(parent
, id
, title
, pos
, size
, style
, name
);
46 bool Create(wxWindow
*parent
,
48 const wxString
& title
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
51 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
52 const wxString
& name
= wxFrameNameStr
);
57 // Get the active MDI child window (Windows only)
58 wxMDIChildFrame
*GetActiveChild() const;
60 // Get the client window
61 wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; }
63 // Create the client window class (don't Create the window,
64 // just return a new class)
65 virtual wxMDIClientWindow
*OnCreateClient(void);
67 WXHMENU
GetWindowMenu() const { return m_windowMenu
; }
71 virtual void Cascade();
73 virtual void ArrangeIcons();
74 virtual void ActivateNext();
75 virtual void ActivatePrevious();
80 // Responds to colour changes
81 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
83 void OnSize(wxSizeEvent
& event
);
85 bool HandleActivate(int state
, bool minimized
, WXHWND activate
);
86 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
88 // override window proc for MDI-specific message processing
89 virtual MRESULT
OS2WindowProc(HWND hwnd
, WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
91 virtual MRESULT
OS2DefWindowProc(HWND hwnd
, WXUINT
, WXWPARAM
, WXLPARAM
);
92 virtual bool OS2TranslateMessage(WXMSG
* msg
);
95 virtual void InternalSetMenuBar();
97 wxMDIClientWindow
* m_clientWindow
;
98 wxMDIChildFrame
* m_currentChild
;
101 // TRUE if MDI Frame is intercepting commands, not child
102 bool m_parentFrameActive
;
105 friend class WXDLLEXPORT wxMDIChildFrame
;
107 DECLARE_EVENT_TABLE()
110 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
112 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
116 inline wxMDIChildFrame(wxMDIParentFrame
*parent
,
118 const wxString
& title
,
119 const wxPoint
& pos
= wxDefaultPosition
,
120 const wxSize
& size
= wxDefaultSize
,
121 long style
= wxDEFAULT_FRAME_STYLE
,
122 const wxString
& name
= wxFrameNameStr
)
124 Create(parent
, id
, title
, pos
, size
, style
, name
);
129 bool Create(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
);
138 virtual void Maximize(bool maximize
= TRUE
);
139 virtual void Restore();
140 virtual void Activate();
144 bool HandleMDIActivate(long bActivate
, WXHWND
, WXHWND
);
145 bool HandleSize(int x
, int y
, WXUINT
);
146 bool HandleWindowPosChanging(void *lpPos
);
147 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
149 virtual MRESULT
OS2WindowProc(HWND hwnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
150 virtual MRESULT
OS2DefWindowProc(HWND hwnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
151 virtual bool OS2TranslateMessage(WXMSG
*msg
);
153 virtual void OS2DestroyWindow();
156 bool ResetWindowStyle(void *vrect
);
159 virtual void DoGetPosition(int *x
, int *y
) const;
160 virtual void DoSetClientSize(int width
, int height
);
161 virtual void InternalSetMenuBar();
164 /* The client window is a child of the parent MDI frame, and itself
165 * contains the child MDI frames.
166 * However, you create the MDI children as children of the MDI parent:
167 * only in the implementation does the client window become the parent
168 * of the children. Phew! So the children are sort of 'adopted'...
171 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
173 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
177 wxMDIClientWindow() { Init(); }
178 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
182 CreateClient(parent
, style
);
185 // Note: this is virtual, to allow overridden behaviour.
186 virtual bool CreateClient(wxMDIParentFrame
*parent
,
187 long style
= wxVSCROLL
| wxHSCROLL
);
189 // Explicitly call default scroll behaviour
190 void OnScroll(wxScrollEvent
& event
);
193 void Init() { m_scrollX
= m_scrollY
= 0; }
195 int m_scrollX
, m_scrollY
;
198 DECLARE_EVENT_TABLE()