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 Set the font and color formats of the new text if provided. Only 402 applies if the BTextView permits multiple character formats. 403*/ 404 405 406/*! 407 \fn void BTextView::SetText(const char* text, int32 length, 408 const text_run_array* runs) 409 \brief Copies text from the \a text buffer up to \a length characters 410 replacing any text currently set in the BTextView with the font and 411 color formats set by \a runs. 412 413 \a text must be at least \a length characters long. \a length may be set 414 to 0 to clear the text from the BTextView. 415 416 \param text The text to set. 417 \param length The maximum number of bytes of \a text to use. 418 \param runs Set the font and color formats of the new text if provided. Only 419 applies if the BTextView permits multiple character formats. 420*/ 421 422 423/*! 424 \fn void BTextView::SetText(BFile* file, int32 offset, int32 length, 425 const text_run_array* runs) 426 \brief Copies text from the \a file starting at the given \a offset up to 427 \a length characters replacing any text currently set in the 428 BTextView with the font and color formats set by \a runs. 429 430 \param file The file to set the text from. 431 \param offset The position in the file to start reading text. 432 \param length The number of bytes of text to read from the file. 433 \param runs Set the font and color formats of the new text if provided. Only 434 applies if the BTextView permits multiple character formats. 435*/ 436 437 438//! @} 439 440 441/*! 442 \name Insert 443 444 The BTextView doesn't keep a reference to the \a text buffer or 445 \a runs array you pass in, you can \c delete them after Insert() returns. 446 447 If the BTextView supports multiple character styles and a 448 \c text_run_array is passed in it will be used to set the font and color 449 formats of the new text. 450 451 If the BTextView does not support multiple character styles, then the 452 \c text_run_array parameter is ignored. 453 454 \see IsStylable() 455*/ 456 457 458/*! 459 \fn void BTextView::Insert(const char* text, const text_run_array* runs) 460 \brief Inserts text from the \a text buffer at the end of the BTextView 461 with the font and color formats set by \a runs. 462 463 \param text The text to insert. 464 \param runs The text styling to set, can be \c NULL. 465*/ 466 467 468/*! 469 \fn void BTextView::Insert(const char* text, int32 length, 470 const text_run_array* runs) 471 \brief Inserts text from the \a text buffer up to \a length characters 472 at the end of the BTextView with the font and color formats set by 473 \a runs. 474 475 \param text The text to insert. 476 \param length The number of bytes of text to insert. 477 \param runs The text styling to use, can be \c NULL. 478*/ 479 480 481/*! 482 \fn void BTextView::Insert(int32 offset, const char* text, int32 length, 483 const text_run_array* runs) 484 \brief Inserts text starting at the given \a offset from the \a text buffer 485 up to \a length characters into the BTextView with the font and 486 color formats set by \a runs. 487 488 \param offset The position to start inserting text. 489 \param text The text to set. 490 \param length The number of bytes of text to insert. 491 \param runs The text styling to use, can be \c NULL. 492*/ 493 494 495//! @} 496 497 498/*! 499 \name Delete 500*/ 501 502 503//! @{ 504 505 506/*! 507 \fn void BTextView::Delete() 508 \brief Deletes the text within the current selection. 509*/ 510 511 512/*! 513 \fn void BTextView::Delete(int32 startOffset, int32 endOffset) 514 \brief Deletes the text enclosed within the given offsets. 515 \param startOffset The offset where the text to delete starts. 516 \param endOffset The offset where the text to delete ends. 517*/ 518 519 520//! @} 521 522 523/*! 524 \name Text information 525*/ 526 527 528//! @{ 529 530 531/*! 532 \fn const char* BTextView::Text() const 533 \brief Returns the BTextView text as a byte array. 534 535 \warning It is possible that the BTextView object had to do some operations 536 on the text, to be able to return it as a C string. If you need to 537 call Text() repeatedly, you'd better use GetText() instead. 538 539 \returns A pointer to the text as a byte array. 540*/ 541 542 543/*! 544 \fn int32 BTextView::TextLength() const 545 \brief Returns the text length of the BTextView text. 546 547 \return The text length of the BTextView text. 548*/ 549 550 551/*! 552 \fn BTextView::GetText(int32 offset, int32 length, char* buffer) const 553 \brief Fills out \a buffer with the text of the BTextView starting at 554 \a offset and grabbing at most \a length bytes. 555 556 You must provide a \a buffer that is large enough to hold at least 557 \a length bytes. 558 559 \param offset Where to start grabbing text from. 560 \param length The number of bytes of text to grab. 561 \param buffer A \a buffer to write the text to. 562 563 \see BString::GetString(int32 offset, int32 length, char* buffer) 564*/ 565 566 567/*! 568 \fn uchar BTextView::ByteAt(int32 offset) const 569 \brief Returns the character at the given offset. 570 571 \param offset The offset to the desired character. 572 573 \return The character at the given offset. 574*/ 575 576 577/*! 578 \fn int32 BTextView::CountLines() const 579 \brief Returns the number of lines that the BTextView object contains. 580 581 \return The number of lines contained in the BTextView object. 582*/ 583 584 585/*! 586 \fn int32 BTextView::CurrentLine() const 587 \brief Returns the index of the current line. 588 589 \return The index of the current line. 590*/ 591 592 593/*! 594 \fn void BTextView::GoToLine(int32 index) 595 \brief Moves the caret to the specified line. 596 597 \param index The index of the line. 598*/ 599 600 601//! @} 602 603 604/*! 605 \name Clipboard 606*/ 607 608 609//! @{ 610 611 612/*! 613 \fn void BTextView::Cut(BClipboard* clipboard) 614 \brief Moves the current selection to the clipboard. 615 616 \param clipboard The clipboard object to move the text to. 617*/ 618 619 620/*! 621 \fn void BTextView::Copy(BClipboard* clipboard) 622 \brief Copies the current selection to the clipboard. 623 624 \param clipboard The clipboard object to copy the selected text to. 625*/ 626 627 628/*! 629 \fn void BTextView::Paste(BClipboard* clipboard) 630 \brief Copy the text contained in the clipboard to the BTextView. 631 632 \param clipboard A pointer to the clipboard. 633*/ 634 635 636/*! 637 \fn bool BTextView::AcceptsPaste(BClipboard* clipboard) 638 \brief Returns whether or not the BTextView can accept the 639 \a clipboard data. 640 641 \returns \c true if the BTextView can accept the pasted clipboard data, 642 \c false otherwise. 643*/ 644 645 646/*! 647 \fn bool BTextView::AcceptsDrop(const BMessage* message) 648 \brief Returns whether or not the BTextView can accept the dropped 649 \a message data. 650 651 \returns \c true if the BTextView can accept the dropped message data, 652 \c false otherwise. 653*/ 654 655 656//! @} 657 658 659/*! 660 \name Selection 661*/ 662 663 664//! @{ 665 666 667/*! 668 \fn void BTextView::Clear() 669 \brief Deletes the currently selected text. 670*/ 671 672 673/*! 674 \fn void BTextView::Select(int32 startOffset, int32 endOffset) 675 \brief Selects the text contained within the given offsets. 676 677 \param startOffset The offset where the text to select starts. 678 \param endOffset The offset where the text to select ends. 679*/ 680 681 682/*! 683 \fn void BTextView::SelectAll() 684 \brief Selects all text contained in the BTextView. 685*/ 686 687 688/*! 689 \fn void BTextView::GetSelection(int32* _start, int32* _end) const 690 \brief Fills out \a _start and \a _end with the start and end offsets of 691 the current selection. 692 693 \param _start A pointer to an int32 to contain the selection's start 694 offset. 695 \param _end A pointer to an int32 to contain the selection's end offset. 696*/ 697 698 699/*! 700 \fn text_run_array* BTextView::RunArray(int32 startOffset, int32 endOffset, 701 int32* _size) const 702 \brief Returns a \c text_run_array for the text within the given offsets. 703 704 The returned \c text_run_array belongs to the caller, so you must 705 free it once you no longer need it. 706 707 \param startOffset The text start offset. 708 \param endOffset The text end offset. 709 \param _size A pointer to an int32 to fill out the run array size. 710 711 \return A \c text_run_array for the text in the given offsets. 712*/ 713 714 715 716/*! 717 \fn int32 BTextView::LineAt(int32 offset) const 718 \brief Returns the line number of the character at the given offset. 719 720 \param offset The offset of the wanted character. 721 722 \return The line number of the character at the given offset. 723*/ 724 725 726/*! 727 \fn int32 BTextView::LineAt(BPoint point) const 728 \brief Returns the line number for the passed point. 729 730 \param point The point to get the line number of. 731 \return The line number for the passed in point. 732*/ 733 734 735/*! 736 \fn BPoint BTextView::PointAt(int32 offset, float* _height) const 737 \brief Returns the location of the character at the given offset. 738 739 \param offset The offset of the character. 740 \param _height A pointer to write the height of the character. 741 742 \return A BPoint object set to the location of the character. 743*/ 744 745 746/*! 747 \fn int32 BTextView::OffsetAt(BPoint point) const 748 \brief Returns the offset at the passed in point. 749 750 \param point The desired point. 751 752 \return The offset for the passed in point. 753*/ 754 755 756 757/*! 758 \fn int32 BTextView::OffsetAt(int32 line) const 759 \brief Returns the offset of the given line. 760 761 \param line A line number. 762 763 \return The offset of the passed line. 764*/ 765 766 767/*! 768 \fn void BTextView::FindWord(int32 offset, int32* _fromOffset, 769 int32* _toOffset) 770 \brief Fills out \a _fromOffset and \a _toOffset for a sequence of 771 character that qualifies as a word starting at \a offset. 772 773 A word is a sequence of characters that the user can select by double- 774 clicking. 775 776 \param offset The offset where to start looking. 777 \param _fromOffset A pointer to an integer to write the starting offset. 778 \param _toOffset A pointer to an integer to write the ending offset. 779*/ 780 781 782/*! 783 \fn bool BTextView::CanEndLine(int32 offset) 784 \brief Returns whether or not the character at the given offset can be 785 the last character of a line. 786 787 \param offset The offset of the character. 788 789 \returns \c true if the character can be the last character of a line, 790 \c false otherwise. 791*/ 792 793 794/*! 795 \fn float BTextView::LineWidth(int32 lineNum) const 796 \brief Returns the width of the line at the given index. 797 798 \param lineNum The index of the line to get the width of. 799*/ 800 801 802/*! 803 \fn float BTextView::LineHeight(int32 lineNum) const 804 \brief Returns the height of the line at the given index. 805 806 \param lineNum The index of the line to get the height of. 807*/ 808 809 810/*! 811 \fn float BTextView::TextHeight(int32 startLine, int32 endLine) const 812 \brief Returns the height of the text enclosed within the given lines. 813 814 \param startLine The index of the starting line. 815 \param endLine The index of the ending line. 816*/ 817 818 819/*! 820 \fn void BTextView::Highlight(int32 startOffset, int32 endOffset) 821 \brief Highlight the text enclosed within the given offsets. 822 823 \param startOffset The start offset of the text to highlight. 824 \param endOffset The end offset of the text to highlight. 825*/ 826 827 828//! @} 829 830 831/*! 832 \name Scrolling 833*/ 834 835 836//! @{ 837 838 839/*! 840 \fn void BTextView::ScrollToOffset(int32 offset) 841 \brief Scrolls the text so that the character at \a offset is visible. 842 843 \param offset The offset of the character to scroll to. 844*/ 845 846 847/*! 848 \fn void BTextView::ScrollToSelection() 849 \brief Scrolls the text so that the character that begins the selection 850 is visible. 851*/ 852 853 854//! @} 855 856 857/*! 858 \name TextRect 859*/ 860 861 862//! @{ 863 864 865/*! 866 \fn void BTextView::SetTextRect(BRect rect) 867 \brief Sets the object's text frame to the passed in \a rect. 868 869 \param rect A BRect object to set the text frame to. 870*/ 871 872 873/*! 874 \fn BRect BTextView::TextRect() const 875 \brief Returns the BTextView's text frame. 876 877 \return The BTextView's text frame. 878*/ 879 880 881//! @} 882 883 884/*! 885 \name Insets 886*/ 887 888 889//! @{ 890 891 892 893/*! 894 \fn void BTextView::SetInsets(float left, float top, float right, 895 float bottom) 896 \brief Sets the insets within the bounds for the object's text frame. 897 898 \note Insets cannot be negative, will result in 0 inset. 899 900 \param left The left inset to set. 901 \param top The top inset to set. 902 \param right The right inset to set. 903 \param bottom The bottom inset to set. 904*/ 905 906 907/*! 908 \fn void BTextView::GetInsets(float* _left, float* _top, float* _right, 909 float* _bottom) const 910 \brief Fills out the parameters with the objects's text insets. 911 912 \param _left A pointer to set to the frame's left inset. 913 \param _top A pointer to set to the frame's top inset. 914 \param _right A pointer to set to the frame's right inset. 915 \param _bottom A pointer to set to the frame's bottom inset. 916*/ 917 918 919 920//! @} 921 922 923/*! 924 \name Stylable 925*/ 926 927 928//! @{ 929 930 931 932/*! 933 \fn void BTextView::SetStylable(bool stylable) 934 \brief Sets whether or not the object accepts multiple character styles. 935 936 \param stylable Pass in \c true to accept multiple character styles, 937 \c false to NOT accept multiple character styles 938*/ 939 940 941/*! 942 \fn bool BTextView::IsStylable() const 943 \brief Returns whether or not the object is stylable. 944 945 If the object is stylable, it can show multiple fonts symultaneously. 946 947 \return \c true if the object is stylable, \c false otherwise. 948*/ 949 950 951//! @} 952 953 954/*! 955 \name Tab width 956*/ 957 958 959//! @{ 960 961 962 963/*! 964 \fn void BTextView::SetTabWidth(float width) 965 \brief Sets the distance between tab stops in pixels. 966 967 \param width The distance in pixel between tab stops to set. 968*/ 969 970 971/*! 972 \fn float BTextView::TabWidth() const 973 \brief Returns the tab width of the BTextView. 974 975 \return The tab width of the BTextView. 976*/ 977 978 979//! @} 980 981 982/*! 983 \name Selectable state 984*/ 985 986 987//! @{ 988 989 990 991/*! 992 \fn void BTextView::MakeSelectable(bool selectable) 993 \brief Sets whether or not the text is selectable. 994 995 \param selectable Pass in \c true to set the text to be selectable, 996 \c false to set the text to be not selectable. 997*/ 998 999 1000/*! 1001 \fn bool BTextView::IsSelectable() const 1002 \brief Returns whether or not the text is selectable. 1003 1004 \return \c true if the text is selectable, 1005 \c false if the text is not selectable. 1006*/ 1007 1008 1009//! @} 1010 1011 1012/*! 1013 \name Editable state 1014*/ 1015 1016 1017//! @{ 1018 1019 1020 1021/*! 1022 \fn void BTextView::MakeEditable(bool editable) 1023 \brief Sets whether or not the text is editable. 1024 1025 \param editable Pass in \c true to set the text to be editable, 1026 \c false to set the object to be not editable. 1027*/ 1028 1029 1030/*! 1031 \fn bool BTextView::IsEditable() const 1032 \brief Returns whether or not the text is editable. 1033 1034 \return \c true if the text is editable, 1035 \c false if the text is not editable. 1036*/ 1037 1038 1039//! @} 1040 1041 1042/*! 1043 \name Word wrap 1044*/ 1045 1046 1047//! @{ 1048 1049 1050 1051/*! 1052 \fn void BTextView::SetWordWrap(bool wrap) 1053 \brief Activate or deactivate word wrapping mode. 1054 1055 \param wrap Pass in \c true to turn on word wrapping mode, 1056 \c false to turn off word wrapping mode. 1057*/ 1058 1059 1060/*! 1061 \fn bool BTextView::DoesWordWrap() const 1062 \brief Returns whether or not word wrapping is activated. 1063 1064 \return \c true if word wrapping is activated, \c false is word wrapping 1065 if not activated. 1066*/ 1067 1068 1069//! @} 1070 1071 1072/*! 1073 \name Max bytes 1074*/ 1075 1076 1077//! @{ 1078 1079 1080 1081/*! 1082 \fn void BTextView::SetMaxBytes(int32 max) 1083 \brief Sets the maximum number of bytes that the BTextView can contain. 1084 1085 \param max The maximum number of bytes to set. 1086*/ 1087 1088 1089/*! 1090 \fn int32 BTextView::MaxBytes() const 1091 \brief Returns the maximum number of bytes that the BTextView can contain. 1092 1093 \return the maximum number of bytes that the BTextView can contain. 1094*/ 1095 1096 1097//! @} 1098 1099 1100/*! 1101 \name Character filtering 1102*/ 1103 1104 1105//! @{ 1106 1107 1108 1109/*! 1110 \fn void BTextView::DisallowChar(uint32 character) 1111 \brief Adds the \a character to the disallowed characters list. 1112 1113 After this method returns, the \a character won't be accepted 1114 by the textview anymore. 1115 1116 \param character The character to disallow. 1117*/ 1118 1119 1120/*! 1121 \fn void BTextView::AllowChar(uint32 character) 1122 \brief Removes the \a character from the disallowed characters list. 1123 1124 After this method returns, the \a character will be accepted 1125 by the textview. 1126 1127 \param character The character to allow. 1128*/ 1129 1130 1131//! @} 1132 1133 1134/*! 1135 \name Alignment 1136*/ 1137 1138 1139//! @{ 1140 1141 1142 1143/*! 1144 \fn void BTextView::SetAlignment(alignment flag) 1145 \brief Sets the way text is aligned within the frame. 1146 1147 Choices are: 1148 - \c B_ALIGN_LEFT 1149 - \c B_ALIGN_RIGHT 1150 - \c B_ALIGN_CENTER 1151 1152 \param flag The text alignment to set. 1153*/ 1154 1155 1156/*! 1157 \fn alignment BTextView::Alignment() const 1158 \brief Returns the current text alignment. 1159 1160 \return The current alignment flag. 1161*/ 1162 1163 1164//! @} 1165 1166 1167/*! 1168 \name Auto-indent 1169*/ 1170 1171 1172//! @{ 1173 1174 1175 1176/*! 1177 \fn void BTextView::SetAutoindent(bool state) 1178 \brief Sets whether or not new lines of text are automatically indented. 1179 1180 \param state Pass in \c true to automatically indent the text, 1181 \c false to turn off automatic text indenting. 1182*/ 1183 1184 1185/*! 1186 \fn bool BTextView::DoesAutoindent() const 1187 \brief Returns whether or not automatic indenting is active. 1188 1189 \return \c true if automatic indenting is activated, \c false otherwise. 1190*/ 1191 1192 1193//! @} 1194 1195 1196/*! 1197 \name Color space 1198*/ 1199 1200 1201//! @{ 1202 1203 1204 1205/*! 1206 \fn void BTextView::SetColorSpace(color_space colors) 1207 \brief Set the color space of the offscreen BBitmap object. 1208 1209 \param colors The colorspace to set on the offscreen BBitmap object. 1210*/ 1211 1212 1213/*! 1214 \fn color_space BTextView::ColorSpace() const 1215 \brief Returns the colorspace set to the offscreen BBitmap object. 1216 1217 \return The colorspace of the offscreen BBitmap object. 1218*/ 1219 1220 1221//! @} 1222 1223 1224/*! 1225 \name Resizable 1226*/ 1227 1228 1229//! @{ 1230 1231 1232 1233/*! 1234 \fn void BTextView::MakeResizable(bool resize, BView* resizeView) 1235 \brief Activates and deactivates automatic resizing. 1236 1237 The resizing mechanism is alternative to BView resizing. The container 1238 view (the one passed to this function) should not automatically resize 1239 itself when the parent is resized. 1240 1241 \param resize Pass in \c true to set the the BTextView to automatically 1242 resize itself, \c false to disable automatic resizing. 1243 \param resizeView The BTextView object's parent view that resizes itself. 1244*/ 1245 1246 1247/*! 1248 \fn bool BTextView::IsResizable() const 1249 \brief Returns whether or not the object is resizable. 1250 1251 \returns \c true if the object is resizable, \c false otherwise. 1252*/ 1253 1254 1255//! @} 1256 1257 1258/*! 1259 \name Undo state 1260*/ 1261 1262 1263//! @{ 1264 1265 1266 1267/*! 1268 \fn void BTextView::SetDoesUndo(bool undo) 1269 \brief Enables and disables the undo mechanism. 1270 1271 \param undo Pass in \c true to enable the undo mechanism, 1272 \c false to disable it. 1273*/ 1274 1275 1276/*! 1277 \fn bool BTextView::DoesUndo() const 1278 \brief Returns whether or not the undo mechanism is enabled. 1279 1280 \return \c true if undo is enabled, \c false otherwise. 1281*/ 1282 1283 1284//! @} 1285 1286 1287/*! 1288 \name Hide typing 1289*/ 1290 1291 1292//! @{ 1293 1294 1295 1296/*! 1297 \fn void BTextView::HideTyping(bool enabled) 1298 \brief Enables and disables type hiding. 1299 1300 \param enabled Pass in \c true to enable type hiding, 1301 \c false to disable it. 1302*/ 1303 1304 1305/*! 1306 \fn bool BTextView::IsTypingHidden() const 1307 \brief Returns whether or not typing is hidden. 1308 1309 \return \c true if typing is hidden, \c false otherwise. 1310*/ 1311 1312 1313//! @} 1314