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: This method is deprecated since ATK version 298 * 2.9.3. Please use atk_text_get_string_at_offset() instead. 299 * 300 * Params: 301 * offset = position 302 * boundaryType = An #AtkTextBoundary 303 * startOffset = the start offset of the returned string 304 * endOffset = the offset of the first character after the 305 * returned substring 306 * 307 * Return: a newly allocated string containing the text after @offset bounded 308 * by the specified @boundary_type. Use g_free() to free the returned string. 309 */ 310 public string getTextAfterOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset); 311 312 /** 313 * Gets the specified text. 314 * 315 * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character at the 316 * offset is returned. 317 * 318 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string 319 * is from the word start at or before the offset to the word start after 320 * the offset. 321 * 322 * The returned string will contain the word at the offset if the offset 323 * is inside a word and will contain the word before the offset if the 324 * offset is not inside a word. 325 * 326 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned 327 * string is from the sentence start at or before the offset to the sentence 328 * start after the offset. 329 * 330 * The returned string will contain the sentence at the offset if the offset 331 * is inside a sentence and will contain the sentence before the offset 332 * if the offset is not inside a sentence. 333 * 334 * If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned 335 * string is from the line start at or before the offset to the line 336 * start after the offset. 337 * 338 * Deprecated: This method is deprecated since ATK version 339 * 2.9.4. Please use atk_text_get_string_at_offset() instead. 340 * 341 * Params: 342 * offset = position 343 * boundaryType = An #AtkTextBoundary 344 * startOffset = the start offset of the returned string 345 * endOffset = the offset of the first character after the 346 * returned substring 347 * 348 * Return: a newly allocated string containing the text at @offset bounded by 349 * the specified @boundary_type. Use g_free() to free the returned string. 350 */ 351 public string getTextAtOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset); 352 353 /** 354 * Gets the specified text. 355 * 356 * Deprecated: This method is deprecated since ATK version 357 * 2.9.3. Please use atk_text_get_string_at_offset() instead. 358 * 359 * Params: 360 * offset = position 361 * boundaryType = An #AtkTextBoundary 362 * startOffset = the start offset of the returned string 363 * endOffset = the offset of the first character after the 364 * returned substring 365 * 366 * Return: a newly allocated string containing the text before @offset bounded 367 * by the specified @boundary_type. Use g_free() to free the returned string. 368 */ 369 public string getTextBeforeOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset); 370 371 /** 372 * Removes the specified selection. 373 * 374 * Params: 375 * selectionNum = The selection number. The selected regions are 376 * assigned numbers that correspond to how far the region is from the 377 * start of the text. The selected region closest to the beginning 378 * of the text region is assigned the number 0, etc. Note that adding, 379 * moving or deleting a selected region can change the numbering. 380 * 381 * Return: %TRUE if success, %FALSE otherwise 382 */ 383 public bool removeSelection(int selectionNum); 384 385 /** 386 * Sets the caret (cursor) position to the specified @offset. 387 * 388 * Params: 389 * offset = position 390 * 391 * Return: %TRUE if success, %FALSE otherwise. 392 */ 393 public bool setCaretOffset(int offset); 394 395 /** 396 * Changes the start and end offset of the specified selection. 397 * 398 * Params: 399 * selectionNum = The selection number. The selected regions are 400 * assigned numbers that correspond to how far the region is from the 401 * start of the text. The selected region closest to the beginning 402 * of the text region is assigned the number 0, etc. Note that adding, 403 * moving or deleting a selected region can change the numbering. 404 * startOffset = the new start position of the selection 405 * endOffset = the new end position of (e.g. offset immediately past) 406 * the selection 407 * 408 * Return: %TRUE if success, %FALSE otherwise 409 */ 410 public bool setSelection(int selectionNum, int startOffset, int endOffset); 411 @property void delegate(TextIF)[] onTextAttributesChangedListeners(); 412 /** 413 * The "text-attributes-changed" signal is emitted when the text 414 * attributes of the text of an object which implements AtkText 415 * changes. 416 */ 417 void addOnTextAttributesChanged(void delegate(TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 418 419 @property void delegate(int, TextIF)[] onTextCaretMovedListeners(); 420 /** 421 * The "text-caret-moved" signal is emitted when the caret 422 * position of the text of an object which implements AtkText 423 * changes. 424 * 425 * Params: 426 * arg1 = The new position of the text caret. 427 */ 428 void addOnTextCaretMoved(void delegate(int, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 429 430 @property void delegate(int, int, TextIF)[] onTextChangedListeners(); 431 /** 432 * The "text-changed" signal is emitted when the text of the 433 * object which implements the AtkText interface changes, This 434 * signal will have a detail which is either "insert" or 435 * "delete" which identifies whether the text change was an 436 * insertion or a deletion. 437 * 438 * Deprecated: Since 2.9.4. Use #AtkObject::text-insert or 439 * #AtkObject::text-remove instead. 440 * 441 * Params: 442 * arg1 = The position (character offset) of the insertion or deletion. 443 * arg2 = The length (in characters) of text inserted or deleted. 444 */ 445 void addOnTextChanged(void delegate(int, int, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 446 447 @property void delegate(int, int, string, TextIF)[] onTextInsertListeners(); 448 /** 449 * The "text-insert" signal is emitted when a new text is 450 * inserted. If the signal was not triggered by the user 451 * (e.g. typing or pasting text), the "system" detail should be 452 * included. 453 * 454 * Params: 455 * arg1 = The position (character offset) of the insertion. 456 * arg2 = The length (in characters) of text inserted. 457 * arg3 = The new text inserted 458 */ 459 void addOnTextInsert(void delegate(int, int, string, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 460 461 @property void delegate(int, int, string, TextIF)[] onTextRemoveListeners(); 462 /** 463 * The "text-remove" signal is emitted when a new text is 464 * removed. If the signal was not triggered by the user 465 * (e.g. typing or pasting text), the "system" detail should be 466 * included. 467 * 468 * Params: 469 * arg1 = The position (character offset) of the removal. 470 * arg2 = The length (in characters) of text removed. 471 * arg3 = The old text removed 472 */ 473 void addOnTextRemove(void delegate(int, int, string, TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 474 475 @property void delegate(TextIF)[] onTextSelectionChangedListeners(); 476 /** 477 * The "text-selection-changed" signal is emitted when the 478 * selected text of an object which implements AtkText changes. 479 */ 480 void addOnTextSelectionChanged(void delegate(TextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 481 482 483 /** 484 * Frees the memory used by an #AtkAttributeSet, including all its 485 * #AtkAttributes. 486 * 487 * Params: 488 * attribSet = The #AtkAttributeSet to free 489 */ 490 public static void attributeSetFree(AtkAttributeSet* attribSet); 491 492 /** 493 * Get the #AtkTextAttribute type corresponding to a text attribute name. 494 * 495 * Params: 496 * name = a string which is the (non-localized) name of an ATK text attribute. 497 * 498 * Return: the #AtkTextAttribute enumerated type corresponding to the specified 499 * name, 500 * or #ATK_TEXT_ATTRIBUTE_INVALID if no matching text attribute is found. 501 */ 502 public static AtkTextAttribute attributeForName(string name); 503 504 /** 505 * Gets the name corresponding to the #AtkTextAttribute 506 * 507 * Params: 508 * attr = The #AtkTextAttribute whose name is required 509 * 510 * Return: a string containing the name; this string should not be freed 511 */ 512 public static string attributeGetName(AtkTextAttribute attr); 513 514 /** 515 * Gets the value for the index of the #AtkTextAttribute 516 * 517 * Params: 518 * attr = The #AtkTextAttribute for which a value is required 519 * index = The index of the required value 520 * 521 * Return: a string containing the value; this string 522 * should not be freed; %NULL is returned if there are no values 523 * maintained for the attr value. 524 */ 525 public static string attributeGetValue(AtkTextAttribute attr, int index); 526 527 /** 528 * Associate @name with a new #AtkTextAttribute 529 * 530 * Params: 531 * name = a name string 532 * 533 * Return: an #AtkTextAttribute associated with @name 534 */ 535 public static AtkTextAttribute attributeRegister(string name); 536 }