add native_string_type for internal use

This commit is contained in:
Jinhao
2015-12-03 01:49:44 +08:00
parent ed4d2af7dd
commit e8266b5ae8
24 changed files with 185 additions and 85 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
};
}
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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;
};
}

View File

@@ -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_;
};

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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();