From 5a45dd6fd9870de6b68eff437fd5fe4ea5895c3c Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Mon, 6 Oct 2008 15:48:27 +0000 Subject: [PATCH] When registering editor, try wxRTTI class name in additon to result of wxPGEditor::GetName(). Allows creating custom editors without needing to implement GetName(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56128 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/editors.h | 7 ++++--- interface/wx/propgrid/editors.h | 6 ++++-- samples/propgrid/propgrid.cpp | 2 -- src/propgrid/editors.cpp | 5 +++++ src/propgrid/propgrid.cpp | 7 +++++++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/wx/propgrid/editors.h b/include/wx/propgrid/editors.h index d9d6b0729d..fc2ffe4259 100644 --- a/include/wx/propgrid/editors.h +++ b/include/wx/propgrid/editors.h @@ -92,10 +92,11 @@ public: /** Returns pointer to the name of the editor. For example, - wxPGEditor_TextCtrl has name "TextCtrl". This method is autogenerated - for custom editors. + wxPGEditor_TextCtrl has name "TextCtrl". If you dont' need to access + your custom editor by string name, then you do not need to implement + this function. */ - virtual wxString GetName() const = 0; + virtual wxString GetName() const; /** Instantiates editor controls. diff --git a/interface/wx/propgrid/editors.h b/interface/wx/propgrid/editors.h index 173d8e414e..1b9ff42267 100644 --- a/interface/wx/propgrid/editors.h +++ b/interface/wx/propgrid/editors.h @@ -51,9 +51,11 @@ public: /** Returns pointer to the name of the editor. For example, - wxPGEditor_TextCtrl has name "TextCtrl". + wxPGEditor_TextCtrl has name "TextCtrl". If you dont' need to access + your custom editor by string name, then you do not need to implement + this function. */ - virtual wxString GetName() const = 0; + virtual wxString GetName() const; /** Instantiates editor controls. diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index 1eda4866e6..26dbfd835d 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -85,8 +85,6 @@ public: wxSampleMultiButtonEditor() {} virtual ~wxSampleMultiButtonEditor() {} - virtual wxString GetName() const { return "SampleMultiButtonEditor"; } - virtual wxPGWindowList CreateControls( wxPropertyGrid* propGrid, wxPGProperty* property, const wxPoint& pos, diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index 2f0f236f8e..087d92324e 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -162,6 +162,11 @@ wxPGEditor::~wxPGEditor() { } +wxString wxPGEditor::GetName() const +{ + return GetClassInfo()->GetClassName(); +} + void wxPGEditor::DrawValue( wxDC& dc, const wxRect& rect, wxPGProperty* property, const wxString& text ) const { if ( !property->IsValueUnspecified() ) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index a21748944e..e8f7b7b293 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -5335,6 +5335,13 @@ wxPGEditor* wxPropertyGrid::RegisterEditorClass( wxPGEditor* editorClass, // Existing editor under this name? wxPGHashMapS2P::iterator vt_it = wxPGGlobalVars->m_mapEditorClasses.find(name); + if ( vt_it != wxPGGlobalVars->m_mapEditorClasses.end() ) + { + // If this name was already used, try class name. + name = editorClass->GetClassInfo()->GetClassName(); + vt_it = wxPGGlobalVars->m_mapEditorClasses.find(name); + } + wxCHECK_MSG( vt_it == wxPGGlobalVars->m_mapEditorClasses.end(), (wxPGEditor*) vt_it->second, "Editor with given name was already registered" ); -- 2.45.2