1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
6 * This file is part of the Gnome Library.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * published by the Free Software Foundation; either the
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * You should have received a copy of the GNU Lesser General Public License
18 * License along with the Gnome Library; see the file COPYING.LIB. If not,
23 /* Text item type for GnomeCanvas widget
25 * GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
26 * copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
29 * Author: Federico Mena <federico@nuclecu.unam.mx>
30 * Port to Pango co-done by Gergõ Érdi <cactus@cactus.rulez.org>
33 #ifndef GNOME_CANVAS_TEXT_H
34 #define GNOME_CANVAS_TEXT_H
36 #include <libgnomecanvas/gnome-canvas.h>
40 /* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction.
42 * A clipping rectangle may be specified for the text. The rectangle is anchored at the text's anchor
43 * point, and is specified by clipping width and height parameters. If the clipping rectangle is
44 * enabled, it will clip the text.
46 * In addition, x and y offset values may be specified. These specify an offset from the anchor
47 * position. If used in conjunction with the clipping rectangle, these could be used to implement
48 * simple scrolling of the text within the clipping rectangle.
50 * Properties marked with [*] also have _set properties associated
51 * with them, that determine if the specified value should be used
52 * instead of the default (style-defined) values
54 * The following object arguments are available:
56 * name type read/write description
57 * ------------------------------------------------------------------------------------------
58 * text string RW The string of the text label
59 * markup string W A Pango markup string for the text label
61 * x gdouble RW X coordinate of anchor point
62 * y gdouble RW Y coordinate of anchor point
64 * font string W A string describing the font
65 * font_desc PangoFontDescription* RW Pointer to a PangoFontDescriptor
66 * attributes PangoAttrList* RW Pointer to a Pango attribute list
67 * style PangoStyle RW Pango style of font to use [*]
68 * variant PangoVariant RW Pango variant of font to use [*]
69 * weight gint RW Pango weight of font to use [*]
70 * stretch PangoStretch RW Pango stretch of font to use [*]
71 * size gint RW Size (in pixels) of font [*]
72 * size_points gdouble RW Size (in points) of font
73 * scale gdouble RW Ratio to scale font [*]
75 * justification GtkJustification RW Justification for multiline text
76 * clip_width gdouble RW Width of clip rectangle
77 * clip_height gdouble RW Height of clip rectangle
78 * clip boolean RW Use clipping rectangle?
79 * x_offset gdouble RW Horizontal offset distance from anchor position
80 * y_offset gdouble RW Vertical offset distance from anchor position
82 * text_width gdouble R Used to query the width of the rendered text
83 * text_height gdouble R Used to query the rendered height of the text
85 * fill_color string W X color specification for text
86 * fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor
87 * fill_color_rgba guint RW RGBA value used for AA color.
90 #define GNOME_TYPE_CANVAS_TEXT (gnome_canvas_text_get_type ())
91 #define GNOME_CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasText))
92 #define GNOME_CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasTextClass))
93 #define GNOME_IS_CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_TEXT))
94 #define GNOME_IS_CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_TEXT))
95 #define GNOME_CANVAS_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasTextClass))
97 typedef struct _GnomeCanvasText GnomeCanvasText
;
98 typedef struct _GnomeCanvasTextClass GnomeCanvasTextClass
;
100 struct _GnomeCanvasText
{
101 GnomeCanvasItem item
;
103 PangoFontDescription
*font_desc
; /* Font description for text */
104 PangoAttrList
*attr_list
; /* Attribute list of the text (caching) */
105 PangoUnderline underline
;
106 gboolean strikethrough
;
110 gchar
*text
; /* Text to display */
111 PangoLayout
*layout
; /* The PangoLayout containing the text */
113 gdouble x
, y
; /* Position at anchor */
115 gdouble clip_width
; /* Width of optional clip rectangle */
116 gdouble clip_height
; /* Height of optional clip rectangle */
118 gdouble xofs
, yofs
; /* Text offset distance from anchor position */
120 gdouble affine
[6]; /* The item -> canvas affine */ /*AA */
122 GtkJustification justification
; /* Justification for text */
124 gint cx
, cy
; /* Top-left canvas coordinates for text */
125 gint clip_cx
, clip_cy
; /* Top-left canvas coordinates for clip rectangle */
126 gint clip_cwidth
, clip_cheight
; /* Size of clip rectangle in pixels */
127 gint max_width
; /* Maximum width of text lines */
128 gint height
; /* Rendered text height in pixels */
130 guint32 rgba
; /* RGBA color for text */ /*AA */
132 guint clip
: 1; /* Use clip rectangle? */
134 guint underline_set
: 1; /* Apply specified underline style? */
135 guint strike_set
: 1; /* Apply specified strikethrough style? */
136 guint rise_set
: 1; /* Apply specified ascension/descension? */
138 guint scale_set
: 1; /* Apply specified font scaling ratio? */
141 struct _GnomeCanvasTextClass
{
142 GnomeCanvasItemClass parent_class
;
145 /* Standard Gtk function */
146 GType
gnome_canvas_text_get_type (void) G_GNUC_CONST
;