From 6ba23bb6c3dfe32516824f588726371e82339df8 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 12 Apr 2015 23:28:48 +0800 Subject: [PATCH] add header_width() methods for getting/setting header width. --- include/nana/gui/widgets/listbox.hpp | 2 ++ source/gui/widgets/listbox.cpp | 29 +++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 1bc087be..10e5dab0 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -474,6 +474,8 @@ By \a clicking on a header the list get \a reordered, first up, and then down al void auto_draw(bool); ///); ///(cont_.size())); } - void item_width(size_type index, unsigned width) + void item_width(size_type pos, unsigned width) { - if (index >= cont_.size()) + if (pos >= cont_.size()) return; for(auto & m : cont_) { - if(m.index == index) + if(m.index == pos) m.pixels = width; } } + unsigned item_width(size_type pos) const + { + for (auto & m : cont_) + { + if (m.index == pos) + return m.pixels; + } + return 0; + } + unsigned pixels() const { unsigned pixels = 0; @@ -3602,6 +3612,19 @@ namespace nana ess.update(); } + listbox& listbox::header_width(size_type pos, unsigned pixels) + { + auto & ess = _m_ess(); + ess.header.item_width(pos, pixels); + ess.update(); + return *this; + } + + unsigned listbox::header_width(size_type pos) const + { + return _m_ess().header.item_width(pos); + } + listbox::cat_proxy listbox::append(nana::string s) { internal_scope_guard lock;