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