]>
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 USE_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
)
46 wxDocMDIParentFrame::wxDocMDIParentFrame(wxDocManager
*manager
, wxFrame
*frame
, wxWindowID id
, const wxString
& title
,
47 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
48 wxMDIParentFrame(frame
, id
, title
, pos
, size
, style
, name
)
50 m_docManager
= manager
;
53 void wxDocMDIParentFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
58 void wxDocMDIParentFrame::OnMRUFile(wxCommandEvent
& event
)
60 wxString
f(m_docManager
->GetHistoryFile(event
.GetSelection() - wxID_FILE1
));
62 (void)m_docManager
->CreateDocument(f
, wxDOC_SILENT
);
65 // Extend event processing to search the view's event table
66 bool wxDocMDIParentFrame::ProcessEvent(wxEvent
& event
)
68 // Try the document manager, then do default processing
69 if (!m_docManager
|| !m_docManager
->ProcessEvent(event
))
70 return wxEvtHandler::ProcessEvent(event
);
75 // Define the behaviour for the frame closing
76 // - must delete all frames except for the main one.
77 bool wxDocMDIParentFrame::OnClose(void)
79 return m_docManager
->Clear(FALSE
);
84 * Default document child frame for MDI children
87 IMPLEMENT_CLASS(wxDocMDIChildFrame
, wxMDIChildFrame
)
89 BEGIN_EVENT_TABLE(wxDocMDIChildFrame
, wxMDIChildFrame
)
90 EVT_ACTIVATE(wxDocMDIChildFrame::OnActivate
)
93 wxDocMDIChildFrame::wxDocMDIChildFrame(wxDocument
*doc
, wxView
*view
, wxMDIParentFrame
*frame
, wxWindowID id
,
94 const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
95 wxMDIChildFrame(frame
, id
, title
, pos
, size
, style
, name
)
97 m_childDocument
= doc
;
100 view
->SetFrame(this);
103 wxDocMDIChildFrame::~wxDocMDIChildFrame(void)
105 m_childView
= (wxView
*) NULL
;
108 // Extend event processing to search the view's event table
109 bool wxDocMDIChildFrame::ProcessEvent(wxEvent
& event
)
112 m_childView
->Activate(TRUE
);
114 if ( !m_childView
|| ! m_childView
->ProcessEvent(event
) )
116 // Only hand up to the parent if it's a menu command
117 if (!event
.IsKindOf(CLASSINFO(wxCommandEvent
)) || !GetParent() || !GetParent()->ProcessEvent(event
))
118 return wxEvtHandler::ProcessEvent(event
);
126 void wxDocMDIChildFrame::OnActivate(wxActivateEvent
& event
)
128 wxMDIChildFrame::OnActivate(event
);
131 m_childView
->Activate(event
.GetActive());
134 bool wxDocMDIChildFrame::OnClose(void)
136 // Close view but don't delete the frame while doing so!
137 // ...since it will be deleted by wxWindows if we return TRUE.
140 bool ans
= m_childView
->Close(FALSE
); // FALSE means don't delete associated window
143 m_childView
->Activate(FALSE
);
145 m_childView
= (wxView
*) NULL
;
146 m_childDocument
= (wxDocument
*) NULL
;
155 // USE_DOC_VIEW_ARCHITECTURE