parent
56f44e6479
commit
fb8ade6557
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Concept of Component Set
|
* Concept of Component Set
|
||||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -60,17 +60,19 @@ namespace nana{ namespace widgets{ namespace detail
|
|||||||
/// Widget scheme.
|
/// Widget scheme.
|
||||||
typedef WidgetScheme widget_scheme_t;
|
typedef WidgetScheme widget_scheme_t;
|
||||||
|
|
||||||
widget_scheme_t * wdg_scheme_ptr_{ nullptr };
|
//widget_scheme_t * wdg_scheme_ptr_{ nullptr }; //deprecated
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// The destructor.
|
/// The destructor.
|
||||||
virtual ~compset_placer(){}
|
virtual ~compset_placer(){}
|
||||||
|
|
||||||
|
/*
|
||||||
/// Init the scheme pointer
|
/// Init the scheme pointer
|
||||||
void init_scheme(widget_scheme_t* wdg_scheme_ptr)
|
void init_scheme(widget_scheme_t* wdg_scheme_ptr) //deprecated
|
||||||
{
|
{
|
||||||
wdg_scheme_ptr_ = wdg_scheme_ptr;
|
wdg_scheme_ptr_ = wdg_scheme_ptr;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/// Enable/Disable the specified component.
|
/// Enable/Disable the specified component.
|
||||||
virtual void enable(component_t, bool) = 0;
|
virtual void enable(component_t, bool) = 0;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Tree Box Implementation
|
* A Tree Box Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE or copy at
|
* (See accompanying file LICENSE or copy at
|
||||||
|
|||||||
@ -6195,8 +6195,9 @@ namespace nana
|
|||||||
return;
|
return;
|
||||||
std::vector<size_type> new_idx;
|
std::vector<size_type> new_idx;
|
||||||
for(size_type i=first_col; i<=last_col; ++i) new_idx.push_back(i);
|
for(size_type i=first_col; i<=last_col; ++i) new_idx.push_back(i);
|
||||||
const item_proxy & ip_row=this->at(row);
|
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
|
const item_proxy ip_row = this->at(row);
|
||||||
const nana::any *pnany=_m_ess().lister.anyobj(row,false);
|
const nana::any *pnany=_m_ess().lister.anyobj(row,false);
|
||||||
std::sort(new_idx.begin(), new_idx.end(), [&](size_type col1,
|
std::sort(new_idx.begin(), new_idx.end(), [&](size_type col1,
|
||||||
size_type col2)
|
size_type col2)
|
||||||
@ -6205,6 +6206,8 @@ namespace nana
|
|||||||
ip_row.text(col2), col2,
|
ip_row.text(col2), col2,
|
||||||
pnany, reverse);
|
pnany, reverse);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Only change the view position of columns
|
||||||
for(size_t i=0; i<new_idx.size(); ++i)
|
for(size_t i=0; i<new_idx.size(); ++i)
|
||||||
{
|
{
|
||||||
move_column(new_idx[i],i+first_col);
|
move_column(new_idx[i],i+first_col);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* A Treebox Implementation
|
* A Treebox Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -1330,6 +1330,10 @@ namespace nana
|
|||||||
class internal_placer
|
class internal_placer
|
||||||
: public compset_placer_interface
|
: public compset_placer_interface
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
internal_placer(const scheme& schm):
|
||||||
|
scheme_(schm)
|
||||||
|
{}
|
||||||
private:
|
private:
|
||||||
//Implement the compset_locator_interface
|
//Implement the compset_locator_interface
|
||||||
|
|
||||||
@ -1364,17 +1368,24 @@ namespace nana
|
|||||||
|
|
||||||
virtual unsigned item_height(graph_reference graph) const override
|
virtual unsigned item_height(graph_reference graph) const override
|
||||||
{
|
{
|
||||||
auto m = std::max((enable_crook_ ? wdg_scheme_ptr_->crook_size : 0), (enable_icon_ ? wdg_scheme_ptr_->icon_size : 0));
|
auto m = std::max((enable_crook_ ? scheme_.crook_size : 0), (enable_icon_ ? scheme_.icon_size : 0));
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
unsigned as = 0, ds = 0, il;
|
||||||
|
graph.text_metrics(as, ds, il);
|
||||||
|
return std::max(as + ds + 8, m);
|
||||||
|
#else
|
||||||
#ifdef _nana_std_has_string_view
|
#ifdef _nana_std_has_string_view
|
||||||
return std::max(m, graph.text_extent_size(std::wstring_view{ L"jH{", 3 }).height + 8);
|
return std::max(m, graph.text_extent_size(std::wstring_view{ L"jH{", 3 }).height + 8);
|
||||||
#else
|
#else
|
||||||
return std::max(m, graph.text_extent_size(L"jH{", 3).height + 8);
|
return std::max(m, graph.text_extent_size(L"jH{", 3).height + 8);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual unsigned item_width(graph_reference graph, const item_attribute_t& attr) const override
|
virtual unsigned item_width(graph_reference graph, const item_attribute_t& attr) const override
|
||||||
{
|
{
|
||||||
return graph.text_extent_size(attr.text).width + (enable_crook_ ? wdg_scheme_ptr_->crook_size : 0) + (enable_icon_ ? wdg_scheme_ptr_ ->icon_size: 0) + (wdg_scheme_ptr_->text_offset << 1) + wdg_scheme_ptr_->item_offset;
|
return graph.text_extent_size(attr.text).width + (enable_crook_ ? scheme_.crook_size : 0) + (enable_icon_ ? scheme_.icon_size : 0) + (scheme_.text_offset << 1) + scheme_.item_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locate a component through the specified coordinate.
|
// Locate a component through the specified coordinate.
|
||||||
@ -1389,7 +1400,7 @@ namespace nana
|
|||||||
case component_t::expander:
|
case component_t::expander:
|
||||||
if(attr.has_children)
|
if(attr.has_children)
|
||||||
{
|
{
|
||||||
r->width = wdg_scheme_ptr_->item_offset;
|
r->width = scheme_.item_offset;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1398,26 +1409,26 @@ namespace nana
|
|||||||
case component_t::crook:
|
case component_t::crook:
|
||||||
if(enable_crook_)
|
if(enable_crook_)
|
||||||
{
|
{
|
||||||
r->x += wdg_scheme_ptr_->item_offset;
|
r->x += scheme_.item_offset;
|
||||||
r->width = wdg_scheme_ptr_->crook_size;
|
r->width = scheme_.crook_size;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case component_t::icon:
|
case component_t::icon:
|
||||||
if(enable_icon_)
|
if(enable_icon_)
|
||||||
{
|
{
|
||||||
r->x += wdg_scheme_ptr_->item_offset + (enable_crook_ ? wdg_scheme_ptr_->crook_size : 0);
|
r->x += scheme_.item_offset + (enable_crook_ ? scheme_.crook_size : 0);
|
||||||
r->y = 2;
|
r->y = 2;
|
||||||
r->width = wdg_scheme_ptr_->icon_size;
|
r->width = scheme_.icon_size;
|
||||||
r->height -= 2;
|
r->height -= 2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case component_t::text:
|
case component_t::text:
|
||||||
{
|
{
|
||||||
auto text_pos = wdg_scheme_ptr_->item_offset + (enable_crook_ ? wdg_scheme_ptr_->crook_size : 0) + (enable_icon_ ? wdg_scheme_ptr_->icon_size : 0) + wdg_scheme_ptr_->text_offset;
|
auto text_pos = scheme_.item_offset + (enable_crook_ ? scheme_.crook_size : 0) + (enable_icon_ ? scheme_.icon_size : 0) + scheme_.text_offset;
|
||||||
r->x += text_pos;
|
r->x += text_pos;
|
||||||
r->width -= (text_pos + wdg_scheme_ptr_->text_offset);
|
r->width -= (text_pos + scheme_.text_offset);
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -1426,6 +1437,7 @@ namespace nana
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
const scheme& scheme_;
|
||||||
bool enable_crook_{ false };
|
bool enable_crook_{ false };
|
||||||
bool enable_icon_{ false };
|
bool enable_icon_{ false };
|
||||||
};
|
};
|
||||||
@ -1680,7 +1692,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
impl_->data.trigger_ptr = this;
|
impl_->data.trigger_ptr = this;
|
||||||
impl_->data.renderer = nana::pat::cloneable<renderer_interface>(internal_renderer());
|
impl_->data.renderer = nana::pat::cloneable<renderer_interface>(internal_renderer());
|
||||||
impl_->data.comp_placer = nana::pat::cloneable<compset_placer_interface>(internal_placer());
|
//impl_->data.comp_placer = nana::pat::cloneable<compset_placer_interface>(internal_placer()); //deprecated
|
||||||
|
|
||||||
impl_->adjust.timer.elapse([this]
|
impl_->adjust.timer.elapse([this]
|
||||||
{
|
{
|
||||||
@ -1946,7 +1958,8 @@ namespace nana
|
|||||||
widget.bgcolor(colors::white);
|
widget.bgcolor(colors::white);
|
||||||
impl_->data.widget_ptr = static_cast<::nana::treebox*>(&widget);
|
impl_->data.widget_ptr = static_cast<::nana::treebox*>(&widget);
|
||||||
impl_->data.scheme_ptr = static_cast<::nana::treebox::scheme_type*>(API::dev::get_scheme(widget));
|
impl_->data.scheme_ptr = static_cast<::nana::treebox::scheme_type*>(API::dev::get_scheme(widget));
|
||||||
impl_->data.comp_placer->init_scheme(impl_->data.scheme_ptr);
|
//impl_->data.comp_placer->init_scheme(impl_->data.scheme_ptr); //deprecated
|
||||||
|
impl_->data.comp_placer = nana::pat::cloneable<compset_placer_interface>(internal_placer{ *impl_->data.scheme_ptr });
|
||||||
|
|
||||||
widget.caption("nana treebox");
|
widget.caption("nana treebox");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user