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"
20 New MDI scheme using tabs. We can use a wxNotebook to implement the client
21 window. wxMDIChildFrame can be implemented as an XmMainWindow widget
22 as before, and is a child of the notebook _and_ of the parent frame...
23 but wxMDIChildFrame::GetParent should return the parent frame.
28 #include "wx/notebook.h"
30 WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr
;
31 WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr
;
33 class WXDLLEXPORT wxMDIClientWindow
;
34 class WXDLLEXPORT wxMDIChildFrame
;
36 class WXDLLEXPORT wxMDIParentFrame
: public wxFrame
38 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
40 friend class WXDLLEXPORT wxMDIChildFrame
;
44 inline wxMDIParentFrame(wxWindow
*parent
,
46 const wxString
& title
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
49 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
, // Scrolling refers to client window
50 const wxString
& name
= wxFrameNameStr
)
52 Create(parent
, id
, title
, pos
, size
, style
, name
);
57 bool Create(wxWindow
*parent
,
59 const wxString
& title
,
60 const wxPoint
& pos
= wxDefaultPosition
,
61 const wxSize
& size
= wxDefaultSize
,
62 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
63 const wxString
& name
= wxFrameNameStr
);
65 void OnSize(wxSizeEvent
& event
);
66 void OnActivate(wxActivateEvent
& event
);
67 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
69 void SetMenuBar(wxMenuBar
*menu_bar
);
71 // Gets the size available for subwindows after menu size, toolbar size
72 // and status bar size have been subtracted. If you want to manage your own
73 // toolbar(s), don't call SetToolBar.
74 void GetClientSize(int *width
, int *height
) const;
75 wxSize
GetClientSize() const { return wxWindow::GetClientSize(); }
77 // Get the active MDI child window
78 wxMDIChildFrame
*GetActiveChild() const ;
80 // Get the client window
81 inline wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; };
83 // Create the client window class (don't Create the window,
84 // just return a new class)
85 virtual wxMDIClientWindow
*OnCreateClient() ;
88 virtual void Cascade();
90 virtual void ArrangeIcons();
91 virtual void ActivateNext();
92 virtual void ActivatePrevious();
96 // Set the active child
97 inline void SetActiveChild(wxMDIChildFrame
* child
) { m_activeChild
= child
; }
99 // Set the child's menubar into the parent frame
100 void SetChildMenuBar(wxMDIChildFrame
* frame
);
102 inline wxMenuBar
* GetActiveMenuBar() const { return m_activeMenuBar
; }
104 // Redirect events to active child first
105 virtual bool ProcessEvent(wxEvent
& event
);
110 wxMDIClientWindow
* m_clientWindow
;
111 wxMDIChildFrame
* m_activeChild
;
112 wxMenuBar
* m_activeMenuBar
;
114 DECLARE_EVENT_TABLE()
117 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
119 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
123 inline wxMDIChildFrame(wxMDIParentFrame
*parent
,
125 const wxString
& title
,
126 const wxPoint
& pos
= wxDefaultPosition
,
127 const wxSize
& size
= wxDefaultSize
,
128 long style
= wxDEFAULT_FRAME_STYLE
,
129 const wxString
& name
= wxFrameNameStr
)
131 Create(parent
, id
, title
, pos
, size
, style
, name
);
136 bool Create(wxMDIParentFrame
*parent
,
138 const wxString
& title
,
139 const wxPoint
& pos
= wxDefaultPosition
,
140 const wxSize
& size
= wxDefaultSize
,
141 long style
= wxDEFAULT_FRAME_STYLE
,
142 const wxString
& name
= wxFrameNameStr
);
145 void SetMenuBar(wxMenuBar
*menu_bar
);
146 void SetTitle(const wxString
& title
);
148 void SetClientSize(int width
, int height
);
149 void SetClientSize(const wxSize
& size
) { wxWindow::SetClientSize(size
); }
151 void GetClientSize(int *width
, int *height
) const;
152 wxSize
GetClientSize() const { return wxWindow::GetClientSize(); }
154 void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
155 virtual void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
156 { wxWindow::SetSize(rect
, sizeFlags
); }
157 virtual void SetSize(const wxSize
& size
) { wxWindow::SetSize(size
); }
159 void GetSize(int *width
, int *height
) const;
160 wxSize
GetSize() const { return wxWindow::GetSize(); }
162 void GetPosition(int *x
, int *y
) const ;
163 wxPoint
GetPosition() const { return wxWindow::GetPosition(); }
166 virtual void SetIcon(const wxIcon
& icon
);
168 // Override wxFrame operations
173 void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
176 virtual void Maximize();
177 inline void Minimize() { Iconize(TRUE
); };
178 virtual void Iconize(bool iconize
);
179 virtual void Restore();
180 virtual void Activate();
181 virtual bool IsIconized() const ;
183 bool Show(bool show
);
185 inline WXWidget
GetMainWidget() const { return m_mainWidget
; };
186 inline WXWidget
GetTopWidget() const { return m_mainWidget
; };
187 inline WXWidget
GetClientWidget() const { return m_mainWidget
; };
190 virtual void OnRaise();
191 virtual void OnLower();
194 inline void SetMDIParentFrame(wxMDIParentFrame
* parentFrame
) { m_mdiParentFrame
= parentFrame
; }
195 inline wxMDIParentFrame
* GetMDIParentFrame() const { return m_mdiParentFrame
; }
198 wxMDIParentFrame
* m_mdiParentFrame
;
201 /* The client window is a child of the parent MDI frame, and itself
202 * contains the child MDI frames.
203 * However, you create the MDI children as children of the MDI parent:
204 * only in the implementation does the client window become the parent
205 * of the children. Phew! So the children are sort of 'adopted'...
208 class WXDLLEXPORT wxMDIClientWindow
: public wxNotebook
210 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
213 wxMDIClientWindow() ;
214 inline wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
216 CreateClient(parent
, style
);
219 ~wxMDIClientWindow();
221 void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
222 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
223 { wxWindow::SetSize(rect
, sizeFlags
); }
224 void SetSize(const wxSize
& size
) { wxWindow::SetSize(size
); }
226 void SetClientSize(int width
, int height
);
227 void SetClientSize(const wxSize
& size
) { wxWindow::SetClientSize(size
); }
229 void GetClientSize(int *width
, int *height
) const;
230 wxSize
GetClientSize() const { return wxWindow::GetClientSize(); }
232 void GetSize(int *width
, int *height
) const ;
233 wxSize
GetSize() const { return wxWindow::GetSize(); }
235 void GetPosition(int *x
, int *y
) const ;
236 wxPoint
GetPosition() const { return wxWindow::GetPosition(); }
238 // Note: this is virtual, to allow overridden behaviour.
239 virtual bool CreateClient(wxMDIParentFrame
*parent
, long style
= wxVSCROLL
| wxHSCROLL
);
241 // Explicitly call default scroll behaviour
242 void OnScroll(wxScrollEvent
& event
);
245 void OnPageChanged(wxNotebookEvent
& event
);
249 DECLARE_EVENT_TABLE()