]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/spinctrl.cpp
Minor header cleaning.
[wxWidgets.git] / src / msw / spinctrl.cpp
index 58673b0e3b38931d4213247b5da8eb40f459a7b2..14bdda9ae059d05c6383ceaf83cd907167e1c246 100644 (file)
@@ -267,6 +267,20 @@ void wxSpinCtrl::OnSetFocus(wxFocusEvent& event)
     event.Skip();
 }
 
     event.Skip();
 }
 
+void wxSpinCtrl::NormalizeValue()
+{
+    int value = GetValue();
+    SetValue( value );
+    if (value != m_oldValue)
+    {
+        wxCommandEvent event( wxEVT_COMMAND_SPINCTRL_UPDATED, GetId() );
+        event.SetEventObject( this );
+        event.SetInt( value );
+        GetEventHandler()->ProcessEvent( event );
+        m_oldValue = value;
+    }
+}
+
 // ----------------------------------------------------------------------------
 // construction
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // construction
 // ----------------------------------------------------------------------------
@@ -354,6 +368,8 @@ bool wxSpinCtrl::Create(wxWindow *parent,
 
     SetRange(min, max);
     SetValue(initial);
 
     SetRange(min, max);
     SetValue(initial);
+    
+    m_oldValue = initial;
 
     // subclass the text ctrl to be able to intercept some events
     wxSetWindowUserData(GetBuddyHwnd(), this);
 
     // subclass the text ctrl to be able to intercept some events
     wxSetWindowUserData(GetBuddyHwnd(), this);
@@ -433,6 +449,8 @@ void  wxSpinCtrl::SetValue(int val)
         // current value in the control, so do it manually
         ::SetWindowText(GetBuddyHwnd(), wxString::Format(_T("%d"), val));
     }
         // current value in the control, so do it manually
         ::SetWindowText(GetBuddyHwnd(), wxString::Format(_T("%d"), val));
     }
+    
+    m_oldValue = GetValue();
 }
 
 int wxSpinCtrl::GetValue() const
 }
 
 int wxSpinCtrl::GetValue() const
@@ -530,14 +548,18 @@ void wxSpinCtrl::OnSpinChange(wxSpinEvent& eventSpin)
 {
     wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, GetId());
     event.SetEventObject(this);
 {
     wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, GetId());
     event.SetEventObject(this);
-    event.SetInt(eventSpin.GetPosition());
-
-    (void)GetEventHandler()->ProcessEvent(event);
+    int value = eventSpin.GetPosition();
+    event.SetInt( value );
+    
+    if (value != m_oldValue)
+        (void)GetEventHandler()->ProcessEvent(event);
 
     if ( eventSpin.GetSkipped() )
     {
         event.Skip();
     }
 
     if ( eventSpin.GetSkipped() )
     {
         event.Skip();
     }
+    
+    m_oldValue = value;
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------