2 * Copyright 2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Augustin Cavalier <waddlesplash>
7 * John Scipione, jscipione@gmail.com
10 * headers/os/interface/TabView.h hrev45377
11 * src/kits/interface/TabView.cpp hrev45377
19 \brief Provides the BTab and BTabView classes.
34 \var tab_position B_TAB_FIRST
36 First tab in the tab view.
43 \var tab_position B_TAB_FRONT
45 Front most tab in the tab view.
52 \var tab_position B_TAB_ANY
54 Any tab in the tab view.
64 \brief A tab that goes in a BTabView.
71 \fn BTab::BTab(BView* contentsView)
72 \brief Initializes a new BTab object as part of a \a tabView.
74 The BTab is enabled, but not selected nor the current focus. \a contentsView
75 is set as the tab's target view -- when the tab is selected, its target
83 \fn BTab::BTab(BMessage* archive)
84 \brief Archive Constructor.
97 \fn BArchivable* BTab::Instantiate(BMessage* archive)
98 \brief Instantiates a BTab object from the passed in \a archive.
105 \fn status_t BTab::Archive(BMessage* data, bool deep) const
106 \brief Archives the object into the \a data message.
108 \param data A pointer to the BMessage object to archive the object into.
109 \param deep Whether or not to archive child views as well.
111 \return A status code, \c B_OK if everything went well or an error code
113 \retval B_OK The object was archived.
114 \retval B_NO_MEMORY Ran out of memory while archiving the object.
121 \fn status_t BTab::Perform(uint32 d, void* arg)
122 \brief Perform some action. (Internal Method)
129 \fn const char* BTab::Label() const
130 \brief Returns the tab's label (the target view's name).
137 \fn void BTab::SetLabel(const char* label)
138 \brief Sets the target view's name, and updates the BTab accordingly.
148 \brief A container for BTab objects to display all tabs.
155 \fn bool BTab::IsSelected() const
156 \brief Returns whether or not the tab is selected.
163 \fn void BTab::Select(BView* owner)
164 \brief Called by the BTabView when the tab is selected.
166 \param owner The view that the tab's view should be owned by.
173 \fn void BTab::Deselect()
174 \brief Called by the BTabView when the tab is de-selected.
181 \fn void BTab::SetEnabled(bool enable)
182 \brief Enables or disables the tab.
189 \fn bool BTab::IsEnabled() const
190 \brief Returns whether or not the tab is enabled.
195 \fn void BTab::MakeFocus(bool focus)
196 \brief Makes the tab the window's focus view or removes it.
203 \fn bool BTab::IsFocus() const
204 \brief Returns whether or not the tab is the window's focus view.
209 \fn void BTab::SetView(BView* view)
210 \brief Sets the view to be displayed for this tab.
215 \fn BView* BTab::View() const
216 \brief Returns a pointer to the view to be displayed for this tab.
221 \fn void BTab::DrawFocusMark(BView* owner, BRect frame)
222 \brief Draws the mark indicating that the BTab object is in focus.
224 This consists of a blue line drawn across the bottom of the tab frame
232 \fn void BTab::DrawLabel(BView* owner, BRect frame)
233 \brief Draws the tab's title.
240 \fn void BTab::DrawTab(BView* owner, BRect frame, tab_position position,
242 \brief Draws the tab.
244 This method draws the tab's title by calling DrawLabel(), then draws the
245 tab itself. The \a position of the tab may affect how the tab is rendered
246 -- for example the frontmost tab may have a different appearance than the
249 \param owner The view that owns the tab.
250 \param frame The frame rectangle to draw in.
251 \param position May affect how the tab is rendered. Choices include:
255 \param full Whether or not to completely draw the tab, no longer used.
262 \fn BTabView::BTabView(const char* name, button_width width, uint32 flags)
263 \brief Initializes a new BTabView object for use as part of a BLayout.
265 \param name The name of the tab view.
266 \param width The tab width flag to use. Options include:
267 - \c B_WIDTH_AS_USUAL
268 - \c B_WIDTH_FROM_WIDEST
269 - \c B_WIDTH_FROM_LABEL
270 \param flags \a flags passed to BView.
277 \fn BTabView::BTabView(BRect frame, const char* name, button_width width,
278 uint32 resizeMask, uint32 flags)
279 \brief Initializes a new BTabView object.
281 \param frame The frame rectangle.
282 \param name The name of the tab view.
283 \param width The tab width flag to use. Options include:
284 - \c B_WIDTH_AS_USUAL
285 - \c B_WIDTH_FROM_WIDEST
286 - \c B_WIDTH_FROM_LABEL
287 \param resizeMask Resizing mask, passed to BView.
288 \param flags \a flags passed to BView.
295 \fn BTabView::BTabView(BMessage* archive)
296 \brief Creates a BTabView object from the passed in \a archive.
303 \fn BTabView::~BTabView()
304 \brief Frees the memory allocated by each tab then destroys the object.
319 \fn BArchivable* BTabView::Instantiate(BMessage* archive)
320 \brief Instantiates a BTabView object from the passed in \a archive.
327 \fn status_t BTabView::Archive(BMessage* data, bool deep) const
328 \brief Archives the object into the \a data message.
330 \param data A pointer to the BMessage object to archive the object into.
331 \param deep Whether or not to archive child views as well.
333 \return A status code, \c B_OK if everything went well or an error code
335 \retval B_OK The object was archived.
336 \retval B_NO_MEMORY Ran out of memory while archiving the object.
343 \fn status_t BTabView::AllUnarchived(const BMessage* from)
344 \brief Hook method called when all views have been unarchived.
346 \copydetails BView::AllUnarchived()
354 \fn status_t BTabView::Perform(perform_code code, void* _data)
355 \brief Perform some action. (Internal Method)
368 \fn void BTabView::AllAttached()
369 \copydoc BView::AllAttached()
374 \fn void BTabView::AllDetached()
375 \copydoc BView::AllDetached()
380 \fn void BTabView::AttachedToWindow()
381 \copydoc BView::AttachedToWindow()
386 \fn void BTabView::DetachedFromWindow()
387 \copydoc BView::DetachedFromWindow()
392 \fn void BTabView::Draw(BRect updateRect)
393 \brief Draws the focus tab and the tab view frame.
400 \fn BRect BTabView::DrawTabs()
401 \brief Draws all the tabs in the BTabView and returns the frame rectangle
402 of the currently selected tab.
409 \fn void BTabView::DrawBox(BRect selectedTabRect)
410 \brief Draws the box that encloses the container view.
412 \param selectedTabRect The frame rectangle of the currently selected tab.
419 \fn void BTabView::FrameResized(float newWidth, float newHeight)
420 \copydoc BView::FrameResized()
425 \fn void BTabView::KeyDown(const char* bytes, int32 numBytes)
426 \brief Handles keyboard navigation for the BTabView.
428 Down and left arrow keys move the focus tab left, up and right
429 arrow keys move the focus tab right. The space bar and enter keys
430 select the currently focused tab.
439 \fn void BTabView::MessageReceived(BMessage* message)
440 \brief Handles scripting messages for the tab view.
442 \copydetails BView::MessageReceived()
447 \fn void BTabView::MouseDown(BPoint where)
448 \brief Selects the tab that the user clicked on (if any).
450 \sa BView::MouseDown()
457 \fn void BTabView::MouseUp(BPoint where)
458 \copydoc BView::MouseUp()
463 \fn void BTabView::MouseMoved(BPoint where, uint32 code,
464 const BMessage* dragMessage)
465 \copydoc BView::MouseMoved()
470 \fn void BTabView::Pulse()
471 \copydoc BView::Pulse()
476 \fn void BTabView::Select(int32 index)
477 \brief Selects the tab at the given \a index making it the selected tab.
479 \param index The zero-based tab index of the tab to select.
486 \fn int32 BTabView::Selection() const
487 \brief Returns the currently selected tab's index.
494 \fn void BTabView::WindowActivated(bool active)
495 \copydoc BView::WindowActivated()
503 \fn void BTabView::MakeFocus(bool focus)
504 \brief Highlight or unhighlight the selection when the tab view acquires
505 or loses its focus state.
507 \copydetails BView::MakeFocus()
512 \fn void BTabView::SetFocusTab(int32 tab, bool focus)
513 \brief Sets the focus state of the specified \a tab.
515 \param tab The index of the tab to set the focus state of.
516 \param focus \c true to set focus, \c false to remove it.
523 \fn int32 BTabView::FocusTab() const
524 \brief Returns the index of the current focus tab.
531 \fn BRect BTabView::TabFrame(int32 index) const
532 \brief Returns the frame rectangle of the tab at the specified \a index.
539 \fn void BTabView::SetFlags(uint32 flags)
540 \copydoc BView::SetFlags()
545 \fn void BTabView::SetResizingMode(uint32 mode)
546 \copydoc BView::SetResizingMode()
551 \fn void BTabView::ResizeToPreferred()
552 \copydoc BView::ResizeToPreferred()
557 \fn void BTabView::GetPreferredSize(float* _width, float* _height)
558 \copydoc BView::GetPreferredSize()
563 \fn BSize BTabView::MinSize()
564 \brief Returns the tab view's minimum size in a BLayout.
571 \fn BSize BTabView::MaxSize()
572 \brief Returns the tab view's maximum size in a BLayout.
579 \fn BSize BTabView::PreferredSize()
580 \brief Returns the tab view's preferred size in a BLayout.
587 \fn void BTabView::FrameMoved(BPoint newPosition)
588 \copydoc BView::FrameMoved()
593 \fn void BTabView::FrameResized(float newWidth, float newHeight)
594 \copydoc BView::FrameResized()
598 \fn BHandler* BTabView::ResolveSpecifier(BMessage* message, int32 index,
599 BMessage* specifier, int32 what, const char* property)
600 \copydoc BHandler::ResolveSpecifier()
605 \fn status_t BTabView::GetSupportedSuites(BMessage* message)
606 \copydoc BHandler::GetSupportedSuites()
611 \fn void BTabView::AddTab(BView* target, BTab* tab)
612 \brief Adds the specified \a tab to the BTabView.
614 The tab is added to the end of the tab list. The new tab's target view is
615 set to \a target. If \a tab is \c NULL, a new BTab object is constructed
616 and added to the BTabView. You can get a pointer to the new tab by calling
619 If you choose to reimplement AddTab(), you should call this parent method
620 at the end of your method.
622 \sa BTabView::TabAt()
629 \fn BTab* BTabView::RemoveTab(int32 index)
630 \brief Removes the tab at the specified \a index from the BTabView and
631 returns a pointer to the BTab object.
633 The BTab object is not deleted, if you don't need it anymore you should delete it.
640 \fn BTab* BTabView::TabAt(int32 index) const
641 \brief Returns a pointer to the BTab object at the specified \a index.
648 \fn void BTabView::SetTabWidth(button_width width)
649 \brief Sets the width of the tabs in the BTabView
651 \a width is one of the following:
652 - \c B_WIDTH_FROM_WIDEST Each tab's width is determined from the width of the widest tab.
653 - \c B_WIDTH_AS_USUAL The default tab width is used for all tabs.
654 - \c B_WIDTH_FROM_LABEL The label of each tab determines the tab width.
661 \fn button_width BTabView::TabWidth() const
662 \brief Returns the current tab width flag.
669 \fn void BTabView::SetTabHeight(float height)
670 \brief Sets the height of the tabs to \a height.
672 \a height should be an integral value.
679 \fn float BTabView::TabHeight() const
680 \brief Returns the current tab height.
687 \fn void BTabView::SetBorder(border_style borderStyle)
688 \brief Sets the border style of the tab view to \a borderStyle.
690 \param borderStyle One of the following:
691 - \c B_FANCY_BORDER (the default)
692 - \c B_PLAIN_BORDER a plain line border,
693 - \c B_NO_BORDER do not draw a border.
700 \fn border_style BTabView::Border() const
701 \brief Returns the current border_style flag.
708 \fn BView* BTabView::ContainerView() const
709 \brief Returns a pointer to the tab view's container view.
716 \fn int32 BTabView::CountTabs() const
717 \brief Returns the number of tabs in the tab view.
724 \fn BView* BTabView::ViewForTab(int32 tabIndex) const
725 \brief Returns the BView of the tab at the specified \a tabIndex.