[Libreoffice-commits] .: 2 commits - vcl/unx

Michael Meeks michael at kemper.freedesktop.org
Thu May 31 04:16:02 PDT 2012


 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx |   80 ++++++++++++++++++++-----------
 1 file changed, 52 insertions(+), 28 deletions(-)

New commits:
commit e67fc823516226a41319ee242fefda245fb18a3e
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Thu May 31 12:14:01 2012 +0100

    vcl: cleanup code flow, and minor indent tweak
    
    Change-Id: Id99b10f84ef977f5c808fb2c9168deaa4455a2a9

diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index a8a849f..9d9dee6 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -1140,25 +1140,25 @@ sal_Bool GtkSalGraphics::getNativeControlRegion(  ControlType nType,
 sal_Bool GtkSalGraphics::NWPaintGTKWindowBackground(
             GdkDrawable* gdkDrawable,
             ControlType, ControlPart,
-            const Rectangle& rControlRectangle,
+            const Rectangle& /* rControlRectangle */,
             const clipList& rClipList,
-            ControlState nState, const ImplControlValue&,
+            ControlState /* nState */, const ImplControlValue&,
             const OUString& )
 {
-        int w,h;
-        gtk_window_get_size(GTK_WINDOW(m_pWindow),&w,&h);
-        GdkRectangle clipRect;
-        for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
-        {
-            clipRect.x = it->Left();
-            clipRect.y = it->Top();
-            clipRect.width = it->GetWidth();
-            clipRect.height = it->GetHeight();
+    int w,h;
+    gtk_window_get_size(GTK_WINDOW(m_pWindow),&w,&h);
+    GdkRectangle clipRect;
+    for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
+    {
+        clipRect.x = it->Left();
+        clipRect.y = it->Top();
+        clipRect.width = it->GetWidth();
+        clipRect.height = it->GetHeight();
 
-            gtk_paint_flat_box(m_pWindow->style,gdkDrawable,GTK_STATE_NORMAL,GTK_SHADOW_NONE,&clipRect,m_pWindow,"base",0,0,w,h);
-        }
+        gtk_paint_flat_box(m_pWindow->style,gdkDrawable,GTK_STATE_NORMAL,GTK_SHADOW_NONE,&clipRect,m_pWindow,"base",0,0,w,h);
+    }
 
-        return sal_True;
+    return sal_True;
 }
 
 sal_Bool GtkSalGraphics::NWPaintGTKButtonReal(
@@ -1281,18 +1281,17 @@ sal_Bool GtkSalGraphics::NWPaintGTKButtonReal(
                                 &clipRect, m_pWindow, "base", x, y, w, h );
         }
 
-        if ( (nState & CTRL_STATE_DEFAULT) && GTK_IS_BUTTON(button) )
-        {
-            gtk_paint_box( button->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
-                           &clipRect, button, "buttondefault", x, y, w, h );
-        }
-        /* don't draw "button", because it can be a tool_button, and
-         * it causes some weird things, so, the default button is
-         * just fine */
-        if(GTK_IS_BUTTON(button))
+        if ( GTK_IS_BUTTON(button) )
         {
+            if ( (nState & CTRL_STATE_DEFAULT) )
+                gtk_paint_box( button->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
+                               &clipRect, button, "buttondefault", x, y, w, h );
+
+            /* 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( button->style, gdkDrawable, stateType, shadowType,
-                               &clipRect, button, "button", xi, yi, wi, hi );
+                           &clipRect, button, "button", xi, yi, wi, hi );
         }
     }
 
commit 7c610c7daca12f631845ddbaf01c52029ef97da3
Author: Ruslan Kabatsayev <b7.10110111 at gmail.com>
Date:   Sat May 26 21:31:38 2012 +0400

    GTK-theming: fix rendering of toolbuttons
    
    Change-Id: I6b7ec963e50c75e65c602681586a1458426ae61f

diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index f9781ab..a8a849f 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 );
 


More information about the Libreoffice-commits mailing list