change some APIs for accepting utf8
This commit is contained in:
@@ -212,11 +212,11 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void trigger::_m_draw_title(graph_reference graph, bool enabled)
|
||||
{
|
||||
nana::string text = wdg_->caption();
|
||||
std::wstring text = ::nana::charset(wdg_->caption(), ::nana::unicode::utf8);
|
||||
|
||||
nana::string::value_type shortkey;
|
||||
nana::string::size_type shortkey_pos;
|
||||
nana::string str = API::transform_shortkey_text(text, shortkey, &shortkey_pos);
|
||||
std::wstring::value_type shortkey;
|
||||
std::wstring::size_type shortkey_pos;
|
||||
std::wstring str = API::transform_shortkey_text(text, shortkey, &shortkey_pos);
|
||||
|
||||
nana::size ts = graph.text_extent_size(str);
|
||||
nana::size gsize = graph.size();
|
||||
@@ -398,14 +398,16 @@ namespace nana{ namespace drawerbase
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
button::button(window wd, const nana::string& text, bool visible)
|
||||
button::button(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
button::button(window wd, const nana::char_t* text, bool visible)
|
||||
button::button(window wd, const char* text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text, std::strlen(text));
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
@@ -509,12 +511,14 @@ namespace nana{ namespace drawerbase
|
||||
});
|
||||
}
|
||||
|
||||
void button::_m_caption(nana::string&& text)
|
||||
void button::_m_caption(std::string&& text)
|
||||
{
|
||||
API::unregister_shortkey(handle());
|
||||
|
||||
nana::char_t shortkey;
|
||||
API::transform_shortkey_text(text, shortkey, 0);
|
||||
std::wstring wtext = ::nana::charset(text, ::nana::unicode::utf8);
|
||||
|
||||
wchar_t shortkey;
|
||||
API::transform_shortkey_text(wtext, shortkey, 0);
|
||||
if (shortkey)
|
||||
API::register_shortkey(handle(), shortkey);
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace nana
|
||||
: public float_listbox::item_interface
|
||||
{
|
||||
nana::paint::image item_image;
|
||||
nana::string item_text;
|
||||
std::string item_text;
|
||||
public:
|
||||
item(const nana::string& s)
|
||||
item(const std::string& s)
|
||||
: item_text(s)
|
||||
{}
|
||||
public:
|
||||
@@ -44,7 +44,7 @@ namespace nana
|
||||
return item_image;
|
||||
}
|
||||
|
||||
const nana::char_t * text() const override
|
||||
const char * text() const override
|
||||
{
|
||||
return item_text.data();
|
||||
}
|
||||
@@ -543,7 +543,7 @@ namespace nana
|
||||
{
|
||||
if(node)
|
||||
{
|
||||
API::dev::window_caption(window_handle(), tree().path());
|
||||
API::dev::window_caption(window_handle(), utf8_cast(tree().path()));
|
||||
if(evt_holder_.selected)
|
||||
evt_holder_.selected(node->value.second.value);
|
||||
}
|
||||
@@ -565,7 +565,7 @@ namespace nana
|
||||
if(i)
|
||||
{
|
||||
for(node_handle child = i->child; child; child = child->next)
|
||||
style_.module.items.emplace_back(std::make_shared<item>(child->value.first));
|
||||
style_.module.items.emplace_back(std::make_shared<item>(utf8_cast(child->value.first)));
|
||||
}
|
||||
r = style_.active_item_rectangle;
|
||||
}
|
||||
@@ -576,7 +576,7 @@ namespace nana
|
||||
{
|
||||
auto end = v.cbegin() + head_;
|
||||
for(auto i = v.cbegin(); i != end; ++i)
|
||||
style_.module.items.emplace_back(std::make_shared<item>((*i)->value.first));
|
||||
style_.module.items.emplace_back(std::make_shared<item>(utf8_cast((*i)->value.first)));
|
||||
}
|
||||
r = style_.active_item_rectangle;
|
||||
}
|
||||
@@ -603,7 +603,7 @@ namespace nana
|
||||
case ui_element::item_arrow:
|
||||
{
|
||||
treebase_.tail(style_.active);
|
||||
nana::string name = style_.module.items[style_.module.index]->text();
|
||||
nana::string name = utf8_cast(style_.module.items[style_.module.index]->text());
|
||||
node_handle node = treebase_.find_child(name);
|
||||
if(node)
|
||||
{
|
||||
@@ -805,16 +805,17 @@ namespace nana
|
||||
delete scheme_;
|
||||
}
|
||||
|
||||
void trigger::insert(const nana::string& str, nana::any value)
|
||||
void trigger::insert(const std::string& str, nana::any value)
|
||||
{
|
||||
scheme_->tree().insert(str, value);
|
||||
API::dev::window_caption(scheme_->window_handle(), scheme_->tree().path());
|
||||
throw_not_utf8(str);
|
||||
scheme_->tree().insert(utf8_cast(str), value);
|
||||
API::dev::window_caption(scheme_->window_handle(), utf8_cast(scheme_->tree().path()));
|
||||
scheme_->draw();
|
||||
}
|
||||
|
||||
bool trigger::childset(const nana::string& str, nana::any value)
|
||||
bool trigger::childset(const std::string& str, nana::any value)
|
||||
{
|
||||
if(scheme_->tree().childset(str, value))
|
||||
if(scheme_->tree().childset(utf8_cast(str), value))
|
||||
{
|
||||
scheme_->draw();
|
||||
return true;
|
||||
@@ -822,9 +823,9 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
bool trigger::childset_erase(const nana::string& str)
|
||||
bool trigger::childset_erase(const std::string& str)
|
||||
{
|
||||
if(scheme_->tree().childset_erase(str))
|
||||
if(scheme_->tree().childset_erase(utf8_cast(str)))
|
||||
{
|
||||
scheme_->draw();
|
||||
return true;
|
||||
@@ -852,14 +853,14 @@ namespace nana
|
||||
return scheme_->tree().splitstr();
|
||||
}
|
||||
|
||||
void trigger::path(const nana::string& str)
|
||||
void trigger::path(const std::string& str)
|
||||
{
|
||||
scheme_->tree().path(str);
|
||||
scheme_->tree().path(utf8_cast(str));
|
||||
}
|
||||
|
||||
nana::string trigger::path() const
|
||||
std::string trigger::path() const
|
||||
{
|
||||
return scheme_->tree().path();
|
||||
return utf8_cast(scheme_->tree().path());
|
||||
}
|
||||
|
||||
nana::any& trigger::value() const
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace checkbox
|
||||
{
|
||||
if (graph.width() > 16 + interval)
|
||||
{
|
||||
nana::string title = widget_->caption();
|
||||
std::wstring title = ::nana::charset(widget_->caption(), ::nana::unicode::utf8);
|
||||
|
||||
unsigned pixels = graph.width() - (16 + interval);
|
||||
|
||||
@@ -129,18 +129,16 @@ namespace checkbox
|
||||
bgcolor(API::bgcolor(wd));
|
||||
}
|
||||
|
||||
checkbox::checkbox(window wd, const nana::string& text, bool visible)
|
||||
checkbox::checkbox(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
bgcolor(API::bgcolor(wd));
|
||||
caption(text);
|
||||
}
|
||||
|
||||
checkbox::checkbox(window wd, const nana::char_t* text, bool visible)
|
||||
checkbox::checkbox(window wd, const char* text, bool visible)
|
||||
: checkbox(wd, std::string(text), visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
bgcolor(API::bgcolor(wd));
|
||||
caption(text);
|
||||
}
|
||||
|
||||
checkbox::checkbox(window wd, const nana::rectangle& r, bool visible)
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace nana
|
||||
std::shared_ptr<nana::detail::key_interface> key;
|
||||
|
||||
nana::paint::image item_image;
|
||||
nana::string item_text;
|
||||
std::string item_text;
|
||||
mutable std::shared_ptr<nana::any> any_ptr;
|
||||
|
||||
item(std::shared_ptr<nana::detail::key_interface> && kv)
|
||||
@@ -62,7 +62,7 @@ namespace nana
|
||||
{
|
||||
}
|
||||
|
||||
item(nana::string&& s)
|
||||
item(std::string&& s)
|
||||
: item_text(std::move(s))
|
||||
{}
|
||||
private:
|
||||
@@ -72,7 +72,7 @@ namespace nana
|
||||
return item_image;
|
||||
}
|
||||
|
||||
const nana::char_t* text() const override
|
||||
const char* text() const override
|
||||
{
|
||||
return item_text.data();
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace nana
|
||||
graph_ = nullptr;
|
||||
}
|
||||
|
||||
void insert(nana::string&& text)
|
||||
void insert(std::string&& text)
|
||||
{
|
||||
items_.emplace_back(std::make_shared<item>(std::move(text)));
|
||||
API::refresh_window(widget_->handle());
|
||||
@@ -338,7 +338,7 @@ namespace nana
|
||||
if (calc_where(*graph_, pos.x, pos.y))
|
||||
state_.button_state = element_state::normal;
|
||||
|
||||
editor_->text(items_[index]->item_text);
|
||||
editor_->text(::nana::charset(items_[index]->item_text, ::nana::unicode::utf8));
|
||||
_m_draw_push_button(widget_->enabled());
|
||||
_m_draw_image();
|
||||
|
||||
@@ -398,7 +398,7 @@ namespace nana
|
||||
if (pos == module_.index)
|
||||
{
|
||||
module_.index = ::nana::npos;
|
||||
this->widget_->caption(L"");
|
||||
this->widget_->caption("");
|
||||
}
|
||||
else if ((::nana::npos != module_.index) && (pos < module_.index))
|
||||
--module_.index;
|
||||
@@ -731,13 +731,14 @@ namespace nana
|
||||
pos_(pos)
|
||||
{}
|
||||
|
||||
item_proxy& item_proxy::text(const nana::string& s)
|
||||
item_proxy& item_proxy::text(const ::std::string& s)
|
||||
{
|
||||
throw_not_utf8(s);
|
||||
impl_->at(pos_).item_text = s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
nana::string item_proxy::text() const
|
||||
::std::string item_proxy::text() const
|
||||
{
|
||||
return impl_->at(pos_).item_text;
|
||||
}
|
||||
@@ -767,7 +768,7 @@ namespace nana
|
||||
}
|
||||
|
||||
/// Behavior of Iterator's value_type
|
||||
bool item_proxy::operator == (const nana::string& s) const
|
||||
bool item_proxy::operator == (const ::std::string& s) const
|
||||
{
|
||||
if (pos_ == nana::npos)
|
||||
return false;
|
||||
@@ -778,17 +779,10 @@ namespace nana
|
||||
{
|
||||
if (pos_ == nana::npos)
|
||||
return false;
|
||||
return (impl_->at(pos_).item_text == static_cast<nana::string>(nana::charset(s, nana::unicode::utf8)));
|
||||
}
|
||||
|
||||
bool item_proxy::operator == (const wchar_t * s) const
|
||||
{
|
||||
if (pos_ == nana::npos)
|
||||
return false;
|
||||
|
||||
return (impl_->at(pos_).item_text == s);
|
||||
}
|
||||
|
||||
|
||||
/// Behavior of Iterator
|
||||
item_proxy & item_proxy::operator=(const item_proxy& r)
|
||||
{
|
||||
@@ -876,16 +870,16 @@ namespace nana
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
combox::combox(window wd, nana::string text, bool visible)
|
||||
combox::combox(window wd, std::string text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(std::move(text));
|
||||
}
|
||||
|
||||
combox::combox(window wd, const nana::char_t* text, bool visible)
|
||||
combox::combox(window wd, const char* text, bool visible)
|
||||
: combox(wd, std::string(text), visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
combox::combox(window wd, const nana::rectangle& r, bool visible)
|
||||
@@ -920,7 +914,7 @@ namespace nana
|
||||
editor->set_accept(std::move(pred));
|
||||
}
|
||||
|
||||
combox& combox::push_back(nana::string text)
|
||||
combox& combox::push_back(std::string text)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
_m_impl().insert(std::move(text));
|
||||
@@ -946,7 +940,7 @@ namespace nana
|
||||
API::update_window(handle());
|
||||
}
|
||||
|
||||
nana::string combox::text(std::size_t pos) const
|
||||
::std::string combox::text(std::size_t pos) const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
return _m_impl().at(pos).item_text;
|
||||
@@ -988,20 +982,22 @@ namespace nana
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
nana::string combox::_m_caption() const throw()
|
||||
std::string combox::_m_caption() const throw()
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = _m_impl().editor();
|
||||
return (editor ? editor->text() : nana::string());
|
||||
if (editor)
|
||||
return ::nana::charset(editor->text());
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void combox::_m_caption(nana::string&& str)
|
||||
void combox::_m_caption(std::string&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
|
||||
auto editor = _m_impl().editor();
|
||||
if (editor)
|
||||
editor->text(std::move(str));
|
||||
editor->text(::nana::charset(str, nana::unicode::utf8));
|
||||
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace nana
|
||||
trigger::trigger()
|
||||
: widget_(nullptr), chose_(false), page_(page::date), pos_(where::none)
|
||||
{
|
||||
const nana::string ws[] = {STR("S"), STR("M"), STR("T"), STR("W"), STR("T"), STR("F"), STR("S")};
|
||||
const std::string ws[] = {"S", "M", "T", "W", "T", "F", "S"};
|
||||
for(int i = 0; i < 7; ++i) weekstr_[i] = ws[i];
|
||||
|
||||
nana::date d;
|
||||
@@ -50,8 +50,9 @@ namespace nana
|
||||
return nana::date(chdate_.year, chdate_.month, chdate_.day);
|
||||
}
|
||||
|
||||
void trigger::week_name(unsigned index, const nana::string& str)
|
||||
void trigger::week_name(unsigned index, const std::string& str)
|
||||
{
|
||||
throw_not_utf8(str);
|
||||
if(index < 7)
|
||||
this->weekstr_[index] = str;
|
||||
}
|
||||
@@ -95,13 +96,13 @@ namespace nana
|
||||
|
||||
if(graph.width() > 32 + border_size * 2)
|
||||
{
|
||||
nana::string str;
|
||||
std::string str;
|
||||
if(page_ == page::date)
|
||||
{
|
||||
str = ::nana::internationalization()(monthstr[chmonth_.month - 1]);
|
||||
str += STR(" ");
|
||||
str += " ";
|
||||
}
|
||||
str += std::to_wstring(chmonth_.year);
|
||||
str += std::to_string(chmonth_.year);
|
||||
|
||||
nana::size txt_s = graph.text_extent_size(str);
|
||||
|
||||
@@ -110,7 +111,8 @@ namespace nana
|
||||
int xpos = static_cast<int>(graph.width() - txt_s.width) / 2;
|
||||
if(xpos < border_size + 16) xpos = 16 + border_size + 1;
|
||||
|
||||
graph.string({ xpos, top }, str, (pos_ == where::topbar ? color_.highlight : color_.normal));
|
||||
graph.set_text_color(pos_ == where::topbar ? color_.highlight : color_.normal);
|
||||
graph.string({ xpos, top }, str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +136,7 @@ namespace nana
|
||||
dbasis_ = dbasis;
|
||||
}
|
||||
|
||||
void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, const nana::string& str, bool primary, bool sel)
|
||||
void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, const std::string& str_utf8, bool primary, bool sel)
|
||||
{
|
||||
nana::rectangle r(static_cast<int>(x * dbasis.row_s), static_cast<int>(y * dbasis.line_s),
|
||||
static_cast<int>(dbasis.row_s), static_cast<int>(dbasis.line_s));
|
||||
@@ -165,13 +167,14 @@ namespace nana
|
||||
if(false == primary)
|
||||
color = { 0xB0, 0xB0, 0xB0 };
|
||||
|
||||
nana::size txt_s = graph.text_extent_size(str);
|
||||
graph.string({ r.x + static_cast<int>(r.width - txt_s.width) / 2, r.y + static_cast<int>(r.height - txt_s.height) / 2 }, str, color);
|
||||
nana::size txt_s = graph.text_extent_size(str_utf8);
|
||||
graph.set_text_color(color);
|
||||
graph.string({ r.x + static_cast<int>(r.width - txt_s.width) / 2, r.y + static_cast<int>(r.height - txt_s.height) / 2 }, str_utf8);
|
||||
}
|
||||
|
||||
void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, int number, bool primary, bool sel)
|
||||
{
|
||||
_m_draw_pos(dbasis, graph, x, y, std::to_wstring(number), primary, sel);
|
||||
_m_draw_pos(dbasis, graph, x, y, std::to_string(number), primary, sel);
|
||||
}
|
||||
|
||||
void trigger::_m_draw_ex_days(drawing_basis & dbasis, graph_reference graph, int begx, int begy, bool before)
|
||||
@@ -615,16 +618,16 @@ namespace nana
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
date_chooser::date_chooser(window wd, const nana::string& text, bool visible)
|
||||
date_chooser::date_chooser(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
date_chooser::date_chooser(window wd, const nana::char_t* text, bool visible)
|
||||
date_chooser::date_chooser(window wd, const char* text, bool visible)
|
||||
: date_chooser(wd, std::string(text), visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
date_chooser::date_chooser(window wd, const rectangle& r, bool visible)
|
||||
@@ -642,7 +645,7 @@ namespace nana
|
||||
return get_drawer_trigger().read();
|
||||
}
|
||||
|
||||
void date_chooser::weekstr(unsigned index, const nana::string& str)
|
||||
void date_chooser::weekstr(unsigned index, const ::std::string& str)
|
||||
{
|
||||
get_drawer_trigger().week_name(index, str);
|
||||
API::refresh_window(*this);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace nana{
|
||||
|
||||
implement() = default;
|
||||
|
||||
implement(window grp_panel, ::nana::string titel, bool vsb, unsigned gap=2)
|
||||
implement(window grp_panel, ::std::string titel, bool vsb, unsigned gap=2)
|
||||
: caption (grp_panel, std::move(titel), vsb),
|
||||
place_content{grp_panel},
|
||||
gap{gap}
|
||||
@@ -51,7 +51,7 @@ namespace nana{
|
||||
void create(window pnl)
|
||||
{
|
||||
caption.create(pnl);
|
||||
caption.caption(STR(""));
|
||||
caption.caption("");
|
||||
place_content.bind(pnl);
|
||||
|
||||
if (!radio_logic)
|
||||
@@ -90,7 +90,7 @@ namespace nana{
|
||||
create(parent, r, vsb);
|
||||
}
|
||||
|
||||
group::group(window parent, ::nana::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb)
|
||||
group::group(window parent, ::std::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb)
|
||||
: panel(parent, r, vsb),
|
||||
impl_(new implement(*this, std::move(titel), vsb, gap))
|
||||
{
|
||||
@@ -103,7 +103,7 @@ namespace nana{
|
||||
delete impl_->radio_logic;
|
||||
}
|
||||
|
||||
group& group::add_option(::nana::string text)
|
||||
group& group::add_option(std::string text)
|
||||
{
|
||||
_THROW_IF_EMPTY()
|
||||
|
||||
@@ -234,12 +234,12 @@ namespace nana{
|
||||
_m_init();
|
||||
}
|
||||
|
||||
::nana::string group::_m_caption() const throw()
|
||||
::std::string group::_m_caption() const throw()
|
||||
{
|
||||
return impl_->caption.caption();
|
||||
}
|
||||
|
||||
void group::_m_caption(::nana::string&& str)
|
||||
void group::_m_caption(::std::string&& str)
|
||||
{
|
||||
impl_->caption.caption(std::move(str));
|
||||
impl_->update_div();
|
||||
|
||||
@@ -772,8 +772,9 @@ namespace nana
|
||||
bgcolor(API::bgcolor(wd));
|
||||
}
|
||||
|
||||
label::label(window wd, const nana::string& text, bool visible)
|
||||
label::label(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
bgcolor(API::bgcolor(wd));
|
||||
caption(text);
|
||||
@@ -806,7 +807,7 @@ namespace nana
|
||||
if(impl->renderer.format(f))
|
||||
{
|
||||
window wd = *this;
|
||||
impl->renderer.parse(API::dev::window_caption(wd));
|
||||
impl->renderer.parse(::nana::charset(API::dev::window_caption(wd), ::nana::unicode::utf8));
|
||||
API::refresh_window(wd);
|
||||
}
|
||||
return *this;
|
||||
@@ -844,11 +845,12 @@ namespace nana
|
||||
return impl->renderer.measure(*graph_ptr, limited, impl->text_align, impl->text_align_v);
|
||||
}
|
||||
|
||||
::nana::size label::measure(paint::graphics& graph, const ::nana::string& str, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align)
|
||||
::nana::size label::measure(paint::graphics& graph, const ::std::string& str, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align)
|
||||
{
|
||||
throw_not_utf8(str);
|
||||
drawerbase::label::renderer rd;
|
||||
rd.format(format_enabled);
|
||||
rd.parse(str);
|
||||
rd.parse(utf8_cast(str));
|
||||
return rd.measure(graph, allowed_width_in_pixel, h_align, v_align);
|
||||
}
|
||||
|
||||
@@ -867,11 +869,11 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
void label::_m_caption(nana::string&& str)
|
||||
void label::_m_caption(std::string&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
window wd = *this;
|
||||
get_drawer_trigger().impl()->renderer.parse(str);
|
||||
get_drawer_trigger().impl()->renderer.parse(::nana::charset(str, nana::unicode::utf8));
|
||||
API::dev::window_caption(wd, std::move(str));
|
||||
API::refresh_window(wd);
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ namespace nana
|
||||
want_focus_{ (!wd) || ((!is_wd_parent_menu) && (API::focus_window() != wd)) },
|
||||
event_focus_{ nullptr }
|
||||
{
|
||||
caption(STR("nana menu window"));
|
||||
caption("nana menu window");
|
||||
get_drawer_trigger().close_menu_tree([this]{ this->_m_close_all(); });
|
||||
get_drawer_trigger().renderer = rdptr;
|
||||
state_.owner_menubar = state_.self_submenu = false;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace nana
|
||||
//class drawer
|
||||
void drawer::attached(widget_reference wdg, graph_reference)
|
||||
{
|
||||
wdg.caption(STR("panel widget"));
|
||||
wdg.caption("panel widget");
|
||||
window_ = wdg.handle();
|
||||
|
||||
API::ignore_mouse_focus(wdg, true);
|
||||
|
||||
@@ -47,10 +47,11 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
virtual void adorn_textbox(window, graph_reference graph, const nana::string& str, const nana::rectangle & r)
|
||||
virtual void adorn_textbox(window, graph_reference graph, const std::string& str, const nana::rectangle & r)
|
||||
{
|
||||
graph.rectangle(r, false, colors::white);
|
||||
graph.string({ r.x + 2, r.y + 1 }, str, colors::white);
|
||||
graph.set_text_color(colors::white);
|
||||
graph.string({ r.x + 2, r.y + 1 }, str);
|
||||
}
|
||||
|
||||
virtual void slider(window, graph_reference graph, const slider_t& s)
|
||||
@@ -512,7 +513,7 @@ namespace nana
|
||||
if(proto_.provider && attr_.is_draw_adorn)
|
||||
{
|
||||
unsigned vadorn = _m_value_by_pos(attr_.adorn_pos);
|
||||
nana::string str = proto_.provider->adorn_trace(attr_.vmax, vadorn);
|
||||
auto str = proto_.provider->adorn_trace(attr_.vmax, vadorn);
|
||||
if(str.size())
|
||||
{
|
||||
nana::size ts = other_.graph->text_extent_size(str);
|
||||
|
||||
@@ -677,20 +677,22 @@ namespace nana
|
||||
modifier(static_cast<std::wstring>(::nana::charset(prefix_utf8, ::nana::unicode::utf8)), static_cast<std::wstring>(::nana::charset(suffix_utf8, ::nana::unicode::utf8)));
|
||||
}
|
||||
|
||||
::nana::string spinbox::_m_caption() const throw()
|
||||
::std::string spinbox::_m_caption() const throw()
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().impl()->editor();
|
||||
return (editor ? editor->text() : nana::string());
|
||||
if (editor)
|
||||
return ::nana::charset(editor->text());
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void spinbox::_m_caption(::nana::string&& text)
|
||||
void spinbox::_m_caption(::std::string&& text)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().impl()->editor();
|
||||
if (editor)
|
||||
{
|
||||
editor->text(std::move(text));
|
||||
editor->text(::nana::charset(text, ::nana::unicode::utf8));
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,14 +209,16 @@ namespace drawerbase {
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
textbox::textbox(window wd, const nana::string& text, bool visible)
|
||||
textbox::textbox(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
textbox::textbox(window wd, const nana::char_t* text, bool visible)
|
||||
textbox::textbox(window wd, const char* text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text, std::strlen(text));
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
@@ -419,11 +421,12 @@ namespace drawerbase {
|
||||
editor->set_accept(std::move(fn));
|
||||
}
|
||||
|
||||
textbox& textbox::tip_string(nana::string str)
|
||||
textbox& textbox::tip_string(std::string str)
|
||||
{
|
||||
throw_not_utf8(str);
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if(editor && editor->tip_string(std::move(str)))
|
||||
if(editor && editor->tip_string(utf8_cast(str)))
|
||||
API::refresh_window(handle());
|
||||
return *this;
|
||||
}
|
||||
@@ -484,14 +487,10 @@ namespace drawerbase {
|
||||
|
||||
int textbox::to_int() const
|
||||
{
|
||||
nana::string s = _m_caption();
|
||||
auto s = _m_caption();
|
||||
if (s.empty()) return 0;
|
||||
|
||||
#ifdef NANA_UNICODE
|
||||
std::wstringstream ss;
|
||||
#else
|
||||
std::stringstream ss;
|
||||
#endif
|
||||
int value;
|
||||
ss << s;
|
||||
ss >> value;
|
||||
@@ -500,14 +499,10 @@ namespace drawerbase {
|
||||
|
||||
double textbox::to_double() const
|
||||
{
|
||||
nana::string s = _m_caption();
|
||||
auto s = _m_caption();
|
||||
if (s.empty()) return 0;
|
||||
|
||||
#ifdef NANA_UNICODE
|
||||
std::wstringstream ss;
|
||||
#else
|
||||
std::stringstream ss;
|
||||
#endif
|
||||
double value;
|
||||
ss << s;
|
||||
ss >> value;
|
||||
@@ -516,13 +511,13 @@ namespace drawerbase {
|
||||
|
||||
textbox& textbox::from(int n)
|
||||
{
|
||||
_m_caption(std::to_wstring(n));
|
||||
_m_caption(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
textbox& textbox::from(double d)
|
||||
{
|
||||
_m_caption(std::to_wstring(d));
|
||||
_m_caption(std::to_string(d));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -542,7 +537,7 @@ namespace drawerbase {
|
||||
editor->erase_highlight(name);
|
||||
}
|
||||
|
||||
void textbox::set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<nana::string> kw_list)
|
||||
void textbox::set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::wstring> kw_list)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@@ -600,20 +595,23 @@ namespace drawerbase {
|
||||
}
|
||||
|
||||
//Override _m_caption for caption()
|
||||
nana::string textbox::_m_caption() const throw()
|
||||
::std::string textbox::_m_caption() const throw()
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
return (editor ? editor->text() : nana::string());
|
||||
if (editor)
|
||||
return ::nana::charset(editor->text());
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void textbox::_m_caption(nana::string&& str)
|
||||
void textbox::_m_caption(std::string&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if (editor)
|
||||
{
|
||||
editor->text(std::move(str));
|
||||
editor->text(::nana::charset(str, ::nana::unicode::utf8));
|
||||
API::update_window(this->handle());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace nana
|
||||
|
||||
typedef std::size_t size_type;
|
||||
|
||||
nana::string text;
|
||||
std::string text;
|
||||
nana::paint::image image;
|
||||
unsigned pixels{0};
|
||||
nana::size textsize;
|
||||
@@ -39,7 +39,7 @@ namespace nana
|
||||
|
||||
kind type;
|
||||
|
||||
item_type(const nana::string& text, const nana::paint::image& img, kind type)
|
||||
item_type(const std::string& text, const nana::paint::image& img, kind type)
|
||||
:text(text), image(img), type(type)
|
||||
{}
|
||||
};
|
||||
@@ -58,9 +58,9 @@ namespace nana
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
void insert(size_type pos, const nana::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)
|
||||
{
|
||||
item_type* m = new item_type(text, img, type);
|
||||
item_type* m = new item_type(std::move(text), img, type);
|
||||
|
||||
if(pos < cont_.size())
|
||||
cont_.insert(cont_.begin() + pos, m);
|
||||
@@ -68,12 +68,12 @@ namespace nana
|
||||
cont_.push_back(m);
|
||||
}
|
||||
|
||||
void push_back(const nana::string& text, const nana::paint::image& img)
|
||||
void push_back(const std::string& text, const nana::paint::image& img)
|
||||
{
|
||||
insert(cont_.size(), text, img, item_type::kind::button);
|
||||
}
|
||||
|
||||
void push_back(const nana::string& text)
|
||||
void push_back(const std::string& text)
|
||||
{
|
||||
insert(cont_.size(), text, nana::paint::image(), item_type::kind::button);
|
||||
}
|
||||
@@ -242,7 +242,7 @@ namespace nana
|
||||
impl_->graph_ptr = &graph;
|
||||
|
||||
widget_ = static_cast< ::nana::toolbar*>(&widget);
|
||||
widget.caption(L"Nana Toolbar");
|
||||
widget.caption("nana toolbar");
|
||||
|
||||
impl_->event_size = API::events(widget.parent()).resized.connect_unignorable([this](const arg_resized& arg)
|
||||
{
|
||||
@@ -405,13 +405,13 @@ namespace nana
|
||||
API::refresh_window(handle());
|
||||
}
|
||||
|
||||
void toolbar::append(const nana::string& text, const nana::paint::image& img)
|
||||
void toolbar::append(const std::string& text, const nana::paint::image& img)
|
||||
{
|
||||
get_drawer_trigger().items().push_back(text, img);
|
||||
API::refresh_window(handle());
|
||||
}
|
||||
|
||||
void toolbar::append(const nana::string& text)
|
||||
void toolbar::append(const std::string& text)
|
||||
{
|
||||
get_drawer_trigger().items().push_back(text, {});
|
||||
API::refresh_window(this->handle());
|
||||
|
||||
@@ -1856,7 +1856,7 @@ namespace nana
|
||||
|
||||
widget.bgcolor(colors::white);
|
||||
impl_->data.widget_ptr = static_cast< ::nana::treebox*>(&widget);
|
||||
widget.caption(STR("Nana Treebox"));
|
||||
widget.caption("nana treebox");
|
||||
}
|
||||
|
||||
void trigger::refresh(graph_reference)
|
||||
|
||||
@@ -41,12 +41,12 @@ namespace nana
|
||||
wdg_._m_notify_destroy();
|
||||
}
|
||||
|
||||
std::wstring caption() override
|
||||
std::string caption() override
|
||||
{
|
||||
return wdg_._m_caption();
|
||||
}
|
||||
|
||||
virtual void caption(std::wstring text)
|
||||
virtual void caption(std::string text)
|
||||
{
|
||||
wdg_._m_caption(std::move(text));
|
||||
}
|
||||
@@ -54,19 +54,15 @@ namespace nana
|
||||
widget& wdg_;
|
||||
};
|
||||
|
||||
nana::string widget::caption() const throw()
|
||||
std::string widget::caption() const throw()
|
||||
{
|
||||
return this->_m_caption();
|
||||
}
|
||||
|
||||
void widget::caption(std::string utf8)
|
||||
{
|
||||
_m_caption(std::wstring(::nana::charset(utf8, ::nana::unicode::utf8)));
|
||||
}
|
||||
|
||||
void widget::caption(std::wstring str)
|
||||
{
|
||||
_m_caption(std::move(str));
|
||||
::nana::throw_not_utf8(utf8);
|
||||
_m_caption(std::move(utf8));
|
||||
}
|
||||
|
||||
void widget::i18n(i18n_eval eval)
|
||||
@@ -228,7 +224,7 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
widget& widget::tooltip(const nana::string& text)
|
||||
widget& widget::tooltip(const ::std::string& text)
|
||||
{
|
||||
nana::tooltip::set(*this, text);
|
||||
return *this;
|
||||
@@ -252,12 +248,12 @@ namespace nana
|
||||
void widget::_m_complete_creation()
|
||||
{}
|
||||
|
||||
nana::string widget::_m_caption() const throw()
|
||||
std::string widget::_m_caption() const throw()
|
||||
{
|
||||
return API::dev::window_caption(handle());
|
||||
}
|
||||
|
||||
void widget::_m_caption(nana::string&& str)
|
||||
void widget::_m_caption(std::string&& str)
|
||||
{
|
||||
API::dev::window_caption(handle(), std::move(str));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user