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