Merge branch 'develop' of https://github.com/leobackes/nana into leobackes-develop

This commit is contained in:
Jinhao 2016-01-24 12:05:54 +08:00
commit 64d81143e6
2 changed files with 81 additions and 20 deletions

View File

@ -466,13 +466,24 @@ namespace nana
} }
}//end namespace drawerbase }//end namespace drawerbase
struct arg_listbox struct arg_listbox
: public event_arg
{
mutable drawerbase::listbox::item_proxy item;
bool selected;
arg_listbox(const drawerbase::listbox::item_proxy&, bool selected);
};
struct arg_category
: public event_arg : public event_arg
{ {
mutable drawerbase::listbox::item_proxy item; drawerbase::listbox::cat_proxy category;
bool selected; void block_category_change() const;
bool category_change_blocked() const;
arg_listbox(const drawerbase::listbox::item_proxy&, bool selected); arg_category(const drawerbase::listbox::cat_proxy&);
private:
mutable bool _m_block_change;
}; };
namespace drawerbase namespace drawerbase
@ -484,6 +495,7 @@ namespace nana
{ {
basic_event<arg_listbox> checked; basic_event<arg_listbox> checked;
basic_event<arg_listbox> selected; basic_event<arg_listbox> selected;
basic_event<arg_category> category_dbl_click;
}; };
struct scheme struct scheme
@ -615,6 +627,9 @@ By \a clicking on one header the list get \a reordered, first up, and then down
} }
item_proxy at(const index_pair &abs_pos) const; item_proxy at(const index_pair &abs_pos) const;
index_pair at(const point & pos) const;
columns_indexs column_from_pos(const point & pos);
void insert(const index_pair&, ::std::string); ///<Insert a new item with a text in the first column. void insert(const index_pair&, ::std::string); ///<Insert a new item with a text in the first column.
void insert(const index_pair&, ::std::wstring); ///<Insert a new item with a text in the first column. void insert(const index_pair&, ::std::wstring); ///<Insert a new item with a text in the first column.

View File

@ -2168,9 +2168,8 @@ namespace nana
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);
} }
bool calc_where(int x, int y) std::pair<parts, size_t> where(int x, int y){
{ std::pair<parts, size_t> new_where;
decltype(pointer_where) new_where;
if(2 < x && x < static_cast<int>(graph->width()) - 2 && 1 < y && y < static_cast<int>(graph->height()) - 1) if(2 < x && x < static_cast<int>(graph->width()) - 2 && 1 < y && y < static_cast<int>(graph->height()) - 1)
{ {
@ -2201,7 +2200,12 @@ namespace nana
new_where.first = parts::unknown; new_where.first = parts::unknown;
new_where.second = npos; new_where.second = npos;
} }
return new_where;
}
bool calc_where(int x, int y)
{
std::pair< parts, size_t > new_where=where(x,y);
if (new_where == pointer_where) if (new_where == pointer_where)
return false; return false;
@ -3545,7 +3549,7 @@ namespace nana
} }
} }
void trigger::dbl_click(graph_reference graph, const arg_mouse&) void trigger::dbl_click(graph_reference graph, const arg_mouse& arg)
{ {
if (essence_->pointer_where.first == essence_t::parts::header) if (essence_->pointer_where.first == essence_t::parts::header)
if (cursor::size_we == essence_->lister.wd_ptr()->cursor()) if (cursor::size_we == essence_->lister.wd_ptr()->cursor())
@ -3567,19 +3571,24 @@ namespace nana
if (!item_pos.is_category()) //being the npos of item.second is a category if (!item_pos.is_category()) //being the npos of item.second is a category
return; return;
bool do_expand = (lister.expand(item_pos.cat) == false); arg_category ai(cat_proxy(essence_, item_pos.cat));
lister.expand(item_pos.cat, do_expand); lister.wd_ptr()->events().category_dbl_click.emit(ai);
if(false == do_expand) if(!ai.category_change_blocked()){
{ bool do_expand = (lister.expand(item_pos.cat) == false);
auto last = lister.last(); lister.expand(item_pos.cat, do_expand);
size_type n = essence_->number_of_lister_items(false);
if (lister.backward(last, n, last)) if(false == do_expand)
offset_y = last; {
} auto last = lister.last();
essence_->adjust_scroll_life(); size_type n = essence_->number_of_lister_items(false);
refresh(graph); if (lister.backward(last, n, last))
API::lazy_refresh(); offset_y = last;
}
essence_->adjust_scroll_life();
refresh(graph);
API::lazy_refresh();
}
} }
} }
@ -4285,6 +4294,22 @@ namespace nana
{ {
} }
arg_category::arg_category ( const nana::drawerbase::listbox::cat_proxy& cat )
: category(cat), _m_block_change(false)
{
}
void arg_category::block_category_change() const {
_m_block_change=true;
}
bool arg_category::category_change_blocked() const {
return _m_block_change;
}
//class listbox //class listbox
listbox::listbox(window wd, bool visible) listbox::listbox(window wd, bool visible)
{ {
@ -4456,6 +4481,27 @@ namespace nana
return at(pos_abs.cat).at(pos_abs.item); return at(pos_abs.cat).at(pos_abs.item);
} }
listbox::index_pair listbox::at ( const point& pos ) const
{
auto & ess=_m_ess();
auto _where=ess.where(pos.x, pos.y);
index_pair item_pos{npos,npos};
if(_where.first==drawerbase::listbox::essence_t::parts::lister){
auto & offset_y = ess.scroll.offset_y_dpl;
ess.lister.forward(offset_y, _where.second, item_pos);
}
return item_pos;
}
listbox::columns_indexs listbox::column_from_pos ( const point& pos )
{
auto & ess=_m_ess();
columns_indexs col=ess.header.item_by_x(pos.x - 2 - ess.scroll.offset_x);
return col;
}
void listbox::insert(const index_pair& pos, std::string text) void listbox::insert(const index_pair& pos, std::string text)
{ {
internal_scope_guard lock; internal_scope_guard lock;