Merge branch 'hotfix-1.4.1' into develop
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Menu implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2009-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2009-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -86,6 +86,11 @@ namespace nana
|
||||
return item_.flags.checked;
|
||||
}
|
||||
|
||||
std::string menu_item_type::item_proxy::text() const
|
||||
{
|
||||
return item_.text;
|
||||
}
|
||||
|
||||
std::size_t menu_item_type::item_proxy::index() const
|
||||
{
|
||||
return index_;
|
||||
@@ -1117,10 +1122,11 @@ namespace nana
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
auto menu::append(std::string text_utf8, const menu::event_fn_t& callback) -> item_proxy
|
||||
auto menu::append(std::string text_utf8, const menu::event_fn_t& handler) -> item_proxy
|
||||
{
|
||||
impl_->mbuilder.data().items.emplace_back(new item_type(std::move(text_utf8), callback));
|
||||
return item_proxy(size() - 1, *impl_->mbuilder.data().items.back());
|
||||
std::unique_ptr<item_type> item{ new item_type{ std::move(text_utf8), handler } };
|
||||
impl_->mbuilder.data().items.emplace_back(item.get());
|
||||
return item_proxy(size() - 1, *item.release());
|
||||
}
|
||||
|
||||
void menu::append_splitter()
|
||||
@@ -1128,6 +1134,18 @@ namespace nana
|
||||
impl_->mbuilder.data().items.emplace_back(new item_type);
|
||||
}
|
||||
|
||||
auto menu::insert(std::size_t pos, std::string text_utf8, const event_fn_t& handler) -> item_proxy
|
||||
{
|
||||
auto & items = impl_->mbuilder.data().items;
|
||||
if (pos > items.size())
|
||||
throw std::out_of_range("menu: a new item inserted to an invalid position");
|
||||
|
||||
std::unique_ptr<item_type> item{ new item_type{ std::move(text_utf8), handler } };
|
||||
impl_->mbuilder.data().items.emplace(impl_->mbuilder.data().items.cbegin() + pos, item.get());
|
||||
|
||||
return item_proxy{ pos, *item.release() };
|
||||
}
|
||||
|
||||
void menu::clear()
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
|
||||
Reference in New Issue
Block a user