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
This commit is contained in:
Jaakko Salli
2008-10-06 15:48:27 +00:00
parent c26873c8ef
commit 5a45dd6fd9
5 changed files with 20 additions and 7 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -85,8 +85,6 @@ public:
wxSampleMultiButtonEditor() {}
virtual ~wxSampleMultiButtonEditor() {}
virtual wxString GetName() const { return "SampleMultiButtonEditor"; }
virtual wxPGWindowList CreateControls( wxPropertyGrid* propGrid,
wxPGProperty* property,
const wxPoint& pos,

View File

@@ -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() )

View File

@@ -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" );