From: Paul Cornett Date: Thu, 10 Jan 2008 17:48:33 +0000 (+0000) Subject: compute scrollbar widths in a more standard way, get rid of redundant m_hasScrolling... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8466fc74fa494ee7b4dccf36f7d2c292e2efd5a8 compute scrollbar widths in a more standard way, get rid of redundant m_hasScrolling member git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51153 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 5d751165ec..9ada466aca 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -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? diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index 2808986822..7519c5c589 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -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 ); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index dc9ed38fe4..7e637c83b0 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -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 =