Update wxFontDataProperty to conform to the current design of wxPG properties with editor dialog
Since wxFontDataProperty derives from wxFontProperty, it should re-implement DisplayEditorDialog() to work as expected.
This commit is contained in:
parent
a3ec84fdd1
commit
30630d4ea5
@ -126,28 +126,25 @@ wxVariant wxFontDataProperty::DoGetValue() const
|
||||
return m_value_wxFontData;
|
||||
}
|
||||
|
||||
// Must re-create font dialog displayer.
|
||||
bool wxFontDataProperty::OnEvent( wxPropertyGrid* propgrid,
|
||||
wxWindow* WXUNUSED(primary), wxEvent& event )
|
||||
bool wxFontDataProperty::DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value)
|
||||
{
|
||||
if ( propgrid->IsMainButtonEvent(event) )
|
||||
wxASSERT_MSG(value.IsType(wxS("wxFontData")), "Function called for incompatible property");
|
||||
|
||||
wxFontData fontData;
|
||||
fontData << value;
|
||||
|
||||
fontData.SetInitialFont(fontData.GetChosenFont());
|
||||
|
||||
wxFontDialog dlg(pg->GetPanel(), fontData);
|
||||
if ( !m_dlgTitle.empty() )
|
||||
{
|
||||
wxVariant useValue = propgrid->GetUncommittedPropertyValue();
|
||||
dlg.SetTitle(m_dlgTitle);
|
||||
}
|
||||
|
||||
wxFontData fontData;
|
||||
fontData << useValue;
|
||||
|
||||
fontData.SetInitialFont(fontData.GetChosenFont());
|
||||
|
||||
wxFontDialog dlg(propgrid, fontData);
|
||||
|
||||
if ( dlg.ShowModal() == wxID_OK )
|
||||
{
|
||||
wxVariant variant;
|
||||
variant << dlg.GetFontData();
|
||||
SetValueInEvent( variant );
|
||||
return true;
|
||||
}
|
||||
if ( dlg.ShowModal() == wxID_OK )
|
||||
{
|
||||
value << dlg.GetFontData();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -38,9 +38,10 @@ public:
|
||||
int childIndex,
|
||||
wxVariant& childValue ) const wxOVERRIDE;
|
||||
virtual void RefreshChildren() wxOVERRIDE;
|
||||
virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ) wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
|
||||
|
||||
// Value must be stored as variant - otherwise it will be
|
||||
// decreffed to oblivion on GetValue().
|
||||
wxVariant m_value_wxFontData;
|
||||
|
Loading…
Reference in New Issue
Block a user