| Class Overview |
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(const BTabView
& tabView);
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.
virtual ~BTabView();
Frees all memory the BTabView
allocated, and deletes every
BTab
attached
to it.
virtual void AttachedToWindow();
Calls BView::AttachedToWindow()
,
then selects the first tab in the tab view.
virtual void Draw(BRect
updateRect);
Draws the tabs and the box that encloses the container view that displays the selected tab's target view.
virtual void 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
.
virtual BRect
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
.
virtual void 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()
virtual void 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()
virtual void WindowActivated(bool active);
Calls the inherited version of
WindowActivated()
,
then calls DrawTabs()
to redraw the tabs.
See also: BWindow::WindowActivated()
virtual void AddTab(BView
* target,
BTab
* tab = NULL);
virtual BTab
* 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.
virtual 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
virtual void 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
.
virtual void Select(int32 tab);
int32 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.
virtual void SetFocusTab(int32 tab,
bool focused);
int32 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.
virtual void SetTabHeight(float height);
float 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.
virtual void SetTabWidth(button_width width);
button_width 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. |
virtual BTab
* TabAt(int32 tab_index);
Returns a pointer to the
BTab
object at the
specified index. The leftmost tab is index number 0.
virtual BRect
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 BArchivable
* 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()
The Archive()
function adds the following fields to its
BMessage
argument:
Field | Type code | Description |
---|---|---|
_high | B_FLOAT_TYPE | The height of the tabs. |
_but_width | B_INT16_TYPE | The tab width value. |
_sel | B_INT32_TYPE | 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.