1 /* Dia -- an diagram creation/manipulation program 2 * Copyright (C) 1998 Alexander Larsson 3 * 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. 8 * 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. 13 * 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. 17 */ 18 #ifndef TEXTLINE_H 19 #define TEXTLINE_H 20 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. 23 * 24 * TODO: Actually make it editable:) 25 */ 26 27 #include <glib.h> 28 #include "diatypes.h" 29 #include "properties.h" 30 31 struct _TextLine { 32 /* don't change these values directly, use the text_line_set* functions */ 33 34 /* Text data: */ 35 gchar *chars; 36 37 /* Attributes: */ 38 DiaFont *font; 39 real height; 40 41 /* Computed values, only access these through text_line_get* functions */ 42 real ascent; 43 real descent; 44 real width; 45 46 /* Private fields */ 47 /** Whether nothing has changed in this object since values were computed. */ 48 gboolean clean; 49 50 /** Copies of the real fields to keep track of changes caused by 51 * properties setting. These may go away if we create TextLine properties. 52 */ 53 gchar *chars_cache; 54 DiaFont *font_cache; 55 real height_cache; 56 57 /** Offsets of the individual glyphs in the string. */ 58 real *offsets; 59 PangoLayoutLine *layout_offsets; 60 }; 61 62 TextLine *text_line_new(const gchar *string, DiaFont *font, real height); 63 void text_line_destroy(TextLine *text); 64 TextLine *text_line_copy(const TextLine *text); 65 void text_line_set_string(TextLine *text, const char *string); 66 void text_line_set_height(TextLine *text, real height); 67 void text_line_set_font(TextLine *text, DiaFont *font); 68 gchar *text_line_get_string(const TextLine *text); 69 DiaFont *text_line_get_font(const TextLine *text); 70 real text_line_get_height(const TextLine *text); 71 void text_line_calc_boundingbox_size(TextLine *text, Point *size); 72 real text_line_get_width(const TextLine *text); 73 real text_line_get_ascent(const TextLine *text); 74 real text_line_get_descent(const TextLine *text); 75 76 void text_line_adjust_glyphs(TextLine *line, 77 PangoGlyphString *glyphs, 78 real scale); 79 void text_line_adjust_layout_line(TextLine *line, PangoLayoutLine *layoutline, 80 real scale); 81 real text_line_get_alignment_adjustment(TextLine *text_line, 82 Alignment alignment); 83 84 #endif 85