]> git.saurik.com Git - wxWidgets.git/commitdiff
moved wxScrollBar geometry methods out of wxRenderer, they are common for all themes
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 30 Oct 2006 12:33:25 +0000 (12:33 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 30 Oct 2006 12:33:25 +0000 (12:33 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42716 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/univ/renderer.h
include/wx/univ/scrolbar.h
include/wx/univ/stdrend.h
src/univ/ctrlrend.cpp
src/univ/scrolbar.cpp
src/univ/stdrend.cpp
src/univ/themes/gtk.cpp
src/univ/themes/win32.cpp

index 225c71b9c6b70a340a7e2533274a0196366de968..446d11fd1edc182358808d2e017702f8ac23a305 100644 (file)
@@ -56,7 +56,6 @@ class WXDLLEXPORT wxScrollBar;
 #include "wx/string.h"
 #include "wx/gdicmn.h"
 #include "wx/icon.h"
-#include "wx/scrolbar.h"            // for wxScrollBar::Element
 
 // helper class used by wxMenu-related functions
 class WXDLLEXPORT wxMenuGeometryInfo
@@ -382,30 +381,8 @@ public:
     virtual void AdjustSize(wxSize *size, const wxWindow *window) = 0;
 
 #if wxUSE_SCROLLBAR
-
     // get the size of a scrollbar arrow
     virtual wxSize GetScrollbarArrowSize() const = 0;
-
-    // gets the bounding box for a scrollbar element for the given (by default
-    // - current) thumb position
-    virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
-                                    wxScrollBar::Element elem,
-                                    int thumbPos = -1) const = 0;
-
-    // returns the size of the scrollbar shaft excluding the arrows
-    virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar) = 0;
-
-    // returns one of wxHT_SCROLLBAR_XXX constants
-    virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
-                                       const wxPoint& pt) const = 0;
-
-    // translate the scrollbar position (in logical units) into physical
-    // coordinate (in pixels) and the other way round
-    virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
-                                     int thumbPos = -1) = 0;
-    virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
-                                 wxCoord coord) = 0;
-
 #endif // wxUSE_SCROLLBAR
 
     // get the height of a listbox item from the base font height
@@ -787,21 +764,6 @@ public:
 #if wxUSE_SCROLLBAR
     virtual wxSize GetScrollbarArrowSize() const
         { return m_renderer->GetScrollbarArrowSize(); }
-    virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
-                                    wxScrollBar::Element elem,
-                                    int thumbPos = -1) const
-        { return m_renderer->GetScrollbarRect(scrollbar, elem, thumbPos); }
-    virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar)
-        { return m_renderer->GetScrollbarSize(scrollbar); }
-    virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
-                                       const wxPoint& pt) const
-        { return m_renderer->HitTestScrollbar(scrollbar, pt); }
-    virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
-                                     int thumbPos = -1)
-        { return m_renderer->ScrollbarToPixel(scrollbar, thumbPos); }
-    virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
-                                 wxCoord coord)
-        { return m_renderer->PixelToScrollbar(scrollbar, coord); }
 #endif // wxUSE_SCROLLBAR
 
     virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
index b686eab5c01b9d862e220f2dd34beadec742106e..ec258c30e212262f4c5f54dec81bff9caa3f86a8 100644 (file)
@@ -121,6 +121,9 @@ public:
     // for wxControlRenderer::DrawScrollbar() only
     const wxScrollArrows& GetArrows() const { return m_arrows; }
 
+    // returns one of wxHT_SCROLLBAR_XXX constants
+    wxHitTest HitTestBar(const wxPoint& pt) const;
+
     // idle processing
     virtual void OnInternalIdle();
 
@@ -141,6 +144,30 @@ protected:
     // is this scrollbar attached to a window or a standalone control?
     bool IsStandalone() const;
 
+    // scrollbar geometry methods:
+
+    // gets the bounding box for a scrollbar element for the given (by default
+    // - current) thumb position
+    wxRect GetScrollbarRect(wxScrollBar::Element elem, int thumbPos = -1) const;
+
+    // returns the size of the scrollbar shaft excluding the arrows
+    wxCoord GetScrollbarSize() const;
+
+    // translate the scrollbar position (in logical units) into physical
+    // coordinate (in pixels) and the other way round
+    wxCoord ScrollbarToPixel(int thumbPos = -1);
+    int PixelToScrollbar(wxCoord coord);
+
+    // return the starting and ending positions, in pixels, of the thumb of a
+    // scrollbar with the given logical position, thumb size and range and the
+    // given physical length
+    static void GetScrollBarThumbSize(wxCoord length,
+                                      int thumbPos,
+                                      int thumbSize,
+                                      int range,
+                                      wxCoord *thumbStart,
+                                      wxCoord *thumbEnd);
+
 private:
     // total range of the scrollbar in logical units
     int m_range;
@@ -165,6 +192,9 @@ private:
     // the object handling the arrows
     wxScrollArrows m_arrows;
 
+    friend WXDLLEXPORT class wxControlRenderer; // for geometry methods
+    friend class wxStdScrollBarInputHandler; // for geometry methods
+
     DECLARE_EVENT_TABLE()
     DECLARE_DYNAMIC_CLASS(wxScrollBar)
 };
index 4fe5ab07faf826f3cd0dc49d883b700035eaa31c..80e53bff0a3b5eed61f8e35b70437c17b5797a62 100644 (file)
@@ -136,21 +136,6 @@ public:
 
     virtual wxCoord GetListboxItemHeight(wxCoord fontHeight);
 
-#if wxUSE_SCROLLBAR
-    virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
-                                    wxScrollBar::Element elem,
-                                    int thumbPos = -1) const;
-
-    virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
-
-    virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
-                                       const wxPoint& pt) const;
-
-    virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
-                                     int thumbPos = -1);
-    virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
-#endif // wxUSE_SCROLLBAR
-
 #if wxUSE_STATUSBAR
     virtual void DrawStatusField(wxDC& dc,
                                  const wxRect& rect,
@@ -349,16 +334,6 @@ protected:
     virtual int GetTextBorderWidth(const wxTextCtrl *text) const;
 #endif // wxUSE_TEXTCTRL
 
-    // return the starting and ending positions, in pixels, of the thumb of a
-    // scrollbar with the given logical position, thumb size and range and the
-    // given physical length
-    static void GetScrollBarThumbSize(wxCoord length,
-                                      int thumbPos,
-                                      int thumbSize,
-                                      int range,
-                                      wxCoord *thumbStart,
-                                      wxCoord *thumbEnd);
-
     // GDI objects we often use
     wxPen m_penBlack,
           m_penDarkGrey,
index b4a3cedd00a0e8b85292e9b17461143fa1f96678..765144be014ffbd6a14e0d6e0bf154c8d6f6cd7e 100644 (file)
@@ -243,7 +243,7 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
         wxScrollBar::Element elem =
             (wxScrollBar::Element)(wxScrollBar::Element_Bar_1 + nBar);
 
-        wxRect rectBar = m_renderer->GetScrollbarRect(scrollbar, elem);
+        wxRect rectBar = scrollbar->GetScrollbarRect(elem);
 
         if ( rgnUpdate.Contains(rectBar) )
         {
@@ -268,7 +268,7 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
         wxScrollBar::Element elem =
             (wxScrollBar::Element)(wxScrollBar::Element_Arrow_Line_1 + nArrow);
 
-        wxRect rectArrow = m_renderer->GetScrollbarRect(scrollbar, elem);
+        wxRect rectArrow = scrollbar->GetScrollbarRect(elem);
         if ( rgnUpdate.Contains(rectArrow) )
         {
             wxLogTrace(_T("scrollbar"),
@@ -293,7 +293,7 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
 
     // and the thumb
     wxScrollBar::Element elem = wxScrollBar::Element_Thumb;
-    wxRect rectThumb = m_renderer->GetScrollbarRect(scrollbar, elem);
+    wxRect rectThumb = scrollbar->GetScrollbarRect(elem);
     if ( rectThumb.width && rectThumb.height && rgnUpdate.Contains(rectThumb) )
     {
         wxLogTrace(_T("scrollbar"),
index e898958f94b5d38691349540243972e03db1d233..b5e1253f3dcc38df73050a3bb1d5ccd880afa2ae 100644 (file)
@@ -300,7 +300,7 @@ wxSize wxScrollBar::DoGetBestClientSize() const
 
 wxScrollArrows::Arrow wxScrollBar::HitTestArrow(const wxPoint& pt) const
 {
-    switch ( m_renderer->HitTestScrollbar(this, pt) )
+    switch ( HitTestBar(pt) )
     {
         case wxHT_SCROLLBAR_ARROW_LINE_1:
             return wxScrollArrows::Arrow_First;
@@ -313,6 +313,259 @@ wxScrollArrows::Arrow wxScrollBar::HitTestArrow(const wxPoint& pt) const
     }
 }
 
+wxHitTest wxScrollBar::HitTestBar(const wxPoint& pt) const
+{
+    // we only need to work with either x or y coord depending on the
+    // orientation, choose one (but still check the other one to verify if the
+    // mouse is in the window at all)
+    const wxSize sizeArrowSB = m_renderer->GetScrollbarArrowSize();
+
+    wxCoord coord, sizeArrow, sizeTotal;
+    wxSize size = GetSize();
+    if ( GetWindowStyle() & wxVERTICAL )
+    {
+        if ( pt.x < 0 || pt.x > size.x )
+            return wxHT_NOWHERE;
+
+        coord = pt.y;
+        sizeArrow = sizeArrowSB.y;
+        sizeTotal = size.y;
+    }
+    else // horizontal
+    {
+        if ( pt.y < 0 || pt.y > size.y )
+            return wxHT_NOWHERE;
+
+        coord = pt.x;
+        sizeArrow = sizeArrowSB.x;
+        sizeTotal = size.x;
+    }
+
+    // test for the arrows first as it's faster
+    if ( coord < 0 || coord > sizeTotal )
+    {
+        return wxHT_NOWHERE;
+    }
+    else if ( coord < sizeArrow )
+    {
+        return wxHT_SCROLLBAR_ARROW_LINE_1;
+    }
+    else if ( coord > sizeTotal - sizeArrow )
+    {
+        return wxHT_SCROLLBAR_ARROW_LINE_2;
+    }
+    else
+    {
+        // calculate the thumb position in pixels
+        sizeTotal -= 2*sizeArrow;
+        wxCoord thumbStart, thumbEnd;
+        int range = GetRange();
+        if ( !range )
+        {
+            // clicking the scrollbar without range has no effect
+            return wxHT_NOWHERE;
+        }
+        else
+        {
+            GetScrollBarThumbSize(sizeTotal,
+                                  GetThumbPosition(),
+                                  GetThumbSize(),
+                                  range,
+                                  &thumbStart,
+                                  &thumbEnd);
+        }
+
+        // now compare with the thumb position
+        coord -= sizeArrow;
+        if ( coord < thumbStart )
+            return wxHT_SCROLLBAR_BAR_1;
+        else if ( coord > thumbEnd )
+            return wxHT_SCROLLBAR_BAR_2;
+        else
+            return wxHT_SCROLLBAR_THUMB;
+    }
+}
+
+/* static */
+void wxScrollBar::GetScrollBarThumbSize(wxCoord length,
+                                        int thumbPos,
+                                        int thumbSize,
+                                        int range,
+                                        wxCoord *thumbStart,
+                                        wxCoord *thumbEnd)
+{
+    // the thumb can't be made less than this number of pixels
+    static const wxCoord thumbMinWidth = 8; // FIXME: should be configurable
+
+    *thumbStart = (length*thumbPos) / range;
+    *thumbEnd = (length*(thumbPos + thumbSize)) / range;
+
+    if ( *thumbEnd - *thumbStart < thumbMinWidth )
+    {
+        // adjust the end if possible
+        if ( *thumbStart <= length - thumbMinWidth )
+        {
+            // yes, just make it wider
+            *thumbEnd = *thumbStart + thumbMinWidth;
+        }
+        else // it is at the bottom of the scrollbar
+        {
+            // so move it a bit up
+            *thumbStart = length - thumbMinWidth;
+            *thumbEnd = length;
+        }
+    }
+}
+
+wxRect wxScrollBar::GetScrollbarRect(wxScrollBar::Element elem,
+                                     int thumbPos) const
+{
+    if ( thumbPos == -1 )
+    {
+        thumbPos = GetThumbPosition();
+    }
+
+    const wxSize sizeArrow = m_renderer->GetScrollbarArrowSize();
+
+    wxSize sizeTotal = GetClientSize();
+    wxCoord *start, *width;
+    wxCoord length, arrow;
+    wxRect rect;
+    if ( IsVertical() )
+    {
+        rect.x = 0;
+        rect.width = sizeTotal.x;
+        length = sizeTotal.y;
+        start = &rect.y;
+        width = &rect.height;
+        arrow = sizeArrow.y;
+    }
+    else // horizontal
+    {
+        rect.y = 0;
+        rect.height = sizeTotal.y;
+        length = sizeTotal.x;
+        start = &rect.x;
+        width = &rect.width;
+        arrow = sizeArrow.x;
+    }
+
+    switch ( elem )
+    {
+        case wxScrollBar::Element_Arrow_Line_1:
+            *start = 0;
+            *width = arrow;
+            break;
+
+        case wxScrollBar::Element_Arrow_Line_2:
+            *start = length - arrow;
+            *width = arrow;
+            break;
+
+        case wxScrollBar::Element_Arrow_Page_1:
+        case wxScrollBar::Element_Arrow_Page_2:
+            // we don't have them at all
+            break;
+
+        case wxScrollBar::Element_Thumb:
+        case wxScrollBar::Element_Bar_1:
+        case wxScrollBar::Element_Bar_2:
+            // we need to calculate the thumb position - do it
+            {
+                length -= 2*arrow;
+                wxCoord thumbStart, thumbEnd;
+                int range = GetRange();
+                if ( !range )
+                {
+                    thumbStart =
+                    thumbEnd = 0;
+                }
+                else
+                {
+                    GetScrollBarThumbSize(length,
+                                          thumbPos,
+                                          GetThumbSize(),
+                                          range,
+                                          &thumbStart,
+                                          &thumbEnd);
+                }
+
+                if ( elem == wxScrollBar::Element_Thumb )
+                {
+                    *start = thumbStart;
+                    *width = thumbEnd - thumbStart;
+                }
+                else if ( elem == wxScrollBar::Element_Bar_1 )
+                {
+                    *start = 0;
+                    *width = thumbStart;
+                }
+                else // elem == wxScrollBar::Element_Bar_2
+                {
+                    *start = thumbEnd;
+                    *width = length - thumbEnd;
+                }
+
+                // everything is relative to the start of the shaft so far
+                *start += arrow;
+            }
+            break;
+
+        case wxScrollBar::Element_Max:
+        default:
+            wxFAIL_MSG( _T("unknown scrollbar element") );
+    }
+
+    return rect;
+}
+
+wxCoord wxScrollBar::GetScrollbarSize() const
+{
+    const wxSize sizeArrowSB = m_renderer->GetScrollbarArrowSize();
+
+    wxCoord sizeArrow, sizeTotal;
+    if ( GetWindowStyle() & wxVERTICAL )
+    {
+        sizeArrow = sizeArrowSB.y;
+        sizeTotal = GetSize().y;
+    }
+    else // horizontal
+    {
+        sizeArrow = sizeArrowSB.x;
+        sizeTotal = GetSize().x;
+    }
+
+    return sizeTotal - 2*sizeArrow;
+}
+
+
+wxCoord wxScrollBar::ScrollbarToPixel(int thumbPos)
+{
+    int range = GetRange();
+    if ( !range )
+    {
+        // the only valid position anyhow
+        return 0;
+    }
+
+    if ( thumbPos == -1 )
+    {
+        // by default use the current thumb position
+        thumbPos = GetThumbPosition();
+    }
+
+    const wxSize sizeArrow = m_renderer->GetScrollbarArrowSize();
+    return (thumbPos * GetScrollbarSize()) / range
+             + (IsVertical() ? sizeArrow.y : sizeArrow.x);
+}
+
+int wxScrollBar::PixelToScrollbar(wxCoord coord)
+{
+    const wxSize sizeArrow = m_renderer->GetScrollbarArrowSize();
+    return ((coord - (IsVertical() ? sizeArrow.y : sizeArrow.x)) *
+               GetRange() ) / GetScrollbarSize();
+}
+
 // ----------------------------------------------------------------------------
 // drawing
 // ----------------------------------------------------------------------------
@@ -331,7 +584,7 @@ void wxScrollBar::UpdateThumb()
         {
             if ( m_elementsState[n] & wxCONTROL_DIRTY )
             {
-                wxRect rect = GetRenderer()->GetScrollbarRect(this, (Element)n);
+                wxRect rect = GetScrollbarRect((Element)n);
 
                 if ( rect.width && rect.height )
                 {
@@ -365,9 +618,7 @@ void wxScrollBar::UpdateThumb()
                         }
 #else                   // efficient version: only repaint the area occupied by
                         // the thumb previously - we can't do better than this
-                        rect = GetRenderer()->GetScrollbarRect(this,
-                                                               Element_Thumb,
-                                                               m_thumbPosOld);
+                        rect = GetScrollbarRect(Element_Thumb, m_thumbPosOld);
 #endif // 0/1
                     }
 
@@ -706,7 +957,7 @@ void wxStdScrollBarInputHandler::HandleThumbMove(wxScrollBar *scrollbar,
                                                  const wxMouseEvent& event)
 {
     int thumbPos = GetMouseCoord(scrollbar, event) - m_ofsMouse;
-    thumbPos = m_renderer->PixelToScrollbar(scrollbar, thumbPos);
+    thumbPos = scrollbar->PixelToScrollbar(thumbPos);
     scrollbar->PerformAction(wxACTION_SCROLL_THUMB_MOVE, thumbPos);
 }
 
@@ -750,11 +1001,7 @@ bool wxStdScrollBarInputHandler::HandleMouse(wxInputConsumer *consumer,
     {
         // determine which part of the window mouse is in
         wxScrollBar *scrollbar = wxStaticCast(consumer->GetInputWindow(), wxScrollBar);
-        wxHitTest ht = m_renderer->HitTestScrollbar
-                                   (
-                                    scrollbar,
-                                    event.GetPosition()
-                                   );
+        wxHitTest ht = scrollbar->HitTest(event.GetPosition());
 
         // when the mouse is pressed on any scrollbar element, we capture it
         // and hold capture until the same mouse button is released
@@ -792,7 +1039,7 @@ bool wxStdScrollBarInputHandler::HandleMouse(wxInputConsumer *consumer,
                     case wxHT_SCROLLBAR_THUMB:
                         consumer->PerformAction(wxACTION_SCROLL_THUMB_DRAG);
                         m_ofsMouse = GetMouseCoord(scrollbar, event) -
-                                     m_renderer->ScrollbarToPixel(scrollbar);
+                                     scrollbar->ScrollbarToPixel();
 
                         // fall through: there is no immediate action
 
@@ -875,11 +1122,7 @@ bool wxStdScrollBarInputHandler::HandleMouseMove(wxInputConsumer *consumer,
 
     if ( event.Dragging() )
     {
-        wxHitTest ht = m_renderer->HitTestScrollbar
-                                   (
-                                    scrollbar,
-                                    event.GetPosition()
-                                   );
+        wxHitTest ht = scrollbar->HitTestBar(event.GetPosition());
         if ( ht == m_htLast )
         {
             // nothing changed
index 5a78545902b1a7ffb56c8a223811e5e416e8950b..6d7040a705e6b190105c28a0f465cde50b6b95b2 100644 (file)
@@ -837,270 +837,6 @@ void wxStdRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
     DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
 }
 
-// ----------------------------------------------------------------------------
-// scrollbars geometry
-// ----------------------------------------------------------------------------
-
-#if wxUSE_SCROLLBAR
-
-/* static */
-void wxStdRenderer::GetScrollBarThumbSize(wxCoord length,
-                                          int thumbPos,
-                                          int thumbSize,
-                                          int range,
-                                          wxCoord *thumbStart,
-                                          wxCoord *thumbEnd)
-{
-    // the thumb can't be made less than this number of pixels
-    static const wxCoord thumbMinWidth = 8; // FIXME: should be configurable
-
-    *thumbStart = (length*thumbPos) / range;
-    *thumbEnd = (length*(thumbPos + thumbSize)) / range;
-
-    if ( *thumbEnd - *thumbStart < thumbMinWidth )
-    {
-        // adjust the end if possible
-        if ( *thumbStart <= length - thumbMinWidth )
-        {
-            // yes, just make it wider
-            *thumbEnd = *thumbStart + thumbMinWidth;
-        }
-        else // it is at the bottom of the scrollbar
-        {
-            // so move it a bit up
-            *thumbStart = length - thumbMinWidth;
-            *thumbEnd = length;
-        }
-    }
-}
-
-wxRect wxStdRenderer::GetScrollbarRect(const wxScrollBar *scrollbar,
-                                       wxScrollBar::Element elem,
-                                       int thumbPos) const
-{
-    if ( thumbPos == -1 )
-    {
-        thumbPos = scrollbar->GetThumbPosition();
-    }
-
-    const wxSize sizeArrow = GetScrollbarArrowSize();
-
-    wxSize sizeTotal = scrollbar->GetClientSize();
-    wxCoord *start, *width;
-    wxCoord length, arrow;
-    wxRect rect;
-    if ( scrollbar->IsVertical() )
-    {
-        rect.x = 0;
-        rect.width = sizeTotal.x;
-        length = sizeTotal.y;
-        start = &rect.y;
-        width = &rect.height;
-        arrow = sizeArrow.y;
-    }
-    else // horizontal
-    {
-        rect.y = 0;
-        rect.height = sizeTotal.y;
-        length = sizeTotal.x;
-        start = &rect.x;
-        width = &rect.width;
-        arrow = sizeArrow.x;
-    }
-
-    switch ( elem )
-    {
-        case wxScrollBar::Element_Arrow_Line_1:
-            *start = 0;
-            *width = arrow;
-            break;
-
-        case wxScrollBar::Element_Arrow_Line_2:
-            *start = length - arrow;
-            *width = arrow;
-            break;
-
-        case wxScrollBar::Element_Arrow_Page_1:
-        case wxScrollBar::Element_Arrow_Page_2:
-            // we don't have them at all
-            break;
-
-        case wxScrollBar::Element_Thumb:
-        case wxScrollBar::Element_Bar_1:
-        case wxScrollBar::Element_Bar_2:
-            // we need to calculate the thumb position - do it
-            {
-                length -= 2*arrow;
-                wxCoord thumbStart, thumbEnd;
-                int range = scrollbar->GetRange();
-                if ( !range )
-                {
-                    thumbStart =
-                    thumbEnd = 0;
-                }
-                else
-                {
-                    GetScrollBarThumbSize(length,
-                                          thumbPos,
-                                          scrollbar->GetThumbSize(),
-                                          range,
-                                          &thumbStart,
-                                          &thumbEnd);
-                }
-
-                if ( elem == wxScrollBar::Element_Thumb )
-                {
-                    *start = thumbStart;
-                    *width = thumbEnd - thumbStart;
-                }
-                else if ( elem == wxScrollBar::Element_Bar_1 )
-                {
-                    *start = 0;
-                    *width = thumbStart;
-                }
-                else // elem == wxScrollBar::Element_Bar_2
-                {
-                    *start = thumbEnd;
-                    *width = length - thumbEnd;
-                }
-
-                // everything is relative to the start of the shaft so far
-                *start += arrow;
-            }
-            break;
-
-        case wxScrollBar::Element_Max:
-        default:
-            wxFAIL_MSG( _T("unknown scrollbar element") );
-    }
-
-    return rect;
-}
-
-wxCoord wxStdRenderer::GetScrollbarSize(const wxScrollBar *scrollbar)
-{
-    const wxSize sizeArrowSB = GetScrollbarArrowSize();
-
-    wxCoord sizeArrow, sizeTotal;
-    if ( scrollbar->GetWindowStyle() & wxVERTICAL )
-    {
-        sizeArrow = sizeArrowSB.y;
-        sizeTotal = scrollbar->GetSize().y;
-    }
-    else // horizontal
-    {
-        sizeArrow = sizeArrowSB.x;
-        sizeTotal = scrollbar->GetSize().x;
-    }
-
-    return sizeTotal - 2*sizeArrow;
-}
-
-wxHitTest
-wxStdRenderer::HitTestScrollbar(const wxScrollBar *scrollbar, const wxPoint& pt) const
-{
-    // we only need to work with either x or y coord depending on the
-    // orientation, choose one (but still check the other one to verify if the
-    // mouse is in the window at all)
-    const wxSize sizeArrowSB = GetScrollbarArrowSize();
-
-    wxCoord coord, sizeArrow, sizeTotal;
-    wxSize size = scrollbar->GetSize();
-    if ( scrollbar->GetWindowStyle() & wxVERTICAL )
-    {
-        if ( pt.x < 0 || pt.x > size.x )
-            return wxHT_NOWHERE;
-
-        coord = pt.y;
-        sizeArrow = sizeArrowSB.y;
-        sizeTotal = size.y;
-    }
-    else // horizontal
-    {
-        if ( pt.y < 0 || pt.y > size.y )
-            return wxHT_NOWHERE;
-
-        coord = pt.x;
-        sizeArrow = sizeArrowSB.x;
-        sizeTotal = size.x;
-    }
-
-    // test for the arrows first as it's faster
-    if ( coord < 0 || coord > sizeTotal )
-    {
-        return wxHT_NOWHERE;
-    }
-    else if ( coord < sizeArrow )
-    {
-        return wxHT_SCROLLBAR_ARROW_LINE_1;
-    }
-    else if ( coord > sizeTotal - sizeArrow )
-    {
-        return wxHT_SCROLLBAR_ARROW_LINE_2;
-    }
-    else
-    {
-        // calculate the thumb position in pixels
-        sizeTotal -= 2*sizeArrow;
-        wxCoord thumbStart, thumbEnd;
-        int range = scrollbar->GetRange();
-        if ( !range )
-        {
-            // clicking the scrollbar without range has no effect
-            return wxHT_NOWHERE;
-        }
-        else
-        {
-            GetScrollBarThumbSize(sizeTotal,
-                                  scrollbar->GetThumbPosition(),
-                                  scrollbar->GetThumbSize(),
-                                  range,
-                                  &thumbStart,
-                                  &thumbEnd);
-        }
-
-        // now compare with the thumb position
-        coord -= sizeArrow;
-        if ( coord < thumbStart )
-            return wxHT_SCROLLBAR_BAR_1;
-        else if ( coord > thumbEnd )
-            return wxHT_SCROLLBAR_BAR_2;
-        else
-            return wxHT_SCROLLBAR_THUMB;
-    }
-}
-
-
-wxCoord
-wxStdRenderer::ScrollbarToPixel(const wxScrollBar *scrollbar, int thumbPos)
-{
-    int range = scrollbar->GetRange();
-    if ( !range )
-    {
-        // the only valid position anyhow
-        return 0;
-    }
-
-    if ( thumbPos == -1 )
-    {
-        // by default use the current thumb position
-        thumbPos = scrollbar->GetThumbPosition();
-    }
-
-    const wxSize sizeArrow = GetScrollbarArrowSize();
-    return (thumbPos*GetScrollbarSize(scrollbar)) / range
-             + (scrollbar->IsVertical() ? sizeArrow.y : sizeArrow.x);
-}
-
-int wxStdRenderer::PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord)
-{
-    const wxSize sizeArrow = GetScrollbarArrowSize();
-    return ((coord - (scrollbar->IsVertical() ? sizeArrow.y : sizeArrow.x)) *
-               scrollbar->GetRange() ) / GetScrollbarSize(scrollbar);
-}
-
-#endif // wxUSE_SCROLLBAR
-
 // ----------------------------------------------------------------------------
 // status bar
 // ----------------------------------------------------------------------------
index 07208440a8f79ea507c77962a05992f2d268f875..837923645fdf7722ca15c526bc26038e85681ea3 100644 (file)
@@ -197,12 +197,9 @@ public:
     virtual void AdjustSize(wxSize *size, const wxWindow *window);
 
     // geometry and hit testing
+#if wxUSE_SCROLLBAR
     virtual wxSize GetScrollbarArrowSize() const
         { return m_sizeScrollbarArrow; }
-#if wxUSE_SCROLLBAR
-    virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
-                                    wxScrollBar::Element elem,
-                                    int thumbPos = -1) const;
 #endif // wxUSE_SCROLLBAR
 
     virtual wxSize GetCheckBitmapSize() const
@@ -2229,24 +2226,6 @@ void wxGTKRenderer::DrawScrollbarShaft(wxDC& dc,
     DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), rectBar);
 }
 
-#if wxUSE_SCROLLBAR
-wxRect wxGTKRenderer::GetScrollbarRect(const wxScrollBar *scrollbar,
-                                       wxScrollBar::Element elem,
-                                       int thumbPos) const
-{
-    // as GTK scrollbars can't be disabled, it makes no sense to remove the
-    // thumb for a scrollbar with range 0 - instead, make it fill the entire
-    // scrollbar shaft
-    if ( (elem == wxScrollBar::Element_Thumb) && !scrollbar->GetRange() )
-    {
-        elem = wxScrollBar::Element_Bar_2;
-    }
-
-    return wxStdRenderer::GetScrollbarRect(scrollbar, elem, thumbPos);
-}
-
-#endif // wxUSE_SCROLLBAR
-
 // ----------------------------------------------------------------------------
 // size adjustments
 // ----------------------------------------------------------------------------
index 3f5416cbc8c4f3a7e327e4e8b94786bcdad9ab5f..42a2efdff65b3f86bdc3822a5a62d9cd1bc1a60b 100644 (file)
@@ -3229,13 +3229,11 @@ bool wxWin32ScrollBarInputHandler::OnScrollTimer(wxScrollBar *scrollbar,
     bool stop = false;
     if ( action == wxACTION_SCROLL_PAGE_DOWN )
     {
-        stop = m_renderer->HitTestScrollbar(scrollbar, m_ptStartScrolling)
-                != wxHT_SCROLLBAR_BAR_2;
+        stop = scrollbar->HitTestBar(m_ptStartScrolling) != wxHT_SCROLLBAR_BAR_2;
     }
     else if ( action == wxACTION_SCROLL_PAGE_UP )
     {
-        stop = m_renderer->HitTestScrollbar(scrollbar, m_ptStartScrolling)
-                != wxHT_SCROLLBAR_BAR_1;
+        stop = scrollbar->HitTestBar(m_ptStartScrolling) != wxHT_SCROLLBAR_BAR_1;
     }
 
     if ( stop )
@@ -3297,7 +3295,7 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control,
             return false;
         }
 
-        ht = m_renderer->HitTestScrollbar(scrollbar, event.GetPosition());
+        ht = scrollbar->HitTestBar(event.GetPosition());
         if ( ht == m_htLast )
         {
             // yes it did, resume scrolling
@@ -3327,7 +3325,7 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control,
         // Always let thumb jump back if we leave the scrollbar
         if ( event.Moving() )
         {
-            ht = m_renderer->HitTestScrollbar(scrollbar, event.GetPosition());
+            ht = scrollbar->HitTestBar(event.GetPosition());
         }
         else // event.Leaving()
         {
@@ -3346,7 +3344,7 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control,
             if (pos.y > -40 && pos.y < scrollbar->GetSize().y+40)
                pos.y = 5;
         }
-        ht = m_renderer->HitTestScrollbar(scrollbar, pos );
+        ht = scrollbar->HitTestBar(pos);
 #endif
 
         // if we're dragging the thumb and the mouse stays in the scrollbar, it