treebox refined

This commit is contained in:
Jinhao 2017-01-21 05:03:50 +08:00
parent 238e85756f
commit 6c3ba75f6f
2 changed files with 25 additions and 50 deletions

View File

@ -1,7 +1,7 @@
/**
* A Tree Box Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -110,17 +110,14 @@ namespace nana
struct pseudo_node_type{};
typedef widgets::detail::tree_cont<treebox_node_type> tree_cont_type;
typedef tree_cont_type::node_type node_type;
using tree_cont_type = widgets::detail::tree_cont<treebox_node_type>;
using node_type = tree_cont_type::node_type;
trigger();
~trigger();
implement * impl() const;
void auto_draw(bool);
void checkable(bool);
bool checkable() const;
void check(node_type*, checkstate);
bool draw();
@ -136,7 +133,6 @@ namespace nana
node_type* insert(node_type*, const std::string& key, std::string&&);
node_type* insert(const std::string& path, std::string&&);
bool verify(const void*) const;
bool verify_kinship(node_type* parent, node_type* child) const;
void remove(node_type*);
@ -148,7 +144,6 @@ namespace nana
node_image_tag& icon(const ::std::string&) const;
void icon_erase(const ::std::string&);
void node_icon(node_type*, const ::std::string& id);
unsigned node_width(const node_type*) const;
bool rename(node_type*, const char* key, const char* name);

View File

@ -1,7 +1,7 @@
/*
* A Treebox Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -1562,35 +1562,6 @@ namespace nana
return impl_;
}
void trigger::auto_draw(bool ad)
{
if(impl_->attr.auto_draw != ad)
{
impl_->attr.auto_draw = ad;
if(ad)
API::update_window(impl_->data.widget_ptr->handle());
}
}
void trigger::checkable(bool enable)
{
auto & comp_placer = impl_->data.comp_placer;
if(comp_placer->enabled(component::crook) != enable)
{
comp_placer->enable(component::crook, enable);
if(impl_->attr.auto_draw)
{
impl_->draw(false);
API::update_window(impl_->data.widget_ptr->handle());
}
}
}
bool trigger::checkable() const
{
return impl_->data.comp_placer->enabled(component::crook);
}
void trigger::check(node_type* node, checkstate cs)
{
if (!node->owner) return;
@ -1727,11 +1698,6 @@ namespace nana
return x;
}
bool trigger::verify(const void* node) const
{
return impl_->attr.tree_cont.verify(reinterpret_cast<const node_type*>(node));
}
bool trigger::verify_kinship(node_type* parent, node_type* child) const
{
if(false == (parent && child)) return false;
@ -1744,7 +1710,7 @@ namespace nana
void trigger::remove(node_type* node)
{
if(!verify(node))
if (!tree().verify(node))
return;
auto & shape = impl_->shape;
@ -1769,10 +1735,10 @@ namespace nana
void trigger::selected(node_type* node)
{
if(impl_->attr.tree_cont.verify(node) && impl_->set_selected(node))
if(tree().verify(node) && impl_->set_selected(node))
{
impl_->draw(true);
API::update_window(impl_->data.widget_ptr->handle());
if(impl_->draw(true))
API::update_window(impl_->data.widget_ptr->handle());
}
}
@ -2160,6 +2126,8 @@ namespace nana
}//end namespace drawerbase
//class treebox
using component = drawerbase::treebox::component;
treebox::treebox(){}
treebox::treebox(window wd, bool visible)
@ -2184,18 +2152,30 @@ namespace nana
void treebox::auto_draw(bool ad)
{
get_drawer_trigger().auto_draw(ad);
auto impl = get_drawer_trigger().impl();
if (impl->attr.auto_draw != ad)
{
impl->attr.auto_draw = ad;
if (ad)
API::refresh_window(this->handle());
}
}
treebox & treebox::checkable(bool enable)
{
get_drawer_trigger().checkable(enable);
auto impl = get_drawer_trigger().impl();
auto & comp_placer = impl->data.comp_placer;
if (comp_placer->enabled(component::crook) != enable)
{
comp_placer->enable(component::crook, enable);
get_drawer_trigger().draw();
}
return *this;
}
bool treebox::checkable() const
{
return get_drawer_trigger().checkable();
return get_drawer_trigger().impl()->data.comp_placer->enabled(component::crook);
}
void treebox::clear()