]> Pileus Git - ~andy/gtk/commitdiff
Update for GdkPangoRenderer
authorOwen Taylor <otaylor@redhat.com>
Sun, 21 Nov 2004 16:24:58 +0000 (16:24 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sun, 21 Nov 2004 16:24:58 +0000 (16:24 +0000)
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)

docs/reference/ChangeLog
docs/reference/gdk/Makefile.am
docs/reference/gdk/gdk-sections.txt
docs/reference/gdk/gdk.types
docs/reference/gdk/images/rotated-text.png [new file with mode: 0644]
docs/reference/gdk/tmpl/drawing.sgml
docs/reference/gdk/tmpl/pango_interaction.sgml
docs/reference/gtk/gtk-sections.txt
docs/reference/gtk/tmpl/gtklabel.sgml

index 749d9b0222fc2343c3f50c1c41c3e295c9496996..3f6f8f189e6a4add250bbe1d19b1575a64695575 100644 (file)
@@ -1,3 +1,14 @@
+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
index dafa39fa450d8dca281ce832836982cc19353541..92b2cfd2773fbe6b7a675993c5d7e1e6452994cd 100644 (file)
@@ -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     \
index 9d7ea2d5d15b1ea7e24bd1398a4230a2400216cc..825c0a0a84d4eaef8a91be62dfffbf1bb29b771a 100644 (file)
@@ -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>
index da34cd89d03a68c79f9d17434a5989936d1c518f..12b0f8d356ff16f0d0b8011e8783561b703efe50 100644 (file)
@@ -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
diff --git a/docs/reference/gdk/images/rotated-text.png b/docs/reference/gdk/images/rotated-text.png
new file mode 100644 (file)
index 0000000..1952314
Binary files /dev/null and b/docs/reference/gdk/images/rotated-text.png differ
index 0443146ad87437cb0970a446cd70a849bd9104ac..87475aeeeeea9cdc2e45a4de176e1a3efb47b554 100644 (file)
@@ -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>
 
index dc6c71af70a6d1c9a67d17a97a795da3c258c1b6..16ee04a5f7d886d34c03642c37f65bf61bdd5e0e 100644 (file)
 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>
 
index 6479e102c00f4783b903f6ec6b4c337707748b30..ba601e69a9cdffd724c44b142612ab5359dffb2c 100644 (file)
@@ -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
index ecd9d06c60184f29b681ad1687c399d9ee8135f6..fb46d301c939b1bb88e908b6e453c6a12999d9b0 100644 (file)
@@ -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: 
+
+