code review of listbox

This commit is contained in:
Jinhao 2015-10-01 02:51:30 +08:00
parent 1d94948887
commit 4cfe366758
2 changed files with 122 additions and 147 deletions

View File

@ -185,9 +185,7 @@ namespace nana
public: public:
trigger(); trigger();
~trigger(); ~trigger();
//essence_t& essence(); //deprecated
essence_t& essence() const; essence_t& essence() const;
void draw();
private: private:
void _m_draw_border(); void _m_draw_border();
private: private:

View File

@ -388,15 +388,14 @@ namespace nana
sortable_ = enable; sortable_ = enable;
} }
std::function<bool(const nana::string&, nana::any*, const nana::string&, nana::any*, bool reverse)> fetch_comp(std::size_t index) const std::function<bool(const nana::string&, nana::any*, const nana::string&, nana::any*, bool reverse)> fetch_comp(std::size_t pos) const
{ {
if(index < cont_.size()) try
{
return column_ref(pos).weak_ordering;
}
catch (...)
{ {
for(auto & m : cont_)
{
if(m.index == index)
return m.weak_ordering;
}
} }
return{}; return{};
} }
@ -409,20 +408,17 @@ namespace nana
void item_width(size_type pos, unsigned width) void item_width(size_type pos, unsigned width)
{ {
for(auto & m : cont_) column(pos).pixels = width;
if(m.index == pos)
{
m.pixels = width;
return;
}
} }
unsigned item_width(size_type pos) const unsigned item_width(size_type pos) const throw()
{ {
for (auto & m : cont_) try
{
return column_ref(pos).pixels;
}
catch (...)
{ {
if (m.index == pos)
return m.pixels;
} }
return 0; return 0;
} }
@ -535,9 +531,8 @@ namespace nana
/// move the col originaly at index to the position currently in front (or after) the col originaly at index "to" invalidating some current index /// move the col originaly at index to the position currently in front (or after) the col originaly at index "to" invalidating some current index
void move(size_type index, size_type to, bool front) throw() void move(size_type index, size_type to, bool front) throw()
{ {
if(index == to) return; if ((index == to) || (index >= cont_.size()) || (to >= cont_.size()))
if(index >= cont_.size()) return; return;
if(to >= cont_.size()) return;
for (auto i = cont_.begin(); i != cont_.end(); ++i) for (auto i = cont_.begin(); i != cont_.end(); ++i)
{ {
@ -711,7 +706,7 @@ namespace nana
nana::any * anyobj(const index_pair& id, bool allocate_if_empty) const nana::any * anyobj(const index_pair& id, bool allocate_if_empty) const
{ {
auto& catobj = *_m_at(id.cat); auto& catobj = *get(id.cat);
if(id.item < catobj.items.size()) if(id.item < catobj.items.size())
{ {
auto& item = catobj.items[id.item]; auto& item = catobj.items[id.item];
@ -880,22 +875,13 @@ namespace nana
/// add a new cat created at "pos" and return a ref to it /// add a new cat created at "pos" and return a ref to it
category_t* create_cat(std::size_t pos, nana::string&& text) category_t* create_cat(std::size_t pos, nana::string&& text)
{ {
#if defined(NANA_LINUX) || defined(NANA_MINGW) return &(*list_.emplace(this->get(pos), std::move(text)));
//Call begin instead of cbegin, because the first parameter
//of emplace is not const_iterator in GCC's C++ standard
//library implementation.
auto i = list_.begin();
#else
auto i = list_.cbegin();
#endif
std::advance(i, pos);
return &(*list_.emplace(i, std::move(text)));
} }
/// Insert before item in absolute "pos" a new item with "text" in column 0, and place it in last display position of this cat /// Insert before item in absolute "pos" a new item with "text" in column 0, and place it in last display position of this cat
bool insert(const index_pair& pos, nana::string&& text) bool insert(const index_pair& pos, nana::string&& text)
{ {
auto & catobj = *_m_at(pos.cat); auto & catobj = *get(pos.cat);
const auto n = catobj.items.size(); const auto n = catobj.items.size();
if (pos.item > n) if (pos.item > n)
@ -914,7 +900,7 @@ namespace nana
/// convert from display order to absolute (find the real item in that display pos) but without check from current active sorting, in fact using just the last sorting !!! /// convert from display order to absolute (find the real item in that display pos) but without check from current active sorting, in fact using just the last sorting !!!
size_type index_by_display_order(size_type cat, size_type display_order_pos) const size_type index_by_display_order(size_type cat, size_type display_order_pos) const
{ {
auto & catobj = *_m_at(cat); auto & catobj = *get(cat);
if (display_order_pos >= catobj.sorted.size()) if (display_order_pos >= catobj.sorted.size())
throw std::out_of_range("listbox: Invalid item position."); throw std::out_of_range("listbox: Invalid item position.");
@ -924,7 +910,7 @@ namespace nana
/// find display order for the real item but without check from current active sorting, in fact using just the last sorting !!! /// find display order for the real item but without check from current active sorting, in fact using just the last sorting !!!
size_type display_order(size_type cat, size_type pos) const size_type display_order(size_type cat, size_type pos) const
{ {
auto & catobj = *_m_at(cat); auto& catobj = *get(cat);
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.");
@ -934,15 +920,16 @@ namespace nana
return npos ; return npos ;
} }
/*
category_t& at(std::size_t cat_pos) category_t& at(std::size_t cat_pos)
{ {
return *(_m_at(cat_pos)); return *(_m_at(cat_pos));
} }
*/
category_t::container::value_type& at_abs(const index_pair& pos) category_t::container::value_type& at_abs(const index_pair& pos)
{ {
return _m_at(pos.cat)->items.at(pos.item); return get(pos.cat)->items.at(pos.item);
} }
/// return a ref to the real item object at display!!! position pos using current sorting only if it is active, and at absolute position if no sorting is currently active. /// return a ref to the real item object at display!!! position pos using current sorting only if it is active, and at absolute position if no sorting is currently active.
@ -953,7 +940,7 @@ namespace nana
if (sorted_index_ != npos) if (sorted_index_ != npos)
index = absolute(pos); index = absolute(pos);
return _m_at(pos.cat)->items.at(index); return get(pos.cat)->items.at(index);
} }
const category_t::container::value_type& at(const index_pair& pos) const const category_t::container::value_type& at(const index_pair& pos) const
@ -963,12 +950,12 @@ namespace nana
if (sorted_index_ != npos) if (sorted_index_ != npos)
index = absolute(pos); index = absolute(pos);
return _m_at(pos.cat)->items.at(index); return get(pos.cat)->items.at(index);
} }
void clear(size_type cat) void clear(size_type cat)
{ {
auto& catobj = *_m_at(cat); auto& catobj = *get(cat);
catobj.items.clear(); catobj.items.clear();
catobj.sorted.clear(); catobj.sorted.clear();
} }
@ -1051,7 +1038,7 @@ namespace nana
std::swap(from, to); std::swap(from, to);
size_type n = 0; size_type n = 0;
auto i = _m_at(from.cat); auto i = get(from.cat);
if(from.item == npos) if(from.item == npos)
{ {
if(i->expand) if(i->expand)
@ -1130,7 +1117,7 @@ namespace nana
void erase(size_type cat) void erase(size_type cat)
{ {
auto i = _m_at(cat); auto i = get(cat);
//If the category is the first one, it just clears the items instead of removing whole category. //If the category is the first one, it just clears the items instead of removing whole category.
if(0 == cat) if(0 == cat)
@ -1156,7 +1143,7 @@ namespace nana
{ {
if(good(cat)) if(good(cat))
{ {
auto & expanded = _m_at(cat)->expand; auto & expanded = get(cat)->expand;
if(expanded != exp) if(expanded != exp)
{ {
expanded = exp; expanded = exp;
@ -1168,7 +1155,7 @@ namespace nana
bool expand(size_type cat) const bool expand(size_type cat) const
{ {
return (good(cat) ? _m_at(cat)->expand : false); return (good(cat) ? get(cat)->expand : false);
} }
container& cat_container() container& cat_container()
@ -1394,8 +1381,7 @@ namespace nana
if (for_selection ? single_selection_category_limited_ : single_check_category_limited_) if (for_selection ? single_selection_category_limited_ : single_check_category_limited_)
{ {
auto i = list_.begin(); auto i = this->get(except.cat);
std::advance(i, except.cat);
std::size_t item_pos = 0; std::size_t item_pos = 0;
for (auto & m : i->items) for (auto & m : i->items)
@ -1541,12 +1527,12 @@ namespace nana
size_type size_item(size_type cat) const size_type size_item(size_type cat) const
{ {
return _m_at(cat)->items.size(); return get(cat)->items.size();
} }
bool categ_checked(size_type cat) const bool categ_checked(size_type cat) const
{ {
auto & items = _m_at(cat)->items; auto& items = get(cat)->items;
for(auto & m : items) for(auto & m : items)
{ {
if(m.flags.checked == false) if(m.flags.checked == false)
@ -1558,7 +1544,7 @@ namespace nana
bool categ_checked(size_type cat, bool ck) bool categ_checked(size_type cat, bool ck)
{ {
bool changed = false; bool changed = false;
auto & items = _m_at(cat)->items; auto & items = get(cat)->items;
size_type index = 0; size_type index = 0;
for(auto & m : items) for(auto & m : items)
{ {
@ -1585,7 +1571,7 @@ namespace nana
bool categ_selected(size_type cat) const bool categ_selected(size_type cat) const
{ {
auto & items = _m_at(cat)->items; auto & items = get(cat)->items;
for(auto & m : items) for(auto & m : items)
if(m.flags.selected == false) if(m.flags.selected == false)
return false; return false;
@ -1661,7 +1647,7 @@ namespace nana
return true; return true;
} }
auto i = _m_at(pos.cat); // pos is not a cat and i point to it cat auto i = get(pos.cat); // pos is not a cat and i point to it cat
if (pos.item < i->items.size()) if (pos.item < i->items.size())
{ {
item = pos; // good item, return it item = pos; // good item, return it
@ -1682,8 +1668,7 @@ namespace nana
if(sorted_index_ == npos || display_pos.item == npos) if(sorted_index_ == npos || display_pos.item == npos)
return display_pos.item ; return display_pos.item ;
auto & catobj = *_m_at(display_pos.cat); auto & catobj = *get(display_pos.cat);
if(catobj.items.empty()) if(catobj.items.empty())
return (display_pos == index_pair{0,0} ? 0 : npos); return (display_pos == index_pair{0,0} ? 0 : npos);
@ -1702,7 +1687,7 @@ namespace nana
if (sorted_index_ == npos) if (sorted_index_ == npos)
return pos.item ; return pos.item ;
auto & catobj = *_m_at(pos.cat); auto& catobj = *get(pos.cat);
for (size_type i=0; i<catobj.sorted.size();++i) for (size_type i=0; i<catobj.sorted.size();++i)
if (pos.item == catobj.sorted[i]) if (pos.item == catobj.sorted[i])
@ -1726,7 +1711,7 @@ namespace nana
if (!good_item(from, from)) if (!good_item(from, from))
return false; return false;
auto cat = _m_at(from.cat); auto cat = get(from.cat);
auto cat_end = list_.end(); auto cat_end = list_.end();
auto items_left = (cat->expand ? cat->items.size() : 0); auto items_left = (cat->expand ? cat->items.size() : 0);
@ -1768,7 +1753,7 @@ namespace nana
if(good(from.cat)) if(good(from.cat))
{ {
auto i = _m_at(from.cat); auto i = get(from.cat);
size_type n = (from.is_category() ? 1 : from.item + 2); // ?? size_type n = (from.is_category() ? 1 : from.item + 2); // ??
if(n <= offs) if(n <= offs)
{ {
@ -1802,25 +1787,25 @@ namespace nana
} }
return false; return false;
} }
private:
/// categories iterator /// categories iterator
container::iterator _m_at(size_type index) container::iterator get(size_type pos)
{ {
if(index >= list_.size()) if (pos >= list_.size())
throw std::out_of_range("nana::listbox: invalid category index"); throw std::out_of_range("nana::listbox: invalid category index");
auto i = list_.begin(); auto i = list_.begin();
std::advance(i, index); std::advance(i, pos);
return i; return i;
} }
container::const_iterator _m_at(size_type index) const container::const_iterator get(size_type pos) const
{ {
if(index >= list_.size()) if (pos >= list_.size())
throw std::out_of_range("nana::listbox: invalid category index"); throw std::out_of_range("nana::listbox: invalid category index");
auto i = list_.cbegin(); auto i = list_.cbegin();
std::advance(i, index); std::advance(i, pos);
return i; return i;
} }
public: public:
@ -2065,6 +2050,25 @@ namespace nana
unsigned width = sz.width - 2 - (v ? scroll.scale : 0); unsigned width = sz.width - 2 - (v ? scroll.scale : 0);
unsigned height = sz.height - 2 - (h ? scroll.scale : 0); unsigned height = sz.height - 2 - (h ? scroll.scale : 0);
//event hander for scrollbars
auto evt_fn = [this](const arg_scroll& arg)
{
if (scroll.h.empty() || (scroll.h.handle() != arg.window_handle))
{
index_pair item;
if (!lister.forward(item, scroll.v.value(), item)) return;
if (item == scroll.offset_y_dpl)
return;
set_scroll_y_dpl(item);
}
else
scroll.offset_x = static_cast<int>(scroll.h.value());
API::refresh_window(this->lister.wd_ptr()->handle());
};
if(h) if(h)
{ {
rectangle r(1, sz.height - scroll.scale - 1, width, scroll.scale); rectangle r(1, sz.height - scroll.scale - 1, width, scroll.scale);
@ -2072,12 +2076,7 @@ namespace nana
{ {
scroll.h.create(wd, r); scroll.h.create(wd, r);
API::take_active(scroll.h.handle(), false, wd); API::take_active(scroll.h.handle(), false, wd);
scroll.h.events().value_changed.connect_unignorable(evt_fn);
scroll.h.events().value_changed.connect_unignorable([this](const ::nana::arg_scroll& arg)
{
scroll.offset_x = static_cast<int>(scroll.h.value());
API::refresh_window(this->lister.wd_ptr()->handle());
});
} }
else else
scroll.h.move(r); scroll.h.move(r);
@ -2092,19 +2091,7 @@ namespace nana
{ {
scroll.v.create(wd, r); scroll.v.create(wd, r);
API::take_active(scroll.v.handle(), false, wd); API::take_active(scroll.v.handle(), false, wd);
scroll.v.events().value_changed.connect_unignorable(evt_fn);
scroll.v.events().value_changed([this](const ::nana::arg_scroll& arg)
{
index_pair item;
if (!lister.forward(item, scroll.v.value(), item)) return;
if (item == scroll.offset_y_dpl)
return;
set_scroll_y_dpl(item);
API::refresh_window(this->lister.wd_ptr()->handle());
});
} }
else else
scroll.v.move(r); scroll.v.move(r);
@ -2150,8 +2137,7 @@ namespace nana
int item_xpos(const nana::rectangle& r) const int item_xpos(const nana::rectangle& r) const
{ {
std::vector<size_type> seq; auto seq = header_seq(r.width);
header_seq(seq, r.width);
return (seq.size() ? (header.item_pos(seq[0], nullptr) - scroll.offset_x + r.x) : 0); return (seq.size() ? (header.item_pos(seq[0], nullptr) - scroll.offset_x + r.x) : 0);
} }
@ -2277,18 +2263,21 @@ namespace nana
return true; return true;
} }
void header_seq(std::vector<size_type> &seqs, unsigned lister_w)const std::vector<size_type> header_seq(unsigned lister_w)const
{ {
int x = - (scroll.offset_x); std::vector<size_type> seqs;
for(const auto& hd : header.cont()) int x = -(scroll.offset_x);
for (const auto& hd : header.cont())
{ {
if(false == hd.visible) continue; if (false == hd.visible) continue;
x += static_cast<int>(hd.pixels); x += static_cast<int>(hd.pixels);
if(x > 0) if (x > 0)
seqs.push_back(hd.index); seqs.push_back(hd.index);
if(x >= static_cast<int>(lister_w)) if (x >= static_cast<int>(lister_w))
break; break;
} }
return seqs;
} }
unsigned auto_width(size_type pos, unsigned max = 3000) /// \todo introduce parametr max_header_width unsigned auto_width(size_type pos, unsigned max = 3000) /// \todo introduce parametr max_header_width
@ -2398,7 +2387,7 @@ namespace nana
void es_lister::erase(const index_pair& pos) void es_lister::erase(const index_pair& pos)
{ {
auto & catobj = *_m_at(pos.cat); auto & catobj = *get(pos.cat);
if (pos.item < catobj.items.size()) if (pos.item < catobj.items.size())
{ {
catobj.items.erase(catobj.items.begin() + pos.item); catobj.items.erase(catobj.items.begin() + pos.item);
@ -2782,8 +2771,7 @@ namespace nana
if((ptr_where.first == parts::lister || ptr_where.first == parts::checker) && ptr_where.second != npos) if((ptr_where.first == parts::lister || ptr_where.first == parts::checker) && ptr_where.second != npos)
lister.forward(essence_->scroll.offset_y_dpl, ptr_where.second, tracker); lister.forward(essence_->scroll.offset_y_dpl, ptr_where.second, tracker);
std::vector<size_type> subitems; auto subitems = essence_->header_seq(rect.width);
essence_->header_seq(subitems, rect.width);
if(subitems.empty()) if(subitems.empty())
return; return;
@ -2792,8 +2780,7 @@ namespace nana
int y = rect.y; int y = rect.y;
int txtoff = (essence_->item_size - essence_->text_height) / 2; int txtoff = (essence_->item_size - essence_->text_height) / 2;
auto i_categ = lister.cat_container().cbegin(); auto i_categ = lister.get(essence_->scroll.offset_y_dpl.cat);
std::advance(i_categ, essence_->scroll.offset_y_dpl.cat);
auto idx = essence_->scroll.offset_y_dpl; auto idx = essence_->scroll.offset_y_dpl;
@ -2859,17 +2846,14 @@ namespace nana
essence_->inline_buffered_table.clear(); essence_->inline_buffered_table.clear();
if (y < rect.y + static_cast<int>(rect.height)) if (y < rect.bottom())
{ essence_->graph->rectangle(rectangle{ rect.x, y, rect.width, static_cast<unsigned>(rect.bottom() - y) }, true, bgcolor);
essence_->graph->set_color(bgcolor);
essence_->graph->rectangle(rectangle{ rect.x, y, rect.width, rect.y + rect.height - y }, true);
}
} }
private: private:
void _m_draw_categ(const category_t& categ, int x, int y, int txtoff, unsigned width, const nana::rectangle& r, nana::color bgcolor, item_state state) const void _m_draw_categ(const category_t& categ, int x, int y, int txtoff, unsigned width, const nana::rectangle& r, nana::color bgcolor, item_state state) const
{ {
bool sel = categ.selected(); const bool sel = categ.selected();
if(sel && (categ.expand == false)) if (sel && (categ.expand == false))
bgcolor = static_cast<color_rgb>(0xD5EFFC); bgcolor = static_cast<color_rgb>(0xD5EFFC);
if (state == item_state::highlighted) if (state == item_state::highlighted)
@ -2889,18 +2873,19 @@ namespace nana
::nana::string str = L'(' + std::to_wstring(categ.items.size()) + L')'; ::nana::string str = L'(' + std::to_wstring(categ.items.size()) + L')';
unsigned str_w = graph->text_extent_size(str).width; auto text_s = graph->text_extent_size(categ.text).width;
auto extend_text_w = text_s + graph->text_extent_size(str).width;
auto text_s = graph->text_extent_size(categ.text); graph->string({ x + 25 + static_cast<int>(text_s), y + txtoff }, str);
graph->string({ x + 25 + static_cast<int>(text_s.width), y + txtoff }, str);
if (x + 35 + text_s.width + str_w < x + width) if (x + 35 + extend_text_w < x + width)
{ {
::nana::point pos{ x + 30 + static_cast<int>(text_s.width + str_w), y + static_cast<int>(essence_->item_size) / 2 }; ::nana::point pos{ x + 30 + static_cast<int>(extend_text_w), y + static_cast<int>(essence_->item_size) / 2 };
graph->line(pos, { x + static_cast<int>(width)-5, pos.y }, txt_color); graph->line(pos, { x + static_cast<int>(width)-5, pos.y }, txt_color);
} }
//Draw selecting inner rectangle //Draw selecting inner rectangle
if(sel && categ.expand == false) if (sel && (categ.expand == false))
{ {
width -= essence_->scroll.offset_x; width -= essence_->scroll.offset_x;
_m_draw_border(r.x, y, (r.width < width ? r.width : width)); _m_draw_border(r.x, y, (r.width < width ? r.width : width));
@ -2934,8 +2919,7 @@ namespace nana
auto graph = essence_->graph; auto graph = essence_->graph;
//draw the background //draw the background
graph->set_color(bgcolor); graph->rectangle(rectangle{ content_r.x, y, show_w, essence_->item_size }, true, bgcolor);
graph->rectangle(rectangle{ content_r.x, y, show_w, essence_->item_size }, true);
int item_xpos = x; int item_xpos = x;
unsigned extreme_text = x; unsigned extreme_text = x;
@ -3113,7 +3097,7 @@ namespace nana
essence_t::inline_pane* _m_find_inline_pane(const index_pair& pos, std::size_t column_pos) const essence_t::inline_pane* _m_find_inline_pane(const index_pair& pos, std::size_t column_pos) const
{ {
auto & cat = essence_->lister.at(pos.cat); auto & cat = *essence_->lister.get(pos.cat);
if (column_pos >= cat.factories.size()) if (column_pos >= cat.factories.size())
return nullptr; return nullptr;
@ -3138,10 +3122,9 @@ namespace nana
{ {
//Draw selecting inner rectangle //Draw selecting inner rectangle
auto graph = essence_->graph; auto graph = essence_->graph;
graph->rectangle({ x, y, width, essence_->item_size }, false, { 0x99, 0xDE, 0xFD }); graph->rectangle({ x, y, width, essence_->item_size }, false, static_cast<color_rgb>(0x99defd));
graph->set_color(colors::white); graph->rectangle({ x + 1, y + 1, width - 2, essence_->item_size - 2 }, false, colors::white);
graph->rectangle({ x + 1, y + 1, width - 2, essence_->item_size - 2 }, false);
graph->set_pixel(x, y); graph->set_pixel(x, y);
graph->set_pixel(x, y + essence_->item_size - 1); graph->set_pixel(x, y + essence_->item_size - 1);
graph->set_pixel(x + width - 1, y); graph->set_pixel(x + width - 1, y);
@ -3171,20 +3154,6 @@ namespace nana
return *essence_; return *essence_;
} }
void trigger::draw()
{
if (API::is_destroying(essence_->lister.wd_ptr()->handle()))
return;
nana::rectangle r;
if(essence_->header.visible() && essence_->rect_header(r))
drawer_header_->draw(r);
if(essence_->rect_lister(r))
drawer_lister_->draw(r);
_m_draw_border();
}
void trigger::_m_draw_border() void trigger::_m_draw_border()
{ {
if (API::widget_borderless(*essence_->lister.wd_ptr())) if (API::widget_borderless(*essence_->lister.wd_ptr()))
@ -3229,7 +3198,16 @@ namespace nana
void trigger::refresh(graph_reference) void trigger::refresh(graph_reference)
{ {
draw(); if (API::is_destroying(essence_->lister.wd_ptr()->handle()))
return;
nana::rectangle r;
if (essence_->header.visible() && essence_->rect_header(r))
drawer_header_->draw(r);
if (essence_->rect_lister(r))
drawer_lister_->draw(r);
_m_draw_border();
} }
void trigger::mouse_move(graph_reference graph, const arg_mouse& arg) void trigger::mouse_move(graph_reference graph, const arg_mouse& arg)
@ -3291,7 +3269,7 @@ namespace nana
if (update) if (update)
{ {
if (2 == update) if (2 == update)
draw(); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
} }
@ -3309,7 +3287,7 @@ namespace nana
essence_->ptr_state = item_state::normal; essence_->ptr_state = item_state::normal;
} }
draw(); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
} }
} }
@ -3425,7 +3403,7 @@ namespace nana
if(essence_->lister.sort_index(essence_->pointer_where.second)) if(essence_->lister.sort_index(essence_->pointer_where.second))
{ {
essence_->trace_item_dpl({0,0}); essence_->trace_item_dpl({0,0});
draw(); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
} }
} }
@ -3435,7 +3413,7 @@ namespace nana
nana::point pos = arg.pos; nana::point pos = arg.pos;
essence_->widget_to_header(pos); essence_->widget_to_header(pos);
drawer_header_->grab(pos, false); drawer_header_->grab(pos, false);
draw(); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
API::capture_window(essence_->lister.wd_ptr()->handle(), false); API::capture_window(essence_->lister.wd_ptr()->handle(), false);
} }
@ -3445,7 +3423,7 @@ namespace nana
{ {
if(essence_->wheel(arg.upwards)) if(essence_->wheel(arg.upwards))
{ {
draw(); refresh(graph);
essence_->adjust_scroll_value(); essence_->adjust_scroll_value();
API::lazy_refresh(); API::lazy_refresh();
} }
@ -3484,7 +3462,7 @@ namespace nana
offset_y = last; offset_y = last;
} }
essence_->adjust_scroll_life(); essence_->adjust_scroll_life();
draw(); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
} }
} }
@ -3492,7 +3470,7 @@ namespace nana
void trigger::resized(graph_reference graph, const arg_resized&) void trigger::resized(graph_reference graph, const arg_resized&)
{ {
essence_->adjust_scroll_life(); essence_->adjust_scroll_life();
draw(); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
} }
@ -3565,7 +3543,7 @@ namespace nana
default: default:
return; return;
} }
draw(); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
} }
@ -3578,12 +3556,12 @@ namespace nana
export_options exp_opt {essence_->def_export_options()}; export_options exp_opt {essence_->def_export_options()};
exp_opt.columns_order = essence_->header.all_headers(true); exp_opt.columns_order = essence_->header.all_headers(true);
exp_opt.only_selected_items = true; exp_opt.only_selected_items = true;
nana::system::dataexch().set(essence_->to_string(exp_opt)); ::nana::system::dataexch().set(essence_->to_string(exp_opt));
return; return;
} }
case keyboard::select_all : case keyboard::select_all :
essence_->lister.select_for_all(true); essence_->lister.select_for_all(true);
draw(); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
break; break;
@ -3605,8 +3583,9 @@ namespace nana
{ {
if (ess) if (ess)
{ {
auto i = ess_->lister.cat_container().begin(); //auto i = ess_->lister.cat_container().begin();
std::advance(i, pos.cat); //std::advance(i, pos.cat);
auto i = ess_->lister.get(pos.cat);
cat_ = &(*i); // what is pos is a cat? cat_ = &(*i); // what is pos is a cat?
} }
} }
@ -3949,8 +3928,7 @@ namespace nana
//Behavior of a container //Behavior of a container
item_proxy cat_proxy::begin() const item_proxy cat_proxy::begin() const
{ {
auto i = ess_->lister.cat_container().begin(); auto i = ess_->lister.get(pos_);
std::advance(i, pos_);
if (i->items.empty()) if (i->items.empty())
return end(); return end();
@ -4137,8 +4115,7 @@ namespace nana
return; return;
} }
auto i = ess_->lister.cat_container().begin(); auto i = ess_->lister.get(pos_);
std::advance(i, pos_);
cat_ = &(*i); cat_ = &(*i);
} }
//class cat_proxy //class cat_proxy