From 33a201363a194a38ee0f4e6b2c42b34b00d69731 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Dec 2001 17:35:07 +0000 Subject: [PATCH] added Close All command support to wxDocView (patch 496068) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13248 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/docmanag.tex | 13 +++++++++++++ include/wx/defs.h | 1 + include/wx/docview.h | 4 ++++ src/common/docview.cpp | 19 +++++++++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/latex/wx/docmanag.tex b/docs/latex/wx/docmanag.tex index 4f501d1..7194f9e 100644 --- a/docs/latex/wx/docmanag.tex +++ b/docs/latex/wx/docmanag.tex @@ -114,6 +114,12 @@ Adds a file to the file history list, if we have a pointer to an appropriate fil Adds the template to the document manager's template list. +\membersection{wxDocManager::CloseDocuments} + +\func{bool}{CloseDocuments}{\param{bool }{force = TRUE}} + +Closes all currentled opened documents. + \membersection{wxDocManager::CreateDocument} \func{wxDocument*}{CreateDocument}{\param{const wxString\& }{path}, \param{long}{ flags}} @@ -284,6 +290,12 @@ from \helpref{Initialize}{wxdocmanagerinitialize}. Closes and deletes the currently active document. +\membersection{wxDocManager::OnFileCloseAll} + +\func{void}{OnFileCloseAll}{\void} + +Closes and deletes all the currently opened documents. + \membersection{wxDocManager::OnFileNew} \func{void}{OnFileNew}{\void} @@ -318,6 +330,7 @@ with the following predefined menu item identifiers: \begin{itemize}\itemsep=0pt \item wxID\_OPEN Creates a new document and opens a file into it. \item wxID\_CLOSE Closes the current document. +\item wxID\_CLOSE\_ALL Closes all documents. \item wxID\_NEW Creates a new document. \item wxID\_SAVE Saves the document. \item wxID\_SAVE\_AS Saves the document into a specified filename. diff --git a/include/wx/defs.h b/include/wx/defs.h index 32ed238..439fd5e 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1186,6 +1186,7 @@ enum wxBorder #define wxID_HELP_COMMANDS 5015 #define wxID_HELP_PROCEDURES 5016 #define wxID_HELP_CONTEXT 5017 +#define wxID_CLOSE_ALL 5018 #define wxID_CUT 5030 #define wxID_COPY 5031 diff --git a/include/wx/docview.h b/include/wx/docview.h index b564db1..4cd975e 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -300,6 +300,7 @@ public: // Handlers for common user commands void OnFileClose(wxCommandEvent& event); + void OnFileCloseAll(wxCommandEvent& event); void OnFileNew(wxCommandEvent& event); void OnFileOpen(wxCommandEvent& event); void OnFileRevert(wxCommandEvent& event); @@ -360,6 +361,9 @@ public: void AddDocument(wxDocument *doc); void RemoveDocument(wxDocument *doc); + // closes all currently open documents + bool CloseDocuments(bool force = TRUE); + // Clear remaining documents and templates bool Clear(bool force = TRUE); diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 95b9f93..0015cce 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -698,6 +698,7 @@ bool wxDocTemplate::FileMatchesTemplate(const wxString& path) BEGIN_EVENT_TABLE(wxDocManager, wxEvtHandler) EVT_MENU(wxID_OPEN, wxDocManager::OnFileOpen) EVT_MENU(wxID_CLOSE, wxDocManager::OnFileClose) + EVT_MENU(wxID_CLOSE_ALL, wxDocManager::OnFileCloseAll) EVT_MENU(wxID_REVERT, wxDocManager::OnFileRevert) EVT_MENU(wxID_NEW, wxDocManager::OnFileNew) EVT_MENU(wxID_SAVE, wxDocManager::OnFileSave) @@ -707,6 +708,7 @@ BEGIN_EVENT_TABLE(wxDocManager, wxEvtHandler) EVT_UPDATE_UI(wxID_OPEN, wxDocManager::OnUpdateFileOpen) EVT_UPDATE_UI(wxID_CLOSE, wxDocManager::OnUpdateFileClose) + EVT_UPDATE_UI(wxID_CLOSE_ALL, wxDocManager::OnUpdateFileClose) EVT_UPDATE_UI(wxID_REVERT, wxDocManager::OnUpdateFileRevert) EVT_UPDATE_UI(wxID_NEW, wxDocManager::OnUpdateFileNew) EVT_UPDATE_UI(wxID_SAVE, wxDocManager::OnUpdateFileSave) @@ -747,7 +749,7 @@ wxDocManager::~wxDocManager() sm_docManager = (wxDocManager*) NULL; } -bool wxDocManager::Clear(bool force) +bool wxDocManager::CloseDocuments(bool force) { wxNode *node = m_docs.First(); while (node) @@ -771,7 +773,15 @@ bool wxDocManager::Clear(bool force) // delete another. node = next; } - node = m_templates.First(); + return TRUE; +} + +bool wxDocManager::Clear(bool force) +{ + if (!CloseDocuments(force)) + return FALSE; + + wxNode *node = m_templates.First(); while (node) { wxDocTemplate *templ = (wxDocTemplate*) node->Data(); @@ -806,6 +816,11 @@ void wxDocManager::OnFileClose(wxCommandEvent& WXUNUSED(event)) } } +void wxDocManager::OnFileCloseAll(wxCommandEvent& WXUNUSED(event)) +{ + CloseDocuments(FALSE); +} + void wxDocManager::OnFileNew(wxCommandEvent& WXUNUSED(event)) { CreateDocument(wxString(""), wxDOC_NEW); -- 2.7.4