use UTF-8 for string representation
This commit is contained in:
parent
2ca11d4e25
commit
7cc173022a
@ -144,6 +144,8 @@ namespace nana
|
|||||||
: public drawer_trigger
|
: public drawer_trigger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using native_string_type = ::nana::detail::native_string_type;
|
||||||
|
|
||||||
enum class kits
|
enum class kits
|
||||||
{
|
{
|
||||||
add,
|
add,
|
||||||
@ -161,15 +163,15 @@ namespace nana
|
|||||||
const pat::cloneable<item_renderer> & ext_renderer() const;
|
const pat::cloneable<item_renderer> & ext_renderer() const;
|
||||||
void ext_renderer(const pat::cloneable<item_renderer>&);
|
void ext_renderer(const pat::cloneable<item_renderer>&);
|
||||||
void set_event_agent(event_agent_interface*);
|
void set_event_agent(event_agent_interface*);
|
||||||
void insert(std::size_t, nana::string&&, nana::any&&);
|
void insert(std::size_t, native_string_type&&, nana::any&&);
|
||||||
std::size_t length() const;
|
std::size_t length() const;
|
||||||
bool close_fly(bool);
|
bool close_fly(bool);
|
||||||
void attach(std::size_t, window);
|
void attach(std::size_t, window);
|
||||||
void erase(std::size_t);
|
void erase(std::size_t);
|
||||||
void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&);
|
void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&);
|
||||||
void tab_image(size_t, const nana::paint::image&);
|
void tab_image(size_t, const nana::paint::image&);
|
||||||
void text(std::size_t, const nana::string&);
|
void text(std::size_t, const native_string_type&);
|
||||||
nana::string text(std::size_t) const;
|
native_string_type text(std::size_t) const;
|
||||||
bool toolbox(kits, bool);
|
bool toolbox(kits, bool);
|
||||||
private:
|
private:
|
||||||
void attached(widget_reference, graph_reference) override;
|
void attached(widget_reference, graph_reference) override;
|
||||||
@ -298,15 +300,19 @@ namespace nana
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back(nana::string text) /// Append a new item.
|
void push_back(std::string text) /// Append a new item.
|
||||||
{
|
{
|
||||||
this->get_drawer_trigger().insert(::nana::npos, std::move(text), value_type());
|
this->get_drawer_trigger().insert(::nana::npos, to_nstring(std::move(text)), value_type());
|
||||||
API::update_window(*this);
|
API::update_window(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(std::size_t pos, std::string text, value_type value = {})
|
void insert(std::size_t pos, std::string text, value_type value = {})
|
||||||
{
|
{
|
||||||
return this->insert(pos, static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), std::move(value));
|
if (pos > length())
|
||||||
|
throw std::out_of_range("tabbar::insert invalid position");
|
||||||
|
|
||||||
|
this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value));
|
||||||
|
API::update_window(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(std::size_t pos, std::wstring text, value_type value = {})
|
void insert(std::size_t pos, std::wstring text, value_type value = {})
|
||||||
@ -314,7 +320,7 @@ namespace nana
|
|||||||
if (pos > length())
|
if (pos > length())
|
||||||
throw std::out_of_range("tabbar::insert invalid position");
|
throw std::out_of_range("tabbar::insert invalid position");
|
||||||
|
|
||||||
this->get_drawer_trigger().insert(pos, std::move(text), std::move(value));
|
this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value));
|
||||||
API::update_window(*this);
|
API::update_window(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,14 +389,14 @@ namespace nana
|
|||||||
API::refresh_window(this->handle());
|
API::refresh_window(this->handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void text(std::size_t pos, const nana::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
|
void text(std::size_t pos, const std::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
|
||||||
{
|
{
|
||||||
this->get_drawer_trigger().text(pos, str);
|
this->get_drawer_trigger().text(pos, to_nstring(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::string text(std::size_t pos) const /// Returns a title of a specified item, If pos is invalid, the method trhows a std::out_of_range object.
|
std::string text(std::size_t pos) const /// Returns a title of a specified item, If pos is invalid, the method trhows a std::out_of_range object.
|
||||||
{
|
{
|
||||||
return this->get_drawer_trigger().text(pos);
|
return to_utf8(this->get_drawer_trigger().text(pos));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<drawerbase::tabbar::event_agent<value_type, drawerbase::tabbar::trigger> > evt_agent_;
|
std::unique_ptr<drawerbase::tabbar::event_agent<value_type, drawerbase::tabbar::trigger> > evt_agent_;
|
||||||
|
|||||||
@ -21,11 +21,12 @@ namespace nana
|
|||||||
{
|
{
|
||||||
namespace tabbar
|
namespace tabbar
|
||||||
{
|
{
|
||||||
|
using native_string_type = ::nana::detail::native_string_type;
|
||||||
struct item_t
|
struct item_t
|
||||||
{
|
{
|
||||||
window relative{nullptr};
|
window relative{nullptr};
|
||||||
paint::image img;
|
paint::image img;
|
||||||
nana::string text;
|
native_string_type text;
|
||||||
any value;
|
any value;
|
||||||
|
|
||||||
::nana::color bgcolor;
|
::nana::color bgcolor;
|
||||||
@ -33,7 +34,7 @@ namespace nana
|
|||||||
|
|
||||||
item_t() = default;
|
item_t() = default;
|
||||||
|
|
||||||
item_t(nana::string&& text, any && value)
|
item_t(native_string_type&& text, any && value)
|
||||||
: text(std::move(text)), value(std::move(value))
|
: text(std::move(text)), value(std::move(value))
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
@ -420,7 +421,7 @@ namespace nana
|
|||||||
evt_agent_ = evt;
|
evt_agent_ = evt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(std::size_t pos, nana::string&& text, nana::any&& value)
|
void insert(std::size_t pos, native_string_type&& text, nana::any&& value)
|
||||||
{
|
{
|
||||||
if (pos >= list_.size())
|
if (pos >= list_.size())
|
||||||
pos = list_.size();
|
pos = list_.size();
|
||||||
@ -639,7 +640,7 @@ namespace nana
|
|||||||
m.img.close();
|
m.img.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool text(std::size_t pos, const nana::string& str)
|
bool text(std::size_t pos, const native_string_type& str)
|
||||||
{
|
{
|
||||||
if (pos >= list_.size())
|
if (pos >= list_.size())
|
||||||
throw std::out_of_range("tabbar: invalid position");
|
throw std::out_of_range("tabbar: invalid position");
|
||||||
@ -654,7 +655,7 @@ namespace nana
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::string text(std::size_t pos) const
|
native_string_type text(std::size_t pos) const
|
||||||
{
|
{
|
||||||
if (pos >= list_.size())
|
if (pos >= list_.size())
|
||||||
throw std::out_of_range("tabbar: invalid position");
|
throw std::out_of_range("tabbar: invalid position");
|
||||||
@ -1163,7 +1164,7 @@ namespace nana
|
|||||||
layouter_->event_agent(evt);
|
layouter_->event_agent(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::insert(std::size_t pos, nana::string&& text, nana::any&& value)
|
void trigger::insert(std::size_t pos, native_string_type&& text, nana::any&& value)
|
||||||
{
|
{
|
||||||
layouter_->insert(pos, std::move(text), std::move(value));
|
layouter_->insert(pos, std::move(text), std::move(value));
|
||||||
}
|
}
|
||||||
@ -1200,13 +1201,13 @@ namespace nana
|
|||||||
API::refresh_window(layouter_->widget_handle());
|
API::refresh_window(layouter_->widget_handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::text(std::size_t i, const nana::string& str)
|
void trigger::text(std::size_t i, const native_string_type& str)
|
||||||
{
|
{
|
||||||
if(layouter_->text(i, str))
|
if(layouter_->text(i, str))
|
||||||
API::refresh_window(layouter_->widget_handle());
|
API::refresh_window(layouter_->widget_handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::string trigger::text(std::size_t i) const
|
native_string_type trigger::text(std::size_t i) const
|
||||||
{
|
{
|
||||||
return layouter_->text(i);
|
return layouter_->text(i);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user