From beba4fa694711bde29d23b5fb5e31aaa36156cb8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Mar 2013 11:00:59 +0000 Subject: [PATCH] Add wxDocument::Activate() method. Make activating the first (and, in the vast majority of cases, the only) view of the document easier. Closes #15120. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/docview.h | 7 +++---- interface/wx/docview.h | 9 +++++++++ src/common/docview.cpp | 8 ++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index cf2e34f02a..5ece48ffc8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -624,6 +624,7 @@ All (GUI): - Add wxAUI_TB_PLAIN_BACKGROUND wxAuiToolBar style (Allann Jones). - Make wxGenericDataViewCtrl::SetFont() really work (Laurent Poujoulat). - Remove wxLogWindow::OnFrameCreate(), it was never called anyhow. +- Added wxDocument::Activate() (troelsk). wxGTK: diff --git a/include/wx/docview.h b/include/wx/docview.h index 420355df5f..d9c34e64a6 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -86,6 +86,9 @@ public: bool GetDocumentSaved() const { return m_savedYet; } void SetDocumentSaved(bool saved = true) { m_savedYet = saved; } + // activate the first view of the document if any + void Activate(); + // return true if the document hasn't been modified since the last time it // was saved (implying that it returns false if it was never saved, even if // the document is not modified) @@ -550,10 +553,6 @@ protected: // view and returns it then wxView *GetActiveView() const; - // activate the first view of the given document if any - void ActivateDocument(wxDocument *doc); - - int m_defaultDocumentNameCounter; int m_maxDocsOpen; wxList m_docs; diff --git a/interface/wx/docview.h b/interface/wx/docview.h index 13d8b218fe..279556757b 100644 --- a/interface/wx/docview.h +++ b/interface/wx/docview.h @@ -1240,6 +1240,15 @@ public: */ bool AlreadySaved() const; + /** + Activate the first view of the document if any. + + @see GetFirstView() + + @since 2.9.5 + */ + void Activate() const; + /** Closes the document, by calling OnSaveModified() and then (if this returned @true) OnCloseDocument(). This does not normally delete the diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 849a3a2754..234c5c2b85 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1407,9 +1407,9 @@ wxDocTemplateVector GetVisibleTemplates(const wxList& allTemplates) } // anonymous namespace -void wxDocManager::ActivateDocument(wxDocument *doc) +void wxDocument::Activate() { - wxView * const view = doc->GetFirstView(); + wxView * const view = GetFirstView(); if ( !view ) return; @@ -1472,7 +1472,7 @@ wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags) if ( fn == doc->GetFilename() ) { // file already open, just activate it and return - ActivateDocument(doc); + doc->Activate(); return doc; } } @@ -1523,7 +1523,7 @@ wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags) // at least under Mac (where views are top level windows) it seems to be // necessary to manually activate the new document to bring it to the // forefront -- and it shouldn't hurt doing this under the other platforms - ActivateDocument(docNew); + docNew->Activate(); return docNew; } -- 2.45.2