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