summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Baudin <xapantu@gmail.com>2011-08-17 14:55:00 +0100
committerMichael Meeks <michael.meeks@suse.com>2011-10-25 13:41:44 +0100
commite94fc5d61c4b5863a92f7451304037f42d21f35c (patch)
treee81de1db6e778db48ae4d97f897cf90cdd2e4d72
parentc11c452aa180393e56b79eb256c79e895fa169c8 (diff)
gtk3: implement initial native widget support for buttons
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx15
-rw-r--r--vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx86
2 files changed, 100 insertions, 1 deletions
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index b08fcf738ed0..5074d166c731 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -52,6 +52,21 @@ public:
long nSrcWidth, long nSrcHeight,
sal_uInt16 /*nFlags*/ );
void updateSettings( AllSettings& rSettings );
+ 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 *mpWindow;
+ GtkStyleContext *mpButtonStyle;
};
#else
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 5a6179ad3ea7..ae655dd60957 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -29,6 +29,91 @@
// Gross inclusion hacks for now ...
#include "../../headless/svpgdi.cxx"
+#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;
+ }
+ }
+}
+
+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(mpWindow));
+ switch(nType)
+ {
+ case CTRL_PUSHBUTTON:
+ if(!GTK_IS_STYLE_CONTEXT(mpButtonStyle))
+ {
+ mpButtonStyle = gtk_widget_get_style_context(gtk_button_new());
+ }
+
+ gtk_style_context_set_state(mpButtonStyle, flags);
+
+ gtk_render_background(mpButtonStyle, cr,
+ rControlRegion.Left(), rControlRegion.Top(),
+ rControlRegion.GetWidth(), rControlRegion.GetHeight());
+ gtk_render_frame(mpButtonStyle, 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 0
+ if(nType == CTRL_PUSHBUTTON)
+ return sal_True;
+#endif
+ return sal_False;
+}
void GtkData::initNWF() {}
void GtkData::deInitNWF() {}
@@ -123,5 +208,4 @@ void GtkSalGraphics::copyArea( long nDestX, long nDestY,
cairo_region_destroy( region );
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */