* lib/text.h: Added text_get_line() declaration
[dia.git] / lib / textline.h
blobbbccffde834904a100840531a74101ce9f06b870
1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #ifndef TEXTLINE_H
19 #define TEXTLINE_H
21 /** The TextLine object is a single line of text with related information,
22 * such as font and font size. It can edited directly in the diagram.
24 * TODO: Actually make it editable:)
27 #include <glib.h>
28 #include "diatypes.h"
29 #include "properties.h"
30 typedef struct _RendererCache RendererCache;
32 typedef void (*RendererCacheFreeFunc) (gpointer* data);
34 struct _RendererCache {
35 DiaRenderer *renderer;
36 RendererCacheFreeFunc *free_func;
37 real scale;
38 gpointer data;
41 struct _TextLine {
42 /* don't change these values directly, use the text_line_set* functions */
44 /* Text data: */
45 gchar *chars;
47 /* Attributes: */
48 DiaFont *font;
49 real height;
51 /* Computed values, only access these through text_line_get* functions */
52 real ascent;
53 real descent;
54 real width;
56 /* Private fields */
57 /** Whether nothing has changed in this object since values were computed. */
58 gboolean clean;
60 /** Copies of the real fields to keep track of changes caused by
61 * properties setting. These may go away if we create TextLine properties.
63 gchar *chars_cache;
64 DiaFont *font_cache;
65 real height_cache;
67 /** Offsets of the individual glyphs in the string. */
68 real *offsets;
69 PangoLayoutLine *layout_offsets;
71 /** Renderers can keep their private cache items in here */
72 RendererCache *renderer_cache;
75 TextLine *text_line_new(const gchar *string, DiaFont *font, real height);
76 void text_line_destroy(TextLine *text);
77 TextLine *text_line_copy(const TextLine *text);
78 void text_line_set_string(TextLine *text, const char *string);
79 void text_line_set_height(TextLine *text, real height);
80 void text_line_set_font(TextLine *text, DiaFont *font);
81 gchar *text_line_get_string(const TextLine *text);
82 DiaFont *text_line_get_font(const TextLine *text);
83 real text_line_get_height(const TextLine *text);
84 void text_line_calc_boundingbox_size(TextLine *text, Point *size);
85 void text_line_draw(DiaRenderer *renderer, TextLine *text_line,
86 Point *pos, Color *color);
87 real text_line_get_width(TextLine *text);
88 real text_line_get_ascent(TextLine *text);
89 real text_line_get_descent(TextLine *text);
90 void text_line_set_renderer_cache(TextLine *text_line, DiaRenderer *renderer,
91 RendererCacheFreeFunc free_func, real scale,
92 gpointer data);
93 gpointer text_line_get_renderer_cache(TextLine *text_line,
94 DiaRenderer *renderer, real scale);
96 void text_line_adjust_glyphs(TextLine *line,
97 PangoGlyphString *glyphs,
98 real scale);
99 void text_line_adjust_layout_line(TextLine *line, PangoLayoutLine *layoutline,
100 real scale);
101 real text_line_get_alignment_adjustment(TextLine *text_line,
102 Alignment alignment);
104 #endif