Commit 438e3e1c authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Update for GdkPangoRenderer

Sat Nov 20 16:01:51 2004  Owen Taylor  <otaylor@redhat.com>

        * gdk/gdk-sections.txt gdk/gdk.types : Update for GdkPangoRenderer
        * gdk/Makefile.am gdk/images/rotated-text.png:

        * gdk/tmpl/pango_interaction.sgml: Add a long
        description and an extensive example (more or less the same as
        demos/gtk-demo/rotated_text.c)
parent 9cdd597f
Sat Nov 20 16:01:51 2004 Owen Taylor <otaylor@redhat.com>
* gdk/gdk-sections.txt gdk/gdk.types : Update for GdkPangoRenderer
* gdk/Makefile.am gdk/images/rotated-text.png:
* gdk/tmpl/pango_interaction.sgml: Add a long
description and an extensive example (more or less the same as
demos/gtk-demo/rotated_text.c)
* gtk/gtk-sections.txt: Add gtk_label_set/get_angle.
2004-11-20 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk-sections.txt: Add gtk_dialog_set_alternative_button_order_from_array
......
......@@ -59,6 +59,8 @@ content_files = \
# Images to copy into HTML directory
HTML_IMAGES = \
images/rotated-text.png \
\
images/X_cursor.png \
images/arrow.png \
images/based_arrow_down.png \
......
......@@ -464,7 +464,10 @@ GdkSegment
gdk_draw_rectangle
gdk_draw_arc
gdk_draw_polygon
gdk_draw_trapezoids
GdkTrapezoid
gdk_draw_glyphs
gdk_draw_glyphs_transformed
gdk_draw_layout_line
gdk_draw_layout_line_with_colors
gdk_draw_layout
......@@ -827,6 +830,14 @@ GDK_TYPE_PROP_MODE
<SECTION>
<TITLE>Pango Interaction</TITLE>
<FILE>pango_interaction</FILE>
GdkPangoRenderer
GdkPangoRendererClass
gdk_pango_renderer_new
gdk_pango_renderer_get_default
gdk_pango_renderer_set_drawable
gdk_pango_renderer_set_gc
gdk_pango_renderer_set_stipple
gdk_pango_renderer_set_override_color
gdk_pango_context_get
gdk_pango_context_get_for_screen
gdk_pango_context_set_colormap
......@@ -836,6 +847,17 @@ gdk_pango_attr_embossed_new
gdk_pango_attr_stipple_new
gdk_pango_layout_get_clip_region
gdk_pango_layout_line_get_clip_region
<SUBSECTION Standard>
GDK_TYPE_PANGO_RENDERER
GDK_PANGO_RENDERER
GDK_IS_PANGO_RENDERER
GDK_PANGO_RENDERER_CLASS
GDK_IS_PANGO_RENDERER_CLASS
GDK_PANGO_RENDERER_GET_CLASS
<SUBSECTION Private>
gdk_pango_renderer_get_type
GdkPangoRendererPrivate
</SECTION>
<SECTION>
......
......@@ -5,6 +5,7 @@ gdk_display_manager_get_type
gdk_screen_get_type
gdk_drawable_get_type
gdk_window_object_get_type
gdk_pango_renderer_get_type
gdk_pixmap_get_type
gdk_gc_get_type
gdk_keymap_get_type
......@@ -285,6 +285,29 @@ function.
@npoints:
<!-- ##### FUNCTION gdk_draw_trapezoids ##### -->
<para>
</para>
@drawable:
@gc:
@trapezoids:
@n_trapezoids:
<!-- ##### STRUCT GdkTrapezoid ##### -->
<para>
</para>
@y1:
@x11:
@x21:
@y2:
@x12:
@x22:
<!-- ##### FUNCTION gdk_draw_glyphs ##### -->
<para>
......@@ -298,6 +321,20 @@ function.
@glyphs:
<!-- ##### FUNCTION gdk_draw_glyphs_transformed ##### -->
<para>
</para>
@drawable:
@gc:
@matrix:
@font:
@x:
@y:
@glyphs:
<!-- ##### FUNCTION gdk_draw_layout_line ##### -->
<para>
......
......@@ -2,18 +2,206 @@
Pango Interaction
<!-- ##### SECTION Short_Description ##### -->
Low-level access to Pango
Using Pango in GDK
<!-- ##### SECTION Long_Description ##### -->
<para>
Pango is the text layout system used by GDK and GTK+. The functions
and types in this section are used to render Pango objects to GDK.
drawables, and also extend the set of Pango attributes to include
stippling and embossing.
</para>
<para>
Creating a #PangoLayout object is the first step in rendering text,
and requires getting a handle to a #PangoContext. For GTK+ programs,
you'll usually want to use gtk_widget_get_context(), or
gtk_widget_create_pango_layout(), rather than using the lowlevel
gdk_pango_context_get_for_screen(). Once you have a #PangoLayout, you
can set the text and attributes of it with Pango functions like
pango_layout_set_text() and get its size with pango_layout_get_size().
(Note that Pango uses a fixed point system internally, so converting
between Pango units and pixels using <link
linkend="PANGO-SCALE-CAPS">PANGO_SCALE</link> or the PANGO_PIXELS() macro.)
</para>
<para>
Rendering a Pango layout is done most simply with gdk_draw_layout();
you can also draw pieces of the layout with gdk_draw_layout() or
gdk_draw_glyphs(). #GdkPangoRenderer is a subclass of #PangoRenderer
that is used internally to implement these functions. Using it
directly or subclassing it can be useful in some cases. See the
#GdkPangoRenderer documentation for details.
</para>
<example id="rotated-example">
<title>Using #GdkPangoRenderer to draw transformed text</title>
<!-- Note that this example is basically the same as
demos/gtk-demo/rotated_text.c -->
<programlisting>
#define RADIUS 100
#define N_WORDS 10
#define FONT "Sans Bold 18"
GdkScreen *screen = gdk_drawable_get_screen (drawable);
PangoRenderer *renderer;
GdkGC *gc;
PangoMatrix matrix = PANGO_MATRIX_INIT;
PangoContext *context;
PangoLayout *layout;
PangoFontDescription *desc;
double device_radius;
int width, height;
int i;
/* Get the default renderer for the screen, and set it up for drawing */
renderer = gdk_pango_renderer_get_default (screen);
gdk_pango_renderer_set_drawable (GDK_PANGO_RENDERER (renderer), drawable);
gc = gdk_gc_new (drawable);
gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (renderer), gc);
/* Set up a transformation matrix so that the user space coordinates for
* where we are drawing are [-RADIUS, RADIUS], [-RADIUS, RADIUS]
* We first center, then change the scale */
gdk_drawable_get_size (drawable, &amp;width, &amp;height);
device_radius = MIN (width, height) / 2.;
pango_matrix_translate (&amp;matrix,
device_radius + (width - 2 * device_radius) / 2,
device_radius + (height - 2 * device_radius) / 2);
pango_matrix_scale (&amp;matrix, device_radius / RADIUS, device_radius / RADIUS);
/* Create a PangoLayout, set the font and text */
context = gdk_pango_context_get_for_screen (screen);
layout = pango_layout_new (context);
pango_layout_set_text (layout, "Text", -1);
desc = pango_font_description_from_string (FONT);
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
/* Draw the layout N_WORDS times in a circle */
for (i = 0; i &lt; N_WORDS; i++)
{
GdkColor color;
PangoMatrix rotated_matrix = matrix;
int width, height;
double angle = (360. * i) / N_WORDS;
/* Gradient from red at angle == 60 to blue at angle == 300 */
color.red = 65535 * (1 + cos ((angle - 60) * M_PI / 180.)) / 2;
color.green = 0;
color.blue = 65535 - color.red;
gdk_pango_renderer_set_override_color (GDK_PANGO_RENDERER (renderer),
PANGO_RENDER_PART_FOREGROUND, &amp;color);
pango_matrix_rotate (&amp;rotated_matrix, angle);
pango_context_set_matrix (context, &amp;rotated_matrix);
/* Inform Pango to re-layout the text with the new transformation matrix */
pango_layout_context_changed (layout);
pango_layout_get_size (layout, &amp;width, &amp;height);
pango_renderer_draw_layout (renderer, layout,
- width / 2, - RADIUS * PANGO_SCALE);
}
/* Clean up default renderer, since it is shared */
gdk_pango_renderer_set_override_color (GDK_PANGO_RENDERER (renderer),
PANGO_RENDER_PART_FOREGROUND, NULL);
gdk_pango_renderer_set_drawable (GDK_PANGO_RENDERER (renderer), NULL);
gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (renderer), NULL);
/* free the objects we created */
g_object_unref (layout);
g_object_unref (context);
g_object_unref (gc);
</programlisting>
</example>
<figure>
<title>Output of <xref linkend="rotated-example"/></title>
<graphic fileref="rotated-text.png" format="PNG"/>
</figure>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GdkPangoRenderer ##### -->
<para>
</para>
<!-- ##### ARG GdkPangoRenderer:screen ##### -->
<para>
</para>
<!-- ##### STRUCT GdkPangoRendererClass ##### -->
<para>
</para>
<!-- ##### FUNCTION gdk_pango_renderer_new ##### -->
<para>
</para>
@screen:
@Returns:
<!-- ##### FUNCTION gdk_pango_renderer_get_default ##### -->
<para>
</para>
@screen:
@Returns:
<!-- ##### FUNCTION gdk_pango_renderer_set_drawable ##### -->
<para>
</para>
@gdk_renderer:
@drawable:
<!-- ##### FUNCTION gdk_pango_renderer_set_gc ##### -->
<para>
</para>
@gdk_renderer:
@gc:
<!-- ##### FUNCTION gdk_pango_renderer_set_stipple ##### -->
<para>
</para>
@gdk_renderer:
@part:
@stipple:
<!-- ##### FUNCTION gdk_pango_renderer_set_override_color ##### -->
<para>
</para>
@gdk_renderer:
@part:
@color:
<!-- ##### FUNCTION gdk_pango_context_get ##### -->
<para>
......
......@@ -1935,10 +1935,12 @@ gtk_label_get_selection_bounds
gtk_label_get_use_markup
gtk_label_get_use_underline
gtk_label_get_single_line_mode
gtk_label_get_angle
gtk_label_set_label
gtk_label_set_use_markup
gtk_label_set_use_underline
gtk_label_set_single_line_mode
gtk_label_set_angle
<SUBSECTION Standard>
GTK_LABEL
GTK_IS_LABEL
......
......@@ -170,6 +170,11 @@ described below.
@label: the object which received the signal.
@arg1:
<!-- ##### ARG GtkLabel:angle ##### -->
<para>
</para>
<!-- ##### ARG GtkLabel:attributes ##### -->
<para>
......@@ -564,6 +569,15 @@ Gtk+ 1.0.x.
@Returns:
<!-- ##### FUNCTION gtk_label_get_angle ##### -->
<para>
</para>
@label:
@Returns:
<!-- ##### FUNCTION gtk_label_set_label ##### -->
<para>
......@@ -600,3 +614,12 @@ Gtk+ 1.0.x.
@single_line_mode:
<!-- ##### FUNCTION gtk_label_set_angle ##### -->
<para>
</para>
@label:
@angle:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment