#if wxUSE_SPINBTN
+#ifdef __WXMSW__
+ #define IS_MOTION_SPIN_SUPPORTED 1
+#else
+ #define IS_MOTION_SPIN_SUPPORTED 0
+#endif
+
+#if IS_MOTION_SPIN_SUPPORTED
+
//
// This class implements ability to rapidly change "spin" value
// by moving mouse when one of the spin buttons is depressed.
{
if ( m_bLeftDown )
{
- Capture();
int dy = m_ptPosition.y - event.GetPosition().y;
- m_ptPosition = event.GetPosition();
-
- wxSpinEvent evtscroll( (dy >= 0) ? wxEVT_SCROLL_LINEUP :
- wxEVT_SCROLL_LINEDOWN,
- GetId() );
- evtscroll.SetEventObject(this);
-
- m_spins = abs(dy);
- GetEventHandler()->ProcessEvent(evtscroll);
- m_spins = 1;
+ if ( dy )
+ {
+ Capture();
+ m_ptPosition = event.GetPosition();
+
+ wxSpinEvent evtscroll( (dy >= 0) ? wxEVT_SCROLL_LINEUP :
+ wxEVT_SCROLL_LINEDOWN,
+ GetId() );
+ evtscroll.SetEventObject(this);
+
+ wxASSERT( m_spins == 1 );
+
+ m_spins = abs(dy);
+ GetEventHandler()->ProcessEvent(evtscroll);
+ m_spins = 1;
+ }
}
}
}
};
+#endif // IS_MOTION_SPIN_SUPPORTED
+
WX_PG_IMPLEMENT_INTERNAL_EDITOR_CLASS(SpinCtrl,
wxPGSpinCtrlEditor,
wxSpinButton* wnd2;
- wnd2 = new wxPGSpinButton();
+#if IS_MOTION_SPIN_SUPPORTED
+ if ( property->GetAttributeAsLong(wxT("MotionSpin"), 0) )
+ {
+ wnd2 = new wxPGSpinButton();
+ }
+ else
+#endif
+ {
+ wnd2 = new wxSpinButton();
+ }
#ifdef __WXMSW__
wnd2->Hide();
if ( evtType == wxEVT_SCROLL_LINEUP || evtType == wxEVT_SCROLL_LINEDOWN )
{
- wxPGSpinButton* spinButton =
- (wxPGSpinButton*) propgrid->GetEditorControlSecondary();
+ #if IS_MOTION_SPIN_SUPPORTED
+ if ( property->GetAttributeAsLong(wxT("MotionSpin"), 0) )
+ {
+ wxPGSpinButton* spinButton =
+ (wxPGSpinButton*) propgrid->GetEditorControlSecondary();
- if ( spinButton )
- spins = spinButton->GetSpins();
+ if ( spinButton )
+ spins = spinButton->GetSpins();
+ }
+ #endif
wxString s;
// Can't use wnd since it might be clipper window
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
{
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
{