Hi,
Here is a patch to render gtk3 button correctly. I send it now because I
won't have internet until tuesday, and it would be a bit stupid if
anyone made the same thing... So, you are aware that the patch exists,
if you need it :)
So, there are some warnings about unused variables, of course, they will
be used later. I didn't split drawNativeControl(), but I suppose it will
be necessary later.
Here is a screenshot:
http://pix.toile-libre.org/upload/original/1313519421.png
I don't know if it is worth to apply it now (it is not finished at all),
but it is under GPLv3+/MPL.
I will try to complete to work again on gtk3 next week...
Lucas
From 0e3f8e8106985c51db320033a495fe05b7f6709e Mon Sep 17 00:00:00 2001
From: Lucas Baudin <xapantu@gmail.com>
Date: Tue, 16 Aug 2011 20:20:24 +0200
Subject: [PATCH] [GTK3] Add button rendering
---
vcl/Library_vclplug_gtk3.mk | 1 +
vcl/inc/unx/gtk/gtkgdi.hxx | 10 +++
vcl/unx/gtk/window/gtkframe.cxx | 13 ---
vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 100 ++++++++++++++++++++++++-
4 files changed, 109 insertions(+), 15 deletions(-)
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index 4642923..e71cb81 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -116,6 +116,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\
vcl/unx/gtk3/app/gtk3gtksys \
vcl/unx/gtk3/window/gtk3gtkframe \
vcl/unx/gtk3/window/gtk3gtkobject \
+ vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk \
))
ifeq ($(OS),LINUX)
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 83d4aa8..47f4e34 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -47,6 +47,16 @@ class GtkSalFrame;
class GtkSalGraphics : public X11SalGraphics {
public:
GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
+ virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart, const
Rectangle& rControlRegion,
+ ControlState nState, const ImplControlValue& aValue,
+ const rtl::OUString& rCaption );
+ virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart );
+ virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart, const
Rectangle& rControlRegion, ControlState nState,
+ const ImplControlValue& aValue, const
rtl::OUString& rCaption,
+ Rectangle &rNativeBoundingRegion, Rectangle
&rNativeContentRegion );
+private:
+ GtkWidget *m_pWindow;
+ GtkStyleContext* m_buttonStyle;
};
#else
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index faa8a71..fb20689 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -3880,17 +3880,4 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*,
gint
return sal_False;
}
-#ifdef GTK_GRAPHICS_DISABLED
-
-void GtkData::initNWF() {}
-void GtkData::deInitNWF() {}
-
-GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
- : X11SalGraphics()
-{
- Init( pFrame, GDK_WINDOW_XID( widget_get_window( pWindow ) ),
- gdk_x11_screen_get_screen_number( gtk_widget_get_screen( pWindow ) ) );
-}
-
-#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index aa68cc2..637be5f 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -26,7 +26,103 @@
* instead of those above.
*/
-#include "../../headless/svpdi.hxx"
-#include "../../headless/svpdi.hxx"
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <unx/gtk/gtkframe.hxx>
+#include <unx/gtk/gtkdata.hxx>
+#include <unx/gtk/gtkinst.hxx>
+#include <unx/gtk/gtkgdi.hxx>
+
+/************************************************************************
+ * State conversion
+ ************************************************************************/
+static void NWConvertVCLStateToGTKState( ControlState nVCLState,
+ GtkStateFlags* nGTKState, GtkShadowType* nGTKShadow )
+{
+ *nGTKShadow = GTK_SHADOW_OUT;
+ *nGTKState = GTK_STATE_FLAG_INSENSITIVE;
+
+ if ( nVCLState & CTRL_STATE_ENABLED )
+ {
+ if ( nVCLState & CTRL_STATE_PRESSED )
+ {
+ *nGTKState = GTK_STATE_FLAG_ACTIVE;
+ *nGTKShadow = GTK_SHADOW_IN;
+ }
+ else if ( nVCLState & CTRL_STATE_ROLLOVER )
+ {
+ *nGTKState = GTK_STATE_FLAG_PRELIGHT;
+ *nGTKShadow = GTK_SHADOW_OUT;
+ }
+ else
+ {
+ *nGTKState = GTK_STATE_FLAG_NORMAL;
+ *nGTKShadow = GTK_SHADOW_OUT;
+ }
+ }
+}
+
+void GtkData::initNWF() {}
+void GtkData::deInitNWF() {}
+
+GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
+ : X11SalGraphics()
+{
+ m_pWindow = pWindow;
+ m_buttonStyle = NULL;
+ Init( pFrame, GDK_WINDOW_XID( widget_get_window( pWindow ) ),
+ gdk_x11_screen_get_screen_number( gtk_widget_get_screen( pWindow ) ) );
+}
+
+sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle&
rControlRegion,
+ ControlState nState, const ImplControlValue& aValue,
+ const rtl::OUString& rCaption )
+{
+ GtkStateFlags flags;
+ GtkShadowType shadow;
+ NWConvertVCLStateToGTKState(nState, &flags, &shadow);
+ cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(m_pWindow));
+ switch(nType)
+ {
+ case CTRL_PUSHBUTTON:
+ if(!GTK_IS_STYLE_CONTEXT(m_buttonStyle))
+ {
+ m_buttonStyle = gtk_widget_get_style_context(gtk_button_new());
+ }
+
+ gtk_style_context_set_state(m_buttonStyle, flags);
+
+ gtk_render_background(m_buttonStyle, cr,
+ rControlRegion.Left(), rControlRegion.Top(),
+ rControlRegion.GetWidth(), rControlRegion.GetHeight());
+ gtk_render_frame(m_buttonStyle, cr,
+ rControlRegion.Left(), rControlRegion.Top(),
+ rControlRegion.GetWidth(), rControlRegion.GetHeight());
+
+ return sal_True;
+ default:
+ return sal_False;
+ }
+ cairo_destroy(cr);
+}
+
+sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const
Rectangle& rControlRegion, ControlState nState,
+ const ImplControlValue& aValue, const
rtl::OUString& rCaption,
+ Rectangle &rNativeBoundingRegion, Rectangle
&rNativeContentRegion )
+{
+ switch(nType)
+ {
+ default:
+ return sal_False;
+ }
+}
+
+sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart )
+{
+ if(nType == CTRL_PUSHBUTTON)
+ return sal_True;
+ return sal_False;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
--
1.7.4.1
Context
- [Libreoffice] [Patch] Gtk3 button rendering · Lucas Baudin
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.