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