Updated FSF's address
[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, see <http://www.gnu.org/licenses/>.
16  */
17
18 #if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (ATK_COMPILATION)
19 #error "Only <atk/atk.h> can be included directly."
20 #endif
21
22 #ifndef __ATK_TEXT_H__
23 #define __ATK_TEXT_H__
24
25 #include <glib-object.h>
26 #include <atk/atkobject.h>
27 #include <atk/atkutil.h>
28
29 G_BEGIN_DECLS
30
31 /**
32  *AtkTextAttribute:
33  *@ATK_TEXT_ATTR_INVALID: Invalid attribute, like bad spelling or grammar.
34  *@ATK_TEXT_ATTR_LEFT_MARGIN: The pixel width of the left margin
35  *@ATK_TEXT_ATTR_RIGHT_MARGIN: The pixel width of the right margin
36  *@ATK_TEXT_ATTR_INDENT: The number of pixels that the text is indented
37  *@ATK_TEXT_ATTR_INVISIBLE: Either "true" or "false" indicating whether text is visible or not
38  *@ATK_TEXT_ATTR_EDITABLE: Either "true" or "false" indicating whether text is editable or not
39  *@ATK_TEXT_ATTR_PIXELS_ABOVE_LINES: Pixels of blank space to leave above each newline-terminated line. 
40  *@ATK_TEXT_ATTR_PIXELS_BELOW_LINES: Pixels of blank space to leave below each newline-terminated line.
41  *@ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP: Pixels of blank space to leave between wrapped lines inside the same newline-terminated line (paragraph).
42  *@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.
43  *@ATK_TEXT_ATTR_RISE: Number of pixels that the characters are risen above the baseline
44  *@ATK_TEXT_ATTR_UNDERLINE: "none", "single", "double", "low", or "error"
45  *@ATK_TEXT_ATTR_STRIKETHROUGH: "true" or "false" whether the text is strikethrough 
46  *@ATK_TEXT_ATTR_SIZE: The size of the characters in points. eg: 10
47  *@ATK_TEXT_ATTR_SCALE: The scale of the characters. The value is a string representation of a double 
48  *@ATK_TEXT_ATTR_WEIGHT: The weight of the characters.
49  *@ATK_TEXT_ATTR_LANGUAGE: The language used
50  *@ATK_TEXT_ATTR_FAMILY_NAME: The font family name
51  *@ATK_TEXT_ATTR_BG_COLOR: The background color. The value is an RGB value of the format "%u,%u,%u"
52  *@ATK_TEXT_ATTR_FG_COLOR:The foreground color. The value is an RGB value of the format "%u,%u,%u"
53  *@ATK_TEXT_ATTR_BG_STIPPLE: "true" if a #GdkBitmap is set for stippling the background color.
54  *@ATK_TEXT_ATTR_FG_STIPPLE: "true" if a #GdkBitmap is set for stippling the foreground color.
55  *@ATK_TEXT_ATTR_WRAP_MODE: The wrap mode of the text, if any. Values are "none", "char", "word", or "word_char".
56  *@ATK_TEXT_ATTR_DIRECTION: The direction of the text, if set. Values are "none", "ltr" or "rtl" 
57  *@ATK_TEXT_ATTR_JUSTIFICATION: The justification of the text, if set. Values are "left", "right", "center" or "fill" 
58  *@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"
59  *@ATK_TEXT_ATTR_VARIANT: The capitalization variant of the text, if set. Values are "normal" or "small_caps"
60  *@ATK_TEXT_ATTR_STYLE: The slant style of the text, if set. Values are "normal", "oblique" or "italic"
61  *@ATK_TEXT_ATTR_LAST_DEFINED: not a valid text attribute, used for finding end of enumeration
62  *
63  * Describes the text attributes supported
64  **/
65 typedef enum
66 {
67   ATK_TEXT_ATTR_INVALID = 0,
68   ATK_TEXT_ATTR_LEFT_MARGIN,
69   ATK_TEXT_ATTR_RIGHT_MARGIN,
70   ATK_TEXT_ATTR_INDENT,
71   ATK_TEXT_ATTR_INVISIBLE,
72   ATK_TEXT_ATTR_EDITABLE,
73   ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
74   ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
75   ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
76   ATK_TEXT_ATTR_BG_FULL_HEIGHT,
77   ATK_TEXT_ATTR_RISE,
78   ATK_TEXT_ATTR_UNDERLINE,
79   ATK_TEXT_ATTR_STRIKETHROUGH,
80   ATK_TEXT_ATTR_SIZE,
81   ATK_TEXT_ATTR_SCALE,
82   ATK_TEXT_ATTR_WEIGHT,
83   ATK_TEXT_ATTR_LANGUAGE,
84   ATK_TEXT_ATTR_FAMILY_NAME,
85   ATK_TEXT_ATTR_BG_COLOR,
86   ATK_TEXT_ATTR_FG_COLOR,
87   ATK_TEXT_ATTR_BG_STIPPLE,
88   ATK_TEXT_ATTR_FG_STIPPLE,
89   ATK_TEXT_ATTR_WRAP_MODE,
90   ATK_TEXT_ATTR_DIRECTION,
91   ATK_TEXT_ATTR_JUSTIFICATION,
92   ATK_TEXT_ATTR_STRETCH,
93   ATK_TEXT_ATTR_VARIANT,
94   ATK_TEXT_ATTR_STYLE,
95   ATK_TEXT_ATTR_LAST_DEFINED
96 } AtkTextAttribute;
97
98 AtkTextAttribute         atk_text_attribute_register   (const gchar *name);
99
100
101 #define ATK_TYPE_TEXT                    (atk_text_get_type ())
102 #define ATK_IS_TEXT(obj)                 G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TEXT)
103 #define ATK_TEXT(obj)                    G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TEXT, AtkText)
104 #define ATK_TEXT_GET_IFACE(obj)          (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TEXT, AtkTextIface))
105
106 #ifndef _TYPEDEF_ATK_TEXT_
107 #define _TYPEDEF_ATK_TEXT_
108 typedef struct _AtkText AtkText;
109 #endif
110 typedef struct _AtkTextIface AtkTextIface;
111
112
113 /**
114  *AtkTextBoundary:
115  *@ATK_TEXT_BOUNDARY_CHAR: Boundary is the boundary between characters
116  * (including non-printing characters)
117  *@ATK_TEXT_BOUNDARY_WORD_START: Boundary is the start (i.e. first character) of a word.
118  *@ATK_TEXT_BOUNDARY_WORD_END: Boundary is the end (i.e. last
119  * character) of a word.
120  *@ATK_TEXT_BOUNDARY_SENTENCE_START: Boundary is the first character in a sentence.
121  *@ATK_TEXT_BOUNDARY_SENTENCE_END: Boundary is the last (terminal)
122  * character in a sentence; in languages which use "sentence stop"
123  * punctuation such as English, the boundary is thus the '.', '?', or
124  * similar terminal punctuation character.
125  *@ATK_TEXT_BOUNDARY_LINE_START: Boundary is the initial character of the content or a
126  * character immediately following a newline, linefeed, or return character.
127  *@ATK_TEXT_BOUNDARY_LINE_END: Boundary is the linefeed, or return
128  * character.
129  *
130  * Text boundary types used for specifying boundaries for regions of text.
131  * This enumerationis deprecated since 2.9.4 and should not be used. Use
132  * AtkTextGranularity with #atk_text_get_string_at_offset instead.
133  **/
134 typedef enum {
135   ATK_TEXT_BOUNDARY_CHAR,
136   ATK_TEXT_BOUNDARY_WORD_START,
137   ATK_TEXT_BOUNDARY_WORD_END,
138   ATK_TEXT_BOUNDARY_SENTENCE_START,
139   ATK_TEXT_BOUNDARY_SENTENCE_END,
140   ATK_TEXT_BOUNDARY_LINE_START,
141   ATK_TEXT_BOUNDARY_LINE_END
142 } AtkTextBoundary;
143
144 /**
145  *AtkTextGranularity:
146  *@ATK_TEXT_GRANULARITY_CHAR: Granularity is defined by the boundaries between characters
147  * (including non-printing characters)
148  *@ATK_TEXT_GRANULARITY_WORD: Granularity is defined by the boundaries of a word,
149  * starting at the beginning of the current word and finishing at the beginning of
150  * the following one, if present.
151  *@ATK_TEXT_GRANULARITY_SENTENCE: Granularity is defined by the boundaries of a sentence,
152  * starting at the beginning of the current sentence and finishing at the beginning of
153  * the following one, if present.
154  *@ATK_TEXT_GRANULARITY_LINE: Granularity is defined by the boundaries of a line,
155  * starting at the beginning of the current line and finishing at the beginning of
156  * the following one, if present.
157  *@ATK_TEXT_GRANULARITY_PARAGRAPH: Granularity is defined by the boundaries of a paragraph,
158  * starting at the beginning of the current paragraph and finishing at the beginning of
159  * the following one, if present.
160  *
161  * Text granularity types used for specifying the granularity of the region of
162  * text we are interested in.
163  **/
164 typedef enum {
165   ATK_TEXT_GRANULARITY_CHAR,
166   ATK_TEXT_GRANULARITY_WORD,
167   ATK_TEXT_GRANULARITY_SENTENCE,
168   ATK_TEXT_GRANULARITY_LINE,
169   ATK_TEXT_GRANULARITY_PARAGRAPH
170 } AtkTextGranularity;
171
172 /**
173  * AtkTextRectangle:
174  * @x: The horizontal coordinate of a rectangle
175  * @y: The vertical coordinate of a rectangle
176  * @width: The width of a rectangle
177  * @height: The height of a rectangle
178  *
179  * A structure used to store a rectangle used by AtkText.
180  **/
181
182 typedef struct _AtkTextRectangle AtkTextRectangle;
183
184 struct _AtkTextRectangle {
185   gint x;
186   gint y;
187   gint width;
188   gint height;
189 };
190
191 /**
192  * AtkTextRange:
193  * @bounds: A rectangle giving the bounds of the text range
194  * @start_offset: The start offset of a AtkTextRange
195  * @end_offset: The end offset of a AtkTextRange
196  * @content: The text in the text range
197  *
198  * A structure used to describe a text range.
199  **/
200 typedef struct _AtkTextRange AtkTextRange;
201
202 struct _AtkTextRange {
203   AtkTextRectangle bounds;
204   gint start_offset;
205   gint end_offset;
206   gchar* content;
207 };
208
209 GType atk_text_range_get_type (void);
210
211 /**
212  *AtkTextClipType:
213  *@ATK_TEXT_CLIP_NONE: No clipping to be done
214  *@ATK_TEXT_CLIP_MIN: Text clipped by min coordinate is omitted
215  *@ATK_TEXT_CLIP_MAX: Text clipped by max coordinate is omitted
216  *@ATK_TEXT_CLIP_BOTH: Only text fully within mix/max bound is retained
217  *
218  *Describes the type of clipping required.
219  **/
220 typedef enum {
221     ATK_TEXT_CLIP_NONE,
222     ATK_TEXT_CLIP_MIN,
223     ATK_TEXT_CLIP_MAX,
224     ATK_TEXT_CLIP_BOTH
225 } AtkTextClipType;
226
227 /**
228  * AtkTextIface:
229  * @get_text_after_offset: Gets specified text. This virtual function
230  *   is deprecated and it should not be overridden.
231  * @get_text_at_offset: Gets specified text. This virtual function
232  *   is deprecated and it should not be overridden.
233  * @get_text_before_offset: Gets specified text. This virtual function
234  *   is deprecated and it should not be overridden.
235  * @get_string_at_offset: Gets a portion of the text exposed through
236  *   an AtkText according to a given offset and a specific
237  *   granularity, along with the start and end offsets defining the
238  *   boundaries of such a portion of text.
239  * @text_changed: the signal handler which is executed when there is a
240  *   text change. This virtual function is deprecated sice 2.9.4 and
241  *   it should not be overriden.
242  */
243 struct _AtkTextIface
244 {
245   GTypeInterface parent;
246
247   gchar*         (* get_text)                     (AtkText          *text,
248                                                    gint             start_offset,
249                                                    gint             end_offset);
250   gchar*         (* get_text_after_offset)        (AtkText          *text,
251                                                    gint             offset,
252                                                    AtkTextBoundary  boundary_type,
253                                                    gint             *start_offset,
254                                                    gint             *end_offset);
255   gchar*         (* get_text_at_offset)           (AtkText          *text,
256                                                    gint             offset,
257                                                    AtkTextBoundary  boundary_type,
258                                                    gint             *start_offset,
259                                                    gint             *end_offset);
260   gunichar       (* get_character_at_offset)      (AtkText          *text,
261                                                    gint             offset);
262   gchar*         (* get_text_before_offset)       (AtkText          *text,
263                                                    gint             offset,
264                                                    AtkTextBoundary  boundary_type,
265                                                    gint             *start_offset,
266                                                    gint             *end_offset);
267   gint           (* get_caret_offset)             (AtkText          *text);
268   AtkAttributeSet* (* get_run_attributes)         (AtkText          *text,
269                                                    gint             offset,
270                                                    gint             *start_offset,
271                                                    gint             *end_offset);
272   AtkAttributeSet* (* get_default_attributes)     (AtkText          *text);
273   void           (* get_character_extents)        (AtkText          *text,
274                                                    gint             offset,
275                                                    gint             *x,
276                                                    gint             *y,
277                                                    gint             *width,
278                                                    gint             *height,
279                                                    AtkCoordType     coords);
280   gint           (* get_character_count)          (AtkText          *text);
281   gint           (* get_offset_at_point)          (AtkText          *text,
282                                                    gint             x,
283                                                    gint             y,
284                                                    AtkCoordType     coords);
285   gint           (* get_n_selections)             (AtkText          *text);
286   gchar*         (* get_selection)                (AtkText          *text,
287                                                    gint             selection_num,
288                                                    gint             *start_offset,
289                                                    gint             *end_offset);
290   gboolean       (* add_selection)                (AtkText          *text,
291                                                    gint             start_offset,
292                                                    gint             end_offset);
293   gboolean       (* remove_selection)             (AtkText          *text,
294                                                    gint             selection_num);
295   gboolean       (* set_selection)                (AtkText          *text,
296                                                    gint             selection_num,
297                                                    gint             start_offset,
298                                                    gint             end_offset);
299   gboolean       (* set_caret_offset)             (AtkText          *text,
300                                                    gint             offset);
301
302   /*
303    * signal handlers
304    */
305   void           (* text_changed)                 (AtkText          *text,
306                                                    gint             position,
307                                                    gint             length);
308   void           (* text_caret_moved)             (AtkText          *text,
309                                                    gint             location);
310   void           (* text_selection_changed)       (AtkText          *text);
311
312   void           (* text_attributes_changed)      (AtkText          *text);
313
314
315   void           (* get_range_extents)            (AtkText          *text,
316                                                    gint             start_offset,
317                                                    gint             end_offset,
318                                                    AtkCoordType     coord_type,
319                                                    AtkTextRectangle *rect);
320
321   AtkTextRange** (* get_bounded_ranges)           (AtkText          *text,
322                                                    AtkTextRectangle *rect,
323                                                    AtkCoordType     coord_type,
324                                                    AtkTextClipType  x_clip_type,
325                                                    AtkTextClipType  y_clip_type);
326
327   gchar*         (* get_string_at_offset)         (AtkText            *text,
328                                                    gint               offset,
329                                                    AtkTextGranularity granularity,
330                                                    gint               *start_offset,
331                                                    gint               *end_offset);
332 };
333
334 GType            atk_text_get_type (void);
335
336
337 /*
338  * Additional AtkObject properties used by AtkText:
339  *    "accessible_text" (accessible text has changed)
340  *    "accessible_caret" (accessible text cursor position changed:
341  *                         editable text only)
342  */
343
344 gchar*        atk_text_get_text                           (AtkText          *text,
345                                                            gint             start_offset,
346                                                            gint             end_offset);
347 gunichar      atk_text_get_character_at_offset            (AtkText          *text,
348                                                            gint             offset);
349 G_DEPRECATED_FOR(atk_text_get_string_at_offset)
350 gchar*        atk_text_get_text_after_offset              (AtkText          *text,
351                                                            gint             offset,
352                                                            AtkTextBoundary  boundary_type,
353                                                            gint             *start_offset,
354                                                            gint             *end_offset);
355 G_DEPRECATED_FOR(atk_text_get_string_at_offset)
356 gchar*        atk_text_get_text_at_offset                 (AtkText          *text,
357                                                            gint             offset,
358                                                            AtkTextBoundary  boundary_type,
359                                                            gint             *start_offset,
360                                                            gint             *end_offset);
361 G_DEPRECATED_FOR(atk_text_get_string_at_offset)
362 gchar*        atk_text_get_text_before_offset             (AtkText          *text,
363                                                            gint             offset,
364                                                            AtkTextBoundary  boundary_type,
365                                                            gint             *start_offset,
366                                                            gint             *end_offset);
367 gchar*        atk_text_get_string_at_offset               (AtkText            *text,
368                                                            gint               offset,
369                                                            AtkTextGranularity granularity,
370                                                            gint               *start_offset,
371                                                            gint               *end_offset);
372 gint          atk_text_get_caret_offset                   (AtkText          *text);
373 void          atk_text_get_character_extents              (AtkText          *text,
374                                                            gint             offset,
375                                                            gint             *x,
376                                                            gint             *y,
377                                                            gint             *width,
378                                                            gint             *height,
379                                                            AtkCoordType     coords);
380 AtkAttributeSet* atk_text_get_run_attributes              (AtkText          *text,
381                                                            gint             offset,
382                                                            gint             *start_offset,
383                                                            gint             *end_offset);
384 AtkAttributeSet* atk_text_get_default_attributes          (AtkText          *text);
385 gint          atk_text_get_character_count                (AtkText          *text);
386 gint          atk_text_get_offset_at_point                (AtkText          *text,
387                                                            gint             x,
388                                                            gint             y,
389                                                            AtkCoordType     coords);
390 gint          atk_text_get_n_selections                   (AtkText          *text);
391 gchar*        atk_text_get_selection                      (AtkText          *text,
392                                                            gint             selection_num,
393                                                            gint             *start_offset,
394                                                            gint             *end_offset);
395 gboolean      atk_text_add_selection                      (AtkText          *text,
396                                                            gint             start_offset,
397                                                            gint             end_offset);
398 gboolean      atk_text_remove_selection                   (AtkText          *text,
399                                                            gint             selection_num);
400 gboolean      atk_text_set_selection                      (AtkText          *text,
401                                                            gint             selection_num,
402                                                            gint             start_offset,
403                                                            gint             end_offset);
404 gboolean      atk_text_set_caret_offset                   (AtkText          *text,
405                                                            gint             offset);
406 void          atk_text_get_range_extents                  (AtkText          *text,
407
408                                                            gint             start_offset,
409                                                            gint             end_offset,
410                                                            AtkCoordType     coord_type,
411                                                            AtkTextRectangle *rect);
412 AtkTextRange**  atk_text_get_bounded_ranges               (AtkText          *text,
413                                                            AtkTextRectangle *rect,
414                                                            AtkCoordType     coord_type,
415                                                            AtkTextClipType  x_clip_type,
416                                                            AtkTextClipType  y_clip_type);
417 void          atk_text_free_ranges                        (AtkTextRange     **ranges);
418 void          atk_attribute_set_free                      (AtkAttributeSet  *attrib_set);
419 const gchar*  atk_text_attribute_get_name                 (AtkTextAttribute attr);
420 AtkTextAttribute       atk_text_attribute_for_name        (const gchar      *name);
421 const gchar*  atk_text_attribute_get_value                (AtkTextAttribute attr,
422                                                            gint             index_);
423
424 G_END_DECLS
425
426 #endif /* __ATK_TEXT_H__ */