diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-05 15:55:20 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-05 15:55:59 +0000 |
commit | 8c8fa0783ddfee50e55deae307901a1691b88009 (patch) | |
tree | 71dc3753aba107cba52ec06b4c1008add3560b2b /vcl | |
parent | 070396471b5bb2ce834d141decea88869eb1c6a7 (diff) |
Revert "require at least gtk3 3.20.0 to build and run gtk3 bits"
Linux-deb-x86_64_56-lhm-ubuntu-trusty is at 3.18, not defunct
Linux-Ubuntu-x86_64_54-TDE
This reverts commit 75e828cad5e652f111278b103b72b9a9a344b689.
Change-Id: I8939e4bb1876186f5ed75b3ad4c2626e37e4c81c
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/gtk/gtkgdi.hxx | 4 | ||||
-rw-r--r-- | vcl/unx/gtk/gtkinst.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk/gtksalmenu.cxx | 7 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkframe.cxx | 29 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 1407 |
5 files changed, 1136 insertions, 313 deletions
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx index 386224895471..fc896db7f913 100644 --- a/vcl/inc/unx/gtk/gtkgdi.hxx +++ b/vcl/inc/unx/gtk/gtkgdi.hxx @@ -131,7 +131,9 @@ public: virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override; - GtkStyleContext* createStyleContext(GtkControlPart ePart); + GtkStyleContext* createStyleContext(gtk_widget_path_iter_set_object_nameFunc set_object_name, GtkControlPart ePart); + GtkStyleContext* createNewContext(GtkControlPart ePart, gtk_widget_path_iter_set_object_nameFunc set_object_name); + GtkStyleContext* createOldContext(GtkControlPart ePart); GtkStyleContext* makeContext(GtkWidgetPath *pPath, GtkStyleContext *pParent); private: GtkWidget *mpWindow; diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx index 2aeffb894952..30f0aa51843f 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -82,7 +82,7 @@ extern "C" XInitThreads(); #if GTK_CHECK_VERSION(3,0,0) - if (gtk_minor_version < 20) + if (gtk_minor_version < 18) { g_warning("require a newer gtk than 3.%d for theme expectations", gtk_minor_version); return nullptr; diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx index 61be00fe48c3..6f16984ba6d0 100644 --- a/vcl/unx/gtk/gtksalmenu.cxx +++ b/vcl/unx/gtk/gtksalmenu.cxx @@ -630,7 +630,12 @@ void GtkSalMenu::ShowCloseButton(bool bShow) "min-width: 18px;" "min-height: 18px;" "}"; - gtk_css_provider_load_from_data(pProvider, data, -1, nullptr); + const gchar olddata[] = "* { " + "padding: 0;" + "margin-left: 8px;" + "margin-right: 8px;" + "}"; + gtk_css_provider_load_from_data(pProvider, gtk_check_version(3, 20, 0) == nullptr ? data : olddata, -1, nullptr); gtk_style_context_add_provider(pButtonContext, GTK_STYLE_PROVIDER(pProvider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index 8ce0586ea835..1f90760f7666 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -2081,15 +2081,36 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents ) if (!m_pWindow) return; - GdkSeat* pSeat = gdk_display_get_default_seat(getGdkDisplay()); +#if GTK_CHECK_VERSION(3, 20, 0) + if (gtk_check_version(3, 20, 0) == nullptr) + { + GdkSeat* pSeat = gdk_display_get_default_seat(getGdkDisplay()); + if (bGrab) + { + gdk_seat_grab(pSeat, widget_get_window(getMouseEventWidget()), GDK_SEAT_CAPABILITY_ALL_POINTING, + bOwnerEvents, nullptr, nullptr, nullptr, nullptr); + } + else + { + gdk_seat_ungrab(pSeat); + } + return; + } +#endif + + //else older gtk3 + const int nMask = (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); + + GdkDeviceManager* pDeviceManager = gdk_display_get_device_manager(getGdkDisplay()); + GdkDevice* pPointer = gdk_device_manager_get_client_pointer(pDeviceManager); if (bGrab) { - gdk_seat_grab(pSeat, widget_get_window(getMouseEventWidget()), GDK_SEAT_CAPABILITY_ALL_POINTING, - bOwnerEvents, nullptr, nullptr, nullptr, nullptr); + gdk_device_grab(pPointer, widget_get_window(getMouseEventWidget()), GDK_OWNERSHIP_NONE, + bOwnerEvents, (GdkEventMask) nMask, m_pCurrentCursor, gtk_get_current_event_time()); } else { - gdk_seat_ungrab(pSeat); + gdk_device_ungrab(pPointer, gtk_get_current_event_time()); } } diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index 5ae090f37d1d..38b724be27d8 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -259,6 +259,8 @@ tools::Rectangle GtkSalGraphics::NWGetScrollButtonRect( ControlPart nPart, tools "has-secondary-forward-stepper", &has_forward2, "has-backward-stepper", &has_backward, "has-secondary-backward-stepper", &has_backward2, nullptr ); + gint buttonWidth; + gint buttonHeight; gint nFirst = 0; gint nSecond = 0; @@ -268,46 +270,103 @@ tools::Rectangle GtkSalGraphics::NWGetScrollButtonRect( ControlPart nPart, tools if ( has_backward ) nFirst += 1; if ( has_backward2 ) nSecond += 1; - Size aSize; - if (nPart == ControlPart::ButtonLeft || nPart == ControlPart::ButtonRight) + if (gtk_check_version(3, 20, 0) == nullptr) { - QuerySize(mpHScrollbarStyle, aSize); - QuerySize(mpHScrollbarContentsStyle, aSize); - QuerySize(mpHScrollbarButtonStyle, aSize); + Size aSize; + if (nPart == ControlPart::ButtonLeft || nPart == ControlPart::ButtonRight) + { + QuerySize(mpHScrollbarStyle, aSize); + QuerySize(mpHScrollbarContentsStyle, aSize); + QuerySize(mpHScrollbarButtonStyle, aSize); + } + else + { + QuerySize(mpVScrollbarStyle, aSize); + QuerySize(mpVScrollbarContentsStyle, aSize); + QuerySize(mpVScrollbarButtonStyle, aSize); + } + + if (nPart == ControlPart::ButtonUp) + { + aSize.Height() *= nFirst; + buttonRect.setX(aAreaRect.Left()); + buttonRect.setY(aAreaRect.Top()); + } + else if (nPart == ControlPart::ButtonLeft) + { + aSize.Width() *= nFirst; + buttonRect.setX(aAreaRect.Left()); + buttonRect.setY(aAreaRect.Top()); + } + else if (nPart == ControlPart::ButtonDown) + { + aSize.Height() *= nSecond; + buttonRect.setX(aAreaRect.Left()); + buttonRect.setY(aAreaRect.Top() + aAreaRect.GetHeight() - aSize.Height()); + } + else if (nPart == ControlPart::ButtonRight) + { + aSize.Width() *= nSecond; + buttonRect.setX(aAreaRect.Left() + aAreaRect.GetWidth() - aSize.Width()); + buttonRect.setY(aAreaRect.Top()); + } + + buttonRect.SetSize(aSize); + + return buttonRect; + } + + gint slider_width; + gint stepper_size; + gint stepper_spacing; + gint trough_border; + + // Grab some button style attributes + gtk_style_context_get_style( pScrollbarStyle, + "slider-width", &slider_width, + "stepper-size", &stepper_size, + "trough-border", &trough_border, + "stepper-spacing", &stepper_spacing, nullptr ); + + if ( ( nPart == ControlPart::ButtonUp ) || ( nPart == ControlPart::ButtonDown ) ) + { + buttonWidth = slider_width + 2 * trough_border; + buttonHeight = stepper_size + trough_border + stepper_spacing; } else { - QuerySize(mpVScrollbarStyle, aSize); - QuerySize(mpVScrollbarContentsStyle, aSize); - QuerySize(mpVScrollbarButtonStyle, aSize); + buttonWidth = stepper_size + trough_border + stepper_spacing; + buttonHeight = slider_width + 2 * trough_border; } - if (nPart == ControlPart::ButtonUp) + if ( nPart == ControlPart::ButtonUp ) { - aSize.Height() *= nFirst; - buttonRect.setX(aAreaRect.Left()); - buttonRect.setY(aAreaRect.Top()); + buttonHeight *= nFirst; + buttonHeight -= 1; + buttonRect.setX( aAreaRect.Left() ); + buttonRect.setY( aAreaRect.Top() ); } - else if (nPart == ControlPart::ButtonLeft) + else if ( nPart == ControlPart::ButtonLeft ) { - aSize.Width() *= nFirst; - buttonRect.setX(aAreaRect.Left()); - buttonRect.setY(aAreaRect.Top()); + buttonWidth *= nFirst; + buttonWidth -= 1; + buttonRect.setX( aAreaRect.Left() ); + buttonRect.setY( aAreaRect.Top() ); } - else if (nPart == ControlPart::ButtonDown) + else if ( nPart == ControlPart::ButtonDown ) { - aSize.Height() *= nSecond; - buttonRect.setX(aAreaRect.Left()); - buttonRect.setY(aAreaRect.Top() + aAreaRect.GetHeight() - aSize.Height()); + buttonHeight *= nSecond; + buttonRect.setX( aAreaRect.Left() ); + buttonRect.setY( aAreaRect.Top() + aAreaRect.GetHeight() - buttonHeight ); } - else if (nPart == ControlPart::ButtonRight) + else if ( nPart == ControlPart::ButtonRight ) { - aSize.Width() *= nSecond; - buttonRect.setX(aAreaRect.Left() + aAreaRect.GetWidth() - aSize.Width()); - buttonRect.setY(aAreaRect.Top()); + buttonWidth *= nSecond; + buttonRect.setX( aAreaRect.Left() + aAreaRect.GetWidth() - buttonWidth ); + buttonRect.setY( aAreaRect.Top() ); } - buttonRect.SetSize(aSize); + buttonRect.SetSize( Size( buttonWidth, buttonHeight ) ); return buttonRect; } @@ -379,7 +438,328 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, ControlPart nPart, const ImplControlValue& rValue ) { - assert(rValue.getType() == ControlType::Scrollbar); + if (gtk_check_version(3, 20, 0) == nullptr) + { + assert(rValue.getType() == ControlType::Scrollbar); + const ScrollbarValue& rScrollbarVal = static_cast<const ScrollbarValue&>(rValue); + tools::Rectangle scrollbarRect; + GtkStateFlags stateFlags; + GtkOrientation scrollbarOrientation; + tools::Rectangle thumbRect = rScrollbarVal.maThumbRect; + tools::Rectangle button11BoundRect = rScrollbarVal.maButton1Rect; // backward + tools::Rectangle button22BoundRect = rScrollbarVal.maButton2Rect; // forward + tools::Rectangle button12BoundRect = rScrollbarVal.maButton1Rect; // secondary forward + tools::Rectangle button21BoundRect = rScrollbarVal.maButton2Rect; // secondary backward + gdouble arrow1Angle; // backward + gdouble arrow2Angle; // forward + tools::Rectangle arrowRect; + gint slider_width = 0; + gint stepper_size = 0; + + // make controlvalue rectangles relative to area + thumbRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() ); + button11BoundRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() ); + button22BoundRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() ); + button12BoundRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() ); + button21BoundRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() ); + + // Find the overall bounding rect of the control + scrollbarRect = rControlRectangle; + if (scrollbarRect.GetWidth() <= 0 || scrollbarRect.GetHeight() <= 0) + return; + + gint slider_side; + Size aSize; + if (nPart == ControlPart::DrawBackgroundHorz) + { + QuerySize(mpHScrollbarStyle, aSize); + QuerySize(mpHScrollbarContentsStyle, aSize); + QuerySize(mpHScrollbarTroughStyle, aSize); + QuerySize(mpHScrollbarSliderStyle, aSize); + slider_side = aSize.Height(); + gtk_style_context_get(mpHScrollbarButtonStyle, + gtk_style_context_get_state(mpHScrollbarButtonStyle), + "min-height", &slider_width, + "min-width", &stepper_size, nullptr); + } + else + { + QuerySize(mpVScrollbarStyle, aSize); + QuerySize(mpVScrollbarContentsStyle, aSize); + QuerySize(mpVScrollbarTroughStyle, aSize); + QuerySize(mpVScrollbarSliderStyle, aSize); + slider_side = aSize.Width(); + gtk_style_context_get(mpVScrollbarButtonStyle, + gtk_style_context_get_state(mpVScrollbarButtonStyle), + "min-width", &slider_width, + "min-height", &stepper_size, nullptr); + } + + gboolean has_forward; + gboolean has_forward2; + gboolean has_backward; + gboolean has_backward2; + + gtk_style_context_get_style( context, + "has-forward-stepper", &has_forward, + "has-secondary-forward-stepper", &has_forward2, + "has-backward-stepper", &has_backward, + "has-secondary-backward-stepper", &has_backward2, nullptr ); + + if ( nPart == ControlPart::DrawBackgroundHorz ) + { + // Center vertically in the track + scrollbarRect.Move( 0, (scrollbarRect.GetHeight() - slider_side) / 2 ); + scrollbarRect.SetSize( Size( scrollbarRect.GetWidth(), slider_side ) ); + thumbRect.Move( 0, (scrollbarRect.GetHeight() - slider_side) / 2 ); + thumbRect.SetSize( Size( thumbRect.GetWidth(), slider_side ) ); + + scrollbarOrientation = GTK_ORIENTATION_HORIZONTAL; + arrow1Angle = G_PI * 3 / 2; + arrow2Angle = G_PI / 2; + + if ( has_backward ) + { + button12BoundRect.Move( stepper_size, + (scrollbarRect.GetHeight() - slider_width) / 2 ); + } + + button11BoundRect.Move( 0, (scrollbarRect.GetHeight() - slider_width) / 2 ); + button11BoundRect.SetSize( Size( stepper_size, slider_width ) ); + button12BoundRect.SetSize( Size( stepper_size, slider_width ) ); + + if ( has_backward2 ) + { + button22BoundRect.Move( stepper_size, (scrollbarRect.GetHeight() - slider_width) / 2 ); + button21BoundRect.Move( 0, (scrollbarRect.GetHeight() - slider_width) / 2 ); + } + else + { + button22BoundRect.Move( 0, (scrollbarRect.GetHeight() - slider_width) / 2 ); + } + + button21BoundRect.SetSize( Size( stepper_size, slider_width ) ); + button22BoundRect.SetSize( Size( stepper_size, slider_width ) ); + } + else + { + // Center horizontally in the track + scrollbarRect.Move( (scrollbarRect.GetWidth() - slider_side) / 2, 0 ); + scrollbarRect.SetSize( Size( slider_side, scrollbarRect.GetHeight() ) ); + thumbRect.Move( (scrollbarRect.GetWidth() - slider_side) / 2, 0 ); + thumbRect.SetSize( Size( slider_side, thumbRect.GetHeight() ) ); + + scrollbarOrientation = GTK_ORIENTATION_VERTICAL; + arrow1Angle = 0; + arrow2Angle = G_PI; + + if ( has_backward ) + { + button12BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, + stepper_size ); + } + button11BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, 0 ); + button11BoundRect.SetSize( Size( slider_width, stepper_size ) ); + button12BoundRect.SetSize( Size( slider_width, stepper_size ) ); + + if ( has_backward2 ) + { + button22BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, stepper_size ); + button21BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, 0 ); + } + else + { + button22BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, 0 ); + } + + button21BoundRect.SetSize( Size( slider_width, stepper_size ) ); + button22BoundRect.SetSize( Size( slider_width, stepper_size ) ); + } + + bool has_slider = ( thumbRect.GetWidth() > 0 && thumbRect.GetHeight() > 0 ); + + // ----------------- CONTENTS + GtkStyleContext* pScrollbarContentsStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarContentsStyle : mpHScrollbarContentsStyle; + + gtk_render_background(gtk_widget_get_style_context(gCacheWindow), cr, 0, 0, + scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); + + gtk_render_background(context, cr, 0, 0, + scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); + gtk_render_frame(context, cr, 0, 0, + scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); + + gtk_render_background(pScrollbarContentsStyle, cr, 0, 0, + scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); + gtk_render_frame(pScrollbarContentsStyle, cr, 0, 0, + scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); + + bool backwardButtonInsensitive = + rScrollbarVal.mnCur == rScrollbarVal.mnMin; + bool forwardButtonInsensitive = rScrollbarVal.mnMax == 0 || + rScrollbarVal.mnCur + rScrollbarVal.mnVisibleSize >= rScrollbarVal.mnMax; + + // ----------------- BUTTON 1 + if ( has_backward ) + { + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnButton1State); + if ( backwardButtonInsensitive ) + stateFlags = GTK_STATE_FLAG_INSENSITIVE; + + GtkStyleContext* pScrollbarButtonStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarButtonStyle : mpHScrollbarButtonStyle; + + gtk_style_context_set_state(pScrollbarButtonStyle, stateFlags); + + gtk_render_background(pScrollbarButtonStyle, cr, + button11BoundRect.Left(), button11BoundRect.Top(), + button11BoundRect.GetWidth(), button11BoundRect.GetHeight() ); + gtk_render_frame(pScrollbarButtonStyle, cr, + button11BoundRect.Left(), button11BoundRect.Top(), + button11BoundRect.GetWidth(), button11BoundRect.GetHeight() ); + + // ----------------- ARROW 1 + NWCalcArrowRect( button11BoundRect, arrowRect ); + gtk_render_arrow(pScrollbarButtonStyle, cr, + arrow1Angle, + arrowRect.Left(), arrowRect.Top(), + MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); + } + if ( has_forward2 ) + { + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnButton2State); + if ( forwardButtonInsensitive ) + stateFlags = GTK_STATE_FLAG_INSENSITIVE; + + GtkStyleContext* pScrollbarButtonStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarButtonStyle : mpHScrollbarButtonStyle; + + gtk_style_context_set_state(pScrollbarButtonStyle, stateFlags); + + gtk_render_background(pScrollbarButtonStyle, cr, + button12BoundRect.Left(), button12BoundRect.Top(), + button12BoundRect.GetWidth(), button12BoundRect.GetHeight() ); + gtk_render_frame(pScrollbarButtonStyle, cr, + button12BoundRect.Left(), button12BoundRect.Top(), + button12BoundRect.GetWidth(), button12BoundRect.GetHeight() ); + + // ----------------- ARROW 1 + NWCalcArrowRect( button12BoundRect, arrowRect ); + gtk_render_arrow(pScrollbarButtonStyle, cr, + arrow2Angle, + arrowRect.Left(), arrowRect.Top(), + MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); + } + // ----------------- BUTTON 2 + + if ( has_forward ) + { + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnButton2State); + if ( forwardButtonInsensitive ) + stateFlags = GTK_STATE_FLAG_INSENSITIVE; + + GtkStyleContext* pScrollbarButtonStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarButtonStyle : mpHScrollbarButtonStyle; + + gtk_style_context_set_state(pScrollbarButtonStyle, stateFlags); + + gtk_render_background(pScrollbarButtonStyle, cr, + button22BoundRect.Left(), button22BoundRect.Top(), + button22BoundRect.GetWidth(), button22BoundRect.GetHeight() ); + gtk_render_frame(pScrollbarButtonStyle, cr, + button22BoundRect.Left(), button22BoundRect.Top(), + button22BoundRect.GetWidth(), button22BoundRect.GetHeight() ); + + // ----------------- ARROW 2 + NWCalcArrowRect( button22BoundRect, arrowRect ); + gtk_render_arrow(pScrollbarButtonStyle, cr, + arrow2Angle, + arrowRect.Left(), arrowRect.Top(), + MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); + } + + if ( has_backward2 ) + { + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnButton1State); + if ( backwardButtonInsensitive ) + stateFlags = GTK_STATE_FLAG_INSENSITIVE; + + GtkStyleContext* pScrollbarButtonStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarButtonStyle : mpHScrollbarButtonStyle; + + gtk_style_context_set_state(pScrollbarButtonStyle, stateFlags); + + gtk_render_background(pScrollbarButtonStyle, cr, + button21BoundRect.Left(), button21BoundRect.Top(), + button21BoundRect.GetWidth(), button21BoundRect.GetHeight() ); + gtk_render_frame(pScrollbarButtonStyle, cr, + button21BoundRect.Left(), button21BoundRect.Top(), + button21BoundRect.GetWidth(), button21BoundRect.GetHeight() ); + + // ----------------- ARROW 2 + NWCalcArrowRect( button21BoundRect, arrowRect ); + gtk_render_arrow(pScrollbarButtonStyle, cr, + arrow1Angle, + arrowRect.Left(), arrowRect.Top(), + MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); + } + + // ----------------- TROUGH + // trackrect matches that of ScrollBar::ImplCalc + tools::Rectangle aTrackRect(Point(0, 0), scrollbarRect.GetSize()); + if (nPart == ControlPart::DrawBackgroundHorz) + { + tools::Rectangle aBtn1Rect = NWGetScrollButtonRect(ControlPart::ButtonLeft, aTrackRect); + tools::Rectangle aBtn2Rect = NWGetScrollButtonRect(ControlPart::ButtonRight, aTrackRect); + aTrackRect.Left() = aBtn1Rect.Right(); + aTrackRect.Right() = aBtn2Rect.Left(); + } + else + { + tools::Rectangle aBtn1Rect = NWGetScrollButtonRect(ControlPart::ButtonUp, aTrackRect); + tools::Rectangle aBtn2Rect = NWGetScrollButtonRect(ControlPart::ButtonDown, aTrackRect); + aTrackRect.Top() = aBtn1Rect.Bottom() + 1; + aTrackRect.Bottom() = aBtn2Rect.Top(); + } + + GtkStyleContext* pScrollbarTroughStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarTroughStyle : mpHScrollbarTroughStyle; + gtk_render_background(pScrollbarTroughStyle, cr, aTrackRect.Left(), aTrackRect.Top(), + aTrackRect.GetWidth(), aTrackRect.GetHeight() ); + gtk_render_frame(pScrollbarTroughStyle, cr, aTrackRect.Left(), aTrackRect.Top(), + aTrackRect.GetWidth(), aTrackRect.GetHeight() ); + + // ----------------- THUMB + if ( has_slider ) + { + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnThumbState); + if ( rScrollbarVal.mnThumbState & ControlState::PRESSED ) + stateFlags = (GtkStateFlags) (stateFlags | GTK_STATE_PRELIGHT); + + GtkStyleContext* pScrollbarSliderStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarSliderStyle : mpHScrollbarSliderStyle; + + gtk_style_context_set_state(pScrollbarSliderStyle, stateFlags); + + GtkBorder margin; + gtk_style_context_get_margin(pScrollbarSliderStyle, stateFlags, &margin); + + gtk_render_background(pScrollbarSliderStyle, cr, + thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, + thumbRect.GetWidth() - margin.left - margin.right, + thumbRect.GetHeight() - margin.top - margin.bottom); + + gtk_render_frame(pScrollbarSliderStyle, cr, + thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, + thumbRect.GetWidth() - margin.left - margin.right, + thumbRect.GetHeight() - margin.top - margin.bottom); + } + + return; + } + + OSL_ASSERT( rValue.getType() == ControlType::Scrollbar ); const ScrollbarValue& rScrollbarVal = static_cast<const ScrollbarValue&>(rValue); tools::Rectangle scrollbarRect; GtkStateFlags stateFlags; @@ -394,6 +774,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, tools::Rectangle arrowRect; gint slider_width = 0; gint stepper_size = 0; + gint trough_border = 0; // make controlvalue rectangles relative to area thumbRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() ); @@ -404,36 +785,17 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, // Find the overall bounding rect of the control scrollbarRect = rControlRectangle; - if (scrollbarRect.GetWidth() <= 0 || scrollbarRect.GetHeight() <= 0) - return; + scrollbarRect.SetSize( Size( scrollbarRect.GetWidth() + 1, + scrollbarRect.GetHeight() + 1 ) ); - gint slider_side; - Size aSize; - if (nPart == ControlPart::DrawBackgroundHorz) - { - QuerySize(mpHScrollbarStyle, aSize); - QuerySize(mpHScrollbarContentsStyle, aSize); - QuerySize(mpHScrollbarTroughStyle, aSize); - QuerySize(mpHScrollbarSliderStyle, aSize); - slider_side = aSize.Height(); - gtk_style_context_get(mpHScrollbarButtonStyle, - gtk_style_context_get_state(mpHScrollbarButtonStyle), - "min-height", &slider_width, - "min-width", &stepper_size, nullptr); - } - else - { - QuerySize(mpVScrollbarStyle, aSize); - QuerySize(mpVScrollbarContentsStyle, aSize); - QuerySize(mpVScrollbarTroughStyle, aSize); - QuerySize(mpVScrollbarSliderStyle, aSize); - slider_side = aSize.Width(); - gtk_style_context_get(mpVScrollbarButtonStyle, - gtk_style_context_get_state(mpVScrollbarButtonStyle), - "min-width", &slider_width, - "min-height", &stepper_size, nullptr); - } + if ( (scrollbarRect.GetWidth() <= 1) || (scrollbarRect.GetHeight() <= 1) ) + return; + // Grab some button style attributes + gtk_style_context_get_style( context, + "slider_width", &slider_width, + "stepper_size", &stepper_size, + "trough_border", &trough_border, nullptr ); gboolean has_forward; gboolean has_forward2; gboolean has_backward; @@ -444,14 +806,13 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, "has-secondary-forward-stepper", &has_forward2, "has-backward-stepper", &has_backward, "has-secondary-backward-stepper", &has_backward2, nullptr ); + gint magic = trough_border ? 1 : 0; + gint slider_side = slider_width + (trough_border * 2); if ( nPart == ControlPart::DrawBackgroundHorz ) { - // Center vertically in the track scrollbarRect.Move( 0, (scrollbarRect.GetHeight() - slider_side) / 2 ); scrollbarRect.SetSize( Size( scrollbarRect.GetWidth(), slider_side ) ); - thumbRect.Move( 0, (scrollbarRect.GetHeight() - slider_side) / 2 ); - thumbRect.SetSize( Size( thumbRect.GetWidth(), slider_side ) ); scrollbarOrientation = GTK_ORIENTATION_HORIZONTAL; arrow1Angle = G_PI * 3 / 2; @@ -459,34 +820,39 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, if ( has_backward ) { - button12BoundRect.Move( stepper_size, + button12BoundRect.Move( stepper_size - trough_border, (scrollbarRect.GetHeight() - slider_width) / 2 ); } - button11BoundRect.Move( 0, (scrollbarRect.GetHeight() - slider_width) / 2 ); + button11BoundRect.Move( trough_border, (scrollbarRect.GetHeight() - slider_width) / 2 ); button11BoundRect.SetSize( Size( stepper_size, slider_width ) ); button12BoundRect.SetSize( Size( stepper_size, slider_width ) ); if ( has_backward2 ) { - button22BoundRect.Move( stepper_size, (scrollbarRect.GetHeight() - slider_width) / 2 ); - button21BoundRect.Move( 0, (scrollbarRect.GetHeight() - slider_width) / 2 ); + button22BoundRect.Move( stepper_size+(trough_border+1)/2, (scrollbarRect.GetHeight() - slider_width) / 2 ); + button21BoundRect.Move( (trough_border+1)/2, (scrollbarRect.GetHeight() - slider_width) / 2 ); } else { - button22BoundRect.Move( 0, (scrollbarRect.GetHeight() - slider_width) / 2 ); + button22BoundRect.Move( (trough_border+1)/2, (scrollbarRect.GetHeight() - slider_width) / 2 ); } button21BoundRect.SetSize( Size( stepper_size, slider_width ) ); button22BoundRect.SetSize( Size( stepper_size, slider_width ) ); + + thumbRect.Bottom() = thumbRect.Top() + slider_width - 1; + // Make sure the thumb is at least the default width (so we don't get tiny thumbs), + // but if the VCL gives us a size smaller than the theme's default thumb size, + // honor the VCL size + thumbRect.Right() += magic; + // Center vertically in the track + thumbRect.Move( 0, (scrollbarRect.GetHeight() - slider_width) / 2 ); } else { - // Center horizontally in the track scrollbarRect.Move( (scrollbarRect.GetWidth() - slider_side) / 2, 0 ); scrollbarRect.SetSize( Size( slider_side, scrollbarRect.GetHeight() ) ); - thumbRect.Move( (scrollbarRect.GetWidth() - slider_side) / 2, 0 ); - thumbRect.SetSize( Size( slider_side, thumbRect.GetHeight() ) ); scrollbarOrientation = GTK_ORIENTATION_VERTICAL; arrow1Angle = 0; @@ -495,24 +861,30 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, if ( has_backward ) { button12BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, - stepper_size ); + stepper_size + trough_border ); } - button11BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, 0 ); + button11BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, trough_border ); button11BoundRect.SetSize( Size( slider_width, stepper_size ) ); button12BoundRect.SetSize( Size( slider_width, stepper_size ) ); if ( has_backward2 ) { - button22BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, stepper_size ); - button21BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, 0 ); + button22BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, stepper_size+(trough_border+1)/2 ); + button21BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, (trough_border+1)/2 ); } else { - button22BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, 0 ); + button22BoundRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, (trough_border+1)/2 ); } button21BoundRect.SetSize( Size( slider_width, stepper_size ) ); button22BoundRect.SetSize( Size( slider_width, stepper_size ) ); + + thumbRect.Right() = thumbRect.Left() + slider_width - 1; + + thumbRect.Bottom() += magic; + // Center horizontally in the track + thumbRect.Move( (scrollbarRect.GetWidth() - slider_width) / 2, 0 ); } bool has_slider = ( thumbRect.GetWidth() > 0 && thumbRect.GetHeight() > 0 ); @@ -534,6 +906,40 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gtk_render_frame(pScrollbarContentsStyle, cr, 0, 0, scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); + // ----------------- TROUGH + GtkStyleContext* pScrollbarTroughStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarTroughStyle : mpHScrollbarTroughStyle; + gtk_render_background(pScrollbarTroughStyle, cr, 0, 0, + scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); + gtk_render_frame(pScrollbarTroughStyle, cr, 0, 0, + scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); + + // ----------------- THUMB + if ( has_slider ) + { + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnThumbState); + if ( rScrollbarVal.mnThumbState & ControlState::PRESSED ) + stateFlags = (GtkStateFlags) (stateFlags | GTK_STATE_PRELIGHT); + + GtkStyleContext* pScrollbarSliderStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarSliderStyle : mpHScrollbarSliderStyle; + + gtk_style_context_set_state(pScrollbarSliderStyle, stateFlags); + + GtkBorder margin; + gtk_style_context_get_margin(pScrollbarSliderStyle, stateFlags, &margin); + + gtk_render_background(pScrollbarSliderStyle, cr, + thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, + thumbRect.GetWidth() - margin.left - margin.right, + thumbRect.GetHeight() - margin.top - margin.bottom); + + gtk_render_frame(pScrollbarSliderStyle, cr, + thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, + thumbRect.GetWidth() - margin.left - margin.right, + thumbRect.GetHeight() - margin.top - margin.bottom); + } + bool backwardButtonInsensitive = rScrollbarVal.mnCur == rScrollbarVal.mnMin; bool forwardButtonInsensitive = rScrollbarVal.mnMax == 0 || @@ -591,11 +997,10 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); } // ----------------- BUTTON 2 - - if ( has_forward ) + if ( has_backward2 ) { - stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnButton2State); - if ( forwardButtonInsensitive ) + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnButton1State); + if ( backwardButtonInsensitive ) stateFlags = GTK_STATE_FLAG_INSENSITIVE; GtkStyleContext* pScrollbarButtonStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? @@ -604,24 +1009,23 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gtk_style_context_set_state(pScrollbarButtonStyle, stateFlags); gtk_render_background(pScrollbarButtonStyle, cr, - button22BoundRect.Left(), button22BoundRect.Top(), - button22BoundRect.GetWidth(), button22BoundRect.GetHeight() ); + button21BoundRect.Left(), button21BoundRect.Top(), + button21BoundRect.GetWidth(), button21BoundRect.GetHeight() ); gtk_render_frame(pScrollbarButtonStyle, cr, - button22BoundRect.Left(), button22BoundRect.Top(), - button22BoundRect.GetWidth(), button22BoundRect.GetHeight() ); + button21BoundRect.Left(), button21BoundRect.Top(), + button21BoundRect.GetWidth(), button21BoundRect.GetHeight() ); // ----------------- ARROW 2 - NWCalcArrowRect( button22BoundRect, arrowRect ); + NWCalcArrowRect( button21BoundRect, arrowRect ); gtk_render_arrow(pScrollbarButtonStyle, cr, - arrow2Angle, + arrow1Angle, arrowRect.Left(), arrowRect.Top(), MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); } - - if ( has_backward2 ) + if ( has_forward ) { - stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnButton1State); - if ( backwardButtonInsensitive ) + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnButton2State); + if ( forwardButtonInsensitive ) stateFlags = GTK_STATE_FLAG_INSENSITIVE; GtkStyleContext* pScrollbarButtonStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? @@ -630,70 +1034,19 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gtk_style_context_set_state(pScrollbarButtonStyle, stateFlags); gtk_render_background(pScrollbarButtonStyle, cr, - button21BoundRect.Left(), button21BoundRect.Top(), - button21BoundRect.GetWidth(), button21BoundRect.GetHeight() ); + button22BoundRect.Left(), button22BoundRect.Top(), + button22BoundRect.GetWidth(), button22BoundRect.GetHeight() ); gtk_render_frame(pScrollbarButtonStyle, cr, - button21BoundRect.Left(), button21BoundRect.Top(), - button21BoundRect.GetWidth(), button21BoundRect.GetHeight() ); + button22BoundRect.Left(), button22BoundRect.Top(), + button22BoundRect.GetWidth(), button22BoundRect.GetHeight() ); // ----------------- ARROW 2 - NWCalcArrowRect( button21BoundRect, arrowRect ); + NWCalcArrowRect( button22BoundRect, arrowRect ); gtk_render_arrow(pScrollbarButtonStyle, cr, - arrow1Angle, + arrow2Angle, arrowRect.Left(), arrowRect.Top(), MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); } - - // ----------------- TROUGH - // trackrect matches that of ScrollBar::ImplCalc - tools::Rectangle aTrackRect(Point(0, 0), scrollbarRect.GetSize()); - if (nPart == ControlPart::DrawBackgroundHorz) - { - tools::Rectangle aBtn1Rect = NWGetScrollButtonRect(ControlPart::ButtonLeft, aTrackRect); - tools::Rectangle aBtn2Rect = NWGetScrollButtonRect(ControlPart::ButtonRight, aTrackRect); - aTrackRect.Left() = aBtn1Rect.Right(); - aTrackRect.Right() = aBtn2Rect.Left(); - } - else - { - tools::Rectangle aBtn1Rect = NWGetScrollButtonRect(ControlPart::ButtonUp, aTrackRect); - tools::Rectangle aBtn2Rect = NWGetScrollButtonRect(ControlPart::ButtonDown, aTrackRect); - aTrackRect.Top() = aBtn1Rect.Bottom() + 1; - aTrackRect.Bottom() = aBtn2Rect.Top(); - } - - GtkStyleContext* pScrollbarTroughStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? - mpVScrollbarTroughStyle : mpHScrollbarTroughStyle; - gtk_render_background(pScrollbarTroughStyle, cr, aTrackRect.Left(), aTrackRect.Top(), - aTrackRect.GetWidth(), aTrackRect.GetHeight() ); - gtk_render_frame(pScrollbarTroughStyle, cr, aTrackRect.Left(), aTrackRect.Top(), - aTrackRect.GetWidth(), aTrackRect.GetHeight() ); - - // ----------------- THUMB - if ( has_slider ) - { - stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnThumbState); - if ( rScrollbarVal.mnThumbState & ControlState::PRESSED ) - stateFlags = (GtkStateFlags) (stateFlags | GTK_STATE_PRELIGHT); - - GtkStyleContext* pScrollbarSliderStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? - mpVScrollbarSliderStyle : mpHScrollbarSliderStyle; - - gtk_style_context_set_state(pScrollbarSliderStyle, stateFlags); - - GtkBorder margin; - gtk_style_context_get_margin(pScrollbarSliderStyle, stateFlags, &margin); - - gtk_render_background(pScrollbarSliderStyle, cr, - thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, - thumbRect.GetWidth() - margin.left - margin.right, - thumbRect.GetHeight() - margin.top - margin.bottom); - - gtk_render_frame(pScrollbarSliderStyle, cr, - thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, - thumbRect.GetWidth() - margin.left - margin.right, - thumbRect.GetHeight() - margin.top - margin.bottom); - } } void GtkSalGraphics::PaintOneSpinButton( GtkStyleContext *context, @@ -804,9 +1157,12 @@ tools::Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( gtk_style_context_get_padding( mpButtonStyle, gtk_style_context_get_state(mpButtonStyle), &padding); gint nArrowWidth = FALLBACK_ARROW_SIZE; - gtk_style_context_get(mpComboboxButtonArrowStyle, - gtk_style_context_get_state(mpComboboxButtonArrowStyle), - "min-width", &nArrowWidth, nullptr); + if (gtk_check_version(3, 20, 0) == nullptr) + { + gtk_style_context_get(mpComboboxButtonArrowStyle, + gtk_style_context_get_state(mpComboboxButtonArrowStyle), + "min-width", &nArrowWidth, nullptr); + } gint nButtonWidth = nArrowWidth + padding.left + padding.right; if( nPart == ControlPart::ButtonDown ) @@ -859,18 +1215,20 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, aEditBoxRect.SetPos( Point( areaRect.Left() + buttonRect.GetWidth(), areaRect.Top() ) ); gint arrow_width = FALLBACK_ARROW_SIZE, arrow_height = FALLBACK_ARROW_SIZE; - - if (nType == ControlType::Combobox) - { - gtk_style_context_get(mpComboboxButtonArrowStyle, - gtk_style_context_get_state(mpComboboxButtonArrowStyle), - "min-width", &arrow_width, "min-height", &arrow_height, nullptr); - } - else if (nType == ControlType::Listbox) + if (gtk_check_version(3, 20, 0) == nullptr) { - gtk_style_context_get(mpListboxButtonArrowStyle, - gtk_style_context_get_state(mpListboxButtonArrowStyle), - "min-width", &arrow_width, "min-height", &arrow_height, nullptr); + if (nType == ControlType::Combobox) + { + gtk_style_context_get(mpComboboxButtonArrowStyle, + gtk_style_context_get_state(mpComboboxButtonArrowStyle), + "min-width", &arrow_width, "min-height", &arrow_height, nullptr); + } + else if (nType == ControlType::Listbox) + { + gtk_style_context_get(mpListboxButtonArrowStyle, + gtk_style_context_get_state(mpListboxButtonArrowStyle), + "min-width", &arrow_width, "min-height", &arrow_height, nullptr); + } } arrowRect.SetSize(Size(arrow_width, arrow_height)); @@ -938,36 +1296,36 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, } } -static void appendComboEntry(GtkWidgetPath* pSiblingsPath) +static void appendComboEntry(GtkWidgetPath* pSiblingsPath, gtk_widget_path_iter_set_object_nameFunc set_object_name) { gtk_widget_path_append_type(pSiblingsPath, GTK_TYPE_ENTRY); - gtk_widget_path_iter_set_object_name(pSiblingsPath, -1, "entry"); + set_object_name(pSiblingsPath, -1, "entry"); gtk_widget_path_iter_add_class(pSiblingsPath, -1, "combo"); } -static void appendComboButton(GtkWidgetPath* pSiblingsPath) +static void appendComboButton(GtkWidgetPath* pSiblingsPath, gtk_widget_path_iter_set_object_nameFunc set_object_name) { gtk_widget_path_append_type(pSiblingsPath, GTK_TYPE_BUTTON); - gtk_widget_path_iter_set_object_name(pSiblingsPath, -1, "button"); + set_object_name(pSiblingsPath, -1, "button"); gtk_widget_path_iter_add_class(pSiblingsPath, -1, "combo"); } -static GtkWidgetPath* buildLTRComboSiblingsPath() +static GtkWidgetPath* buildLTRComboSiblingsPath(gtk_widget_path_iter_set_object_nameFunc set_object_name) { GtkWidgetPath* pSiblingsPath = gtk_widget_path_new(); - appendComboEntry(pSiblingsPath); - appendComboButton(pSiblingsPath); + appendComboEntry(pSiblingsPath, set_object_name); + appendComboButton(pSiblingsPath, set_object_name); return pSiblingsPath; } -static GtkWidgetPath* buildRTLComboSiblingsPath() +static GtkWidgetPath* buildRTLComboSiblingsPath(gtk_widget_path_iter_set_object_nameFunc set_object_name) { GtkWidgetPath* pSiblingsPath = gtk_widget_path_new(); - appendComboButton(pSiblingsPath); - appendComboEntry(pSiblingsPath); + appendComboButton(pSiblingsPath, set_object_name); + appendComboEntry(pSiblingsPath, set_object_name); return pSiblingsPath; } @@ -982,7 +1340,7 @@ GtkStyleContext* GtkSalGraphics::makeContext(GtkWidgetPath *pPath, GtkStyleConte return context; } -GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) +GtkStyleContext* GtkSalGraphics::createNewContext(GtkControlPart ePart, gtk_widget_path_iter_set_object_nameFunc set_object_name) { switch (ePart) { @@ -990,7 +1348,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "window"); + set_object_name(path, -1, "window"); gtk_widget_path_iter_add_class(path, -1, "background"); return makeContext(path, nullptr); } @@ -998,14 +1356,14 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "button"); + set_object_name(path, -1, "button"); return makeContext(path, nullptr); } case GtkControlPart::LinkButton: { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "button"); + set_object_name(path, -1, "button"); gtk_widget_path_iter_add_class(path, -1, "link"); return makeContext(path, nullptr); } @@ -1013,28 +1371,28 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_CHECK_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "checkbutton"); + set_object_name(path, -1, "checkbutton"); return makeContext(path, nullptr); } case GtkControlPart::CheckButtonCheck: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpCheckButtonStyle)); gtk_widget_path_append_type(path, GTK_TYPE_CHECK_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "check"); + set_object_name(path, -1, "check"); return makeContext(path, mpCheckButtonStyle); } case GtkControlPart::RadioButton: { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_RADIO_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "radiobutton"); + set_object_name(path, -1, "radiobutton"); return makeContext(path, nullptr); } case GtkControlPart::RadioButtonRadio: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpRadioButtonStyle)); gtk_widget_path_append_type(path, GTK_TYPE_RADIO_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "radio"); + set_object_name(path, -1, "radio"); return makeContext(path, mpRadioButtonStyle); } case GtkControlPart::ComboboxBoxButtonBoxArrow: @@ -1042,7 +1400,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpComboboxButtonBoxStyle)); gtk_widget_path_append_type(path, GTK_TYPE_RADIO_BUTTON); gtk_widget_path_append_type(path, GTK_TYPE_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "arrow"); + set_object_name(path, -1, "arrow"); return makeContext(path, mpComboboxButtonBoxStyle); } case GtkControlPart::ListboxBoxButtonBoxArrow: @@ -1050,14 +1408,14 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpListboxButtonBoxStyle)); gtk_widget_path_append_type(path, GTK_TYPE_RADIO_BUTTON); gtk_widget_path_append_type(path, GTK_TYPE_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "arrow"); + set_object_name(path, -1, "arrow"); return makeContext(path, mpListboxButtonBoxStyle); } case GtkControlPart::Entry: { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_ENTRY); - gtk_widget_path_iter_set_object_name(path, -1, "entry"); + set_object_name(path, -1, "entry"); return makeContext(path, nullptr); } case GtkControlPart::Combobox: @@ -1065,14 +1423,14 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "combobox"); + set_object_name(path, -1, "combobox"); return makeContext(path, nullptr); } case GtkControlPart::ComboboxBox: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpComboboxStyle)); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "box"); + set_object_name(path, -1, "box"); gtk_widget_path_iter_add_class(path, -1, "horizontal"); gtk_widget_path_iter_add_class(path, -1, "linked"); return makeContext(path, mpComboboxStyle); @@ -1081,7 +1439,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpListboxStyle)); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "box"); + set_object_name(path, -1, "box"); gtk_widget_path_iter_add_class(path, -1, "horizontal"); gtk_widget_path_iter_add_class(path, -1, "linked"); return makeContext(path, mpListboxStyle); @@ -1092,12 +1450,12 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) GtkWidgetPath* pSiblingsPath; if (AllSettings::GetLayoutRTL()) { - pSiblingsPath = buildRTLComboSiblingsPath(); + pSiblingsPath = buildRTLComboSiblingsPath(set_object_name); gtk_widget_path_append_with_siblings(path, pSiblingsPath, 1); } else { - pSiblingsPath = buildLTRComboSiblingsPath(); + pSiblingsPath = buildLTRComboSiblingsPath(set_object_name); gtk_widget_path_append_with_siblings(path, pSiblingsPath, 0); } gtk_widget_path_unref(pSiblingsPath); @@ -1109,12 +1467,12 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) GtkWidgetPath* pSiblingsPath; if (AllSettings::GetLayoutRTL()) { - pSiblingsPath = buildRTLComboSiblingsPath(); + pSiblingsPath = buildRTLComboSiblingsPath(set_object_name); gtk_widget_path_append_with_siblings(path, pSiblingsPath, 0); } else { - pSiblingsPath = buildLTRComboSiblingsPath(); + pSiblingsPath = buildLTRComboSiblingsPath(set_object_name); gtk_widget_path_append_with_siblings(path, pSiblingsPath, 1); } gtk_widget_path_unref(pSiblingsPath); @@ -1126,7 +1484,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) GtkWidgetPath* pSiblingsPath = gtk_widget_path_new(); gtk_widget_path_append_type(pSiblingsPath, GTK_TYPE_BUTTON); - gtk_widget_path_iter_set_object_name(pSiblingsPath, -1, "button"); + set_object_name(pSiblingsPath, -1, "button"); gtk_widget_path_iter_add_class(pSiblingsPath, -1, "combo"); gtk_widget_path_append_with_siblings(path, pSiblingsPath, 0); @@ -1137,7 +1495,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpComboboxButtonStyle)); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "box"); + set_object_name(path, -1, "box"); gtk_widget_path_iter_add_class(path, -1, "horizontal"); return makeContext(path, mpComboboxButtonStyle); } @@ -1145,7 +1503,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpListboxButtonStyle)); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "box"); + set_object_name(path, -1, "box"); gtk_widget_path_iter_add_class(path, -1, "horizontal"); return makeContext(path, mpListboxButtonStyle); } @@ -1153,7 +1511,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpWindowStyle)); gtk_widget_path_append_type(path, GTK_TYPE_SPIN_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "spinbutton"); + set_object_name(path, -1, "spinbutton"); gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_HORIZONTAL); return makeContext(path, mpWindowStyle); } @@ -1161,7 +1519,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpSpinStyle)); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "entry"); + set_object_name(path, -1, "entry"); return makeContext(path, mpSpinStyle); } case GtkControlPart::SpinButtonUpButton: @@ -1169,7 +1527,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpSpinStyle)); gtk_widget_path_append_type(path, GTK_TYPE_SPIN_BUTTON); - gtk_widget_path_iter_set_object_name(path, -1, "button"); + set_object_name(path, -1, "button"); gtk_widget_path_iter_add_class(path, -1, ePart == GtkControlPart::SpinButtonUpButton ? "up" : "down"); return makeContext(path, mpSpinStyle); } @@ -1178,7 +1536,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); - gtk_widget_path_iter_set_object_name(path, -1, "scrollbar"); + set_object_name(path, -1, "scrollbar"); gtk_widget_path_iter_add_class(path, -1, ePart == GtkControlPart::ScrollbarVertical ? "vertical" : "horizontal"); return makeContext(path, nullptr); } @@ -1189,7 +1547,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) (ePart == GtkControlPart::ScrollbarVerticalContents) ? mpVScrollbarStyle : mpHScrollbarStyle; GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); - gtk_widget_path_iter_set_object_name(path, -1, "contents"); + set_object_name(path, -1, "contents"); return makeContext(path, pParent); } case GtkControlPart::ScrollbarVerticalTrough: @@ -1199,7 +1557,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) (ePart == GtkControlPart::ScrollbarVerticalTrough) ? mpVScrollbarContentsStyle : mpHScrollbarContentsStyle; GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); - gtk_widget_path_iter_set_object_name(path, -1, "trough"); + set_object_name(path, -1, "trough"); return makeContext(path, pParent); } case GtkControlPart::ScrollbarVerticalSlider: @@ -1209,7 +1567,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) (ePart == GtkControlPart::ScrollbarVerticalSlider) ? mpVScrollbarTroughStyle : mpHScrollbarTroughStyle; GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); - gtk_widget_path_iter_set_object_name(path, -1, "slider"); + set_object_name(path, -1, "slider"); return makeContext(path, pParent); } case GtkControlPart::ScrollbarVerticalButton: @@ -1219,14 +1577,14 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) (ePart == GtkControlPart::ScrollbarVerticalButton) ? mpVScrollbarStyle : mpHScrollbarStyle; GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); - gtk_widget_path_iter_set_object_name(path, -1, "button"); + set_object_name(path, -1, "button"); return makeContext(path, pParent); } case GtkControlPart::ProgressBar: { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_PROGRESS_BAR); - gtk_widget_path_iter_set_object_name(path, -1, "progressbar"); + set_object_name(path, -1, "progressbar"); gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_HORIZONTAL); return makeContext(path, nullptr); } @@ -1234,35 +1592,35 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpProgressBarStyle)); gtk_widget_path_append_type(path, GTK_TYPE_PROGRESS_BAR); - gtk_widget_path_iter_set_object_name(path, -1, "trough"); + set_object_name(path, -1, "trough"); return makeContext(path, mpProgressBarStyle); } case GtkControlPart::ProgressBarProgress: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpProgressBarTroughStyle)); gtk_widget_path_append_type(path, GTK_TYPE_PROGRESS_BAR); - gtk_widget_path_iter_set_object_name(path, -1, "progress"); + set_object_name(path, -1, "progress"); return makeContext(path, mpProgressBarTroughStyle); } case GtkControlPart::Notebook: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpWindowStyle)); gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK); - gtk_widget_path_iter_set_object_name(path, -1, "notebook"); + set_object_name(path, -1, "notebook"); return makeContext(path, mpWindowStyle); } case GtkControlPart::NotebookStack: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookStyle)); gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK); - gtk_widget_path_iter_set_object_name(path, -1, "stack"); + set_object_name(path, -1, "stack"); return makeContext(path, mpNotebookStyle); } case GtkControlPart::NotebookHeader: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookStyle)); gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK); - gtk_widget_path_iter_set_object_name(path, -1, "header"); + set_object_name(path, -1, "header"); gtk_widget_path_iter_add_class(path, -1, "frame"); gtk_widget_path_iter_add_class(path, -1, "top"); return makeContext(path, mpNotebookStyle); @@ -1271,7 +1629,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookHeaderStyle)); gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK); - gtk_widget_path_iter_set_object_name(path, -1, "tabs"); + set_object_name(path, -1, "tabs"); gtk_widget_path_iter_add_class(path, -1, "top"); return makeContext(path, mpNotebookHeaderStyle); } @@ -1279,7 +1637,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookHeaderTabsStyle)); gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK); - gtk_widget_path_iter_set_object_name(path, -1, "tab"); + set_object_name(path, -1, "tab"); gtk_widget_path_iter_add_class(path, -1, "top"); return makeContext(path, mpNotebookHeaderTabsStyle); } @@ -1287,7 +1645,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookHeaderTabsTabStyle)); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "label"); + set_object_name(path, -1, "label"); return makeContext(path, mpNotebookHeaderTabsTabStyle); } case GtkControlPart::NotebookHeaderTabsTabActiveLabel: @@ -1297,7 +1655,7 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_FRAME); - gtk_widget_path_iter_set_object_name(path, -1, "frame"); + set_object_name(path, -1, "frame"); gtk_widget_path_iter_add_class(path, -1, "frame"); return makeContext(path, nullptr); } @@ -1305,21 +1663,21 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpWindowStyle)); gtk_widget_path_append_type(path, GTK_TYPE_MENU_BAR); - gtk_widget_path_iter_set_object_name(path, -1, "menubar"); + set_object_name(path, -1, "menubar"); return makeContext(path, mpWindowStyle); } case GtkControlPart::MenuBarItem: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuBarStyle)); gtk_widget_path_append_type(path, GTK_TYPE_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "menuitem"); + set_object_name(path, -1, "menuitem"); return makeContext(path, mpMenuBarStyle); } case GtkControlPart::MenuWindow: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuBarItemStyle)); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "window"); + set_object_name(path, -1, "window"); gtk_widget_path_iter_add_class(path, -1, "background"); gtk_widget_path_iter_add_class(path, -1, "popup"); return makeContext(path, mpMenuBarItemStyle); @@ -1328,70 +1686,70 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuWindowStyle)); gtk_widget_path_append_type(path, GTK_TYPE_MENU); - gtk_widget_path_iter_set_object_name(path, -1, "menu"); + set_object_name(path, -1, "menu"); return makeContext(path, mpMenuWindowStyle); } case GtkControlPart::MenuItem: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuStyle)); gtk_widget_path_append_type(path, GTK_TYPE_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "menuitem"); + set_object_name(path, -1, "menuitem"); return makeContext(path, mpMenuStyle); } case GtkControlPart::MenuItemLabel: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuItemStyle)); gtk_widget_path_append_type(path, G_TYPE_NONE); - gtk_widget_path_iter_set_object_name(path, -1, "label"); + set_object_name(path, -1, "label"); return makeContext(path, mpMenuItemStyle); } case GtkControlPart::MenuItemArrow: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuItemStyle)); gtk_widget_path_append_type(path, GTK_TYPE_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "arrow"); + set_object_name(path, -1, "arrow"); return makeContext(path, mpMenuItemStyle); } case GtkControlPart::CheckMenuItem: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuStyle)); gtk_widget_path_append_type(path, GTK_TYPE_CHECK_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "menuitem"); + set_object_name(path, -1, "menuitem"); return makeContext(path, mpMenuStyle); } case GtkControlPart::CheckMenuItemCheck: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpCheckMenuItemStyle)); gtk_widget_path_append_type(path, GTK_TYPE_CHECK_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "check"); + set_object_name(path, -1, "check"); return makeContext(path, mpCheckMenuItemStyle); } case GtkControlPart::RadioMenuItem: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuStyle)); gtk_widget_path_append_type(path, GTK_TYPE_RADIO_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "menuitem"); + set_object_name(path, -1, "menuitem"); return makeContext(path, mpMenuStyle); } case GtkControlPart::RadioMenuItemRadio: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpRadioMenuItemStyle)); gtk_widget_path_append_type(path, GTK_TYPE_RADIO_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "radio"); + set_object_name(path, -1, "radio"); return makeContext(path, mpRadioMenuItemStyle); } case GtkControlPart::SeparatorMenuItem: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuStyle)); gtk_widget_path_append_type(path, GTK_TYPE_SEPARATOR_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "menuitem"); + set_object_name(path, -1, "menuitem"); return makeContext(path, mpMenuStyle); } case GtkControlPart::SeparatorMenuItemSeparator: { GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpSeparatorMenuItemStyle)); gtk_widget_path_append_type(path, GTK_TYPE_SEPARATOR_MENU_ITEM); - gtk_widget_path_iter_set_object_name(path, -1, "separator"); + set_object_name(path, -1, "separator"); return makeContext(path, mpSeparatorMenuItemStyle); } } @@ -1399,6 +1757,372 @@ GtkStyleContext* GtkSalGraphics::createStyleContext(GtkControlPart ePart) return nullptr; } +#ifndef GTK_STYLE_CLASS_POPUP +#define GTK_STYLE_CLASS_POPUP "popup" +#endif +#ifndef GTK_STYLE_CLASS_LABEL +#define GTK_STYLE_CLASS_LABEL "label" +#endif + +GtkStyleContext* GtkSalGraphics::createOldContext(GtkControlPart ePart) +{ + switch (ePart) + { + case GtkControlPart::ToplevelWindow: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_WINDOW); + gtk_widget_path_iter_add_class(path, -1, "background"); + return makeContext(path, nullptr); + } + case GtkControlPart::Button: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_BUTTON); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_BUTTON); + gtk_widget_path_iter_add_class(path, -1, "button"); + gtk_widget_path_iter_add_class(path, -1, "text-button"); + return makeContext(path, nullptr); + } + case GtkControlPart::LinkButton: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_LINK_BUTTON); + gtk_widget_path_iter_add_class(path, -1, "text-button"); + return makeContext(path, nullptr); + } + case GtkControlPart::CheckButton: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_CHECK_BUTTON); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_CHECK); + gtk_widget_path_iter_add_class(path, -1, "text-button"); + return makeContext(path, nullptr); + } + case GtkControlPart::CheckButtonCheck: + return mpCheckButtonStyle; + case GtkControlPart::RadioButton: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_RADIO_BUTTON); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_RADIO); + gtk_widget_path_iter_add_class(path, -1, "text-button"); + return makeContext(path, nullptr); + } + case GtkControlPart::RadioButtonRadio: + return mpRadioButtonStyle; + case GtkControlPart::ComboboxBoxButtonBoxArrow: + case GtkControlPart::ListboxBoxButtonBoxArrow: + { + return (ePart == GtkControlPart::ComboboxBoxButtonBoxArrow) + ? mpComboboxButtonStyle : mpListboxButtonStyle; + } + case GtkControlPart::Entry: + case GtkControlPart::ComboboxBoxEntry: + case GtkControlPart::SpinButtonEntry: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_ENTRY); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_ENTRY); + return makeContext(path, nullptr); + } + case GtkControlPart::Combobox: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_COMBO_BOX_TEXT); + return makeContext(path, nullptr); + } + case GtkControlPart::Listbox: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_COMBO_BOX); + return makeContext(path, nullptr); + } + case GtkControlPart::ComboboxBoxButton: + case GtkControlPart::ListboxBoxButton: + { + GtkStyleContext *pParent = + (ePart == GtkControlPart::ComboboxBoxButton ) ? mpComboboxStyle : mpListboxStyle; + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); + gtk_widget_path_append_type(path, GTK_TYPE_TOGGLE_BUTTON); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_BUTTON); + gtk_widget_path_iter_add_class(path, -1, "the-button-in-the-combobox"); + return makeContext(path, pParent); + } + case GtkControlPart::SpinButton: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_SPIN_BUTTON); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_ENTRY); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_HORIZONTAL); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SPINBUTTON); + return makeContext(path, nullptr); + } + case GtkControlPart::SpinButtonUpButton: + case GtkControlPart::SpinButtonDownButton: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpSpinStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_SPIN_BUTTON); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SPINBUTTON); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_BUTTON); + return makeContext(path, mpSpinStyle); + } + case GtkControlPart::ScrollbarVertical: + case GtkControlPart::ScrollbarHorizontal: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, ePart == GtkControlPart::ScrollbarVertical ? "vertical" : "horizontal"); + return makeContext(path, nullptr); + } + case GtkControlPart::ScrollbarVerticalContents: + case GtkControlPart::ScrollbarHorizontalContents: + { + GtkStyleContext *pParent = + (ePart == GtkControlPart::ScrollbarVerticalContents) ? mpVScrollbarStyle : mpHScrollbarStyle; + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); + gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, "contents"); + return makeContext(path, pParent); + } + case GtkControlPart::ScrollbarHorizontalTrough: + case GtkControlPart::ScrollbarVerticalTrough: + { + GtkStyleContext *pParent = + (ePart == GtkControlPart::ScrollbarVerticalTrough) ? mpVScrollbarContentsStyle : mpHScrollbarContentsStyle; + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); + gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_TROUGH); + return makeContext(path, pParent); + } + case GtkControlPart::ScrollbarHorizontalSlider: + case GtkControlPart::ScrollbarVerticalSlider: + { + GtkStyleContext *pParent = + (ePart == GtkControlPart::ScrollbarVerticalSlider) ? mpVScrollbarContentsStyle : mpHScrollbarContentsStyle; + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); + gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SLIDER); + return makeContext(path, pParent); + } + case GtkControlPart::ScrollbarHorizontalButton: + case GtkControlPart::ScrollbarVerticalButton: + { + GtkStyleContext *pParent = + (ePart == GtkControlPart::ScrollbarVerticalButton) ? mpVScrollbarStyle : mpHScrollbarStyle; + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(pParent)); + gtk_widget_path_append_type(path, GTK_TYPE_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SCROLLBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_BUTTON); + return makeContext(path, pParent); + } + case GtkControlPart::ProgressBar: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_PROGRESS_BAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_PROGRESSBAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_HORIZONTAL); + return makeContext(path, nullptr); + } + case GtkControlPart::ProgressBarTrough: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpProgressBarStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_PROGRESS_BAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_TROUGH); + return makeContext(path, mpProgressBarStyle); + } + case GtkControlPart::ProgressBarProgress: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpProgressBarTroughStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_PROGRESS_BAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_PROGRESSBAR); + return makeContext(path, mpProgressBarTroughStyle); + } + case GtkControlPart::Notebook: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpWindowStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_NOTEBOOK); + gtk_widget_path_iter_add_class(path, -1, "frame"); + return makeContext(path, mpWindowStyle); + } + case GtkControlPart::NotebookStack: + return mpNotebookStyle; + case GtkControlPart::NotebookHeader: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookStyle)); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_HEADER); + gtk_widget_path_iter_add_class(path, -1, "top"); + return makeContext(path, gtk_style_context_get_parent(mpNotebookStyle)); + } + case GtkControlPart::NotebookHeaderTabs: + return mpNotebookHeaderStyle; + case GtkControlPart::NotebookHeaderTabsTab: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookHeaderTabsStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_HEADER); + gtk_widget_path_iter_add_class(path, -1, "top"); + gtk_widget_path_iter_add_region(path, -1, GTK_STYLE_REGION_TAB, static_cast<GtkRegionFlags>(GTK_REGION_EVEN | GTK_REGION_FIRST)); + return makeContext(path, mpNotebookHeaderTabsStyle); + } + case GtkControlPart::NotebookHeaderTabsTabLabel: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookHeaderTabsTabStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_LABEL); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_LABEL); + return makeContext(path, mpNotebookHeaderTabsTabStyle); + } + case GtkControlPart::NotebookHeaderTabsTabActiveLabel: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookHeaderTabsTabStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_LABEL); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_LABEL); + gtk_widget_path_iter_add_class(path, -1, "active-page"); + return makeContext(path, mpNotebookHeaderTabsTabStyle); + } + case GtkControlPart::NotebookHeaderTabsTabHoverLabel: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpNotebookHeaderTabsTabStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_LABEL); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_LABEL); + gtk_widget_path_iter_add_class(path, -1, "prelight-page"); + return makeContext(path, mpNotebookHeaderTabsTabStyle); + } + case GtkControlPart::FrameBorder: + { + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_FRAME); + gtk_widget_path_iter_add_class(path, -1, "frame"); + return makeContext(path, nullptr); + } + case GtkControlPart::MenuBar: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpWindowStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_MENU_BAR); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_MENUBAR); + return makeContext(path, mpWindowStyle); + } + case GtkControlPart::MenuBarItem: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuBarStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_MENUITEM); + return makeContext(path, mpMenuBarStyle); + } + case GtkControlPart::MenuWindow: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuBarItemStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_WINDOW); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_POPUP); + gtk_widget_path_iter_add_class(path, -1, "background"); + return makeContext(path, mpMenuBarItemStyle); + } + case GtkControlPart::Menu: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuWindowStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_MENU); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_MENU); + return makeContext(path, mpMenuWindowStyle); + } + case GtkControlPart::MenuItem: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_MENUITEM); + return makeContext(path, mpMenuStyle); + } + case GtkControlPart::MenuItemLabel: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuItemStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_LABEL); + return makeContext(path, mpMenuItemStyle); + } + case GtkControlPart::MenuItemArrow: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuItemStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_ARROW); + return makeContext(path, mpMenuItemStyle); + } + case GtkControlPart::CheckMenuItem: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_CHECK_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_CHECK); + return makeContext(path, mpMenuStyle); + } + case GtkControlPart::CheckMenuItemCheck: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpCheckMenuItemStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_CHECK_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_CHECK); + return makeContext(path, mpCheckMenuItemStyle); + } + case GtkControlPart::RadioMenuItem: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_RADIO_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_MENUITEM); + return makeContext(path, mpMenuStyle); + } + case GtkControlPart::RadioMenuItemRadio: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpRadioMenuItemStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_RADIO_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_RADIO); + return makeContext(path, mpRadioMenuItemStyle); + } + case GtkControlPart::SeparatorMenuItem: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpMenuStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_SEPARATOR_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_MENUITEM); + return makeContext(path, mpMenuStyle); + } + case GtkControlPart::SeparatorMenuItemSeparator: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpSeparatorMenuItemStyle)); + gtk_widget_path_append_type(path, GTK_TYPE_SEPARATOR_MENU_ITEM); + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_SEPARATOR); + return makeContext(path, mpSeparatorMenuItemStyle); + } + case GtkControlPart::ComboboxBox: + case GtkControlPart::ListboxBox: + case GtkControlPart::ComboboxBoxButtonBox: + case GtkControlPart::ListboxBoxButtonBox: + return nullptr; + default: + break; + } + + return mpButtonStyle; +} + +GtkStyleContext* GtkSalGraphics::createStyleContext(gtk_widget_path_iter_set_object_nameFunc set_object_name, + GtkControlPart ePart) +{ + if (set_object_name) + return createNewContext(ePart, set_object_name); + return createOldContext(ePart); +} + +namespace +{ + GtkStateFlags ACTIVE_TAB() + { +#if GTK_CHECK_VERSION(3,20,0) + if (gtk_check_version(3, 20, 0) == nullptr) + return GTK_STATE_FLAG_CHECKED; +#endif + return GTK_STATE_FLAG_ACTIVE; + } +} + void GtkSalGraphics::PaintCheckOrRadio(cairo_t *cr, GtkStyleContext *context, const tools::Rectangle& rControlRectangle, bool bIsCheck, bool bInMenu) { @@ -1445,6 +2169,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co { RenderType renderType = nPart == ControlPart::Focus ? RenderType::Focus : RenderType::BackgroundAndFrame; GtkStyleContext *context = nullptr; + const gchar *styleClass = nullptr; GdkPixbuf *pixbuf = nullptr; bool bInMenu = false; @@ -1493,7 +2218,13 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co renderType = RenderType::BackgroundAndFrame; break; case ControlPart::MenuItemCheckMark: - context = mpCheckMenuItemCheckStyle; + if (gtk_check_version(3, 20, 0) == nullptr) + context = mpCheckMenuItemCheckStyle; + else + { + context = gtk_widget_get_style_context(gCheckMenuItemWidget); + styleClass = GTK_STYLE_CLASS_CHECK; + } renderType = RenderType::Check; nType = ControlType::Checkbox; if (nState & ControlState::PRESSED) @@ -1502,7 +2233,13 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co } break; case ControlPart::MenuItemRadioMark: - context = mpRadioMenuItemRadioStyle; + if (gtk_check_version(3, 20, 0) == nullptr) + context = mpRadioMenuItemRadioStyle; + else + { + context = gtk_widget_get_style_context(gCheckMenuItemWidget); + styleClass = GTK_STYLE_CLASS_RADIO; + } renderType = RenderType::Radio; nType = ControlType::Radiobutton; if (nState & ControlState::PRESSED) @@ -1516,7 +2253,13 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co renderType = RenderType::MenuSeparator; break; case ControlPart::SubmenuArrow: - context = mpMenuItemArrowStyle; + if (gtk_check_version(3, 20, 0) == nullptr) + context = mpMenuItemArrowStyle; + else + { + context = gtk_widget_get_style_context(gCheckMenuItemWidget); + styleClass = GTK_STYLE_CLASS_ARROW; + } renderType = RenderType::Arrow; break; case ControlPart::Entire: @@ -1591,7 +2334,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co case ControlType::TabItem: context = mpNotebookHeaderTabsTabStyle; if (nState & ControlState::SELECTED) - flags = (GtkStateFlags) (flags | GTK_STATE_FLAG_CHECKED); + flags = (GtkStateFlags) (flags | ACTIVE_TAB()); renderType = RenderType::TabItem; break; case ControlType::WindowBackground: @@ -1665,6 +2408,11 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co style_context_set_state(context, flags); + if (styleClass) + { + gtk_style_context_add_class(context, styleClass); + } + switch(renderType) { case RenderType::Background: @@ -1692,11 +2440,16 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co break; case RenderType::ToolbarSeparator: { + const bool bNewStyle = gtk_check_version(3, 20, 0) == nullptr; + gint nSeparatorWidth = 1; - gtk_style_context_get(context, - gtk_style_context_get_state(context), - "min-width", &nSeparatorWidth, nullptr); + if (bNewStyle) + { + gtk_style_context_get(context, + gtk_style_context_get_state(context), + "min-width", &nSeparatorWidth, nullptr); + } gint nHalfSeparatorWidth = nSeparatorWidth / 2; gint nHalfRegionWidth = rControlRegion.GetWidth() / 2; @@ -1706,8 +2459,15 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co nY = rControlRegion.GetHeight() * 0.1; nHeight = rControlRegion.GetHeight() - (2 * nY); - gtk_render_background(context, cr, nX, nY, nSeparatorWidth, nHeight); - gtk_render_frame(context, cr, nX, nY, nSeparatorWidth, nHeight); + if (bNewStyle) + { + gtk_render_background(context, cr, nX, nY, nSeparatorWidth, nHeight); + gtk_render_frame(context, cr, nX, nY, nSeparatorWidth, nHeight); + } + else + { + gtk_render_line(context, cr, nX, nY, nX, nY + nHeight); + } break; } case RenderType::Separator: @@ -1779,6 +2539,16 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co } case RenderType::TabItem: { + if (gtk_check_version(3, 20, 0) != nullptr) + { + gint initial_gap(0); + gtk_style_context_get_style(mpNotebookStyle, + "initial-gap", &initial_gap, + nullptr); + + nX += initial_gap/2; + nWidth -= initial_gap; + } tools::Rectangle aRect(Point(nX, nY), Size(nWidth, nHeight)); render_common(mpNotebookHeaderTabsTabStyle, cr, aRect, flags); break; @@ -1787,6 +2557,11 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co break; } + if (styleClass) + { + gtk_style_context_remove_class(context, styleClass); + } + cairo_destroy(cr); // unref if (!rControlRegion.IsEmpty()) @@ -2270,7 +3045,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) { GtkStyleContext *pCStyle = mpNotebookHeaderTabsTabActiveLabelStyle; - style_context_set_state(pCStyle, GTK_STATE_FLAG_CHECKED); + style_context_set_state(pCStyle, ACTIVE_TAB()); gtk_style_context_get_color(pCStyle, gtk_style_context_get_state(pCStyle), &text_color); aTextColor = getColor( text_color ); aStyleSet.SetTabHighlightTextColor(aTextColor); @@ -2319,27 +3094,44 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) gint min_slider_length = 21; // Grab some button style attributes - Size aSize; - QuerySize(mpHScrollbarStyle, aSize); - QuerySize(mpHScrollbarContentsStyle, aSize); - QuerySize(mpHScrollbarTroughStyle, aSize); - QuerySize(mpHScrollbarSliderStyle, aSize); - - gboolean has_forward, has_forward2, has_backward, has_backward2; - gtk_style_context_get_style(mpHScrollbarStyle, - "has-forward-stepper", &has_forward, - "has-secondary-forward-stepper", &has_forward2, - "has-backward-stepper", &has_backward, - "has-secondary-backward-stepper", &has_backward2, nullptr); - if (has_forward || has_backward || has_forward2 || has_backward2) - QuerySize(mpHScrollbarButtonStyle, aSize); - - aStyleSet.SetScrollBarSize(aSize.Height()); - - gtk_style_context_get(mpVScrollbarSliderStyle, gtk_style_context_get_state(mpVScrollbarSliderStyle), - "min-height", &min_slider_length, - nullptr); - aStyleSet.SetMinThumbSize(min_slider_length); + if (gtk_check_version(3, 20, 0) == nullptr) + { + Size aSize; + QuerySize(mpHScrollbarStyle, aSize); + QuerySize(mpHScrollbarContentsStyle, aSize); + QuerySize(mpHScrollbarTroughStyle, aSize); + QuerySize(mpHScrollbarSliderStyle, aSize); + + gboolean has_forward, has_forward2, has_backward, has_backward2; + gtk_style_context_get_style(mpHScrollbarStyle, + "has-forward-stepper", &has_forward, + "has-secondary-forward-stepper", &has_forward2, + "has-backward-stepper", &has_backward, + "has-secondary-backward-stepper", &has_backward2, nullptr); + if (has_forward || has_backward || has_forward2 || has_backward2) + QuerySize(mpHScrollbarButtonStyle, aSize); + + aStyleSet.SetScrollBarSize(aSize.Height()); + + gtk_style_context_get(mpVScrollbarSliderStyle, gtk_style_context_get_state(mpVScrollbarSliderStyle), + "min-height", &min_slider_length, + nullptr); + aStyleSet.SetMinThumbSize(min_slider_length); + } + else + { + gint slider_width = 14; + gint trough_border = 1; + + gtk_style_context_get_style(mpVScrollbarStyle, + "slider-width", &slider_width, + "trough-border", &trough_border, + "min-slider-length", &min_slider_length, + nullptr); + aStyleSet.SetScrollBarSize(slider_width + 2*trough_border); + gint magic = trough_border ? 1 : 0; + aStyleSet.SetMinThumbSize(min_slider_length - magic); + } // preferred icon style gchar* pIconThemeName = nullptr; @@ -2549,6 +3341,9 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) /* Load the GtkStyleContexts, it might be a bit slow, but usually, * gtk apps create a lot of widgets at startup, so, it shouldn't be * too slow */ + gtk_widget_path_iter_set_object_nameFunc set_object_name = + reinterpret_cast<gtk_widget_path_iter_set_object_nameFunc>(osl_getAsciiFunctionSymbol(nullptr, + "gtk_widget_path_iter_set_object_name")); gCacheWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); gDumbContainer = gtk_fixed_new(); @@ -2559,13 +3354,13 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gEntryBox = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(gDumbContainer), gEntryBox); - mpWindowStyle = createStyleContext(GtkControlPart::ToplevelWindow); - mpEntryStyle = createStyleContext(GtkControlPart::Entry); + mpWindowStyle = createStyleContext(set_object_name, GtkControlPart::ToplevelWindow); + mpEntryStyle = createStyleContext(set_object_name, GtkControlPart::Entry); getStyleContext(&mpTextViewStyle, gtk_text_view_new()); - mpButtonStyle = createStyleContext(GtkControlPart::Button); - mpLinkButtonStyle = createStyleContext(GtkControlPart::LinkButton); + mpButtonStyle = createStyleContext(set_object_name, GtkControlPart::Button); + mpLinkButtonStyle = createStyleContext(set_object_name, GtkControlPart::LinkButton); GtkWidget* pToolbar = gtk_toolbar_new(); mpToolbarStyle = gtk_widget_get_style_context(pToolbar); @@ -2580,60 +3375,60 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), item, -1); mpToolButtonStyle = gtk_widget_get_style_context(GTK_WIDGET(pButton)); - mpVScrollbarStyle = createStyleContext(GtkControlPart::ScrollbarVertical); - mpVScrollbarContentsStyle = createStyleContext(GtkControlPart::ScrollbarVerticalContents); - mpVScrollbarTroughStyle = createStyleContext(GtkControlPart::ScrollbarVerticalTrough); - mpVScrollbarSliderStyle = createStyleContext(GtkControlPart::ScrollbarVerticalSlider); - mpVScrollbarButtonStyle = createStyleContext(GtkControlPart::ScrollbarVerticalButton); - mpHScrollbarStyle = createStyleContext(GtkControlPart::ScrollbarHorizontal); - mpHScrollbarContentsStyle = createStyleContext(GtkControlPart::ScrollbarHorizontalContents); - mpHScrollbarTroughStyle = createStyleContext(GtkControlPart::ScrollbarHorizontalTrough); - mpHScrollbarSliderStyle = createStyleContext(GtkControlPart::ScrollbarHorizontalSlider); - mpHScrollbarButtonStyle = createStyleContext(GtkControlPart::ScrollbarHorizontalButton); + mpVScrollbarStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarVertical); + mpVScrollbarContentsStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarVerticalContents); + mpVScrollbarTroughStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarVerticalTrough); + mpVScrollbarSliderStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarVerticalSlider); + mpVScrollbarButtonStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarVerticalButton); + mpHScrollbarStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarHorizontal); + mpHScrollbarContentsStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarHorizontalContents); + mpHScrollbarTroughStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarHorizontalTrough); + mpHScrollbarSliderStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarHorizontalSlider); + mpHScrollbarButtonStyle = createStyleContext(set_object_name, GtkControlPart::ScrollbarHorizontalButton); - mpCheckButtonStyle = createStyleContext(GtkControlPart::CheckButton); - mpCheckButtonCheckStyle = createStyleContext(GtkControlPart::CheckButtonCheck); + mpCheckButtonStyle = createStyleContext(set_object_name, GtkControlPart::CheckButton); + mpCheckButtonCheckStyle = createStyleContext(set_object_name, GtkControlPart::CheckButtonCheck); - mpRadioButtonStyle = createStyleContext(GtkControlPart::RadioButton); - mpRadioButtonRadioStyle = createStyleContext(GtkControlPart::RadioButtonRadio); + mpRadioButtonStyle = createStyleContext(set_object_name, GtkControlPart::RadioButton); + mpRadioButtonRadioStyle = createStyleContext(set_object_name, GtkControlPart::RadioButtonRadio); /* Spinbutton */ gSpinBox = gtk_spin_button_new(nullptr, 0, 0); gtk_container_add(GTK_CONTAINER(gDumbContainer), gSpinBox); - mpSpinStyle = createStyleContext(GtkControlPart::SpinButton); - mpSpinEntryStyle = createStyleContext(GtkControlPart::SpinButtonEntry); - mpSpinUpStyle = createStyleContext(GtkControlPart::SpinButtonUpButton); - mpSpinDownStyle = createStyleContext(GtkControlPart::SpinButtonDownButton); + mpSpinStyle = createStyleContext(set_object_name, GtkControlPart::SpinButton); + mpSpinEntryStyle = createStyleContext(set_object_name, GtkControlPart::SpinButtonEntry); + mpSpinUpStyle = createStyleContext(set_object_name, GtkControlPart::SpinButtonUpButton); + mpSpinDownStyle = createStyleContext(set_object_name, GtkControlPart::SpinButtonDownButton); /* NoteBook */ - mpNotebookStyle = createStyleContext(GtkControlPart::Notebook); - mpNotebookStackStyle = createStyleContext(GtkControlPart::NotebookStack); - mpNotebookHeaderStyle = createStyleContext(GtkControlPart::NotebookHeader); - mpNotebookHeaderTabsStyle = createStyleContext(GtkControlPart::NotebookHeaderTabs); - mpNotebookHeaderTabsTabStyle = createStyleContext(GtkControlPart::NotebookHeaderTabsTab); - mpNotebookHeaderTabsTabLabelStyle = createStyleContext(GtkControlPart::NotebookHeaderTabsTabLabel); - mpNotebookHeaderTabsTabActiveLabelStyle = createStyleContext(GtkControlPart::NotebookHeaderTabsTabActiveLabel); - mpNotebookHeaderTabsTabHoverLabelStyle = createStyleContext(GtkControlPart::NotebookHeaderTabsTabHoverLabel); + mpNotebookStyle = createStyleContext(set_object_name, GtkControlPart::Notebook); + mpNotebookStackStyle = createStyleContext(set_object_name, GtkControlPart::NotebookStack); + mpNotebookHeaderStyle = createStyleContext(set_object_name, GtkControlPart::NotebookHeader); + mpNotebookHeaderTabsStyle = createStyleContext(set_object_name, GtkControlPart::NotebookHeaderTabs); + mpNotebookHeaderTabsTabStyle = createStyleContext(set_object_name, GtkControlPart::NotebookHeaderTabsTab); + mpNotebookHeaderTabsTabLabelStyle = createStyleContext(set_object_name, GtkControlPart::NotebookHeaderTabsTabLabel); + mpNotebookHeaderTabsTabActiveLabelStyle = createStyleContext(set_object_name, GtkControlPart::NotebookHeaderTabsTabActiveLabel); + mpNotebookHeaderTabsTabHoverLabelStyle = createStyleContext(set_object_name, GtkControlPart::NotebookHeaderTabsTabHoverLabel); /* Combobox */ gComboBox = gtk_combo_box_text_new_with_entry(); gtk_container_add(GTK_CONTAINER(gDumbContainer), gComboBox); - mpComboboxStyle = createStyleContext(GtkControlPart::Combobox); - mpComboboxBoxStyle = createStyleContext(GtkControlPart::ComboboxBox); - mpComboboxEntryStyle = createStyleContext(GtkControlPart::ComboboxBoxEntry); - mpComboboxButtonStyle = createStyleContext(GtkControlPart::ComboboxBoxButton); - mpComboboxButtonBoxStyle = createStyleContext(GtkControlPart::ComboboxBoxButtonBox); - mpComboboxButtonArrowStyle = createStyleContext(GtkControlPart::ComboboxBoxButtonBoxArrow); + mpComboboxStyle = createStyleContext(set_object_name, GtkControlPart::Combobox); + mpComboboxBoxStyle = createStyleContext(set_object_name, GtkControlPart::ComboboxBox); + mpComboboxEntryStyle = createStyleContext(set_object_name, GtkControlPart::ComboboxBoxEntry); + mpComboboxButtonStyle = createStyleContext(set_object_name, GtkControlPart::ComboboxBoxButton); + mpComboboxButtonBoxStyle = createStyleContext(set_object_name, GtkControlPart::ComboboxBoxButtonBox); + mpComboboxButtonArrowStyle = createStyleContext(set_object_name, GtkControlPart::ComboboxBoxButtonBoxArrow); /* Listbox */ gListBox = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gListBox), "sample"); gtk_container_add(GTK_CONTAINER(gDumbContainer), gListBox); - mpListboxStyle = createStyleContext(GtkControlPart::Listbox); - mpListboxBoxStyle = createStyleContext(GtkControlPart::ListboxBox); - mpListboxButtonStyle = createStyleContext(GtkControlPart::ListboxBoxButton); - mpListboxButtonBoxStyle = createStyleContext(GtkControlPart::ListboxBoxButtonBox); - mpListboxButtonArrowStyle = createStyleContext(GtkControlPart::ListboxBoxButtonBoxArrow); + mpListboxStyle = createStyleContext(set_object_name, GtkControlPart::Listbox); + mpListboxBoxStyle = createStyleContext(set_object_name, GtkControlPart::ListboxBox); + mpListboxButtonStyle = createStyleContext(set_object_name, GtkControlPart::ListboxBoxButton); + mpListboxButtonBoxStyle = createStyleContext(set_object_name, GtkControlPart::ListboxBoxButtonBox); + mpListboxButtonArrowStyle = createStyleContext(set_object_name, GtkControlPart::ListboxBoxButtonBoxArrow); /* Menu bar */ gMenuBarWidget = gtk_menu_bar_new(); @@ -2641,12 +3436,12 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gtk_menu_shell_append(GTK_MENU_SHELL(gMenuBarWidget), gMenuItemMenuBarWidget); gtk_container_add(GTK_CONTAINER(gDumbContainer), gMenuBarWidget); - mpMenuBarStyle = createStyleContext(GtkControlPart::MenuBar); - mpMenuBarItemStyle = createStyleContext(GtkControlPart::MenuBarItem); + mpMenuBarStyle = createStyleContext(set_object_name, GtkControlPart::MenuBar); + mpMenuBarItemStyle = createStyleContext(set_object_name, GtkControlPart::MenuBarItem); /* Menu */ - mpMenuWindowStyle = createStyleContext(GtkControlPart::MenuWindow); - mpMenuStyle = createStyleContext(GtkControlPart::Menu); + mpMenuWindowStyle = createStyleContext(set_object_name, GtkControlPart::MenuWindow); + mpMenuStyle = createStyleContext(set_object_name, GtkControlPart::Menu); GtkWidget *menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(gMenuItemMenuBarWidget), menu); @@ -2654,18 +3449,18 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), gCheckMenuItemWidget); - mpMenuItemStyle = createStyleContext(GtkControlPart::MenuItem); - mpMenuItemLabelStyle = createStyleContext(GtkControlPart::MenuItemLabel); - mpMenuItemArrowStyle = createStyleContext(GtkControlPart::MenuItemArrow); - mpCheckMenuItemStyle = createStyleContext(GtkControlPart::CheckMenuItem); - mpCheckMenuItemCheckStyle = createStyleContext(GtkControlPart::CheckMenuItemCheck); - mpRadioMenuItemStyle = createStyleContext(GtkControlPart::RadioMenuItem); - mpRadioMenuItemRadioStyle = createStyleContext(GtkControlPart::RadioMenuItemRadio); - mpSeparatorMenuItemStyle = createStyleContext(GtkControlPart::SeparatorMenuItem); - mpSeparatorMenuItemSeparatorStyle = createStyleContext(GtkControlPart::SeparatorMenuItemSeparator); + mpMenuItemStyle = createStyleContext(set_object_name, GtkControlPart::MenuItem); + mpMenuItemLabelStyle = createStyleContext(set_object_name, GtkControlPart::MenuItemLabel); + mpMenuItemArrowStyle = createStyleContext(set_object_name, GtkControlPart::MenuItemArrow); + mpCheckMenuItemStyle = createStyleContext(set_object_name, GtkControlPart::CheckMenuItem); + mpCheckMenuItemCheckStyle = createStyleContext(set_object_name, GtkControlPart::CheckMenuItemCheck); + mpRadioMenuItemStyle = createStyleContext(set_object_name, GtkControlPart::RadioMenuItem); + mpRadioMenuItemRadioStyle = createStyleContext(set_object_name, GtkControlPart::RadioMenuItemRadio); + mpSeparatorMenuItemStyle = createStyleContext(set_object_name, GtkControlPart::SeparatorMenuItem); + mpSeparatorMenuItemSeparatorStyle = createStyleContext(set_object_name, GtkControlPart::SeparatorMenuItemSeparator); /* Frames */ - mpFrameOutStyle = mpFrameInStyle = createStyleContext(GtkControlPart::FrameBorder); + mpFrameOutStyle = mpFrameInStyle = createStyleContext(set_object_name, GtkControlPart::FrameBorder); getStyleContext(&mpFixedHoriLineStyle, gtk_separator_new(GTK_ORIENTATION_HORIZONTAL)); getStyleContext(&mpFixedVertLineStyle, gtk_separator_new(GTK_ORIENTATION_VERTICAL)); @@ -2692,9 +3487,9 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) mpTreeHeaderButtonStyle = gtk_widget_get_style_context(pTreeHeaderCellWidget); /* Progress Bar */ - mpProgressBarStyle = createStyleContext(GtkControlPart::ProgressBar); - mpProgressBarTroughStyle = createStyleContext(GtkControlPart::ProgressBarTrough); - mpProgressBarProgressStyle = createStyleContext(GtkControlPart::ProgressBarProgress); + mpProgressBarStyle = createStyleContext(set_object_name, GtkControlPart::ProgressBar); + mpProgressBarTroughStyle = createStyleContext(set_object_name, GtkControlPart::ProgressBarTrough); + mpProgressBarProgressStyle = createStyleContext(set_object_name, GtkControlPart::ProgressBarProgress); gtk_widget_show_all(gDumbContainer); } |