]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/slider95.cpp
Fix for [1250089] 'wxHtmlHelpFrame uses constants instead of variables'.
[wxWidgets.git] / src / msw / slider95.cpp
index 7efe6d803d66d003162243c1e7247541af6e07bc..f6ce131dfcff3be148998d87188fab7a0ec09d46 100644 (file)
@@ -42,8 +42,6 @@
     #include <commctrl.h>
 #endif
 
-#define USE_DEFERRED_SIZING 1
-
 // ----------------------------------------------------------------------------
 // constants
 // ----------------------------------------------------------------------------
@@ -112,7 +110,7 @@ wxEND_FLAGS( wxSliderStyle )
 IMPLEMENT_DYNAMIC_CLASS_XTI(wxSlider, wxControl,"wx/scrolbar.h")
 
 wxBEGIN_PROPERTIES_TABLE(wxSlider)
-    wxEVENT_RANGE_PROPERTY( Scroll , wxEVT_SCROLL_TOP , wxEVT_SCROLL_ENDSCROLL , wxScrollEvent )
+    wxEVENT_RANGE_PROPERTY( Scroll , wxEVT_SCROLL_TOP , wxEVT_SCROLL_CHANGED , wxScrollEvent )
     wxEVENT_PROPERTY( Updated , wxEVT_COMMAND_SLIDER_UPDATED , wxCommandEvent )
 
     wxPROPERTY( Value , int , SetValue, GetValue , 0, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
@@ -149,6 +147,8 @@ void wxSlider::Init()
     m_rangeMax = 0;
     m_rangeMin = 0;
     m_tickFreq = 0;
+
+    m_isDragging = false;
 }
 
 bool
@@ -188,7 +188,7 @@ wxSlider::Create(wxWindow *parent,
             }
     };
 
-    wxASSERT_MSG( !(style & wxSL_VERTICAL) | !(style & wxSL_HORIZONTAL),
+    wxASSERT_MSG( !(style & wxSL_VERTICAL) || !(style & wxSL_HORIZONTAL),
                     _T("incompatible slider direction and orientation") );
 
 
@@ -328,14 +328,29 @@ bool wxSlider::MSWOnScroll(int WXUNUSED(orientation),
 
         case SB_THUMBTRACK:
             scrollEvent = wxEVT_SCROLL_THUMBTRACK;
+            m_isDragging = true;
             break;
 
         case SB_THUMBPOSITION:
-            scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
+            if ( m_isDragging )
+            {
+                scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
+                m_isDragging = false;
+            }
+            else
+            {
+                // this seems to only happen when the mouse wheel is used: in
+                // this case, as it might be unexpected to get THUMBRELEASE
+                // without preceding THUMBTRACKs, we don't generate it at all
+                // but generate CHANGED event because the control itself does
+                // not send us SB_ENDSCROLL for whatever reason when mouse
+                // wheel is used
+                scrollEvent = wxEVT_SCROLL_CHANGED;
+            }
             break;
 
         case SB_ENDSCROLL:
-            scrollEvent = wxEVT_SCROLL_ENDSCROLL;
+            scrollEvent = wxEVT_SCROLL_CHANGED;
             break;
 
         default:
@@ -443,16 +458,6 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
         return;
     }
 
-    // if our parent had prepared a defer window handle for us, use it (unless
-    // we are a top level window)
-    wxWindowMSW *parent = GetParent();
-
-#if USE_DEFERRED_SIZING
-    HDWP hdwp = parent && !IsTopLevel() ? (HDWP)parent->m_hDWP : NULL;
-#else
-    HDWP hdwp = 0;
-#endif    
-
     // be careful to position the slider itself after moving the labels as
     // otherwise our GetBoundingBox(), which is called from WM_SIZE handler,
     // would return a wrong result and wrong size would be cached internally
@@ -465,21 +470,20 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
 
         // position all labels: min at the top, value in the middle and max at
         // the bottom
-        wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Min],
+        DoMoveSibling((HWND)(*m_labels)[SliderLabel_Min],
                      xLabel, y, wLabel, hLabel);
 
-        wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Value],
+        DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
                      xLabel, y + (height - hLabel)/2, wLabel, hLabel);
 
-        wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Max],
-                     xLabel, y + height - hLabel, wLabel, hLabel);
+        DoMoveSibling((HWND)(*m_labels)[SliderLabel_Max],
+                      xLabel, y + height - hLabel, wLabel, hLabel);
 
         // position the slider itself along the left/right edge
-        wxMoveWindowDeferred(hdwp, this, GetHwnd(),
-                     HasFlag(wxSL_LEFT) ? x : x + wLabel + HGAP,
-                     y + hLabel/2,
-                     width - wLabel - HGAP,
-                     height - hLabel);
+        wxSliderBase::DoMoveWindow(HasFlag(wxSL_LEFT) ? x : x + wLabel + HGAP,
+                                   y + hLabel/2,
+                                   width - wLabel - HGAP,
+                                   height - hLabel);
     }
     else // horizontal
     {
@@ -490,37 +494,20 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
 
         // position all labels: min on the left, value in the middle and max to
         // the right
-        wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Min],
-                     x, yLabel, wLabel, hLabel);
+        DoMoveSibling((HWND)(*m_labels)[SliderLabel_Min],
+                      x, yLabel, wLabel, hLabel);
 
-        wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Value],
-                     x + (width - wLabel)/2, yLabel, wLabel, hLabel);
+        DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
+                      x + (width - wLabel)/2, yLabel, wLabel, hLabel);
 
-        wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Max],
-                     x + width - wLabel, yLabel, wLabel, hLabel);
+        DoMoveSibling((HWND)(*m_labels)[SliderLabel_Max],
+                      x + width - wLabel, yLabel, wLabel, hLabel);
 
         // position the slider itself along the top/bottom edge
-        wxMoveWindowDeferred(hdwp, this, GetHwnd(),
-                     x,
-                     HasFlag(wxSL_TOP) ? y : y + hLabel,
-                     width,
-                     height - hLabel);
-    }
-    if ( hdwp )
-    {
-        // Store the size so we can report it accurately
-        wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-        if (!extraData)
-        {
-            extraData = new wxExtraWindowData;
-            m_windowReserved = (void*) extraData;
-        }
-        extraData->m_pos = wxPoint(x, y);
-        extraData->m_size = wxSize(width, height);
-        extraData->m_deferring = true;
-
-        // hdwp must be updated as it may have been changed
-        parent->m_hDWP = (WXHANDLE)hdwp;
+        wxSliderBase::DoMoveWindow(x,
+                                   HasFlag(wxSL_TOP) ? y : y + hLabel,
+                                   width,
+                                   height - hLabel);
     }
 }
 
@@ -651,7 +638,7 @@ int wxSlider::GetLineSize() const
 
 int wxSlider::GetSelEnd() const
 {
-    return (int)::SendMessage(GetHwnd(), TBM_SETSELEND, 0, 0);
+    return (int)::SendMessage(GetHwnd(), TBM_GETSELEND, 0, 0);
 }
 
 int wxSlider::GetSelStart() const