API Documentation

BStringView

BStringView

Constructor and Destructor

BStringView()

BStringView::BStringView(BRect frame, const char *name, const char *text, uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW)
BStringView::BStringView(BMessage *archive)

Initializes the BStringView by assigning it a text string and the system plain font (be_plain_font). The frame, name, resizingMode, and flags arguments are passed unchanged to the BView constructor.

The frame rectangle needs to be large enough to display the entire string in the current font. The string is drawn at the bottom of the frame rectangle and, by default, is aligned to the left side. A different horizontal alignment can be set by calling SetAlignment().

~BStringView()

virtual BStringView::~BStringView()

Frees the text string.

Hook Functions

AttachedToWindow()

virtual void BStringView::AttachedToWindow()

Sets the BStringView’s low color and its background view color to match the background color of its new parent view.

See also: BView::AttachedToWindow()

Draw()

virtual void BStringView::Draw(BRect updateRect)

Draws the string along the bottom of the BStringView’s frame rectangle in the current high color.

Member Functions

Archive()

virtual status_t BStringView::Archive(BMessage *archive, bool deep = true) const

Calls the inherited version of Archive(), then adds the string and its alignment to the BMessage archive.

SetAlignment(), Alignment()

void BStringView::SetAlignment(alignment flag)

alignment BStringView::Alignment() const

These functions align the string within the BStringView’s frame rectangle and return the current alignment. The alignment flag can be:

Constant

Description

B_ALIGN_LEFT

The string is aligned at the left side of the frame rectangle.

B_ALIGN_RIGHT

The string is aligned at the right side of the frame rectangle.

B_ALIGN_CENTER

The string is aligned so that the center of the string falls midway between the left and right sides of the frame rectangle.

The default is B_ALIGN_LEFT.

SetText(), Text()

void BStringView::SetText(const char *string)

const char *BStringView::Text() const

These functions set and return the text string that the BStringView draws. SetText() frees the previous string and copies string to replace it. Text() returns the null-terminated string.

Static Functions

Instantiate()

See BArchivable::Instantiate()

Archived Fields

The Archive() function adds the following fields to its BMessage argument:

Field

Type code

Description

_text

B_STRING_TYPE

Text displayed in the view (present only if it is not NULL).

_align

B_INT32_TYPE

Alignment of text in frame.