fix issues of tabbar::relate and tabbar::append

This commit is contained in:
Jinhao
2015-12-08 22:54:27 +08:00
parent 3d1c18cc50
commit 871ddd25af
2 changed files with 10 additions and 6 deletions

View File

@@ -287,12 +287,12 @@ namespace nana
tabbar& append(std::wstring text, window attach_wd, value_type value = {}) tabbar& append(std::wstring text, window attach_wd, value_type value = {})
{ {
if (attach_wd && API::empty_window(attach_wd))
throw std::invalid_argument("tabbar.attach: invalid window handle");
this->get_drawer_trigger().insert(::nana::npos, std::move(text), std::move(value)); this->get_drawer_trigger().insert(::nana::npos, std::move(text), std::move(value));
if (attach_wd) if (attach_wd)
{ this->attach(this->get_drawer_trigger().length() - 1, attach_wd);
auto pos = this->get_drawer_trigger().length();
relate(pos, attach_wd);
}
API::update_window(*this); API::update_window(*this);
return *this; return *this;
@@ -324,9 +324,12 @@ namespace nana
this->get_drawer_trigger().attach(pos, wd); this->get_drawer_trigger().attach(pos, wd);
} }
void attach(std::size_t pos, window wd) void attach(std::size_t pos, window attach_wd)
{ {
this->get_drawer_trigger().attach(pos, wd); if (attach_wd && API::empty_window(attach_wd))
throw std::invalid_argument("tabbar.attach: invalid window handle");
this->get_drawer_trigger().attach(pos, attach_wd);
} }
void erase(std::size_t pos) void erase(std::size_t pos)

View File

@@ -608,6 +608,7 @@ namespace nana
if (pos >= list_.size()) if (pos >= list_.size())
throw std::out_of_range("tabbar: invalid position"); throw std::out_of_range("tabbar: invalid position");
iterator_at(pos)->relative = wd;
API::show_window(wd, basis_.active == pos); API::show_window(wd, basis_.active == pos);
} }