]> git.saurik.com Git - wxWidgets.git/commitdiff
provide generic implementation for ShowScrollbars() too
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 24 Dec 2008 16:11:02 +0000 (16:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 24 Dec 2008 16:11:02 +0000 (16:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57530 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/scrolwin.h
src/generic/scrlwing.cpp

index d85a167eb65211c72d87e3565ed5172caf65d128..efb0fd94863e9e1d644164605dee8288a74c5e62 100644 (file)
@@ -93,7 +93,10 @@ public:
     // associated window), always (as wxALWAYS_SHOW_SB style does) or never (in
     // which case you should provide some other way to scroll the window as the
     // user wouldn't be able to do it at all)
-    void ShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert);
+    void ShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert)
+    {
+        DoShowScrollbars(horz, vert);
+    }
 
     // Enable/disable Windows scrolling in either direction. If true, wxWidgets
     // scrolls the canvas and only a bit of the canvas is invalidated; no
@@ -246,7 +249,8 @@ protected:
                          int virtSize,
                          int& pixelsPerUnit,
                          int& scrollUnits,
-                         int& scrollPosition);
+                         int& scrollPosition,
+                         wxScrollbarVisibility visibility);
 
     // this function should be overridden to return the size available for
     // m_targetWindow inside m_win of the given size
@@ -293,6 +297,8 @@ protected:
 
     wxScrollHelperEvtHandler *m_handler;
 
+    wxScrollbarVisibility m_xVisibility,
+                          m_yVisibility;
 
     DECLARE_NO_COPY_CLASS(wxScrollHelper)
 };
index 19cb186145e1d2422dc580431d77eba0cdb6cfd7..d0a8cea4bcefccac3f54dc60eaa0441badd7b5ee 100644 (file)
@@ -323,6 +323,9 @@ wxScrollHelper::wxScrollHelper(wxWindow *win)
     m_xScrollingEnabled =
     m_yScrollingEnabled = true;
 
+    m_xVisibility =
+    m_yVisibility = wxSHOW_SB_DEFAULT;
+
     m_scaleX =
     m_scaleY = 1.0;
 #if wxUSE_MOUSEWHEEL
@@ -650,13 +653,21 @@ wxScrollHelper::AdjustScrollbar(int orient,
                                 int virtSize,
                                 int& pixelsPerUnit,
                                 int& scrollUnits,
-                                int& scrollPosition)
+                                int& scrollPosition,
+                                wxScrollbarVisibility visibility)
 {
+    if ( visibility == wxSHOW_SB_NEVER )
+    {
+        m_win->SetScrollbar(orient, 0, 0, 0);
+        return;
+    }
+
     // scroll lines per page: if 0, no scrolling is needed
     int unitsPerPage;
 
     // check if we need scrollbar in this direction at all
-    if ( pixelsPerUnit == 0 || clientSize >= virtSize )
+    if ( pixelsPerUnit == 0 ||
+            (clientSize >= virtSize && visibility != wxSHOW_SB_ALWAYS) )
     {
         // scrolling is disabled or unnecessary
         scrollUnits =
@@ -755,14 +766,16 @@ void wxScrollHelper::AdjustScrollbars()
                         virtSize.x,
                         m_xScrollPixelsPerLine,
                         m_xScrollLines,
-                        m_xScrollPosition);
+                        m_xScrollPosition,
+                        m_xVisibility);
 
         AdjustScrollbar(wxVERTICAL,
                         clientSize.y,
                         virtSize.y,
                         m_yScrollPixelsPerLine,
                         m_yScrollLines,
-                        m_yScrollPosition);
+                        m_yScrollPosition,
+                        m_yVisibility);
 
 
         // If a scrollbar (dis)appeared as a result of this, we need to adjust
@@ -972,16 +985,16 @@ void wxScrollHelper::EnableScrolling (bool x_scroll, bool y_scroll)
     m_yScrollingEnabled = y_scroll;
 }
 
-void wxScrollHelper::ShowScrollbars(wxScrollbarVisibility horz,
-                                    wxScrollbarVisibility vert)
-{
-    DoShowScrollbars(horz, vert);
-}
-
 void wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility horz,
                                       wxScrollbarVisibility vert)
 {
-    // TODO
+    if ( horz != m_xVisibility || vert != m_yVisibility )
+    {
+        m_xVisibility = horz;
+        m_yVisibility = vert;
+
+        AdjustScrollbars();
+    }
 }
 
 // Where the current view starts from