Added toolbar.clear()

This commit is contained in:
besh81 2018-03-18 10:48:17 +01:00
parent 592da3fe4f
commit fcb5c81631
2 changed files with 17 additions and 2 deletions

View File

@ -90,6 +90,7 @@ namespace nana
void separate(); ///< Adds a separator. void separate(); ///< Adds a separator.
void append(const ::std::string& text, const nana::paint::image& img); ///< Adds a control button. void append(const ::std::string& text, const nana::paint::image& img); ///< Adds a control button.
void append(const ::std::string& text); ///< Adds a control button. void append(const ::std::string& text); ///< Adds a control button.
void clear(); ///< Removes all control buttons and separators.
bool enable(size_type index) const; bool enable(size_type index) const;
void enable(size_type index, bool enable_state); void enable(size_type index, bool enable_state);
void scale(unsigned s); ///< Sets the scale of control button. void scale(unsigned s); ///< Sets the scale of control button.

View File

@ -57,8 +57,7 @@ namespace nana
~item_container() ~item_container()
{ {
for(auto ptr : cont_) clear();
delete ptr;
} }
void insert(size_type pos, std::string text, const nana::paint::image& img, item_type::kind type) void insert(size_type pos, std::string text, const nana::paint::image& img, item_type::kind type)
@ -120,6 +119,15 @@ namespace nana
{ {
return cont_.at(pos); return cont_.at(pos);
} }
void clear()
{
for(auto ptr : cont_)
delete ptr;
cont_.clear();
}
private: private:
container_type cont_; container_type cont_;
size_t right_{ npos }; size_t right_{ npos };
@ -461,6 +469,12 @@ namespace nana
API::refresh_window(this->handle()); API::refresh_window(this->handle());
} }
void toolbar::clear()
{
get_drawer_trigger().items().clear();
API::refresh_window(this->handle());
}
bool toolbar::enable(size_type pos) const bool toolbar::enable(size_type pos) const
{ {
auto & items = get_drawer_trigger().items(); auto & items = get_drawer_trigger().items();