The Interface Kit: BStringItem

Derived from: public BListItem

Declared in: be/interface/ListItem.h

Library: libbe.so


Overview

A BStringItem is an item of text that can appear in a BListView, including a BOutlineListView. It's the only concrete representative of the abstract BListItem class that the Interface Kit defines. It simply draws the item as a string of text.


Constructor and Destructor


BStringItem()


      BStringItem(const char *text, uint32 level = 0, bool expanded = true) 
      BStringItem(BMessage *archive) 

Initializes the BStringItem by making a copy of the text string passed as an argument. This is the string the item will display. The level and expanded arguments are passed unchanged to the BListItem constructor; see that function for an explanation.


~BStringItem()


      virtual ~BStringItem(void) 

Frees the text the item displays.


Static Functions


Instantiate()


      static BStringItem *Instantiate(BMessage *archive) 

Returns a new BStringItem object, allocated by new and created with the version of the constructor that takes a BMessage archive. However, if the archive message doesn't contain archived data for a BStringItem, Instantiate() returns NULL.

See also: BArchivable::Instantiate(), instantiate_object(), Archive()


Member Functions


Archive()


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

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

See also: BArchivable::Archive(), Instantiate() static function


DrawItem()


      virtual void DrawItem(BView *owner, BRect frame, bool complete = false) 

Draws the text string, dimming it if the item is disabled and highlighting it if the item is selected.

See also: BListItem::DrawItem()


SetText(), Text()


      virtual void SetText(const char *text) 

      const char *Text(void) const

These functions set and return the text that the BStringItem draws. SetText() copies the string it's passed. Text() returns a pointer to the string owned by the BStringItem.


Update()


      virtual void Update(BView *owner, const BFont *font)

Overrides the BListItem version of Update() to recalculate the width and height of the BStringItem and the placement of the text. The width of the item is based on the width of the owner BView. The height and text placement are based on the owner's font. The item must be tall enough to display the string in the current font.

See also: BListItem::Update()






The Be Book, in lovely HTML, for the BeOS Preview Release.

Copyright © 1997 Be, Inc. All rights reserved.

Be is a registered trademark; BeOS, BeBox, BeWare, GeekPort, the Be logo, and the BeOS logo are trademarks of Be, Inc.

Last modified September 18, 1997.