X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8a337f95d82671e8f94809a49687d2c18d316e39..55410bb4f67febe1ca20654f078ea4fb9a6223ae:/src/propgrid/advprops.cpp diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 32eff3b0a7..1b9fa5ee16 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -108,6 +108,14 @@ bool operator == (const wxArrayInt& array1, const wxArrayInt& array2) #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. @@ -194,18 +202,23 @@ private: { 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; + } } } @@ -217,6 +230,8 @@ private: } }; +#endif // IS_MOTION_SPIN_SUPPORTED + WX_PG_IMPLEMENT_INTERNAL_EDITOR_CLASS(SpinCtrl, wxPGSpinCtrlEditor, @@ -240,7 +255,16 @@ wxPGWindowList wxPGSpinCtrlEditor::CreateControls( wxPropertyGrid* propgrid, wxP 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(); @@ -291,11 +315,16 @@ bool wxPGSpinCtrlEditor::OnEvent( wxPropertyGrid* propgrid, wxPGProperty* proper 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 @@ -428,7 +457,7 @@ wxPGWindowList wxPGDatePickerCtrlEditor::CreateControls( wxPropertyGrid* propgri 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(); @@ -461,14 +490,18 @@ wxPGWindowList wxPGDatePickerCtrlEditor::CreateControls( wxPropertyGrid* propgri } // 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 @@ -493,11 +526,20 @@ bool wxPGDatePickerCtrlEditor::GetValueFromControl( wxVariant& variant, wxPGProp 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 @@ -1381,8 +1423,6 @@ bool wxSystemColourProperty::DoSetAttribute( const wxString& name, wxVariant& va { 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 @@ -1714,8 +1754,8 @@ wxImageFileProperty::wxImageFileProperty( const wxString& label, const wxString& { SetAttribute( wxPG_FILE_WILDCARD, wxPGGetDefaultImageWildcard() ); - m_pImage = (wxImage*) NULL; - m_pBitmap = (wxBitmap*) NULL; + m_pImage = NULL; + m_pBitmap = NULL; } wxImageFileProperty::~wxImageFileProperty() @@ -1875,7 +1915,8 @@ void wxMultiChoiceProperty::GenerateValueAsString( wxVariant& value, 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. @@ -2036,6 +2077,17 @@ wxDateProperty::~wxDateProperty() { } +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 {