Displays and manipulates styled text. More...
Inherits BView.
Public Member Functions | |
BTextView (BMessage *archive) | |
Creates a BTextView object from the passed in archive. | |
BTextView (BRect frame, const char *name, BRect textRect, const BFont *initialFont, const rgb_color *initialColor, uint32 resizeMask, uint32 flags) | |
Creates a new BTextView object and sets the initial font and color. | |
BTextView (BRect frame, const char *name, BRect textRect, uint32 resizeMask, uint32 flags=B_WILL_DRAW|B_PULSE_NEEDED) | |
Creates a new BTextView object. | |
BTextView (const char *name, const BFont *initialFont, const rgb_color *initialColor, uint32 flags) | |
Creates a new BTextView object and sets the initial font and color, dynamic layout version. | |
BTextView (const char *name, uint32 flags=B_WILL_DRAW|B_PULSE_NEEDED) | |
Creates a BTextView object, dynamic layout version. | |
virtual | ~BTextView () |
Frees the memory allocated and destroys the object. | |
virtual void | GetHeightForWidth (float width, float *min, float *max, float *preferred) |
Returns the min, max and preferred height for a given width. | |
virtual void | GetPreferredSize (float *_width, float *_height) |
Fill out the preferred width and height of the view into the _width and _height parameters. | |
virtual status_t | GetSupportedSuites (BMessage *data) |
virtual bool | HasHeightForWidth () |
Returns whether the layout of the view can calculate a height for a given width. | |
virtual void | MakeFocus (bool focus=true) |
Highlight or unhighlight the selection when the text view acquires or loses its focus state. | |
virtual BSize | MaxSize () |
Return the maximum size of the view. | |
virtual BSize | MinSize () |
Return the minimum size of the view. | |
virtual status_t | Perform (perform_code code, void *data) |
Perform some action. (Internal Method) | |
virtual BSize | PreferredSize () |
Return the preferred size of the view. | |
virtual void | ResizeToPreferred () |
Resizes the view to its preferred size keeping the position of the left top corner constant. | |
virtual BHandler * | ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 form, const char *property) |
Hook Methods | |
virtual void | AttachedToWindow () |
Hook method called when the text view is added to the view hierarchy. | |
virtual void | DetachedFromWindow () |
Hook method that is called when the text view is removed from the view hierarchy. | |
virtual void | Draw (BRect updateRect) |
Hook method called to draw the contents of the text view. | |
virtual void | MouseDown (BPoint where) |
Hook method that is called when a mouse button is pushed down while the cursor is contained in the view. | |
virtual void | MouseUp (BPoint where) |
Hook method that is called when a mouse button is released while the cursor is contained in the view. | |
virtual void | MouseMoved (BPoint where, uint32 code, const BMessage *dragMessage) |
Hook method that is called whenever the mouse cursor enters, exits or moves inside the view. | |
virtual void | WindowActivated (bool active) |
Hook method that is called when the window becomes the active window or gives up that status. | |
virtual void | KeyDown (const char *bytes, int32 numBytes) |
Hook method that is called when a key is pressed while the view is the focus view of the active window. | |
virtual void | Pulse () |
Hook method that is called at a set interval. | |
virtual void | FrameResized (float newWidth, float newHeight) |
Hook method that is called when the frame is resized. | |
virtual void | MessageReceived (BMessage *message) |
Hook method called with a message is received by the text view. | |
virtual void | AllAttached () |
virtual void | AllDetached () |
SetText | |
The BTextView doesn't keep a reference to the text buffer, file, or runs array you pass in, you can If the BTextView supports multiple character styles and a If the BTextView does not support multiple character styles, then the
| |
void | SetText (const char *text, const text_run_array *runs=NULL) |
Copies text from the text buffer replacing any text currently set in the BTextView with the font and color formats set by runs. | |
void | SetText (const char *text, int32 length, const text_run_array *runs=NULL) |
Copies text from the text buffer up to length characters replacing any text currently set in the BTextView with the font and color formats set by runs. | |
void | SetText (BFile *file, int32 offset, int32 length, const text_run_array *runs=NULL) |
Copies text from the file starting at the given offset up to length characters replacing any text currently set in the BTextView with the font and color formats set by runs. | |
Insert | |
The BTextView doesn't keep a reference to the text buffer or runs array you pass in, you can If the BTextView supports multiple character styles and a If the BTextView does not support multiple character styles, then the
| |
void | Insert (const char *text, const text_run_array *runs=NULL) |
Inserts text from the text buffer at the end of the BTextView with the font and color formats set by runs. | |
void | Insert (const char *text, int32 length, const text_run_array *runs=NULL) |
Inserts text from the text buffer up to length characters at the end of the BTextView with the font and color formats set by runs. | |
void | Insert (int32 offset, const char *text, int32 length, const text_run_array *runs=NULL) |
Inserts text starting at the given offset from the text buffer up to length characters into the BTextView with the font and color formats set by runs. | |
Delete | |
void | Delete () |
Deletes the text within the current selection. | |
void | Delete (int32 startOffset, int32 endOffset) |
Deletes the text enclosed within the given offsets. | |
Text Information | |
const char * | Text () const |
Returns the BTextView text as a byte array. | |
int32 | TextLength () const |
Returns the text length of the BTextView text. | |
void | GetText (int32 offset, int32 length, char *buffer) const |
Fills out buffer with the text of the BTextView starting at offset and grabbing at most length bytes. | |
uint8 | ByteAt (int32 offset) const |
Returns the character at the given offset. | |
int32 | CountLines () const |
Returns the number of lines that the BTextView object contains. | |
int32 | CurrentLine () const |
Returns the index of the current line. | |
void | GoToLine (int32 lineNumber) |
Moves the caret to the specified line. | |
Clipboard | |
virtual void | Cut (BClipboard *clipboard) |
Moves the current selection to the clipboard. | |
virtual void | Copy (BClipboard *clipboard) |
Copies the current selection to the clipboard. | |
virtual void | Paste (BClipboard *clipboard) |
Copy the text contained in the clipboard to the BTextView. | |
virtual bool | AcceptsPaste (BClipboard *clipboard) |
Returns whether or not the BTextView can accept the clipboard data. | |
virtual bool | AcceptsDrop (const BMessage *message) |
Returns whether or not the BTextView can accept the dropped message data. | |
Selection | |
void | Clear () |
Deletes the currently selected text. | |
virtual void | Select (int32 startOffset, int32 endOffset) |
Selects the text contained within the given offsets. | |
void | SelectAll () |
Selects all text contained in the BTextView. | |
void | GetSelection (int32 *_start, int32 *_end) const |
Fills out _start and _end with the start and end offsets of the current selection. | |
text_run_array * | RunArray (int32 startOffset, int32 endOffset, int32 *_size=NULL) const |
Returns a text_run_array for the text within the given offsets. | |
int32 | LineAt (int32 offset) const |
Returns the line number of the character at the given offset. | |
int32 | LineAt (BPoint point) const |
Returns the line number for the passed point. | |
BPoint | PointAt (int32 offset, float *_height=NULL) const |
Returns the location of the character at the given offset. | |
int32 | OffsetAt (BPoint point) const |
Returns the offset at the passed in point. | |
int32 | OffsetAt (int32 line) const |
Returns the offset of the given line. | |
virtual void | FindWord (int32 offset, int32 *_fromOffset, int32 *_toOffset) |
Fills out _fromOffset and _toOffset for a sequence of character that qualifies as a word starting at offset. | |
virtual bool | CanEndLine (int32 offset) |
Returns whether or not the character at the given offset can be the last character of a line. | |
float | LineWidth (int32 lineNumber=0) const |
Returns the width of the line at the given lineNumber. | |
float | LineHeight (int32 lineNumber=0) const |
Returns the height of the line at the given lineNumber. | |
float | TextHeight (int32 startLine, int32 endLine) const |
Returns the height of the text enclosed within the given lines. | |
void | Highlight (int32 startOffset, int32 endOffset) |
Highlight the text enclosed within the given offsets. | |
Color Adoption | |
void | AdoptSystemColors () |
Adopts document colors tinted to match panel background if uneditable. | |
bool | HasSystemColors () const |
Tests whether or not the text view is using system colors. | |
GetFontandColor() and SetFontAndColor() | |
void | SetFontAndColor (const BFont *font, uint32 mode=B_FONT_ALL, const rgb_color *color=NULL) |
Set font and text color of the current selection. The default mode is B_FONT_ALL . | |
void | SetFontAndColor (int32 startOffset, int32 endOffset, const BFont *font, uint32 mode=B_FONT_ALL, const rgb_color *color=NULL) |
Set the font and color of a selection starting at startoffset ending at endOffset. The default mode is B_FONT_ALL . | |
void | GetFontAndColor (int32 offset, BFont *_font, rgb_color *_color=NULL) const |
Fill out _font and _color at specified text offset. | |
void | GetFontAndColor (BFont *_font, uint32 *_mode, rgb_color *_color=NULL, bool *_sameColor=NULL) const |
Fill out _font, _mode, _color and sameColor with the font and color of the current selection. | |
Scrolling | |
virtual void | ScrollToOffset (int32 offset) |
Scrolls the text so that the character at offset is visible. | |
void | ScrollToSelection () |
Scrolls the text so that the character that begins the selection is visible. | |
TextRect | |
void | SetTextRect (BRect rect) |
Sets the object's text frame to the passed in rect. | |
BRect | TextRect () const |
Returns the BTextView's text frame. | |
Insets | |
void | SetInsets (float left, float top, float right, float bottom) |
Sets the insets within the bounds for the object's text frame. | |
void | GetInsets (float *_left, float *_top, float *_right, float *_bottom) const |
Fills out the parameters with the objects's text insets. | |
Stylable | |
void | SetStylable (bool stylable) |
Sets whether or not the object accepts multiple font styles. | |
bool | IsStylable () const |
Returns whether or not the object accepts multiple font styles. | |
Tab Width | |
void | SetTabWidth (float width) |
Sets the distance between tab stops in pixels. | |
float | TabWidth () const |
Returns the tab width of the BTextView. | |
Selectable State | |
void | MakeSelectable (bool selectable=true) |
Sets whether or not the text is selectable. | |
bool | IsSelectable () const |
Returns whether or not the text is selectable. | |
Editable State | |
void | MakeEditable (bool editable=true) |
Sets whether or not the text is editable. | |
bool | IsEditable () const |
Returns whether or not the text is editable. | |
Word Wrap | |
void | SetWordWrap (bool wrap) |
Activate or deactivate word wrapping mode. | |
bool | DoesWordWrap () const |
Returns whether or not word wrapping is activated. | |
Max Bytes | |
void | SetMaxBytes (int32 max) |
Sets the maximum number of bytes that the BTextView can contain. | |
int32 | MaxBytes () const |
Returns the maximum number of bytes that the BTextView can contain. | |
Character Filtering | |
void | DisallowChar (uint32 character) |
Adds the character to the disallowed characters list. | |
void | AllowChar (uint32 character) |
Removes the character from the disallowed characters list. | |
Alignment | |
void | SetAlignment (alignment align) |
Sets the way text is aligned within the frame. | |
alignment | Alignment () const |
Returns the current text alignment. | |
Autoindent | |
void | SetAutoindent (bool state) |
Sets whether or not new lines of text are automatically indented. | |
bool | DoesAutoindent () const |
Returns whether or not automatic indenting is active. | |
Color Space | |
void | SetColorSpace (color_space colors) |
Set the color space of the offscreen BBitmap object. | |
color_space | ColorSpace () const |
Returns the colorspace set to the offscreen BBitmap object. | |
Resizable | |
void | MakeResizable (bool resize, BView *resizeView=NULL) |
Activates and deactivates automatic resizing. | |
bool | IsResizable () const |
Returns whether or not the object is resizable. | |
Undo State | |
void | SetDoesUndo (bool undo) |
Enables and disables the undo mechanism. | |
bool | DoesUndo () const |
Returns whether or not the undo mechanism is enabled. | |
Hide Typing | |
void | HideTyping (bool enabled) |
Enables and disables type hiding. | |
bool | IsTypingHidden () const |
Returns whether or not typing is hidden. | |
![]() | |
BView (BMessage *archive) | |
Archive constructor. | |
BView (BRect frame, const char *name, uint32 resizingMode, uint32 flags) | |
Standard constructor. | |
BView (const char *name, uint32 flags, BLayout *layout=NULL) | |
Layout constructor. | |
virtual | ~BView () |
Destructor method. | |
BRect | Bounds () const |
Returns the view's frame rectangle in the view's coordinate system. | |
void | Flush () const |
Flushes the attached window's connection to App Server. | |
BRect | Frame () const |
Returns the view's frame rectangle in the parent's coordinate system. | |
virtual void | GetPreferredSize (float *_width, float *_height) |
Fill out the preferred width and height of the view into the _width and _height parameters. | |
virtual status_t | GetSupportedSuites (BMessage *data) |
virtual void | Hide () |
Hides the view without removing it from the view hierarchy. | |
bool | IsFocus () const |
Returns whether or not the view is the window's current focus view. | |
bool | IsHidden () const |
Returns whether or not the view is hidden. | |
bool | IsHidden (const BView *looking_from) const |
Returns whether or not the view is hidden from the perspective of lookingFrom. | |
bool | IsPrinting () const |
Returns whether or not the view is drawing to a printer. | |
BPoint | LeftTop () const |
Returns the left top corner point. | |
virtual status_t | Perform (perform_code code, void *data) |
Perform some action. (Internal Method) | |
virtual void | ResizeToPreferred () |
Resizes the view to its preferred size keeping the position of the left top corner constant. | |
uint32 | ResizingMode () const |
Returns the resizing mode flags mask set in the constructor or by SetResizingMode(). | |
virtual BHandler * | ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 form, const char *property) |
virtual void | SetResizingMode (uint32 mode) |
Sets the resizing mode of the view according to the mode mask. | |
void | SetViewCursor (const BCursor *cursor, bool sync=true) |
Assigns cursor to the view. | |
virtual void | Show () |
Shows the view making it visible. | |
void | Sync () const |
Synchronizes the attached window's connection to App Server. | |
BWindow * | Window () const |
Returns the window the view is attached to. | |
void | AddChild (BView *child, BView *before=NULL) |
Adds child to the view hierarchy immediately before before. | |
bool | AddChild (BLayoutItem *child) |
Add the child layout item to the view hierarchy. | |
bool | RemoveChild (BView *child) |
Removes child from the view hierarchy. | |
int32 | CountChildren () const |
Returns the number of child views that this view has. | |
BView * | ChildAt (int32 index) const |
Returns a pointer to the child view found at index. | |
BView * | NextSibling () const |
Returns a pointer to the next sibling view. | |
BView * | PreviousSibling () const |
Returns a pointer to the previous sibling view. | |
bool | RemoveSelf () |
Removes the view and all child views from the view hierarchy. | |
BView * | FindView (const char *name) const |
Returns the view in the view hierarchy with the specified name. | |
BView * | Parent () const |
Returns a pointer to the view's parent. | |
void | ConvertToScreen (BPoint *point) const |
Convert point to the screen's coordinate system in place. | |
BPoint | ConvertToScreen (BPoint point) const |
Returns point converted to the screen's coordinate system. | |
void | ConvertFromScreen (BPoint *point) const |
Convert point from the screen's coordinate system to the view's coordinate system in place. | |
BPoint | ConvertFromScreen (BPoint point) const |
Returns point converted from the screen's coordinate system to the view's coordinate system. | |
void | ConvertToScreen (BRect *rect) const |
Convert rect to the screen's coordinate system in place. | |
BRect | ConvertToScreen (BRect rect) const |
Returns rect converted to the screen's coordinate system. | |
void | ConvertFromScreen (BRect *rect) const |
Convert rect from the screen's coordinate system to the view's coordinate system in place. | |
BRect | ConvertFromScreen (BRect rect) const |
Returns rect converted from the screen's coordinate system to the view's coordinate system. | |
void | ConvertToParent (BPoint *point) const |
Convert point to the parent's coordinate system in place. | |
BPoint | ConvertToParent (BPoint point) const |
Returns point converted to the parent's coordinate system. | |
void | ConvertFromParent (BPoint *point) const |
Convert point from the parent's coordinate system to the view's coordinate system in place. | |
BPoint | ConvertFromParent (BPoint point) const |
Returns point converted from the parent's coordinate system to the view's coordinate system. | |
void | ConvertToParent (BRect *rect) const |
Convert rect to the parent's coordinate system in place. | |
BRect | ConvertToParent (BRect rect) const |
Returns rect converted to the parent's coordinate system. | |
void | ConvertFromParent (BRect *rect) const |
Convert rect from the parent's coordinate system to the view's coordinate system in place. | |
BRect | ConvertFromParent (BRect rect) const |
Returns rect converted from the parent's coordinate system to the view's coordinate system. | |
virtual void | SetFlags (uint32 flags) |
Sets the view flags to the flags mask. | |
uint32 | Flags () const |
Return the view flags set in the constructor or by SetFlags(). | |
void | GetClippingRegion (BRegion *region) const |
Fill out region with the view's clipping region. | |
virtual void | ConstrainClippingRegion (BRegion *region) |
Set the clipping region the region restricting the area that the view can draw in. | |
void | ClipToPicture (BPicture *picture, BPoint where=B_ORIGIN, bool sync=true) |
Intersects the current clipping region of the view with the pixels of picture. | |
void | ClipToInversePicture (BPicture *picture, BPoint where=B_ORIGIN, bool sync=true) |
Intersects the current clipping region of the view with the pixels outside of picture. | |
void | ClipToRect (BRect rect) |
Intersects the current clipping region of the view with the pixels of rect. | |
void | ClipToInverseRect (BRect rect) |
Intersects the current clipping region of the view with the pixels outside of rect. | |
void | ClipToShape (BShape *shape) |
Intersects the current clipping region of the view with the pixels of shape. | |
void | ClipToInverseShape (BShape *shape) |
Intersects the current clipping region of the view with the pixels outside of shape. | |
virtual void | SetDrawingMode (drawing_mode mode) |
Sets the drawing mode of the view. | |
drawing_mode | DrawingMode () const |
Return the current drawing_mode. | |
void | SetBlendingMode (source_alpha srcAlpha, alpha_function alphaFunc) |
Set the blending mode which controls how transparency is used. | |
void | GetBlendingMode (source_alpha *srcAlpha, alpha_function *alphaFunc) const |
Fill out srcAlpha and alphaFunc with the alpha mode and alpha function of the view. | |
virtual void | SetPenSize (float size) |
Set the pen size to size. | |
float | PenSize () const |
Return the current pen size. | |
bool | HasDefaultColors () const |
Tests if the view has any colors set. | |
bool | HasSystemColors () const |
Tests if the view is using system "panel" colors. B_PANEL_BACKGROUND_COLOR for ViewUIColor() B_PANEL_BACKGROUND_COLOR for LowUIColor() B_PANEL_TEXT_COLOR for HighUIColor() | |
void | AdoptParentColors () |
Attempts to use the colors of any parent view. Will adopt view, low, and high colors. Should be called in AttachedToWindow() or AllAttached(). | |
void | AdoptSystemColors () |
Instructs view to use standard system "panel" colors. B_PANEL_BACKGROUND_COLOR for ViewUIColor() B_PANEL_BACKGROUND_COLOR for LowUIColor() B_PANEL_TEXT_COLOR for HighUIColor() | |
void | AdoptViewColors (BView *view) |
Attempts to use the colors of a given view. Will adopt view, low, and high colors. | |
virtual void | SetViewColor (rgb_color color) |
Set the view color of the view. | |
void | SetViewColor (uchar red, uchar green, uchar blue, uchar alpha=255) |
Set the view color of the view. | |
rgb_color | ViewColor () const |
Return the current view color. | |
void | SetViewUIColor (color_which which, float tint=B_NO_TINT) |
Set the view color of the view to a system constant. The color will update live with user changes. | |
color_which | ViewUIColor (float *tint=NULL) const |
Return the current view color constant being used. | |
virtual void | SetHighColor (rgb_color color) |
Set the high color of the view. | |
void | SetHighColor (uchar red, uchar green, uchar blue, uchar alpha=255) |
Set the high color of the view. | |
rgb_color | HighColor () const |
Return the current high color. | |
void | SetHighUIColor (color_which which, float tint=B_NO_TINT) |
Set the high color of the view to a system constant. The color will update live with user changes. | |
color_which | HighUIColor (float *tint=NULL) const |
Return the current high color constant being used. | |
virtual void | SetLowColor (rgb_color color) |
Set the low color of the view. | |
void | SetLowColor (uchar red, uchar green, uchar blue, uchar alpha=255) |
Set the low color of the view. | |
rgb_color | LowColor () const |
Return the current low color. | |
void | SetLowUIColor (color_which which, float tint=B_NO_TINT) |
Set the low color of the view to a system constant. The color will update live with user changes. | |
color_which | LowUIColor (float *tint=NULL) const |
Return the current low color constant being used. | |
void | SetLineMode (cap_mode lineCap, join_mode lineJoin, float miterLimit=B_DEFAULT_MITER_LIMIT) |
Set line mode to use PostScript-style line cap and join modes. | |
join_mode | LineJoinMode () const |
Returns the current line join mode. | |
cap_mode | LineCapMode () const |
Returns the current line cap mode. | |
float | LineMiterLimit () const |
Returns the miter limit used for B_MITER_JOIN join mode. | |
void | SetFillRule (int32 rule) |
Sets the fill rule for the view. | |
int32 | FillRule () const |
Return the current fill mode. | |
void | SetOrigin (BPoint where) |
Sets the origin in the view's coordinate system. | |
void | SetOrigin (float x, float y) |
Sets the origin in the view's coordinate system. | |
BPoint | Origin () const |
Returns the origin point in the view's coordinate system. | |
void | SetTransform (BAffineTransform transform) |
Sets a BAffineTransform to transform the coordinate system. | |
BAffineTransform | Transform () const |
Returns the current BAffineTransform that is applied to the coordinate system. | |
void | TranslateBy (double x, double y) |
Translate the current view by coordinates. | |
void | ScaleBy (double x, double y) |
Scale the current view by factors x and y. | |
void | RotateBy (double angleRadians) |
Rotate the current view by angleRadians. | |
BAffineTransform | TransformTo (coordinate_space basis) const |
Return the BAffineTransform to convert from the current drawing space to basis. | |
void | PushState () |
Saves the drawing state to the stack. | |
void | PopState () |
Restores the drawing state from the stack. | |
void | MovePenTo (BPoint pt) |
Move the pen to point in the view's coordinate system. | |
void | MovePenTo (float x, float y) |
Move the pen to the point specified by x and y in the view's coordinate system. | |
void | MovePenBy (float x, float y) |
Move the pen by x pixels horizontally and y pixels vertically. | |
BPoint | PenLocation () const |
Return the current pen location as a BPoint object. | |
virtual void | SetFont (const BFont *font, uint32 mask=B_FONT_ALL) |
Set the font of the view. | |
void | GetFont (BFont *font) const |
Fill out font with the font set to the view. | |
void | TruncateString (BString *in_out, uint32 mode, float width) const |
Truncate string with truncation mode mode so that it is no wider than width set in the view's font. | |
float | StringWidth (const char *string) const |
Return the width of string set in the font of the view. | |
float | StringWidth (const char *string, int32 length) const |
Return the width of string set in the font of the view up to length characters. | |
void | GetStringWidths (char *stringArray[], int32 lengthArray[], int32 numStrings, float widthArray[]) const |
Fill out widths of the strings in stringArray set in the font of the view into widthArray. | |
void | SetFontSize (float size) |
Set the size of the view's font to size. | |
void | ForceFontAliasing (bool enable) |
Turn anti-aliasing on and off when printing. | |
void | GetFontHeight (font_height *height) const |
Fill out the font_height struct with the view font. | |
void | SetScale (float scale) const |
Sets the scale of the coordinate system the view uses for drawing. | |
float | Scale () const |
Return the current drawing scale. | |
void | SetViewBitmap (const BBitmap *bitmap, BRect srcRect, BRect dstRect, uint32 followFlags=B_FOLLOW_LEFT_TOP, uint32 options=B_TILE_BITMAP) |
Sets the background bitmap of the view. | |
void | SetViewBitmap (const BBitmap *bitmap, uint32 followFlags=B_FOLLOW_LEFT_TOP, uint32 options=B_TILE_BITMAP) |
Sets the background bitmap of the view. | |
void | ClearViewBitmap () |
Clears the background bitmap of the view if it has one. | |
status_t | SetViewOverlay (const BBitmap *overlay, BRect srcRect, BRect dstRect, rgb_color *colorKey, uint32 followFlags=B_FOLLOW_LEFT_TOP, uint32 options=0) |
Sets the overlay bitmap of the view. | |
status_t | SetViewOverlay (const BBitmap *overlay, rgb_color *colorKey, uint32 followFlags=B_FOLLOW_LEFT_TOP, uint32 options=0) |
Sets the overlay bitmap of the view. | |
void | ClearViewOverlay () |
Clears the overlay bitmap of the view if it has one. | |
void | StrokeLine (BPoint toPoint, ::pattern pattern=B_SOLID_HIGH) |
Stroke a line from the current pen location to the point toPoint. | |
void | StrokeLine (BPoint start, BPoint end, ::pattern pattern=B_SOLID_HIGH) |
Stroke a line from point start to point end. | |
void | BeginLineArray (int32 count) |
Begin a line array of up to count lines. | |
void | AddLine (BPoint start, BPoint end, rgb_color color) |
Add a line to the line array drawn from start to end. | |
void | EndLineArray () |
End the line array drawing the lines. | |
void | StrokePolygon (const BPolygon *polygon, bool closed=true, ::pattern pattern=B_SOLID_HIGH) |
Stroke a polygon shape. | |
void | StrokePolygon (const BPoint *pointArray, int32 numPoints, bool closed=true, ::pattern pattern=B_SOLID_HIGH) |
Stroke a polygon shape made up of points specified by pointArray. | |
void | StrokePolygon (const BPoint *pointArray, int32 numPoints, BRect bounds, bool closed=true, ::pattern pattern=B_SOLID_HIGH) |
Stroke a polygon shape made up of points specified by pointArray inscribed by bounds. | |
void | FillPolygon (const BPolygon *polygon, ::pattern pattern=B_SOLID_HIGH) |
Fill a polygon shape. | |
void | FillPolygon (const BPoint *pointArray, int32 numPoints, ::pattern pattern=B_SOLID_HIGH) |
Fill a polygon shape made up of points specified by pointArray. | |
void | FillPolygon (const BPoint *pointArray, int32 numPoints, BRect bounds, ::pattern pattern=B_SOLID_HIGH) |
Fill a polygon shape made up of points specified by pointArray inscribed by bounds. | |
void | FillPolygon (const BPolygon *polygon, const BGradient &gradient) |
Fill a polygon shape with the specified gradient pattern. | |
void | FillPolygon (const BPoint *pointArray, int32 numPoints, const BGradient &gradient) |
Fill a polygon shape made up of points specified by pointArray with the specified gradient pattern. | |
void | FillPolygon (const BPoint *pointArray, int32 numPoints, BRect bounds, const BGradient &gradient) |
Fill a polygon shape made up of points specified by pointArray inscribed by bounds with the specified gradient pattern. | |
void | StrokeTriangle (BPoint point1, BPoint point2, BPoint point3, BRect bounds, ::pattern pattern=B_SOLID_HIGH) |
Stroke the triangle specified by points point1, point2, and point3 and enclosed by bounds. | |
void | StrokeTriangle (BPoint point1, BPoint point2, BPoint point3, ::pattern pattern=B_SOLID_HIGH) |
Stroke the triangle specified by points point1, point2, and point3. | |
void | FillTriangle (BPoint point1, BPoint point2, BPoint point3, ::pattern pattern=B_SOLID_HIGH) |
Fill the triangle specified by points point1, point2, and point3. | |
void | FillTriangle (BPoint point1, BPoint point2, BPoint point3, BRect bounds, ::pattern pattern=B_SOLID_HIGH) |
Fill the triangle specified by points point1, point2, and point3 and enclosed by bounds. | |
void | FillTriangle (BPoint point1, BPoint point2, BPoint point3, const BGradient &gradient) |
Fill the triangle specified by points point1, point2, and point3 with the specified gradient pattern. | |
void | FillTriangle (BPoint point1, BPoint point2, BPoint point3, BRect bounds, const BGradient &gradient) |
Fill the triangle specified by points point1, point2, and point3 and enclosed by bounds with the specified gradient pattern. | |
void | StrokeRect (BRect rect, ::pattern pattern=B_SOLID_HIGH) |
Stroke the rectangle specified by rect. | |
void | FillRect (BRect rect, ::pattern pattern=B_SOLID_HIGH) |
Fill the rectangle specified by rect. | |
void | FillRect (BRect rect, const BGradient &gradient) |
Fill the rectangle specified by rect with the specified gradient pattern. | |
void | FillRegion (BRegion *rectegion, ::pattern pattern=B_SOLID_HIGH) |
Fill region. | |
void | FillRegion (BRegion *rectegion, const BGradient &gradient) |
Fill region with the specified gradient pattern. | |
void | InvertRect (BRect rect) |
Inverts the colors within rect. | |
void | StrokeRoundRect (BRect rect, float xRadius, float yRadius, ::pattern pattern=B_SOLID_HIGH) |
Stroke the rounded rectangle with horizontal radius xRadius and vertical radius yRadius. | |
void | FillRoundRect (BRect rect, float xRadius, float yRadius, ::pattern pattern=B_SOLID_HIGH) |
Fill the rounded rectangle with horizontal radius xRadius and vertical radius yRadius. | |
void | FillRoundRect (BRect rect, float xRadius, float yRadius, const BGradient &gradient) |
Fill the rounded rectangle with horizontal radius xRadius and vertical radius yRadius with the specified gradient pattern. | |
void | StrokeEllipse (BPoint center, float xRadius, float yRadius, ::pattern pattern=B_SOLID_HIGH) |
Stroke the outline of an ellipse starting at center with a horizontal radius of xRadius and a vertical radius of yRadius. | |
void | StrokeEllipse (BRect rect, ::pattern pattern=B_SOLID_HIGH) |
Stroke the outline of an ellipse inscribed within rect. | |
void | FillEllipse (BPoint center, float xRadius, float yRadius, ::pattern pattern=B_SOLID_HIGH) |
Fill an ellipse starting at center with a horizontal radius of xRadius and a vertical radius of yRadius. | |
void | FillEllipse (BRect rect, ::pattern pattern=B_SOLID_HIGH) |
Fill an ellipse inscribed within rect. | |
void | FillEllipse (BPoint center, float xRadius, float yRadius, const BGradient &gradient) |
Fill an ellipse with the specified gradient pattern starting at center with a horizontal radius of xRadius and a vertical radius of yRadius. | |
void | FillEllipse (BRect rect, const BGradient &gradient) |
Fill an ellipse with the specified gradient pattern inscribed within rect. | |
void | StrokeArc (BPoint center, float xRadius, float yRadius, float startAngle, float arcAngle, ::pattern pattern=B_SOLID_HIGH) |
Stroke the outline of an arc starting at center with a horizontal radius of xRadius and a vertical radius of yRadius starting at startAngle and drawing arcAngle degrees. | |
void | StrokeArc (BRect rect, float startAngle, float arcAngle, ::pattern pattern=B_SOLID_HIGH) |
Stroke the outline of an arc inscribed within rect starting at startAngle and drawing arcAngle degrees. | |
void | FillArc (BPoint center, float xRadius, float yRadius, float startAngle, float arcAngle, ::pattern pattern=B_SOLID_HIGH) |
Fill an arc starting at center with a horizontal radius of xRadius and a vertical radius of yRadius starting at startAngle and drawing arcAngle degrees. | |
void | FillArc (BRect rect, float startAngle, float arcAngle, ::pattern pattern=B_SOLID_HIGH) |
Fill an arc inscribed within rect starting at startAngle and drawing arcAngle degrees. | |
void | FillArc (BPoint center, float xRadius, float yRadius, float startAngle, float arcAngle, const BGradient &gradient) |
Fill an arc with the specified gradient pattern starting at center with a horizontal radius of xRadius and a vertical radius of yRadius starting at startAngle and drawing arcAngle degrees. | |
void | FillArc (BRect rect, float startAngle, float arcAngle, const BGradient &gradient) |
Fill an arc with the specified gradient pattern inscribed within rect starting at startAngle and drawing arcAngle degrees. | |
void | StrokeBezier (BPoint *controlPoints, ::pattern pattern=B_SOLID_HIGH) |
Stroke a bezier curve. | |
void | FillBezier (BPoint *controlPoints, ::pattern pattern=B_SOLID_HIGH) |
Fill a bezier curve. | |
void | FillBezier (BPoint *controlPoints, const BGradient &gradient) |
Fill a bezier curve. | |
void | StrokeShape (BShape *shape, ::pattern pattern=B_SOLID_HIGH) |
Stroke shape. | |
void | FillShape (BShape *shape, ::pattern pattern=B_SOLID_HIGH) |
Fill shape. | |
void | FillShape (BShape *shape, const BGradient &gradient) |
Fill shape with the specified gradient pattern. | |
void | CopyBits (BRect src, BRect dst) |
Copy the bits from the src rectangle to the dst rectangle in the view's coordinate system. | |
void | DrawBitmapAsync (const BBitmap *aBitmap, BRect bitmapRect, BRect viewRect, uint32 options) |
Draws bitmap on the view within viewRect asynchronously. bitmap portion is scaled to fit viewRect. | |
void | DrawBitmapAsync (const BBitmap *aBitmap, BRect bitmapRect, BRect viewRect) |
Draws bitmap on the view within viewRect asynchronously. bitmap portion is scaled to fit viewRect. | |
void | DrawBitmapAsync (const BBitmap *aBitmap, BRect viewRect) |
Draws bitmap on the view within viewRect asynchronously. bitmap is scaled to fit viewRect. | |
void | DrawBitmapAsync (const BBitmap *aBitmap, BPoint where) |
Draws bitmap on the view offset by where asynchronously. | |
void | DrawBitmapAsync (const BBitmap *aBitmap) |
Draws bitmap on the view asynchronously. | |
void | DrawBitmap (const BBitmap *aBitmap, BRect bitmapRect, BRect viewRect, uint32 options) |
Draws bitmap on the view within viewRect. bitmap portion is scaled to fit viewRect. | |
void | DrawBitmap (const BBitmap *aBitmap, BRect bitmapRect, BRect viewRect) |
Draws bitmap on the view within viewRect. bitmap portion is scaled to fit viewRect. | |
void | DrawBitmap (const BBitmap *aBitmap, BRect viewRect) |
Draws bitmap on the view within viewRect. bitmap is scaled to fit viewRect. | |
void | DrawBitmap (const BBitmap *aBitmap, BPoint where) |
Draws bitmap on the view offset by where. | |
void | DrawBitmap (const BBitmap *aBitmap) |
Draws bitmap on the view. | |
void | DrawTiledBitmapAsync (const BBitmap *aBitmap, BRect viewRect, BPoint phase=B_ORIGIN) |
Draws bitmap on the view within viewRect asynchronously. If bitmap is smaller, it is cloned to fill remaining space in viewRect. | |
void | DrawTiledBitmap (const BBitmap *aBitmap, BRect viewRect, BPoint phase=B_ORIGIN) |
Draws bitmap on the view within viewRect. If bitmap is smaller, it is cloned to fill remaining space in viewRect. | |
void | DrawChar (char aChar) |
Draws character c onto to the view at the current pen position. | |
void | DrawChar (char aChar, BPoint location) |
Draws character c at the specified location in the view. | |
void | DrawString (const char *string, escapement_delta *delta=NULL) |
Draw string onto the view at the current pen position. | |
void | DrawString (const char *string, BPoint location, escapement_delta *delta=NULL) |
Draw string onto the view at the specified location in the view. | |
void | DrawString (const char *string, int32 length, escapement_delta *delta=NULL) |
Draw string up to length characters onto the view at the current pen position. | |
void | DrawString (const char *string, int32 length, BPoint location, escapement_delta *delta=0L) |
Draw string up to length characters onto the view at the specified location in the view. | |
void | DrawString (const char *string, const BPoint *locations, int32 locationCount) |
Draw string locationCount times at the specified locations. | |
void | DrawString (const char *string, int32 length, const BPoint *locations, int32 locationCount) |
Draw string up to length characters locationCount times at the specified locations. | |
void | Invalidate (BRect invalRect) |
Sends a message to App Server to redraw the portion of the view specified by invalRect. | |
void | Invalidate (const BRegion *invalRegion) |
Sends a message to App Server to redraw the portion of the view specified by region. | |
void | Invalidate () |
Sends a message to App Server to redraw the view. | |
void | DelayedInvalidate (bigtime_t delay) |
Sends a message to App Server to redraw the entire view after a certain, minimum, delay. Repeated calls to this method may be merged, but the view is guaranteed to be redrawn after the delay given in the first call of this method. | |
void | DelayedInvalidate (bigtime_t delay, BRect invalRect) |
Sends a message to App Server to redraw the portion of the view specified by invalRect after a certain, minimum, delay. Repeated calls to this method may be merged, but the invalidated rect is guaranteed to be redrawn after the minimum delay given by the first call of this method. | |
void | SetDiskMode (char *filename, long offset) |
Unimplemented. | |
void | BeginPicture (BPicture *a_picture) |
Begins sending drawing instructions to picture. | |
void | AppendToPicture (BPicture *a_picture) |
Appends drawing instructions to picture without clearing it first. | |
BPicture * | EndPicture () |
Ends the drawing instruction recording session and returns the BPicture object passed to BeginPicture() or AppendToPicture(). | |
void | DrawPicture (const BPicture *a_picture) |
Draws the picture at the view's current pen position. | |
void | DrawPicture (const BPicture *a_picture, BPoint where) |
Draws the picture at the location in the view specified by where. | |
void | DrawPicture (const char *filename, long offset, BPoint where) |
Draws the picture from the file specified by filename offset by offset bytes at the location in the view specified by where. | |
void | DrawPictureAsync (const BPicture *a_picture) |
Draws the picture at the view's current pen position. | |
void | DrawPictureAsync (const BPicture *a_picture, BPoint where) |
Draws the picture at the location in the view specified by where. | |
void | DrawPictureAsync (const char *filename, long offset, BPoint where) |
Draws the picture from the file specified by filename offset by offset bytes at the location in the view specified by where. | |
void | BeginLayer (uint8 opacity) |
Begins a drawing layer. | |
void | EndLayer () |
Finish a layer and blend it in with the view. | |
void | MoveBy (float dh, float dv) |
Moves the view deltaX pixels horizontally and deltaY pixels vertically in the parent view's coordinate system. | |
void | MoveTo (BPoint where) |
Move the view to the location specified by where in the parent view's coordinate system. | |
void | MoveTo (float x, float y) |
Move the view to the coordinates specified by x in the horizontal dimension and y in the vertical dimension in the parent view's coordinate system. | |
void | ResizeBy (float dh, float dv) |
Resize the view by deltaWidth horizontally and deltaHeight vertically without moving the top left corner of the view. | |
void | ResizeTo (float width, float height) |
Resize the view to the specified width and height. | |
void | ResizeTo (BSize size) |
Resize the view to the dimension specified by size. | |
virtual status_t | AllUnarchived (const BMessage *archive) |
Hook method called when all views have been unarchived. | |
virtual status_t | AllArchived (BMessage *archive) const |
Hook method called when all views have been archived. | |
virtual void | KeyUp (const char *bytes, int32 numBytes) |
Hook method called when a keyboard key is released. | |
virtual void | FrameMoved (BPoint newPosition) |
Hook method called when the view is moved. | |
virtual void | TargetedByScrollView (BScrollView *scrollView) |
Hook method called when the view becomes the target of scrollView. | |
virtual void | DrawAfterChildren (BRect updateRect) |
Perform any drawing that needs to be done after child view have already been drawn. | |
void | BeginRectTracking (BRect startRect, uint32 style=B_TRACK_WHOLE_RECT) |
Displays an outline rectangle on the view and initiates tracking. | |
void | EndRectTracking () |
Ends tracking removing the outline rectangle from the view. | |
void | GetMouse (BPoint *location, uint32 *buttons, bool checkMessageQueue=true) |
Fills out the cursor location and the current state of the mouse buttons. | |
void | DragMessage (BMessage *message, BRect dragRect, BHandler *replyTo=NULL) |
Initiates a drag-and-drop session. | |
void | DragMessage (BMessage *message, BBitmap *bitmap, BPoint offset, BHandler *replyTo=NULL) |
Initiates a drag-and-drop session of an image. | |
void | DragMessage (BMessage *message, BBitmap *bitmap, drawing_mode dragMode, BPoint offset, BHandler *replyTo=NULL) |
Initiates a drag-and-drop session of an image with drawing_mode set by dragMode. | |
status_t | SetEventMask (uint32 mask, uint32 options=0) |
Sets whether or not the view can accept mouse and keyboard events when not in focus. | |
uint32 | EventMask () |
Returns the current event mask. | |
status_t | SetMouseEventMask (uint32 mask, uint32 options=0) |
Sets whether or not the view can accept mouse and keyboard events when not in focus from within MouseDown() until the following MouseUp() event. | |
void | ScrollBy (float dh, float dv) |
Scroll the view by deltaX horizontally and deltaY vertically. | |
void | ScrollTo (float x, float y) |
Scroll the view to the point specified by coordinates. | |
virtual void | ScrollTo (BPoint where) |
Scroll the view to the point specified by where. | |
BScrollBar * | ScrollBar (orientation direction) const |
Returns the BScrollBar object that has the BView set as its target. | |
virtual BAlignment | LayoutAlignment () |
Return the current BAlignemnt of the view. | |
void | SetExplicitMinSize (BSize size) |
Set this view's min size, to be used by MinSize(). | |
void | SetExplicitMaxSize (BSize size) |
Set this view's max size, to be used by MaxSize(). | |
void | SetExplicitPreferredSize (BSize size) |
Set this view's preferred size, to be used by PreferredSize(). | |
void | SetExplicitSize (BSize size) |
Set this view's size. | |
void | SetExplicitAlignment (BAlignment alignment) |
Set this view's alignment, to be used by Alignment(). | |
BSize | ExplicitMinSize () const |
Returns the explicit minimum size. | |
BSize | ExplicitMaxSize () const |
Returns the explicit maximum size. | |
BSize | ExplicitPreferredSize () const |
Returns the explicit preferred size. | |
BAlignment | ExplicitAlignment () const |
Returns the explicit alignment size. | |
void | InvalidateLayout (bool descendants=false) |
Invalidate layout. | |
virtual void | SetLayout (BLayout *layout) |
Sets the layout of the view. | |
BLayout * | GetLayout () const |
Get the layout of the view. | |
void | EnableLayoutInvalidation () |
Enable layout invalidation. | |
void | DisableLayoutInvalidation () |
Disable layout invalidation. | |
bool | IsLayoutInvalidationDisabled () |
Returns whether or not layout invalidation is disabled. | |
bool | IsLayoutValid () const |
Returns whether or not the layout is valid. | |
void | ResetLayoutInvalidation () |
Service call for BView derived classes re-enabling InvalidateLayout() notifications. | |
BLayoutContext * | LayoutContext () const |
Returns the BLayoutContext for this View. | |
void | Layout (bool force) |
Layout the view. | |
void | Relayout () |
Relayout the view. | |
void | SetToolTip (const char *text) |
Set the tool tip of the view to text. | |
void | SetToolTip (BToolTip *tip) |
Set the tool tip of the view to the tip object. | |
BToolTip * | ToolTip () const |
Return the tool tip set to the view or NULL if not set. | |
void | ShowToolTip (BToolTip *tip=NULL) |
Show the tool tip at the current mouse position. | |
void | HideToolTip () |
Hide the view's tool tip. | |
![]() | |
BHandler (const char *name=NULL) | |
Construct a new handler with a name. | |
virtual | ~BHandler () |
Free the filters of this handler, as well as the list of observers. | |
virtual status_t | Perform (perform_code d, void *arg) |
Perform some action (Internal method defined for binary compatibility purposes). | |
BHandler (BMessage *data) | |
Construct a handler from an archived message. | |
BLooper * | Looper () const |
Return a pointer to the looper that this handler is associated with. | |
void | SetName (const char *name) |
Set or change the name of this handler. | |
const char * | Name () const |
Return the name of this handler. | |
virtual void | SetNextHandler (BHandler *handler) |
Set the next handler in the chain that the message is passed on to if this handler cannot process it. | |
BHandler * | NextHandler () const |
Return the next hander in the chain to which the message is passed on. | |
virtual void | AddFilter (BMessageFilter *filter) |
Add filter as a prerequisite to this handler. | |
virtual bool | RemoveFilter (BMessageFilter *filter) |
Remove filter from the filter list. | |
virtual void | SetFilterList (BList *filters) |
Set the internal list of filters to filters. | |
BList * | FilterList () |
Return a pointer to the list of filters. | |
bool | LockLooper () |
Lock the looper associated with this handler. | |
status_t | LockLooperWithTimeout (bigtime_t timeout) |
Lock the looper associated with this handler, with a time out value. | |
void | UnlockLooper () |
Unlock the looper. | |
status_t | StartWatching (BMessenger target, uint32 what) |
Subscribe this handler to watch a specific state change of a target. | |
status_t | StartWatchingAll (BMessenger target) |
Subscribe this handler to watch a target for all events. | |
status_t | StopWatching (BMessenger target, uint32 what) |
Unsubscribe this handler from watching a specific state. | |
status_t | StopWatchingAll (BMessenger target) |
Unsubscribe this handler from watching all states. | |
status_t | StartWatching (BHandler *observer, uint32 what) |
Subscribe an observer for a specific state change of this handler. | |
status_t | StartWatchingAll (BHandler *observer) |
Subscribe an observer for a all state changes. | |
status_t | StopWatching (BHandler *observer, uint32 what) |
Unsubscribe an observer from watching a specific state. | |
status_t | StopWatchingAll (BHandler *observer) |
Unsubscribe an observer from watching all states. | |
virtual void | SendNotices (uint32 what, const BMessage *notice=NULL) |
Emit a state change to the observers. | |
bool | IsWatched () const |
Check if there are any observers watching this handler. | |
![]() | |
BArchivable () | |
Constructor. Does nothing. | |
BArchivable (BMessage *from) | |
Constructor. Does important behind-the-scenes work in the unarchiving process. | |
virtual | ~BArchivable () |
Destructor. Does nothing. | |
virtual status_t | AllArchived (BMessage *archive) const |
Method relating to the use of BArchiver . | |
virtual status_t | AllUnarchived (const BMessage *archive) |
Method relating to the use of BUnarchiver . | |
virtual status_t | Archive (BMessage *into, bool deep=true) const |
Archive the object into a BMessage. | |
virtual status_t | Perform (perform_code d, void *arg) |
Perform some action (Internal method defined for binary compatibility purposes). | |
Protected Member Functions | |
virtual void | DoLayout () |
Layout view within the layout context. | |
virtual void | LayoutInvalidated (bool descendants) |
Hook method called when the layout is invalidated. | |
![]() | |
virtual void | LayoutChanged () |
Hook function that is called when the layout if this view, or one of its children, has changed. | |
status_t | ScrollWithMouseWheelDelta (BScrollBar *, float) |
Handle the scroll wheel changing over scrollbars. | |
virtual bool | GetToolTipAt (BPoint point, BToolTip **_tip) |
Point _tip with the view's tool tip. | |
Archiving | |
virtual status_t | Archive (BMessage *archive, bool deep=true) const |
Archives the object into the data message. | |
static BArchivable * | Instantiate (BMessage *archive) |
Instantiates a BTextView object from the passed in archive. | |
Additional Inherited Members | |
![]() | |
static BArchivable * | Instantiate (BMessage *archive) |
Creates a new BView object from the data message. | |
![]() | |
static BArchivable * | Instantiate (BMessage *data) |
Static method to instantiate a handler from an archived message. | |
![]() | |
static BArchivable * | Instantiate (BMessage *archive) |
Static member to restore objects from messages. | |
Displays and manipulates styled text.
Each BTextView instance has a TextRect() that keeps track of the bounds of the text inside it. BTextView will resize and reposition TextRect() as the view size changes in FrameResized(). You must set the initial text rect either in the constructor, or using SetTextRect().
The dynamic layout versions of the constructor set the initial TextRect() to Bounds(). TextRect() uses the view's coordinate system.
Setting the text rect to Bounds() will add some default insets repositioning the text inside the view. If you do not want this you may override the default insets by calling SetInsets(). It is recommended that you use SetInsets() to offset the initial text rect position instead of offsetting the text rect passed into the constructor. SetInsets() will retain insets with changing alignment and word-wrap while the distance of the initial TextRect() from the view Bounds() is not retained.
TextRect() can be wider or narrower than the view and it can be taller or shorter. As you type, delete, cut, and paste the width and height of the text rect may change. If word-wrap is on, TextRect() width will always be set to the width of the view minus insets. If word-wrap is off TextRect() width will be set to the width of the longest line of text. The top and bottom of TextRect() will always be set to the top and bottom of the text. Highlight() will highlight multiple lines at least to the edge of the text view even if TextRect() is narrower.
When TextRect() is made wider or taller than the view scroll bars will activate if present. You may scroll using ScrollToOffset() to scroll the text so that the character at the given offset is visible or you may call ScrollToSelection() to scroll the text so that the character that begins the selection is visible.
Call SetText() to change the text. This will resize TextRect().
Call SetWordWrap() to turn word-wrap on and off. This will resize TextRect().
Call SetAlignment() to change the alignment to B_ALIGN_CENTER
or B_ALIGN_RIGHT
. This will reposition TextRect().
Call SetStylable() to allow multiple font styles.
Call SetTabWidth() to set the width of hard tabs. You may turn auto-indentation off with SetAutoindent().
Call MakeSelectable() and MakeEditable() to turn the ability for text to be selectable or editable off. A non-editable, non-selectable text view can be useful as a BStringView that wraps.
Call AdoptSystemColors() to set default colors.
Call MakeResizable() to make the view width track with text width, this can be useful for short single-line text views.
BTextView::BTextView | ( | BRect | frame, |
const char * | name, | ||
BRect | textRect, | ||
uint32 | resizeMask, | ||
uint32 | flags = B_WILL_DRAW | B_PULSE_NEEDED |
||
) |
Creates a new BTextView object.
frame | The frame rectangle of the view. |
name | The name of the view. |
textRect | The area of the text within the view. |
resizeMask | Resizing mask, passed to BView. |
flags | flags passed to BView, B_FRAME_EVENTS , B_PULSE_NEEDED and B_INPUT_METHOD_AWARE are always set. |
BTextView::BTextView | ( | BRect | frame, |
const char * | name, | ||
BRect | textRect, | ||
const BFont * | initialFont, | ||
const rgb_color * | initialColor, | ||
uint32 | resizeMask, | ||
uint32 | flags | ||
) |
Creates a new BTextView object and sets the initial font and color.
frame | The BTextView frame rectangle. |
name | The name of the object. |
textRect | The area of the text within the BTextView object. |
initialFont | The text font to display. |
initialColor | The text color to display. |
resizeMask | Resizing mask, passed to BView. |
flags | flags passed to BView, B_FRAME_EVENTS , B_PULSE_NEEDED and B_INPUT_METHOD_AWARE are always set. |
BTextView::BTextView | ( | const char * | name, |
uint32 | flags = B_WILL_DRAW | B_PULSE_NEEDED |
||
) |
Creates a BTextView object, dynamic layout version.
name | The name of the object. |
flags | flags passed to BView, B_FRAME_EVENTS , B_PULSE_NEEDED and B_INPUT_METHOD_AWARE are always set. |
BTextView::BTextView | ( | const char * | name, |
const BFont * | initialFont, | ||
const rgb_color * | initialColor, | ||
uint32 | flags | ||
) |
Creates a new BTextView object and sets the initial font and color, dynamic layout version.
name | The name of the object. |
initialFont | The text font to display. |
initialColor | The text color to display. |
flags | flags passed to BView, B_FRAME_EVENTS , B_PULSE_NEEDED and B_INPUT_METHOD_AWARE are always set. |
BTextView::BTextView | ( | BMessage * | archive | ) |
|
virtual |
Frees the memory allocated and destroys the object.
|
virtual |
|
virtual |
BTextView::AdoptSystemColors | ( | ) |
Adopts document colors tinted to match panel background if uneditable.
B_DOCUMENT_BACKGROUND_COLOR
for ViewUIColor()B_DOCUMENT_BACKGROUND_COLOR
for LowUIColor()B_DOCUMENT_TEXT_COLOR
for HighUIColor()This is reimplemented from BView which uses panel colors.
View and low colors tinted B_DARKEN_1_TINT
(inverse on dark) if uneditable.
Does not alter text color.
alignment BTextView::Alignment | ( | ) | const |
Returns the current text alignment.
|
virtual |
Similar to AttachedToWindow() but this method is triggered after all child views have already been attached to a window.
Reimplemented from BView.
|
virtual |
Similar to AttachedToWindow() but this method is triggered after all child views have already been detached from a window.
Reimplemented from BView.
void BTextView::AllowChar | ( | uint32 | character | ) |
Removes the character from the disallowed characters list.
After this method returns, the character will be accepted by the textview.
character | The character to allow. |
Archives the object into the data message.
data | A pointer to the BMessage object to archive the object into. |
deep | Whether or not to archive child views as well. |
B_OK
if everything went well or an error code otherwise. B_OK | The object was archived. |
B_NO_MEMORY | Ran out of memory while archiving the object. |
Reimplemented from BView.
|
virtual |
Hook method called when the text view is added to the view hierarchy.
Sets the pulse rate to 2 per second and adjust scrollbars if needed.
Reimplemented from BView.
Returns the character at the given offset.
offset | The offset to the desired character. |
|
virtual |
Returns whether or not the character at the given offset can be the last character of a line.
offset | The offset of the character. |
true
if the character can be the last character of a line, false
otherwise.void BTextView::Clear | ( | ) |
Deletes the currently selected text.
color_space BTextView::ColorSpace | ( | ) | const |
Returns the colorspace set to the offscreen BBitmap object.
|
virtual |
Copies the current selection to the clipboard.
clipboard | The clipboard object to copy the selected text to. |
int32 BTextView::CountLines | ( | ) | const |
int32 BTextView::CurrentLine | ( | ) | const |
Returns the index of the current line.
|
virtual |
Moves the current selection to the clipboard.
clipboard | The clipboard object to move the text to. |
void BTextView::Delete | ( | ) |
Deletes the text within the current selection.
Deletes the text enclosed within the given offsets.
startOffset | The offset where the text to delete starts. |
endOffset | The offset where the text to delete ends. |
|
virtual |
Hook method that is called when the text view is removed from the view hierarchy.
Reimplemented from BView.
void BTextView::DisallowChar | ( | uint32 | character | ) |
Adds the character to the disallowed characters list.
After this method returns, the character won't be accepted by the textview anymore.
character | The character to disallow. |
bool BTextView::DoesAutoindent | ( | ) | const |
Returns whether or not automatic indenting is active.
true
if automatic indenting is activated, false
otherwise.bool BTextView::DoesUndo | ( | ) | const |
Returns whether or not the undo mechanism is enabled.
true
if undo is enabled, false
otherwise.bool BTextView::DoesWordWrap | ( | ) | const |
Returns whether or not word wrapping is activated.
true
if word wrapping is activated, false
is word wrapping if not activated.
|
protectedvirtual |
|
virtual |
Hook method called to draw the contents of the text view.
updateRect | The rectangular area to draw. |
Reimplemented from BView.
Fills out _fromOffset and _toOffset for a sequence of character that qualifies as a word starting at offset.
A word is a sequence of characters that the user can select by double- clicking.
offset | The offset where to start looking. |
_fromOffset | A pointer to an integer to write the starting offset. |
_toOffset | A pointer to an integer to write the ending offset. |
|
virtual |
Hook method that is called when the frame is resized.
This method updates any associated scrollbars.
newWidth | The new width of the view. |
newHeight | The new height of the view. |
Reimplemented from BView.
void BTextView::GetFontAndColor | ( | BFont * | _font, |
uint32 * | _mode, | ||
rgb_color * | _color = NULL , |
||
bool * | _sameColor = NULL |
||
) | const |
Fill out _font, _mode, _color and sameColor with the font and color of the current selection.
_font | The BFont to fill out. |
_mode | The font mode. |
_color | The rgb_color to fill out. |
_sameColor | Whether or not the color is the same as passed in. |
|
virtual |
Returns the min, max and preferred height for a given width.
[in] | width | The width you want the height to be calculated for. |
[out] | min | The minimum height that the layout will request. |
[out] | max | The maximum height that the layout will request. |
[out] | preferred | The preferred height for this width. |
Reimplemented from BView.
void BTextView::GetInsets | ( | float * | _left, |
float * | _top, | ||
float * | _right, | ||
float * | _bottom | ||
) | const |
Fills out the parameters with the objects's text insets.
_left | A pointer to set to the frame's left inset. |
_top | A pointer to set to the frame's top inset. |
_right | A pointer to set to the frame's right inset. |
_bottom | A pointer to set to the frame's bottom inset. |
|
virtual |
Fill out the preferred width and height of the view into the _width and _height parameters.
Derived classes should override this method to set the preferred size of object.
NULL
if you only want to get the other one.[out] | _width | Pointer to a float to store the width of the view. |
[out] | _height | Pointer to a float to store the height of the view. |
Reimplemented from BView.
Fills out _start and _end with the start and end offsets of the current selection.
_start | A pointer to an int32 to contain the selection's start offset. |
_end | A pointer to an int32 to contain the selection's end offset. |
Reports the suites of messages and specifiers that derived classes understand.
Reimplemented from BView.
Fills out buffer with the text of the BTextView starting at offset and grabbing at most length bytes.
You must provide a buffer that is large enough to hold at least length bytes.
offset | Where to start grabbing text from. |
length | The number of bytes of text to grab. |
buffer | A buffer to write the text to. |
void BTextView::GoToLine | ( | int32 | index | ) |
Moves the caret to the specified line.
index | The index of the line. |
|
virtual |
Returns whether the layout of the view can calculate a height for a given width.
Use GetHeightForWidth() to actually get the preferred size.
true
if the height values can be calculated, false
if they cannot.Reimplemented from BView.
bool BTextView::HasSystemColors | ( | ) | const |
Tests whether or not the text view is using system colors.
B_DOCUMENT_BACKGROUND_COLOR
for ViewUIColor() either untinted or B_DARKEN_1_TINT
B_DOCUMENT_BACKGROUND_COLOR
for LowUIColor() either untinted or B_DARKEN_1_TINT
B_DOCUMENT_TEXT_COLOR
for HighUIColor() untintedDoes not consider text color.
true
if using system colors either untinted or using uneditable tint false
otherwise.void BTextView::HideTyping | ( | bool | enabled | ) |
Enables and disables type hiding.
enabled | Pass in true to enable type hiding, false to disable it. |
Highlight the text enclosed within the given offsets.
startOffset | The start offset of the text to highlight. |
endOffset | The end offset of the text to highlight. |
void BTextView::Insert | ( | const char * | text, |
const text_run_array * | runs = NULL |
||
) |
Inserts text from the text buffer at the end of the BTextView with the font and color formats set by runs.
text | The text to insert. |
runs | The text styling to set, can be NULL . |
void BTextView::Insert | ( | const char * | text, |
int32 | length, | ||
const text_run_array * | runs = NULL |
||
) |
Inserts text from the text buffer up to length characters at the end of the BTextView with the font and color formats set by runs.
text | The text to insert. |
length | The number of bytes of text to insert. |
runs | The text styling to use, can be NULL . |
void BTextView::Insert | ( | int32 | offset, |
const char * | text, | ||
int32 | length, | ||
const text_run_array * | runs = NULL |
||
) |
Inserts text starting at the given offset from the text buffer up to length characters into the BTextView with the font and color formats set by runs.
offset | The position to start inserting text. |
text | The text to set. |
length | The number of bytes of text to insert. |
runs | The text styling to use, can be NULL . |
|
static |
Instantiates a BTextView object from the passed in archive.
archive | The BMessage object that the object is created from. |
bool BTextView::IsEditable | ( | ) | const |
Returns whether or not the text is editable.
true
if the text is editable, false
if the text is not editable.bool BTextView::IsResizable | ( | ) | const |
Returns whether or not the object is resizable.
true
if the object is resizable, false
otherwise.bool BTextView::IsSelectable | ( | ) | const |
Returns whether or not the text is selectable.
true
if the text is selectable, false
if the text is not selectable.bool BTextView::IsStylable | ( | ) | const |
Returns whether or not the object accepts multiple font styles.
true
if the object is accepts multiple font styles, false
otherwise.bool BTextView::IsTypingHidden | ( | ) | const |
Returns whether or not typing is hidden.
true
if typing is hidden, false
otherwise.
|
virtual |
Hook method that is called when a key is pressed while the view is the focus view of the active window.
bytes | The bytes of the key combination pressed. |
numBytes | The number of bytes in bytes. |
Reimplemented from BView.
|
protectedvirtual |
Hook method called when the layout is invalidated.
descendants | Whether or not child views have also been invalidated. |
Reimplemented from BView.
Returns the line number for the passed point.
point | The point to get the line number of. |
Returns the line number of the character at the given offset.
offset | The offset of the wanted character. |
float BTextView::LineHeight | ( | int32 | lineNumber = 0 | ) | const |
Returns the height of the line at the given lineNumber.
lineNumber | The index of the line to get the height of, 0-indexed. |
float BTextView::LineWidth | ( | int32 | lineNumber = 0 | ) | const |
Returns the width of the line at the given lineNumber.
lineNumber | The index of the line to get the width of, 0-indexed. |
void BTextView::MakeEditable | ( | bool | editable = true | ) |
Sets whether or not the text is editable.
Will automatically tint document colors to indicate uneditable if you have previously called AdoptSystemColors().
editable | Pass in true to set the text to be editable, false to set the object to be not editable. |
|
virtual |
Highlight or unhighlight the selection when the text view acquires or loses its focus state.
The focus view handles selections and KeyDown events when the the attached window is active. There can be only one focus view at a time per window.
When called with focus set to true
this method first calls MakeFocus() on the previously focused view with focus set to false
.
The focus doesn't automatically change when MouseDown() is called so calling MakeFocus() is the only way to make a view the focus view of a window. Classes derived from BView that can display the current selection, or that can accept pasted data should call MakeFocus() in their MouseDown() method to update the focus view of the window on click.
If the view isn't attached to a window this method has no effect.
focus | true to set focus, false to remove it. |
Reimplemented from BView.
Activates and deactivates automatic resizing.
The resizing mechanism is alternative to BView resizing. The container view (the one passed to this function) should not automatically resize itself when the parent is resized.
resize | Pass in true to set the the BTextView to automatically resize itself, false to disable automatic resizing. |
resizeView | The BTextView object's parent view that resizes itself. |
void BTextView::MakeSelectable | ( | bool | selectable = true | ) |
Sets whether or not the text is selectable.
selectable | Pass in true to set the text to be selectable, false to set the text to be not selectable. |
int32 BTextView::MaxBytes | ( | ) | const |
Returns the maximum number of bytes that the BTextView can contain.
|
virtual |
Return the maximum size of the view.
Reimplemented from BView.
|
virtual |
Hook method called with a message is received by the text view.
message | The message received by the associated looper. |
Reimplemented from BView.
|
virtual |
Return the minimum size of the view.
Reimplemented from BView.
|
virtual |
Hook method that is called when a mouse button is pushed down while the cursor is contained in the view.
where | The point on the screen where the mouse pointer is when the mouse button is pressed. |
Reimplemented from BView.
Hook method that is called whenever the mouse cursor enters, exits or moves inside the view.
where | The new location of the mouse in the view's coordinate system. |
code | One of the following:
|
dragMessage | If a drag-and-drop operation is taking place this is a pointer to a BMessage that holds the drag information, otherwise the pointer is NULL . |
Reimplemented from BView.
|
virtual |
Hook method that is called when a mouse button is released while the cursor is contained in the view.
This method stops asynchronous mouse tracking.
where | The point on the screen where the mouse pointer is when the mouse button is released. |
Reimplemented from BView.
Returns the offset at the passed in point.
point | The desired point. |
Returns the offset of the given line.
line | A line number. |
|
virtual |
Copy the text contained in the clipboard to the BTextView.
clipboard | A pointer to the clipboard. |
|
virtual |
Perform some action. (Internal Method)
This method is available to allow classes to be extended while maintaining binary compatibility.
The following perform codes are recognized:
PERFORM_CODE_MIN_SIZE:
PERFORM_CODE_MAX_SIZE:
PERFORM_CODE_PREFERRED_SIZE:
PERFORM_CODE_LAYOUT_ALIGNMENT:
PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH:
PERFORM_CODE_GET_HEIGHT_FOR_WIDTH:
PERFORM_CODE_SET_LAYOUT:
PERFORM_CODE_INVALIDATE_LAYOUT:
PERFORM_CODE_DO_LAYOUT:
PERFORM_CODE_GET_TOOL_TIP_AT:
PERFORM_CODE_ALL_UNARCHIVED:
PERFORM_CODE_ALL_ARCHIVED:
code | The perform code. |
_data | A pointer to store some data. |
Reimplemented from BView.
Returns the location of the character at the given offset.
offset | The offset of the character. |
_height | A pointer to write the height of the character. |
|
virtual |
Return the preferred size of the view.
Reimplemented from BView.
|
virtual |
Hook method that is called at a set interval.
This method is used to make the I-beam cursor blink.
An action is performed each time the App Server calls the Pulse() method. The pulse rate is set by SetPulseRate(). You can implement Pulse() to do anything you want. The default version does nothing. The pulse granularity is no better than once per 100,000 microseconds.
Reimplemented from BView.
|
virtual |
|
virtual |
Determine the proper handler for a scripting message.
message | The scripting message to determine the handler. |
index | The index of the specifier. |
specifier | The message which contains the specifier. |
what | The 'what' field of the specifier message. |
property | The name of the target property. |
Reimplemented from BView.
text_run_array * BTextView::RunArray | ( | int32 | startOffset, |
int32 | endOffset, | ||
int32 * | _size = NULL |
||
) | const |
Returns a text_run_array
for the text within the given offsets.
The returned text_run_array
belongs to the caller, so you must free it once you no longer need it.
startOffset | The text start offset. |
endOffset | The text end offset. |
_size | A pointer to an int32 to fill out the run array size. |
text_run_array
for the text in the given offsets.
|
virtual |
Scrolls the text so that the character at offset is visible.
offset | The offset of the character to scroll to. |
void BTextView::ScrollToSelection | ( | ) |
Scrolls the text so that the character that begins the selection is visible.
Selects the text contained within the given offsets.
startOffset | The offset where the text to select starts. |
endOffset | The offset where the text to select ends. |
void BTextView::SelectAll | ( | ) |
void BTextView::SetAlignment | ( | alignment | flag | ) |
Sets the way text is aligned within the frame.
Choices are:
B_ALIGN_LEFT
B_ALIGN_RIGHT
B_ALIGN_CENTER
flag | The text alignment to set. |
void BTextView::SetAutoindent | ( | bool | state | ) |
Sets whether or not new lines of text are automatically indented.
state | Pass in true to automatically indent the text, false to turn off automatic text indenting. |
void BTextView::SetColorSpace | ( | color_space | colors | ) |
void BTextView::SetDoesUndo | ( | bool | undo | ) |
Enables and disables the undo mechanism.
undo | Pass in true to enable the undo mechanism, false to disable it. |
void BTextView::SetFontAndColor | ( | const BFont * | font, |
uint32 | mode = B_FONT_ALL , |
||
const rgb_color * | color = NULL |
||
) |
Set font and text color of the current selection. The default mode is B_FONT_ALL
.
font | The BFont to set, a copy is made. |
mode | Font mode bitmap of one or more the following constants:
|
color | The text color to set, a copy is made. NULL to keep the current color. |
void BTextView::SetFontAndColor | ( | int32 | startOffset, |
int32 | endOffset, | ||
const BFont * | font, | ||
uint32 | mode = B_FONT_ALL , |
||
const rgb_color * | color = NULL |
||
) |
Set the font and color of a selection starting at startoffset ending at endOffset. The default mode is B_FONT_ALL
.
startOffset | The start offset. |
endOffset | The end offset. |
font | The BFont to set, a copy is made. |
mode | Font mode bitmap of one or more the following constants:
|
color | The text color to set, a copy is made. NULL to keep the current color. |
void BTextView::SetInsets | ( | float | left, |
float | top, | ||
float | right, | ||
float | bottom | ||
) |
Sets the insets within the bounds for the object's text frame.
left | The left inset to set. |
top | The top inset to set. |
right | The right inset to set. |
bottom | The bottom inset to set. |
void BTextView::SetMaxBytes | ( | int32 | max | ) |
Sets the maximum number of bytes that the BTextView can contain.
max | The maximum number of bytes to set. |
void BTextView::SetStylable | ( | bool | stylable | ) |
Sets whether or not the object accepts multiple font styles.
stylable | true to accept multiple font styles, false to NOT accept multiple font styles. |
void BTextView::SetTabWidth | ( | float | width | ) |
Sets the distance between tab stops in pixels.
width | The distance in pixel between tab stops to set. |
void BTextView::SetText | ( | BFile * | file, |
int32 | offset, | ||
int32 | length, | ||
const text_run_array * | runs = NULL |
||
) |
Copies text from the file starting at the given offset up to length characters replacing any text currently set in the BTextView with the font and color formats set by runs.
file | The file to set the text from. |
offset | The position in the file to start reading text. |
length | The number of bytes of text to read from the file. |
runs | Set the font and color formats of the new text if provided. Only applies if the BTextView permits multiple character formats. |
void BTextView::SetText | ( | const char * | text, |
const text_run_array * | runs = NULL |
||
) |
Copies text from the text buffer replacing any text currently set in the BTextView with the font and color formats set by runs.
text | The text to set. |
runs | Set the font and color formats of the new text if provided. Only applies if the BTextView permits multiple character formats. |
void BTextView::SetText | ( | const char * | text, |
int32 | length, | ||
const text_run_array * | runs = NULL |
||
) |
Copies text from the text buffer up to length characters replacing any text currently set in the BTextView with the font and color formats set by runs.
text must be at least length characters long. length may be set to 0 to clear the text from the BTextView.
text | The text to set. |
length | The maximum number of bytes of text to use. |
runs | Set the font and color formats of the new text if provided. Only applies if the BTextView permits multiple character formats. |
void BTextView::SetTextRect | ( | BRect | rect | ) |
Sets the object's text frame to the passed in rect.
rect | A BRect object to set the text frame to. |
void BTextView::SetWordWrap | ( | bool | wrap | ) |
Activate or deactivate word wrapping mode.
wrap | Pass in true to turn on word wrapping mode, false to turn off word wrapping mode. |
float BTextView::TabWidth | ( | ) | const |
Returns the tab width of the BTextView.
const char * BTextView::Text | ( | ) | const |
Returns the BTextView text as a byte array.
Returns the height of the text enclosed within the given lines.
startLine | The index of the starting line. |
endLine | The index of the ending line. |
int32 BTextView::TextLength | ( | ) | const |
BRect BTextView::TextRect | ( | ) | const |
Returns the BTextView's text frame.
|
virtual |
Hook method that is called when the window becomes the active window or gives up that status.
active | true when the window becomes activated, false when the window becomes deactivated. |
Reimplemented from BView.