The Interface Kit: BBox

Derived from: public BView

Declared in: <interface/Box.h>


Overview

A BBox draws a labeled border around other views. It serves only to label those views and organize them visually. It doesn't respond to messages.

The border is drawn inside the edge of the view's frame rectangle. If the BBox has a label, the border at the top of box is broken where the label appears (and the border is inset from the top somewhat to make room for the label).

The current pen size of the view determines the width of the border, which by default is 1.0 coordinate unit. This size produces the best results, especially for fancy borders. If you make the border thicker, it will be inset somewhat so that none of it is clipped by the BBox's frame rectangle. The label is drawn in the current font, which by default is the system bold font. Both the border and the label are drawn in the current high color; the default high color is black.

The views that the box encloses should be made children of the BBox object.


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.
B_FANCY_BORDER The border is a fancier line that looks like a 3D groove inset into the 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(void)

Frees the label, if the BBox has one.


Static Functions


Instantiate()


      static BBox *Instantiate(BMessage *archive) 

Returns a new BBox 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 data for a Box object, Instantiate() returns NULL.

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


Member Functions


Archive()


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

Archives the BBox by recording its label and border style in the BMessage archive, after calling the inherited version of the function.

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


AttachedToWindow()


      virtual void AttachedToWindow(void)

Makes the BBox's background view color and its low color match the background color of its new parent, after calling the inherited version of AttachedToWindow().

See also: BView::AttachedToWindow()


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.

See also: BView::Draw()


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.

See also: 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.






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 June 30, 1997.