[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/source vcl/unx
Caolán McNamara
caolanm at redhat.com
Wed May 13 02:00:45 PDT 2015
vcl/inc/unx/gtk/gtkgdi.hxx | 9 -
vcl/source/control/ilstbox.cxx | 2
vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 182 +++++++++++++++-----------
3 files changed, 114 insertions(+), 79 deletions(-)
New commits:
commit 7343e171256f16e86b3c43aca6412c738c89c3d4
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue May 12 21:06:48 2015 +0100
gtk3: stop painting the active listboxes blue
gtk3 equivalents are comboboxes without entries and
those don't do this
Change-Id: I71efe2c11a1d604e6c15927844f5a25b78771e62
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index bd1935c..0961df1 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -2716,7 +2716,7 @@ void ImplWin::ImplDraw( bool bLayout )
if( IsEnabled() )
{
- if( HasFocus() )
+ if (HasFocus() && !ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea)
{
SetTextColor( rStyleSettings.GetHighlightTextColor() );
SetFillColor( rStyleSettings.GetHighlightColor() );
commit 5db6da7c5d27c5b8be59fb9a4599d5c95d7f1bd7
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue May 12 17:37:58 2015 +0100
gtk3: get comboboxes and listboxes rendering right again
and also get roll-over working for listboxes, here
its actually to *not* support PART_BUTTON_DOWN that does
that, which is weird.
Change-Id: I0fc1152a3ee49164f6b5ecca6933730271c6da5c
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 68c6cf7..bde44ab 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -77,7 +77,10 @@ private:
static GtkStyleContext *mpMenuItemStyle;
static GtkStyleContext *mpSpinStyle;
static GtkStyleContext *mpComboboxStyle;
+ static GtkStyleContext *mpComboboxEntryStyle;
+ static GtkStyleContext *mpComboboxButtonStyle;
static GtkStyleContext *mpListboxStyle;
+ static GtkStyleContext *mpListboxButtonStyle;
static GtkStyleContext *mpNoteBookStyle;
static Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
@@ -101,13 +104,13 @@ private:
const Rectangle& rControlRectangle,
ControlType nType,
ControlPart nPart,
- const ImplControlValue& aValue );
- static void PaintCombobox( GtkStyleContext *context,
+ const ImplControlValue& aValue);
+ static void PaintCombobox(GtkStateFlags flags,
cairo_t *cr,
const Rectangle& rControlRectangle,
ControlType nType,
ControlPart nPart,
- const ImplControlValue& aValue );
+ const ImplControlValue& aValue);
static void PaintCheckOrRadio(GtkStyleContext *context,
cairo_t *cr,
const Rectangle& rControlRectangle,
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 906d3b2..2aad70e 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -32,7 +32,10 @@ GtkStyleContext* GtkSalGraphics::mpMenuStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuItemStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpSpinStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpComboboxStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpComboboxEntryStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpComboboxButtonStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpListboxStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpListboxButtonStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpNoteBookStyle = NULL;
bool GtkSalGraphics::style_loaded = false;
@@ -78,37 +81,6 @@ enum {
RENDER_EXTENSION = 11,
};
-static void PrepareComboboxStyle( GtkStyleContext *context,
- gboolean forEntry)
-{
- GtkWidgetPath *path, *siblingsPath;
-
- path = gtk_widget_path_new();
- siblingsPath = gtk_widget_path_new();
- gtk_widget_path_append_type(path, GTK_TYPE_COMBO_BOX);
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_COMBOBOX_ENTRY);
-
- gtk_widget_path_append_type(siblingsPath, GTK_TYPE_ENTRY);
- gtk_widget_path_append_type(siblingsPath, GTK_TYPE_BUTTON);
- gtk_widget_path_iter_add_class(siblingsPath, 0, GTK_STYLE_CLASS_ENTRY);
- gtk_widget_path_iter_add_class(siblingsPath, 1, GTK_STYLE_CLASS_BUTTON);
-
- if (forEntry)
- {
- gtk_widget_path_append_with_siblings(path, siblingsPath, 1);
- gtk_widget_path_append_with_siblings(path, siblingsPath, 0);
- }
- else
- {
- gtk_widget_path_append_with_siblings(path, siblingsPath, 0);
- gtk_widget_path_append_with_siblings(path, siblingsPath, 1);
- }
-
- gtk_style_context_set_path(context, path);
- gtk_widget_path_free(path);
- gtk_widget_path_free(siblingsPath);
-}
-
static void NWCalcArrowRect( const Rectangle& rButton, Rectangle& rArrow )
{
// Size the arrow appropriately
@@ -698,8 +670,7 @@ Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlType nType,
return aButtonRect;
}
-void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
- cairo_t *cr,
+void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr,
const Rectangle& rControlRectangle,
ControlType nType,
ControlPart nPart,
@@ -721,28 +692,49 @@ void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
Rectangle aEditBoxRect( areaRect );
aEditBoxRect.SetSize( Size( areaRect.GetWidth() - buttonRect.GetWidth(), aEditBoxRect.GetHeight() ) );
+ arrowRect.SetSize( Size( (gint)(ARROW_SIZE),
+ (gint)(ARROW_SIZE) ) );
+ arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2),
+ buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) );
+
+
if ( nType == CTRL_COMBOBOX )
{
+ gtk_style_context_save(mpComboboxButtonStyle);
+ gtk_style_context_set_state(mpComboboxButtonStyle, flags);
+
if( nPart == PART_ENTIRE_CONTROL )
{
- PrepareComboboxStyle(context, true);
- gtk_render_background(context, cr,
+ gtk_render_background(mpComboboxStyle, cr,
+ 0, 0,
+ areaRect.GetWidth(), areaRect.GetHeight());
+ gtk_render_frame(mpComboboxStyle, cr,
+ 0, 0,
+ areaRect.GetWidth(), areaRect.GetHeight());
+
+ gtk_render_background(mpComboboxEntryStyle, cr,
0, 0,
aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
- gtk_render_frame(context, cr,
+ gtk_render_frame(mpComboboxEntryStyle, cr,
0, 0,
aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
}
- PrepareComboboxStyle(context, false);
- gtk_render_background(context, cr,
+ gtk_render_background(mpComboboxButtonStyle, cr,
(buttonRect.Left() - areaRect.Left()),
(buttonRect.Top() - areaRect.Top()),
buttonRect.GetWidth(), buttonRect.GetHeight() );
- gtk_render_frame(context, cr,
+ gtk_render_frame(mpComboboxButtonStyle, cr,
(buttonRect.Left() - areaRect.Left()),
(buttonRect.Top() - areaRect.Top()),
buttonRect.GetWidth(), buttonRect.GetHeight() );
+
+ gtk_render_arrow(mpComboboxStyle, cr,
+ G_PI,
+ (arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()),
+ arrowRect.GetWidth() );
+
+ gtk_style_context_restore(mpComboboxButtonStyle);
}
else if (nType == CTRL_LISTBOX)
{
@@ -755,23 +747,31 @@ void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
}
else
{
- gtk_render_background(context, cr,
+ gtk_style_context_save(mpListboxButtonStyle);
+ gtk_style_context_set_state(mpListboxButtonStyle, flags);
+
+ gtk_render_background(mpListboxStyle, cr,
+ 0, 0,
+ areaRect.GetWidth(), areaRect.GetHeight());
+ gtk_render_frame(mpListboxStyle, cr,
+ 0, 0,
+ areaRect.GetWidth(), areaRect.GetHeight());
+
+ gtk_render_background(mpListboxButtonStyle, cr,
0, 0,
areaRect.GetWidth(), areaRect.GetHeight());
- gtk_render_frame(context, cr,
+ gtk_render_frame(mpListboxButtonStyle, cr,
0, 0,
areaRect.GetWidth(), areaRect.GetHeight());
+
+ gtk_render_arrow(mpListboxStyle, cr,
+ G_PI,
+ (arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()),
+ arrowRect.GetWidth() );
+
+ gtk_style_context_restore(mpListboxButtonStyle);
}
}
-
- arrowRect.SetSize( Size( (gint)(ARROW_SIZE),
- (gint)(ARROW_SIZE) ) );
- arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2),
- buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) );
- gtk_render_arrow(context, cr,
- G_PI,
- (arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()),
- arrowRect.GetWidth() );
}
void GtkSalGraphics::PaintCheckOrRadio(GtkStyleContext *context,
@@ -829,15 +829,8 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
renderType = RENDER_COMBOBOX;
break;
case CTRL_LISTBOX:
- switch (nPart)
- {
- case PART_ENTIRE_CONTROL:
- context = mpListboxStyle;
- renderType = RENDER_COMBOBOX;
- break;
- default:
- return false;
- }
+ context = mpListboxStyle;
+ renderType = RENDER_COMBOBOX;
break;
case CTRL_MENU_POPUP:
@@ -1033,7 +1026,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
PaintSpinButton(context, cr, rControlRegion, nType, nPart, aValue);
break;
case RENDER_COMBOBOX:
- PaintCombobox(context, cr, rControlRegion, nType, nPart, aValue);
+ PaintCombobox(flags, cr, rControlRegion, nType, nPart, aValue);
break;
default:
break;
@@ -1091,6 +1084,14 @@ Rectangle AdjustRectForTextBordersPadding(GtkStyleContext* pStyle, long nContent
return aEditRect;
}
+static GtkWidget* gCacheWindow;
+static GtkWidget* gDumbContainer;
+static GtkWidget* gComboBox;
+static GtkWidget* gComboBoxButtonWidget;
+static GtkWidget* gComboBoxEntryWidget;
+static GtkWidget* gListBox;
+static GtkWidget* gListBoxButtonWidget;
+
bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState,
const ImplControlValue& rValue, const OUString&,
Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion )
@@ -1188,11 +1189,17 @@ bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPar
}
else if (nType == CTRL_LISTBOX && nPart == PART_ENTIRE_CONTROL)
{
- aEditRect = AdjustRectForTextBordersPadding(mpListboxStyle, rValue.getNumericVal(), rControlRegion);
+ GtkRequisition aReq;
+ gtk_widget_get_preferred_size(gComboBox, NULL, &aReq);
+ long nHeight = (rControlRegion.GetHeight() > aReq.height) ? rControlRegion.GetHeight() : aReq.height;
+ aEditRect = Rectangle(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nHeight));
}
else if (nType == CTRL_COMBOBOX && nPart == PART_ENTIRE_CONTROL)
{
- aEditRect = AdjustRectForTextBordersPadding(mpComboboxStyle, rValue.getNumericVal(), rControlRegion);
+ GtkRequisition aReq;
+ gtk_widget_get_preferred_size(gComboBox, NULL, &aReq);
+ long nHeight = (rControlRegion.GetHeight() > aReq.height) ? rControlRegion.GetHeight() : aReq.height;
+ aEditRect = Rectangle(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nHeight));
}
else if (nType == CTRL_SPINBOX && nPart == PART_ENTIRE_CONTROL)
{
@@ -1639,7 +1646,7 @@ bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP
break;
case CTRL_LISTBOX:
- if(nPart==PART_ENTIRE_CONTROL || nPart==PART_WINDOW || nPart==HAS_BACKGROUND_TEXTURE || nPart == PART_BUTTON_DOWN)
+ if (nPart==PART_ENTIRE_CONTROL || nPart==PART_WINDOW || nPart==HAS_BACKGROUND_TEXTURE)
return true;
break;
@@ -1715,9 +1722,6 @@ void GtkSalGraphics::WidgetQueueDraw() const
gtk_widget_queue_draw(mpWindow);
}
-static GtkWidget* gCacheWindow;
-static GtkWidget* gDumbContainer;
-
namespace {
void getStyleContext(GtkStyleContext** style, GtkWidget* widget)
@@ -1744,6 +1748,26 @@ void GtkData::deInitNWF()
gtk_widget_destroy(gCacheWindow);
}
+static void get_combo_box_entry_inner_widgets(GtkWidget *widget, gpointer)
+{
+ if (GTK_IS_TOGGLE_BUTTON(widget))
+ {
+ gComboBoxButtonWidget = widget;
+ }
+ else if (GTK_IS_ENTRY(widget))
+ {
+ gComboBoxEntryWidget = widget;
+ }
+}
+
+void get_combo_box_inner_button(GtkWidget *widget, gpointer)
+{
+ if (GTK_IS_TOGGLE_BUTTON(widget))
+ {
+ gListBoxButtonWidget = widget;
+ }
+}
+
GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
: SvpSalGraphics(),
mpFrame( pFrame ),
@@ -1822,17 +1846,25 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
getStyleContext(&mpNoteBookStyle, gtk_notebook_new());
/* Combobox */
- mpComboboxStyle = gtk_style_context_new();
- PrepareComboboxStyle(mpComboboxStyle, true);
+ gComboBox = gtk_combo_box_text_new_with_entry();
+ getStyleContext(&mpComboboxStyle, gComboBox);
+ /* Get ComboBox Entry and Button */
+ gtk_container_forall(GTK_CONTAINER(gComboBox),
+ get_combo_box_entry_inner_widgets,
+ NULL);
+ mpComboboxEntryStyle = gtk_widget_get_style_context(gComboBoxEntryWidget);
+ mpComboboxButtonStyle = gtk_widget_get_style_context(gComboBoxButtonWidget);
/* Listbox */
- mpListboxStyle = gtk_style_context_new();
- path = gtk_widget_path_new();
- gtk_widget_path_append_type(path, GTK_TYPE_COMBO_BOX);
- gtk_widget_path_append_type(path, GTK_TYPE_BUTTON);
- gtk_widget_path_iter_add_class(path, 1, GTK_STYLE_CLASS_BUTTON);
- gtk_style_context_set_path(mpListboxStyle, path);
- gtk_widget_path_free(path);
+ gListBox = gtk_combo_box_text_new();
+ getStyleContext(&mpListboxStyle, gListBox);
+ /* Get ComboBox Button */
+ gtk_container_forall(GTK_CONTAINER(gListBox),
+ get_combo_box_inner_button,
+ NULL);
+ mpListboxButtonStyle = gtk_widget_get_style_context(gListBoxButtonWidget);
+
+ gtk_widget_show_all(gDumbContainer);
}
cairo_t* GtkSalGraphics::getCairoContext() const
More information about the Libreoffice-commits
mailing list