1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module atk.TextIF;
26 
27 private import glib.Str;
28 private import gobject.Signals;
29 private import gtkc.atk;
30 public  import gtkc.atktypes;
31 public  import gtkc.gdktypes;
32 
33 
34 /**
35  * #AtkText should be implemented by #AtkObjects on behalf of widgets
36  * that have text content which is either attributed or otherwise
37  * non-trivial.  #AtkObjects whose text content is simple,
38  * unattributed, and very brief may expose that content via
39  * #atk_object_get_name instead; however if the text is editable,
40  * multi-line, typically longer than three or four words, attributed,
41  * selectable, or if the object already uses the 'name' ATK property
42  * for other information, the #AtkText interface should be used to
43  * expose the text content.  In the case of editable text content,
44  * #AtkEditableText (a subtype of the #AtkText interface) should be
45  * implemented instead.
46  * 
47  * #AtkText provides not only traversal facilities and change
48  * notification for text content, but also caret tracking and glyph
49  * bounding box calculations.  Note that the text strings are exposed
50  * as UTF-8, and are therefore potentially multi-byte, and
51  * caret-to-byte offset mapping makes no assumptions about the
52  * character length; also bounding box glyph-to-offset mapping may be
53  * complex for languages which use ligatures.
54  */
55 public interface TextIF{
56 	/** Get the main Gtk struct */
57 	public AtkText* getTextStruct();
58 
59 	/** the main Gtk struct as a void* */
60 	protected void* getStruct();
61 
62 	/**
63 	 */
64 
65 	/**
66 	 * Frees the memory associated with an array of AtkTextRange. It is assumed
67 	 * that the array was returned by the function atk_text_get_bounded_ranges
68 	 * and is NULL terminated.
69 	 *
70 	 * Params:
71 	 *     ranges = A pointer to an array of #AtkTextRange which is
72 	 *         to be freed.
73 	 *
74 	 * Since: 1.3
75 	 */
76 	public static void freeRanges(AtkTextRange*[] ranges);
77 
78 	/**
79 	 * Adds a selection bounded by the specified offsets.
80 	 *
81 	 * Params:
82 	 *     startOffset = the start position of the selected region
83 	 *     endOffset = the offset of the first character after the selected region.
84 	 *
85 	 * Return: %TRUE if success, %FALSE otherwise
86 	 */
87 	public bool addSelection(int startOffset, int endOffset);
88 
89 	/**
90 	 * Get the ranges of text in the specified bounding box.
91 	 *
92 	 * Params:
93 	 *     rect = An AtkTextRectangle giving the dimensions of the bounding box.
94 	 *     coordType = Specify whether coordinates are relative to the screen or widget window.
95 	 *     xClipType = Specify the horizontal clip type.
96 	 *     yClipType = Specify the vertical clip type.
97 	 *
98 	 * Return: Array of AtkTextRange. The last
99 	 *     element of the array returned by this function will be NULL.
100 	 *
101 	 * Since: 1.3
102 	 */
103 	public AtkTextRange*[] getBoundedRanges(AtkTextRectangle* rect, AtkCoordType coordType, AtkTextClipType xClipType, AtkTextClipType yClipType);
104 
105 	/**
106 	 * Gets the offset position of the caret (cursor).
107 	 *
108 	 * Return: the offset position of the caret (cursor).
109 	 */
110 	public int getCaretOffset();
111 
112 	/**
113 	 * Gets the specified text.
114 	 *
115 	 * Params:
116 	 *     offset = position
117 	 *
118 	 * Return: the character at @offset.
119 	 */
120 	public dchar getCharacterAtOffset(int offset);
121 
122 	/**
123 	 * Gets the character count.
124 	 *
125 	 * Return: the number of characters.
126 	 */
127 	public int getCharacterCount();
128 
129 	/**
130 	 * Get the bounding box containing the glyph representing the character at
131 	 * a particular text offset.
132 	 *
133 	 * Params:
134 	 *     offset = The offset of the text character for which bounding information is required.
135 	 *     x = Pointer for the x cordinate of the bounding box
136 	 *     y = Pointer for the y cordinate of the bounding box
137 	 *     width = Pointer for the width of the bounding box
138 	 *     height = Pointer for the height of the bounding box
139 	 *     coords = specify whether coordinates are relative to the screen or widget window
140 	 */
141 	public void getCharacterExtents(int offset, int* x, int* y, int* width, int* height, AtkCoordType coords);
142 
143 	/**
144 	 * Creates an #AtkAttributeSet which consists of the default values of
145 	 * attributes for the text. See the enum AtkTextAttribute for types of text
146 	 * attributes that can be returned. Note that other attributes may also be
147 	 * returned.
148 	 *
149 	 * Return: an #AtkAttributeSet which contains the default
150 	 *     values of attributes.  at @offset. this #atkattributeset should be freed by
151 	 *     a call to atk_attribute_set_free().
152 	 */
153 	public AtkAttributeSet* getDefaultAttributes();
154 
155 	/**
156 	 * Gets the number of selected regions.
157 	 *
158 	 * Return: The number of selected regions, or -1 if a failure
159 	 *     occurred.
160 	 */
161 	public int getNSelections();
162 
163 	/**
164 	 * Gets the offset of the character located at coordinates @x and @y. @x and @y
165 	 * are interpreted as being relative to the screen or this widget's window
166 	 * depending on @coords.
167 	 *
168 	 * Params:
169 	 *     x = screen x-position of character
170 	 *     y = screen y-position of character
171 	 *     coords = specify whether coordinates are relative to the screen or
172 	 *         widget window
173 	 *
174 	 * Return: the offset to the character which is located at
175 	 *     the specified @x and @y coordinates.
176 	 */
177 	public int getOffsetAtPoint(int x, int y, AtkCoordType coords);
178 
179 	/**
180 	 * Get the bounding box for text within the specified range.
181 	 *
182 	 * Params:
183 	 *     startOffset = The offset of the first text character for which boundary
184 	 *         information is required.
185 	 *     endOffset = The offset of the text character after the last character
186 	 *         for which boundary information is required.
187 	 *     coordType = Specify whether coordinates are relative to the screen or widget window.
188 	 *     rect = A pointer to a AtkTextRectangle which is filled in by this function.
189 	 *
190 	 * Since: 1.3
191 	 */
192 	public void getRangeExtents(int startOffset, int endOffset, AtkCoordType coordType, AtkTextRectangle* rect);
193 
194 	/**
195 	 * Creates an #AtkAttributeSet which consists of the attributes explicitly
196 	 * set at the position @offset in the text. @start_offset and @end_offset are
197 	 * set to the start and end of the range around @offset where the attributes are
198 	 * invariant. Note that @end_offset is the offset of the first character
199 	 * after the range.  See the enum AtkTextAttribute for types of text
200 	 * attributes that can be returned. Note that other attributes may also be
201 	 * returned.
202 	 *
203 	 * Params:
204 	 *     offset = the offset at which to get the attributes, -1 means the offset of
205 	 *         the character to be inserted at the caret location.
206 	 *     startOffset = the address to put the start offset of the range
207 	 *     endOffset = the address to put the end offset of the range
208 	 *
209 	 * Return: an #AtkAttributeSet which contains the attributes
210 	 *     explicitly set at @offset. This #AtkAttributeSet should be freed by a call
211 	 *     to atk_attribute_set_free().
212 	 */
213 	public AtkAttributeSet* getRunAttributes(int offset, out int startOffset, out int endOffset);
214 
215 	/**
216 	 * Gets the text from the specified selection.
217 	 *
218 	 * Params:
219 	 *     selectionNum = The selection number.  The selected regions are
220 	 *         assigned numbers that correspond to how far the region is from the
221 	 *         start of the text.  The selected region closest to the beginning
222 	 *         of the text region is assigned the number 0, etc.  Note that adding,
223 	 *         moving or deleting a selected region can change the numbering.
224 	 *     startOffset = passes back the start position of the selected region
225 	 *     endOffset = passes back the end position of (e.g. offset immediately past)
226 	 *         the selected region
227 	 *
228 	 * Return: a newly allocated string containing the selected text. Use g_free()
229 	 *     to free the returned string.
230 	 */
231 	public string getSelection(int selectionNum, out int startOffset, out int endOffset);
232 
233 	/**
234 	 * Gets a portion of the text exposed through an #AtkText according to a given @offset
235 	 * and a specific @granularity, along with the start and end offsets defining the
236 	 * boundaries of such a portion of text.
237 	 *
238 	 * If @granularity is ATK_TEXT_GRANULARITY_CHAR the character at the
239 	 * offset is returned.
240 	 *
241 	 * If @granularity is ATK_TEXT_GRANULARITY_WORD the returned string
242 	 * is from the word start at or before the offset to the word start after
243 	 * the offset.
244 	 *
245 	 * The returned string will contain the word at the offset if the offset
246 	 * is inside a word and will contain the word before the offset if the
247 	 * offset is not inside a word.
248 	 *
249 	 * If @granularity is ATK_TEXT_GRANULARITY_SENTENCE the returned string
250 	 * is from the sentence start at or before the offset to the sentence
251 	 * start after the offset.
252 	 *
253 	 * The returned string will contain the sentence at the offset if the offset
254 	 * is inside a sentence and will contain the sentence before the offset
255 	 * if the offset is not inside a sentence.
256 	 *
257 	 * If @granularity is ATK_TEXT_GRANULARITY_LINE the returned string
258 	 * is from the line start at or before the offset to the line
259 	 * start after the offset.
260 	 *
261 	 * If @granularity is ATK_TEXT_GRANULARITY_PARAGRAPH the returned string
262 	 * is from the start of the paragraph at or before the offset to the start
263 	 * of the following paragraph after the offset.
264 	 *
265 	 * Params:
266 	 *     offset = position
267 	 *     granularity = An #AtkTextGranularity
268 	 *     startOffset = the start offset of the returned string, or -1
269 	 *         if an error has occurred (e.g. invalid offset, not implemented)
270 	 *     endOffset = the offset of the first character after the returned string,
271 	 *         or -1 if an error has occurred (e.g. invalid offset, not implemented)
272 	 *
273 	 * Return: a newly allocated string containing the text
274 	 *     at the @offset bounded by the specified @granularity. Use
275 	 *     g_free() to free the returned string.  Returns %NULL if the
276 	 *     offset is invalid or no implementation is available.
277 	 *
278 	 * Since: 2.10
279 	 */
280 	public string getStringAtOffset(int offset, AtkTextGranularity granularity, out int startOffset, out int endOffset);
281 
282 	/**
283 	 * Gets the specified text.
284 	 *
285 	 * Params:
286 	 *     startOffset = start position
287 	 *     endOffset = end position, or -1 for the end of the string.
288 	 *
289 	 * Return: a newly allocated string containing the text from @start_offset up
290 	 *     to, but not including @end_offset. Use g_free() to free the returned string.
291 	 */
292 	public string getText(int startOffset, int endOffset);
293 
294 	/**
295 	 * Gets the specified text.
296 	 *
297 	 * Deprecated: Please use atk_text_get_string_at_offset() instead.
298 	 *
299 	 * Params:
300 	 *     offset = position
301 	 *     boundaryType = An #AtkTextBoundary
302 	 *     startOffset = the start offset of the returned string
303 	 *     endOffset = the offset of the first character after the
304 	 *         returned substring
305 	 *
306 	 * Return: a newly allocated string containing the text after @offset bounded
307 	 *     by the specified @boundary_type. Use g_free() to free the returned string.
308 	 */
309 	public string getTextAfterOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset);
310 
311 	/**
312 	 * Gets the specified text.
313 	 *
314 	 * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character at the
315 	 * offset is returned.
316 	 *
317 	 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string
318 	 * is from the word start at or before the offset to the word start after
319 	 * the offset.
320 	 *
321 	 * The returned string will contain the word at the offset if the offset
322 	 * is inside a word and will contain the word before the offset if the
323 	 * offset is not inside a word.
324 	 *
325 	 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned
326 	 * string is from the sentence start at or before the offset to the sentence
327 	 * start after the offset.
328 	 *
329 	 * The returned string will contain the sentence at the offset if the offset
330 	 * is inside a sentence and will contain the sentence before the offset
331 	 * if the offset is not inside a sentence.
332 	 *
333 	 * If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned
334 	 * string is from the line start at or before the offset to the line
335 	 * start after the offset.
336 	 *
337 	 * Deprecated: This method is deprecated since ATK version
338 	 * 2.9.4. Please use atk_text_get_string_at_offset() instead.
339 	 *
340 	 * Params:
341 	 *     offset = position
342 	 *     boundaryType = An #AtkTextBoundary
343 	 *     startOffset = the start offset of the returned string
344 	 *     endOffset = the offset of the first character after the
345 	 *         returned substring
346 	 *
347 	 * Return: a newly allocated string containing the text at @offset bounded by
348 	 *     the specified @boundary_type. Use g_free() to free the returned string.
349 	 */
350 	public string getTextAtOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset);
351 
352 	/**
353 	 * Gets the specified text.
354 	 *
355 	 * Deprecated: Please use atk_text_get_string_at_offset() instead.
356 	 *
357 	 * Params:
358 	 *     offset = position
359 	 *     boundaryType = An #AtkTextBoundary
360 	 *     startOffset = the start offset of the returned string
361 	 *     endOffset = the offset of the first character after the
362 	 *         returned substring
363 	 *
364 	 * Return: a newly allocated string containing the text before @offset bounded
365 	 *     by the specified @boundary_type. Use g_free() to free the returned string.
366 	 */
367 	public string getTextBeforeOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset);
368 
369 	/**
370 	 * Removes the specified selection.
371 	 *
372 	 * Params:
373 	 *     selectionNum = The selection number.  The selected regions are
374 	 *         assigned numbers that correspond to how far the region is from the
375 	 *         start of the text.  The selected region closest to the beginning
376 	 *         of the text region is assigned the number 0, etc.  Note that adding,
377 	 *         moving or deleting a selected region can change the numbering.
378 	 *
379 	 * Return: %TRUE if success, %FALSE otherwise
380 	 */
381 	public bool removeSelection(int selectionNum);
382 
383 	/**
384 	 * Sets the caret (cursor) position to the specified @offset.
385 	 *
386 	 * Params:
387 	 *     offset = position
388 	 *
389 	 * Return: %TRUE if success, %FALSE otherwise.
390 	 */
391 	public bool setCaretOffset(int offset);
392 
393 	/**
394 	 * Changes the start and end offset of the specified selection.
395 	 *
396 	 * Params:
397 	 *     selectionNum = The selection number.  The selected regions are
398 	 *         assigned numbers that correspond to how far the region is from the
399 	 *         start of the text.  The selected region closest to the beginning
400 	 *         of the text region is assigned the number 0, etc.  Note that adding,
401 	 *         moving or deleting a selected region can change the numbering.
402 	 *     startOffset = the new start position of the selection
403 	 *     endOffset = the new end position of (e.g. offset immediately past)
404 	 *         the selection
405 	 *
406 	 * Return: %TRUE if success, %FALSE otherwise
407 	 */
408 	public bool setSelection(int selectionNum, int startOffset, int endOffset);
409 	@property void delegate(TextIF)[] onTextAttributesChangedListeners();
410 	/**
411 	 * The "text-attributes-changed" signal is emitted when the text
412 	 * attributes of the text of an object which implements AtkText
413 	 * changes.
414 	 */
415 	void addOnTextAttributesChanged(void delegate(TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
416 
417 	@property void delegate(int, TextIF)[] onTextCaretMovedListeners();
418 	/**
419 	 * The "text-caret-moved" signal is emitted when the caret
420 	 * position of the text of an object which implements AtkText
421 	 * changes.
422 	 *
423 	 * Params:
424 	 *     arg1 = The new position of the text caret.
425 	 */
426 	void addOnTextCaretMoved(void delegate(int, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
427 
428 	@property void delegate(int, int, TextIF)[] onTextChangedListeners();
429 	/**
430 	 * The "text-changed" signal is emitted when the text of the
431 	 * object which implements the AtkText interface changes, This
432 	 * signal will have a detail which is either "insert" or
433 	 * "delete" which identifies whether the text change was an
434 	 * insertion or a deletion.
435 	 *
436 	 * Deprecated: Use #AtkObject::text-insert or
437 	 * #AtkObject::text-remove instead.
438 	 *
439 	 * Params:
440 	 *     arg1 = The position (character offset) of the insertion or deletion.
441 	 *     arg2 = The length (in characters) of text inserted or deleted.
442 	 */
443 	void addOnTextChanged(void delegate(int, int, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
444 
445 	@property void delegate(int, int, string, TextIF)[] onTextInsertListeners();
446 	/**
447 	 * The "text-insert" signal is emitted when a new text is
448 	 * inserted. If the signal was not triggered by the user
449 	 * (e.g. typing or pasting text), the "system" detail should be
450 	 * included.
451 	 *
452 	 * Params:
453 	 *     arg1 = The position (character offset) of the insertion.
454 	 *     arg2 = The length (in characters) of text inserted.
455 	 *     arg3 = The new text inserted
456 	 */
457 	void addOnTextInsert(void delegate(int, int, string, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
458 
459 	@property void delegate(int, int, string, TextIF)[] onTextRemoveListeners();
460 	/**
461 	 * The "text-remove" signal is emitted when a new text is
462 	 * removed. If the signal was not triggered by the user
463 	 * (e.g. typing or pasting text), the "system" detail should be
464 	 * included.
465 	 *
466 	 * Params:
467 	 *     arg1 = The position (character offset) of the removal.
468 	 *     arg2 = The length (in characters) of text removed.
469 	 *     arg3 = The old text removed
470 	 */
471 	void addOnTextRemove(void delegate(int, int, string, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
472 
473 	@property void delegate(TextIF)[] onTextSelectionChangedListeners();
474 	/**
475 	 * The "text-selection-changed" signal is emitted when the
476 	 * selected text of an object which implements AtkText changes.
477 	 */
478 	void addOnTextSelectionChanged(void delegate(TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
479 
480 
481 	/**
482 	 * Frees the memory used by an #AtkAttributeSet, including all its
483 	 * #AtkAttributes.
484 	 *
485 	 * Params:
486 	 *     attribSet = The #AtkAttributeSet to free
487 	 */
488 	public static void attributeSetFree(AtkAttributeSet* attribSet);
489 
490 	/**
491 	 * Get the #AtkTextAttribute type corresponding to a text attribute name.
492 	 *
493 	 * Params:
494 	 *     name = a string which is the (non-localized) name of an ATK text attribute.
495 	 *
496 	 * Return: the #AtkTextAttribute enumerated type corresponding to the specified
497 	 *     name,
498 	 *     or #ATK_TEXT_ATTRIBUTE_INVALID if no matching text attribute is found.
499 	 */
500 	public static AtkTextAttribute attributeForName(string name);
501 
502 	/**
503 	 * Gets the name corresponding to the #AtkTextAttribute
504 	 *
505 	 * Params:
506 	 *     attr = The #AtkTextAttribute whose name is required
507 	 *
508 	 * Return: a string containing the name; this string should not be freed
509 	 */
510 	public static string attributeGetName(AtkTextAttribute attr);
511 
512 	/**
513 	 * Gets the value for the index of the #AtkTextAttribute
514 	 *
515 	 * Params:
516 	 *     attr = The #AtkTextAttribute for which a value is required
517 	 *     index = The index of the required value
518 	 *
519 	 * Return: a string containing the value; this string
520 	 *     should not be freed; %NULL is returned if there are no values
521 	 *     maintained for the attr value.
522 	 */
523 	public static string attributeGetValue(AtkTextAttribute attr, int index);
524 
525 	/**
526 	 * Associate @name with a new #AtkTextAttribute
527 	 *
528 	 * Params:
529 	 *     name = a name string
530 	 *
531 	 * Return: an #AtkTextAttribute associated with @name
532 	 */
533 	public static AtkTextAttribute attributeRegister(string name);
534 }