]> git.saurik.com Git - wxWidgets.git/commitdiff
compute scrollbar widths in a more standard way, get rid of redundant m_hasScrolling...
authorPaul Cornett <paulcor@bullseye.com>
Thu, 10 Jan 2008 17:48:33 +0000 (17:48 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Thu, 10 Jan 2008 17:48:33 +0000 (17:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51153 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/window.h
src/gtk/scrolwin.cpp
src/gtk/window.cpp

index 5d751165ecf24b8643141ef35c6bb9bdf45f4856..9ada466aca6ec8c3f9a5bc6bdc5b1110a4730644 100644 (file)
@@ -289,7 +289,6 @@ public:
     // extra (wxGTK-specific) flags
     bool                 m_noExpose:1;          // wxGLCanvas has its own redrawing
     bool                 m_nativeSizeEvent:1;   // wxGLCanvas sends wxSizeEvent upon "alloc_size"
-    bool                 m_hasScrolling:1;
     bool                 m_hasVMT:1;
     bool                 m_hasFocus:1;          // true if == FindFocus()
     bool                 m_isScrolling:1;       // dragging scrollbar thumb?
index 2808986822679f3dbc5494dee5946738f7497e85..7519c5c58961b4a9cbd0a0742bb3a430c2b8edb1 100644 (file)
@@ -121,10 +121,6 @@ void wxScrollHelperNative::DoAdjustScrollbar(GtkRange* range,
 
 void wxScrollHelperNative::AdjustScrollbars()
 {
-    // this flag indicates which window has the scrollbars
-    m_win->m_hasScrolling = m_xScrollPixelsPerLine != 0 ||
-                                m_yScrollPixelsPerLine != 0;
-
     int vw, vh;
     m_targetWindow->GetVirtualSize( &vw, &vh );
 
index dc9ed38fe47e4d5a4b09c64ce714cebc3c779975..7e637c83b076ba1a89f5c960d55e7bde34be9352 100644 (file)
@@ -258,35 +258,6 @@ wxWindow *wxFindFocusedChild(wxWindowGTK *win)
     return (wxWindow *)NULL;
 }
 
-static void GetScrollbarWidth(GtkWidget* widget, int& w, int& h)
-{
-    GtkScrolledWindow* scroll_window = GTK_SCROLLED_WINDOW(widget);
-    GtkScrolledWindowClass* scroll_class = GTK_SCROLLED_WINDOW_CLASS(GTK_OBJECT_GET_CLASS(scroll_window));
-    GtkRequisition scroll_req;
-
-    w = 0;
-    if (scroll_window->vscrollbar_visible)
-    {
-        scroll_req.width = 2;
-        scroll_req.height = 2;
-        (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->vscrollbar) )->size_request )
-            (scroll_window->vscrollbar, &scroll_req );
-        w = scroll_req.width +
-            scroll_class->scrollbar_spacing;
-    }
-
-    h = 0;
-    if (scroll_window->hscrollbar_visible)
-    {
-        scroll_req.width = 2;
-        scroll_req.height = 2;
-        (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->hscrollbar) )->size_request )
-            (scroll_window->hscrollbar, &scroll_req );
-        h = scroll_req.height +
-            scroll_class->scrollbar_spacing;
-    }
-}
-
 //-----------------------------------------------------------------------------
 // "size_request" of m_widget
 //-----------------------------------------------------------------------------
@@ -2139,7 +2110,6 @@ void wxWindowGTK::Init()
     m_noExpose = false;
     m_nativeSizeEvent = false;
 
-    m_hasScrolling = false;
     m_isScrolling = false;
     m_mouseButtonDown = false;
 
@@ -2731,19 +2701,27 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
 
     if (m_wxwindow)
     {
-        int dw = 0;
-        int dh = 0;
-
-        if (m_hasScrolling)
-            GetScrollbarWidth(m_widget, dw, dh);
+        // if window is scrollable, account for scrollbars
+        for (int i = 0; i < 2 && m_scrollBar[i]; i++)
+        {
+            GtkRequisition req;
+            GtkAdjustment* adj = gtk_range_get_adjustment(m_scrollBar[i]);
+            // if scrollbar enabled
+            if (adj->upper > adj->page_size)
+            {
+                gtk_widget_size_request(GTK_WIDGET(m_scrollBar[i]), &req);
+                if (i == ScrollDir_Horz)
+                    h -= req.height;
+                else
+                    w -= req.width;
+            }
+        }
 
         int border_x, border_y;
         WX_PIZZA(m_wxwindow)->get_border_widths(border_x, border_y);
-        dw += 2 * border_x;
-        dh += 2 * border_y;
+        w -= 2 * border_x;
+        h -= 2 * border_y;
 
-        w -= dw;
-        h -= dh;
         if (w < 0)
             w = 0;
         if (h < 0)
@@ -3997,11 +3975,7 @@ void wxWindowGTK::SetScrollbar(int orient,
     GtkRange* const sb = m_scrollBar[dir];
     wxCHECK_RET( sb, _T("this window is not scrollable") );
 
-    if (range > 0)
-    {
-        m_hasScrolling = true;
-    }
-    else
+    if (range <= 0)
     {
         // GtkRange requires upper > lower
         range =