use UTF-8 for string representation
This commit is contained in:
@@ -212,11 +212,9 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void trigger::_m_draw_title(graph_reference graph, bool enabled)
|
||||
{
|
||||
std::wstring text = ::nana::charset(wdg_->caption(), ::nana::unicode::utf8);
|
||||
|
||||
std::wstring::value_type shortkey;
|
||||
std::wstring::size_type shortkey_pos;
|
||||
std::wstring str = API::transform_shortkey_text(text, shortkey, &shortkey_pos);
|
||||
wchar_t shortkey;
|
||||
std::string::size_type shortkey_pos;
|
||||
std::wstring str = to_wstring(API::transform_shortkey_text(wdg_->caption(), shortkey, &shortkey_pos));
|
||||
|
||||
nana::size ts = graph.text_extent_size(str);
|
||||
nana::size gsize = graph.size();
|
||||
@@ -237,7 +235,7 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
unsigned omitted_pixels = gsize.width - icon_sz.width;
|
||||
std::size_t txtlen = str.size();
|
||||
const nana::char_t* txtptr = str.c_str();
|
||||
const auto txtptr = str.c_str();
|
||||
if(ts.width)
|
||||
{
|
||||
nana::paint::text_renderer tr(graph);
|
||||
@@ -513,14 +511,14 @@ namespace nana{ namespace drawerbase
|
||||
{
|
||||
API::unregister_shortkey(handle());
|
||||
|
||||
std::wstring wtext = ::nana::to_wstring(text);
|
||||
native_string_type ntext = std::move(text);
|
||||
|
||||
wchar_t shortkey;
|
||||
API::transform_shortkey_text(wtext, shortkey, 0);
|
||||
API::transform_shortkey_text(to_utf8(ntext), shortkey, nullptr);
|
||||
if (shortkey)
|
||||
API::register_shortkey(handle(), shortkey);
|
||||
|
||||
base_type::_m_caption(std::move(text));
|
||||
base_type::_m_caption(std::move(ntext));
|
||||
}
|
||||
//end class button
|
||||
}//end namespace nana
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace nana
|
||||
flags.checked = false;
|
||||
}
|
||||
|
||||
menu_item_type::menu_item_type(nana::string text, const event_fn_t& f)
|
||||
menu_item_type::menu_item_type(std::string text, const event_fn_t& f)
|
||||
: text(std::move(text)), functor(f)
|
||||
{
|
||||
flags.enabled = true;
|
||||
@@ -148,7 +148,7 @@ namespace nana
|
||||
img.stretch(rectangle{ img.size() }, graph, rectangle{ pos, ::nana::size(image_px, image_px) });
|
||||
}
|
||||
|
||||
void item_text(graph_reference graph, const nana::point& pos, const nana::string& text, unsigned text_pixels, const attr& at)
|
||||
void item_text(graph_reference graph, const nana::point& pos, const std::wstring& text, unsigned text_pixels, const attr& at)
|
||||
{
|
||||
graph.set_text_color(at.enabled ? colors::black : colors::gray_border);
|
||||
nana::paint::text_renderer tr(graph);
|
||||
@@ -240,7 +240,7 @@ namespace nana
|
||||
return root_;
|
||||
}
|
||||
|
||||
void insert(std::size_t pos, nana::string&& text, const event_fn_t& fn)
|
||||
void insert(std::size_t pos, std::string&& text, const event_fn_t& fn)
|
||||
{
|
||||
if(pos < root_.items.size())
|
||||
root_.items.emplace(root_.items.begin() + pos, std::move(text), std::ref(fn));
|
||||
@@ -382,9 +382,9 @@ namespace nana
|
||||
renderer->item(*graph_, item_r, attr);
|
||||
|
||||
//Draw text, the text is transformed from orignal for hotkey character
|
||||
nana::char_t hotkey;
|
||||
nana::string::size_type hotkey_pos;
|
||||
nana::string text = API::transform_shortkey_text(m.text, hotkey, &hotkey_pos);
|
||||
wchar_t hotkey;
|
||||
std::string::size_type hotkey_pos;
|
||||
auto text = to_wstring(API::transform_shortkey_text(m.text, hotkey, &hotkey_pos));
|
||||
|
||||
if (m.image.empty() == false)
|
||||
renderer->item_image(graph, nana::point(item_r.x + 5, item_r.y + static_cast<int>(item_h_px - image_px) / 2 - 1), image_px, m.image);
|
||||
@@ -1108,7 +1108,7 @@ namespace nana
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
auto menu::append(const nana::string& text, const menu::event_fn_t& f) -> item_proxy
|
||||
auto menu::append(const std::string& text, const menu::event_fn_t& f) -> item_proxy
|
||||
{
|
||||
impl_->mbuilder.data().items.emplace_back(text, f);
|
||||
return item_proxy(size() - 1, impl_->mbuilder.data().items.back());
|
||||
|
||||
@@ -30,11 +30,11 @@ namespace nana
|
||||
{
|
||||
struct item_type
|
||||
{
|
||||
item_type(const ::nana::string& text, unsigned long shortkey)
|
||||
item_type(const ::std::wstring& text, unsigned long shortkey)
|
||||
: text(text), shortkey(shortkey)
|
||||
{}
|
||||
|
||||
::nana::string text;
|
||||
::std::wstring text;
|
||||
unsigned long shortkey;
|
||||
::nana::menu menu_obj;
|
||||
::nana::point pos;
|
||||
@@ -52,7 +52,7 @@ namespace nana
|
||||
delete i;
|
||||
}
|
||||
|
||||
void append(const ::nana::string& text, unsigned long shortkey)
|
||||
void append(const ::std::wstring& text, unsigned long shortkey)
|
||||
{
|
||||
if(shortkey && shortkey < 0x61) shortkey += (0x61 - 0x41);
|
||||
cont_.push_back(new item_type(text, shortkey));
|
||||
@@ -122,7 +122,7 @@ namespace nana
|
||||
graph_.rectangle(r.pare_off(1), true, body);
|
||||
}
|
||||
|
||||
void item_renderer::caption(const point& pos, const nana::string& text)
|
||||
void item_renderer::caption(const point& pos, const std::wstring& text)
|
||||
{
|
||||
graph_.string(pos, text, colors::black);
|
||||
}
|
||||
@@ -138,10 +138,10 @@ namespace nana
|
||||
delete items_;
|
||||
}
|
||||
|
||||
nana::menu* trigger::push_back(const ::nana::string& text)
|
||||
nana::menu* trigger::push_back(const ::std::wstring& text)
|
||||
{
|
||||
::nana::char_t shkey;
|
||||
API::transform_shortkey_text(text, shkey, nullptr);
|
||||
wchar_t shkey;
|
||||
API::transform_shortkey_text(to_utf8(text), shkey, nullptr);
|
||||
|
||||
if(shkey)
|
||||
API::register_shortkey(widget_->handle(), shkey);
|
||||
@@ -187,9 +187,9 @@ namespace nana
|
||||
for (auto i : items_->cont())
|
||||
{
|
||||
//Transform the text if it contains the hotkey character
|
||||
::nana::char_t hotkey;
|
||||
::nana::string::size_type hotkey_pos;
|
||||
auto text = API::transform_shortkey_text(i->text, hotkey, &hotkey_pos);
|
||||
wchar_t hotkey;
|
||||
::std::wstring::size_type hotkey_pos;
|
||||
auto text = API::transform_shortkey_text(to_utf8(i->text), hotkey, &hotkey_pos);
|
||||
|
||||
nana::size text_s = graph.text_extent_size(text);
|
||||
|
||||
@@ -212,11 +212,11 @@ namespace nana
|
||||
|
||||
//Draw text, the text is transformed from orignal for hotkey character
|
||||
int text_top_off = (item_s.height - text_s.height) / 2;
|
||||
ird.caption({ item_pos.x + 8, item_pos.y + text_top_off }, text);
|
||||
ird.caption({ item_pos.x + 8, item_pos.y + text_top_off }, to_wstring(text));
|
||||
|
||||
if (hotkey)
|
||||
{
|
||||
unsigned off_w = (hotkey_pos ? graph.text_extent_size(text, static_cast<unsigned>(hotkey_pos)).width : 0);
|
||||
unsigned off_w = (hotkey_pos ? graph.text_extent_size(text.c_str(), static_cast<unsigned>(hotkey_pos)).width : 0);
|
||||
nana::size hotkey_size = graph.text_extent_size(text.c_str() + hotkey_pos, 1);
|
||||
|
||||
unsigned ascent, descent, inleading;
|
||||
@@ -617,9 +617,9 @@ namespace nana
|
||||
});
|
||||
}
|
||||
|
||||
menu& menubar::push_back(const nana::string& text)
|
||||
menu& menubar::push_back(const std::string& text)
|
||||
{
|
||||
return *(get_drawer_trigger().push_back(text));
|
||||
return *(get_drawer_trigger().push_back(to_wstring(text)));
|
||||
}
|
||||
|
||||
menu& menubar::at(std::size_t index) const
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* A Tabbar Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -788,7 +788,7 @@ namespace nana
|
||||
};
|
||||
|
||||
for(auto & m : list_)
|
||||
menulister_.append(m.text, fn);
|
||||
menulister_.append(to_utf8(m.text), fn);
|
||||
|
||||
auto r = toolbox_.area(toolbox_.ButtonList, basis_.graph->height());
|
||||
r.x += _m_toolbox_pos();
|
||||
@@ -1006,8 +1006,10 @@ namespace nana
|
||||
nana::size ts = basis_.graph->text_extent_size(item.text);
|
||||
basis_.graph->set_text_color(m.fgcolor.invisible() ? fgcolor : m.fgcolor);
|
||||
nana::paint::text_renderer tr(*basis_.graph);
|
||||
|
||||
std::wstring wtext = to_wstring(item.text);
|
||||
tr.render({ m.r.x + 24, m.r.y + static_cast<int>(m.r.height - ts.height) / 2 },
|
||||
item.text.c_str(), item.text.length(), basis_.item_pixels - 24 - 18, true);
|
||||
wtext.c_str(), wtext.length(), basis_.item_pixels - 24 - 18, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -639,7 +639,7 @@ namespace nana
|
||||
|
||||
nana::paint::image* image(const node_type* node)
|
||||
{
|
||||
const nana::string& idstr = node->value.second.img_idstr;
|
||||
const std::string& idstr = node->value.second.img_idstr;
|
||||
if(idstr.size())
|
||||
{
|
||||
auto i = shape.image_table.find(idstr);
|
||||
|
||||
Reference in New Issue
Block a user