summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk
diff options
context:
space:
mode:
authorRuslan Kabatsayev <b7.10110111@gmail.com>2012-05-26 21:31:38 +0400
committerMichael Meeks <michael.meeks@suse.com>2012-05-31 12:08:53 +0100
commit7c610c7daca12f631845ddbaf01c52029ef97da3 (patch)
treeeac1fc01bd955f44a513188da798b61366942226 /vcl/unx/gtk
parent7b52e6b9b1c42ccd9ff5a6adbc3b62622d31ca75 (diff)
GTK-theming: fix rendering of toolbuttons
Change-Id: I6b7ec963e50c75e65c602681586a1458426ae61f
Diffstat (limited to 'vcl/unx/gtk')
-rw-r--r--vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx41
1 files changed, 33 insertions, 8 deletions
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index f9781abf74b1..a8a849f86ac5 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -1183,8 +1183,31 @@ sal_Bool GtkSalGraphics::NWPaintGTKButtonReal(
NWEnsureGTKButton( m_nXScreen );
NWEnsureGTKToolbar( m_nXScreen );
- NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
- NWSetWidgetState( gWidgetData[m_nXScreen].gBtnWidget, nState, stateType );
+
+ // Flat toolbutton has a bit bigger variety of states than normal buttons, so handle it differently
+ if(GTK_IS_TOGGLE_BUTTON(button))
+ {
+ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
+ shadowType=GTK_SHADOW_IN;
+ else
+ shadowType=GTK_SHADOW_OUT;
+
+ if(nState & CTRL_STATE_ROLLOVER)
+ stateType=GTK_STATE_PRELIGHT;
+ else
+ stateType=GTK_STATE_NORMAL;
+
+ if(nState & CTRL_STATE_PRESSED)
+ {
+ stateType=GTK_STATE_ACTIVE;
+ shadowType=GTK_SHADOW_IN;
+ }
+ }
+ else
+ {
+ NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
+ NWSetWidgetState( gWidgetData[m_nXScreen].gBtnWidget, nState, stateType );
+ }
x = rControlRectangle.Left();
y = rControlRectangle.Top();
@@ -1266,8 +1289,11 @@ sal_Bool GtkSalGraphics::NWPaintGTKButtonReal(
/* don't draw "button", because it can be a tool_button, and
* it causes some weird things, so, the default button is
* just fine */
- gtk_paint_box( gWidgetData[m_nXScreen].gBtnWidget->style, gdkDrawable, stateType, shadowType,
- &clipRect, gWidgetData[m_nXScreen].gBtnWidget, "button", xi, yi, wi, hi );
+ if(GTK_IS_BUTTON(button))
+ {
+ gtk_paint_box( button->style, gdkDrawable, stateType, shadowType,
+ &clipRect, button, "button", xi, yi, wi, hi );
+ }
}
return( sal_True );
@@ -2617,12 +2643,11 @@ sal_Bool GtkSalGraphics::NWPaintGTKToolbar(
|| (nState & CTRL_STATE_ROLLOVER);
if( aValue.getTristateVal() == BUTTONVALUE_ON )
{
- if(!(nState & CTRL_STATE_ROLLOVER))
- nState |= CTRL_STATE_PRESSED;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pButtonWidget),TRUE);
bPaintButton = true;
}
else
- stateType = GTK_STATE_PRELIGHT; // only for bPaintButton = true, in which case always rollver is meant
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pButtonWidget),FALSE);
NWSetWidgetState( pButtonWidget, nState, stateType );
gtk_widget_ensure_style( pButtonWidget );
@@ -4020,7 +4045,7 @@ static void NWEnsureGTKToolbar( SalX11Screen nScreen )
{
gWidgetData[nScreen].gToolbarWidget = gtk_toolbar_new();
NWAddWidgetToCacheWindow( gWidgetData[nScreen].gToolbarWidget, nScreen );
- gWidgetData[nScreen].gToolbarButtonWidget = GTK_WIDGET(gtk_button_new());
+ gWidgetData[nScreen].gToolbarButtonWidget = GTK_WIDGET(gtk_toggle_button_new());
gWidgetData[nScreen].gSeparator = GTK_WIDGET(gtk_separator_tool_item_new());
NWAddWidgetToCacheWindow( gWidgetData[nScreen].gSeparator, nScreen );