diff options
author | Timothy Pearson <[email protected]> | 2012-11-11 15:40:15 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-11-11 15:40:15 -0600 |
commit | b358b8dfae1263c05ecc63b3a43371467bc91497 (patch) | |
tree | 94204b3789ec9e0cebfe459586aef5a7f1867f49 /tdegtk/tdegtk-draw.cpp | |
parent | ec156de9735a1b6183a0bede86986e132d080594 (diff) | |
download | gtk3-tqt-engine-b358b8dfae1263c05ecc63b3a43371467bc91497.tar.gz gtk3-tqt-engine-b358b8dfae1263c05ecc63b3a43371467bc91497.zip |
Fix scrollbars
Diffstat (limited to 'tdegtk/tdegtk-draw.cpp')
-rw-r--r-- | tdegtk/tdegtk-draw.cpp | 89 |
1 files changed, 68 insertions, 21 deletions
diff --git a/tdegtk/tdegtk-draw.cpp b/tdegtk/tdegtk-draw.cpp index 169c2f7..3f616ca 100644 --- a/tdegtk/tdegtk-draw.cpp +++ b/tdegtk/tdegtk-draw.cpp @@ -60,6 +60,10 @@ p.setBrush(TQt::NoBrush); extern int m_scrollBarSubLineWidth; +extern bool m_scrollbarBack1; +extern bool m_scrollbarForward1; +extern bool m_scrollbarBack2; +extern bool m_scrollbarForward2; WidgetLookup m_widgetLookup; Animations m_animations; @@ -410,11 +414,18 @@ void gtkScrollbarToScrollbarCeData(GtkScrollbar* scrollbarWidget, TQStyleControl ceData.pageStep = gtk_adjustment_get_page_increment(adjustment); // Convert the GTK slider length into a correct pagestep that TQt3 can use to obtain the same slider length value + bool threeButtonScrollBar = false; + if (m_scrollbarBack2 | m_scrollbarForward2) threeButtonScrollBar = true; TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None; int gtkSliderLength = slider_end_pos - slider_start_pos; uint range = ceData.maxSteps - ceData.minSteps; + // HACK + // GTK3 does not handle odd-sized steppers correctly + if ((m_scrollBarSubLineWidth % 2) != 0) { + gtkSliderLength = gtkSliderLength + 4; + } int sbextent = tqApp->style().pixelMetric(TQStyle::PM_ScrollBarExtent, ceData, elementFlags, NULL); - int maxlen = ((ceData.orientation == TQt::Horizontal) ? ceData.rect.width() : ceData.rect.height()) - (sbextent * 2); + int maxlen = ((ceData.orientation == TQt::Horizontal) ? ceData.rect.width() : ceData.rect.height()) - (sbextent * (threeButtonScrollBar ? 3.0 : 2.0)); int gtkPageStep=ceil((-1.0)*(range*gtkSliderLength)/(gtkSliderLength-maxlen)); ceData.pageStep = gtkPageStep; } @@ -600,6 +611,8 @@ draw_slider_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, Gtk cairo_restore(cr); } +TQStyle::SubControl lastSliderActiveSubControl = TQStyle::SC_None; + static void draw_scrollbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) { cairo_save(cr); @@ -658,6 +671,10 @@ draw_scrollbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, state = (GtkStateFlags)(state | GTK_STATE_FLAG_INSENSITIVE); } + sflags &= ~TQStyle::Style_On; + sflags &= ~TQStyle::Style_Down; + sflags &= ~TQStyle::Style_Active; + // Determine active subcontrols gint cursor_x = -1; gint cursor_y = -1; @@ -680,34 +697,64 @@ draw_scrollbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, last = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarLast); // HACK - // This may not be 100% reliable, and it has the side effect of triggering the page step activity effect when the slider is dragged quickly and the mouse cursor momentarily pops out of the slider rectangle. + // This may not be 100% reliable! GdkModifierType mouseStateFlags; gdk_device_get_state (device, gtk_widget_get_window(widget), NULL, &mouseStateFlags); bool mousedown = (mouseStateFlags & GDK_BUTTON1_MASK); if (mousedown) { - if (subline.contains(cursor_pos)) { - activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSubLine); - } - if (addline.contains(cursor_pos)) { - activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarAddLine); - } - if (subpage.contains(cursor_pos)) { - activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSubPage); + bool combine_addlineregion_drawing_areas = tqApp->style().styleHint(TQStyle::SH_ScrollBar_CombineAddLineRegionDrawingAreas); + if (lastSliderActiveSubControl != TQStyle::SC_None) { + activeSubControl = (TQStyle::SubControl)(activeSubControl | lastSliderActiveSubControl); } - if (addpage.contains(cursor_pos)) { - activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarAddPage); - } - if (slider.contains(cursor_pos)) { - activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSlider); - } - if (first.contains(cursor_pos)) { - activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarFirst); - } - if (last.contains(cursor_pos)) { - activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarLast); + else { + if (subline.contains(cursor_pos)) { + activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSubLine); + lastSliderActiveSubControl = TQStyle::SC_ScrollBarSubLine; + } + else if (addline.contains(cursor_pos)) { + // Not so fast...the addline region may contain a subline control! + TQRect internalSubLine; + if (ceData.orientation == TQt::Horizontal) { + internalSubLine = TQRect(addline.x(), addline.y(), addline.width()/2, addline.height()); + } + else { + internalSubLine = TQRect(addline.x(), addline.y(), addline.width(), addline.height()/2); + } + if (internalSubLine.contains(cursor_pos)) { + activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSubLine); + lastSliderActiveSubControl = TQStyle::SC_ScrollBarSubLine; + } + else { + activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarAddLine); + lastSliderActiveSubControl = TQStyle::SC_ScrollBarAddLine; + } + } + else if (subpage.contains(cursor_pos)) { + activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSubPage); + lastSliderActiveSubControl = TQStyle::SC_ScrollBarSubPage; + } + else if (addpage.contains(cursor_pos)) { + activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarAddPage); + lastSliderActiveSubControl = TQStyle::SC_ScrollBarAddPage; + } + else if (slider.contains(cursor_pos)) { + activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSlider); + lastSliderActiveSubControl = TQStyle::SC_ScrollBarSlider; + } + else if (first.contains(cursor_pos)) { + activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarFirst); + lastSliderActiveSubControl = TQStyle::SC_ScrollBarFirst; + } + else if (last.contains(cursor_pos)) { + activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarLast); + lastSliderActiveSubControl = TQStyle::SC_ScrollBarLast; + } } } + else { + lastSliderActiveSubControl = TQStyle::SC_None; + } } // Draw item |