summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-10-14 10:30:32 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-10-14 10:34:59 +0100
commit6e8dbdbe1a9d15d7e7d000e4132fd5df3fecd660 (patch)
tree69e56e851970706d3fba9f18281b4d0f7512eff8
parentd2081e8b61bbe982f4e0977c2b46e00ccf19732f (diff)
Related: tdf#101699 gtk3: get correct combobox and listbox arrows
Change-Id: Ib2322bfda09b05925c74d93a530b9ed9fac73032
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx3
-rw-r--r--vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx33
2 files changed, 32 insertions, 4 deletions
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index cd369e52ef37..802dd9ad9a33 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -40,6 +40,7 @@ enum class GtkControlPart
RadioButton,
RadioButtonRadio,
Entry,
+ Arrow,
SpinButton,
SpinButtonUpButton,
SpinButtonDownButton,
@@ -131,8 +132,10 @@ private:
static GtkStyleContext *mpSeparatorMenuItemStyle;
static GtkStyleContext *mpComboboxStyle;
static GtkStyleContext *mpComboboxButtonStyle;
+ static GtkStyleContext *mpComboboxButtonArrowStyle;
static GtkStyleContext *mpListboxStyle;
static GtkStyleContext *mpListboxButtonStyle;
+ static GtkStyleContext *mpListboxButtonArrowStyle;
static GtkStyleContext *mpFrameInStyle;
static GtkStyleContext *mpFrameOutStyle;
static GtkStyleContext *mpFixedHoriLineStyle;
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index b904dfc3dcef..fa6a06408ea0 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -53,8 +53,10 @@ GtkStyleContext* GtkSalGraphics::mpSpinUpStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpSpinDownStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpComboboxStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpComboboxButtonStyle = nullptr;
+GtkStyleContext* GtkSalGraphics::mpComboboxButtonArrowStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpListboxStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpListboxButtonStyle = nullptr;
+GtkStyleContext* GtkSalGraphics::mpListboxButtonArrowStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpFrameInStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpFrameOutStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpFixedHoriLineStyle = nullptr;
@@ -744,8 +746,21 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr,
if (AllSettings::GetLayoutRTL())
aEditBoxRect.SetPos( Point( areaRect.Left() + buttonRect.GetWidth(), areaRect.Top() ) );
- arrowRect.SetSize( Size( (gint)(ARROW_SIZE),
- (gint)(ARROW_SIZE) ) );
+ gint arrow_width, arrow_height;
+ if (nType == ControlType::Combobox)
+ {
+ gtk_style_context_get(mpComboboxButtonArrowStyle,
+ gtk_style_context_get_state(mpComboboxButtonArrowStyle),
+ "min-width", &arrow_width, "min-height", &arrow_height, NULL);
+ }
+ else if (nType == ControlType::Listbox)
+ {
+ gtk_style_context_get(mpListboxButtonArrowStyle,
+ gtk_style_context_get_state(mpListboxButtonArrowStyle),
+ "min-width", &arrow_width, "min-height", &arrow_height, NULL);
+ }
+
+ arrowRect.SetSize(Size(arrow_width, arrow_height));
arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2),
buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) );
@@ -790,7 +805,7 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr,
(buttonRect.Top() - areaRect.Top()),
buttonRect.GetWidth(), buttonRect.GetHeight() );
- gtk_render_arrow(mpComboboxStyle, cr,
+ gtk_render_arrow(mpComboboxButtonArrowStyle, cr,
G_PI,
(arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()),
arrowRect.GetWidth() );
@@ -825,7 +840,7 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr,
0, 0,
areaRect.GetWidth(), areaRect.GetHeight());
- gtk_render_arrow(mpListboxStyle, cr,
+ gtk_render_arrow(mpListboxButtonArrowStyle, cr,
G_PI,
(arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()),
arrowRect.GetWidth() );
@@ -889,6 +904,14 @@ static GtkStyleContext* createStyleContext(GtkControlPart ePart, GtkStyleContext
gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_RADIO);
#endif
break;
+ case GtkControlPart::Arrow:
+ gtk_widget_path_append_type(path, GTK_TYPE_BUTTON);
+#if GTK_CHECK_VERSION(3, 19, 2)
+ gtk_widget_path_iter_set_object_name(path, -1, "arrow");
+#else
+ gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_BUTTON);
+#endif
+ break;
case GtkControlPart::Entry:
gtk_widget_path_append_type(path, GTK_TYPE_ENTRY);
#if GTK_CHECK_VERSION(3, 19, 2)
@@ -2437,12 +2460,14 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
gComboBox = gtk_combo_box_text_new_with_entry();
getStyleContext(&mpComboboxStyle, gComboBox);
mpComboboxButtonStyle = createStyleContext(GtkControlPart::Button, mpComboboxStyle);
+ mpComboboxButtonArrowStyle = createStyleContext(GtkControlPart::Arrow, mpComboboxButtonStyle);
/* Listbox */
gListBox = gtk_combo_box_text_new();
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gListBox), "sample");
getStyleContext(&mpListboxStyle, gListBox);
mpListboxButtonStyle = createStyleContext(GtkControlPart::Button, mpListboxStyle);
+ mpListboxButtonArrowStyle = createStyleContext(GtkControlPart::Arrow, mpListboxButtonStyle);
/* Frames */
mpFrameOutStyle = mpFrameInStyle = createStyleContext(GtkControlPart::FrameBorder);