Added new API for ATK 1.11/1.12. Minor docs cleanup.
[platform/upstream/atk.git] / atk / atktext.h
1 /* ATK - The Accessibility Toolkit for GTK+
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #ifndef __ATK_TEXT_H__
22 #define __ATK_TEXT_H__
23
24 #include <glib-object.h>
25 #include <atk/atkobject.h>
26 #include <atk/atkutil.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 /**
33  *AtkTextAttribute
34  *@ATK_TEXT_ATTR_INVALID: Invalid attribute
35  *@ATK_TEXT_ATTR_LEFT_MARGIN: The pixel width of the left margin
36  *@ATK_TEXT_ATTR_RIGHT_MARGIN: The pixel width of the right margin
37  *@ATK_TEXT_ATTR_INDENT: The number of pixels that the text is indented
38  *@ATK_TEXT_ATTR_INVISIBLE: Either "true" or "false" indicating whether text is visible or not
39  *@ATK_TEXT_ATTR_EDITABLE: Either "true" or "false" indicating whether text is editable or not
40  *@ATK_TEXT_ATTR_PIXELS_ABOVE_LINES: Pixels of blank space to leave above each newline-terminated line. 
41  *@ATK_TEXT_ATTR_PIXELS_BELOW_LINES: Pixels of blank space to leave below each newline-terminated line.
42  *@ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP: Pixels of blank space to leave between wrapped lines inside the same newline-terminated line (paragraph).
43  *@ATK_TEXT_ATTR_BG_FULL_HEIGHT: "true" or "false" whether to make the background color for each character the height of the highest font used on the current line, or the height of the font used for the current character.
44  *@ATK_TEXT_ATTR_RISE: Number of pixels that the characters are risen above the baseline
45  *@ATK_TEXT_ATTR_UNDERLINE: "none", "single", "double" or "low"
46  *@ATK_TEXT_ATTR_STRIKETHROUGH: "true" or "false" whether the text is strikethrough 
47  *@ATK_TEXT_ATTR_SIZE: The size of the characters. 
48  *@ATK_TEXT_ATTR_SCALE: The scale of the characters. The value is a string representation of a double 
49  *@ATK_TEXT_ATTR_WEIGHT: The weight of the characters.
50  *@ATK_TEXT_ATTR_LANGUAGE: The language used
51  *@ATK_TEXT_ATTR_FAMILY_NAME: The font family name
52  *@ATK_TEXT_ATTR_BG_COLOR: The background color. The value is an RGB value of the format "%u,%u,%u"
53  *@ATK_TEXT_ATTR_FG_COLOR:The foreground color. The value is an RGB value of the format "%u,%u,%u"
54  *@ATK_TEXT_ATTR_BG_STIPPLE: "true" if a #GdkBitmap is set for stippling the background color.
55  *@ATK_TEXT_ATTR_FG_STIPPLE: "true" if a #GdkBitmap is set for stippling the foreground color.
56  *@ATK_TEXT_ATTR_WRAP_MODE: The wrap mode of the text, if any. Values are "none", "char" or "word" 
57  *@ATK_TEXT_ATTR_DIRECTION: The direction of the text, if set. Values are "none", "ltr" or "rtl" 
58  *@ATK_TEXT_ATTR_JUSTIFICATION: The justification of the text, if set. Values are "left", "right", "center" or "fill" 
59  *@ATK_TEXT_ATTR_STRETCH: The stretch of the text, if set. Values are "ultra_condensed", "extra_condensed", "condensed", "semi_condensed", "normal", "semi_expanded", "expanded", "extra_expanded" or "ultra_expanded"
60  *@ATK_TEXT_ATTR_VARIANT: The capitalization variant of the text, if set. Values are "normal" or "small_caps"
61  *@ATK_TEXT_ATTR_STYLE: The slant style of the text, if set. Values are "normal", "oblique" or "italic"
62  *@ATK_TEXT_ATTR_LAST_DEFINED: not a valid text attribute, used for finding end of enumeration
63  *
64  * Describes the text attributes supported
65  **/
66 typedef enum
67 {
68   ATK_TEXT_ATTR_INVALID = 0,
69   ATK_TEXT_ATTR_LEFT_MARGIN,
70   ATK_TEXT_ATTR_RIGHT_MARGIN,
71   ATK_TEXT_ATTR_INDENT,
72   ATK_TEXT_ATTR_INVISIBLE,
73   ATK_TEXT_ATTR_EDITABLE,
74   ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
75   ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
76   ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
77   ATK_TEXT_ATTR_BG_FULL_HEIGHT,
78   ATK_TEXT_ATTR_RISE,
79   ATK_TEXT_ATTR_UNDERLINE,
80   ATK_TEXT_ATTR_STRIKETHROUGH,
81   ATK_TEXT_ATTR_SIZE,
82   ATK_TEXT_ATTR_SCALE,
83   ATK_TEXT_ATTR_WEIGHT,
84   ATK_TEXT_ATTR_LANGUAGE,
85   ATK_TEXT_ATTR_FAMILY_NAME,
86   ATK_TEXT_ATTR_BG_COLOR,
87   ATK_TEXT_ATTR_FG_COLOR,
88   ATK_TEXT_ATTR_BG_STIPPLE,
89   ATK_TEXT_ATTR_FG_STIPPLE,
90   ATK_TEXT_ATTR_WRAP_MODE,
91   ATK_TEXT_ATTR_DIRECTION,
92   ATK_TEXT_ATTR_JUSTIFICATION,
93   ATK_TEXT_ATTR_STRETCH,
94   ATK_TEXT_ATTR_VARIANT,
95   ATK_TEXT_ATTR_STYLE,
96   ATK_TEXT_ATTR_LAST_DEFINED
97 } AtkTextAttribute;
98
99 AtkTextAttribute         atk_text_attribute_register   (const gchar *name);
100
101
102 #define ATK_TYPE_TEXT                    (atk_text_get_type ())
103 #define ATK_IS_TEXT(obj)                 G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TEXT)
104 #define ATK_TEXT(obj)                    G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TEXT, AtkText)
105 #define ATK_TEXT_GET_IFACE(obj)          (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TEXT, AtkTextIface))
106
107 #ifndef _TYPEDEF_ATK_TEXT_
108 #define _TYPEDEF_ATK_TEXT_
109 typedef struct _AtkText AtkText;
110 #endif
111 typedef struct _AtkTextIface AtkTextIface;
112
113 /**
114  *AtkTextBoundary:
115  *@ATK_TEXT_BOUNDARY_CHAR:
116  *@ATK_TEXT_BOUNDARY_WORD_START:
117  *@ATK_TEXT_BOUNDARY_WORD_END:
118  *@ATK_TEXT_BOUNDARY_SENTENCE_START:
119  *@ATK_TEXT_BOUNDARY_SENTENCE_END:
120  *@ATK_TEXT_BOUNDARY_LINE_START:
121  *@ATK_TEXT_BOUNDARY_LINE_END:
122  *
123  *Text boundary types used for specifying boundaries for regions of text
124  **/
125 typedef enum {
126   ATK_TEXT_BOUNDARY_CHAR,
127   ATK_TEXT_BOUNDARY_WORD_START,
128   ATK_TEXT_BOUNDARY_WORD_END,
129   ATK_TEXT_BOUNDARY_SENTENCE_START,
130   ATK_TEXT_BOUNDARY_SENTENCE_END,
131   ATK_TEXT_BOUNDARY_LINE_START,
132   ATK_TEXT_BOUNDARY_LINE_END
133 } AtkTextBoundary;
134
135 /**
136  * AtkTextRectangle:
137  * @x: The horizontal coordinate of a rectangle
138  * @y: The vertical coordinate of a rectangle
139  * @width: The width of a rectangle
140  * @height: The height of a rectangle
141  *
142  * A structure used to store a rectangle used by AtkText.
143  **/
144
145 typedef struct _AtkTextRectangle AtkTextRectangle;
146
147 struct _AtkTextRectangle {
148   gint x;
149   gint y;
150   gint width;
151   gint height;
152 };
153
154 /**
155  * AtkTextRange:
156  * @bounds: A rectangle giving the bounds of the text range
157  * @start_offset: The start offset of a AtkTextRange
158  * @end_offset: The end offset of a AtkTextRange
159  * @content: The text in the text range
160  *
161  * A structure used to describe a text range.
162  **/
163 typedef struct _AtkTextRange AtkTextRange;
164
165 struct _AtkTextRange {
166   AtkTextRectangle bounds;
167   gint start_offset;
168   gint end_offset;
169   gchar* content;
170 };
171
172 /**
173  *AtkTextClipType
174  *@ATK_TEXT_CLIP_NONE: No clipping to be done
175  *@ATK_TEXT_CLIP_MIN: Text clipped by min coordinate is omitted
176  *@ATK_TEXT_CLIP_MAX: Text clipped by max coordinate is omitted
177  *@ATK_TEXT_CLIP_BOTH: Only text fully within mix/max bound is retained
178  *
179  *Describes the type of clipping required.
180  **/
181 typedef enum {
182     ATK_TEXT_CLIP_NONE,
183     ATK_TEXT_CLIP_MIN,
184     ATK_TEXT_CLIP_MAX,
185     ATK_TEXT_CLIP_BOTH
186 } AtkTextClipType;
187
188 struct _AtkTextIface
189 {
190   GTypeInterface parent;
191
192   gchar*         (* get_text)                     (AtkText          *text,
193                                                    gint             start_offset,
194                                                    gint             end_offset);
195   gchar*         (* get_text_after_offset)        (AtkText          *text,
196                                                    gint             offset,
197                                                    AtkTextBoundary  boundary_type,
198                                                    gint             *start_offset,
199                                                    gint             *end_offset);
200   gchar*         (* get_text_at_offset)           (AtkText          *text,
201                                                    gint             offset,
202                                                    AtkTextBoundary  boundary_type,
203                                                    gint             *start_offset,
204                                                    gint             *end_offset);
205   gunichar       (* get_character_at_offset)      (AtkText          *text,
206                                                    gint             offset);
207   gchar*         (* get_text_before_offset)       (AtkText          *text,
208                                                    gint             offset,
209                                                    AtkTextBoundary  boundary_type,
210                                                    gint             *start_offset,
211                                                    gint             *end_offset);
212   gint           (* get_caret_offset)             (AtkText          *text);
213   AtkAttributeSet* (* get_run_attributes)         (AtkText          *text,
214                                                    gint             offset,
215                                                    gint             *start_offset,
216                                                    gint             *end_offset);
217   AtkAttributeSet* (* get_default_attributes)     (AtkText          *text);
218   void           (* get_character_extents)        (AtkText          *text,
219                                                    gint             offset,
220                                                    gint             *x,
221                                                    gint             *y,
222                                                    gint             *width,
223                                                    gint             *height,
224                                                    AtkCoordType     coords);
225   gint           (* get_character_count)          (AtkText          *text);
226   gint           (* get_offset_at_point)          (AtkText          *text,
227                                                    gint             x,
228                                                    gint             y,
229                                                    AtkCoordType     coords);
230   gint           (* get_n_selections)             (AtkText          *text);
231   gchar*         (* get_selection)                (AtkText          *text,
232                                                    gint             selection_num,
233                                                    gint             *start_offset,
234                                                    gint             *end_offset);
235   gboolean       (* add_selection)                (AtkText          *text,
236                                                    gint             start_offset,
237                                                    gint             end_offset);
238   gboolean       (* remove_selection)             (AtkText          *text,
239                                                    gint             selection_num);
240   gboolean       (* set_selection)                (AtkText          *text,
241                                                    gint             selection_num,
242                                                    gint             start_offset,
243                                                    gint             end_offset);
244   gboolean       (* set_caret_offset)             (AtkText          *text,
245                                                    gint             offset);
246
247   /*
248    * signal handlers
249    */
250   void           (* text_changed)                 (AtkText          *text,
251                                                    gint             position,
252                                                    gint             length);
253   void           (* text_caret_moved)             (AtkText          *text,
254                                                    gint             location);
255   void           (* text_selection_changed)       (AtkText          *text);
256
257   void           (* text_attributes_changed)      (AtkText          *text);
258
259
260   void           (* get_range_extents)            (AtkText          *text,
261                                                    gint             start_offset,
262                                                    gint             end_offset,
263                                                    AtkCoordType     coord_type,
264                                                    AtkTextRectangle *rect);
265
266   AtkTextRange** (* get_bounded_ranges)           (AtkText          *text,
267                                                    AtkTextRectangle *rect,
268                                                    AtkCoordType     coord_type,
269                                                    AtkTextClipType  x_clip_type,
270                                                    AtkTextClipType  y_clip_type);
271  
272
273   AtkFunction    pad4;
274 };
275
276 GType            atk_text_get_type (void);
277
278
279 /*
280  * Additional AtkObject properties used by AtkText:
281  *    "accessible_text" (accessible text has changed)
282  *    "accessible_caret" (accessible text cursor position changed:
283  *                         editable text only)
284  */
285
286 gchar*        atk_text_get_text                           (AtkText          *text,
287                                                            gint             start_offset,
288                                                            gint             end_offset);
289 gunichar      atk_text_get_character_at_offset            (AtkText          *text,
290                                                            gint             offset);
291 gchar*        atk_text_get_text_after_offset              (AtkText          *text,
292                                                            gint             offset,
293                                                            AtkTextBoundary  boundary_type,
294                                                            gint             *start_offset,
295                                                            gint             *end_offset);
296 gchar*        atk_text_get_text_at_offset                 (AtkText          *text,
297                                                            gint             offset,
298                                                            AtkTextBoundary  boundary_type,
299                                                            gint             *start_offset,
300                                                            gint             *end_offset);
301 gchar*        atk_text_get_text_before_offset             (AtkText          *text,
302                                                            gint             offset,
303                                                            AtkTextBoundary  boundary_type,
304                                                            gint             *start_offset,
305                                                            gint             *end_offset);
306 gint          atk_text_get_caret_offset                   (AtkText          *text);
307 void          atk_text_get_character_extents              (AtkText          *text,
308                                                            gint             offset,
309                                                            gint             *x,
310                                                            gint             *y,
311                                                            gint             *width,
312                                                            gint             *height,
313                                                            AtkCoordType     coords);
314 AtkAttributeSet* atk_text_get_run_attributes              (AtkText          *text,
315                                                            gint             offset,
316                                                            gint             *start_offset,
317                                                            gint             *end_offset);
318 AtkAttributeSet* atk_text_get_default_attributes          (AtkText          *text);
319 gint          atk_text_get_character_count                (AtkText          *text);
320 gint          atk_text_get_offset_at_point                (AtkText          *text,
321                                                            gint             x,
322                                                            gint             y,
323                                                            AtkCoordType     coords);
324 gint          atk_text_get_n_selections                   (AtkText          *text);
325 gchar*        atk_text_get_selection                      (AtkText          *text,
326                                                            gint             selection_num,
327                                                            gint             *start_offset,
328                                                            gint             *end_offset);
329 gboolean      atk_text_add_selection                      (AtkText          *text,
330                                                            gint             start_offset,
331                                                            gint             end_offset);
332 gboolean      atk_text_remove_selection                   (AtkText          *text,
333                                                            gint             selection_num);
334 gboolean      atk_text_set_selection                      (AtkText          *text,
335                                                            gint             selection_num,
336                                                            gint             start_offset,
337                                                            gint             end_offset);
338 gboolean      atk_text_set_caret_offset                   (AtkText          *text,
339                                                            gint             offset);
340 void          atk_text_get_range_extents                  (AtkText          *text,
341
342                                                            gint             start_offset,
343                                                            gint             end_offset,
344                                                            AtkCoordType     coord_type,
345                                                            AtkTextRectangle *rect);
346 AtkTextRange**  atk_text_get_bounded_ranges               (AtkText          *text,
347                                                            AtkTextRectangle *rect,
348                                                            AtkCoordType     coord_type,
349                                                            AtkTextClipType  x_clip_type,
350                                                            AtkTextClipType  y_clip_type);
351 void          atk_text_free_ranges                        (AtkTextRange     **ranges);
352 void          atk_attribute_set_free                      (AtkAttributeSet  *attrib_set);
353 G_CONST_RETURN gchar*  atk_text_attribute_get_name        (AtkTextAttribute attr);
354 AtkTextAttribute       atk_text_attribute_for_name        (const gchar      *name);
355 G_CONST_RETURN gchar*  atk_text_attribute_get_value       (AtkTextAttribute attr,
356                                                            gint             index_);
357
358 #ifdef __cplusplus
359 }
360 #endif /* __cplusplus */
361
362
363 #endif /* __ATK_TEXT_H__ */