summaryrefslogtreecommitdiff
path: root/gdk/gdkpango.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2009-03-27 16:54:10 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2009-03-27 16:54:10 +0000
commitd21f55fe9add35bb708d260841ce047c2458a7ca (patch)
tree5e7b0e3907401ef66ffaca471f78b1d253a0d17b /gdk/gdkpango.c
parent4d520f241d45ba8fedad21325caad8ab5a182e9f (diff)
downloadgtk+-d21f55fe9add35bb708d260841ce047c2458a7ca.tar.gz
Bug 437533 – Implement draw_shape PangoRenderer method
2009-03-27 Behdad Esfahbod <behdad@gnome.org> Bug 437533 – Implement draw_shape PangoRenderer method * gdk/gdkpango.c (gdk_pango_renderer_draw_shape), (gdk_pango_renderer_class_init): Implement draw_shape * demos/gtk-demo/rotated_text.c (fancy_shape_renderer), (create_fancy_attr_list_for_layout), (rotated_text_expose_event), (do_rotated_text): 1) Port to pangocairo 2) Also show a rotated label 3) Install a custom shape renderer on both. The second one goes through gdkpango and hence tests the patch above. It's working. svn path=/trunk/; revision=22592
Diffstat (limited to 'gdk/gdkpango.c')
-rw-r--r--gdk/gdkpango.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gdk/gdkpango.c b/gdk/gdkpango.c
index 302eb9d3e0..a38640374b 100644
--- a/gdk/gdkpango.c
+++ b/gdk/gdkpango.c
@@ -312,6 +312,52 @@ gdk_pango_renderer_draw_error_underline (PangoRenderer *renderer,
}
static void
+gdk_pango_renderer_draw_shape (PangoRenderer *renderer,
+ PangoAttrShape *attr,
+ int x,
+ int y)
+{
+ GdkPangoRenderer *gdk_renderer = GDK_PANGO_RENDERER (renderer);
+ GdkPangoRendererPrivate *priv = gdk_renderer->priv;
+ PangoLayout *layout;
+ PangoCairoShapeRendererFunc shape_renderer;
+ gpointer shape_renderer_data;
+ cairo_t *cr;
+ double dx = (double)x / PANGO_SCALE, dy = (double)y / PANGO_SCALE;
+
+ layout = pango_renderer_get_layout (renderer);
+
+ if (!layout)
+ return;
+
+ shape_renderer = pango_cairo_context_get_shape_renderer (pango_layout_get_context (layout),
+ &shape_renderer_data);
+
+ if (!shape_renderer)
+ return;
+
+ cr = get_cairo_context (gdk_renderer, PANGO_RENDER_PART_FOREGROUND);
+
+ cairo_save (cr);
+
+ if (priv->embossed)
+ {
+ cairo_save (cr);
+ emboss_context (gdk_renderer, cr);
+
+ cairo_move_to (cr, dx, dy);
+ shape_renderer (cr, attr, FALSE, shape_renderer_data);
+
+ cairo_restore (cr);
+ }
+
+ cairo_move_to (cr, dx, dy);
+ shape_renderer (cr, attr, FALSE, shape_renderer_data);
+
+ cairo_restore (cr);
+}
+
+static void
gdk_pango_renderer_part_changed (PangoRenderer *renderer,
PangoRenderPart part)
{
@@ -474,6 +520,7 @@ gdk_pango_renderer_class_init (GdkPangoRendererClass *klass)
renderer_class->draw_glyphs = gdk_pango_renderer_draw_glyphs;
renderer_class->draw_rectangle = gdk_pango_renderer_draw_rectangle;
renderer_class->draw_error_underline = gdk_pango_renderer_draw_error_underline;
+ renderer_class->draw_shape = gdk_pango_renderer_draw_shape;
renderer_class->part_changed = gdk_pango_renderer_part_changed;
renderer_class->begin = gdk_pango_renderer_begin;
renderer_class->end = gdk_pango_renderer_end;