1/* 2 * Copyright 2001-2013 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 * Stefano Ceccherini (stefano.ceccherini@gmail.com) 8 * John Scipione, jscipione@gmail.com 9 * 10 * Corresponds to: 11 * headers/os/interface/TextView.h hrev45377 12 * src/kits/interface/TextView.cpp hrev45377 13 */ 14 15 16/*! 17 \file TextView.h 18 \ingroup interface 19 \ingroup libbe 20 \brief Provides the BTextView class and associated structs. 21*/ 22 23 24/*! 25 \struct text_run 26 \ingroup interface 27 \ingroup libbe 28 \brief text run struct 29*/ 30 31 32/*! 33 \var text_run::offset 34*/ 35 36 37/*! 38 \var text_run::font 39*/ 40 41 42/*! 43 \var text_run::color 44*/ 45 46 47/*! 48 \struct text_run_array 49 \ingroup interface 50 \ingroup libbe 51 \brief text run array struct 52*/ 53 54 55/*! 56 \var text_run_array::count 57*/ 58 59 60/*! 61 \var text_run_array::runs 62*/ 63 64 65/*! 66 \enum undo_state 67 \ingroup interface 68 69 Undo state flags. 70*/ 71 72 73/*! 74 \var undo_state B_UNDO_UNAVAILABLE 75*/ 76 77 78/*! 79 \var undo_state B_UNDO_TYPING 80*/ 81 82 83/*! 84 \var undo_state B_UNDO_CUT 85*/ 86 87 88/*! 89 \var undo_state B_UNDO_PASTE 90*/ 91 92 93/*! 94 \var undo_state B_UNDO_CLEAR 95*/ 96 97 98/*! 99 \var undo_state B_UNDO_DROP 100*/ 101 102 103/*! 104 \class BTextView 105 \ingroup interface 106 \ingroup libbe 107 \brief Displays and manipulates styled text. 108*/ 109 110 111/*! 112 \fn BTextView::BTextView(BRect frame, const char* name, BRect textRect, 113 uint32 resizeMask, uint32 flags) 114 \brief Creates a new BTextView object. 115 116 \param frame The frame rectangle of the view. 117 \param name The name of the view. 118 \param textRect The area of the text within the view. 119 \param resizeMask Resizing mask, passed to BView. 120 \param flags \a flags passed to BView, \c B_FRAME_EVENTS, 121 \c B_PULSE_NEEDED and \c B_INPUT_METHOD_AWARE are always set. 122*/ 123 124 125/*! 126 \fn BTextView::BTextView(BRect frame, const char* name, BRect textRect, 127 const BFont* initialFont, const rgb_color* initialColor, 128 uint32 resizeMask, uint32 flags) 129 \brief Creates a new BTextView object and sets the initial font and color. 130 131 \param frame The BTextView frame rectangle. 132 \param name The name of the object. 133 \param textRect The area of the text within the BTextView object. 134 \param initialFont The text font to display. 135 \param initialColor The text color to display. 136 \param resizeMask Resizing mask, passed to BView. 137 \param flags \a flags passed to BView, \c B_FRAME_EVENTS, 138 \c B_PULSE_NEEDED and \c B_INPUT_METHOD_AWARE are always set. 139*/ 140 141 142/*! 143 \fn BTextView::BTextView(const char* name, uint32 flags) 144 \brief Creates a BTextView object, dynamic layout version. 145 146 \param name The name of the object. 147 \param flags \a flags passed to BView, \c B_FRAME_EVENTS, 148 \c B_PULSE_NEEDED and \c B_INPUT_METHOD_AWARE are always set. 149*/ 150 151 152/*! 153 \fn BTextView::BTextView(const char* name, const BFont* initialFont, 154 const rgb_color* initialColor, uint32 flags) 155 \brief Creates a new BTextView object and sets the initial font and color, 156 dynamic layout version. 157 158 \param name The name of the object. 159 \param initialFont The text font to display. 160 \param initialColor The text color to display. 161 \param flags \a flags passed to BView, \c B_FRAME_EVENTS, 162 \c B_PULSE_NEEDED and \c B_INPUT_METHOD_AWARE are always set. 163*/ 164 165 166/*! 167 \fn BTextView::BTextView(BMessage* archive) 168 \brief Creates a BTextView object from the passed in \a archive. 169 170 \param archive The BMessage object from which the object is created. 171*/ 172 173 174/*! 175 \fn BTextView::~BTextView() 176 \brief Frees the memory allocated and destroys the object. 177*/ 178 179 180/*! 181 \name Archiving 182*/ 183 184 185//! @{ 186 187 188/*! 189 \fn BArchivable* BTextView::Instantiate(BMessage* archive) 190 \brief Instantiates a BTextView object from the passed in \a archive. 191 192 \param archive The BMessage object that the object is created from. 193 194 \return A new BTextView object as a BArchivable. 195*/ 196 197 198/*! 199 \fn status_t BTextView::Archive(BMessage* data, bool deep) const 200 \brief Archives the object into the \a data message. 201 202 \param data A pointer to the BMessage object to archive the object into. 203 \param deep Whether or not to archive child views as well. 204 205 \return A status code, \c B_OK if everything went well or an error code 206 otherwise. 207 \retval B_OK The object was archived. 208 \retval B_NO_MEMORY Ran out of memory while archiving the object. 209*/ 210 211 212//! @} 213 214 215/*! 216 \name Hook methods 217*/ 218 219 220//! @{ 221 222 223/*! 224 \fn void BTextView::AttachedToWindow() 225 \brief Hook method called when the text view is added to the view hierarchy. 226 227 Sets the pulse rate to 2 per second and adjust scrollbars if needed. 228 229 \see BView::AttachedToWindow() 230*/ 231 232 233/*! 234 \fn void BTextView::DetachedFromWindow() 235 \brief Hook method that is called when the text view is removed from the 236 view hierarchy. 237 238 \see BView::DetachedFromWindow() 239*/ 240 241 242/*! 243 \fn void BTextView::Draw(BRect updateRect) 244 \brief Hook method called to draw the contents of the text view. 245 246 \param updateRect The rectangular area to draw. 247 248 \see BView::Draw() 249*/ 250 251 252/*! 253 \fn void BTextView::MouseDown(BPoint where) 254 \brief Hook method that is called when a mouse button is pushed down while 255 the cursor is contained in the view. 256 257 \param where The location where the mouse button was pushed down. 258 259 \see BView::MouseDown() 260*/ 261 262 263/*! 264 \fn void BTextView::MouseUp(BPoint where) 265 \brief Hook method that is called when a mouse button is released while 266 the cursor is contained in the view. 267 268 This method stops asynchronous mouse tracking. 269 270 \param where The location that the mouse button was released. 271 272 \see BView::MouseUp() 273*/ 274 275 276/*! 277 \fn void BTextView::MouseMoved(BPoint where, uint32 code, 278 const BMessage* message) 279 \brief Hook method that is called whenever the mouse cursor enters, exits 280 or moves inside the view. 281 282 \param where The point where the mouse cursor has moved to. 283 \param code A code which indicates if the mouse entered or exited the view. 284 \param message A message containing drag and drop information. 285 286 \see BView::MouseMoved() 287*/ 288 289 290/*! 291 \fn void BTextView::WindowActivated(bool state) 292 \brief Hook method that is called when the window becomes the active window 293 or gives up that status. 294 295 \param state If \c true, window has just been activated. If \c false the 296 window has just been deactivated. 297 298 \see BView::WindowActivated() 299*/ 300 301 302/*! 303 \fn void BTextView::KeyDown(const char* bytes, int32 numBytes) 304 \brief Hook method that is called when a key is pressed while the view is 305 the focus view of the active window. 306 307 \see BView::KeyDown() 308*/ 309 310 311/*! 312 \fn void BTextView::Pulse() 313 \brief Hook method that is called at a set interval. 314 315 This method is used to make the I-beam blink. 316 317 \see BView::Pulse() 318*/ 319 320 321/*! 322 \fn void BTextView::FrameResized(float width, float height) 323 \brief Hook method that is called when the frame is resized. 324 325 This method updates any associated scrollbars. 326 327 \param width The new view width. 328 \param height The new view height. 329 330 \see BView::FrameResized() 331*/ 332 333 334/*! 335 \fn void BTextView::MessageReceived(BMessage* message) 336 \brief Hook method called with a message is received by the text view. 337 338 \param message The message received by the text view. 339 340 \see BView::MessageReceived() 341*/ 342 343 344//! @} 345 346 347/*! 348 \fn void BTextView::MakeFocus(bool focusState) 349 \brief Highlight or unhighlight the selection when the text view acquires 350 or loses its focus state. 351 352 \param focusState \c true to receive focus or \c false to lose it. 353 354 \see BView::MakeFocus() 355*/ 356 357 358/*! 359 \fn BHandler* BTextView::ResolveSpecifier(BMessage* message, int32 index, 360 BMessage* specifier, int32 what, const char* property) 361 \brief Returns the proper handler for the passed in scripting \a message. 362 363 \param message The scripting message to determine the handler. 364 \param index The index of the specifier. 365 \param specifier The message which contains the specifier. 366 \param what The 'what' field of the specifier message. 367 \param property The name of the target property. 368 369 \return The proper BHandler for the passed in scripting \a message. 370 371 \see BView::ResolveSpecifier() 372*/ 373 374 375/*! 376 \name SetText 377 378 The BTextView doesn't keep a reference to the \a text buffer, \a file, or 379 \a runs array you pass in, you can \c delete them after SetText() returns. 380 381 If the BTextView supports multiple character styles and a 382 \c text_run_array is passed in it will be used to set the font and color 383 formats of the new text. 384 385 If the BTextView does not support multiple character styles, then the 386 \c text_run_array parameter is ignored. 387 388 \see IsStylable() 389*/ 390 391 392//! @{ 393 394 395/*! 396 \fn void BTextView::SetText(const char* text, const text_run_array* runs) 397 \brief Copies text from the \a text buffer replacing any text currently 398 set in the BTextView with the font and color formats set by \a runs. 399 400 \param text The text to set. 401 \param runs The text styling to set, can be \c NULL. 402*/ 403 404 405/*! 406 \fn void BTextView::SetText(const char* text, int32 length, 407 const text_run_array* runs) 408 \brief Copies text from the \a text buffer up to \a length characters 409 replacing any text currently set in the BTextView with the font and 410 color formats set by \a runs. 411 412 \a text must be at least \a length characters long. \a length may be set 413 to 0 to clear the text from the BTextView. 414 415 \param text The text to set. 416 \param length The number of bytes of text to set. 417 \param runs The text styling to use, can be \c NULL. 418*/ 419 420 421/*! 422 \fn void BTextView::SetText(BFile* file, int32 offset, int32 length, 423 const text_run_array* runs) 424 \brief Copies text from the \a file starting at the given \a offset up to 425 \a length characters replacing any text currently set in the 426 BTextView with the font and color formats set by \a runs. 427 428 \param file The file to set the text from. 429 \param offset The position in the file to start reading text. 430 \param length The number of bytes of text to read from the file. 431 \param runs The text styling to use, can be \c NULL. 432*/ 433 434 435//! @} 436 437 438/*! 439 \name Insert 440 441 The BTextView doesn't keep a reference to the \a text buffer or 442 \a runs array you pass in, you can \c delete them after Insert() returns. 443 444 If the BTextView supports multiple character styles and a 445 \c text_run_array is passed in it will be used to set the font and color 446 formats of the new text. 447 448 If the BTextView does not support multiple character styles, then the 449 \c text_run_array parameter is ignored. 450 451 \see IsStylable() 452*/ 453 454 455/*! 456 \fn void BTextView::Insert(const char* text, const text_run_array* runs) 457 \brief Inserts text from the \a text buffer at the end of the BTextView 458 with the font and color formats set by \a runs. 459 460 \param text The text to insert. 461 \param runs The text styling to set, can be \c NULL. 462*/ 463 464 465/*! 466 \fn void BTextView::Insert(const char* text, int32 length, 467 const text_run_array* runs) 468 \brief Inserts text from the \a text buffer up to \a length characters 469 at the end of the BTextView with the font and color formats set by 470 \a runs. 471 472 \param text The text to insert. 473 \param length The number of bytes of text to insert. 474 \param runs The text styling to use, can be \c NULL. 475*/ 476 477 478/*! 479 \fn void BTextView::Insert(int32 offset, const char* text, int32 length, 480 const text_run_array* runs) 481 \brief Inserts text starting at the given \a offset from the \a text buffer 482 up to \a length characters into the BTextView with the font and 483 color formats set by \a runs. 484 485 \param offset The position to start inserting text. 486 \param text The text to set. 487 \param length The number of bytes of text to insert. 488 \param runs The text styling to use, can be \c NULL. 489*/ 490 491 492//! @{ 493 494 495/*! 496 \fn void BTextView::SetText(const char* text, const text_run_array* runs) 497*/ 498 499 500/*! 501 \fn void BTextView::SetText(const char* text, int32 length, 502 const text_run_array* runs) 503*/ 504 505 506/*! 507 \fn void BTextView::SetText(BFile* file, int32 offset, int32 length, 508 const text_run_array* runs) 509*/ 510 511//! @} 512 513 514/*! 515 \name Delete 516*/ 517 518 519//! @{ 520 521 522/*! 523 \fn void BTextView::Delete() 524 \brief Deletes the text within the current selection. 525*/ 526 527 528/*! 529 \fn void BTextView::Delete(int32 startOffset, int32 endOffset) 530 \brief Deletes the text enclosed within the given offsets. 531 \param startOffset The offset where the text to delete starts. 532 \param endOffset The offset where the text to delete ends. 533*/ 534 535 536//! @} 537 538 539/*! 540 \name Text information 541*/ 542 543 544//! @{ 545 546 547/*! 548 \fn const char* BTextView::Text() const 549 \brief Returns the BTextView text as a byte array. 550 551 \warning It is possible that the BTextView object had to do some operations 552 on the text, to be able to return it as a C string. If you need to 553 call Text() repeatedly, you'd better use GetText() instead. 554 555 \returns A pointer to the text as a byte array. 556*/ 557 558 559/*! 560 \fn int32 BTextView::TextLength() const 561 \brief Returns the text length of the BTextView text. 562 563 \return The text length of the BTextView text. 564*/ 565 566 567/*! 568 \fn BTextView::GetText(int32 offset, int32 length, char* buffer) const 569 \brief Fills out \a buffer with the text of the BTextView starting at 570 \a offset and grabbing at most \a length bytes. 571 572 You must provide a \a buffer that is large enough to hold at least 573 \a length bytes. 574 575 \param offset Where to start grabbing text from. 576 \param length The number of bytes of text to grab. 577 \param buffer A \a buffer to write the text to. 578 579 \see BString::GetString(int32 offset, int32 length, char* buffer) 580*/ 581 582 583/*! 584 \fn uchar BTextView::ByteAt(int32 offset) const 585 \brief Returns the character at the given offset. 586 587 \param offset The offset to the desired character. 588 589 \return The character at the given offset. 590*/ 591 592 593/*! 594 \fn int32 BTextView::CountLines() const 595 \brief Returns the number of lines that the BTextView object contains. 596 597 \return The number of lines contained in the BTextView object. 598*/ 599 600 601/*! 602 \fn int32 BTextView::CurrentLine() const 603 \brief Returns the index of the current line. 604 605 \return The index of the current line. 606*/ 607 608 609/*! 610 \fn void BTextView::GoToLine(int32 index) 611 \brief Moves the caret to the specified line. 612 613 \param index The index of the line. 614*/ 615 616 617//! @} 618 619 620/*! 621 \name Clipboard 622*/ 623 624 625//! @{ 626 627 628/*! 629 \fn void BTextView::Cut(BClipboard* clipboard) 630 \brief Moves the current selection to the clipboard. 631 632 \param clipboard The clipboard object to move the text to. 633*/ 634 635 636/*! 637 \fn void BTextView::Copy(BClipboard* clipboard) 638 \brief Copies the current selection to the clipboard. 639 640 \param clipboard The clipboard object to copy the selected text to. 641*/ 642 643 644/*! 645 \fn void BTextView::Paste(BClipboard* clipboard) 646 \brief Copy the text contained in the clipboard to the BTextView. 647 648 \param clipboard A pointer to the clipboard. 649*/ 650 651 652/*! 653 \fn bool BTextView::AcceptsPaste(BClipboard* clipboard) 654 \brief Returns whether or not the BTextView can accept the 655 \a clipboard data. 656 657 \returns \c true if the BTextView can accept the pasted clipboard data, 658 \c false otherwise. 659*/ 660 661 662/*! 663 \fn bool BTextView::AcceptsDrop(const BMessage* message) 664 \brief Returns whether or not the BTextView can accept the dropped 665 \a message data. 666 667 \returns \c true if the BTextView can accept the dropped message data, 668 \c false otherwise. 669*/ 670 671 672//! @} 673 674 675/*! 676 \name Selection 677*/ 678 679 680//! @{ 681 682 683/*! 684 \fn void BTextView::Clear() 685 \brief Deletes the currently selected text. 686*/ 687 688 689/*! 690 \fn void BTextView::Select(int32 startOffset, int32 endOffset) 691 \brief Selects the text contained within the given offsets. 692 693 \param startOffset The offset where the text to select starts. 694 \param endOffset The offset where the text to select ends. 695*/ 696 697 698/*! 699 \fn void BTextView::SelectAll() 700 \brief Selects all text contained in the BTextView. 701*/ 702 703 704/*! 705 \fn void BTextView::GetSelection(int32* _start, int32* _end) const 706 \brief Fills out \a _start and \a _end with the start and end offsets of 707 the current selection. 708 709 \param _start A pointer to an int32 to contain the selection's start 710 offset. 711 \param _end A pointer to an int32 to contain the selection's end offset. 712*/ 713 714 715/*! 716 \fn text_run_array* BTextView::RunArray(int32 startOffset, int32 endOffset, 717 int32* _size) const 718 \brief Returns a \c text_run_array for the text within the given offsets. 719 720 The returned \c text_run_array belongs to the caller, so you must 721 free it once you no longer need it. 722 723 \param startOffset The text start offset. 724 \param endOffset The text end offset. 725 \param _size A pointer to an int32 to fill out the run array size. 726 727 \return A \c text_run_array for the text in the given offsets. 728*/ 729 730 731 732/*! 733 \fn int32 BTextView::LineAt(int32 offset) const 734 \brief Returns the line number of the character at the given offset. 735 736 \param offset The offset of the wanted character. 737 738 \return The line number of the character at the given offset. 739*/ 740 741 742/*! 743 \fn int32 BTextView::LineAt(BPoint point) const 744 \brief Returns the line number for the passed point. 745 746 \param point The point to get the line number of. 747 \return The line number for the passed in point. 748*/ 749 750 751/*! 752 \fn BPoint BTextView::PointAt(int32 offset, float* _height) const 753 \brief Returns the location of the character at the given offset. 754 755 \param offset The offset of the character. 756 \param _height A pointer to write the height of the character. 757 758 \return A BPoint object set to the location of the character. 759*/ 760 761 762/*! 763 \fn int32 BTextView::OffsetAt(BPoint point) const 764 \brief Returns the offset at the passed in point. 765 766 \param point The desired point. 767 768 \return The offset for the passed in point. 769*/ 770 771 772 773/*! 774 \fn int32 BTextView::OffsetAt(int32 line) const 775 \brief Returns the offset of the given line. 776 777 \param line A line number. 778 779 \return The offset of the passed line. 780*/ 781 782 783/*! 784 \fn void BTextView::FindWord(int32 offset, int32* _fromOffset, 785 int32* _toOffset) 786 \brief Fills out \a _fromOffset and \a _toOffset for a sequence of 787 character that qualifies as a word starting at \a offset. 788 789 A word is a sequence of characters that the user can select by double- 790 clicking. 791 792 \param offset The offset where to start looking. 793 \param _fromOffset A pointer to an integer to write the starting offset. 794 \param _toOffset A pointer to an integer to write the ending offset. 795*/ 796 797 798/*! 799 \fn bool BTextView::CanEndLine(int32 offset) 800 \brief Returns whether or not the character at the given offset can be 801 the last character of a line. 802 803 \param offset The offset of the character. 804 805 \returns \c true if the character can be the last character of a line, 806 \c false otherwise. 807*/ 808 809 810/*! 811 \fn float BTextView::LineWidth(int32 lineNum) const 812 \brief Returns the width of the line at the given index. 813 814 \param lineNum The index of the line to get the width of. 815*/ 816 817 818/*! 819 \fn float BTextView::LineHeight(int32 lineNum) const 820 \brief Returns the height of the line at the given index. 821 822 \param lineNum The index of the line to get the height of. 823*/ 824 825 826/*! 827 \fn float BTextView::TextHeight(int32 startLine, int32 endLine) const 828 \brief Returns the height of the text enclosed within the given lines. 829 830 \param startLine The index of the starting line. 831 \param endLine The index of the ending line. 832*/ 833 834 835/*! 836 \fn void BTextView::Highlight(int32 startOffset, int32 endOffset) 837 \brief Highlight the text enclosed within the given offsets. 838 839 \param startOffset The start offset of the text to highlight. 840 \param endOffset The end offset of the text to highlight. 841*/ 842 843 844//! @} 845 846 847/*! 848 \name Scrolling 849*/ 850 851 852//! @{ 853 854 855/*! 856 \fn void BTextView::ScrollToOffset(int32 offset) 857 \brief Scrolls the text so that the character at \a offset is visible. 858 859 \param offset The offset of the character to scroll to. 860*/ 861 862 863/*! 864 \fn void BTextView::ScrollToSelection() 865 \brief Scrolls the text so that the character that begins the selection 866 is visible. 867*/ 868 869 870//! @} 871 872 873/*! 874 \name TextRect 875*/ 876 877 878//! @{ 879 880 881/*! 882 \fn void BTextView::SetTextRect(BRect rect) 883 \brief Sets the object's text frame to the passed in \a rect. 884 885 \param rect A BRect object to set the text frame to. 886*/ 887 888 889/*! 890 \fn BRect BTextView::TextRect() const 891 \brief Returns the BTextView's text frame. 892 893 \return The BTextView's text frame. 894*/ 895 896 897//! @} 898 899 900/*! 901 \name Insets 902*/ 903 904 905//! @{ 906 907 908 909/*! 910 \fn void BTextView::SetInsets(float left, float top, float right, 911 float bottom) 912 \brief Sets the insets within the bounds for the object's text frame. 913 914 \note Insets cannot be negative, will result in 0 inset. 915 916 \param left The left inset to set. 917 \param top The top inset to set. 918 \param right The right inset to set. 919 \param bottom The bottom inset to set. 920*/ 921 922 923/*! 924 \fn void BTextView::GetInsets(float* _left, float* _top, float* _right, 925 float* _bottom) const 926 \brief Fills out the parameters with the objects's text insets. 927 928 \param _left A pointer to set to the frame's left inset. 929 \param _top A pointer to set to the frame's top inset. 930 \param _right A pointer to set to the frame's right inset. 931 \param _bottom A pointer to set to the frame's bottom inset. 932*/ 933 934 935 936//! @} 937 938 939/*! 940 \name Stylable 941*/ 942 943 944//! @{ 945 946 947 948/*! 949 \fn void BTextView::SetStylable(bool stylable) 950 \brief Sets whether or not the object accepts multiple character styles. 951 952 \param stylable Pass in \c true to accept multiple character styles, 953 \c false to NOT accept multiple character styles 954*/ 955 956 957/*! 958 \fn bool BTextView::IsStylable() const 959 \brief Returns whether or not the object is stylable. 960 961 If the object is stylable, it can show multiple fonts symultaneously. 962 963 \return \c true if the object is stylable, \c false otherwise. 964*/ 965 966 967//! @} 968 969 970/*! 971 \name Tab width 972*/ 973 974 975//! @{ 976 977 978 979/*! 980 \fn void BTextView::SetTabWidth(float width) 981 \brief Sets the distance between tab stops in pixels. 982 983 \param width The distance in pixel between tab stops to set. 984*/ 985 986 987/*! 988 \fn float BTextView::TabWidth() const 989 \brief Returns the tab width of the BTextView. 990 991 \return The tab width of the BTextView. 992*/ 993 994 995//! @} 996 997 998/*! 999 \name Selectable state 1000*/ 1001 1002 1003//! @{ 1004 1005 1006 1007/*! 1008 \fn void BTextView::MakeSelectable(bool selectable) 1009 \brief Sets whether or not the text is selectable. 1010 1011 \param selectable Pass in \c true to set the text to be selectable, 1012 \c false to set the text to be not selectable. 1013*/ 1014 1015 1016/*! 1017 \fn bool BTextView::IsSelectable() const 1018 \brief Returns whether or not the text is selectable. 1019 1020 \return \c true if the text is selectable, 1021 \c false if the text is not selectable. 1022*/ 1023 1024 1025//! @} 1026 1027 1028/*! 1029 \name Editable state 1030*/ 1031 1032 1033//! @{ 1034 1035 1036 1037/*! 1038 \fn void BTextView::MakeEditable(bool editable) 1039 \brief Sets whether or not the text is editable. 1040 1041 \param editable Pass in \c true to set the text to be editable, 1042 \c false to set the object to be not editable. 1043*/ 1044 1045 1046/*! 1047 \fn bool BTextView::IsEditable() const 1048 \brief Returns whether or not the text is editable. 1049 1050 \return \c true if the text is editable, 1051 \c false if the text is not editable. 1052*/ 1053 1054 1055//! @} 1056 1057 1058/*! 1059 \name Word wrap 1060*/ 1061 1062 1063//! @{ 1064 1065 1066 1067/*! 1068 \fn void BTextView::SetWordWrap(bool wrap) 1069 \brief Activate or deactivate word wrapping mode. 1070 1071 \param wrap Pass in \c true to turn on word wrapping mode, 1072 \c false to turn off word wrapping mode. 1073*/ 1074 1075 1076/*! 1077 \fn bool BTextView::DoesWordWrap() const 1078 \brief Returns whether or not word wrapping is activated. 1079 1080 \return \c true if word wrapping is activated, \c false is word wrapping 1081 if not activated. 1082*/ 1083 1084 1085//! @} 1086 1087 1088/*! 1089 \name Max bytes 1090*/ 1091 1092 1093//! @{ 1094 1095 1096 1097/*! 1098 \fn void BTextView::SetMaxBytes(int32 max) 1099 \brief Sets the maximum number of bytes that the BTextView can contain. 1100 1101 \param max The maximum number of bytes to set. 1102*/ 1103 1104 1105/*! 1106 \fn int32 BTextView::MaxBytes() const 1107 \brief Returns the maximum number of bytes that the BTextView can contain. 1108 1109 \return the maximum number of bytes that the BTextView can contain. 1110*/ 1111 1112 1113//! @} 1114 1115 1116/*! 1117 \name Character filtering 1118*/ 1119 1120 1121//! @{ 1122 1123 1124 1125/*! 1126 \fn void BTextView::DisallowChar(uint32 character) 1127 \brief Adds the \a character to the disallowed characters list. 1128 1129 After this method returns, the \a character won't be accepted 1130 by the textview anymore. 1131 1132 \param character The character to disallow. 1133*/ 1134 1135 1136/*! 1137 \fn void BTextView::AllowChar(uint32 character) 1138 \brief Removes the \a character from the disallowed characters list. 1139 1140 After this method returns, the \a character will be accepted 1141 by the textview. 1142 1143 \param character The character to allow. 1144*/ 1145 1146 1147//! @} 1148 1149 1150/*! 1151 \name Alignment 1152*/ 1153 1154 1155//! @{ 1156 1157 1158 1159/*! 1160 \fn void BTextView::SetAlignment(alignment flag) 1161 \brief Sets the way text is aligned within the frame. 1162 1163 Choices are: 1164 - \c B_ALIGN_LEFT 1165 - \c B_ALIGN_RIGHT 1166 - \c B_ALIGN_CENTER 1167 1168 \param flag The text alignment to set. 1169*/ 1170 1171 1172/*! 1173 \fn alignment BTextView::Alignment() const 1174 \brief Returns the current text alignment. 1175 1176 \return The current alignment flag. 1177*/ 1178 1179 1180//! @} 1181 1182 1183/*! 1184 \name Auto-indent 1185*/ 1186 1187 1188//! @{ 1189 1190 1191 1192/*! 1193 \fn void BTextView::SetAutoindent(bool state) 1194 \brief Sets whether or not new lines of text are automatically indented. 1195 1196 \param state Pass in \c true to automatically indent the text, 1197 \c false to turn off automatic text indenting. 1198*/ 1199 1200 1201/*! 1202 \fn bool BTextView::DoesAutoindent() const 1203 \brief Returns whether or not automatic indenting is active. 1204 1205 \return \c true if automatic indenting is activated, \c false otherwise. 1206*/ 1207 1208 1209//! @} 1210 1211 1212/*! 1213 \name Color space 1214*/ 1215 1216 1217//! @{ 1218 1219 1220 1221/*! 1222 \fn void BTextView::SetColorSpace(color_space colors) 1223 \brief Set the color space of the offscreen BBitmap object. 1224 1225 \param colors The colorspace to set on the offscreen BBitmap object. 1226*/ 1227 1228 1229/*! 1230 \fn color_space BTextView::ColorSpace() const 1231 \brief Returns the colorspace set to the offscreen BBitmap object. 1232 1233 \return The colorspace of the offscreen BBitmap object. 1234*/ 1235 1236 1237//! @} 1238 1239 1240/*! 1241 \name Resizable 1242*/ 1243 1244 1245//! @{ 1246 1247 1248 1249/*! 1250 \fn void BTextView::MakeResizable(bool resize, BView* resizeView) 1251 \brief Activates and deactivates automatic resizing. 1252 1253 The resizing mechanism is alternative to BView resizing. The container 1254 view (the one passed to this function) should not automatically resize 1255 itself when the parent is resized. 1256 1257 \param resize Pass in \c true to set the the BTextView to automatically 1258 resize itself, \c false to disable automatic resizing. 1259 \param resizeView The BTextView object's parent view that resizes itself. 1260*/ 1261 1262 1263/*! 1264 \fn bool BTextView::IsResizable() const 1265 \brief Returns whether or not the object is resizable. 1266 1267 \returns \c true if the object is resizable, \c false otherwise. 1268*/ 1269 1270 1271//! @} 1272 1273 1274/*! 1275 \name Undo state 1276*/ 1277 1278 1279//! @{ 1280 1281 1282 1283/*! 1284 \fn void BTextView::SetDoesUndo(bool undo) 1285 \brief Enables and disables the undo mechanism. 1286 1287 \param undo Pass in \c true to enable the undo mechanism, 1288 \c false to disable it. 1289*/ 1290 1291 1292/*! 1293 \fn bool BTextView::DoesUndo() const 1294 \brief Returns whether or not the undo mechanism is enabled. 1295 1296 \return \c true if undo is enabled, \c false otherwise. 1297*/ 1298 1299 1300//! @} 1301 1302 1303/*! 1304 \name Hide typing 1305*/ 1306 1307 1308//! @{ 1309 1310 1311 1312/*! 1313 \fn void BTextView::HideTyping(bool enabled) 1314 \brief Enables and disables type hiding. 1315 1316 \param enabled Pass in \c true to enable type hiding, 1317 \c false to disable it. 1318*/ 1319 1320 1321/*! 1322 \fn bool BTextView::IsTypingHidden() const 1323 \brief Returns whether or not typing is hidden. 1324 1325 \return \c true if typing is hidden, \c false otherwise. 1326*/ 1327 1328 1329//! @} 1330