1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 /* 3 * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation 4 * All rights reserved. 5 * 6 * This file is part of the Gnome Library. 7 * 8 * The Gnome Library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public License as 10 * published by the Free Software Foundation; either version 2 of the 11 * License, or (at your option) any later version. 12 * 13 * The Gnome Library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public 19 * License along with the Gnome Library; see the file COPYING.LIB. If not, 20 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 * Boston, MA 02111-1307, USA. 22 */ 23 /* 24 @NOTATION@ 25 */ 26 /* Text item type for GnomeCanvas widget 27 * 28 * GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is 29 * copyrighted by the Regents of the University of California, Sun Microsystems, and other parties. 30 * 31 * 32 * Author: Federico Mena <federico@nuclecu.unam.mx> 33 * Port to Pango co-done by Gergõ Érdi <cactus@cactus.rulez.org> 34 */ 35 36 #ifndef GNOME_CANVAS_TEXT_H 37 #define GNOME_CANVAS_TEXT_H 38 39 40 #include <libgnomecanvas/gnome-canvas.h> 41 42 43 G_BEGIN_DECLS 44 45 46 /* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction. 47 * 48 * A clipping rectangle may be specified for the text. The rectangle is anchored at the text's anchor 49 * point, and is specified by clipping width and height parameters. If the clipping rectangle is 50 * enabled, it will clip the text. 51 * 52 * In addition, x and y offset values may be specified. These specify an offset from the anchor 53 * position. If used in conjunction with the clipping rectangle, these could be used to implement 54 * simple scrolling of the text within the clipping rectangle. 55 * 56 * Properties marked with [*] also have _set properties associated 57 * with them, that determine if the specified value should be used 58 * instead of the default (style-defined) values 59 * 60 * The following object arguments are available: 61 * 62 * name type read/write description 63 * ------------------------------------------------------------------------------------------ 64 * text string RW The string of the text label 65 * markup string W A Pango markup string for the text label 66 * 67 * x double RW X coordinate of anchor point 68 * y double RW Y coordinate of anchor point 69 * 70 * font string W A string describing the font 71 * font_desc PangoFontDescription* RW Pointer to a PangoFontDescriptor 72 * attributes PangoAttrList* RW Pointer to a Pango attribute list 73 * style PangoStyle RW Pango style of font to use [*] 74 * variant PangoVariant RW Pango variant of font to use [*] 75 * weight int RW Pango weight of font to use [*] 76 * stretch PangoStretch RW Pango stretch of font to use [*] 77 * size int RW Size (in pixels) of font [*] 78 * size_points double RW Size (in points) of font 79 * scale double RW Ratio to scale font [*] 80 * 81 * anchor GtkAnchorType RW Anchor side for the text 82 * justification GtkJustification RW Justification for multiline text 83 * clip_width double RW Width of clip rectangle 84 * clip_height double RW Height of clip rectangle 85 * clip boolean RW Use clipping rectangle? 86 * x_offset double RW Horizontal offset distance from anchor position 87 * y_offset double RW Vertical offset distance from anchor position 88 * 89 * text_width double R Used to query the width of the rendered text 90 * text_height double R Used to query the rendered height of the text 91 * 92 * fill_color string W X color specification for text 93 * fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor 94 * fill_color_rgba guint RW RGBA value used for AA color. 95 * fill_stipple GdkBitmap* RW Stipple pattern for filling the text 96 */ 97 98 #define GNOME_TYPE_CANVAS_TEXT (gnome_canvas_text_get_type ()) 99 #define GNOME_CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasText)) 100 #define GNOME_CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasTextClass)) 101 #define GNOME_IS_CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_TEXT)) 102 #define GNOME_IS_CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_TEXT)) 103 #define GNOME_CANVAS_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasTextClass)) 104 105 106 typedef struct _GnomeCanvasText GnomeCanvasText; 107 typedef struct _GnomeCanvasTextClass GnomeCanvasTextClass; 108 109 typedef struct _GnomeCanvasTextPrivate GnomeCanvasTextPrivate; 110 111 struct _GnomeCanvasText { 112 GnomeCanvasItem item; 113 114 PangoFontDescription *font_desc; /* Font description for text */ 115 PangoAttrList *attr_list; /* Attribute list of the text (caching) */ 116 PangoUnderline underline; 117 gboolean strikethrough; 118 int rise; 119 double scale; 120 121 char *text; /* Text to display */ 122 GdkBitmap *stipple; /* Stipple for text */ 123 GdkGC *gc; /* GC for drawing text */ 124 PangoLayout *layout; /* The PangoLayout containing the text */ 125 126 gulong pixel; /* Fill color */ 127 128 double x, y; /* Position at anchor */ 129 130 double clip_width; /* Width of optional clip rectangle */ 131 double clip_height; /* Height of optional clip rectangle */ 132 133 double xofs, yofs; /* Text offset distance from anchor position */ 134 135 double affine[6]; /* The item -> canvas affine */ /*AA*/ 136 137 GtkAnchorType anchor; /* Anchor side for text */ 138 GtkJustification justification; /* Justification for text */ 139 140 int cx, cy; /* Top-left canvas coordinates for text */ 141 int clip_cx, clip_cy; /* Top-left canvas coordinates for clip rectangle */ 142 int clip_cwidth, clip_cheight; /* Size of clip rectangle in pixels */ 143 int max_width; /* Maximum width of text lines */ 144 int height; /* Rendered text height in pixels */ 145 146 guint32 rgba; /* RGBA color for text */ /*AA*/ 147 148 guint clip : 1; /* Use clip rectangle? */ 149 150 guint underline_set : 1; /* Apply specified underline style? */ 151 guint strike_set : 1; /* Apply specified strikethrough style? */ 152 guint rise_set : 1; /* Apply specified ascension/descension? */ 153 154 guint scale_set : 1; /* Apply specified font scaling ratio? */ 155 156 GnomeCanvasTextPrivate *priv; 157 }; 158 159 struct _GnomeCanvasTextClass { 160 GnomeCanvasItemClass parent_class; 161 }; 162 163 164 /* Standard Gtk function */ 165 GType gnome_canvas_text_get_type (void) G_GNUC_CONST; 166 167 168 G_END_DECLS 169 170 #endif 171