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 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
);
108 virtual void DoSetSize(int x
, int y
,
109 int width
, int height
,
110 int sizeFlags
= wxSIZE_AUTO
);
111 virtual void DoSetClientSize(int width
, int height
);
116 wxMDIClientWindow
* m_clientWindow
;
117 wxMDIChildFrame
* m_activeChild
;
118 wxMenuBar
* m_activeMenuBar
;
120 DECLARE_EVENT_TABLE()
123 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
125 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
129 wxMDIChildFrame(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
)
137 Create(parent
, id
, title
, pos
, size
, style
, name
);
142 bool Create(wxMDIParentFrame
*parent
,
144 const wxString
& title
,
145 const wxPoint
& pos
= wxDefaultPosition
,
146 const wxSize
& size
= wxDefaultSize
,
147 long style
= wxDEFAULT_FRAME_STYLE
,
148 const wxString
& name
= wxFrameNameStr
);
151 void SetMenuBar(wxMenuBar
*menu_bar
);
152 void SetTitle(const wxString
& title
);
154 void SetClientSize(int width
, int height
);
155 void GetClientSize(int *width
, int *height
) const;
156 void GetSize(int *width
, int *height
) const;
157 void GetPosition(int *x
, int *y
) const ;
160 virtual void SetIcon(const wxIcon
& icon
);
162 // Override wxFrame operations
167 void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
170 virtual void Maximize();
171 virtual void Maximize(bool WXUNUSED(maximize
)) { };
172 inline void Minimize() { Iconize(TRUE
); };
173 virtual void Iconize(bool iconize
);
174 virtual void Restore();
175 virtual void Activate();
176 virtual bool IsIconized() const ;
178 // Is the frame maximized? Returns TRUE for
179 // wxMDIChildFrame due to the tabbed implementation.
180 virtual bool IsMaximized(void) const ;
182 bool Show(bool show
);
184 WXWidget
GetMainWidget() const { return m_mainWidget
; };
185 WXWidget
GetTopWidget() const { return m_mainWidget
; };
186 WXWidget
GetClientWidget() const { return m_mainWidget
; };
189 virtual void OnRaise();
190 virtual void OnLower();
193 void SetMDIParentFrame(wxMDIParentFrame
* parentFrame
) { m_mdiParentFrame
= parentFrame
; }
194 wxMDIParentFrame
* GetMDIParentFrame() const { return m_mdiParentFrame
; }
197 wxMDIParentFrame
* m_mdiParentFrame
;
199 virtual void DoSetSize(int x
, int y
,
200 int width
, int height
,
201 int sizeFlags
= wxSIZE_AUTO
);
202 virtual void DoSetClientSize(int width
, int height
);
205 /* The client window is a child of the parent MDI frame, and itself
206 * contains the child MDI frames.
207 * However, you create the MDI children as children of the MDI parent:
208 * only in the implementation does the client window become the parent
209 * of the children. Phew! So the children are sort of 'adopted'...
212 class WXDLLEXPORT wxMDIClientWindow
: public wxNotebook
214 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
217 wxMDIClientWindow() ;
218 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
220 CreateClient(parent
, style
);
223 ~wxMDIClientWindow();
225 void GetClientSize(int *width
, int *height
) const;
226 void GetSize(int *width
, int *height
) const ;
227 void GetPosition(int *x
, int *y
) const ;
229 // Note: this is virtual, to allow overridden behaviour.
230 virtual bool CreateClient(wxMDIParentFrame
*parent
, long style
= wxVSCROLL
| wxHSCROLL
);
232 // Explicitly call default scroll behaviour
233 void OnScroll(wxScrollEvent
& event
);
236 void OnPageChanged(wxNotebookEvent
& event
);
239 virtual void DoSetSize(int x
, int y
,
240 int width
, int height
,
241 int sizeFlags
= wxSIZE_AUTO
);
242 virtual void DoSetClientSize(int width
, int height
);
245 DECLARE_EVENT_TABLE()