Merge branch 'hotfixes-1.0.1' of https://github.com/qPCR4vir/nana into qPCR4vir-hotfixes-1.0.1

This commit is contained in:
Jinhao 2015-03-22 11:37:45 +08:00
commit a3c69418ea
2 changed files with 38 additions and 9 deletions

View File

@ -129,22 +129,26 @@ namespace checkbox
checkbox::checkbox(window wd, bool visible) checkbox::checkbox(window wd, bool visible)
{ {
create(wd, rectangle(), visible); create(wd, rectangle(), visible);
bgcolor(API::bgcolor(wd));
} }
checkbox::checkbox(window wd, const nana::string& text, bool visible) checkbox::checkbox(window wd, const nana::string& text, bool visible)
{ {
create(wd, rectangle(), visible); create(wd, rectangle(), visible);
bgcolor(API::bgcolor(wd));
caption(text); caption(text);
} }
checkbox::checkbox(window wd, const nana::char_t* text, bool visible) checkbox::checkbox(window wd, const nana::char_t* text, bool visible)
{ {
create(wd, rectangle(), visible); create(wd, rectangle(), visible);
bgcolor(API::bgcolor(wd));
caption(text); caption(text);
} }
checkbox::checkbox(window wd, const nana::rectangle& r, bool visible) checkbox::checkbox(window wd, const nana::rectangle& r, bool visible)
{ {
bgcolor(API::bgcolor(wd));
create(wd, r, visible); create(wd, r, visible);
} }

View File

@ -841,8 +841,11 @@ namespace nana
if (pos >= catobj.sorted.size()) if (pos >= catobj.sorted.size())
throw std::out_of_range("listbox: Invalid item position."); throw std::out_of_range("listbox: Invalid item position.");
auto i = std::find(catobj.sorted.begin(), catobj.sorted.end(), pos); for (size_type i=0; i<catobj.sorted.size();++i)
return (i != catobj.sorted.end() ? *i : npos); if (pos==catobj.sorted[i])
return i;
return npos ;
} }
category_t::container::value_type& at(const index_pair& pos) category_t::container::value_type& at(const index_pair& pos)
@ -1178,6 +1181,21 @@ namespace nana
if (to.is_item()) if (to.is_item())
item_proxy(ess_, to).select(sel); item_proxy(ess_, to).select(sel);
} }
void select_display_range(index_pair fr_abs, index_pair to_dpl, bool sel)
{
index_pair fr_dpl (fr_abs.cat, this->display_order(fr_abs.cat, fr_abs.item));
if (fr_dpl > to_dpl)
std::swap(fr_dpl, to_dpl);
for (; fr_dpl != to_dpl; forward(fr_dpl, 1, fr_dpl))
{
if (fr_dpl.is_item())
item_proxy(ess_, index_pair(fr_dpl.cat, absolute( fr_dpl ) )).select(sel);
}
if (to_dpl.is_item())
item_proxy(ess_, index_pair(to_dpl.cat, absolute( to_dpl ) )).select(sel);
}
bool select_for_all(bool sel) bool select_for_all(bool sel)
{ {
@ -2607,6 +2625,7 @@ namespace nana
graph->rectangle(rectangle{ r.x, y, show_w, essence_->item_size }, true); graph->rectangle(rectangle{ r.x, y, show_w, essence_->item_size }, true);
int item_xpos = x; int item_xpos = x;
unsigned extreme_text = x;
bool first = true; bool first = true;
for(auto index : seqs) for(auto index : seqs)
@ -2683,17 +2702,23 @@ namespace nana
graph->string(point{ xpos, y + 2 }, STR("...")); graph->string(point{ xpos, y + 2 }, STR("..."));
//Erase the part that over the next subitem. //Erase the part that over the next subitem.
if (index + 1 <= seqs.size()) if (index + 1 < seqs.size())
{ {
graph->set_color(bgcolor); graph->set_color(bgcolor);
graph->rectangle(rectangle{item_xpos + static_cast<int>(header.pixels), y + 2, ts.width + ext_w - header.pixels, essence_->item_size - 4}, true); graph->rectangle(rectangle{item_xpos + static_cast<int>(header.pixels), y + 2, ts.width + ext_w - header.pixels, essence_->item_size - 4}, true);
} }
extreme_text = std::max (extreme_text, item_xpos + ext_w + ts.width);
} }
} }
graph->line({ item_xpos - 1, y }, { item_xpos - 1, y + static_cast<int>(essence_->item_size) - 1 }, { 0xEB, 0xF4, 0xF9 }); graph->line({ item_xpos - 1, y }, { item_xpos - 1, y + static_cast<int>(essence_->item_size) - 1 }, { 0xEB, 0xF4, 0xF9 });
item_xpos += header.pixels; item_xpos += header.pixels;
if (index + 1 >= seqs.size() && extreme_text > item_xpos)
{
graph->set_color(item.bgcolor);
graph->rectangle(rectangle{item_xpos , y + 2, extreme_text - item_xpos, essence_->item_size - 4}, true);
}
first = false; first = false;
} }
@ -2916,14 +2941,14 @@ namespace nana
if (!lister.single_selection()) if (!lister.single_selection())
{ {
if (arg.shift) if (arg.shift)
lister.select_range(lister.last_selected, item_pos, sel); lister.select_display_range(lister.last_selected, item_pos, sel);
else if (arg.ctrl) else if (arg.ctrl)
sel = !item_proxy(essence_, item_pos).selected(); sel = !item_proxy(essence_, index_pair (item_pos.cat, lister.absolute(item_pos))).selected();
else else
lister.select_for_all(false); lister.select_for_all(false);
} }
else else
sel = !item_proxy(essence_, item_pos).selected(); sel = !item_proxy(essence_, index_pair (item_pos.cat, lister.absolute(item_pos))).selected();
if(item_ptr) if(item_ptr)
{ {