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