remove some duplicated functions of treebox
This commit is contained in:
parent
c1113cf41d
commit
9fa0bc2db9
@ -128,17 +128,11 @@ namespace nana
|
|||||||
void placer(::nana::pat::cloneable<compset_placer_interface>&&);
|
void placer(::nana::pat::cloneable<compset_placer_interface>&&);
|
||||||
const ::nana::pat::cloneable<compset_placer_interface>& placer() const;
|
const ::nana::pat::cloneable<compset_placer_interface>& placer() const;
|
||||||
|
|
||||||
nana::any & value(node_type*) const;
|
|
||||||
node_type* insert(node_type*, const std::string& key, std::string&&);
|
node_type* insert(node_type*, const std::string& key, std::string&&);
|
||||||
node_type* insert(const std::string& path, std::string&&);
|
node_type* insert(const std::string& path, std::string&&);
|
||||||
|
|
||||||
bool verify_kinship(node_type* parent, node_type* child) const;
|
|
||||||
|
|
||||||
void remove(node_type*);
|
|
||||||
node_type * selected() const;
|
node_type * selected() const;
|
||||||
void selected(node_type*);
|
void selected(node_type*);
|
||||||
void set_expand(node_type*, bool);
|
|
||||||
void set_expand(const ::std::string& path, bool);
|
|
||||||
|
|
||||||
node_image_tag& icon(const ::std::string&) const;
|
node_image_tag& icon(const ::std::string&) const;
|
||||||
void icon_erase(const ::std::string&);
|
void icon_erase(const ::std::string&);
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
#include <nana/gui/element.hpp>
|
#include <nana/gui/element.hpp>
|
||||||
#include <nana/gui/layout_utility.hpp>
|
#include <nana/gui/layout_utility.hpp>
|
||||||
#include <nana/system/platform.hpp>
|
#include <nana/system/platform.hpp>
|
||||||
#include <stdexcept>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
@ -304,9 +303,9 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool clear(node_type* node)
|
bool unlink(node_type* node, bool perf_clear)
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!attr.tree_cont.verify(node))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (node->is_ancestor_of(shape.first))
|
if (node->is_ancestor_of(shape.first))
|
||||||
@ -325,6 +324,8 @@ namespace nana
|
|||||||
if (node->is_ancestor_of(node_state.event_node))
|
if (node->is_ancestor_of(node_state.event_node))
|
||||||
node_state.event_node = nullptr;
|
node_state.event_node = nullptr;
|
||||||
|
|
||||||
|
if (perf_clear)
|
||||||
|
{
|
||||||
if (node->child)
|
if (node->child)
|
||||||
{
|
{
|
||||||
attr.tree_cont.clear(node);
|
attr.tree_cont.clear(node);
|
||||||
@ -333,6 +334,10 @@ namespace nana
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attr.tree_cont.remove(node);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool draw(bool reset_scroll, bool ignore_update = false)
|
bool draw(bool reset_scroll, bool ignore_update = false)
|
||||||
{
|
{
|
||||||
if(data.graph && (false == data.stop_drawing))
|
if(data.graph && (false == data.stop_drawing))
|
||||||
@ -439,17 +444,6 @@ namespace nana
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check_kinship(const node_type* parent, const node_type * child)
|
|
||||||
{
|
|
||||||
if((!parent) || (!child))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
while(child && (child != parent))
|
|
||||||
child = child->owner;
|
|
||||||
|
|
||||||
return (nullptr != child);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool make_adjust(node_type * node, int reason)
|
bool make_adjust(node_type * node, int reason)
|
||||||
{
|
{
|
||||||
if(!node) return false;
|
if(!node) return false;
|
||||||
@ -911,7 +905,7 @@ namespace nana
|
|||||||
if (node_)
|
if (node_)
|
||||||
{
|
{
|
||||||
auto impl = trigger_->impl();
|
auto impl = trigger_->impl();
|
||||||
impl->clear(node_);
|
if(impl->unlink(node_, true))
|
||||||
impl->draw(true);
|
impl->draw(true);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@ -1703,14 +1697,6 @@ namespace nana
|
|||||||
return impl_->data.comp_placer;
|
return impl_->data.comp_placer;
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::any & trigger::value(node_type* node) const
|
|
||||||
{
|
|
||||||
if(impl_->attr.tree_cont.verify(node) == false)
|
|
||||||
throw std::invalid_argument("Nana.GUI.treebox.value() invalid node");
|
|
||||||
|
|
||||||
return node->value.second.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger::node_type* trigger::insert(node_type* node, const std::string& key, std::string&& title)
|
trigger::node_type* trigger::insert(node_type* node, const std::string& key, std::string&& title)
|
||||||
{
|
{
|
||||||
node_type * p = impl_->attr.tree_cont.node(node, key);
|
node_type * p = impl_->attr.tree_cont.node(node, key);
|
||||||
@ -1733,36 +1719,6 @@ namespace nana
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool trigger::verify_kinship(node_type* parent, node_type* child) const
|
|
||||||
{
|
|
||||||
if(false == (parent && child)) return false;
|
|
||||||
|
|
||||||
while(child && (child != parent))
|
|
||||||
child = child->owner;
|
|
||||||
|
|
||||||
return (nullptr != child);
|
|
||||||
}
|
|
||||||
|
|
||||||
void trigger::remove(node_type* node)
|
|
||||||
{
|
|
||||||
if (!tree().verify(node))
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto & shape = impl_->shape;
|
|
||||||
auto & node_state = impl_->node_state;
|
|
||||||
|
|
||||||
if(verify_kinship(node, node_state.event_node))
|
|
||||||
node_state.event_node = nullptr;
|
|
||||||
|
|
||||||
if(verify_kinship(node, shape.first))
|
|
||||||
shape.first = nullptr;
|
|
||||||
|
|
||||||
if(verify_kinship(node, node_state.selected))
|
|
||||||
node_state.selected = nullptr;
|
|
||||||
|
|
||||||
impl_->attr.tree_cont.remove(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger::node_type* trigger::selected() const
|
trigger::node_type* trigger::selected() const
|
||||||
{
|
{
|
||||||
return impl_->node_state.selected;
|
return impl_->node_state.selected;
|
||||||
@ -1774,18 +1730,6 @@ namespace nana
|
|||||||
impl_->draw(true);
|
impl_->draw(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::set_expand(node_type* node, bool exp)
|
|
||||||
{
|
|
||||||
if((impl_->data.widget_ptr) && impl_->set_expanded(node, exp))
|
|
||||||
impl_->draw(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void trigger::set_expand(const std::string& path, bool exp)
|
|
||||||
{
|
|
||||||
if(impl_->set_expanded(impl_->attr.tree_cont.find(path), exp))
|
|
||||||
impl_->draw(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
node_image_tag& trigger::icon(const std::string& id) const
|
node_image_tag& trigger::icon(const std::string& id) const
|
||||||
{
|
{
|
||||||
auto i = impl_->shape.image_table.find(id);
|
auto i = impl_->shape.image_table.find(id);
|
||||||
@ -2201,7 +2145,7 @@ namespace nana
|
|||||||
void treebox::clear()
|
void treebox::clear()
|
||||||
{
|
{
|
||||||
auto impl = get_drawer_trigger().impl();
|
auto impl = get_drawer_trigger().impl();
|
||||||
impl->clear(impl->attr.tree_cont.get_root());
|
if (impl->unlink(impl->attr.tree_cont.get_root(), true))
|
||||||
impl->draw(true);
|
impl->draw(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2234,15 +2178,16 @@ namespace nana
|
|||||||
treebox::item_proxy treebox::erase(item_proxy i)
|
treebox::item_proxy treebox::erase(item_proxy i)
|
||||||
{
|
{
|
||||||
auto next = i.sibling();
|
auto next = i.sibling();
|
||||||
get_drawer_trigger().remove(i._m_node());
|
if (get_drawer_trigger().impl()->unlink(i._m_node(), false))
|
||||||
|
get_drawer_trigger().impl()->draw(true);
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void treebox::erase(const std::string& keypath)
|
void treebox::erase(const std::string& keypath)
|
||||||
{
|
{
|
||||||
auto i = find(keypath);
|
auto i = find(keypath);
|
||||||
if(!i.empty())
|
if (!i.empty())
|
||||||
get_drawer_trigger().remove(i._m_node());
|
this->erase(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string treebox::make_key_path(item_proxy i, const std::string& splitter) const
|
std::string treebox::make_key_path(item_proxy i, const std::string& splitter) const
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user