Updated so that functions that take screen coords as
[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 <pango/pango.h>
25 #include <glib-object.h>
26 #include <atk/atkobject.h>
27 #include <atk/atkutil.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33 typedef GSList AtkAttributeSet;
34
35 typedef struct _AtkAttribute {
36   gchar* name;
37   gchar* value;
38 }AtkAttribute;
39
40 #define ATK_TYPE_TEXT                    (atk_text_get_type ())
41 #define ATK_IS_TEXT(obj)                 G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TEXT)
42 #define ATK_TEXT(obj)                    G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TEXT, AtkText)
43 #define ATK_TEXT_GET_IFACE(obj)          (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TEXT, AtkTextIface))
44
45 #ifndef _TYPEDEF_ATK_TEXT_
46 #define _TYPEDEF_ATK_TEXT_
47 typedef struct _AtkText AtkText;
48 #endif
49 typedef struct _AtkTextIface AtkTextIface;
50
51 /**
52  *AtkTextBoundary:
53  *@ATK_TEXT_BOUNDARY_CHAR:
54  *@ATK_TEXT_BOUNDARY_WORD_START:
55  *@ATK_TEXT_BOUNDARY_WORD_END:
56  *@ATK_TEXT_BOUNDARY_SENTENCE_START:
57  *@ATK_TEXT_BOUNDARY_SENTENCE_END:
58  *@ATK_TEXT_BOUNDARY_LINE_START:
59  *@ATK_TEXT_BOUNDARY_LINE_END:
60  *
61  *Text boundary types used for specifying boundaries for regions of text
62  **/
63 typedef enum {
64   ATK_TEXT_BOUNDARY_CHAR,
65   ATK_TEXT_BOUNDARY_WORD_START,
66   ATK_TEXT_BOUNDARY_WORD_END,
67   ATK_TEXT_BOUNDARY_SENTENCE_START,
68   ATK_TEXT_BOUNDARY_SENTENCE_END,
69   ATK_TEXT_BOUNDARY_LINE_START,
70   ATK_TEXT_BOUNDARY_LINE_END
71 } AtkTextBoundary;
72
73 struct _AtkTextIface
74 {
75   GTypeInterface parent;
76
77   gchar*         (* get_text)                     (AtkText          *text,
78                                                    gint             start_offset,
79                                                    gint             end_offset);
80   gchar*         (* get_text_after_offset)        (AtkText          *text,
81                                                    gint             offset,
82                                                    AtkTextBoundary  boundary_type,
83                                                    gint             *startOffset,
84                                                    gint             *endOffset);
85   gchar*         (* get_text_at_offset)           (AtkText          *text,
86                                                    gint             offset,
87                                                    AtkTextBoundary  boundary_type,
88                                                    gint             *startOffset,
89                                                    gint             *endOffset);
90   gunichar       (* get_character_at_offset)      (AtkText          *text,
91                                                    gint             offset);
92   gchar*         (* get_text_before_offset)       (AtkText          *text,
93                                                    gint             offset,
94                                                    AtkTextBoundary  boundary_type,
95                                                    gint             *startOffset,
96                                                    gint             *endOffset);
97   gint           (* get_caret_offset)             (AtkText          *text);
98   AtkAttributeSet* (* ref_run_attributes)         (AtkText          *text,
99                                                    gint             offset,
100                                                    gint             *start_offset,
101                                                    gint             *end_offset);
102   void           (* get_character_extents)        (AtkText          *text,
103                                                    gint             offset,
104                                                    gint             *x,
105                                                    gint             *y,
106                                                    gint             *length,
107                                                    gint             *width,
108                                                    AtkCoordType     coords);
109   gint           (* get_character_count)          (AtkText          *text);
110   gint           (* get_offset_at_point)          (AtkText          *text,
111                                                    gint             x,
112                                                    gint             y,
113                                                    AtkCoordType     coords);
114   gint           (* get_n_selections)             (AtkText          *text);
115   gchar*         (* get_selection)                (AtkText          *text,
116                                                    gint             selection_num,
117                                                    gint             *start_offset,
118                                                    gint             *end_offset);
119   gboolean       (* add_selection)                (AtkText          *text,
120                                                    gint             start_offset,
121                                                    gint             end_offset);
122   gboolean       (* remove_selection)             (AtkText          *text,
123                                                    gint             selection_num);
124   gboolean       (* set_selection)                (AtkText          *text,
125                                                    gint             selection_num,
126                                                    gint             start_offset,
127                                                    gint             end_offset);
128   gboolean       (* set_caret_offset)             (AtkText          *text,
129                                                    gint             offset);
130
131   /*
132    * signal handlers
133    */
134   void           (* text_changed)                 (AtkText          *text);
135   void           (* caret_changed)                (AtkText          *text,
136                                                    gint             location);
137 };
138
139 GType            atk_text_get_type (void);
140
141
142 /*
143  * Additional AtkObject properties used by AtkText:
144  *    "accessible_text" (accessible text has changed)
145  *    "accessible_caret" (accessible text cursor position changed:
146  *                         editable text only)
147  */
148
149 gchar*        atk_text_get_text                           (AtkText          *text,
150                                                            gint             start_offset,
151                                                            gint             end_offset);
152 gunichar      atk_text_get_character_at_offset            (AtkText          *text,
153                                                            gint             offset);
154 gchar*        atk_text_get_text_after_offset              (AtkText          *text,
155                                                            gint             offset,
156                                                            AtkTextBoundary  boundary_type,
157                                                            gint             *startOffset,
158                                                            gint             *endOffset);
159 gchar*        atk_text_get_text_at_offset                 (AtkText          *text,
160                                                            gint             offset,
161                                                            AtkTextBoundary  boundary_type,
162                                                            gint             *startOffset,
163                                                            gint             *endOffset);
164 gchar*        atk_text_get_text_before_offset             (AtkText          *text,
165                                                            gint             offset,
166                                                            AtkTextBoundary  boundary_type,
167                                                            gint             *startOffset,
168                                                            gint             *endOffset);
169 gint          atk_text_get_caret_offset                   (AtkText          *text);
170 void          atk_text_get_character_extents              (AtkText          *text,
171                                                            gint             offset,
172                                                            gint             *x,
173                                                            gint             *y,
174                                                            gint             *length,
175                                                            gint             *width,
176                                                            AtkCoordType     coords);
177 AtkAttributeSet* atk_text_ref_run_attributes              (AtkText          *text,
178                                                            gint             offset,
179                                                            gint             *start_offset,
180                                                            gint             *end_offset);
181 gint          atk_text_get_character_count                (AtkText          *text);
182 gint          atk_text_get_offset_at_point                (AtkText          *text,
183                                                            gint             x,
184                                                            gint             y,
185                                                            AtkCoordType     coords);
186 gint          atk_text_get_n_selections                   (AtkText          *text);
187 gchar*        atk_text_get_selection                      (AtkText          *text,
188                                                            gint             selection_num,
189                                                            gint             *start_offset,
190                                                            gint             *end_offset);
191 gboolean      atk_text_add_selection                      (AtkText          *text,
192                                                            gint             start_offset,
193                                                            gint             end_offset);
194 gboolean      atk_text_remove_selection                   (AtkText          *text,
195                                                            gint             selection_num);
196 gboolean      atk_text_set_selection                      (AtkText          *text,
197                                                            gint             selection_num,
198                                                            gint             start_offset,
199                                                            gint             end_offset);
200 gboolean      atk_text_set_caret_offset                   (AtkText          *text,
201                                                            gint             offset);
202 void          AtkAttributeSet_free                        (AtkAttributeSet  *attrib_set);
203
204 #ifdef __cplusplus
205 }
206 #endif /* __cplusplus */
207
208
209 #endif /* __ATK_TEXT_H__ */