bool wxDocument::OnCloseDocument()
{
+ // Tell all views that we're about to close
+ NotifyClosing();
DeleteContents();
Modify(FALSE);
return TRUE;
}
}
+void wxDocument::NotifyClosing()
+{
+ wxNode *node = m_documentViews.First();
+ while (node)
+ {
+ wxView *view = (wxView *)node->Data();
+ view->OnClosingDocument();
+ node = node->Next();
+ }
+}
+
void wxDocument::SetFilename(const wxString& filename, bool notifyViews)
{
m_documentFile = filename;
void wxView::Activate(bool activate)
{
- if (GetDocumentManager())
+ if (GetDocument() && GetDocumentManager())
{
OnActivateView(activate, this, GetDocumentManager()->GetCurrentView());
GetDocumentManager()->ActivateView(this, activate);
{
wxDocument *doc = GetCurrentDocument();
event.Enable( (doc && doc->GetCommandProcessor() && doc->GetCommandProcessor()->CanUndo()) );
+ if (doc && doc->GetCommandProcessor())
+ doc->GetCommandProcessor()->SetMenuStrings();
}
void wxDocManager::OnUpdateRedo(wxUpdateUIEvent& event)
{
wxDocument *doc = GetCurrentDocument();
event.Enable( (doc && doc->GetCommandProcessor() && doc->GetCommandProcessor()->CanRedo()) );
+ if (doc && doc->GetCommandProcessor())
+ doc->GetCommandProcessor()->SetMenuStrings();
}
void wxDocManager::OnUpdatePrint(wxUpdateUIEvent& event)
wxDocTemplate **data = new wxDocTemplate *[noTemplates];
int i;
int n = 0;
+
for (i = 0; i < noTemplates; i++)
{
if (templates[i]->IsVisible())
{
- strings.Add(templates[i]->m_description);
- if (!sort)
+ int j;
+ bool want = TRUE;
+ for (j = 0; j < n; j++)
+ {
+ //filter out NOT unique documents + view combinations
+ if ( templates[i]->m_docTypeName == data[j]->m_docTypeName &&
+ templates[i]->m_viewTypeName == data[j]->m_viewTypeName
+ )
+ want = FALSE;
+ }
+
+ if ( want )
{
+ strings.Add(templates[i]->m_description);
+
data[n] = templates[i];
n ++;
}
wxDocTemplate **data = new wxDocTemplate *[noTemplates];
int i;
int n = 0;
+
for (i = 0; i < noTemplates; i++)
{
wxDocTemplate *templ = templates[i];
if ( templ->IsVisible() && !templ->GetViewName().empty() )
{
- strings.Add(templ->m_viewTypeName);
- if (!sort)
+ int j;
+ bool want = TRUE;
+ for (j = 0; j < n; j++)
{
+ //filter out NOT unique views
+ if ( templates[i]->m_viewTypeName == data[j]->m_viewTypeName )
+ want = FALSE;
+ }
+
+ if ( want )
+ {
+ strings.Add(templ->m_viewTypeName);
data[n] = templ;
n ++;
}