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
);
68 void OnMenuHighlight(wxMenuEvent
& event
);
70 void SetMenuBar(wxMenuBar
*menu_bar
);
72 // Get the active MDI child window
73 wxMDIChildFrame
*GetActiveChild() const ;
75 // Get the client window
76 wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; };
78 // Create the client window class (don't Create the window,
79 // just return a new class)
80 virtual wxMDIClientWindow
*OnCreateClient() ;
83 virtual void Cascade();
85 virtual void ArrangeIcons();
86 virtual void ActivateNext();
87 virtual void ActivatePrevious();
91 // Set the active child
92 inline void SetActiveChild(wxMDIChildFrame
* child
) { m_activeChild
= child
; }
94 // Set the child's menubar into the parent frame
95 void SetChildMenuBar(wxMDIChildFrame
* frame
);
97 inline wxMenuBar
* GetActiveMenuBar() const { return m_activeMenuBar
; }
99 // Redirect events to active child first
100 virtual bool ProcessEvent(wxEvent
& event
);
103 virtual void DoSetSize(int x
, int y
,
104 int width
, int height
,
105 int sizeFlags
= wxSIZE_AUTO
);
106 virtual void DoSetClientSize(int width
, int height
);
108 // Gets the size available for subwindows after menu size, toolbar size
109 // and status bar size have been subtracted. If you want to manage your own
110 // toolbar(s), don't call SetToolBar.
111 void DoGetClientSize(int *width
, int *height
) const;
115 wxMDIClientWindow
* m_clientWindow
;
116 wxMDIChildFrame
* m_activeChild
;
117 wxMenuBar
* m_activeMenuBar
;
119 DECLARE_EVENT_TABLE()
122 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
124 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
128 wxMDIChildFrame(wxMDIParentFrame
*parent
,
130 const wxString
& title
,
131 const wxPoint
& pos
= wxDefaultPosition
,
132 const wxSize
& size
= wxDefaultSize
,
133 long style
= wxDEFAULT_FRAME_STYLE
,
134 const wxString
& name
= wxFrameNameStr
)
136 Create(parent
, id
, title
, pos
, size
, style
, name
);
141 bool Create(wxMDIParentFrame
*parent
,
143 const wxString
& title
,
144 const wxPoint
& pos
= wxDefaultPosition
,
145 const wxSize
& size
= wxDefaultSize
,
146 long style
= wxDEFAULT_FRAME_STYLE
,
147 const wxString
& name
= wxFrameNameStr
);
150 void SetMenuBar(wxMenuBar
*menu_bar
);
151 void SetTitle(const wxString
& title
);
154 virtual void SetIcon(const wxIcon
& icon
);
155 virtual void SetIcons(const wxIconBundle
& icons
);
157 // Override wxFrame operations
162 void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
165 virtual void Maximize();
166 virtual void Maximize(bool WXUNUSED(maximize
)) { };
167 inline void Minimize() { Iconize(TRUE
); };
168 virtual void Iconize(bool iconize
);
169 virtual void Restore();
170 virtual void Activate();
171 virtual bool IsIconized() const ;
173 virtual bool IsTopLevel() const { return FALSE
; }
175 // Is the frame maximized? Returns TRUE for
176 // wxMDIChildFrame due to the tabbed implementation.
177 virtual bool IsMaximized(void) const ;
179 bool Show(bool show
);
181 WXWidget
GetMainWidget() const { return m_mainWidget
; };
182 WXWidget
GetTopWidget() const { return m_mainWidget
; };
183 WXWidget
GetClientWidget() const { return m_mainWidget
; };
186 virtual void OnRaise();
187 virtual void OnLower();
190 void SetMDIParentFrame(wxMDIParentFrame
* parentFrame
) { m_mdiParentFrame
= parentFrame
; }
191 wxMDIParentFrame
* GetMDIParentFrame() const { return m_mdiParentFrame
; }
194 wxMDIParentFrame
* m_mdiParentFrame
;
196 virtual void DoSetSize(int x
, int y
,
197 int width
, int height
,
198 int sizeFlags
= wxSIZE_AUTO
);
199 virtual void DoSetClientSize(int width
, int height
);
201 void DoGetClientSize(int *width
, int *height
) const;
202 void DoGetSize(int *width
, int *height
) const;
203 void DoGetPosition(int *x
, int *y
) const ;
206 /* The client window is a child of the parent MDI frame, and itself
207 * contains the child MDI frames.
208 * However, you create the MDI children as children of the MDI parent:
209 * only in the implementation does the client window become the parent
210 * of the children. Phew! So the children are sort of 'adopted'...
213 class WXDLLEXPORT wxMDIClientWindow
: public wxNotebook
215 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
218 wxMDIClientWindow() ;
219 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
221 CreateClient(parent
, style
);
224 ~wxMDIClientWindow();
226 // Note: this is virtual, to allow overridden behaviour.
227 virtual bool CreateClient(wxMDIParentFrame
*parent
, long style
= wxVSCROLL
| wxHSCROLL
);
229 // Explicitly call default scroll behaviour
230 void OnScroll(wxScrollEvent
& event
);
233 void OnPageChanged(wxNotebookEvent
& event
);
236 virtual void DoSetSize(int x
, int y
,
237 int width
, int height
,
238 int sizeFlags
= wxSIZE_AUTO
);
239 virtual void DoSetClientSize(int width
, int height
);
241 void DoGetClientSize(int *width
, int *height
) const;
242 void DoGetSize(int *width
, int *height
) const ;
243 void DoGetPosition(int *x
, int *y
) const ;
247 DECLARE_EVENT_TABLE()