let listbox append_header return the pos of the new header

This commit is contained in:
qPCR4vir 2015-05-07 22:48:20 +02:00
parent df22696e25
commit 444449dfaa
2 changed files with 9 additions and 8 deletions

View File

@ -561,9 +561,10 @@ By \a clicking on one header the list get \a reordered, first up, and then down
void auto_draw(bool); ///<Set state: Redraw automatically after an operation?
void append_header(nana::string, unsigned width = 120);///<Appends a new column with a header text and the specified width at the end
listbox& header_width(size_type pos, unsigned pixels);
unsigned header_width(size_type pos) const;
/// Appends a new column with a header text and the specified width at the end, and return it position
size_type append_header(nana::string header_text, unsigned width = 120);
cat_proxy append(nana::string); ///<Appends a new category at the end
void append(std::initializer_list<nana::string>); ///<Appends categories at the end

View File

@ -399,20 +399,19 @@ namespace nana
return{};
}
void create(nana::string&& text, unsigned pixels)
size_type create(nana::string&& text, unsigned pixels)
{
cont_.emplace_back(std::move(text), pixels, static_cast<size_type>(cont_.size()));
return cont_.back().index;
}
void item_width(size_type pos, unsigned width)
{
if (pos >= cont_.size())
return;
for(auto & m : cont_)
{
if(m.index == pos)
{
m.pixels = width;
return;
}
}
@ -3994,11 +3993,12 @@ namespace nana
_m_ess().set_auto_draw(ad);
}
void listbox::append_header(nana::string text, unsigned width)
listbox::size_type listbox::append_header(nana::string text, unsigned width)
{
auto & ess = _m_ess();
ess.header.create(std::move(text), width);
listbox::size_type index = ess.header.create(std::move(text), width);
ess.update();
return index;
}
listbox& listbox::header_width(size_type pos, unsigned pixels)