new item::insert to add an item at specified pos

This commit is contained in:
Jinhao
2017-01-19 06:27:54 +08:00
parent 880a91b717
commit 238e85756f
2 changed files with 37 additions and 6 deletions

View File

@@ -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
@@ -48,6 +48,8 @@ namespace nana
item_proxy& checked(bool);
bool checked() const;
std::string text() const;
std::size_t index() const;
private:
std::size_t index_;
@@ -123,8 +125,19 @@ namespace nana
~menu();
/// Appends an item to the menu.
item_proxy append(std::string text_utf8, const event_fn_t& callback= event_fn_t());
item_proxy append(std::string text_utf8, const event_fn_t& handler = {});
void append_splitter();
/// Inserts new item at specified position
/**
* It will invalidate the existing item proxies from the specified position.
* @param pos The position where new item to be inserted
* @param text_utf8 The title of item
* @param handler The event handler for the item.
* @return the item proxy to the new inserted item.
*/
item_proxy insert(std::size_t pos, std::string text_utf8, const event_fn_t& handler = {});
void clear(); ///< Erases all of the items.
/// Closes the menu. It does not destroy the menu; just close the window for the menu.
void close();