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

Displays a hierarchical list of items, such as the files and directories on a disk. See also in documentation More...

Inheritance diagram for nana::treebox:
nana::widget_object< category::widget_tag, drawerbase::treebox::trigger, drawerbase::treebox::treebox_events, drawerbase::treebox::scheme > nana::detail::widget_base nana::widget

Public Types

typedef
drawerbase::treebox::item_proxy 
item_proxy
 A type refers to the item and is also used to iterate through the nodes. More...
 
typedef
drawerbase::treebox::node_image_tag 
node_image_type
 state images for the node More...
 
typedef
drawerbase::treebox::renderer_interface 
renderer_interface
 The interface of treebox user-defined item renderer. More...
 
typedef
drawerbase::treebox::compset_placer_interface 
compset_placer_interface
 The interface of treebox compset_placer to define the position of node components. More...
 
- Public Types inherited from nana::widget_object< category::widget_tag, drawerbase::treebox::trigger, drawerbase::treebox::treebox_events, drawerbase::treebox::scheme >
using scheme_type = drawerbase::treebox::scheme
 
using event_type = drawerbase::treebox::treebox_events
 
- Public Types inherited from nana::widget
using native_string_type = detail::native_string_type
 

Public Member Functions

 treebox ()
 The default constructor without creating the widget. More...
 
 treebox (window wd, bool visible)
 The construct that creates a widget. More...
 
 treebox (window, const nana::rectangle &=rectangle(), bool visible=true)
 The construct that creates a widget. More...
 
template<typename ItemRenderer >
treeboxrenderer (const ItemRenderer &rd)
 
const nana::pat::cloneable
< renderer_interface > & 
renderer () const
 get user-defined node renderer More...
 
template<typename Placer >
treeboxplacer (const Placer &r)
 
const nana::pat::cloneable
< compset_placer_interface > & 
placer () const
 
void auto_draw (bool enable)
 Enable the widget to be draws automatically when it is operated. More...
 
template<typename Function >
void avoid_drawing (Function fn)
 Prevents drawing during execution. More...
 
treeboxcheckable (bool enable)
 Enable the checkboxs for each item of the widget. More...
 
bool checkable () const
 Are the checkboxs are enabled? More...
 
void clear ()
 Clears the contents. More...
 
node_image_typeicon (const ::std::string &id)
 Creates an icon scheme with the specified name. More...
 
void icon_erase (const ::std::string &id)
 
item_proxy find (const ::std::string &keypath)
 Find an item through a specified keypath. More...
 
item_proxy insert (const ::std::string &path_key,::std::string title)
 Inserts a new node to treebox, but if the keypath exists change and returns the existing node. More...
 
item_proxy insert (item_proxy pos, const ::std::string &key,::std::string title)
 Inserts a new node to treebox, but if the keypath exists change and returns the existing node. More...
 
item_proxy erase (item_proxy i)
 Removes the node at i and return the Item proxy following the removed node. More...
 
void erase (const ::std::string &keypath)
 Removes the node by the key path. More...
 
::std::string make_key_path (item_proxy i, const ::std::string &splitter) const
 returns the key path More...
 
item_proxy selected () const
 returns the selected node More...
 
void scroll_into_view (item_proxy item, align_v bearing)
 Scrolls a specified item into view. More...
 
void scroll_into_view (item_proxy item)
 Scrolls a specified item into view. More...
 
item_proxy hovered (bool exclude_expander) const
 Gets the current hovered node. More...
 
- Public Member Functions inherited from nana::widget_object< category::widget_tag, drawerbase::treebox::trigger, drawerbase::treebox::treebox_events, drawerbase::treebox::scheme >
 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::treebox::trigger, drawerbase::treebox::treebox_events, drawerbase::treebox::scheme >
typedef
drawerbase::treebox::trigger 
drawer_trigger_t
 
- Protected Member Functions inherited from nana::widget_object< category::widget_tag, drawerbase::treebox::trigger, drawerbase::treebox::treebox_events, drawerbase::treebox::scheme >
drawerbase::treebox::triggerget_drawer_trigger ()
 
const
drawerbase::treebox::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 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 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

Displays a hierarchical list of items, such as the files and directories on a disk. See also in documentation

treebox.png
treebox
Examples:
file_explorer.cpp, folder_tree_nana.cpp, folder_tree_std.cpp, widget_show.cpp, and widget_show2.cpp.

Member Typedef Documentation

The interface of treebox compset_placer to define the position of node components.

A type refers to the item and is also used to iterate through the nodes.

Examples:
file_explorer.cpp.

The interface of treebox user-defined item renderer.

Constructor & Destructor Documentation

nana::treebox::treebox ( )

The default constructor without creating the widget.

nana::treebox::treebox ( window  wd,
bool  visible 
)

The construct that creates a widget.

Parameters
wdA handle to the parent window of the widget being created.
visiblespecifying the visibility after creating.
nana::treebox::treebox ( window  wd,
const nana::rectangle r = rectangle(),
bool  visible = true 
)

The construct that creates a widget.

Parameters
wdA handle to the parent window of the widget being created.
rthe size and position of the widget in its parent window coordinate.
visiblespecifying if visible after creating.

Member Function Documentation

void nana::treebox::auto_draw ( bool  enable)

Enable the widget to be draws automatically when it is operated.

The treebox automatically redraws after certain operations, but, under some circumstances, it is good to disable the automatic drawing mode, for example, before adding nodes in a loop, disable the mode avoiding frequent and useless refresh for better performance, and then, after the operations, enable the automatic redraw mode again.

Parameters
enablebool whether to enable.
template<typename Function >
void nana::treebox::avoid_drawing ( Function  fn)
inline

Prevents drawing during execution.

treebox & nana::treebox::checkable ( bool  enable)

Enable the checkboxs for each item of the widget.

Parameters
enablebool indicates whether to show or hide the checkboxs.
bool nana::treebox::checkable ( ) const

Are the checkboxs are enabled?

void nana::treebox::clear ( )

Clears the contents.

treebox::item_proxy nana::treebox::erase ( item_proxy  i)

Removes the node at i and return the Item proxy following the removed node.

void nana::treebox::erase ( const ::std::string keypath)

Removes the node by the key path.

auto nana::treebox::find ( const ::std::string keypath)

Find an item through a specified keypath.

treebox::item_proxy nana::treebox::hovered ( bool  exclude_expander) const

Gets the current hovered node.

treebox::node_image_type & nana::treebox::icon ( const ::std::string id)

Creates an icon scheme with the specified name.

The icon scheme includes 3 images for node states. These states are 'normal', 'hovered' and 'expanded'. If 'hovered' or 'expanded' are not set, it uses 'normal' state image for these 2 states. See also in documentation

Parameters
idThe name of an icon scheme. If the name is not existing, it creates a new scheme for the name.
Returns
The reference of node image scheme corresponding with the specified id.
void nana::treebox::icon_erase ( const ::std::string id)
item_proxy nana::treebox::insert ( const ::std::string path_key,
::std::string  title 
)

Inserts a new node to treebox, but if the keypath exists change and returns the existing node.

Parameters
path_keyspecifies the node hierarchy
titleused for displaying
Examples:
folder_tree_nana.cpp, and folder_tree_std.cpp.
item_proxy nana::treebox::insert ( item_proxy  pos,
const ::std::string key,
::std::string  title 
)

Inserts a new node to treebox, but if the keypath exists change and returns the existing node.

Parameters
posthe parent item node
keyspecifies the new node
titletitle used for displaying in the new node.
std::string nana::treebox::make_key_path ( item_proxy  i,
const ::std::string splitter 
) const

returns the key path

template<typename Placer >
treebox& nana::treebox::placer ( const Placer &  r)
inline
Parameters
rlocation of a node components
const nana::pat::cloneable< treebox::compset_placer_interface > & nana::treebox::placer ( ) const
template<typename ItemRenderer >
treebox& nana::treebox::renderer ( const ItemRenderer &  rd)
inline
Parameters
rdset user-defined node renderer
const nana::pat::cloneable< treebox::renderer_interface > & nana::treebox::renderer ( ) const

get user-defined node renderer

void nana::treebox::scroll_into_view ( item_proxy  item,
align_v  bearing 
)

Scrolls a specified item into view.

Parameters
itemAn item to be requested.
bearingThe position where the item to be positioned in the view.
void nana::treebox::scroll_into_view ( item_proxy  item)

Scrolls a specified item into view.

Parameters
itemAn item to be requested.
treebox::item_proxy nana::treebox::selected ( ) const

returns the selected node