diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index ca4bb8ed..87309008 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -477,6 +477,9 @@ namespace nana color_proxy header_grabbed{ static_cast(0x8BD6F6)}; color_proxy header_floated{ static_cast(0xBABBBC)}; color_proxy item_selected{ static_cast(0xD5EFFC) }; + + unsigned max_header_width{3000}, /// \todo how to implement some geometrical parameters ?? + ext_w = 5; }; } }//end namespace drawerbase @@ -490,22 +493,6 @@ The user can \a drag the header to \a resize it or to \a reorganize it. By \a clicking on one header the list get \a reordered, first up, and then down alternatively. 1. The resolver is used to resolute an object of the specified type for a listbox item. -2. The any_objective of listbox have a 2-Dimension indexing. The first dimension is for the category, and the second one is for the item of the specified category. - int main() - { - using namespace nana::gui; - form fm; - listbox lb(fm, nana::rectangle(10, 10, 280, 120)); - lb.append_header(STR("Header"), 200); - lb.append_item(STR("int")); - lb.append_item(STR("double")); - lb.anyobj(0, 0, 10); - lb.anyobj(0, 1, 0.1); - int * pi = lb.anyobj(0, 0); // it returns a nullptr if there is not an int object specified. - double * pd = lb.anyobj(0, 1); // it returns a nullptr if there is not an double object specified. - fm.show(); - exec(); - } 3. nana::listbox creates the category 0 by default. The member functions without the categ parameter operate the items that belong to category 0. 4. A sort compare is used for sorting the items. It is a strict weak ordering comparer that must meet the requirement: Irreflexivity (comp(x, x) returns false) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 3588576f..9c8eccf7 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2304,7 +2304,29 @@ namespace nana break; } } - private: + + unsigned auto_width(size_type pos, unsigned max=3000) /// \todo introduce parametr max_header_width + { + unsigned max_w{0} ; + for (const auto &cat : lister.cat_container()) + for (const auto &it : cat.items ) + { + if (pos >= it.cells.size()) continue; + // precalcule text geometry + unsigned ts = static_cast ( graph->text_extent_size(it.cells[pos].text).width); + if (max_w < ts) + max_w = ts; + } + if (!max_w) return 0; + + unsigned ext_w = scheme_ptr->ext_w ; + if( pos == 0 && checkable) // only before the first column (display_order=0 ?) + ext_w += 18; + header.item_width(pos, max_w + ext_w + 1 < max ? max_w + ext_w + 1 : max); + return max_w; + } + + private: void _m_answer_scroll(const arg_mouse& arg) { if(arg.evt_code == event_code::mouse_move && arg.left_button == false) return; @@ -2907,7 +2929,7 @@ namespace nana cell_txtcolor = m_cell.custom_format->fgcolor; } - int ext_w = 5; + int ext_w = essence_->scheme_ptr->ext_w; if(first && essence_->checkable) // draw the checkbox if need, only before the first column (display_order=0 ?) { ext_w += 18; @@ -3306,6 +3328,14 @@ namespace nana void trigger::dbl_click(graph_reference graph, const arg_mouse&) { + if (essence_->pointer_where.first == essence_t::parts::header) + if (cursor::size_we == essence_->lister.wd_ptr()->cursor()) + { + if (essence(). auto_width(drawer_header_->item_spliter() )) // ? in order + essence().update(); + return; + } + if (essence_->pointer_where.first != essence_t::parts::lister) return; @@ -4010,19 +4040,8 @@ namespace nana } unsigned listbox::auto_width(size_type pos, unsigned max) { - unsigned max_w{0}; auto & ess = _m_ess(); - for (const auto &cat : ess.lister.cat_container()) - for (const auto &it : cat.items ) - { - if (pos >= it.cells.size()) continue; - // precalcule text geometry - unsigned ts = static_cast ( ess.graph->text_extent_size(it.cells[pos].text).width); - if (max_w < ts) - max_w = ts; - } - if (!max_w) return 0; - header_width(pos, max_w < max ? max_w : max); + unsigned max_w = ess.auto_width(pos, max); ess.update(); return max_w; }