1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "mdi.h"
18 #include "wx/settings.h"
20 extern wxList wxModelessWindows
;
22 #if !USE_SHARED_LIBRARY
23 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
)
24 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
)
25 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
)
27 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
)
28 EVT_SIZE(wxMDIParentFrame::OnSize
)
29 EVT_ACTIVATE(wxMDIParentFrame::OnActivate
)
30 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged
)
33 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
)
34 EVT_SCROLL(wxMDIClientWindow::OnScroll
)
41 wxMDIParentFrame::wxMDIParentFrame()
45 bool wxMDIParentFrame::Create(wxWindow
*parent
,
47 const wxString
& title
,
54 wxTopLevelWindows
.Append(this);
57 m_windowStyle
= style
;
59 if (parent
) parent
->AddChild(this);
64 m_windowId
= (int)NewControlId();
66 // TODO: create MDI parent frame
68 wxModelessWindows
.Append(this);
73 wxMDIParentFrame::~wxMDIParentFrame()
77 // Get size *available for subwindows* i.e. excluding menu bar.
78 void wxMDIParentFrame::GetClientSize(int *x
, int *y
) const
83 void wxMDIParentFrame::SetMenuBar(wxMenuBar
*menu_bar
)
88 m_frameMenuBar
= NULL
;
92 if (menu_bar
->m_menuBarFrame
)
95 m_frameMenuBar
= menu_bar
;
98 void wxMDIParentFrame::OnSize(wxSizeEvent
& event
)
100 #if wxUSE_CONSTRAINTS
107 GetClientSize(&width
, &height
);
109 if ( GetClientWindow() )
110 GetClientWindow()->SetSize(x
, y
, width
, height
);
113 void wxMDIParentFrame::OnActivate(wxActivateEvent
& event
)
118 // Returns the active MDI child window
119 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild() const
125 // Create the client window class (don't Create the window,
126 // just return a new class)
127 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient()
129 return new wxMDIClientWindow
;
132 // Responds to colour changes, and passes event on to children.
133 void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
137 // Propagate the event to the non-top-level children
138 wxFrame::OnSysColourChanged(event
);
142 void wxMDIParentFrame::Cascade()
147 void wxMDIParentFrame::Tile()
152 void wxMDIParentFrame::ArrangeIcons()
157 void wxMDIParentFrame::ActivateNext()
162 void wxMDIParentFrame::ActivatePrevious()
169 wxMDIChildFrame::wxMDIChildFrame()
173 bool wxMDIChildFrame::Create(wxMDIParentFrame
*parent
,
175 const wxString
& title
,
179 const wxString
& name
)
186 m_windowId
= (int)NewControlId();
188 if (parent
) parent
->AddChild(this);
190 // TODO: create child frame
192 wxModelessWindows
.Append(this);
196 wxMDIChildFrame::~wxMDIChildFrame()
200 // Set the client size (i.e. leave the calculation of borders etc.
202 void wxMDIChildFrame::SetClientSize(int width
, int height
)
207 void wxMDIChildFrame::GetPosition(int *x
, int *y
) const
212 void wxMDIChildFrame::SetMenuBar(wxMenuBar
*menu_bar
)
217 m_frameMenuBar
= NULL
;
221 if (menu_bar
->m_menuBarFrame
)
223 m_frameMenuBar
= menu_bar
;
227 void wxMDIChildFrame::Maximize()
232 void wxMDIChildFrame::Restore()
237 void wxMDIChildFrame::Activate()
244 wxMDIClientWindow::wxMDIClientWindow()
248 wxMDIClientWindow::~wxMDIClientWindow()
252 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame
*parent
, long style
)
254 // TODO create client window
255 m_backgroundColour
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
);
260 // Explicitly call default scroll behaviour
261 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
)
263 Default(); // Default processing