[gtk+/gtk-style-context: 43/191] GtkThemingEngine: Add vmethod to render layouts.



commit 627a0a6058fdc91440044382e8cf5c0ff414115b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Mar 27 20:21:55 2010 +0100

    GtkThemingEngine: Add vmethod to render layouts.

 gtk/gtkthemingengine.c |   40 ++++++++++++++++++++++++++++++++++++++++
 gtk/gtkthemingengine.h |    5 +++++
 2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 49dbe44..b56a86d 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -85,6 +85,11 @@ static void gtk_theming_engine_render_focus    (GtkThemingEngine *engine,
                                                 gdouble           y,
                                                 gdouble           width,
                                                 gdouble           height);
+static void gtk_theming_engine_render_layout   (GtkThemingEngine *engine,
+                                                cairo_t          *cr,
+                                                gdouble           x,
+                                                gdouble           y,
+                                                PangoLayout      *layout);
 
 G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
 
@@ -123,6 +128,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass)
   klass->render_frame = gtk_theming_engine_render_frame;
   klass->render_expander = gtk_theming_engine_render_expander;
   klass->render_focus = gtk_theming_engine_render_focus;
+  klass->render_layout = gtk_theming_engine_render_layout;
 
   g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate));
 }
@@ -913,5 +919,39 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine,
   gdk_color_free (base_color);
 }
 
+static void
+gtk_theming_engine_render_layout (GtkThemingEngine *engine,
+                                  cairo_t          *cr,
+                                  gdouble           x,
+                                  gdouble           y,
+                                  PangoLayout      *layout)
+{
+  GdkColor *fg_color;
+  GtkStateFlags flags;
+  GtkStateType state;
+
+  cairo_save (cr);
+  flags = gtk_theming_engine_get_state (engine);
+
+  if (flags & GTK_STATE_FLAG_PRELIGHT)
+    state = GTK_STATE_PRELIGHT;
+  else if (flags & GTK_STATE_FLAG_INSENSITIVE)
+    state = GTK_STATE_INSENSITIVE;
+  else
+    state = GTK_STATE_NORMAL;
+
+  gtk_theming_engine_get (engine, state,
+                          "foreground-color", &fg_color,
+                          NULL);
+
+  cairo_move_to (cr, x, y);
+  gdk_cairo_set_source_color (cr, fg_color);
+  pango_cairo_show_layout (cr, layout);
+
+  cairo_restore (cr);
+
+  gdk_color_free (fg_color);
+}
+
 #define __GTK_THEMING_ENGINE_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h
index 61dc7f3..6a79edc 100644
--- a/gtk/gtkthemingengine.h
+++ b/gtk/gtkthemingengine.h
@@ -91,6 +91,11 @@ struct GtkThemingEngineClass
                          gdouble           y,
                          gdouble           width,
                          gdouble           height);
+  void (* render_layout) (GtkThemingEngine *engine,
+                          cairo_t          *cr,
+                          gdouble           x,
+                          gdouble           y,
+                          PangoLayout      *layout);
 };
 
 GType gtk_theming_engine_get_type (void) G_GNUC_CONST;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]