Added new logic for handling multiple select regions to atktext.[ch].
[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
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 #define ATK_TYPE_TEXT                    (atk_text_get_type ())
33 #define ATK_IS_TEXT(obj)                 G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TEXT)
34 #define ATK_TEXT(obj)                    G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TEXT, AtkText)
35 #define ATK_TEXT_GET_IFACE(obj)          (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TEXT, AtkTextIface))
36
37 #ifndef _TYPEDEF_ATK_TEXT_
38 #define _TYPEDEF_ATK_TEXT_
39 typedef struct _AtkText AtkText;
40 #endif
41 typedef struct _AtkTextIface AtkTextIface;
42
43 /**
44  *AtkTextBoundary:
45  *@ATK_TEXT_BOUNDARY_CHAR:
46  *@ATK_TEXT_BOUNDARY_CURSOR_POS:
47  *@ATK_TEXT_BOUNDARY_WORD_START:
48  *@ATK_TEXT_BOUNDARY_WORD_END:
49  *@ATK_TEXT_BOUNDARY_SENTENCE_START:
50  *@ATK_TEXT_BOUNDARY_SENTENCE_END:
51  *@ATK_TEXT_BOUNDARY_LINE_START:
52  *@ATK_TEXT_BOUNDARY_LINE_END:
53  *
54  *Text boundary types used for specifying boundaries for regions of text
55  **/
56 typedef enum {
57   ATK_TEXT_BOUNDARY_CHAR,
58   ATK_TEXT_BOUNDARY_CURSOR_POS,
59   ATK_TEXT_BOUNDARY_WORD_START,
60   ATK_TEXT_BOUNDARY_WORD_END,
61   ATK_TEXT_BOUNDARY_SENTENCE_START,
62   ATK_TEXT_BOUNDARY_SENTENCE_END,
63   ATK_TEXT_BOUNDARY_LINE_START,
64   ATK_TEXT_BOUNDARY_LINE_END
65 } AtkTextBoundary;
66
67 struct _AtkTextIface
68 {
69   GTypeInterface parent;
70
71   gchar*         (* get_text)                     (AtkText          *text,
72                                                    gint             start_offset,
73                                                    gint             end_offset);
74   gchar*         (* get_text_after_offset)        (AtkText          *text,
75                                                    gint             offset,
76                                                    AtkTextBoundary  boundary_type);
77   gchar*         (* get_text_at_offset)           (AtkText          *text,
78                                                    gint             offset,
79                                                    AtkTextBoundary  boundary_type);
80   gunichar       (* get_character_at_offset)      (AtkText          *text,
81                                                    gint             offset);
82   gchar*         (* get_text_before_offset)       (AtkText          *text,
83                                                    gint             offset,
84                                                    AtkTextBoundary  boundary_type);
85   gint           (* get_caret_offset)             (AtkText          *text);
86   void           (* get_row_col_at_offset)        (AtkText          *text,
87                                                    gint             offset,
88                                                    gint             *row,
89                                                    gint             *col);
90   PangoAttrList* (* get_range_attributes)         (AtkText          *text,
91                                                    gint             start_offset,
92                                                    gint             end_offset);
93   void           (* get_character_extents)        (AtkText          *text,
94                                                    gint             offset,
95                                                    gint             *x,
96                                                    gint             *y,
97                                                    gint             *length,
98                                                    gint             *width);
99   gint           (* get_character_count)          (AtkText          *text);
100   gint           (* get_offset_at_point)          (AtkText          *text,
101                                                    gint             x,
102                                                    gint             y);
103   gint           (* get_n_selections)             (AtkText          *text);
104   gchar*         (* get_selection)                (AtkText          *text,
105                                                    gint             selection_num,
106                                                    gint             *start_offset,
107                                                    gint             *end_offset);
108   gboolean       (* add_selection)                (AtkText          *text,
109                                                    gint             start_offset,
110                                                    gint             end_offset);
111   gboolean       (* remove_selection)             (AtkText          *text,
112                                                    gint             selection_num);
113   gboolean       (* set_selection)                (AtkText          *text,
114                                                    gint             selection_num,
115                                                    gint             start_offset,
116                                                    gint             end_offset);
117   gboolean       (* set_caret_offset)             (AtkText          *text,
118                                                    gint             offset);
119   void           (* text_changed)                 (AtkText          *text);
120   void           (* caret_changed)                (AtkText          *text,
121                                                    gint             location);
122 };
123 GType            atk_text_get_type (void);
124
125
126 /*
127  * Additional AtkObject properties used by AtkText:
128  *    "accessible_text" (accessible text has changed)
129  *    "accessible_caret" (accessible text cursor position changed:
130  *                         editable text only)
131  */
132
133 gchar*        atk_text_get_text                           (AtkText          *text,
134                                                            gint             start_offset,
135                                                            gint             end_offset);
136 gunichar      atk_text_get_character_at_offset            (AtkText          *text,
137                                                            gint             offset);
138 gchar*        atk_text_get_text_after_offset              (AtkText          *text,
139                                                            gint             offset,
140                                                            AtkTextBoundary  boundary_type);
141 gchar*        atk_text_get_text_at_offset                 (AtkText          *text,
142                                                            gint             offset,
143                                                            AtkTextBoundary  boundary_type);
144 gchar*        atk_text_get_text_before_offset             (AtkText          *text,
145                                                            gint             offset,
146                                                            AtkTextBoundary  boundary_type);
147 gint          atk_text_get_caret_offset                   (AtkText          *text);
148 void          atk_text_get_row_col_at_offset              (AtkText          *text,
149                                                            gint             offset,
150                                                            gint             *row,
151                                                            gint             *col);
152 PangoAttrList* atk_text_get_range_attributes              (AtkText          *text,
153                                                            gint             start_offset,
154                                                            gint             end_offset);
155 void          atk_text_get_character_extents              (AtkText          *text,
156                                                            gint             offset,
157                                                            gint             *x,
158                                                            gint             *y,
159                                                            gint             *length,
160                                                            gint             *width);
161 gint          atk_text_get_character_count                (AtkText          *text);
162 gint          atk_text_get_offset_at_point                (AtkText          *text,
163                                                            gint             x,
164                                                            gint             y);
165 gint          atk_text_get_n_selections                   (AtkText          *text);
166 gchar*        atk_text_get_selection                      (AtkText          *text,
167                                                            gint             selection_num,
168                                                            gint             *start_offset,
169                                                            gint             *end_offset);
170 gboolean      atk_text_add_selection                      (AtkText          *text,
171                                                            gint             start_offset,
172                                                            gint             end_offset);
173 gboolean      atk_text_remove_selection                   (AtkText          *text,
174                                                            gint             selection_num);
175 gboolean      atk_text_set_selection                      (AtkText          *text,
176                                                            gint             selection_num,
177                                                            gint             start_offset,
178                                                            gint             end_offset);
179 gboolean      atk_text_set_caret_offset                   (AtkText          *text,
180                                                            gint             offset);
181
182 #ifdef __cplusplus
183 }
184 #endif /* __cplusplus */
185
186
187 #endif /* __ATK_TEXT_H__ */