]>
git.saurik.com Git - wxWidgets.git/blob - src/common/docmdi.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Frame classes for MDI document/view applications
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "docmdi.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #if wxUSE_DOC_VIEW_ARCHITECTURE
33 #include "wx/docmdi.h"
36 * Docview MDI parent frame
39 IMPLEMENT_CLASS(wxDocMDIParentFrame
, wxMDIParentFrame
)
41 BEGIN_EVENT_TABLE(wxDocMDIParentFrame
, wxMDIParentFrame
)
42 EVT_MENU(wxID_EXIT
, wxDocMDIParentFrame::OnExit
)
43 EVT_MENU_RANGE(wxID_FILE1
, wxID_FILE9
, wxDocMDIParentFrame::OnMRUFile
)
44 EVT_CLOSE(wxDocMDIParentFrame::OnCloseWindow
)
47 wxDocMDIParentFrame::wxDocMDIParentFrame(wxDocManager
*manager
, wxFrame
*frame
, wxWindowID id
, const wxString
& title
,
48 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
49 wxMDIParentFrame(frame
, id
, title
, pos
, size
, style
, name
)
51 m_docManager
= manager
;
54 void wxDocMDIParentFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
59 void wxDocMDIParentFrame::OnMRUFile(wxCommandEvent
& event
)
61 wxString
f(m_docManager
->GetHistoryFile(event
.GetSelection() - wxID_FILE1
));
63 (void)m_docManager
->CreateDocument(f
, wxDOC_SILENT
);
66 // Extend event processing to search the view's event table
67 bool wxDocMDIParentFrame::ProcessEvent(wxEvent
& event
)
69 // Try the document manager, then do default processing
70 if (!m_docManager
|| !m_docManager
->ProcessEvent(event
))
71 return wxEvtHandler::ProcessEvent(event
);
76 void wxDocMDIParentFrame::OnCloseWindow(wxCloseEvent
& event
)
78 if (m_docManager
->Clear(!event
.CanVeto()))
88 * Default document child frame for MDI children
91 IMPLEMENT_CLASS(wxDocMDIChildFrame
, wxMDIChildFrame
)
93 BEGIN_EVENT_TABLE(wxDocMDIChildFrame
, wxMDIChildFrame
)
94 EVT_ACTIVATE(wxDocMDIChildFrame::OnActivate
)
95 EVT_CLOSE(wxDocMDIChildFrame::OnCloseWindow
)
98 wxDocMDIChildFrame::wxDocMDIChildFrame(wxDocument
*doc
, wxView
*view
, wxMDIParentFrame
*frame
, wxWindowID id
,
99 const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
100 wxMDIChildFrame(frame
, id
, title
, pos
, size
, style
, name
)
102 m_childDocument
= doc
;
105 view
->SetFrame(this);
108 wxDocMDIChildFrame::~wxDocMDIChildFrame(void)
110 m_childView
= (wxView
*) NULL
;
113 // Extend event processing to search the view's event table
114 bool wxDocMDIChildFrame::ProcessEvent(wxEvent
& event
)
116 if ( !m_childView
|| ! m_childView
->ProcessEvent(event
) )
118 // Only hand up to the parent if it's a menu command
119 if (!event
.IsKindOf(CLASSINFO(wxCommandEvent
)) || !GetParent() || !GetParent()->ProcessEvent(event
))
120 return wxEvtHandler::ProcessEvent(event
);
128 void wxDocMDIChildFrame::OnActivate(wxActivateEvent
& event
)
130 wxMDIChildFrame::OnActivate(event
);
132 if (event
.GetActive() && m_childView
)
133 m_childView
->Activate(event
.GetActive());
136 void wxDocMDIChildFrame::OnCloseWindow(wxCloseEvent
& event
)
138 // Close view but don't delete the frame while doing so!
139 // ...since it will be deleted by wxWindows if we return TRUE.
143 if (!event
.CanVeto())
144 ans
= TRUE
; // Must delete.
146 ans
= m_childView
->Close(FALSE
); // FALSE means don't delete associated window
150 m_childView
->Activate(FALSE
);
152 m_childView
= (wxView
*) NULL
;
153 m_childDocument
= (wxDocument
*) NULL
;
165 // wxUSE_DOC_VIEW_ARCHITECTURE