Nana C++ Library. Reference for users.
What we need to use nana
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
nana::tabbar< T > Class Template Reference

Analogous to dividers in a notebook or the labels in a file cabinet. More...

Inheritance diagram for nana::tabbar< T >:
nana::widget_object< category::widget_tag, drawerbase::tabbar::trigger, drawerbase::tabbar::tabbar_events< Type > > nana::detail::widget_base nana::widget

Public Types

using value_type = Type
 The type of element data which is stored in the tabbar. More...
 
using item_renderer = drawerbase::tabbar::item_renderer
 A user-defined item renderer should be derived from this interface. More...
 
using kits = drawer_trigger_t::kits
 
- Public Types inherited from nana::widget_object< category::widget_tag, drawerbase::tabbar::trigger, drawerbase::tabbar::tabbar_events< Type > >
using scheme_type = ::nana::widget_geometrics
 
using event_type = drawerbase::tabbar::tabbar_events< Type >
 
- Public Types inherited from nana::widget
using native_string_type = detail::native_string_type
 

Public Member Functions

 tabbar ()
 
 tabbar (window wd, bool visible)
 
 ~tabbar ()
 
value_typeoperator[] (std::size_t pos) const
 
void activated (std::size_t pos)
 Activates a tab specified by pos. More...
 
std::size_t activated () const
 
value_type const & at (std::size_t pos) const
 Returns pos'th element. More...
 
void close_fly (bool fly)
 Draw or not a close button in each tab. More...
 
const pat::cloneable
< item_renderer > & 
renderer () const
 
void renderer (const pat::cloneable< item_renderer > &ir)
 
std::size_t length () const
 Returns the number of items. More...
 
tabbarappend (std::string text, window attach_wd, value_type value={})
 Append a new tab. More...
 
tabbarappend (std::wstring text, window attach_wd, value_type value={})
 
void push_back (std::string text)
 Append a new item. More...
 
void insert (std::size_t pos, std::string text, value_type value={})
 
void insert (std::size_t pos, std::wstring text, value_type value={})
 
window attach (std::size_t pos, window attach_wd, bool drop_other=true)
 Attach a window to a specified tab. When the tab is activated, tabbar shows the attached window. More...
 
void erase (std::size_t pos)
 
void tab_bgcolor (std::size_t pos, const ::nana::color &clr)
 
void tab_fgcolor (std::size_t pos, const ::nana::color &clr)
 
void tab_image (std::size_t pos, const nana::paint::image &img)
 
void toolbox (kits kit, bool enable)
 Sets buttons of the tabbar's toolbox, refer to notes for more details. More...
 
void text (std::size_t pos, const std::string &str)
 Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object. More...
 
std::string text (std::size_t pos) const
 Returns a title of a specified item, If pos is invalid, the method throws a std::out_of_range object. More...
 
- Public Member Functions inherited from nana::widget_object< category::widget_tag, drawerbase::tabbar::trigger, drawerbase::tabbar::tabbar_events< Type > >
 widget_object ()
 
 ~widget_object ()
 
event_typeevents () const
 
bool create (window parent_wd, bool visible)
 
bool create (window parent_wd, const rectangle &r={}, bool visible=true)
 
widget_objectborderless (bool enable)
 
bool borderless () const
 
scheme_typescheme () const
 
void filter_event (const event_code evt_code, const bool bDisabled)
 
void filter_event (const std::vector< event_code > evt_codes, const bool bDisabled)
 
void filter_event (const event_filter_status &evt_all_states)
 
bool filter_event (const event_code evt_code)
 
event_filter_status filter_event ()
 
void clear_filter ()
 
- Public Member Functions inherited from nana::detail::widget_base
window handle () const override
 Returns the handle of window, returns 0 if window is not created. More...
 
- Public Member Functions inherited from nana::widget
 widget ()=default
 
virtual ~widget ()=default
 
bool empty () const
 Determines whether the manipulator is handling a window. More...
 
void close ()
 
window parent () const
 
::std::string caption () const noexcept
 
::std::wstring caption_wstring () const noexcept
 
native_string_type caption_native () const noexcept
 
widgetcaption (std::string utf8)
 
widgetcaption (std::wstring)
 
template<typename... Args>
void i18n (std::string msgid, Args &&...args)
 
void i18n (i18n_eval)
 
void cursor (nana::cursor)
 
nana::cursor cursor () const
 Retrieves the shape of cursor. More...
 
void typeface (const paint::font &font)
 
paint::font typeface () const
 
bool enabled () const
 Determines whether the window is enabled for mouse and keyboard input. More...
 
void enabled (bool)
 
void enable_dropfiles (bool)
 Enables/Disables a window to accept dropped files. More...
 
void focus ()
 
bool focused () const
 
std::shared_ptr
< scroll_operation_interface
scroll_operation ()
 
void show ()
 Sets the window visible. More...
 
void hide ()
 Sets the window invisible. More...
 
bool visible () const
 
nana::size size () const
 
void size (const nana::size &)
 
void set_capture (bool ignore_children)
 Enables the widget to grab the mouse input. More...
 
void release_capture ()
 Disables the widget to grab the mouse input. More...
 
point pos () const
 
void move (int x, int y)
 
void move (const point &)
 
void move (const rectangle &)
 
void fgcolor (const nana::color &)
 
nana::color fgcolor () const
 
void bgcolor (const nana::color &)
 
nana::color bgcolor () const
 
general_eventsevents () const
 
void umake_event (event_handle eh) const
 Deletes an event callback by a handle. More...
 
widgetregister_shortkey (wchar_t)
 Registers a shortkey. To remove a registered key, pass 0. More...
 
widgettake_active (bool activated, window take_if_not_activated)
 
widgettooltip (const ::std::string &)
 
 operator dummy_bool_type () const
 
 operator window () const
 

Public Attributes

 __pad0__: tabbar() { this->create(wd
 
 r
 
 visible
 

Additional Inherited Members

- Protected Types inherited from nana::widget_object< category::widget_tag, drawerbase::tabbar::trigger, drawerbase::tabbar::tabbar_events< Type > >
typedef drawerbase::tabbar::trigger drawer_trigger_t
 
- Protected Member Functions inherited from nana::widget_object< category::widget_tag, drawerbase::tabbar::trigger, drawerbase::tabbar::tabbar_events< Type > >
drawerbase::tabbar::triggerget_drawer_trigger ()
 
const drawerbase::tabbar::triggerget_drawer_trigger () const
 
- Protected Member Functions inherited from nana::widget
std::unique_ptr
<::nana::detail::widget_notifier_interface
_m_wdg_notifier ()
 
virtual void _m_complete_creation ()
 
virtual native_string_type _m_caption () const noexcept
 
virtual void _m_caption (native_string_type &&)
 
virtual nana::cursor _m_cursor () const
 
virtual void _m_cursor (nana::cursor)
 
virtual void _m_close ()
 
virtual bool _m_enabled () const
 
virtual void _m_enabled (bool)
 
virtual std::shared_ptr
< scroll_operation_interface
_m_scroll_operation ()
 
virtual bool _m_show (bool)
 
virtual bool _m_visible () const
 
virtual void _m_size (const nana::size &)
 
virtual void _m_move (int x, int y)
 
virtual void _m_move (const rectangle &)
 
virtual void _m_typeface (const nana::paint::font &font)
 
virtual nana::paint::font _m_typeface () const
 
virtual void _m_fgcolor (const nana::color &)
 
virtual nana::color _m_fgcolor () const
 
virtual void _m_bgcolor (const nana::color &)
 
virtual nana::color _m_bgcolor () const
 
- Protected Attributes inherited from nana::detail::widget_base
window handle_ { nullptr }
 

Detailed Description

template<typename T>
class nana::tabbar< T >

Analogous to dividers in a notebook or the labels in a file cabinet.

  1. The button_container is a member template of tabbar. It is used to identify a button in the tabbar. The buttons of toolbox are: scrolling button, list button and close button. Only scrolling button is enabled by default. Enable the 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.

    tabbar.png
    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;
     };
    
    • add_tab() is invoked when a new item is being created.
    • active() method is invoked when selects an item.
    • remove() method is invoked when closes an item and to stop closing the item by returning false.
Examples:
widget_show.cpp, and widget_show2.cpp.

Member Typedef Documentation

template<typename T >
using nana::tabbar< T >::item_renderer = drawerbase::tabbar::item_renderer

A user-defined item renderer should be derived from this interface.

template<typename T >
using nana::tabbar< T >::kits = drawer_trigger_t::kits
template<typename T >
using nana::tabbar< T >::value_type = Type

The type of element data which is stored in the tabbar.

Constructor & Destructor Documentation

template<typename T >
nana::tabbar< T >::tabbar ( )
inline
template<typename T >
nana::tabbar< T >::tabbar ( window  wd,
bool  visible 
)
inline
template<typename T >
nana::tabbar< T >::~tabbar ( )
inline

Member Function Documentation

template<typename T >
void nana::tabbar< T >::activated ( std::size_t  pos)
inline

Activates a tab specified by pos.

template<typename T >
std::size_t nana::tabbar< T >::activated ( ) const
inline
template<typename T >
tabbar& nana::tabbar< T >::append ( std::string  text,
window  attach_wd,
value_type  value = {} 
)
inline

Append a new tab.

template<typename T >
tabbar& nana::tabbar< T >::append ( std::wstring  text,
window  attach_wd,
value_type  value = {} 
)
inline
template<typename T >
value_type const& nana::tabbar< T >::at ( std::size_t  pos) const
inline

Returns pos'th element.

template<typename T >
window nana::tabbar< T >::attach ( std::size_t  pos,
window  attach_wd,
bool  drop_other = true 
)
inline

Attach a window to a specified tab. When the tab is activated, tabbar shows the attached window.

Parameters
posThe position of tab to set the attached window.
attach_wdA handle to the window to be set.
drop_otherDrop the attached windows of other tabs whose attach windows are equal to the parameter attach_wd. If drop_other is true, the other tabs attached windows equal to attach_wd will be dropped.
Returns
A handle to the last attached window of specified tab.
template<typename T >
void nana::tabbar< T >::close_fly ( bool  fly)
inline

Draw or not a close button in each tab.

template<typename T >
void nana::tabbar< T >::erase ( std::size_t  pos)
inline
template<typename T >
void nana::tabbar< T >::insert ( std::size_t  pos,
std::string  text,
value_type  value = {} 
)
inline
template<typename T >
void nana::tabbar< T >::insert ( std::size_t  pos,
std::wstring  text,
value_type  value = {} 
)
inline
template<typename T >
std::size_t nana::tabbar< T >::length ( ) const
inline

Returns the number of items.

template<typename T >
value_type& nana::tabbar< T >::operator[] ( std::size_t  pos) const
inline
template<typename T >
void nana::tabbar< T >::push_back ( std::string  text)
inline

Append a new item.

template<typename T >
const pat::cloneable<item_renderer>& nana::tabbar< T >::renderer ( ) const
inline
template<typename T >
void nana::tabbar< T >::renderer ( const pat::cloneable< item_renderer > &  ir)
inline
template<typename T >
void nana::tabbar< T >::tab_bgcolor ( std::size_t  pos,
const ::nana::color clr 
)
inline
template<typename T >
void nana::tabbar< T >::tab_fgcolor ( std::size_t  pos,
const ::nana::color clr 
)
inline
template<typename T >
void nana::tabbar< T >::tab_image ( std::size_t  pos,
const nana::paint::image img 
)
inline
template<typename T >
void nana::tabbar< T >::text ( std::size_t  pos,
const std::string str 
)
inline

Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.

template<typename T >
std::string nana::tabbar< T >::text ( std::size_t  pos) const
inline

Returns a title of a specified item, If pos is invalid, the method throws a std::out_of_range object.

template<typename T >
void nana::tabbar< T >::toolbox ( kits  kit,
bool  enable 
)
inline

Sets buttons of the tabbar's toolbox, refer to notes for more details.

Member Data Documentation

template<typename T >
nana::tabbar< T >::__pad0__
template<typename T >
nana::tabbar< T >::r
template<typename T >
nana::tabbar< T >::visible