Nana C++ Library  
An open-source C++ framework project
The Nana Programmer's Guide 
nana::gui::tabbar<typename Type>

Description

A tabbar widget is analogous to dividers in a notebook or the labels in a file cabinet .

Model of

Widget Window 

Public base classes

class widget_object<widget_tag, DrawerTrigger>: public widget

Template Parameter

typename Type The type of element data which is stored in the tabbar

Typedefs

value_type It is a alias for template parameter Type.
item_renderer The interface of an item renderer. A user-defined item renderer should be derived from this interface.
ext_event_type The extended event.
button_add The type identifies the add button of the tabbar's toolbox.
button_scroll The type identifies the scroll button of the tabbar's toolbox.
button_list The type identifies the list button of the tabbar's toolbox.
button_close The type identifies the close button of the tabbar's toolbox.
template<typename Add = null_type, typename Scroll = null_type, typename List = null_type, typename Close = null_type> struct button_container; A template class identifies the buttons of the tabbar's toolbox. Refer to notes for more details.

Members

tabbar() The default constrocutor.
tabbar(window wd, bool visible) Create a tabbar.
tabbar(window wd, const nana::string& title, bool visible = true) Ditto.
tabbar(window wd, const nana::char_t* title, bool visible = true) Ditto.
tabbar(window wd, const rectangle& r = rectangle, bool visible = true) Ditto.
void active(size_t i) Actives a tab specified by i.
size_t active() const Returns the index of the active tab.
value_type& at(size_t i) const Returns i'th element
void close_fly(bool enable) Enables or disables the close button of toolbox to draw in each tab.
pat::cloneable<item_renderer> & ext_renderer() Returns a reference to the cloneable item renderer.
void ext_renderer(const pat::cloneable<item_renderer>&) Sets a new user-defined item renderer
ext_event_type& ext_event() const Retrieves the extended event object.
size_t length() const Returns the number of items.
void push_back(const nana::string& text) Append a new item.
void relate(size_t pos, nana::gui::window) Binds a window to an item specified by pos, if the item is selected, shows the window, otherwise, hides it.
void tab_bgcolor(size_t pos, nana::color_t) Set the tab item background color.
void tab_fgcolor(size_t pos, nana::color_t) Set the text color of a tab item.
void tab_image(size_t pos, const nana::paint::image& img) Sets the image of a tab item.
void text(size_t pos, const nana::string& str) Sets the title of the specified item. If pos is invalid, the method throws a std::out_of_range object.
nana::string text(size_t pos) const Returns a title of a specified item. If pos is invalid, the method trhows a std::out_of_range object.
template<typename ButtonContainer> void toolbox(const ButtonContainer& bc, bool) Sets buttons of the tabbar's toolbox, refer to notes for more details.
value_type& operator[](size_t pos) const Returns pos'th element


File

nana/gui/widgets/tabbar.hpp

Notes

1, The button_container is a member template of tabbar, it is used for identifing the buttons of toolbox of tabbar. The buttons of toolbox are scrolling button, list button and close button, only scrolling button is enabled by default, enable other buttons by employing the tabbar::toolbox member function. An example.

typedef tabbar<int> tabbar_t;
tabbar_object.toolbox(tabbar_t::button_container<tabbar_t::button_list, tabbar_t::button_close>(), true);

Sets the list button and close button to be enabled.

nana::gui::tabbar


2, The tabbar provides an event_trigger class for abstract event, such as selecting an item or closing an item.

template<typename Tabbar>
struct ext_event_type
{
    typedef Tabbar tabbar;
    typedef typename tabbar::value_type value_type;
   
    nana::functor_group<void(tabbar&, value_type&)> add_tab;
    nana::functor_group<void(tabbar&, value_type&)> active;
    nana::functor_group<bool(tabbar&, value_type&)> remove;
};


The add_tab() is invoked when a new item is being created. The select() methond is invoked when selects an item. The remove() method is invoked when closes an item and to stop closing the item by returning false.

See also

None.


Move to The Nana Programmer's Guide Main Page