Public Member Functions | Static Public Member Functions | Protected Member Functions
BBox Class Reference

A rectangular view with a border and an optional label to group related subviews visually. More...

Inheritance diagram for BBox:
BView BHandler BArchivable

List of all members.

Public Member Functions

 BBox (BRect frame, const char *name=NULL, uint32 resizingMode=B_FOLLOW_LEFT|B_FOLLOW_TOP, uint32 flags=B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE_JUMP, border_style border=B_FANCY_BORDER)
 Constructs a named BBox object from a set of dimensions.
 BBox (const char *name, uint32 flags=B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE_JUMP, border_style border=B_FANCY_BORDER, BView *child=NULL)
 Constructs a named BBox object with its dimensions defined automatically by the Layout API.
 BBox (border_style border, BView *child)
 Constructs an anonymous BBox object with a defined border style and child view.
 BBox (BMessage *archive)
 Constructs a BBox object from an archive message.
virtual ~BBox ()
 Destructor method.
virtual status_t AllArchived (BMessage *archive) const
 Method relating to the use of BArchiver.
virtual void AllAttached ()
 Similar to AttachedToWindow() but this method is triggered after all child views have already been attached to a window.
virtual void AllDetached ()
 Similar to AttachedToWindow() but this method is triggered after all child views have already been detached from a window.
virtual status_t AllUnarchived (const BMessage *archive)
 Method relating to the use of BUnarchiver.
virtual status_t Archive (BMessage *archive, bool deep=true) const
 Archives the object into archive.
virtual void AttachedToWindow ()
 Hook method that is called when the object is attached to a window.
border_style Border () const
 Gets the current border_style.
virtual void DetachedFromWindow ()
 Hook method that is called when the object is detached from a window.
virtual void Draw (BRect updateRect)
 Draws the area of the box that intersects updateRect.
virtual void DrawAfterChildren (BRect r)
 Perform any drawing that needs to be done after child view have already been drawn.
virtual void FrameMoved (BPoint newLocation)
 Hook method that gets called when the view is moved.
virtual void FrameResized (float width, float height)
 Hook method that gets called when the BBox object is resized.
BLayoutGetLayout () const
 Get the layout of the view.
virtual void GetPreferredSize (float *_width, float *_height)
 Fill out the preferred width and height of the box into the _width and _height parameters.
virtual status_t GetSupportedSuites (BMessage *message)
 Reports the suites of messages and specifiers that derived classes understand.
BRect InnerFrame ()
 Gets the frame rectangle just inside the border of the box.
virtual void KeyDown (const char *bytes, int32 numBytes)
 Hook method that is called when a keyboard key is pressed.
virtual void KeyUp (const char *bytes, int32 numBytes)
 Hook method that is called when a keyboard key is released.
const char * Label () const
 Gets the text of the box's label.
BViewLabelView () const
 Gets the BView representing the label.
virtual void MakeFocus (bool focused=true)
 Gives or removes focus from the control.
virtual BSize MaxSize ()
 Gets the maximum possible size of the BBox object.
virtual void MessageReceived (BMessage *message)
 Handle message that has been received by the associated looper.
virtual BSize MinSize ()
 Gets the minimum possible size of the BBox object.
virtual void MouseDown (BPoint point)
 Hook method that is called when a mouse button is pressed.
virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *dragMessage)
 Hook method that is called when the mouse is moved.
virtual void MouseUp (BPoint point)
 Hook method that is called when a mouse button is released.
virtual status_t Perform (perform_code d, void *arg)
 Perform some action. (Internal Method)
virtual BSize PreferredSize ()
 Returns the preferred size of the box.
virtual void Pulse ()
 Hook method that gets invoked when the view receives a B_PULSE message.
virtual void ResizeToPreferred ()
 Resizes the box to its preferred dimensions.
virtual BHandlerResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 what, const char *property)
 Determine the proper handler for a scripting message.
virtual void SetBorder (border_style border)
 Sets the border_style.
void SetExplicitAlignment (BAlignment alignment)
 Set this item's explicit alignment, to be used by Alignment().
void SetExplicitMaxSize (BSize size)
 Set this item's explicit max size, to be used by MaxSize().
void SetExplicitMinSize (BSize size)
 Set this item's explicit min size, to be used by MinSize().
void SetExplicitPreferredSize (BSize size)
 Set this item's explicit preferred size, to be used by PreferredSize().
void SetLabel (const char *string)
 Sets the box's label text.
status_t SetLabel (BView *viewLabel)
 Sets the label from a BView.
virtual void SetLayout (BLayout *layout)
 Set the layout of the view.
float TopBorderOffset ()
 Gets the distance from the very top of the box to the top border line in pixels.
virtual void WindowActivated (bool active)
 Hook method that is called when the attached window becomes activated or deactivated.
Methods triggering or related to laying out this BLayout.
BLayoutContext * LayoutContext () const
 Returns the BLayoutContext this BLayout is currently operating in, or NULL.
Core Handler Functionality
BLooperLooper () 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.
BHandlerNextHandler () const
 Return the next hander in the chain to which the message is passed on.
Message Filtering
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.
BListFilterList ()
 Return a pointer to the list of filters.
Locking

This class provides some utility functions to look the looper associated with this handler.

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.
Observing

Handlers can function as state machines, which emit messages to observers when the state changes. Use the following methods to subscribe to these notifications.

Note that there is a semantic difference between the two StartWatching() methods. The overloaded method that accepts a BHandler, expects as argument an observer that watches this handler. The method that accepts a BMessenger, expects a target that emits the state changes to this handler.

status_t StartWatching (BMessenger target, uint32 what)
 Subscribe this handler to watch a specific state change of a target.
status_t StartWatching (BHandler *observer, uint32 what)
 Subscribe an observer for a specific state change of this handler.
status_t StartWatchingAll (BMessenger target)
 Subscribe this handler to watch a target for all events.
status_t StartWatchingAll (BHandler *observer)
 Subscribe an observer for a all state changes.
status_t StopWatching (BMessenger target, uint32 what)
 Unsubscribe this handler from watching a specific state.
status_t StopWatching (BHandler *observer, uint32 what)
 Unsubscribe an observer from watching a specific state.
status_t StopWatchingAll (BMessenger target)
 Unsubscribe this handler from watching all states.
status_t StopWatchingAll (BHandler *observer)
 Unsubscribe an observer from watching all states.
Emitting State Changes

If your handler functions as a state machine, and it has observers (which subscribed using the StartWatching() method), you can emit these state changes.

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.

Static Public Member Functions

static BArchivableInstantiate (BMessage *archive)
 Creates a new object from an archive.

Protected Member Functions

virtual void DoLayout ()
 Lays out the box moving everything into its appropriate position.
virtual void LayoutInvalidated (bool descendants=false)

Detailed Description

A rectangular view with a border and an optional label to group related subviews visually.

A basic BBox looks like this:

B_FANCY_BORDER.png

A box's label can either be composed of text or it can be a view such as a checkbox or dropdown box. See SetLabel() for more details on setting the box's label.


Constructor & Destructor Documentation

BBox::BBox ( BRect  frame,
const char *  name = NULL,
uint32  resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32  flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
border_style  border = B_FANCY_BORDER 
)

Constructs a named BBox object from a set of dimensions.

Note:
This is the only constructor that can be used if the box is to be inserted in a window that doesn't use the layout system.
Parameters:
frameThe bounds of the box.
nameThe name of the box.
resizingModeDefines the behavior of the box as the parent view resizes. See BView for details.
flagsBehavior flags for the box. See BView for details.
borderThe border_style of the box.
BBox::BBox ( const char *  name,
uint32  flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
border_style  border = B_FANCY_BORDER,
BView child = NULL 
)

Constructs a named BBox object with its dimensions defined automatically by the Layout API.

Parameters:
nameThe name of the box.
flagsBehavior flags for the box. See BView for details.
borderThe border_style of the box.
childAdds an initial child to the Box object. See the Layout API for details.
BBox::BBox ( border_style  border,
BView child 
)

Constructs an anonymous BBox object with a defined border style and child view.

There can only be a single child view. This view can, however, act as a nesting container if you need to show more items inside the box.

BBox::~BBox ( ) [virtual]

Destructor method.

Calling the destructor will also free the memory used by the box's label if it has one.

BBox::BBox ( BMessage archive)

Constructs a BBox object from an archive message.

This method is usually not called directly. If you want to build a BBox object from a message you should call Instantiate() which can handle errors properly.

If the archive deep, the BBox object will also unarchive each of its child views recursively.

Parameters:
archiveThe archive message to restore from.

Member Function Documentation

void BHandler::AddFilter ( BMessageFilter filter) [virtual, inherited]

Add filter as a prerequisite to this handler.

If the handler is associated with a looper, this looper needs to be locked in order for this operation to succeed.

Note that the filter is not copied, rather a pointer to the filter is stored. As such, you need to make sure that the filter object exists as long as it is added to this handler.

See also:
RemoveFilter(), SetFilterList()
virtual status_t BView::AllArchived ( BMessage into) const [virtual, inherited]

Method relating to the use of BArchiver.

This hook function is called once the first BArchiver that was created in an archiving session is either destroyed, or has its Finish() method called. Implementations of this method can be used, in conjunction with BArchiver::IsArchived(), to reference objects in your archive that you do not own, depending on whether or not those objects were archived by their owners. Implementations of this method should call the implementation of their parent class, the same as for the Archive() method.

Warning:
To guarantee that your AllArchived() method will be called during archival, you must create a BArchiver object in your Archive() implementation.
You should archive any objects you own in your Archive() method implementation, and NOT your AllArchived() method.
See also:
BArchiver BArchiver::Finish()

Reimplemented from BArchivable.

virtual status_t BView::AllUnarchived ( const BMessage archive) [virtual, inherited]

Method relating to the use of BUnarchiver.

This hook function is called triggered in the BUnarchiver::Finish() method. In this method, you can rebuild references to objects that may be direct children of your object, or may be children of other objects. Implementations of this method should call the implementation of their parent class, the same as for the Archive() method.

Warning:
To guarantee that your AllUnarchived() method will be called during unarchival, you must create a BUnarchiver object in your archive constructor.
See also:
BUnarchiver, BUnarchiver::Finish()

Reimplemented from BArchivable.

virtual status_t BBox::Archive ( BMessage archive,
bool  deep = true 
) const [virtual]

Archives the object into archive.

Parameters:
archiveThe target archive that the data will go into.
deepWhether or not to recursively archive child views.
Return values:
B_OKThe archive operation was successful.
B_BAD_VALUENULL archive message.
B_ERRORThe archive operation failed.
See also:
BArchivable::Archive()

Reimplemented from BView.

void BBox::AttachedToWindow ( ) [virtual]

Hook method that is called when the object is attached to a window.

This method overrides BView::AttachedToWindow() to set the background color of the box to the background of its parent view.

If you are using the layout system, the BBox is also resized according to the layout of the parent view.

See also:
BView::AttachedToWindow()

Reimplemented from BView.

border_style BBox::Border ( ) const

Gets the current border_style.

Possible border_style values include:

  • B_PLAIN_BORDER A single 1-pixel line border.
  • B_FANCY_BORDER The default, beveled look.
  • B_NO_BORDER Used to make a borderless box.
Returns:
The border_style of the box.
void BBox::DoLayout ( ) [protected, virtual]

Lays out the box moving everything into its appropriate position.

This only works if the BBox object was constructed using the Layout API, i.e. it was created with one of the BRect-less constructors.

Once the size of the box is known from laying out its parent views, this method is called so the box can adjust the position and size of the label, eventually truncating the label text if there is not enough space. The exact border positions are also computed, then the child view is also laid out if its size constraints change.

Reimplemented from BView.

void BBox::Draw ( BRect  updateRect) [virtual]

Draws the area of the box that intersects updateRect.

This is an hook method called by the Interface Kit, you don't have to call it yourself. If you need to forcefully redraw the view, consider calling Invalidate() instead.

Parameters:
updateRectThe rectangular area to be drawn.

Reimplemented from BView.

void BView::DrawAfterChildren ( BRect  r) [virtual, inherited]

Perform any drawing that needs to be done after child view have already been drawn.

Parameters:
rThe rectangular area to be drawn.
BList * BHandler::FilterList ( ) [inherited]

Return a pointer to the list of filters.

Returns:
A pointer to the list of filters. Do not manipulate the list of filters directly, but use the methods provided by this class, in order to maintain internal consistency.
See also:
AddFilter(), RemoveFilter(), SetFilterList().
virtual void BBox::FrameMoved ( BPoint  newPosition) [virtual]

Hook method that gets called when the view is moved.

Parameters:
newPositionThe point of the top left corner of the frame that the view has been moved to.

Reimplemented from BView.

void BBox::FrameResized ( float  width,
float  height 
) [virtual]

Hook method that gets called when the BBox object is resized.

This method may be called either because the window in which the BBox object was resized, or because the window layout was otherwise altered.

This method recomputes the layout of the BBox (including label and contents) and makes it redraw as necessary.

Reimplemented from BView.

BLayout * BView::GetLayout ( ) const [inherited]

Get the layout of the view.

Returns:
The layout of the view.
void BBox::GetPreferredSize ( float *  _width,
float *  _height 
) [virtual]

Fill out the preferred width and height of the box into the _width and _height parameters.

Note:
Either the _width or _height parameter may be set to NULL if you only want to get the other one.

The size is computed from the child view sizes, unless it was explicitly set for the BBox (which can be done only if the BBox is configured to use the Layout API).

Parameters:
[out]_widthPointer to a float to store the width of the view.
[out]_heightPointer to a float to store the height of the view.

Reimplemented from BView.

BRect BBox::InnerFrame ( )

Gets the frame rectangle just inside the border of the box.

Warning:
This method is not part of the BeOS R5 API and is not yet finalized.
Returns:
A BRect set to the dimensions of the box's inside border.
static BArchivable * BBox::Instantiate ( BMessage archive) [static]

Creates a new object from an archive.

If the message is a valid object then the instance created from the passed in archive will be returned. Otherwise this method will return NULL.

Parameters:
archiveThe archive message.
Returns:
An instance of the object if archive is valid or NULL.
See also:
BArchivable::Instantiate()

Reimplemented from BView.

void BView::KeyDown ( const char *  bytes,
int32  numBytes 
) [virtual, inherited]

Hook method that is called when a keyboard key is pressed.

Parameters:
bytesThe bytes of the key combination pressed.
numBytesThe number of bytes in bytes.

Reimplemented in BTextView, BListView, BColorControl, BControl, BCheckBox, BButton, and BChannelControl.

void BView::KeyUp ( const char *  bytes,
int32  numBytes 
) [virtual, inherited]

Hook method that is called when a keyboard key is released.

Parameters:
bytesThe bytes of the key combination pressed.
numBytesThe number of bytes in bytes.
const char * BBox::Label ( ) const

Gets the text of the box's label.

This only works if the label is set as text. If you set the label to a BView, you have to get the text by other means, likely starting with LabelView.

Returns:
The label text of the BBox if the box has a text label or NULL otherwise.
BView * BBox::LabelView ( ) const

Gets the BView representing the label.

Returns:
a pointer to a BView object.
virtual void BBox::LayoutInvalidated ( bool  descendants = false) [protected, virtual]

Hook method called when this layout becomes invalid. This is a good place to clear any caches your object might hold.

Reimplemented from BView.

bool BHandler::LockLooper ( ) [inherited]

Lock the looper associated with this handler.

Return values:
trueThe looper is locked.
falseThere was an error acquiring the lock.
See also:
LockLooperWithTimeout(), UnlockLooper()
status_t BHandler::LockLooperWithTimeout ( bigtime_t  timeout) [inherited]

Lock the looper associated with this handler, with a time out value.

Parameters:
timeoutThe time to wait for acquiring the lock in microseconds. You may also use B_INFINITE_TIMEOUT, in which this method will wait as long as it takes to acquire the lock.
Return values:
B_OKLocking succeeded.
B_BAD_VALUEThis handler is not associated with a looper (anymore).
B_TIMED_OUTThe time specified in timeout has passed without locking the looper.
See also:
LockLooper(), UnlockLooper()
BLooper * BHandler::Looper ( ) const [inherited]

Return a pointer to the looper that this handler is associated with.

Returns:
If the handler is not yet associated with a looper, it will return NULL.
See also:
BLooper::AddHandler()
LockLooper()
virtual void BBox::MakeFocus ( bool  focusState = true) [virtual]

Gives or removes focus from the control.

Parameters:
focusStatetrue to set focus, false to remove it.

Reimplemented from BView.

BSize BBox::MaxSize ( ) [virtual]

Gets the maximum possible size of the BBox object.

The maximum size depends on the maximize size of the child views.

Returns:
The maximum possible size of the BBox as a BSize.

Reimplemented from BView.

virtual void BBox::MessageReceived ( BMessage message) [virtual]

Handle message that has been received by the associated looper.

This method is reimplemented by subclasses. If the messages that have been received by a looper pass through the filters, then they end up in the MessageReceived() methods.

The example below shows a very common way to handle message. Usually, this involves parsing the BMessage::what constant and then perform an action based on that.

void
ShowImageApp::MessageReceived(BMessage *message)
{
    switch (message->what) {
        case MSG_FILE_OPEN:
            fOpenPanel->Show();
            break;

        case B_CANCEL:
            // File open panel was closed,
            // start checking count of open windows.
            StartPulse();
            break;
        
        default:
            // We do not handle this message, pass it on to the base class.
            BApplication::MessageReceived(message); 
            break;
    }
}

If your handler cannot process this message, you should pass it on to the base class. Eventually, it will reach the base implementation, which will reply with B_MESSAGE_NOT_UNDERSTOOD.

Attention:
If you want to keep or manipulate the message, have a look at BLooper::DetachCurrentMessage() to receive ownership of the message.
Parameters:
messageThe message that needs to be handled.

Reimplemented from BView.

BSize BBox::MinSize ( ) [virtual]

Gets the minimum possible size of the BBox object.

Drawing the box at this size ensures the label and the child view are visible. Reducing the size even more would mean that a view would not be visible.

Reimplemented from BView.

virtual void BBox::MouseDown ( BPoint  where) [virtual]

Hook method that is called when a mouse button is pressed.

Parameters:
whereThe point on the screen where to mouse pointer is when the mouse button is pressed.

Reimplemented from BView.

virtual void BBox::MouseUp ( BPoint  where) [virtual]

Hook method that is called when a mouse button is released.

Parameters:
whereThe point on the screen where to mouse pointer is when the mouse button is released.

Reimplemented from BView.

const char * BHandler::Name ( ) const [inherited]

Return the name of this handler.

See also:
SetName()
BHandler * BHandler::NextHandler ( ) const [inherited]

Return the next hander in the chain to which the message is passed on.

See also:
SetNextHandler()
virtual status_t BBox::Perform ( perform_code  code,
void *  _data 
) [virtual]

Perform some action. (Internal Method)

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:
Parameters:
codeThe perform code.
_dataA pointer to store some data.
Returns:
A status code.
See also:
BHandler::Perform()

Reimplemented from BView.

BSize BBox::PreferredSize ( ) [virtual]

Returns the preferred size of the box.

This method works the same as GetPreferredSize, but uses the more convenient BSize object.

Returns:
The minimum possible size of the BBox as a BSize.

Reimplemented from BView.

void BView::Pulse ( ) [virtual, inherited]

Hook method that gets invoked when the view receives a B_PULSE message.

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.

See also:
SetPulseRate()

Reimplemented in BTextView.

bool BHandler::RemoveFilter ( BMessageFilter filter) [virtual, inherited]

Remove filter from the filter list.

If the handler is associated with a looper, this looper needs to be locked in order for this operation to succeed.

Note that the filter is not deleted, merely removed from the list. You need to take care of the memory yourself.

Return values:
trueThe filter was in the filter list and is removed.
falseThe filter was not found in the filter list.
See also:
AddFilter(), FilterList()
void BBox::ResizeToPreferred ( ) [virtual]

Resizes the box to its preferred dimensions.

Note:
This only works in the non-layout mode, as it forces the resizing.

Reimplemented from BView.

void BHandler::SendNotices ( uint32  what,
const BMessage msg = NULL 
) [virtual, inherited]

Emit a state change to the observers.

The actual state (specified by what) will not be transmitted. This is merely for internal bookkeeping. It is not entirely unimaginable that you still want to inform the observers of what actually took place. You can use the msg to transmit this, and any other data you want. Note that the message will be copied and slightly altered: the what member of the message will be B_OBSERVER_NOTICE_CHANGE, and the what constant you specified will be stored in the B_OBSERVE_ORIGINAL_WHAT label.

Parameters:
whatThe identifier of the state.
msgAny data associated with the state change. You retain ownership of this data, so make sure you dispose it when you are done.
void BBox::SetBorder ( border_style  border) [virtual]

Sets the border_style.

Possible border_style values include:

  • B_PLAIN_BORDER A single 1-pixel line border.
  • B_FANCY_BORDER The default, beveled look.
  • B_NO_BORDER Used to make a borderless box.
Parameters:
borderThe border_style to set.
void BView::SetExplicitAlignment ( BAlignment  alignment) [inherited]

Set this item's explicit alignment, to be used by Alignment().

See also:
BAbstractLayout::SetExplicitAlignment()
void BView::SetExplicitMaxSize ( BSize  size) [inherited]

Set this item's explicit max size, to be used by MaxSize().

See also:
BAbstractLayout::SetExplicitMaxSize()
void BView::SetExplicitMinSize ( BSize  size) [inherited]

Set this item's explicit min size, to be used by MinSize().

See also:
BAbstractLayout::SetExplicitMinSize()
void BView::SetExplicitPreferredSize ( BSize  size) [inherited]

Set this item's explicit preferred size, to be used by PreferredSize().

See also:
BAbstractLayout::SetExplicitPreferredSize()
void BHandler::SetFilterList ( BList filters) [virtual, inherited]

Set the internal list of filters to filters.

If the handler is associated with a looper, this looper needs to be locked in order for this operation to succeed.

The internal list will be replaced with the new list of filters. All the existing filters will be deleted.

See also:
AddFilter(), FilterList()
void BBox::SetLabel ( const char *  string)

Sets the box's label text.

Below is an example of a box with some simple text label:

BBox_example.png

The code to create a box with a text label looks like this:

fIconBox = new BBox("Icon Box");
fIconBox->SetLabel("Icon");
Parameters:
stringThe label text string to set as the box's title.
status_t BBox::SetLabel ( BView viewLabel)

Sets the label from a BView.

This version of SetLabel() provides for building a BBox object with a control used in place of the text label. You can pass in any type of BView derived control for this such as a BPopupMenu or BCheckBox.

An example of a box with a checkbox view is shown below:

BBox_with_checkbox.png

The code to create such a box looks like this:

fVirtualMemoryEnabledCheckBox = new BCheckBox("Virtual memory check box",
    "Enable virtual memory", new BMessage(kVirtualMemoryEnabled));

BBox* fVirtualMemoryBox = new BBox("Virtual memory box");
fVirtualMemoryBox->SetLabel(fVirtualMemoryEnabledCheckBox);
Parameters:
viewLabelA BView.
Returns:
B_OK
void BView::SetLayout ( BLayout layout) [virtual, inherited]

Set the layout of the view.

Parameters:
layoutThe layout to set.

Reimplemented in BColorControl.

void BHandler::SetName ( const char *  name) [inherited]

Set or change the name of this handler.

See also:
Name()
void BHandler::SetNextHandler ( BHandler handler) [virtual, inherited]

Set the next handler in the chain that the message is passed on to if this handler cannot process it.

This method has three requirements:

  1. This handler should belong to a looper.
  2. The looper needs to be locked. See LockLooper().
  3. The handler that you pass must be associated with the same looper.

Failure to meet any of these requirements will result in your application crashing.

By default, the handlers are chained in order that they were associated to a looper with BLooper::AddHander().

See also:
NextHandler()
status_t BHandler::StartWatching ( BMessenger  target,
uint32  what 
) [inherited]

Subscribe this handler to watch a specific state change of a target.

Use this method to subscribe messengers to watch state changes in this handler, this also means that observers from other teams can be subscribed.

// Handler B watches Handler A
BHandler A, B;
BMessenger messengerA(&A)

B.StartWatching(messengerA, kNetworkConnection);
Parameters:
targetThe messenger from which the notifications would be received.
whatThe state that needs to be watched.
Returns:
During the call of this method, a notification will be transmitted using the target. If this works, then this method will return B_OK.
See also:
StartWatchingAll(BMessenger), StopWatching(BMessenger, uint32)
status_t BHandler::StartWatching ( BHandler observer,
uint32  what 
) [inherited]

Subscribe an observer for a specific state change of this handler.

Use this method to subscribe observers to watch this handler. State changes of this handler that match the what argument, will be sent.

// Handler B wants to observe Handler A
BHandler A, B;

A.StartWatching(&B, kNetworkConnection);

Since pointers to handlers can only exist in the local namespace, have a look at StartWatching(BMessenger, uint32) for inter-team watching.

Parameters:
observerThe observer for this handler.
whatThe state that needs to be watched.
Returns:
During the call of this method, a notification will be transmitted using the observer. If this works, then this method will return B_OK.
See also:
StartWatchingAll(BHandler*), StopWatching(BHandler*, uint32)
status_t BHandler::StartWatchingAll ( BMessenger  target) [inherited]

Subscribe this handler to watch a target for all events.

This method performs the same task as StartWatching(BMessenger, uint32), but it will subscribe to all the state changes the target knows.

See also:
StartWatching(BMessenger, uint32), StopWatchingAll(BMessenger)
status_t BHandler::StartWatchingAll ( BHandler observer) [inherited]

Subscribe an observer for a all state changes.

This method performs the same task as StartWatching(BHandler, uint32), but it will subscribe the observer to all the state changes this handler tracks.

See also:
StartWatching(BHandler*, uint32), StopWatchingAll(BHandler*)
status_t BHandler::StopWatching ( BMessenger  target,
uint32  what 
) [inherited]

Unsubscribe this handler from watching a specific state.

This method will unsubscribe this handler from watching a specific event in a target.

See also:
StartWatching(BMessenger, uint32)
status_t BHandler::StopWatching ( BHandler handler,
uint32  what 
) [inherited]

Unsubscribe an observer from watching a specific state.

This method will unsubscribe the handler from watching a specific event.

See also:
StartWatching(BHandler*, uint32)
status_t BHandler::StopWatchingAll ( BMessenger  target) [inherited]

Unsubscribe this handler from watching all states.

This method will unsubscribe the target from watching all state changes.

See also:
StartWatchingAll(BMessenger)
status_t BHandler::StopWatchingAll ( BHandler handler) [inherited]

Unsubscribe an observer from watching all states.

This method will unsubscribe the handler from watching all state changes.

See also:
StartWatchingAll(BHandler*)
float BBox::TopBorderOffset ( )

Gets the distance from the very top of the box to the top border line in pixels.

Warning:
This method is not part of the BeOS R5 API and is not yet finalized.

The distance may vary depending on the text or view used as label and the font settings. The border is drawn center-aligned with the label. This method can be used to line up two boxes visually if one has a label and the other does not.

Returns:
The distance from the very top of the box to the top border line in pixels as a float.
virtual void BBox::WindowActivated ( bool  state) [virtual]

Hook method that is called when the attached window becomes activated or deactivated.

Parameters:
statetrue if the window becomes activated, false if the window becomes deactivated.

Reimplemented from BView.


The Haiku Book pre-R1 - BBox Class Reference
Generated on Sat May 18 2013 by Doxygen 1.7.5.1