mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-23 14:45:04 +08:00
Execute automated tests for wxPropertyGrid
Move existing manually executed tests in propgrid sample to the test suite executed automatically.
This commit is contained in:
@@ -656,3 +656,67 @@ bool wxArrayDoubleProperty::ValidateValue(wxVariant& value,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// MyColourProperty
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Test customizing wxColourProperty via subclassing
|
||||
// * Includes custom colour entry.
|
||||
// * Includes extra custom entry.
|
||||
MyColourProperty::MyColourProperty(const wxString& label,
|
||||
const wxString& name,
|
||||
const wxColour& value)
|
||||
: wxColourProperty(label, name, value)
|
||||
{
|
||||
wxPGChoices colours;
|
||||
colours.Add("White");
|
||||
colours.Add("Black");
|
||||
colours.Add("Red");
|
||||
colours.Add("Green");
|
||||
colours.Add("Blue");
|
||||
colours.Add("Custom");
|
||||
colours.Add("None");
|
||||
m_choices = colours;
|
||||
SetIndex(0);
|
||||
wxVariant variant;
|
||||
variant << value;
|
||||
SetValue(variant);
|
||||
}
|
||||
|
||||
wxColour MyColourProperty::GetColour(int index) const
|
||||
{
|
||||
switch ( index )
|
||||
{
|
||||
case 0: return *wxWHITE;
|
||||
case 1: return *wxBLACK;
|
||||
case 2: return *wxRED;
|
||||
case 3: return *wxGREEN;
|
||||
case 4: return *wxBLUE;
|
||||
case 5:
|
||||
// Return current colour for the custom entry
|
||||
wxColour col;
|
||||
if ( GetIndex() == GetCustomColourIndex() )
|
||||
{
|
||||
if ( m_value.IsNull() )
|
||||
return col;
|
||||
col << m_value;
|
||||
return col;
|
||||
}
|
||||
return *wxWHITE;
|
||||
}
|
||||
return wxColour();
|
||||
}
|
||||
|
||||
wxString MyColourProperty::ColourToString(const wxColour& col, int index, int argFlags) const
|
||||
{
|
||||
if ( index == (int)(m_choices.GetCount() - 1) )
|
||||
return wxEmptyString;
|
||||
|
||||
return wxColourProperty::ColourToString(col, index, argFlags);
|
||||
}
|
||||
|
||||
int MyColourProperty::GetCustomColourIndex() const
|
||||
{
|
||||
return m_choices.GetCount() - 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user