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