Deprecate 'text-changed' signal
[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 #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
23
24 #ifndef __ATK_TEXT_H__
25 #define __ATK_TEXT_H__
26
27 #include <glib-object.h>
28 #include <atk/atkobject.h>
29 #include <atk/atkutil.h>
30
31 G_BEGIN_DECLS
32
33 /**
34  *AtkTextAttribute:
35  *@ATK_TEXT_ATTR_INVALID: Invalid attribute
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. 
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
64  *
65  * Describes the text attributes supported
66  **/
67 typedef enum
68 {
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;
99
100 AtkTextAttribute         atk_text_attribute_register   (const gchar *name);
101
102
103 #define ATK_TYPE_TEXT                    (atk_text_get_type ())
104 #define ATK_IS_TEXT(obj)                 G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TEXT)
105 #define ATK_TEXT(obj)                    G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TEXT, AtkText)
106 #define ATK_TEXT_GET_IFACE(obj)          (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TEXT, AtkTextIface))
107
108 #ifndef _TYPEDEF_ATK_TEXT_
109 #define _TYPEDEF_ATK_TEXT_
110 typedef struct _AtkText AtkText;
111 #endif
112 typedef struct _AtkTextIface AtkTextIface;
113
114
115 /**
116  *AtkTextBoundary:
117  *@ATK_TEXT_BOUNDARY_CHAR: Boundary is the boundary between characters
118  * (including non-printing characters)
119  *@ATK_TEXT_BOUNDARY_WORD_START: Boundary is the start (i.e. first character) of a word.
120  *@ATK_TEXT_BOUNDARY_WORD_END: Boundary is the end (i.e. last
121  * character) of a word. This boundary is deprecated, and should not be
122  * used.
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. This boundary is
128  * deprecated, and should not be used.
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. This boundary is deprecated, and should not be used.
133  *
134  * Text boundary types used for specifying boundaries for regions of
135  * text. Note that some boundaries are deprecated since 2.9.3., not
136  * marked explicitly due to the lack of a formal method to mark as
137  * deprecated some elements from a enum.
138  *
139  *
140  **/
141 typedef enum {
142   ATK_TEXT_BOUNDARY_CHAR,
143   ATK_TEXT_BOUNDARY_WORD_START,
144   ATK_TEXT_BOUNDARY_WORD_END,
145   ATK_TEXT_BOUNDARY_SENTENCE_START,
146   ATK_TEXT_BOUNDARY_SENTENCE_END,
147   ATK_TEXT_BOUNDARY_LINE_START,
148   ATK_TEXT_BOUNDARY_LINE_END
149 } AtkTextBoundary;
150
151 /**
152  * AtkTextRectangle:
153  * @x: The horizontal coordinate of a rectangle
154  * @y: The vertical coordinate of a rectangle
155  * @width: The width of a rectangle
156  * @height: The height of a rectangle
157  *
158  * A structure used to store a rectangle used by AtkText.
159  **/
160
161 typedef struct _AtkTextRectangle AtkTextRectangle;
162
163 struct _AtkTextRectangle {
164   gint x;
165   gint y;
166   gint width;
167   gint height;
168 };
169
170 /**
171  * AtkTextRange:
172  * @bounds: A rectangle giving the bounds of the text range
173  * @start_offset: The start offset of a AtkTextRange
174  * @end_offset: The end offset of a AtkTextRange
175  * @content: The text in the text range
176  *
177  * A structure used to describe a text range.
178  **/
179 typedef struct _AtkTextRange AtkTextRange;
180
181 struct _AtkTextRange {
182   AtkTextRectangle bounds;
183   gint start_offset;
184   gint end_offset;
185   gchar* content;
186 };
187
188 GType atk_text_range_get_type (void);
189
190 /**
191  *AtkTextClipType:
192  *@ATK_TEXT_CLIP_NONE: No clipping to be done
193  *@ATK_TEXT_CLIP_MIN: Text clipped by min coordinate is omitted
194  *@ATK_TEXT_CLIP_MAX: Text clipped by max coordinate is omitted
195  *@ATK_TEXT_CLIP_BOTH: Only text fully within mix/max bound is retained
196  *
197  *Describes the type of clipping required.
198  **/
199 typedef enum {
200     ATK_TEXT_CLIP_NONE,
201     ATK_TEXT_CLIP_MIN,
202     ATK_TEXT_CLIP_MAX,
203     ATK_TEXT_CLIP_BOTH
204 } AtkTextClipType;
205
206 /**
207  * AtkTextIface:
208  * @get_text_after_offset: Gets specified text. This virtual function
209  *   is deprecated and it should not be overridden.
210  * @get_text_before_offset: Gets specified text. This virtual function
211  *   is deprecated and it should not be overridden.
212  * @text_changed: the signal handler which is executed when there is a
213  *   text change. This virtual function is deprecated sice 2.9.4 and
214  *   it should not be overriden.
215  */
216 struct _AtkTextIface
217 {
218   GTypeInterface parent;
219
220   gchar*         (* get_text)                     (AtkText          *text,
221                                                    gint             start_offset,
222                                                    gint             end_offset);
223   gchar*         (* get_text_after_offset)        (AtkText          *text,
224                                                    gint             offset,
225                                                    AtkTextBoundary  boundary_type,
226                                                    gint             *start_offset,
227                                                    gint             *end_offset);
228   gchar*         (* get_text_at_offset)           (AtkText          *text,
229                                                    gint             offset,
230                                                    AtkTextBoundary  boundary_type,
231                                                    gint             *start_offset,
232                                                    gint             *end_offset);
233   gunichar       (* get_character_at_offset)      (AtkText          *text,
234                                                    gint             offset);
235   gchar*         (* get_text_before_offset)       (AtkText          *text,
236                                                    gint             offset,
237                                                    AtkTextBoundary  boundary_type,
238                                                    gint             *start_offset,
239                                                    gint             *end_offset);
240   gint           (* get_caret_offset)             (AtkText          *text);
241   AtkAttributeSet* (* get_run_attributes)         (AtkText          *text,
242                                                    gint             offset,
243                                                    gint             *start_offset,
244                                                    gint             *end_offset);
245   AtkAttributeSet* (* get_default_attributes)     (AtkText          *text);
246   void           (* get_character_extents)        (AtkText          *text,
247                                                    gint             offset,
248                                                    gint             *x,
249                                                    gint             *y,
250                                                    gint             *width,
251                                                    gint             *height,
252                                                    AtkCoordType     coords);
253   gint           (* get_character_count)          (AtkText          *text);
254   gint           (* get_offset_at_point)          (AtkText          *text,
255                                                    gint             x,
256                                                    gint             y,
257                                                    AtkCoordType     coords);
258   gint           (* get_n_selections)             (AtkText          *text);
259   gchar*         (* get_selection)                (AtkText          *text,
260                                                    gint             selection_num,
261                                                    gint             *start_offset,
262                                                    gint             *end_offset);
263   gboolean       (* add_selection)                (AtkText          *text,
264                                                    gint             start_offset,
265                                                    gint             end_offset);
266   gboolean       (* remove_selection)             (AtkText          *text,
267                                                    gint             selection_num);
268   gboolean       (* set_selection)                (AtkText          *text,
269                                                    gint             selection_num,
270                                                    gint             start_offset,
271                                                    gint             end_offset);
272   gboolean       (* set_caret_offset)             (AtkText          *text,
273                                                    gint             offset);
274
275   /*
276    * signal handlers
277    */
278   void           (* text_changed)                 (AtkText          *text,
279                                                    gint             position,
280                                                    gint             length);
281   void           (* text_caret_moved)             (AtkText          *text,
282                                                    gint             location);
283   void           (* text_selection_changed)       (AtkText          *text);
284
285   void           (* text_attributes_changed)      (AtkText          *text);
286
287
288   void           (* get_range_extents)            (AtkText          *text,
289                                                    gint             start_offset,
290                                                    gint             end_offset,
291                                                    AtkCoordType     coord_type,
292                                                    AtkTextRectangle *rect);
293
294   AtkTextRange** (* get_bounded_ranges)           (AtkText          *text,
295                                                    AtkTextRectangle *rect,
296                                                    AtkCoordType     coord_type,
297                                                    AtkTextClipType  x_clip_type,
298                                                    AtkTextClipType  y_clip_type);
299 };
300
301 GType            atk_text_get_type (void);
302
303
304 /*
305  * Additional AtkObject properties used by AtkText:
306  *    "accessible_text" (accessible text has changed)
307  *    "accessible_caret" (accessible text cursor position changed:
308  *                         editable text only)
309  */
310
311 gchar*        atk_text_get_text                           (AtkText          *text,
312                                                            gint             start_offset,
313                                                            gint             end_offset);
314 gunichar      atk_text_get_character_at_offset            (AtkText          *text,
315                                                            gint             offset);
316 G_DEPRECATED_FOR(atk_text_get_text_at_offset)
317 gchar*        atk_text_get_text_after_offset              (AtkText          *text,
318                                                            gint             offset,
319                                                            AtkTextBoundary  boundary_type,
320                                                            gint             *start_offset,
321                                                            gint             *end_offset);
322 gchar*        atk_text_get_text_at_offset                 (AtkText          *text,
323                                                            gint             offset,
324                                                            AtkTextBoundary  boundary_type,
325                                                            gint             *start_offset,
326                                                            gint             *end_offset);
327 G_DEPRECATED_FOR(atk_text_get_text_at_offset)
328 gchar*        atk_text_get_text_before_offset             (AtkText          *text,
329                                                            gint             offset,
330                                                            AtkTextBoundary  boundary_type,
331                                                            gint             *start_offset,
332                                                            gint             *end_offset);
333 gint          atk_text_get_caret_offset                   (AtkText          *text);
334 void          atk_text_get_character_extents              (AtkText          *text,
335                                                            gint             offset,
336                                                            gint             *x,
337                                                            gint             *y,
338                                                            gint             *width,
339                                                            gint             *height,
340                                                            AtkCoordType     coords);
341 AtkAttributeSet* atk_text_get_run_attributes              (AtkText          *text,
342                                                            gint             offset,
343                                                            gint             *start_offset,
344                                                            gint             *end_offset);
345 AtkAttributeSet* atk_text_get_default_attributes          (AtkText          *text);
346 gint          atk_text_get_character_count                (AtkText          *text);
347 gint          atk_text_get_offset_at_point                (AtkText          *text,
348                                                            gint             x,
349                                                            gint             y,
350                                                            AtkCoordType     coords);
351 gint          atk_text_get_n_selections                   (AtkText          *text);
352 gchar*        atk_text_get_selection                      (AtkText          *text,
353                                                            gint             selection_num,
354                                                            gint             *start_offset,
355                                                            gint             *end_offset);
356 gboolean      atk_text_add_selection                      (AtkText          *text,
357                                                            gint             start_offset,
358                                                            gint             end_offset);
359 gboolean      atk_text_remove_selection                   (AtkText          *text,
360                                                            gint             selection_num);
361 gboolean      atk_text_set_selection                      (AtkText          *text,
362                                                            gint             selection_num,
363                                                            gint             start_offset,
364                                                            gint             end_offset);
365 gboolean      atk_text_set_caret_offset                   (AtkText          *text,
366                                                            gint             offset);
367 void          atk_text_get_range_extents                  (AtkText          *text,
368
369                                                            gint             start_offset,
370                                                            gint             end_offset,
371                                                            AtkCoordType     coord_type,
372                                                            AtkTextRectangle *rect);
373 AtkTextRange**  atk_text_get_bounded_ranges               (AtkText          *text,
374                                                            AtkTextRectangle *rect,
375                                                            AtkCoordType     coord_type,
376                                                            AtkTextClipType  x_clip_type,
377                                                            AtkTextClipType  y_clip_type);
378 void          atk_text_free_ranges                        (AtkTextRange     **ranges);
379 void          atk_attribute_set_free                      (AtkAttributeSet  *attrib_set);
380 const gchar*  atk_text_attribute_get_name                 (AtkTextAttribute attr);
381 AtkTextAttribute       atk_text_attribute_for_name        (const gchar      *name);
382 const gchar*  atk_text_attribute_get_value                (AtkTextAttribute attr,
383                                                            gint             index_);
384
385 G_END_DECLS
386
387 #endif /* __ATK_TEXT_H__ */