release 0.8.0
[swfdec.git] / swfdec / swfdec_text_layout.h
blobb181360d38ca0162b0d315a16d02654b405dfd6c
1 /* Swfdec
2 * Copyright (C) 2006-2008 Benjamin Otte <otte@gnome.org>
3 * 2007 Pekka Lampila <pekka.lampila@iki.fi>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
21 #ifndef _SWFDEC_TEXT_LAYOUT_H_
22 #define _SWFDEC_TEXT_LAYOUT_H_
24 #include <swfdec_rectangle.h>
25 #include <swfdec_renderer.h>
26 #include <swfdec_text_buffer.h>
28 G_BEGIN_DECLS
30 typedef struct _SwfdecTextLayout SwfdecTextLayout;
31 typedef struct _SwfdecTextLayoutClass SwfdecTextLayoutClass;
33 #define SWFDEC_TYPE_TEXT_LAYOUT (swfdec_text_layout_get_type())
34 #define SWFDEC_IS_TEXT_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT_LAYOUT))
35 #define SWFDEC_IS_TEXT_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT_LAYOUT))
36 #define SWFDEC_TEXT_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT_LAYOUT, SwfdecTextLayout))
37 #define SWFDEC_TEXT_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT_LAYOUT, SwfdecTextLayoutClass))
38 #define SWFDEC_TEXT_LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_TEXT_LAYOUT, SwfdecTextLayoutClass))
40 struct _SwfdecTextLayout
42 GObject object;
44 SwfdecTextBuffer * text; /* the text we render */
45 /* properties */
46 gboolean word_wrap; /* TRUE if we do word wrapping */
47 guint width; /* width we use for alignment */
48 gboolean password; /* TRUE if the text should be displayed as asterisks */
49 double scale; /* scale factor in use */
51 /* layout data */
52 GSequence * blocks; /* ordered list of blocks */
53 /* cached values */
54 guint layout_width; /* width of layout or 0 if not computed yet */
57 struct _SwfdecTextLayoutClass
59 GObjectClass object_class;
62 GType swfdec_text_layout_get_type (void);
64 SwfdecTextLayout * swfdec_text_layout_new (SwfdecTextBuffer * buffer);
66 void swfdec_text_layout_set_wrap_width (SwfdecTextLayout * layout,
67 guint width);
68 guint swfdec_text_layout_get_wrap_width (SwfdecTextLayout * layout);
69 void swfdec_text_layout_set_word_wrap (SwfdecTextLayout * layout,
70 gboolean wrap);
71 gboolean swfdec_text_layout_get_word_wrap (SwfdecTextLayout * layout);
72 void swfdec_text_layout_set_password (SwfdecTextLayout * layout,
73 gboolean password);
74 gboolean swfdec_text_layout_get_password (SwfdecTextLayout * layout);
75 void swfdec_text_layout_set_scale (SwfdecTextLayout * layout,
76 double scale);
77 double swfdec_text_layout_get_scale (SwfdecTextLayout * layout);
78 guint swfdec_text_layout_get_width (SwfdecTextLayout * layout);
79 guint swfdec_text_layout_get_height (SwfdecTextLayout * layout);
81 guint swfdec_text_layout_get_n_rows (SwfdecTextLayout * layout);
82 guint swfdec_text_layout_get_visible_rows (SwfdecTextLayout * layout,
83 guint row,
84 guint height);
85 guint swfdec_text_layout_get_visible_rows_end (SwfdecTextLayout * layout,
86 guint height);
87 void swfdec_text_layout_get_ascent_descent (SwfdecTextLayout * layout,
88 int * ascent,
89 int * descent);
91 void swfdec_text_layout_render (SwfdecTextLayout * layout,
92 cairo_t * cr,
93 const SwfdecColorTransform *ctrans,
94 guint row,
95 guint height,
96 SwfdecColor focus);
97 void swfdec_text_layout_query_position (SwfdecTextLayout * layout,
98 guint row,
99 int x,
100 int y,
101 gsize * index_,
102 gboolean * hit,
103 int * trailing);
106 G_END_DECLS
107 #endif