]>
git.saurik.com Git - wxWidgets.git/blob - src/common/docmdi.cpp
0e8c9d1c35aec41313bd22c40774a7cd3881e0a8
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"
23 #if wxUSE_MDI_ARCHITECTURE && wxUSE_DOC_VIEW_ARCHITECTURE
25 #include "wx/docmdi.h"
28 * Docview MDI parent frame
31 IMPLEMENT_CLASS(wxDocMDIParentFrame
, wxMDIParentFrame
)
33 BEGIN_EVENT_TABLE(wxDocMDIParentFrame
, wxMDIParentFrame
)
34 EVT_MENU(wxID_EXIT
, wxDocMDIParentFrame::OnExit
)
35 EVT_MENU_RANGE(wxID_FILE1
, wxID_FILE9
, wxDocMDIParentFrame::OnMRUFile
)
36 EVT_CLOSE(wxDocMDIParentFrame::OnCloseWindow
)
39 wxDocMDIParentFrame::wxDocMDIParentFrame(wxDocManager
*manager
, wxFrame
*frame
, wxWindowID id
, const wxString
& title
,
40 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
41 wxMDIParentFrame(frame
, id
, title
, pos
, size
, style
, name
)
43 m_docManager
= manager
;
46 void wxDocMDIParentFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
51 void wxDocMDIParentFrame::OnMRUFile(wxCommandEvent
& event
)
53 wxString
f(m_docManager
->GetHistoryFile(event
.GetSelection() - wxID_FILE1
));
55 (void)m_docManager
->CreateDocument(f
, wxDOC_SILENT
);
58 // Extend event processing to search the view's event table
59 bool wxDocMDIParentFrame::ProcessEvent(wxEvent
& event
)
61 // Try the document manager, then do default processing
62 if (!m_docManager
|| !m_docManager
->ProcessEvent(event
))
63 return wxEvtHandler::ProcessEvent(event
);
68 void wxDocMDIParentFrame::OnCloseWindow(wxCloseEvent
& event
)
70 if (m_docManager
->Clear(!event
.CanVeto()))
80 * Default document child frame for MDI children
83 IMPLEMENT_CLASS(wxDocMDIChildFrame
, wxMDIChildFrame
)
85 BEGIN_EVENT_TABLE(wxDocMDIChildFrame
, wxMDIChildFrame
)
86 EVT_ACTIVATE(wxDocMDIChildFrame::OnActivate
)
87 EVT_CLOSE(wxDocMDIChildFrame::OnCloseWindow
)
90 wxDocMDIChildFrame::wxDocMDIChildFrame(wxDocument
*doc
, wxView
*view
, wxMDIParentFrame
*frame
, wxWindowID id
,
91 const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
92 wxMDIChildFrame(frame
, id
, title
, pos
, size
, style
, name
)
94 m_childDocument
= doc
;
100 wxDocMDIChildFrame::~wxDocMDIChildFrame(void)
102 m_childView
= (wxView
*) NULL
;
105 // Extend event processing to search the view's event table
106 bool wxDocMDIChildFrame::ProcessEvent(wxEvent
& event
)
108 if ( !m_childView
|| ! m_childView
->ProcessEvent(event
) )
110 // Only hand up to the parent if it's a menu command
111 if (!event
.IsKindOf(CLASSINFO(wxCommandEvent
)) || !GetParent() || !GetParent()->ProcessEvent(event
))
112 return wxEvtHandler::ProcessEvent(event
);
120 void wxDocMDIChildFrame::OnActivate(wxActivateEvent
& event
)
122 wxMDIChildFrame::OnActivate(event
);
124 if (event
.GetActive() && m_childView
)
125 m_childView
->Activate(event
.GetActive());
128 void wxDocMDIChildFrame::OnCloseWindow(wxCloseEvent
& event
)
130 // Close view but don't delete the frame while doing so!
131 // ...since it will be deleted by wxWindows if we return TRUE.
135 if (!event
.CanVeto())
136 ans
= TRUE
; // Must delete.
138 ans
= m_childView
->Close(FALSE
); // FALSE means don't delete associated window
142 m_childView
->Activate(FALSE
);
144 m_childView
= (wxView
*) NULL
;
145 m_childDocument
= (wxDocument
*) NULL
;
157 // wxUSE_DOC_VIEW_ARCHITECTURE