add native_string_type for internal use
This commit is contained in:
parent
ed4d2af7dd
commit
e8266b5ae8
@ -81,6 +81,35 @@ namespace nana
|
||||
|
||||
std::wstring utf8_cast(const std::string&);
|
||||
std::string utf8_cast(const std::wstring&);
|
||||
|
||||
const std::string& to_utf8(const std::string&);
|
||||
std::string to_utf8(const std::wstring&);
|
||||
|
||||
std::wstring to_wstring(const std::string& utf8_str);
|
||||
const std::wstring& to_wstring(const std::wstring& wstr);
|
||||
std::wstring&& to_wstring(std::wstring&& wstr);
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
using native_string_type = std::wstring;
|
||||
#else //POSIX
|
||||
using native_string_type = std::string;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
const detail::native_string_type to_native_string(const std::string&);
|
||||
const detail::native_string_type& to_native_string(const std::wstring&);
|
||||
detail::native_string_type to_native_string(int);
|
||||
detail::native_string_type to_native_string(double);
|
||||
#else //POSIX
|
||||
const detail::native_string_type& to_native_string(const std::string&);
|
||||
const detail::native_string_type to_native_string(const std::wstring&);
|
||||
detail::native_string_type to_native_string(int);
|
||||
detail::native_string_type to_native_string(double);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANA_UNICODE
|
||||
|
@ -145,7 +145,7 @@ namespace detail
|
||||
basic_window *parent;
|
||||
basic_window *owner;
|
||||
|
||||
::std::string title;
|
||||
native_string_type title;
|
||||
::nana::detail::drawer drawer; //Self Drawer with owen graphics
|
||||
basic_window* root_widget; //A pointer refers to the root basic window, if the window is a root, the pointer refers to itself.
|
||||
paint::graphics* root_graph; //Refer to the root buffer graphics
|
||||
|
@ -34,6 +34,8 @@ namespace detail
|
||||
unsigned extra_height; //extra border size, it is useful in Windows, ignore in X11 always 0
|
||||
};
|
||||
|
||||
using native_string_type = ::nana::detail::native_string_type;
|
||||
|
||||
static nana::size primary_monitor_size();
|
||||
static rectangle screen_area_from_point(const point&);
|
||||
static window_result create_window(native_window_type, bool nested, const rectangle&, const appearance&);
|
||||
@ -65,8 +67,8 @@ namespace detail
|
||||
|
||||
static void window_size(native_window_type, const size&);
|
||||
static void get_window_rect(native_window_type, rectangle&);
|
||||
static void window_caption(native_window_type, const std::string&);
|
||||
static std::string window_caption(native_window_type);
|
||||
static void window_caption(native_window_type, const native_string_type&);
|
||||
static native_string_type window_caption(native_window_type);
|
||||
static void capture_window(native_window_type, bool);
|
||||
static nana::point cursor_position();
|
||||
static native_window_type get_owner_window(native_window_type);
|
||||
|
@ -30,8 +30,8 @@ namespace nana
|
||||
|
||||
virtual widget* widget_ptr() const = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual std::string caption() = 0;
|
||||
virtual void caption(std::string) = 0;
|
||||
virtual ::nana::detail::native_string_type caption() = 0;
|
||||
virtual void caption(::nana::detail::native_string_type) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ namespace API
|
||||
widget_colors* get_scheme(window);
|
||||
|
||||
void attach_drawer(widget&, drawer_trigger&);
|
||||
std::string window_caption(window) throw();
|
||||
void window_caption(window, std::string);
|
||||
::nana::detail::native_string_type window_caption(window) throw();
|
||||
void window_caption(window, ::nana::detail::native_string_type);
|
||||
|
||||
window create_window(window, bool nested, const rectangle&, const appearance&, widget* attached);
|
||||
window create_widget(window, const rectangle&, widget* attached);
|
||||
@ -271,7 +271,7 @@ namespace API
|
||||
void update_window(window); ///< Copies the off-screen buffer to the screen for immediate display.
|
||||
|
||||
void window_caption(window, const std::string& title_utf8);
|
||||
void window_caption(window, const nana::string& title);
|
||||
void window_caption(window, const std::wstring& title);
|
||||
::std::string window_caption(window);
|
||||
|
||||
void window_cursor(window, cursor);
|
||||
|
@ -104,7 +104,7 @@ namespace nana{
|
||||
private:
|
||||
//Overrides widget virtual functions
|
||||
void _m_complete_creation() override;
|
||||
void _m_caption(std::string&&) override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
};
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
@ -238,10 +238,10 @@ namespace nana
|
||||
}
|
||||
private:
|
||||
//Overrides widget's virtual functions
|
||||
void _m_caption(std::string&& str) override
|
||||
void _m_caption(native_string_type&& str) override
|
||||
{
|
||||
this->get_drawer_trigger().path(str);
|
||||
API::dev::window_caption(*this, this->get_drawer_trigger().path());
|
||||
this->get_drawer_trigger().path(to_utf8(str));
|
||||
API::dev::window_caption(*this, to_native_string(this->get_drawer_trigger().path()) );
|
||||
}
|
||||
};
|
||||
}//end namespace nana
|
||||
|
@ -223,8 +223,8 @@ namespace nana
|
||||
const drawerbase::combox::drawer_impl& _m_impl() const;
|
||||
private:
|
||||
//Overrides widget's virtual functions
|
||||
::std::string _m_caption() const throw() override;
|
||||
void _m_caption(::std::string&&) override;
|
||||
native_string_type _m_caption() const throw() override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
nana::any * _m_anyobj(std::size_t pos, bool alloc_if_empty) const override;
|
||||
};
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ namespace nana{
|
||||
void _m_add_child(const char* field, widget*);
|
||||
void _m_init();
|
||||
void _m_complete_creation() override;
|
||||
::std::string _m_caption() const throw() override;
|
||||
void _m_caption(::std::string&&) override;
|
||||
native_string_type _m_caption() const throw() override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
};
|
||||
|
@ -76,7 +76,7 @@ namespace nana
|
||||
label& text_align(align horizontal_align, align_v vertical_align= align_v::top);
|
||||
private:
|
||||
//Overrides widget's virtual function
|
||||
void _m_caption(std::string&&) override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
};
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
@ -106,8 +106,8 @@ namespace nana
|
||||
void modifier(std::wstring prefix, std::wstring suffix);
|
||||
void modifier(const std::string & prefix_utf8, const std::string& suffix_utf8);
|
||||
private:
|
||||
::std::string _m_caption() const throw();
|
||||
void _m_caption(::std::string&&);
|
||||
native_string_type _m_caption() const throw();
|
||||
void _m_caption(native_string_type&&);
|
||||
}; //end class spinbox
|
||||
}//end namespace nana
|
||||
|
||||
|
@ -209,8 +209,8 @@ namespace nana
|
||||
unsigned line_pixels() const;
|
||||
protected:
|
||||
//Overrides widget's virtual functions
|
||||
::std::string _m_caption() const throw() override;
|
||||
void _m_caption(::std::string&&) override;
|
||||
native_string_type _m_caption() const throw() override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
void _m_typeface(const paint::font&) override;
|
||||
};
|
||||
}//end namespace nana
|
||||
|
@ -34,11 +34,8 @@ namespace nana
|
||||
class inner_widget_notifier;
|
||||
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
|
||||
public:
|
||||
#if defined(NANA_WINDOWS)
|
||||
using native_string_type = std::wstring;
|
||||
#else //POSIX
|
||||
using native_string_type = std::string;
|
||||
#endif
|
||||
using native_string_type = detail::native_string_type;
|
||||
|
||||
virtual ~widget() = default;
|
||||
virtual window handle() const = 0; ///< Returns the handle of window, returns 0 if window is not created.
|
||||
bool empty() const; ///< Determines whether the manipulator is handling a window.
|
||||
@ -113,8 +110,8 @@ namespace nana
|
||||
virtual void _m_complete_creation();
|
||||
|
||||
virtual general_events& _m_get_general_events() const = 0;
|
||||
virtual ::std::string _m_caption() const throw();
|
||||
virtual void _m_caption(::std::string&&);
|
||||
virtual native_string_type _m_caption() const throw();
|
||||
virtual void _m_caption(native_string_type&&);
|
||||
virtual nana::cursor _m_cursor() const;
|
||||
virtual void _m_cursor(nana::cursor);
|
||||
virtual void _m_close();
|
||||
|
@ -407,6 +407,73 @@ namespace nana
|
||||
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
const std::string& to_utf8(const std::string& str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string to_utf8(const std::wstring& text)
|
||||
{
|
||||
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
std::wstring to_wstring(const std::string& utf8_str)
|
||||
{
|
||||
return ::nana::charset(utf8_str, ::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
const std::wstring& to_wstring(const std::wstring& wstr)
|
||||
{
|
||||
return wstr;
|
||||
}
|
||||
|
||||
std::wstring&& to_wstring(std::wstring&& wstr)
|
||||
{
|
||||
return static_cast<std::wstring&&>(wstr);
|
||||
}
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
const detail::native_string_type to_native_string(const std::string& text)
|
||||
{
|
||||
return ::nana::charset(text, ::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
const detail::native_string_type& to_native_string(const std::wstring& text)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
detail::native_string_type to_native_string(int n)
|
||||
{
|
||||
return std::to_wstring(n);
|
||||
}
|
||||
|
||||
detail::native_string_type to_native_string(double d)
|
||||
{
|
||||
return std::to_wstring(d);
|
||||
}
|
||||
#else //POSIX
|
||||
const detail::native_string_type& to_native_string(const std::string& text)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
const detail::native_string_type to_native_string(const std::wstring& text)
|
||||
{
|
||||
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
detail::native_string_type to_native_string(int n)
|
||||
{
|
||||
return std::to_string(n);
|
||||
}
|
||||
|
||||
detail::native_string_type to_native_string(double d)
|
||||
{
|
||||
return std::to_string(d);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
std::size_t strlen(const char_t* str)
|
||||
{
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user