# The Interface Kit: BBox

Derived from: public BView

Declared in: be/interface/Box.h

Library: libbe.so

## Overview

A BBox is a purely cosmetic and organizational view that draws a labeled border around its (view) children. The border and label are drawn within the BBox's frame rectangle, thus:

- The current pen size of the view determines the width of the border; by default it's 1.0 coordinate unit.

- The label is drawn in the current font, which by default is the system bold font.

- The label is drawn in the current high color; the default high color is black.

## Constructor and Destructor

### 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)
          BBox(BMessage *archive)

Initializes the BBox by passing the frame, name, resizingMode, and flags to the BView constructor, and sets the style of its border to border. Three border styles are possible:

`B_PLAIN_BORDER` | The border is a simple line, lighter on the left and top than on the right and bottom so that the box looks raised from the surrounding surface.
`B_FANCY_BORDER` | The border is a fancier line that looks like a 3D groove inset into the surrounding surface of the view.
`B_NO_BORDER` | There is no border. This option is not that useful for a BBox object; it turns the box into something other than a box.

The constructor also sets the font for displaying the BBox's label to the system bold font (`be_bold_font`). However, the new object doesn't have a label; call `SetLabel()` to assign it one.

See also: `SetLabel()`

### ~BBox()

          virtual ~BBox()

Frees the label, if the BBox has one.

## Member Functions

### AttachedToWindow()

          virtual void AttachedToWindow(void)

Makes the BBox's background view color and its low color match the background color of its new parent.

### Border() see SetBorder()

### Draw()

          virtual void Draw(BRect updateRect)

Draws the box and its label. This function is called automatically in response to update messages.

### FrameResized()

          virtual void FrameResized(float width, float height)

Makes sure that the parts of the box that change when it's resized are redrawn.

See also: `BView::FrameResized()`

### Label() see SetLabel()

### SetBorder(), Border()

          virtual void SetBorder(border_style border)

          border_style Border(void) const

These functions set and return the style of border the BBox draws--`B_PLAIN_BORDER`, `B_FANCY_BORDER`, or `B_NO_BORDER`. The border style is initially set by the BBox constructor.

### SetLabel(), Label()

          void SetLabel(const char *string)

          const char *Label(void) const

These functions set and return the label that's displayed along the top edge of the box. `SetLabel()` copies string and makes it the BBox's label, freeing the previous label, if any. If string is `NULL`, it removes the current label and frees it.

`Label()` returns a pointer to the BBox's current label, or `NULL` if it doesn't have one.

## Archived Fields

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

Field | Type code | Meaning
"_label" | `B_STRING_TYPE` | The box's descriptive text.
"_style" | `B_BOOL_TYPE` | Exists and is `true` if the style is not `B_FANCY_BORDER`.

The Be Book, in lovely HTML, for BeOS Release 3.

Copyright © 1998 Be, Inc. All rights reserved.

Last modified March 26, 1998.