add native_string_type for internal use
This commit is contained in:
@@ -1076,18 +1076,17 @@ namespace nana{
|
||||
#endif
|
||||
}
|
||||
|
||||
void native_interface::window_caption(native_window_type wd, const std::string& title)
|
||||
void native_interface::window_caption(native_window_type wd, const native_string_type& title)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
std::wstring wtext = ::nana::charset(title, ::nana::unicode::utf8);
|
||||
if(::GetCurrentThreadId() != ::GetWindowThreadProcessId(reinterpret_cast<HWND>(wd), 0))
|
||||
{
|
||||
wchar_t * wstr = new wchar_t[wtext.length() + 1];
|
||||
std::wcscpy(wstr, wtext.c_str());
|
||||
wchar_t * wstr = new wchar_t[title.length() + 1];
|
||||
std::wcscpy(wstr, title.c_str());
|
||||
::PostMessage(reinterpret_cast<HWND>(wd), nana::detail::messages::remote_thread_set_window_text, reinterpret_cast<WPARAM>(wstr), 0);
|
||||
}
|
||||
else
|
||||
::SetWindowText(reinterpret_cast<HWND>(wd), wtext.c_str());
|
||||
::SetWindowText(reinterpret_cast<HWND>(wd), title.c_str());
|
||||
#elif defined(NANA_X11)
|
||||
::XTextProperty name;
|
||||
char * text = const_cast<char*>(title.c_str());
|
||||
@@ -1101,13 +1100,13 @@ namespace nana{
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string native_interface::window_caption(native_window_type wd)
|
||||
auto native_interface::window_caption(native_window_type wd) -> native_string_type
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
int length = ::GetWindowTextLength(reinterpret_cast<HWND>(wd));
|
||||
if(length > 0)
|
||||
{
|
||||
nana::string str;
|
||||
native_string_type str;
|
||||
//One for NULL terminator which GetWindowText will write.
|
||||
str.resize(length+1);
|
||||
|
||||
@@ -1116,7 +1115,7 @@ namespace nana{
|
||||
//Remove the null terminator writtien by GetWindowText
|
||||
str.resize(length);
|
||||
|
||||
return ::nana::charset(str);
|
||||
return str;
|
||||
}
|
||||
#elif defined(NANA_X11)
|
||||
nana::detail::platform_scope_guard psg;
|
||||
@@ -1136,7 +1135,7 @@ namespace nana{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return std::string();
|
||||
return native_string_type();
|
||||
}
|
||||
|
||||
void native_interface::capture_window(native_window_type wd, bool cap)
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace API
|
||||
}
|
||||
}
|
||||
|
||||
std::string window_caption(window wd) throw()
|
||||
::nana::detail::native_string_type window_caption(window wd) throw()
|
||||
{
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard isg;
|
||||
@@ -234,7 +234,7 @@ namespace API
|
||||
return {};
|
||||
}
|
||||
|
||||
void window_caption(window wd, std::string title)
|
||||
void window_caption(window wd, ::nana::detail::native_string_type title)
|
||||
{
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
@@ -823,12 +823,15 @@ namespace API
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(iwd))
|
||||
iwd->widget_notifier->caption(title_utf8);
|
||||
iwd->widget_notifier->caption(to_native_string(title_utf8));
|
||||
}
|
||||
|
||||
void window_caption(window wd, const nana::string& title)
|
||||
void window_caption(window wd, const std::wstring& title)
|
||||
{
|
||||
window_caption(wd, static_cast<std::string>(::nana::charset(title).to_bytes(::nana::unicode::utf8)));
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(iwd))
|
||||
iwd->widget_notifier->caption(to_native_string(title));
|
||||
}
|
||||
|
||||
std::string window_caption(window wd)
|
||||
@@ -836,7 +839,7 @@ namespace API
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(iwd))
|
||||
return iwd->widget_notifier->caption();
|
||||
return to_utf8(iwd->widget_notifier->caption());
|
||||
|
||||
return{};
|
||||
}
|
||||
|
||||
@@ -511,11 +511,11 @@ namespace nana{ namespace drawerbase
|
||||
});
|
||||
}
|
||||
|
||||
void button::_m_caption(std::string&& text)
|
||||
void button::_m_caption(native_string_type&& text)
|
||||
{
|
||||
API::unregister_shortkey(handle());
|
||||
|
||||
std::wstring wtext = ::nana::charset(text, ::nana::unicode::utf8);
|
||||
std::wstring wtext = ::nana::to_wstring(text);
|
||||
|
||||
wchar_t shortkey;
|
||||
API::transform_shortkey_text(wtext, shortkey, 0);
|
||||
|
||||
@@ -543,7 +543,7 @@ namespace nana
|
||||
{
|
||||
if(node)
|
||||
{
|
||||
API::dev::window_caption(window_handle(), tree().path());
|
||||
API::dev::window_caption(window_handle(), to_native_string(tree().path()));
|
||||
if(evt_holder_.selected)
|
||||
evt_holder_.selected(node->value.second.value);
|
||||
}
|
||||
@@ -807,7 +807,7 @@ namespace nana
|
||||
{
|
||||
throw_not_utf8(str);
|
||||
scheme_->tree().insert(str, value);
|
||||
API::dev::window_caption(scheme_->window_handle(), scheme_->tree().path());
|
||||
API::dev::window_caption(scheme_->window_handle(), to_native_string(scheme_->tree().path()));
|
||||
scheme_->draw();
|
||||
}
|
||||
|
||||
|
||||
@@ -982,22 +982,22 @@ namespace nana
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
std::string combox::_m_caption() const throw()
|
||||
auto combox::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = _m_impl().editor();
|
||||
if (editor)
|
||||
return ::nana::charset(editor->text());
|
||||
return std::string();
|
||||
return to_native_string(editor->text());
|
||||
return native_string_type();
|
||||
}
|
||||
|
||||
void combox::_m_caption(std::string&& str)
|
||||
void combox::_m_caption(native_string_type&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
|
||||
auto editor = _m_impl().editor();
|
||||
if (editor)
|
||||
editor->text(::nana::charset(str, nana::unicode::utf8));
|
||||
editor->text(to_native_string(str));
|
||||
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
@@ -234,12 +234,12 @@ namespace nana{
|
||||
_m_init();
|
||||
}
|
||||
|
||||
::std::string group::_m_caption() const throw()
|
||||
auto group::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
return impl_->caption.caption();
|
||||
return impl_->caption.caption_native();
|
||||
}
|
||||
|
||||
void group::_m_caption(::std::string&& str)
|
||||
void group::_m_caption(native_string_type&& str)
|
||||
{
|
||||
impl_->caption.caption(std::move(str));
|
||||
impl_->update_div();
|
||||
|
||||
@@ -807,7 +807,7 @@ namespace nana
|
||||
if(impl->renderer.format(f))
|
||||
{
|
||||
window wd = *this;
|
||||
impl->renderer.parse(::nana::charset(API::dev::window_caption(wd), ::nana::unicode::utf8));
|
||||
impl->renderer.parse(::nana::to_wstring(API::dev::window_caption(wd)));
|
||||
API::refresh_window(wd);
|
||||
}
|
||||
return *this;
|
||||
@@ -869,11 +869,11 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
void label::_m_caption(std::string&& str)
|
||||
void label::_m_caption(native_string_type&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
window wd = *this;
|
||||
get_drawer_trigger().impl()->renderer.parse(::nana::charset(str, nana::unicode::utf8));
|
||||
get_drawer_trigger().impl()->renderer.parse(to_wstring(str));
|
||||
API::dev::window_caption(wd, std::move(str));
|
||||
API::refresh_window(wd);
|
||||
}
|
||||
|
||||
@@ -677,22 +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)));
|
||||
}
|
||||
|
||||
::std::string spinbox::_m_caption() const throw()
|
||||
auto spinbox::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().impl()->editor();
|
||||
if (editor)
|
||||
return ::nana::charset(editor->text());
|
||||
return std::string();
|
||||
return to_native_string(editor->text());
|
||||
return native_string_type();
|
||||
}
|
||||
|
||||
void spinbox::_m_caption(::std::string&& text)
|
||||
void spinbox::_m_caption(native_string_type&& text)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().impl()->editor();
|
||||
if (editor)
|
||||
{
|
||||
editor->text(::nana::charset(text, ::nana::unicode::utf8));
|
||||
editor->text(to_wstring(text));
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ namespace drawerbase {
|
||||
|
||||
std::stringstream ss;
|
||||
int value;
|
||||
ss << s;
|
||||
ss << to_utf8(s);
|
||||
ss >> value;
|
||||
return value;
|
||||
}
|
||||
@@ -504,20 +504,20 @@ namespace drawerbase {
|
||||
|
||||
std::stringstream ss;
|
||||
double value;
|
||||
ss << s;
|
||||
ss << to_utf8(s);
|
||||
ss >> value;
|
||||
return value;
|
||||
}
|
||||
|
||||
textbox& textbox::from(int n)
|
||||
{
|
||||
_m_caption(std::to_string(n));
|
||||
_m_caption(to_native_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
textbox& textbox::from(double d)
|
||||
{
|
||||
_m_caption(std::to_string(d));
|
||||
_m_caption(to_native_string(d));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -595,23 +595,23 @@ namespace drawerbase {
|
||||
}
|
||||
|
||||
//Override _m_caption for caption()
|
||||
::std::string textbox::_m_caption() const throw()
|
||||
auto textbox::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if (editor)
|
||||
return ::nana::charset(editor->text());
|
||||
return to_native_string(editor->text());
|
||||
|
||||
return std::string();
|
||||
return native_string_type();
|
||||
}
|
||||
|
||||
void textbox::_m_caption(std::string&& str)
|
||||
void textbox::_m_caption(native_string_type&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if (editor)
|
||||
{
|
||||
editor->text(::nana::charset(str, ::nana::unicode::utf8));
|
||||
editor->text(to_wstring(str));
|
||||
API::update_window(this->handle());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,12 @@ namespace nana
|
||||
wdg_._m_notify_destroy();
|
||||
}
|
||||
|
||||
std::string caption() override
|
||||
native_string_type caption() override
|
||||
{
|
||||
return wdg_._m_caption();
|
||||
}
|
||||
|
||||
virtual void caption(std::string text)
|
||||
void caption(native_string_type text) override
|
||||
{
|
||||
wdg_._m_caption(std::move(text));
|
||||
}
|
||||
@@ -56,33 +56,35 @@ namespace nana
|
||||
|
||||
std::string widget::caption() const throw()
|
||||
{
|
||||
return this->_m_caption();
|
||||
return utf8_cast(_m_caption());
|
||||
}
|
||||
|
||||
std::wstring widget::caption_wstring() const throw()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
return _m_caption();
|
||||
#else
|
||||
return utf8_cast(_m_caption());
|
||||
#endif
|
||||
}
|
||||
|
||||
auto widget::caption_native() const throw() -> native_string_type
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
return caption_wstring();
|
||||
#else
|
||||
return caption();
|
||||
#endif
|
||||
return _m_caption();
|
||||
}
|
||||
|
||||
widget& widget::caption(std::string utf8)
|
||||
{
|
||||
::nana::throw_not_utf8(utf8);
|
||||
_m_caption(std::move(utf8));
|
||||
native_string_type str = to_native_string(utf8);
|
||||
_m_caption(std::move(str));
|
||||
return *this;
|
||||
}
|
||||
|
||||
widget& widget::caption(std::wstring text)
|
||||
{
|
||||
_m_caption(utf8_cast(text));
|
||||
native_string_type str = to_native_string(text);
|
||||
_m_caption(std::move(str));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -90,7 +92,8 @@ namespace nana
|
||||
{
|
||||
if (handle())
|
||||
{
|
||||
_m_caption(eval());
|
||||
native_string_type str = to_native_string(eval());
|
||||
_m_caption(std::move(str));
|
||||
internationalization_parts::set_eval(handle(), std::move(eval));
|
||||
}
|
||||
}
|
||||
@@ -269,12 +272,12 @@ namespace nana
|
||||
void widget::_m_complete_creation()
|
||||
{}
|
||||
|
||||
std::string widget::_m_caption() const throw()
|
||||
auto widget::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
return API::dev::window_caption(handle());
|
||||
}
|
||||
|
||||
void widget::_m_caption(std::string&& str)
|
||||
void widget::_m_caption(native_string_type&& str)
|
||||
{
|
||||
API::dev::window_caption(handle(), std::move(str));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user