From 10f35de8f72310ad37ec6922c6464f0a8425a944 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 21 Mar 2015 18:17:50 +0100 Subject: [PATCH 1/6] fix: make checkbox and label have the same bgcolor as the owner --- source/gui/widgets/checkbox.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/gui/widgets/checkbox.cpp b/source/gui/widgets/checkbox.cpp index 1a73f706..8993a8b7 100644 --- a/source/gui/widgets/checkbox.cpp +++ b/source/gui/widgets/checkbox.cpp @@ -129,22 +129,26 @@ namespace checkbox checkbox::checkbox(window wd, bool visible) { create(wd, rectangle(), visible); + bgcolor(API::bgcolor(wd)); } checkbox::checkbox(window wd, const nana::string& text, bool visible) { create(wd, rectangle(), visible); + bgcolor(API::bgcolor(wd)); caption(text); } checkbox::checkbox(window wd, const nana::char_t* text, bool visible) { create(wd, rectangle(), visible); + bgcolor(API::bgcolor(wd)); caption(text); } checkbox::checkbox(window wd, const nana::rectangle& r, bool visible) { + bgcolor(API::bgcolor(wd)); create(wd, r, visible); } From f93c71ed808249a486110a4efd7b3395b3ef259f Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 22 Mar 2015 02:54:18 +0100 Subject: [PATCH 2/6] FIX: minor problem erasing excess text of last cell in selected listbox item --- source/gui/widgets/listbox.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index ef7a7130..cb45040a 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2607,6 +2607,7 @@ namespace nana graph->rectangle(rectangle{ r.x, y, show_w, essence_->item_size }, true); int item_xpos = x; + unsigned extreme_text = x; bool first = true; for(auto index : seqs) @@ -2683,17 +2684,23 @@ namespace nana graph->string(point{ xpos, y + 2 }, STR("...")); //Erase the part that over the next subitem. - if (index + 1 <= seqs.size()) + if (index + 1 < seqs.size()) { graph->set_color(bgcolor); graph->rectangle(rectangle{item_xpos + static_cast(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(essence_->item_size) - 1 }, { 0xEB, 0xF4, 0xF9 }); 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; } From 835b3ce14562542ec49a3563ec603fd8321bc9fd Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 22 Mar 2015 02:56:03 +0100 Subject: [PATCH 3/6] FIX: return self pos (= *i ) --- source/gui/widgets/listbox.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index cb45040a..837af8b3 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -841,8 +841,11 @@ namespace nana if (pos >= catobj.sorted.size()) throw std::out_of_range("listbox: Invalid item position."); - auto i = std::find(catobj.sorted.begin(), catobj.sorted.end(), pos); - return (i != catobj.sorted.end() ? *i : npos); + for (size_type i=0; i Date: Sun, 22 Mar 2015 02:57:50 +0100 Subject: [PATCH 4/6] FIX: select range of items with shift and mouse when list is ordered --- source/gui/widgets/listbox.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 837af8b3..2fdd474a 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -1181,6 +1181,21 @@ namespace nana if (to.is_item()) 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) { @@ -2609,7 +2624,7 @@ namespace nana graph->set_color(bgcolor); 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; @@ -2688,7 +2703,7 @@ namespace nana //Erase the part that over the next subitem. if (index + 1 < seqs.size()) - { + { graph->set_color(bgcolor); graph->rectangle(rectangle{item_xpos + static_cast(header.pixels), y + 2, ts.width + ext_w - header.pixels, essence_->item_size - 4}, true); } @@ -2926,9 +2941,9 @@ namespace nana if (!lister.single_selection()) { 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) - sel = !item_proxy(essence_, item_pos).selected(); + sel = !item_proxy(essence_, item_pos).selected(); else lister.select_for_all(false); } @@ -2938,7 +2953,7 @@ namespace nana if(item_ptr) { item_ptr->flags.selected = sel; - index_pair last_selected(item_pos.cat, lister.absolute(item_pos)); + index_pair last_selected(item_pos.cat, lister.absolute(item_pos)); arg_listbox arg{item_proxy{essence_, last_selected}, sel}; lister.wd_ptr()->events().selected.emit(arg); From 0cbe4534fff56891220458cc64c0828d50c4c844 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 22 Mar 2015 03:07:21 +0100 Subject: [PATCH 5/6] FIX: unselect item with ctrl-click in ordered listbox --- source/gui/widgets/listbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 2fdd474a..22b87cf3 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2943,7 +2943,7 @@ namespace nana if (arg.shift) lister.select_display_range(lister.last_selected, item_pos, sel); 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 lister.select_for_all(false); } From 974e47d59e15cef5ab584cd4111429d5a4b9641d Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 22 Mar 2015 03:12:55 +0100 Subject: [PATCH 6/6] FIX ? : select - unselect item with click in single selection listbox --- source/gui/widgets/listbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 22b87cf3..5b2c4ff8 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2948,7 +2948,7 @@ namespace nana lister.select_for_all(false); } 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) {