I looked at some source code here:
\src\plugins\contrib\wxSmith\wxwidgets\properties\wxscolourproperty.cpp
I see some function get override, such as:
// This is based on the code of wxSystemColourProperty in advprops.h|cpp of wxPropertyGrid
class wxsMyColourPropertyClass : public wxEnumProperty
{
WX_PG_DECLARE_PROPERTY_CLASS(wxsMyColourPropertyClass)
public:
wxsMyColourPropertyClass( const wxString& label = wxEmptyString,
const wxString& name = wxPG_LABEL,
const wxColourPropertyValue& value = wxColourPropertyValue(wxsCOLOUR_DEFAULT,*wxWHITE) );
~wxsMyColourPropertyClass();
virtual void OnSetValue();
virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
/** Override in derived class to customize how colours are printed as strings.
*/
virtual wxString ColourToString( const wxColour& col, int index, int argFlags = 0 ) const;
/** Returns index of entry that triggers colour picker dialog
(default is last).
*/
virtual int GetCustomColourIndex() const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
Do you mean that we need to add a special function overloading here?
See here:
https://docs.wxwidgets.org/3.3/classwx_p_g_property.htmlI see VZ(wx developer) just close my issue, and he suggest that we need to override some functions myself.
Am I correct?
EDIT:See this code in
https://github.com/wxWidgets/wxWidgets/blob/master/src/propgrid/advprops.cpp#L1102C1-L1182C2#if WXWIN_COMPATIBILITY_3_2
// By call to obsolete function we want to check if user-overriden function is still in use
wxString wxSystemColourProperty::ColourToStringWithCheck(const wxColour& col, int index,
wxPGPropValFormatFlags flags) const
{
m_oldColourToStringCalled = false;
wxString res = ColourToString(col, index, static_cast<int>(flags));
if ( m_oldColourToStringCalled )
{
// Our own function was called - this implies that call was forwarded to the new overriding
// function and there is no need to call it explicitly.
}
else
{ // User-overriden obsolete function was called
wxFAIL_MSG(wxString::Format("in %s use ColourToString with 'flags' argument as wxPGPropValFormatFlags", GetClassInfo()->GetClassName()));
}
return res;
}
#endif // WXWIN_COMPATIBILITY_3_2
wxString wxSystemColourProperty::ColourToString( const wxColour& col,
int index,
wxPGPropValFormatFlags flags ) const
{
if ( index == wxNOT_FOUND )
{
if ( !!(flags & wxPGPropValFormatFlags::FullValue) || !!(m_flags & wxPGPropertyFlags_ColourHasAlpha) )
{
return wxString::Format(wxS("(%i,%i,%i,%i)"),
(int)col.Red(),
(int)col.Green(),
(int)col.Blue(),
(int)col.Alpha());
}
else
{
return wxString::Format(wxS("(%i,%i,%i)"),
(int)col.Red(),
(int)col.Green(),
(int)col.Blue());
}
}
else
{
return m_choices.GetLabel(index);
}
}
wxString wxSystemColourProperty::ValueToString( wxVariant& value,
wxPGPropValFormatFlags flags ) const
{
wxColourPropertyValue val = GetVal(&value);
int index;
if ( !!(flags & wxPGPropValFormatFlags::ValueIsCurrent) )
{
// GetIndex() only works reliably if wxPGPropValFormatFlags::ValueIsCurrent flag is set,
// but we should use it whenever possible.
index = GetIndex();
// If custom colour was selected, use invalid index, so that
// ColourToString() will return properly formatted colour text.
if ( index == GetCustomColourIndex() &&
!(m_flags & wxPGPropertyFlags_HideCustomColour) )
index = wxNOT_FOUND;
}
else
{
index = m_choices.Index(val.m_type);
}
#if WXWIN_COMPATIBILITY_3_2
// Special implementation with check if user-overriden obsolete function is still in use
return ColourToStringWithCheck(val.m_colour, index, flags);
#else
return ColourToString(val.m_colour, index, flags);
#endif // WXWIN_COMPATIBILITY_3_2 | !WXWIN_COMPATIBILITY_3_2
}
https://github.com/wxWidgets/wxWidgets/blob/8245e1073ae66fd246d2ec180160d2e20acf3644/interface/wx/propgrid/advprops.h#L92C1-L168C1This is the header file.