From 9aed8b82c175cd30777a23fbe2f8859d30376ffe Mon Sep 17 00:00:00 2001
From: Ruslan Kabatsayev <b7.10110111@gmail.com>
Date: Mon, 28 May 2012 02:28:49 +0400
Subject: GTK theming: implement rendering window background

Change-Id: I34c6c38f383fce54aa0b2a61a5e88ee9a8cff4e7
---
 vcl/inc/unx/gtk/gtkgdi.hxx               |    5 +++++
 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx |   30 +++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index bdc397e..fbdcef1 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -165,6 +165,11 @@ protected:
     GdkPixmap* NWGetPixmapFromScreen( Rectangle srcRect );
     sal_Bool NWRenderPixmapToScreen( GdkPixmap* pPixmap, Rectangle dstRect );
 
+    sal_Bool NWPaintGTKWindowBackground( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
+                           const Rectangle& rControlRectangle,
+                           const clipList& rClipList,
+                           ControlState nState, const ImplControlValue& aValue,
+                           const OUString& rCaption );
     sal_Bool NWPaintGTKButtonReal( GtkWidget* button, GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
                            const Rectangle& rControlRectangle,
                            const clipList& rClipList,
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index c92d6f5..37d5345 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -614,7 +614,8 @@ sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPar
                 (   (nPart == PART_TRACK_HORZ_AREA)
                 ||  (nPart == PART_TRACK_VERT_AREA)
                 )
-        )
+        ) ||
+        (nType == CTRL_WINDOW_BACKGROUND)
         )
         return( sal_True );
     return( sal_False );
@@ -898,6 +899,10 @@ sal_Bool GtkSalGraphics::drawNativeControl(    ControlType nType,
     {
         returnVal = NWPaintGTKSlider( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
     }
+    else if( nType == CTRL_WINDOW_BACKGROUND )
+    {
+        returnVal = NWPaintGTKWindowBackground( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
+    }
 
     if( pixmap )
     {
@@ -1132,6 +1137,29 @@ sal_Bool GtkSalGraphics::getNativeControlRegion(  ControlType nType,
 /************************************************************************
  * Individual control drawing functions
  ************************************************************************/
+sal_Bool GtkSalGraphics::NWPaintGTKWindowBackground(
+            GdkDrawable* gdkDrawable,
+            ControlType, ControlPart,
+            const Rectangle& rControlRectangle,
+            const clipList& rClipList,
+            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();
+
+            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;
+}
 
 sal_Bool GtkSalGraphics::NWPaintGTKButtonReal(
             GtkWidget* button,
-- 
1.7.10.2

