Add wxDocManager::Get{Views,Documents,Templates}Vector().
Add accessors returning more convenient wxVectors to supplement the existing ones giving access to internally used wxLists. Closes #14814. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73004 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -687,6 +687,7 @@ All (GUI):
|
||||
- Added support for Korean Johab and Vietnamese encodings (jank9201).
|
||||
- Fix off by 1 bug with setting font size in points in wxHTML (gevorg).
|
||||
- Fix return value of wxGenericListCtrl::InsertColumn() (Sebastian Walderich).
|
||||
- Add wxDocManager::Get{Views,Documents,Templates}Vector() (troelsk).
|
||||
|
||||
GTK:
|
||||
|
||||
|
@@ -60,6 +60,12 @@ enum
|
||||
|
||||
#define wxMAX_FILE_HISTORY 9
|
||||
|
||||
#ifndef __VISUALC6__
|
||||
typedef wxVector<wxDocument*> wxDocVector;
|
||||
typedef wxVector<wxView*> wxViewVector;
|
||||
typedef wxVector<wxDocTemplate*> wxDocTemplateVector;
|
||||
#endif
|
||||
|
||||
class WXDLLIMPEXP_CORE wxDocument : public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
@@ -140,8 +146,13 @@ public:
|
||||
|
||||
virtual bool AddView(wxView *view);
|
||||
virtual bool RemoveView(wxView *view);
|
||||
|
||||
#ifndef __VISUALC6__
|
||||
wxViewVector GetViewsVector() const { return m_documentViews.AsVector<wxView*>(); }
|
||||
#endif
|
||||
wxList& GetViews() { return m_documentViews; }
|
||||
const wxList& GetViews() const { return m_documentViews; }
|
||||
|
||||
wxView *GetFirstView() const;
|
||||
|
||||
virtual void UpdateAllViews(wxView *sender = NULL, wxObject *hint = NULL);
|
||||
@@ -455,6 +466,10 @@ public:
|
||||
virtual void ActivateView(wxView *view, bool activate = true);
|
||||
virtual wxView *GetCurrentView() const { return m_currentView; }
|
||||
|
||||
#ifndef __VISUALC6__
|
||||
wxDocVector GetDocumentsVector() const { return m_docs.AsVector<wxDocument*>(); }
|
||||
wxDocTemplateVector GetTemplatesVector() const { return m_templates.AsVector<wxDocTemplate*>(); }
|
||||
#endif
|
||||
wxList& GetDocuments() { return m_docs; }
|
||||
wxList& GetTemplates() { return m_templates; }
|
||||
|
||||
|
@@ -6,6 +6,27 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
A vector of wxDocument pointers.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
typedef wxVector<wxDocument*> wxDocVector;
|
||||
|
||||
/**
|
||||
A vector of wxView pointers.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
typedef wxVector<wxView*> wxViewVector;
|
||||
|
||||
/**
|
||||
A vector of wxDocTemplate pointers.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
typedef wxVector<wxDocTemplate*> wxDocTemplateVector;
|
||||
|
||||
/**
|
||||
@class wxDocTemplate
|
||||
|
||||
@@ -534,6 +555,20 @@ public:
|
||||
*/
|
||||
virtual wxView* GetCurrentView() const;
|
||||
|
||||
/**
|
||||
Returns a vector of wxDocument pointers.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
wxDocVector GetDocumentsVector() const;
|
||||
|
||||
/**
|
||||
Returns a vector of wxDocTemplate pointers.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
wxDocTemplateVector GetTemplatesVector() const;
|
||||
|
||||
/**
|
||||
Returns a reference to the list of documents.
|
||||
*/
|
||||
@@ -1299,6 +1334,13 @@ public:
|
||||
*/
|
||||
virtual wxString GetUserReadableName() const;
|
||||
|
||||
/**
|
||||
Returns a vector of wxView pointers.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
wxViewVector GetViewsVector() const;
|
||||
|
||||
//@{
|
||||
/**
|
||||
Returns the list whose elements are the views on the document.
|
||||
|
@@ -385,16 +385,19 @@ void MyApp::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
default:
|
||||
wxFAIL_MSG( "unknown mode ");
|
||||
}
|
||||
const wxDocVector
|
||||
docList = wxDocManager::GetDocumentManager()->GetDocumentsVector();
|
||||
|
||||
wxLogMessage
|
||||
(
|
||||
"This is the wxWidgets Document/View Sample\n"
|
||||
"running in %s mode.\n"
|
||||
"%d open documents.\n"
|
||||
"\n"
|
||||
"Authors: Julian Smart, Vadim Zeitlin\n"
|
||||
"\n"
|
||||
"Usage: docview [--{mdi,sdi,single}]",
|
||||
modeName
|
||||
modeName,
|
||||
static_cast<int>(docList.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -76,8 +76,6 @@
|
||||
#include "wx/wfstream.h"
|
||||
#endif
|
||||
|
||||
typedef wxVector<wxDocTemplate *> wxDocTemplates;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWidgets macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -1384,11 +1382,11 @@ namespace
|
||||
{
|
||||
|
||||
// helper function: return only the visible templates
|
||||
wxDocTemplates GetVisibleTemplates(const wxList& allTemplates)
|
||||
wxDocTemplateVector GetVisibleTemplates(const wxList& allTemplates)
|
||||
{
|
||||
// select only the visible templates
|
||||
const size_t totalNumTemplates = allTemplates.GetCount();
|
||||
wxDocTemplates templates;
|
||||
wxDocTemplateVector templates;
|
||||
if ( totalNumTemplates )
|
||||
{
|
||||
templates.reserve(totalNumTemplates);
|
||||
@@ -1425,7 +1423,7 @@ wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags)
|
||||
// this ought to be const but SelectDocumentType/Path() are not
|
||||
// const-correct and can't be changed as, being virtual, this risks
|
||||
// breaking user code overriding them
|
||||
wxDocTemplates templates(GetVisibleTemplates(m_templates));
|
||||
wxDocTemplateVector templates(GetVisibleTemplates(m_templates));
|
||||
const size_t numTemplates = templates.size();
|
||||
if ( !numTemplates )
|
||||
{
|
||||
@@ -1532,7 +1530,7 @@ wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags)
|
||||
|
||||
wxView *wxDocManager::CreateView(wxDocument *doc, long flags)
|
||||
{
|
||||
wxDocTemplates templates(GetVisibleTemplates(m_templates));
|
||||
wxDocTemplateVector templates(GetVisibleTemplates(m_templates));
|
||||
const size_t numTemplates = templates.size();
|
||||
|
||||
if ( numTemplates == 0 )
|
||||
|
Reference in New Issue
Block a user