- Make wxGenericDataViewCtrl::SetFont() really work (Laurent Poujoulat).
- Remove wxLogWindow::OnFrameCreate(), it was never called anyhow.
- Added wxDocument::Activate() (troelsk).
+- Added wxDocManager::FindDocumentByPath() (troelsk).
wxGTK:
// Find template from document class info, may return NULL.
wxDocTemplate* FindTemplate(const wxClassInfo* documentClassInfo);
+ // Find document from file name, may return NULL.
+ wxDocument* FindDocumentByPath(const wxString& path) const;
+
wxDocument *GetCurrentDocument() const;
void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; }
*/
wxDocTemplate* FindTemplate(const wxClassInfo* classinfo);
+
+ /**
+ Search for the document corresponding to the given file.
+
+ @param path
+ Document file path.
+ @return
+ Pointer to a wxDocument, or @NULL if none found.
+
+ @since 2.9.5
+ */
+ wxDocument* FindDocumentByPath(const wxString& path) const;
+
/**
Closes the specified document.
win->Raise();
}
+wxDocument* wxDocManager::FindDocumentByPath(const wxString& path) const
+{
+ const wxFileName fileName(path);
+ for ( wxList::const_iterator i = m_docs.begin(); i != m_docs.end(); ++i )
+ {
+ wxDocument * const doc = wxStaticCast(*i, wxDocument);
+
+ if ( fileName == wxFileName(doc->GetFilename()) )
+ return doc;
+ }
+ return NULL;
+}
+
wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags)
{
// this ought to be const but SelectDocumentType/Path() are not
// check whether the document with this path is already opened
if ( !path.empty() )
{
- const wxFileName fn(path);
- for ( wxList::const_iterator i = m_docs.begin(); i != m_docs.end(); ++i )
+ wxDocument * const doc = FindDocumentByPath(path);
+ if (doc)
{
- wxDocument * const doc = (wxDocument*)*i;
-
- if ( fn == doc->GetFilename() )
- {
- // file already open, just activate it and return
- doc->Activate();
- return doc;
- }
+ // file already open, just activate it and return
+ doc->Activate();
+ return doc;
}
}
-
// no, we need to create a new document