]> git.saurik.com Git - wxWidgets.git/blame - src/common/docmdi.cpp
don't test sei.hInstApp in DoLaunchDefaultBrowser(), just look at ShellExecuteEx...
[wxWidgets.git] / src / common / docmdi.cpp
CommitLineData
2108f33a
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: docmdi.cpp
3// Purpose: Frame classes for MDI document/view applications
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2108f33a
JS
10/////////////////////////////////////////////////////////////////////////////
11
2108f33a
JS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
2df7be7f 16 #pragma hdrstop
2108f33a
JS
17#endif
18
e30285ab 19#if wxUSE_MDI_ARCHITECTURE
2108f33a 20
2108f33a
JS
21#include "wx/docmdi.h"
22
23/*
24 * Docview MDI parent frame
25 */
26
27IMPLEMENT_CLASS(wxDocMDIParentFrame, wxMDIParentFrame)
28
29BEGIN_EVENT_TABLE(wxDocMDIParentFrame, wxMDIParentFrame)
30 EVT_MENU(wxID_EXIT, wxDocMDIParentFrame::OnExit)
f7bd2698 31 EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, wxDocMDIParentFrame::OnMRUFile)
387a3b02 32 EVT_CLOSE(wxDocMDIParentFrame::OnCloseWindow)
2108f33a
JS
33END_EVENT_TABLE()
34
f0003d29
JS
35wxDocMDIParentFrame::wxDocMDIParentFrame()
36{
37 Init();
38}
39
2108f33a 40wxDocMDIParentFrame::wxDocMDIParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
f0003d29
JS
41 const wxPoint& pos, const wxSize& size, long style, const wxString& name)
42{
43 Init();
44 Create(manager, frame, id, title, pos, size, style, name);
45}
46
47bool wxDocMDIParentFrame::Create(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
48 const wxPoint& pos, const wxSize& size, long style, const wxString& name)
2108f33a 49{
f0003d29
JS
50 m_docManager = manager;
51 return wxMDIParentFrame::Create(frame, id, title, pos, size, style, name);
2108f33a
JS
52}
53
54void wxDocMDIParentFrame::OnExit(wxCommandEvent& WXUNUSED(event))
55{
56 Close();
57}
58
f0003d29
JS
59void wxDocMDIParentFrame::Init()
60{
61 m_docManager = NULL;
62}
63
2108f33a
JS
64void wxDocMDIParentFrame::OnMRUFile(wxCommandEvent& event)
65{
b494c48b
WS
66 wxString f(m_docManager->GetHistoryFile(event.GetId() - wxID_FILE1));
67 if (!f.empty())
2108f33a
JS
68 (void)m_docManager->CreateDocument(f, wxDOC_SILENT);
69}
70
bba5e72a 71bool wxDocMDIParentFrame::TryValidator(wxEvent& event)
2108f33a 72{
bba5e72a 73 return m_docManager && m_docManager->ProcessEventHere(event);
2108f33a
JS
74}
75
387a3b02 76void wxDocMDIParentFrame::OnCloseWindow(wxCloseEvent& event)
2108f33a 77{
387a3b02
JS
78 if (m_docManager->Clear(!event.CanVeto()))
79 {
80 this->Destroy();
81 }
82 else
83 event.Veto();
2108f33a
JS
84}
85
86
87/*
88 * Default document child frame for MDI children
89 */
90
91IMPLEMENT_CLASS(wxDocMDIChildFrame, wxMDIChildFrame)
92
93BEGIN_EVENT_TABLE(wxDocMDIChildFrame, wxMDIChildFrame)
94 EVT_ACTIVATE(wxDocMDIChildFrame::OnActivate)
387a3b02 95 EVT_CLOSE(wxDocMDIChildFrame::OnCloseWindow)
2108f33a
JS
96END_EVENT_TABLE()
97
75799719
VZ
98void wxDocMDIChildFrame::Init()
99{
100 m_childDocument = (wxDocument*) NULL;
101 m_childView = (wxView*) NULL;
102}
103
104wxDocMDIChildFrame::wxDocMDIChildFrame()
105{
106 Init();
107}
108
2108f33a 109wxDocMDIChildFrame::wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id,
75799719
VZ
110 const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
111{
112 Init();
113 Create(doc, view, frame, id, title, pos, size, style, name);
114}
115
116bool wxDocMDIChildFrame::Create(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id,
117 const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
2108f33a 118{
f0003d29
JS
119 m_childDocument = doc;
120 m_childView = view;
121 if (wxMDIChildFrame::Create(frame, id, title, pos, size, style, name))
122 {
123 if (view)
124 view->SetFrame(this);
68379eaf 125 return true;
75799719
VZ
126 }
127
68379eaf 128 return false;
2108f33a
JS
129}
130
131wxDocMDIChildFrame::~wxDocMDIChildFrame(void)
132{
68379eaf 133 m_childView = (wxView *) NULL;
2108f33a
JS
134}
135
bba5e72a 136bool wxDocMDIChildFrame::TryValidator(wxEvent& event)
2108f33a 137{
bba5e72a 138 return m_childView && m_childView->ProcessEventHere(event);
2108f33a
JS
139}
140
141void wxDocMDIChildFrame::OnActivate(wxActivateEvent& event)
142{
143 wxMDIChildFrame::OnActivate(event);
144
7f555861 145 if (event.GetActive() && m_childView)
2108f33a
JS
146 m_childView->Activate(event.GetActive());
147}
148
387a3b02 149void wxDocMDIChildFrame::OnCloseWindow(wxCloseEvent& event)
2108f33a
JS
150{
151 // Close view but don't delete the frame while doing so!
68379eaf 152 // ...since it will be deleted by wxWidgets if we return true.
2108f33a
JS
153 if (m_childView)
154 {
999836aa 155 bool ans = event.CanVeto()
68379eaf
WS
156 ? m_childView->Close(false) // false means don't delete associated window
157 : true; // Must delete.
387a3b02 158
2108f33a
JS
159 if (ans)
160 {
68379eaf 161 m_childView->Activate(false);
2108f33a 162 delete m_childView;
c67daf87
UR
163 m_childView = (wxView *) NULL;
164 m_childDocument = (wxDocument *) NULL;
387a3b02
JS
165
166 this->Destroy();
2108f33a 167 }
387a3b02
JS
168 else
169 event.Veto();
2108f33a 170 }
387a3b02
JS
171 else
172 event.Veto();
2108f33a
JS
173}
174
175#endif
47d67540 176 // wxUSE_DOC_VIEW_ARCHITECTURE
2108f33a 177