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 | |
parent | ec156de9735a1b6183a0bede86986e132d080594 (diff) | |
download | gtk3-tqt-engine-b358b8dfae1263c05ecc63b3a43371467bc91497.tar.gz gtk3-tqt-engine-b358b8dfae1263c05ecc63b3a43371467bc91497.zip |
Fix scrollbars
Diffstat (limited to 'tdegtk')
-rw-r--r-- | tdegtk/tdegtk-draw.cpp | 89 | ||||
-rw-r--r-- | tdegtk/tdegtk-theme.cpp | 28 |
2 files changed, 83 insertions, 34 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 diff --git a/tdegtk/tdegtk-theme.cpp b/tdegtk/tdegtk-theme.cpp index d52a5f0..fe4db01 100644 --- a/tdegtk/tdegtk-theme.cpp +++ b/tdegtk/tdegtk-theme.cpp @@ -42,6 +42,10 @@ void initTDESettings(); void writeGtkThemeControlFile(int forceRecreate); int m_scrollBarSubLineWidth = -1; +bool m_scrollbarBack1 = false; +bool m_scrollbarForward1 = false; +bool m_scrollbarBack2 = false; +bool m_scrollbarForward2 = false; extern "C" { #include <gmodule.h> @@ -567,19 +571,14 @@ void writeGtkThemeControlFile(int forceRecreate) { // and asking the style which subcontrol is at that location. TQRect rect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, &sbar, TQStyle::SC_ScrollBarGroove); - bool back1 = false; - bool forward1 = false; - bool back2 = false; - bool forward2 = false; - TQStyle::SubControl sc = TQStyle::SC_None; for (TQPoint pos(0,7) ; pos.x()<rect.x() ; pos.setX(pos.x()+1)) { TQStyle::SubControl sc2 = tqApp->style().querySubControl(TQStyle::CC_ScrollBar, &sbar, pos); if (sc != sc2) { - if (sc2 == TQStyle::SC_ScrollBarAddLine) forward1 = true; - if (sc2 == TQStyle::SC_ScrollBarSubLine) back1 = true; + if (sc2 == TQStyle::SC_ScrollBarAddLine) m_scrollbarForward1 = true; + if (sc2 == TQStyle::SC_ScrollBarSubLine) m_scrollbarBack1 = true; sc = sc2; } } @@ -589,12 +588,15 @@ void writeGtkThemeControlFile(int forceRecreate) { TQStyle::SubControl sc2 = tqApp->style().querySubControl(TQStyle::CC_ScrollBar, &sbar, pos); if (sc != sc2) { - if (sc2 == TQStyle::SC_ScrollBarAddLine) forward2 = true; - if (sc2 == TQStyle::SC_ScrollBarSubLine) back2 = true; + if (sc2 == TQStyle::SC_ScrollBarAddLine) m_scrollbarForward2 = true; + if (sc2 == TQStyle::SC_ScrollBarSubLine) m_scrollbarBack2 = true; sc = sc2; } } + // FIXME + // The items in a GTK3 combobox cannot be styled, either to draw them in a custom manner or to change their height + // A bug report should be filed on this issue... bool combobox_appears_as_list = (!(tqApp->style().styleHint(TQStyle::SH_ComboBox_Popup) || tqApp->style().styleHint(TQStyle::SH_GUIStyle) == TQt::MotifStyle)); stream << parse_rc_string(TQString("-GtkComboBox-appears-as-list: %1px").arg(combobox_appears_as_list), "*"); @@ -605,10 +607,10 @@ void writeGtkThemeControlFile(int forceRecreate) { stream << parse_rc_string("-GtkComboBox-arrow-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ArrowSize)), "*"); stream << parse_rc_string("-GtkComboBox-arrow-scaling: 0", "*"); - stream << parse_rc_string(TQString("-GtkScrollbar-has-backward-stepper: ") + (back1 ? "1" : "0"), "*"); - stream << parse_rc_string(TQString("-GtkScrollbar-has-forward-stepper: ") + (forward2 ? "1" : "0"), "*"); - stream << parse_rc_string(TQString("-GtkScrollbar-has-secondary-forward-stepper: ") + (forward1 ? "1" : "0"), "*"); - stream << parse_rc_string(TQString("-GtkScrollbar-has-secondary-backward-stepper: ") + (back2 ? "1" : "0"), "*"); + stream << parse_rc_string(TQString("-GtkScrollbar-has-backward-stepper: ") + (m_scrollbarBack1 ? "1" : "0"), "*"); + stream << parse_rc_string(TQString("-GtkScrollbar-has-forward-stepper: ") + (m_scrollbarForward2 ? "1" : "0"), "*"); + stream << parse_rc_string(TQString("-GtkScrollbar-has-secondary-forward-stepper: ") + (m_scrollbarForward1 ? "1" : "0"), "*"); + stream << parse_rc_string(TQString("-GtkScrollbar-has-secondary-backward-stepper: ") + (m_scrollbarBack2 ? "1" : "0"), "*"); m_scrollBarSubLineWidth = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, &sbar, TQStyle::SC_ScrollBarSubLine).width(); |