1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI classes
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "mdi.h"
18 #include "wx/settings.h"
20 extern wxList wxModelessWindows
;
22 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
)
23 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
)
24 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
)
26 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
)
27 EVT_SIZE(wxMDIParentFrame::OnSize
)
28 EVT_ACTIVATE(wxMDIParentFrame::OnActivate
)
29 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged
)
32 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
)
33 EVT_SCROLL(wxMDIClientWindow::OnScroll
)
39 wxMDIParentFrame::wxMDIParentFrame()
43 bool wxMDIParentFrame::Create(wxWindow
*parent
,
45 const wxString
& title
,
52 wxTopLevelWindows
.Append(this);
55 m_windowStyle
= style
;
57 if (parent
) parent
->AddChild(this);
62 m_windowId
= (int)NewControlId();
64 // TODO: create MDI parent frame
66 wxModelessWindows
.Append(this);
71 wxMDIParentFrame::~wxMDIParentFrame()
75 // Get size *available for subwindows* i.e. excluding menu bar.
76 void wxMDIParentFrame::GetClientSize(int *x
, int *y
) const
81 void wxMDIParentFrame::SetMenuBar(wxMenuBar
*menu_bar
)
86 m_frameMenuBar
= NULL
;
90 if (menu_bar
->m_menuBarFrame
)
93 m_frameMenuBar
= menu_bar
;
96 void wxMDIParentFrame::OnSize(wxSizeEvent
& event
)
105 GetClientSize(&width
, &height
);
107 if ( GetClientWindow() )
108 GetClientWindow()->SetSize(x
, y
, width
, height
);
111 void wxMDIParentFrame::OnActivate(wxActivateEvent
& event
)
116 // Returns the active MDI child window
117 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild() const
123 // Create the client window class (don't Create the window,
124 // just return a new class)
125 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient()
127 return new wxMDIClientWindow
;
130 // Responds to colour changes, and passes event on to children.
131 void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
135 // Propagate the event to the non-top-level children
136 wxFrame::OnSysColourChanged(event
);
140 void wxMDIParentFrame::Cascade()
145 void wxMDIParentFrame::Tile()
150 void wxMDIParentFrame::ArrangeIcons()
155 void wxMDIParentFrame::ActivateNext()
160 void wxMDIParentFrame::ActivatePrevious()
167 wxMDIChildFrame::wxMDIChildFrame()
171 bool wxMDIChildFrame::Create(wxMDIParentFrame
*parent
,
173 const wxString
& title
,
177 const wxString
& name
)
184 m_windowId
= (int)NewControlId();
186 if (parent
) parent
->AddChild(this);
188 // TODO: create child frame
190 wxModelessWindows
.Append(this);
194 wxMDIChildFrame::~wxMDIChildFrame()
198 // Set the client size (i.e. leave the calculation of borders etc.
200 void wxMDIChildFrame::SetClientSize(int width
, int height
)
205 void wxMDIChildFrame::GetPosition(int *x
, int *y
) const
210 void wxMDIChildFrame::SetMenuBar(wxMenuBar
*menu_bar
)
215 m_frameMenuBar
= NULL
;
219 if (menu_bar
->m_menuBarFrame
)
221 m_frameMenuBar
= menu_bar
;
225 void wxMDIChildFrame::Maximize()
230 void wxMDIChildFrame::Restore()
235 void wxMDIChildFrame::Activate()
242 wxMDIClientWindow::wxMDIClientWindow()
246 wxMDIClientWindow::~wxMDIClientWindow()
250 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame
*parent
, long style
)
252 // TODO create client window
253 m_backgroundColour
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
);
258 // Explicitly call default scroll behaviour
259 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
)
261 Default(); // Default processing