2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = AtkText.html
56 import tango
.io
.Stdout
; // use the tango loging?
60 private import gtkc
.atktypes
;
62 private import gtkc
.atk
;
65 private import glib
.Str
;
72 * AtkText should be implemented by AtkObjects on behalf of widgets that
73 * have text content which is either attributed or otherwise non-trivial.
74 * AtkObjects whose text content is simple, unattributed, and very brief
75 * may expose that content via atk_object_get_name instead; however if the
76 * text is editable, multi-line, typically longer than three or four words,
77 * attributed, selectable, or if the object already uses the 'name' ATK
78 * property for other information, the AtkText interface should be used
79 * to expose the text content. In the case of editable text content,
80 * AtkEditableText (a subtype of the AtkText interface) should be
81 * implemented instead.
82 * AtkText provides not only traversal facilities and change notification
83 * for text content, but also caret tracking and glyph bounding box
84 * calculations. Note that the text strings are exposed as UTF-8, and are
85 * therefore potentially multi-byte, and caret-to-byte offset mapping makes
86 * no assumptions about the character length; also bounding box
87 * glyph-to-offset mapping may be complex for languages which use ligatures.
92 /** the main Gtk struct */
93 protected AtkText
* atkText
;
96 public AtkText
* getTextStruct()
102 /** the main Gtk struct as a void* */
103 protected void* getStruct()
105 return cast(void*)atkText
;
109 * Sets our main struct and passes it to the parent class
111 public this (AtkText
* atkText
)
115 if ( atkText
is null )
120 Stdout("struct atkText is null on constructor").newline
;
124 printf("struct atkText is null on constructor");
131 assert(atkText
!is null, "struct atkText is null on constructor");
133 this.atkText
= atkText
;
139 // imports for the signal processing
140 private import gobject
.Signals
;
141 private import gtkc
.gdktypes
;
142 int[char[]] connectedSignals
;
144 void delegate(Text
)[] onTextAttributesChangedListeners
;
145 void addOnTextAttributesChanged(void delegate(Text
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
147 if ( !("text-attributes-changed" in connectedSignals
) )
151 "text-attributes-changed",
152 cast(GCallback
)&callBackTextAttributesChanged
,
156 connectedSignals
["text-attributes-changed"] = 1;
158 onTextAttributesChangedListeners
~= dlg
;
160 extern(C
) static void callBackTextAttributesChanged(AtkText
* atktextStruct
, Text text
)
162 bool consumed
= false;
164 foreach ( void delegate(Text
) dlg
; text
.onTextAttributesChangedListeners
)
172 void delegate(gint
, Text
)[] onTextCaretMovedListeners
;
173 void addOnTextCaretMoved(void delegate(gint
, Text
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
175 if ( !("text-caret-moved" in connectedSignals
) )
180 cast(GCallback
)&callBackTextCaretMoved
,
184 connectedSignals
["text-caret-moved"] = 1;
186 onTextCaretMovedListeners
~= dlg
;
188 extern(C
) static void callBackTextCaretMoved(AtkText
* atktextStruct
, gint arg1
, Text text
)
190 bool consumed
= false;
192 foreach ( void delegate(gint
, Text
) dlg
; text
.onTextCaretMovedListeners
)
200 void delegate(gint
, gint
, Text
)[] onTextChangedListeners
;
201 void addOnTextChanged(void delegate(gint
, gint
, Text
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
203 if ( !("text-changed" in connectedSignals
) )
208 cast(GCallback
)&callBackTextChanged
,
212 connectedSignals
["text-changed"] = 1;
214 onTextChangedListeners
~= dlg
;
216 extern(C
) static void callBackTextChanged(AtkText
* atktextStruct
, gint arg1
, gint arg2
, Text text
)
218 bool consumed
= false;
220 foreach ( void delegate(gint
, gint
, Text
) dlg
; text
.onTextChangedListeners
)
222 dlg(arg1
, arg2
, text
);
228 void delegate(Text
)[] onTextSelectionChangedListeners
;
229 void addOnTextSelectionChanged(void delegate(Text
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
231 if ( !("text-selection-changed" in connectedSignals
) )
235 "text-selection-changed",
236 cast(GCallback
)&callBackTextSelectionChanged
,
240 connectedSignals
["text-selection-changed"] = 1;
242 onTextSelectionChangedListeners
~= dlg
;
244 extern(C
) static void callBackTextSelectionChanged(AtkText
* atktextStruct
, Text text
)
246 bool consumed
= false;
248 foreach ( void delegate(Text
) dlg
; text
.onTextSelectionChangedListeners
)
266 * Gets the specified text.
274 * the text from start_offset up to, but not including end_offset.
276 public char[] getText(int startOffset
, int endOffset
)
278 // gchar* atk_text_get_text (AtkText *text, gint start_offset, gint end_offset);
279 return Str
.toString(atk_text_get_text(atkText
, startOffset
, endOffset
) );
283 * Gets the specified text.
289 * the character at offset.
291 public gunichar
getCharacterAtOffset(int offset
)
293 // gunichar atk_text_get_character_at_offset (AtkText *text, gint offset);
294 return atk_text_get_character_at_offset(atkText
, offset
);
298 * Gets the specified text.
299 * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character after the
300 * offset is returned.
301 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string
302 * is from the word start after the offset to the next word start.
303 * The returned string will contain the word after the offset if the offset
304 * is inside a word or if the offset is not inside a word.
305 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_END the returned string
306 * is from the word end at or after the offset to the next work end.
307 * The returned string will contain the word after the offset if the offset
308 * is inside a word and will contain the word after the word after the offset
309 * if the offset is not inside a word.
310 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned
311 * string is from the sentence start after the offset to the next sentence
313 * The returned string will contain the sentence after the offset if the offset
314 * is inside a sentence or if the offset is not inside a sentence.
315 * If the boundary_type is ATK_TEXT_BOUNDARY_SENTENCE_END the returned string
316 * is from the sentence end at or after the offset to the next sentence end.
317 * The returned string will contain the sentence after the offset if the offset
318 * is inside a sentence and will contain the sentence after the sentence
319 * after the offset if the offset is not inside a sentence.
320 * If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned
321 * string is from the line start after the offset to the next line start.
322 * If the boundary_type is ATK_TEXT_BOUNDARY_LINE_END the returned string
323 * is from the line end at or after the offset to the next line start.
331 * the start offset of the returned string
333 * the offset of the first character after the
336 * the text after offset bounded by the specified boundary_type.
338 public char[] getTextAfterOffset(int offset
, AtkTextBoundary boundaryType
, int* startOffset
, int* endOffset
)
340 // gchar* atk_text_get_text_after_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset);
341 return Str
.toString(atk_text_get_text_after_offset(atkText
, offset
, boundaryType
, startOffset
, endOffset
) );
345 * Gets the specified text.
346 * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character at the
347 * offset is returned.
348 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string
349 * is from the word start at or before the offset to the word start after
351 * The returned string will contain the word at the offset if the offset
352 * is inside a word and will contain the word before the offset if the
353 * offset is not inside a word.
354 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_END the returned string
355 * is from the word end before the offset to the word end at or after the
357 * The returned string will contain the word at the offset if the offset
358 * is inside a word and will contain the word after to the offset if the
359 * offset is not inside a word.
360 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned
361 * string is from the sentence start at or before the offset to the sentence
362 * start after the offset.
363 * The returned string will contain the sentence at the offset if the offset
364 * is inside a sentence and will contain the sentence before the offset
365 * if the offset is not inside a sentence.
366 * If the boundary_type is ATK_TEXT_BOUNDARY_SENTENCE_END the returned string
367 * is from the sentence end before the offset to the sentence end at or
369 * The returned string will contain the sentence at the offset if the offset
370 * is inside a sentence and will contain the sentence after the offset
371 * if the offset is not inside a sentence.
372 * If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned
373 * string is from the line start at or before the offset to the line
374 * start after the offset.
375 * If the boundary_type is ATK_TEXT_BOUNDARY_LINE_END the returned string
376 * is from the line end before the offset to the line end at or after
385 * the start offset of the returned string
387 * the offset of the first character after the
390 * the text at offset bounded by the specified boundary_type.
392 public char[] getTextAtOffset(int offset
, AtkTextBoundary boundaryType
, int* startOffset
, int* endOffset
)
394 // gchar* atk_text_get_text_at_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset);
395 return Str
.toString(atk_text_get_text_at_offset(atkText
, offset
, boundaryType
, startOffset
, endOffset
) );
399 * Gets the specified text.
400 * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character before the
401 * offset is returned.
402 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string
403 * is from the word start before the word start before the offset to
404 * the word start before the offset.
405 * The returned string will contain the word before the offset if the offset
406 * is inside a word and will contain the word before the word before the
407 * offset if the offset is not inside a word.
408 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_END the returned string
409 * is from the word end before the word end at or before the offset to the
410 * word end at or before the offset.
411 * The returned string will contain the word before the offset if the offset
412 * is inside a word or if the offset is not inside a word.
413 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned
414 * string is from the sentence start before the sentence start before
415 * the offset to the sentence start before the offset.
416 * The returned string will contain the sentence before the offset if the
417 * offset is inside a sentence and will contain the sentence before the
418 * sentence before the offset if the offset is not inside a sentence.
419 * If the boundary_type is ATK_TEXT_BOUNDARY_SENTENCE_END the returned string
420 * is from the sentence end before the sentence end at or before the offset to
421 * the sentence end at or before the offset.
422 * The returned string will contain the sentence before the offset if the
423 * offset is inside a sentence or if the offset is not inside a sentence.
424 * If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned
425 * string is from the line start before the line start ar or before the offset
426 * to the line start ar or before the offset.
427 * If the boundary_type is ATK_TEXT_BOUNDARY_LINE_END the returned string
428 * is from the line end before the line end before the offset to the
429 * line end before the offset.
437 * the start offset of the returned string
439 * the offset of the first character after the
442 * the text before offset bounded by the specified boundary_type.
444 public char[] getTextBeforeOffset(int offset
, AtkTextBoundary boundaryType
, int* startOffset
, int* endOffset
)
446 // gchar* atk_text_get_text_before_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset);
447 return Str
.toString(atk_text_get_text_before_offset(atkText
, offset
, boundaryType
, startOffset
, endOffset
) );
451 * Gets the offset position of the caret (cursor).
455 * the offset position of the caret (cursor).
457 public int getCaretOffset()
459 // gint atk_text_get_caret_offset (AtkText *text);
460 return atk_text_get_caret_offset(atkText
);
464 * Get the bounding box containing the glyph representing the character at
465 * a particular text offset.
469 * The offset of the text character for which bounding information is required.
471 * Pointer for the x cordinate of the bounding box
473 * Pointer for the y cordinate of the bounding box
475 * Pointer for the width of the bounding box
477 * Pointer for the height of the bounding box
479 * specify whether coordinates are relative to the screen or widget window
481 public void getCharacterExtents(int offset
, int* x
, int* y
, int* width
, int* height
, AtkCoordType coords
)
483 // void atk_text_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords);
484 atk_text_get_character_extents(atkText
, offset
, x
, y
, width
, height
, coords
);
488 * Creates an AtkAttributeSet which consists of the attributes explicitly
489 * set at the position offset in the text. start_offset and end_offset are
490 * set to the start and end of the range around offset where the attributes are
491 * invariant. Note that end_offset is the offset of the first character
492 * after the range. See the enum AtkTextAttribute for types of text
493 * attributes that can be returned. Note that other attributes may also be
498 * the offset at which to get the attributes
500 * the address to put the start offset of the range
502 * the address to put the end offset of the range
504 * an AtkAttributeSet which contains the attributes explicitly set
505 * at offset. This AtkAttributeSet should be freed by a call to
506 * atk_attribute_set_free().
508 public AtkAttributeSet
* getRunAttributes(int offset
, int* startOffset
, int* endOffset
)
510 // AtkAttributeSet* atk_text_get_run_attributes (AtkText *text, gint offset, gint *start_offset, gint *end_offset);
511 return atk_text_get_run_attributes(atkText
, offset
, startOffset
, endOffset
);
515 * Creates an AtkAttributeSet which consists of the default values of
516 * attributes for the text. See the enum AtkTextAttribute for types of text
517 * attributes that can be returned. Note that other attributes may also be
522 * an AtkAttributeSet which contains the default values of attributes.
523 * at offset. This AtkAttributeSet should be freed by a call to
524 * atk_attribute_set_free().
526 public AtkAttributeSet
* getDefaultAttributes()
528 // AtkAttributeSet* atk_text_get_default_attributes (AtkText *text);
529 return atk_text_get_default_attributes(atkText
);
533 * Gets the character count.
537 * the number of characters.
539 public int getCharacterCount()
541 // gint atk_text_get_character_count (AtkText *text);
542 return atk_text_get_character_count(atkText
);
546 * Gets the offset of the character located at coordinates x and y. x and y
547 * are interpreted as being relative to the screen or this widget's window
548 * depending on coords.
552 * screen x-position of character
554 * screen y-position of character
556 * specify whether coordinates are relative to the screen or
559 * the offset to the character which is located at
560 * the specified x and y coordinates.
562 public int getOffsetAtPoint(int x
, int y
, AtkCoordType coords
)
564 // gint atk_text_get_offset_at_point (AtkText *text, gint x, gint y, AtkCoordType coords);
565 return atk_text_get_offset_at_point(atkText
, x
, y
, coords
);
569 * Get the ranges of text in the specified bounding box.
574 * An AtkTextRectagle giving the dimensions of the bounding box.
576 * Specify whether coordinates are relative to the screen or widget window.
578 * Specify the horizontal clip type.
580 * Specify the vertical clip type.
582 * Array of AtkTextRange. The last element of the array returned
583 * by this function will be NULL.
586 public AtkTextRange
** getBoundedRanges(AtkTextRectangle
* rect
, AtkCoordType coordType
, AtkTextClipType xClipType
, AtkTextClipType yClipType
)
588 // AtkTextRange** atk_text_get_bounded_ranges (AtkText *text, AtkTextRectangle *rect, AtkCoordType coord_type, AtkTextClipType x_clip_type, AtkTextClipType y_clip_type);
589 return atk_text_get_bounded_ranges(atkText
, rect
, coordType
, xClipType
, yClipType
);
593 * Get the bounding box for text within the specified range.
597 * The offset of the first text character for which boundary
598 * information is required.
600 * The offset of the text character after the last character
601 * for which boundary information is required.
603 * Specify whether coordinates are relative to the screen or widget window.
605 * A pointer to a AtkTextRectangle which is filled in by this function.
608 public void getRangeExtents(int startOffset
, int endOffset
, AtkCoordType coordType
, AtkTextRectangle
* rect
)
610 // void atk_text_get_range_extents (AtkText *text, gint start_offset, gint end_offset, AtkCoordType coord_type, AtkTextRectangle *rect);
611 atk_text_get_range_extents(atkText
, startOffset
, endOffset
, coordType
, rect
);
615 * Frees the memory associated with an array of AtkTextRange. It is assumed
616 * that the array was returned by the function atk_text_get_bounded_ranges
617 * and is NULL terminated.
619 * A pointer to an array of AtkTextRange which is to be freed.
622 public static void freeRanges(AtkTextRange
** ranges
)
624 // void atk_text_free_ranges (AtkTextRange **ranges);
625 atk_text_free_ranges(ranges
);
629 * Gets the number of selected regions.
633 * The number of selected regions, or -1 if a failure
636 public int getNSelections()
638 // gint atk_text_get_n_selections (AtkText *text);
639 return atk_text_get_n_selections(atkText
);
643 * Gets the text from the specified selection.
647 * The selection number. The selected regions are
648 * assigned numbers that correspond to how far the region is from the
649 * start of the text. The selected region closest to the beginning
650 * of the text region is assigned the number 0, etc. Note that adding,
651 * moving or deleting a selected region can change the numbering.
653 * passes back the start position of the selected region
655 * passes back the end position of (e.g. offset immediately past)
656 * the selected region
660 public char[] getSelection(int selectionNum
, int* startOffset
, int* endOffset
)
662 // gchar* atk_text_get_selection (AtkText *text, gint selection_num, gint *start_offset, gint *end_offset);
663 return Str
.toString(atk_text_get_selection(atkText
, selectionNum
, startOffset
, endOffset
) );
667 * Adds a selection bounded by the specified offsets.
671 * the start position of the selected region
673 * the offset of the first character after the selected region.
675 * TRUE if success, FALSE otherwise
677 public int addSelection(int startOffset
, int endOffset
)
679 // gboolean atk_text_add_selection (AtkText *text, gint start_offset, gint end_offset);
680 return atk_text_add_selection(atkText
, startOffset
, endOffset
);
684 * Removes the specified selection.
688 * The selection number. The selected regions are
689 * assigned numbers that correspond to how far the region is from the
690 * start of the text. The selected region closest to the beginning
691 * of the text region is assigned the number 0, etc. Note that adding,
692 * moving or deleting a selected region can change the numbering.
694 * TRUE if success, FALSE otherwise
696 public int removeSelection(int selectionNum
)
698 // gboolean atk_text_remove_selection (AtkText *text, gint selection_num);
699 return atk_text_remove_selection(atkText
, selectionNum
);
703 * Changes the start and end offset of the specified selection.
707 * The selection number. The selected regions are
708 * assigned numbers that correspond to how far the region is from the
709 * start of the text. The selected region closest to the beginning
710 * of the text region is assigned the number 0, etc. Note that adding,
711 * moving or deleting a selected region can change the numbering.
713 * the new start position of the selection
715 * the new end position of (e.g. offset immediately past)
718 * TRUE if success, FALSE otherwise
720 public int setSelection(int selectionNum
, int startOffset
, int endOffset
)
722 // gboolean atk_text_set_selection (AtkText *text, gint selection_num, gint start_offset, gint end_offset);
723 return atk_text_set_selection(atkText
, selectionNum
, startOffset
, endOffset
);
727 * Sets the caret (cursor) position to the specified offset.
733 * TRUE if success, FALSE otherwise.
735 public int setCaretOffset(int offset
)
737 // gboolean atk_text_set_caret_offset (AtkText *text, gint offset);
738 return atk_text_set_caret_offset(atkText
, offset
);
742 * Frees the memory used by an AtkAttributeSet, including all its
745 * The AtkAttributeSet to free
747 public static void atkAttributeSetFree(AtkAttributeSet
* attribSet
)
749 // void atk_attribute_set_free (AtkAttributeSet *attrib_set);
750 atk_attribute_set_free(attribSet
);
754 * Associate name with a new AtkTextAttribute
758 * an AtkTextAttribute associated with name
760 public static AtkTextAttribute
attributeRegister(char[] name
)
762 // AtkTextAttribute atk_text_attribute_register (const gchar *name);
763 return atk_text_attribute_register(Str
.toStringz(name
));
767 * Gets the name corresponding to the AtkTextAttribute
769 * The AtkTextAttribute whose name is required
771 * a string containing the name; this string should not be freed
773 public static char[] attributeGetName(AtkTextAttribute attr
)
775 // const gchar* atk_text_attribute_get_name (AtkTextAttribute attr);
776 return Str
.toString(atk_text_attribute_get_name(attr
) );
780 * Get the AtkTextAttribute type corresponding to a text attribute name.
782 * a string which is the (non-localized) name of an ATK text attribute.
784 * the AtkTextAttribute enumerated type corresponding to the specified
786 * or ATK_TEXT_ATTRIBUTE_INVALID if no matching text attribute is found.
788 public static AtkTextAttribute
attributeForName(char[] name
)
790 // AtkTextAttribute atk_text_attribute_for_name (const gchar *name);
791 return atk_text_attribute_for_name(Str
.toStringz(name
));
795 * Gets the value for the index of the AtkTextAttribute
797 * The AtkTextAttribute for which a value is required
799 * The index of the required value
801 * a string containing the value; this string should not be freed;
802 * NULL is returned if there are no values maintained for the attr value.
804 * The "text-attributes-changed" signal
805 * void user_function (AtkText *atktext,
806 * gpointer user_data) : Run Last
807 * The "text-attributes-changed" signal is emitted when the text attributes of
808 * the text of an object which implements AtkText changes.
810 * the object which received the signal.
812 * user data set when the signal handler was connected.
814 public static char[] attributeGetValue(AtkTextAttribute attr
, int index
)
816 // const gchar* atk_text_attribute_get_value (AtkTextAttribute attr, gint index_);
817 return Str
.toString(atk_text_attribute_get_value(attr
, index
) );