NULL,
wxT("DatePickerCtrl editor can only be used with wxDateProperty or derivative.") );
- wxDateProperty* prop = (wxDateProperty*) property;
+ wxDateProperty* prop = wxDynamicCast(property, wxDateProperty);
// Use two stage creation to allow cleaner display on wxMSW
wxDatePickerCtrl* ctrl = new wxDatePickerCtrl();
}
// Copies value from property to control
-void wxPGDatePickerCtrlEditor::UpdateControl( wxPGProperty* property, wxWindow* wnd ) const
+void wxPGDatePickerCtrlEditor::UpdateControl( wxPGProperty* property,
+ wxWindow* wnd ) const
{
wxDatePickerCtrl* ctrl = (wxDatePickerCtrl*) wnd;
wxASSERT( ctrl && ctrl->IsKindOf(CLASSINFO(wxDatePickerCtrl)) );
- // We assume that property's data type is 'int' (or something similar),
- // thus allowing us to get raw, unchecked value via DoGetValue.
- ctrl->SetValue( property->GetValue().GetDateTime() );
+ wxDateTime dateValue(wxInvalidDateTime);
+ wxVariant v(property->GetValue());
+ if ( v.GetType() == wxT("datetime") )
+ dateValue = v.GetDateTime();
+
+ ctrl->SetValue( dateValue );
}
// Control's events are redirected here
return true;
}
-void wxPGDatePickerCtrlEditor::SetValueToUnspecified( wxPGProperty* WXUNUSED(property), wxWindow* WXUNUSED(wnd) ) const
+void wxPGDatePickerCtrlEditor::SetValueToUnspecified( wxPGProperty* property,
+ wxWindow* wnd ) const
{
- // TODO?
- //wxDateProperty* prop = (wxDateProperty*) property;
- //ctrl->SetValue(?);
+ wxDatePickerCtrl* ctrl = (wxDatePickerCtrl*) wnd;
+ wxASSERT( ctrl && ctrl->IsKindOf(CLASSINFO(wxDatePickerCtrl)) );
+
+ wxDateProperty* prop = wxDynamicCast(property, wxDateProperty);
+
+ if ( prop )
+ {
+ int datePickerStyle = prop->GetDatePickerStyle();
+ if ( datePickerStyle & wxDP_ALLOWNONE )
+ ctrl->SetValue(wxInvalidDateTime);
+ }
}
#endif // wxUSE_DATEPICKCTRL
wxFont font;
font << m_value;
- SetParentalType(wxPG_PROP_AGGREGATE);
+ AddPrivateChild( new wxIntProperty( _("Point Size"),
+ wxS("Point Size"),(long)font.GetPointSize() ) );
- AddChild( new wxIntProperty( _("Point Size"), wxS("Point Size"),(long)font.GetPointSize() ) );
-
- AddChild( new wxEnumProperty(_("Family"), wxS("PointSize"),
- gs_fp_es_family_labels,gs_fp_es_family_values,
- font.GetFamily()) );
+ AddPrivateChild( new wxEnumProperty(_("Family"), wxS("PointSize"),
+ gs_fp_es_family_labels,gs_fp_es_family_values,
+ font.GetFamily()) );
wxString faceName = font.GetFaceName();
// If font was not in there, add it now
p->SetValueFromString(faceName, wxPG_FULL_VALUE);
- AddChild( p );
+ AddPrivateChild( p );
- AddChild( new wxEnumProperty(_("Style"), wxS("Style"),
- gs_fp_es_style_labels,gs_fp_es_style_values,font.GetStyle()) );
+ AddPrivateChild( new wxEnumProperty(_("Style"), wxS("Style"),
+ gs_fp_es_style_labels,gs_fp_es_style_values,
+ font.GetStyle()) );
- AddChild( new wxEnumProperty(_("Weight"), wxS("Weight"),
- gs_fp_es_weight_labels,gs_fp_es_weight_values,font.GetWeight()) );
+ AddPrivateChild( new wxEnumProperty(_("Weight"), wxS("Weight"),
+ gs_fp_es_weight_labels,gs_fp_es_weight_values,
+ font.GetWeight()) );
- AddChild( new wxBoolProperty(_("Underlined"), wxS("Underlined"),
- font.GetUnderlined()) );
+ AddPrivateChild( new wxBoolProperty(_("Underlined"), wxS("Underlined"),
+ font.GetUnderlined()) );
}
wxFontProperty::~wxFontProperty() { }
{
int ival = wxPGVariantToInt(value);
- SetChoicesExclusive(); // Make sure we don't corrupt colour lists of other properties
-
if ( ival && (m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
{
// Show custom choice
{
SetAttribute( wxPG_FILE_WILDCARD, wxPGGetDefaultImageWildcard() );
- m_pImage = (wxImage*) NULL;
- m_pBitmap = (wxBitmap*) NULL;
+ m_pImage = NULL;
+ m_pBitmap = NULL;
}
wxImageFileProperty::~wxImageFileProperty()
wxArrayInt wxMultiChoiceProperty::GetValueAsIndices() const
{
- const wxArrayInt& valueArr = wxArrayIntRefFromVariant(GetValue());
+ wxVariant variant = GetValue();
+ const wxArrayInt& valueArr = wxArrayIntRefFromVariant(variant);
unsigned int i;
// Translate values to string indices.
{
}
+void wxDateProperty::OnSetValue()
+{
+ //
+ // Convert invalid dates to unspecified value
+ if ( m_value.GetType() == wxT("datetime") )
+ {
+ if ( !m_value.GetDateTime().IsValid() )
+ m_value.MakeNull();
+ }
+}
+
bool wxDateProperty::StringToValue( wxVariant& variant, const wxString& text,
int WXUNUSED(argFlags) ) const
{
wxDateTime dt;
- const char* c = dt.ParseFormat(text, wxString(wxDefaultDateTimeFormat), wxDefaultDateTime, NULL);
+ // FIXME: do we really want to return true from here if only part of the
+ // string was parsed?
+ const char* c = dt.ParseFormat(text);
if ( c )
{