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;
76 // Get the active MDI child window
77 wxMDIChildFrame
*GetActiveChild() const ;
79 // Get the client window
80 inline wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; };
82 // Create the client window class (don't Create the window,
83 // just return a new class)
84 virtual wxMDIClientWindow
*OnCreateClient() ;
87 virtual void Cascade();
89 virtual void ArrangeIcons();
90 virtual void ActivateNext();
91 virtual void ActivatePrevious();
95 // Set the active child
96 inline void SetActiveChild(wxMDIChildFrame
* child
) { m_activeChild
= child
; }
98 // Set the child's menubar into the parent frame
99 void SetChildMenuBar(wxMDIChildFrame
* frame
);
101 inline wxMenuBar
* GetActiveMenuBar() const { return m_activeMenuBar
; }
103 // Redirect events to active child first
104 virtual bool ProcessEvent(wxEvent
& event
);
109 wxMDIClientWindow
* m_clientWindow
;
110 wxMDIChildFrame
* m_activeChild
;
111 wxMenuBar
* m_activeMenuBar
;
113 DECLARE_EVENT_TABLE()
116 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
118 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
122 inline wxMDIChildFrame(wxMDIParentFrame
*parent
,
124 const wxString
& title
,
125 const wxPoint
& pos
= wxDefaultPosition
,
126 const wxSize
& size
= wxDefaultSize
,
127 long style
= wxDEFAULT_FRAME_STYLE
,
128 const wxString
& name
= wxFrameNameStr
)
130 Create(parent
, id
, title
, pos
, size
, style
, name
);
135 bool Create(wxMDIParentFrame
*parent
,
137 const wxString
& title
,
138 const wxPoint
& pos
= wxDefaultPosition
,
139 const wxSize
& size
= wxDefaultSize
,
140 long style
= wxDEFAULT_FRAME_STYLE
,
141 const wxString
& name
= wxFrameNameStr
);
144 void SetMenuBar(wxMenuBar
*menu_bar
);
145 void SetTitle(const wxString
& title
);
146 void SetClientSize(int width
, int height
);
147 void GetClientSize(int *width
, int *height
) const;
148 void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
149 void GetSize(int *width
, int *height
) const;
150 void GetPosition(int *x
, int *y
) const ;
153 virtual void SetIcon(const wxIcon
& icon
);
155 // Override wxFrame operations
160 void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
163 virtual void Maximize();
164 inline void Minimize() { Iconize(TRUE
); };
165 virtual void Iconize(bool iconize
);
166 virtual void Restore();
167 virtual void Activate();
168 virtual bool IsIconized() const ;
170 bool Show(bool show
);
172 inline WXWidget
GetMainWidget() const { return m_mainWidget
; };
173 inline WXWidget
GetTopWidget() const { return m_mainWidget
; };
174 inline WXWidget
GetClientWidget() const { return m_mainWidget
; };
177 virtual void OnRaise();
178 virtual void OnLower();
181 inline void SetMDIParentFrame(wxMDIParentFrame
* parentFrame
) { m_mdiParentFrame
= parentFrame
; }
182 inline wxMDIParentFrame
* GetMDIParentFrame() const { return m_mdiParentFrame
; }
185 wxMDIParentFrame
* m_mdiParentFrame
;
188 /* The client window is a child of the parent MDI frame, and itself
189 * contains the child MDI frames.
190 * However, you create the MDI children as children of the MDI parent:
191 * only in the implementation does the client window become the parent
192 * of the children. Phew! So the children are sort of 'adopted'...
195 class WXDLLEXPORT wxMDIClientWindow
: public wxNotebook
197 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
200 wxMDIClientWindow() ;
201 inline wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
203 CreateClient(parent
, style
);
206 ~wxMDIClientWindow();
208 void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
209 void SetClientSize(int width
, int height
);
210 void GetClientSize(int *width
, int *height
) const;
212 void GetSize(int *width
, int *height
) const ;
213 void GetPosition(int *x
, int *y
) const ;
215 // Note: this is virtual, to allow overridden behaviour.
216 virtual bool CreateClient(wxMDIParentFrame
*parent
, long style
= wxVSCROLL
| wxHSCROLL
);
218 // Explicitly call default scroll behaviour
219 void OnScroll(wxScrollEvent
& event
);
222 void OnPageChanged(wxNotebookEvent
& event
);
226 DECLARE_EVENT_TABLE()