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

Represent an architecture of categories and what category is chosen. The categorize widget can be used for representing a path of a directory or the order of a hierarchy. More...

Inheritance diagram for nana::categorize< T >:
nana::widget_object< category::widget_tag, drawerbase::categorize::trigger, drawerbase::categorize::categorize_events< T > > nana::detail::widget_base nana::widget

Public Types

using native_string_type = widget::native_string_type
 
using value_type = T
 The type of objects stored. More...
 
using renderer = drawerbase::categorize::renderer
 The interface for user-defined renderer. More...
 
- Public Types inherited from nana::widget_object< category::widget_tag, drawerbase::categorize::trigger, drawerbase::categorize::categorize_events< T > >
using scheme_type = ::nana::widget_geometrics
 
using event_type = drawerbase::categorize::categorize_events< T >
 
- Public Types inherited from nana::widget
using native_string_type = detail::native_string_type
 

Public Member Functions

 categorize ()
 
this create (wd, r, visible)
 
 categorize (window wd, bool visible)
 
 categorize (window wd, const std::string &text_utf8, bool visible=true)
 
 categorize (window wd, const char *text_utf8, bool visible=true)
 
 categorize (window wd, const std::wstring &text, bool visible=true)
 
 categorize (window wd, const wchar_t *text, bool visible=true)
 
categorizeinsert (const std::string &name, const value_type &value)
 
categorizechildset (const std::string &name, const value_type &value)
 Inserts a child category into current category. More...
 
categorizechildset_erase (const std::string &name)
 Erases a child category with a specified name from current category. More...
 
void clear ()
 
categorizesplitstr (const std::string &sstr)
 Sets the splitter string. More...
 
std::string splitstr () const
 
value_typevalue () const
 Retrieves a reference of the current category's value type object. If current category is empty, it throws a exception of std::runtime_error. More...
 
- Public Member Functions inherited from nana::widget_object< category::widget_tag, drawerbase::categorize::trigger, drawerbase::categorize::categorize_events< T > >
 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
 

Additional Inherited Members

- Protected Types inherited from nana::widget_object< category::widget_tag, drawerbase::categorize::trigger, drawerbase::categorize::categorize_events< T > >
typedef
drawerbase::categorize::trigger 
drawer_trigger_t
 
- Protected Member Functions inherited from nana::widget_object< category::widget_tag, drawerbase::categorize::trigger, drawerbase::categorize::categorize_events< T > >
drawerbase::categorize::triggerget_drawer_trigger ()
 
const
drawerbase::categorize::trigger
get_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 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::categorize< T >

Represent an architecture of categories and what category is chosen. The categorize widget can be used for representing a path of a directory or the order of a hierarchy.

  1. The definition of ext_event_type
             struct ext_event_type
             {
                     typedef Implementation-Specified categorize_type;
                     typedef typename categorize_type::value_type value_type;
                     nana::functor_group<void(categorize_type&, value_type&)> selected;   //Selects a category
             };
    
  2. Definition of renderer
             class renderer
             {
              public:
                     typedef nana::paint::graphics & graph_reference;
                     enum state_t {state_normal, state_over, state_pressed};
                     struct ui_element
                     {
                             enum t
                             {
                                     none,           //Out of the widget
                                     somewhere, item_root, item_name, item_arrow
                             };
                             static const size_t npos = static_cast<size_t>(-1);
                             t what;
                             size_t index;
                             ui_element();
                     };
                     virtual ~renderer() = 0;
                     virtual void background(graph_reference, window, const nana::rectangle&, 
                                                                     const   ui_element&)     = 0;
                     virtual void root_arrow(graph_reference, const nana::rectangle&, state_t) = 0;
                     virtual void item(graph_reference, const nana::rectangle&, size_t index,
                     const nana::string& name, unsigned text_height,
                     bool has_child, state_t) = 0;
                     virtual void border(graph_reference) = 0;
             };
    
  3. The caption() methods of the categorize widget is used for retrieving and setting the category.

example

    #include <iostream>
    #include <nana/gui/wvl.hpp>
    #include <nana/gui/widgets/categorize.hpp>

    void selected(nana::categorize<int> & categ, int&)
    {
            nana::msgbox mb(categ, STR("categorize"));
            mb.icon(mb.icon_information);
            mb<<STR("The value of selected is ")<<categ.value()<<STR(", caption is \"")
            <<categ.caption()<<STR("\""); //caption() method, see Note 3.
            mb();
    }

    int main()
    {
            using namespace nana::gui;
            form fm;
            categorize<int> categ(fm, 10, 10, 200, 24);

            categ.childset(STR("Invalid Category"), 0); // Invalid category because of empty current category.

            categ.insert(STR("First"), 0);  // Insert a category and now it is the current category.

            categ.insert(STR("Second"), 1); // Insert a category as a child of "First" category, and then 
                                          ;  // the "Second" is the current category.

            categ.childset(STR("Third"), 2);
            ; // Insert a category as a child of "Second".

            categ.childset(STR("Another Child"), 2);
                    ; // childset() always insert categories into current category, and
                    ; // it does not displace the current category, and therefore "Another Child"
                    ; // is a child of "Second".

            categ.ext_event().selected = selected;
                    ; // This may crash in VC2012-RC due to compiler bug.
                    ; // Please refer to compatibility-issue for more details

            fm.show();
            exec();
    }
categorize.jpg
Screenshot of categorize.
Examples:
categ.cpp, file_explorer.cpp, widget_show.cpp, and widget_show2.cpp.

Member Typedef Documentation

template<typename T>
using nana::categorize< T >::renderer = drawerbase::categorize::renderer

The interface for user-defined renderer.

template<typename T>
using nana::categorize< T >::value_type = T

The type of objects stored.

Constructor & Destructor Documentation

template<typename T>
nana::categorize< T >::categorize ( )
inline
template<typename T>
nana::categorize< T >::categorize ( window  wd,
bool  visible 
)
inline
template<typename T>
nana::categorize< T >::categorize ( window  wd,
const std::string text_utf8,
bool  visible = true 
)
inline
template<typename T>
nana::categorize< T >::categorize ( window  wd,
const char *  text_utf8,
bool  visible = true 
)
inline
template<typename T>
nana::categorize< T >::categorize ( window  wd,
const std::wstring text,
bool  visible = true 
)
inline
template<typename T>
nana::categorize< T >::categorize ( window  wd,
const wchar_t *  text,
bool  visible = true 
)
inline

Member Function Documentation

template<typename T>
categorize& nana::categorize< T >::childset ( const std::string name,
const value_type value 
)
inline

Inserts a child category into current category.

template<typename T>
categorize& nana::categorize< T >::childset_erase ( const std::string name)
inline

Erases a child category with a specified name from current category.

template<typename T>
void nana::categorize< T >::clear ( )
inline
template<typename T>
this nana::categorize< T >::create ( wd  ,
,
visible   
)
template<typename T>
categorize& nana::categorize< T >::insert ( const std::string name,
const value_type value 
)
inline

Insert a new category with a specified name and the object of value type. The new category would be inserted as a child in current category, and after inserting, the new category is replaced of the current category as a new current one.

template<typename T>
categorize& nana::categorize< T >::splitstr ( const std::string sstr)
inline

Sets the splitter string.

template<typename T>
std::string nana::categorize< T >::splitstr ( ) const
inline
template<typename T>
value_type& nana::categorize< T >::value ( ) const
inline

Retrieves a reference of the current category's value type object. If current category is empty, it throws a exception of std::runtime_error.