BTabView¶
Constructor and Destructor¶
BTabView()
BTabView::BTabView(BRect frame, const char *name, button_width width = B_WIDTH_AS_USUAL, uint32 resizingMode = B_FOLLOW_ALL, uint32 flags = B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP | B_FRAME_EVENTS)
BTabView::BTabView(const BTabView &tabView)
BTabView::BTabView(BMessage *archive)
Initializes the BTabView to the frame rectangle, stated
in its eventual parent’s coordinate system, and assigns it the specified
name, resizingMode, and flags. These are
described in detail in the BView
section.
The width parameter, which can be one of the following values, specifies the widths of the tabs in the BTabView. All tabs in a BTabView are the same width.
Constant |
Description |
---|---|
|
Each tab’s width is determined based upon the width of the widest tab name. |
|
The default tab width is used for all tabs. |
|
The tab width for each tab is based on the width of the tab’s label. |
The container view for the BTabView’s subviews is created and added to the BTabView as well.
~BTabView()
virtual BTabView::~BTabView()
Frees all memory the BTabView allocated, and deletes every
BTab
attached to it.
Hook Functions¶
AttachedToWindow()
virtual void BTabView::AttachedToWindow()
Calls BView::AttachedToWindow()
, then selects the first tab in
the tab view.
Draw()
virtual void BTabView::Draw(BRect updateRect)
Draws the tabs and the box that encloses the container view that displays the selected tab’s target view.
DrawBox()
virtual void BTabView::DrawBox(BRect selTabRect)
Draws the box that encloses the container view. selTabRect is the
frame rectangle of the currently-selected tab; this information is used to
allow the box to attach properly to the current tab. This is the same
rectangle that the DrawTabs()
function returns.
This is called for you by the Draw()
function and is
provided primarily as a hook for customizing the appearance of your
BTabView.
DrawTabs()
virtual BRect BTabView::DrawTabs()
Draws all the tabs in the BTabView and returns the frame
rectangle of the currently-selected tab. This rectangle should then be
passed to DrawBox()
to draw the container view’s
enclosing box.
This is called for you by the Draw()
function and is
provided primarily as a hook for customizing the appearance of your
BTabView.
KeyDown()
virtual void BTabView::KeyDown(const char *bytes, int32 numBytes)
The KeyDown() function handles keyboard navigation of the BTabView; the down and left arrow keys move the focus to the left, and the up and right arrow keys move the focus to the right. The space bar and enter keys select the focused tab.
All other keys are passed through to the BView::KeyDown()
function for further processing.
See also: the Keyboard Information appendix, “B_KEY_DOWN” in the Message
Protocols appendix, BView::KeyDown()
, modifiers()
MouseDown()
virtual void BTabView::MouseDown(BPoint point)
Identifies which tab (if any) the user clicked and selects that tab. If the
mouse was not inside a tab when clicked, the BView::MouseDown()
function is called.
See also: “B_MOUSE_DOWN” in the Message Protocols appendix,
BView::GetMouse()
WindowActivated()
virtual void BTabView::WindowActivated(bool active)
Calls the inherited version of WindowActivated()
, then
calls DrawTabs()
to redraw the tabs.
See also: BWindow::WindowActivated()
Member Functions¶
AddTab(), RemoveTab()
virtual void BTabView::AddTab(BView *target, BTab *tab = NULL)
virtual BTab *BTabView::RemoveTab(int32 tab_index)
AddTab() adds the specified tab as the rightmost tab in the BTabView. The new tab’s target view is set to target.
If tab is NULL, a new BTab
object is
constructed and added to the BTabView. You can get a pointer to
the new tab using the TabAt()
function
if you choose to reimplement AddTab(), you should call the
inherited form of this function once the BTab
has been
customized.
RemoveTab() removes the tab with the specified index
number from the BTabView and returns a pointer to the
BTab
object. The BTab
is not deleted—if you don’t
need it anymore, you can do that yourself.
Archive()
virtual BTabView::Archive(BMessage *archive, bool deep = true) const
Calls the inherited version of Archive()
and stores the
BTabView in the BMessage
archive.
See also: BArchivable::Archive()
,
Instantiate()
static function
MakeFocus()
virtual void BTabView::MakeFocus(bool focused = true)
Makes the BTabView the current focus by first calling
BView::MakeFocus()
, then making the currently-selected tab the
focus of the BTabView.
Select(), Selection()
virtual void BTabView::Select(int32 tab)
int32 BTabView::Selection() const
Select() selects the tab specified by its index number, first deselecting the previously-selected tab.
Selection() returns the index number of the currently-selected tab.
SetFocusTab(), FocusTab()
virtual void BTabView::SetFocusTab(int32 tab, bool focused)
int32 BTabView::FocusTab() const
SetFocusTab() sets the focus state of the specified tab. If focused is true, the specified tab becomes the new focus; if focused is false, the focus is removed from the currently-focused tab but no new focus is set (the BTabView becomes focusless).
FocusTab() returns the index number of the tab that is currently the focus.
SetTabHeight(), TabHeight()
virtual void BTabView::SetTabHeight(float height)
float BTabView::TabHeight() const
SetTabHeight() sets the height of the tabs in the BTabView. TabHeight() returns the current tab height.
When you change the tab height, the container view for the target views is resized so that the BTabView doesn’t change size. Making the tabs taller by n pixels causes the container view’s top edge to move down by n pixels, and decreasing the heights of the tabs increases the height of the container view.
SetTabWidth(), TabWidth()
virtual void BTabView::SetTabWidth(button_width width)
button_width BTabView::TabWidth() const
SetTabWidth() sets the width of the tabs in the BTabView, and TabWidth() returns the current width setting. width must be one of the following values:
Constant |
Description |
---|---|
|
Each tab’s width is determined based upon the width of the widest tab name. |
|
The default tab width is used for all tabs. |
TabAt()
virtual BTab *BTabView::TabAt(int32 tab_index)
Returns a pointer to the BTab
object at the specified index.
The leftmost tab is index number 0.
TabFrame()
virtual BRect BTabView::TabFrame(int32 tab_index)
Returns the frame rectangle of the tab whose index number is specified. The leftmost tab is index number 0.
See also: DrawTabs()
,
DrawBox()
, Draw()
Static Functions¶
Instantiate()
static BArchivable *BTabView::Instantiate(BMessage *archive)
Returns a new BTabView 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
BTabView object, Instantiate() returns
NULL.
See also: BArchivable::Instantiate()
,
instantiate_object()
, Archive()
Archived Fields¶
The Archive()
function adds the following fields to
its BMessage
argument:
Field |
Type code |
Description |
---|---|---|
_high |
|
The height of the tabs. |
_but_width |
|
The tab width value. |
_sel |
|
Which tab is selected. |
The archived tabs are added to the _l_items field (deep copy only). The tabs’ target views are added to the _views field (deep copy only), with the leftmost tab inserted first in the _views array, and the rightmost tab inserted last.