]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/advprops.cpp
fix wxGTK1 compilation after wxTextEntry DoGetValue() change
[wxWidgets.git] / src / propgrid / advprops.cpp
index 32eff3b0a79294f5cf93beb07c0e791e1115d30a..1b9fa5ee16c03e8fddfd4c76ce22ba95c38215fb 100644 (file)
@@ -108,6 +108,14 @@ bool operator == (const wxArrayInt& array1, const wxArrayInt& array2)
 #if wxUSE_SPINBTN
 
 
 #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.
 //
 // 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 )
             {
         {
             if ( m_bLeftDown )
             {
-                Capture();
                 int dy = m_ptPosition.y - event.GetPosition().y;
                 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,
 
 WX_PG_IMPLEMENT_INTERNAL_EDITOR_CLASS(SpinCtrl,
                                       wxPGSpinCtrlEditor,
@@ -240,7 +255,16 @@ wxPGWindowList wxPGSpinCtrlEditor::CreateControls( wxPropertyGrid* propgrid, wxP
 
     wxSpinButton* wnd2;
 
 
     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();
 
 #ifdef __WXMSW__
     wnd2->Hide();
@@ -291,11 +315,16 @@ bool wxPGSpinCtrlEditor::OnEvent( wxPropertyGrid* propgrid, wxPGProperty* proper
 
     if ( evtType == wxEVT_SCROLL_LINEUP || evtType == wxEVT_SCROLL_LINEDOWN )
     {
 
     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
 
         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.") );
 
                  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();
 
     // 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
 }
 
 // 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)) );
 
 {
     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
 }
 
 // Control's events are redirected here
@@ -493,11 +526,20 @@ bool wxPGDatePickerCtrlEditor::GetValueFromControl( wxVariant& variant, wxPGProp
     return true;
 }
 
     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
 }
 
 #endif // wxUSE_DATEPICKCTRL
@@ -1381,8 +1423,6 @@ bool wxSystemColourProperty::DoSetAttribute( const wxString& name, wxVariant& va
     {
         int ival = wxPGVariantToInt(value);
 
     {
         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
         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() );
 
 {
     SetAttribute( wxPG_FILE_WILDCARD, wxPGGetDefaultImageWildcard() );
 
-    m_pImage = (wxImage*) NULL;
-    m_pBitmap = (wxBitmap*) NULL;
+    m_pImage = NULL;
+    m_pBitmap = NULL;
 }
 
 wxImageFileProperty::~wxImageFileProperty()
 }
 
 wxImageFileProperty::~wxImageFileProperty()
@@ -1875,7 +1915,8 @@ void wxMultiChoiceProperty::GenerateValueAsString( wxVariant& value,
 
 wxArrayInt wxMultiChoiceProperty::GetValueAsIndices() const
 {
 
 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.
     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
 {
 bool wxDateProperty::StringToValue( wxVariant& variant, const wxString& text,
                                     int WXUNUSED(argFlags) ) const
 {