Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
BStringItem Class Reference

A list item of a text string used as a member of a BListView or BOutlineListView. More...

Inherits BListItem.

Public Member Functions

 BStringItem (BMessage *archive)
 Archive constructor.
 
 BStringItem (const char *text, uint32 outlineLevel=0, bool expanded=true)
 Creates a new BStringItem object which displays the text string.
 
virtual ~BStringItem ()
 Destructor, frees the memory used by the string.
 
virtual void DrawItem (BView *owner, BRect frame, bool complete=false)
 Hook method called when the string item is drawn.
 
virtual status_t Perform (perform_code code, void *arg)
 Performs an action give a perform_code and arg. (Internal Method)
 
virtual void SetText (const char *text)
 Sets the text string displayed by the item. The memory used by the old string is freed.
 
const char * Text () const
 
virtual void Update (BView *owner, const BFont *font)
 Hook method that's called when the owner changes.
 
- Public Member Functions inherited from BListItem
 BListItem (BMessage *archive)
 Create a new list item from archived message.
 
 BListItem (uint32 outlineLevel=0, bool expanded=true)
 Create a new list item with the specified level.
 
virtual ~BListItem ()
 Destroy the list item freeing any memory used.
 
void Deselect ()
 Unselect the list item.
 
float Height () const
 Return the height of the list item.
 
bool IsEnabled () const
 Returns whether or not the list item is currently enabled.
 
bool IsExpanded () const
 Returns whether or not the list item is currently expanded.
 
bool IsSelected () const
 Return whether or not the list item is currently selected.
 
uint32 OutlineLevel () const
 Returns the current outline level of the list item. This only makes sense if the list item is part of a BOutlineListView.
 
virtual status_t Perform (perform_code code, void *arg)
 Performs an action give a perform_code and arg. (Internal Method)
 
void Select ()
 Select the list item.
 
virtual void SetEnabled (bool enabled)
 Enable or disable the list item.
 
void SetExpanded (bool expanded)
 Set the expanded state of the list item. This only makes sense if the list item is part of a BOutlineListView.
 
void SetHeight (float height)
 Set the height of the list item to height.
 
void SetOutlineLevel (uint32 level)
 Set the outline level of the list item.
 
void SetWidth (float width)
 Set the width of the list item to width.
 
virtual void Update (BView *owner, const BFont *font)
 Hook method that's called when the owner changes.
 
float Width () const
 Return the width of the list item.
 
- Public Member Functions inherited from BArchivable
 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

float BaselineOffset () const
 Returns the offset from the top of the frame to the base line of the text.
 

Archiving

virtual status_t Archive (BMessage *archive, bool deep=true) const
 Archives the the BStringItem object into the archive message.
 
static BArchivableInstantiate (BMessage *archive)
 Creates a new BStringItem object from an archive message.
 

Additional Inherited Members

- Static Public Member Functions inherited from BArchivable
static BArchivableInstantiate (BMessage *archive)
 Static member to restore objects from messages.
 

Detailed Description

A list item of a text string used as a member of a BListView or BOutlineListView.

Since
BeOS R3

Constructor & Destructor Documentation

◆ BStringItem() [1/2]

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

Creates a new BStringItem object which displays the text string.

The level and expanded parameters only apply to string items attached to a BOutlineListView and are passed unchanged to the BListItem constructor.

Parameters
textThe text to display.
levelThe level of the item in a BOutlineListView.
expandedWhether or not the item is expanded in a BOutlineListView.
Since
BeOS R3

◆ BStringItem() [2/2]

BStringItem::BStringItem ( BMessage archive)

Archive constructor.

Parameters
archiveThe message archive to construct the string item from.
Since
BeOS R3

◆ ~BStringItem()

BStringItem::~BStringItem ( )
virtual

Destructor, frees the memory used by the string.

Since
BeOS R3

Member Function Documentation

◆ Archive()

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

Archives the the BStringItem object into the archive message.

Parameters
archiveA pointer to the BMessage to archive the object into.
deepThis parameter has no effect for this class.
Returns
A status code, B_OK if everything went well or an error code otherwise.
Return values
B_OKThe object was archived successfully.
B_NO_MEMORYRan out of memory while archiving the object.
Since
BeOS R3

Reimplemented from BListItem.

◆ BaselineOffset()

float BStringItem::BaselineOffset ( ) const
protected

Returns the offset from the top of the frame to the base line of the text.

The baseline is the line upon which the letters "sit" and below which descenders extend. This value is set in the Update() method.

This may be overridden by derived classes to set the base line offset.

Returns
The offset to the baseline of the text as a float.
Since
Haiku R1

◆ DrawItem()

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

Hook method called when the string item is drawn.

The background is drawn either B_LIST_BACKGROUND_COLOR or B_LIST_SELECTED_BACKGROUND_COLOR depending on whether the item is selected or not.

Similarly, the text is drawn either B_LIST_ITEM_TEXT_COLOR or B_LIST_SELECTED_ITEM_TEXT_COLOR.

The text is drawn in a lighter color if the item is disabled to indicate that it may not be selected. A darker color is used instead if B_LIST_BACKGROUND_COLOR is set to a dark color.

Parameters
ownerThe string item's parent.
frameThe frame to draw in.
completeWhether or not to draw the background in addition to the item's contents.
See also
IsSelected()
IsEnabled()
Since
BeOS R3

Implements BListItem.

◆ Instantiate()

BArchivable * BStringItem::Instantiate ( BMessage archive)
static

Creates a new BStringItem object from an archive message.

Returns
A newly created BStringItem object or NULL if the message doesn't contain an archived BStringItem.
Since
BeOS R3

◆ Perform()

virtual status_t BStringItem::Perform ( perform_code  d,
void *  arg 
)
virtual

Performs an action give a perform_code and arg. (Internal Method)

Parameters
dThe perform code.
argA pointer to some data to perform on.
Returns
A status code.
Since
Haiku R1

Reimplemented from BListItem.

◆ SetText()

void BStringItem::SetText ( const char *  text)
virtual

Sets the text string displayed by the item. The memory used by the old string is freed.

Parameters
textThe text string to set in a C-string.
Since
BeOS R3

◆ Text()

const char * BStringItem::Text ( ) const
Returns
The text set to the item.
the text set to the item as a C-string.
Since
BeOS R3

◆ Update()

virtual void BStringItem::Update ( BView owner,
const BFont font 
)
virtual

Hook method that's called when the owner changes.

This method gets called when the list item is added to the list view.

The default implementation sets the width of the list item to the width of owner and sets the height to fit font.

Parameters
ownerThe list item's new owner.
fontThe font set to the list item's current owner.
Since
BeOS R3

Reimplemented from BListItem.