Merge branch 'hotfix-1.5.6' into develop

This commit is contained in:
Jinhao
2018-04-12 15:49:30 +08:00
10 changed files with 116 additions and 8 deletions

View File

@@ -3271,6 +3271,22 @@ namespace nana
modified_ptr->div_owner = div_owner;
modified_ptr->div_next = div_next;
if (div_owner)
{
implement::division * pv_div = nullptr;
//Updates the div_next of the div at front of modified one.
for (auto & div : div_owner->children)
{
if (div.get() == modified_ptr)
{
if (pv_div)
pv_div->div_next = modified_ptr;
break;
}
pv_div = div.get();
}
}
}
catch (...)
{

View File

@@ -194,6 +194,21 @@ namespace nana{
return impl_->place_content.field(field);
}
void group::field_display(const char* field_name, bool display)
{
impl_->place_content.field_display(field_name, display);
}
bool group::field_display(const char* field_name) const
{
return impl_->place_content.field_display(field_name);
}
void group::erase(window handle)
{
impl_->place_content.erase(handle);
}
void group::_m_add_child(const char* field, widget* wdg)
{
impl_->place_content[field] << wdg->handle();

View File

@@ -316,6 +316,11 @@ namespace nana
return cont_.back().index;
}
void clear()
{
cont_.clear();
}
unsigned width_px() const noexcept ///< the visible width of the whole header
{
unsigned pixels = 0;
@@ -1538,9 +1543,37 @@ namespace nana
return n;
}
template<typename Pred>
std::vector<std::pair<index_pair, bool>> select_display_range_if(const index_pair& fr_abs, index_pair to_dpl, bool deselect_others, Pred pred)
/// Finds a good item or category if an item specified by pos is invaild
index_pair find_next_good(index_pair pos, bool ignore_category) const noexcept
{
//Return the pos if it is good
if (this->good(pos))
return pos;
while(pos.cat < this->categories_.size())
{
if ((pos.npos == pos.item) && !ignore_category)
return pos;
auto cat_item_size = this->get(pos.cat)->items.size();
if (pos.item < cat_item_size)
return pos;
if ((pos.npos == pos.item) && (cat_item_size > 0) && ignore_category)
return index_pair{ pos.cat, 0 };
++pos.cat;
pos.item = pos.npos;
}
return index_pair{};
}
template<typename Pred>
std::vector<std::pair<index_pair, bool>> select_display_range_if(index_pair fr_abs, index_pair to_dpl, bool deselect_others, Pred pred)
{
fr_abs = find_next_good(fr_abs, true);
if (to_dpl.empty())
{
if (fr_abs.empty())
@@ -1548,6 +1581,7 @@ namespace nana
to_dpl = this->last();
}
auto fr_dpl = (fr_abs.is_category() ? fr_abs : this->index_cast(fr_abs, false)); //Converts an absolute position to display position
if (fr_dpl > to_dpl)
@@ -5467,6 +5501,15 @@ namespace nana
return pos;
}
void listbox::clear_headers()
{
internal_scope_guard lock;
auto & ess = _m_ess();
ess.lister.erase();
ess.header.clear();
ess.update();
}
listbox::cat_proxy listbox::append(std::string s)
{
internal_scope_guard lock;

View File

@@ -625,6 +625,13 @@ namespace nana
{
return get_drawer_trigger().ess().items.size();
}
void menubar::clear()
{
internal_scope_guard lock;
get_drawer_trigger().ess().items.clear();
API::refresh_window(handle());
}
bool menubar::cancel()
{

View File

@@ -1,7 +1,7 @@
/*
* A Toolbar Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -55,8 +55,7 @@ namespace nana
~item_container()
{
for(auto ptr : cont_)
delete ptr;
clear();
}
void insert(size_type pos, std::string text, const nana::paint::image& img, item_type::kind type)
@@ -118,6 +117,15 @@ namespace nana
{
return cont_.at(pos);
}
void clear()
{
for(auto ptr : cont_)
delete ptr;
cont_.clear();
}
private:
container_type cont_;
size_t right_{ npos };
@@ -467,6 +475,12 @@ namespace nana
return {*this, get_drawer_trigger().items().size() - 1u};
}
void toolbar::clear()
{
get_drawer_trigger().items().clear();
API::refresh_window(this->handle());
}
bool toolbar::enable(size_type pos) const
{
auto & items = get_drawer_trigger().items();

View File

@@ -1,7 +1,7 @@
/*
* A Treebox Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -958,10 +958,14 @@ namespace nana
return *this;
}
std::size_t item_proxy::size() const
{
std::size_t n = 0;
for(auto child = node_->child; child; child = child->child)
//Fixed by ErrorFlynn
//this method incorrectly returned the number of levels beneath the nodes using child = child->child
for(auto child = node_->child; child; child = child->next)
++n;
return n;