diff --git a/CMakeLists.txt b/CMakeLists.txt
index e416d60c..f2024d27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@
#https://cmake.org/cmake-tutorial/
#https://cmake.org/cmake/help/v3.3/module/CMakeDependentOption.html?highlight=cmakedependentoption
-# use CACHE FORCE or set(USE_meganz_mingw_std_threads ON) or delete CMakecache.txt or the entirely build dir
+# use CACHEÂ FORCE or set(USE_meganz_mingw_std_threads ON) or delete CMakecache.txt or the entirely build dir
# if your changes don't execute
option(USE_meganz_mingw_std_threads "replaced boost.thread with meganz's mingw-std-threads." OFF)
option(USE_UNICODE "Use Unicode Character Set" ON)
@@ -143,16 +143,15 @@ aux_source_directory(${NANA_SOURCE_DIR}/paint/detail NANA_PAINT_DETAIL_SOURCE)
aux_source_directory(${NANA_SOURCE_DIR}/system NANA_SYSTEM_SOURCE)
aux_source_directory(${NANA_SOURCE_DIR}/threads NANA_THREADS_SOURCE)
-#To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library
-#and Use SOURCE_GROUP if all your sources are in the same directory
+#To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library
+#and Use SOURCE_GROUP if all your sources are in the same directory
+if(NOT APPLE)
add_library(${PROJECT_NAME} ${NANA_SOURCE}
${NANA_DETAIL_SOURCE}
${NANA_FILESYSTEM_SOURCE}
-if(NOT APPLE)
${NANA_AUDIO_SOURCE}
${NANA_AUDIO_DETAIL_SOURCE}
-endif (NOT APPLE)
${NANA_GUI_SOURCE}
${NANA_GUI_DETAIL_SOURCE}
${NANA_GUI_WIDGETS_SOURCE}
@@ -160,11 +159,26 @@ endif (NOT APPLE)
${NANA_PAINT_SOURCE}
${NANA_PAINT_DETAIL_SOURCE}
${NANA_SYSTEM_SOURCE}
- ${NANA_THREADS_SOURCE})
+ ${NANA_THREADS_SOURCE})
+endif (NOT APPLE)
+
if(APPLE)
- #Headers: use INCLUDE_DIRECTORIES
- # Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES
+add_library(${PROJECT_NAME} ${NANA_SOURCE}
+ ${NANA_DETAIL_SOURCE}
+ ${NANA_FILESYSTEM_SOURCE}
+ ${NANA_AUDIO_SOURCE}
+ ${NANA_AUDIO_DETAIL_SOURCE}
+ ${NANA_GUI_SOURCE}
+ ${NANA_GUI_DETAIL_SOURCE}
+ ${NANA_GUI_WIDGETS_SOURCE}
+ ${NANA_GUI_WIDGETS_SKELETONS_SOURCE}
+ ${NANA_PAINT_SOURCE}
+ ${NANA_PAINT_DETAIL_SOURCE}
+ ${NANA_SYSTEM_SOURCE}
+ ${NANA_THREADS_SOURCE})
+ #Headers: use INCLUDE_DIRECTORIES
+ # Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES
target_link_libraries(${PROJECT_NAME} -L/opt/X11/lib/ -lX11 -lXft -lpng -liconv)
endif(APPLE)
diff --git a/build/codeblocks/nana.cbp b/build/codeblocks/nana.cbp
index 49f61ad7..e0d020a6 100644
--- a/build/codeblocks/nana.cbp
+++ b/build/codeblocks/nana.cbp
@@ -119,7 +119,6 @@
-
diff --git a/build/vc2013/nana.vcxproj b/build/vc2013/nana.vcxproj
index 01db0e79..82ed86e6 100644
--- a/build/vc2013/nana.vcxproj
+++ b/build/vc2013/nana.vcxproj
@@ -256,7 +256,6 @@
-
diff --git a/build/vc2013/nana.vcxproj.filters b/build/vc2013/nana.vcxproj.filters
index d2c700e8..1d5d8d11 100644
--- a/build/vc2013/nana.vcxproj.filters
+++ b/build/vc2013/nana.vcxproj.filters
@@ -291,9 +291,6 @@
Source Files\nana
-
- Source Files\nana
-
Source Files\nana
diff --git a/build/vc2015/nana.vcxproj b/build/vc2015/nana.vcxproj
index 89ceaaa3..139797f3 100644
--- a/build/vc2015/nana.vcxproj
+++ b/build/vc2015/nana.vcxproj
@@ -249,7 +249,6 @@
-
diff --git a/build/vc2015/nana.vcxproj.filters b/build/vc2015/nana.vcxproj.filters
index 8130c2bc..9781e955 100644
--- a/build/vc2015/nana.vcxproj.filters
+++ b/build/vc2015/nana.vcxproj.filters
@@ -69,9 +69,6 @@
Source Files
-
- Source Files
-
Source Files
diff --git a/include/nana/audio/detail/audio_stream.hpp b/include/nana/audio/detail/audio_stream.hpp
index 5fe9d39c..d148f98f 100644
--- a/include/nana/audio/detail/audio_stream.hpp
+++ b/include/nana/audio/detail/audio_stream.hpp
@@ -59,7 +59,7 @@ namespace nana{ namespace audio{
unsigned cksize;
};
public:
- bool open(const nana::string& file);
+ bool open(const std::string& file);
void close();
bool empty() const;
const wave_spec::format_chunck & format() const;
diff --git a/include/nana/audio/player.hpp b/include/nana/audio/player.hpp
index 24378214..3fc1acca 100644
--- a/include/nana/audio/player.hpp
+++ b/include/nana/audio/player.hpp
@@ -14,10 +14,10 @@ namespace nana{ namespace audio
struct implementation;
public:
player();
- player(const nana::string& file);
+ player(const std::string& file);
~player();
- bool open(const nana::string& file);
+ bool open(const std::string& file);
void play();
void close();
private:
diff --git a/include/nana/basic_types.hpp b/include/nana/basic_types.hpp
index da37272d..e990a681 100644
--- a/include/nana/basic_types.hpp
+++ b/include/nana/basic_types.hpp
@@ -67,7 +67,8 @@ namespace nana
}
};
- typedef std::basic_string > cistring;
+ using cistring = std::basic_string>;
+ using ciwstring = std::basic_string>;
namespace detail
diff --git a/include/nana/charset.hpp b/include/nana/charset.hpp
index 6c36159b..725fdf96 100644
--- a/include/nana/charset.hpp
+++ b/include/nana/charset.hpp
@@ -18,6 +18,24 @@
namespace nana
{
+ namespace utf
+ {
+ /// Attempt to get a pointer to a character of UTF-8 string by a specifed character index.
+ /// @param text_utf8 A string encoded as UTF-8.
+ /// @param pos The unicode character index.
+ /// @returns A pointer to the unicode character. It returns a null if pos is out of range.
+ const char* char_ptr(const char* text_utf8, unsigned pos);
+ const char* char_ptr(const ::std::string& text_utf8, unsigned pos);
+
+ /// Get the unicode character by a specified character index.
+ /// @param text_utf8 A string encoded as UTF-8.
+ /// @param pos The unicode character index.
+ /// @param len A unsigned pointer to receive the number of bytes it takes in UTF-8 encoded. If len is a nullptr, it is ignored.
+ /// @returns A unicode character. '\0' if pos is out of range.
+ wchar_t char_at(const char* text_utf8, unsigned pos, unsigned * len);
+ wchar_t char_at(const ::std::string& text_utf8, unsigned pos, unsigned * len);
+ }
+
enum class unicode
{
utf8, utf16, utf32
diff --git a/include/nana/deploy.hpp b/include/nana/deploy.hpp
index a4414ac9..8d9f2cb3 100644
--- a/include/nana/deploy.hpp
+++ b/include/nana/deploy.hpp
@@ -23,7 +23,6 @@
#include
#include
-
//Implement workarounds for GCC/MinGW which version is below 4.8.2
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)
namespace std
@@ -93,56 +92,61 @@ namespace std
}
#endif
-
-#ifndef NANA_UNICODE
- namespace nana
- {
- typedef char char_t;
- typedef std::string string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE
- }
- #define STR(string) string
-#else
- namespace nana
- {
- typedef wchar_t char_t;
- typedef std::wstring string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE
- }
- #define STR(string) L##string
-#endif
-
namespace nana
{
- std::size_t strlen(const char_t* str);
- char_t* strcpy(char_t* dest, const char_t* source);
-#ifdef _MSC_VER
- template
- inline char* strcpy(char (&dest)[N], const char* source)
- {
- ::strncpy_s(dest, source, _TRUNCATE);
- return dest;
- }
- template
- inline wchar_t* strcpy(wchar_t (&dest)[N], const wchar_t* source)
- {
- ::wcsncpy_s(dest, source, _TRUNCATE);
- return dest;
- }
-#endif // #ifdef _MSC_VER
-}
+ /// Checks whether a specified text is utf8 encoding
+ bool is_utf8(const char* str, unsigned len);
+ void throw_not_utf8(const std::string& text);
+ void throw_not_utf8(const char*, unsigned len);
+ void throw_not_utf8(const char*);
+
+ 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);
#if defined(NANA_WINDOWS)
- #define NANA_SHARED_EXPORT extern "C" _declspec(dllexport)
-#elif defined(NANA_LINUX) || defined(NANA_MACOS)
- #define NANA_SHARED_EXPORT extern "C"
+ std::string to_osmbstr(const std::string& text_utf8);
+#else
+ std::string to_osmbstr(std::string text_utf8);
#endif
+
+ 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_nstring(const std::string&);
+ const detail::native_string_type& to_nstring(const std::wstring&);
+ detail::native_string_type to_nstring(std::string&&);
+ detail::native_string_type&& to_nstring(std::wstring&&);
+#else //POSIX
+ const detail::native_string_type& to_nstring(const std::string&);
+ const detail::native_string_type to_nstring(const std::wstring&);
+ detail::native_string_type&& to_nstring(std::string&&);
+ detail::native_string_type to_nstring(std::wstring&&);
+#endif
+ detail::native_string_type to_nstring(int);
+ detail::native_string_type to_nstring(double);
+ detail::native_string_type to_nstring(std::size_t);
+}
+
+
namespace nana
{
- bool is_incomplete(const nana::string& str, unsigned pos);
-
inline unsigned make_rgb(unsigned char red, unsigned char green, unsigned char blue)
{
-
return ((unsigned(red) << 16)|((unsigned(green)<<8))|blue);
}
}
diff --git a/include/nana/detail/linux_X11/msg_packet.hpp b/include/nana/detail/linux_X11/msg_packet.hpp
index b1fc3dec..ea24091f 100644
--- a/include/nana/detail/linux_X11/msg_packet.hpp
+++ b/include/nana/detail/linux_X11/msg_packet.hpp
@@ -22,7 +22,7 @@ namespace detail
Window window;
int x;
int y;
- std::vector * files;
+ std::vector * files;
}mouse_drop;
}u;
};
diff --git a/include/nana/detail/linux_X11/platform_spec.hpp b/include/nana/detail/linux_X11/platform_spec.hpp
index 0a013ed6..12f4e94a 100644
--- a/include/nana/detail/linux_X11/platform_spec.hpp
+++ b/include/nana/detail/linux_X11/platform_spec.hpp
@@ -70,7 +70,7 @@ namespace detail
struct font_tag
{
- nana::string name;
+ std::string name;
unsigned height;
unsigned weight;
bool italic;
@@ -102,7 +102,7 @@ namespace detail
#if defined(NANA_UNICODE)
XftDraw * xftdraw{nullptr};
XftColor xft_fgcolor;
- const std::string charset(const nana::string& str, const std::string& strcode);
+ const std::string charset(const std::wstring& str, const std::string& strcode);
#endif
drawable_impl_type();
~drawable_impl_type();
@@ -203,7 +203,7 @@ namespace detail
void default_native_font(const font_ptr_t&);
unsigned font_size_to_height(unsigned) const;
unsigned font_height_to_size(unsigned) const;
- font_ptr_t make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strick_out);
+ font_ptr_t make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strick_out);
Display* open_display();
void close_display();
diff --git a/include/nana/detail/win32/platform_spec.hpp b/include/nana/detail/win32/platform_spec.hpp
index b129406b..dc6329fe 100644
--- a/include/nana/detail/win32/platform_spec.hpp
+++ b/include/nana/detail/win32/platform_spec.hpp
@@ -80,7 +80,7 @@ namespace detail
struct font_tag
{
- nana::string name;
+ native_string_type name;
unsigned height;
unsigned weight;
bool italic;
@@ -186,7 +186,7 @@ namespace detail
void default_native_font(const font_ptr_t&);
unsigned font_size_to_height(unsigned) const;
unsigned font_height_to_size(unsigned) const;
- font_ptr_t make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
+ font_ptr_t make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
static platform_spec& instance();
diff --git a/include/nana/filesystem/file_iterator.hpp b/include/nana/filesystem/file_iterator.hpp
index 94f37001..26df3f10 100644
--- a/include/nana/filesystem/file_iterator.hpp
+++ b/include/nana/filesystem/file_iterator.hpp
@@ -1,12 +1,12 @@
/*
* A File Iterator Implementation
- * Copyright(C) 2003 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
* http://www.boost.org/LICENSE_1_0.txt)
*
- * @file: stdex/filesystem/file_iterator.hpp
+ * @file: filesystem/file_iterator.hpp
* @description:
* file_iterator is a toolkit for applying each file and directory in a
* specified path.
@@ -39,9 +39,9 @@ namespace filesystem
#ifdef NANA_WINDOWS
fileinfo(const WIN32_FIND_DATA& wfd);
#elif defined(NANA_POSIX)
- fileinfo(const nana::string& filename, const struct stat &);
+ fileinfo(const std::string& filename, const struct stat &);
#endif
- nana::string name;
+ ::std::string name;
unsigned long size;
bool directory;
@@ -56,7 +56,7 @@ namespace filesystem
basic_file_iterator():end_(true), handle_(nullptr){}
- basic_file_iterator(const nana::string& file_path)
+ basic_file_iterator(const std::string& file_path)
:end_(false), handle_(nullptr)
{
_m_prepare(file_path);
@@ -92,14 +92,13 @@ namespace filesystem
return (*p == 0);
}
- void _m_prepare(const nana::string& file_path)
+ void _m_prepare(const std::string& file_path)
{
#if defined(NANA_WINDOWS)
- path_ = file_path;
- auto pat = file_path;
+ auto pat = utf8_cast(file_path);
DWORD attr = ::GetFileAttributes(pat.data());
if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
- pat += STR("\\*");
+ pat += L"\\*";
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_);
@@ -120,10 +119,11 @@ namespace filesystem
}
value_ = value_type(wfd_);
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
- path_ = nana::charset(file_path);
- if(path_.size() && (path_[path_.size() - 1] != '/'))
+ path_ = file_path;
+ if(path_.size() && path_.back() != '/')
path_ += '/';
- find_handle_t handle = opendir(path_.c_str());
+ auto handle = opendir(path_.c_str());
+
end_ = true;
if(handle)
{
@@ -143,7 +143,7 @@ namespace filesystem
struct stat fst;
if(stat((path_ + dnt->d_name).c_str(), &fst) == 0)
{
- value_ = value_type(nana::charset(dnt->d_name), fst);
+ value_ = value_type(dnt->d_name, fst);
}
else
{
@@ -226,9 +226,8 @@ namespace filesystem
#if defined(NANA_WINDOWS)
WIN32_FIND_DATA wfd_;
- nana::string path_;
-#elif defined(NANA_LINUX) || defined(NANA_MACOS)
- std::string path_;
+#else
+ std::string path_;
#endif
std::shared_ptr find_ptr_;
diff --git a/include/nana/filesystem/filesystem.hpp b/include/nana/filesystem/filesystem.hpp
index dda69c98..6425f922 100644
--- a/include/nana/filesystem/filesystem.hpp
+++ b/include/nana/filesystem/filesystem.hpp
@@ -1,7 +1,7 @@
/*
* A ISO C++ filesystem Implementation
* Nana C++ Library(http://www.nanapro.org)
- * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
+ * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
#include
@@ -55,25 +56,27 @@ namespace nana { namespace experimental
{
namespace filesystem
{
- enum class file_type
- {
- none = 0, ///< has not been determined or an error occurred while trying to determine
- not_found = -1, ///< Pseudo-type: file was not found. Is not considered an error
- regular = 1,
- directory = 2 ,
- symlink =3, ///< Symbolic link file
- block =4, ///< Block special file
- character= 5 , ///< Character special file
- fifo = 6 , ///< FIFO or pipe file
- socket =7,
- unknown= 8 ///< The file does exist, but is of an operating system dependent type not covered by any of the other
- };
+ enum class file_type
+ {
+ none = 0, ///< has not been determined or an error occurred while trying to determine
+ not_found = -1, ///< Pseudo-type: file was not found. Is not considered an error
+ regular = 1,
+ directory = 2 ,
+ symlink =3, ///< Symbolic link file
+ block =4, ///< Block special file
+ character= 5 , ///< Character special file
+ fifo = 6 , ///< FIFO or pipe file
+ socket =7,
+ unknown= 8 ///< The file does exist, but is of an operating system dependent type not covered by any of the other
+ };
- enum class perms
- {
- none =0, ///< There are no permissions set for the file.
- unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
- };
+ enum class perms
+ {
+ none = 0, ///< There are no permissions set for the file.
+ all = 0x1FF, ///< owner_all | group_all | others_all
+ mask = 0xFFF, ///< all | set_uid | set_gid | sticky_bit.
+ unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
+ };
//enum class copy_options;
//enum class directory_options;
@@ -96,35 +99,28 @@ namespace filesystem
uintmax_t free;
uintmax_t available;
};
- using file_time_type = std::chrono::time_point< std::chrono::system_clock>;// trivial-clock> ;
- class file_status
- {
- file_type m_ft = file_type::none;
- perms m_prms = perms::unknown;
+ using file_time_type = std::chrono::time_point;// trivial-clock> ;
- public:
- explicit file_status(file_type ft = file_type::none, perms prms = perms::unknown)
- :m_ft{ft}, m_prms{prms}
- {}
+ class file_status
+ {
+ file_type m_ft = file_type::none;
+ perms m_prms = perms::unknown;
- file_status(const file_status& fs) : m_ft{fs.m_ft}, m_prms{fs.m_prms}{} // = default;
- file_status(file_status&& fs) : m_ft{fs.m_ft}, m_prms{fs.m_prms}{} // = default;
+ public:
+ explicit file_status(file_type ft = file_type::none, perms prms = perms::unknown);
- ~file_status(){};
- file_status& operator=(const file_status&) = default;
- file_status& operator=(file_status&&fs) // = default;
- {
- m_ft=fs.m_ft; m_prms = fs.m_prms;
- return *this;
- }
- // observers
- file_type type() const { return m_ft;}
- perms permissions() const { return m_prms;}
- // modifiers
- void type (file_type ft) { m_ft=ft ;}
- void permissions(perms prms) { m_prms = prms; }
- };
+ // observers
+ file_type type() const;
+ perms permissions() const;
+
+ // modifiers
+ void type(file_type ft);
+ void permissions(perms prms);
+ private:
+ file_type value_;
+ perms perms_;
+ };
/// concerned only with lexical and syntactic aspects and does not necessarily exist in
/// external storage, and the pathname is not necessarily valid for the current operating system
@@ -136,29 +132,54 @@ namespace filesystem
class path
{
public:
+#if defined(NANA_WINDOWS)
+ using value_type = wchar_t;
+ const static value_type preferred_separator = '\\';
+#else
+ using value_type = char;
+ const static value_type preferred_separator = '/';
+#endif
+ using string_type = std::basic_string;
+
path();
- path(const nana::string&);
+
+ template
+ path(const Source& source)
+ {
+ _m_assign(source);
+ }
+
+ int compare(const path& other) const;
bool empty() const;
- path root() const;
+ path extension() const;
+
+ path parent_path() const;
file_type what() const;
- nana::string filename() const;
-#if defined(NANA_WINDOWS)
- public:
- nana::string to_string() const { return text_; }
- operator nana::string() const { return text_; }
+ path filename() const;
+
+ const value_type*c_str() const;
+ const string_type& native() const;
+ operator string_type() const;
+
+ std::string string() const;
+ std::wstring wstring() const;
+ std::string u8string() const;
private:
- nana::string text_;
-#else
- public:
- std::string to_string() const { return text_; }
- operator std::string() const { return text_; }
+ void _m_assign(const std::string& source_utf8);
+ void _m_assign(const std::wstring& source);
private:
- std::string text_;
-#endif
+ string_type pathstr_;
};
+ bool operator==(const path& lhs, const path& rhs);
+ bool operator!=(const path& lhs, const path& rhs);
+ bool operator<(const path& lhs, const path& rhs);
+ bool operator>(const path& lhs, const path& rhs);
+
+
+
struct directory_entry
{
using path_type = filesystem::path;
@@ -193,9 +214,7 @@ namespace filesystem
typedef std::input_iterator_tag iterator_category;
directory_iterator():end_(true), handle_(nullptr){}
-
- directory_iterator(const nana::string& file_path) { _m_prepare(file_path); }
- directory_iterator(const path& file_path) { _m_prepare(file_path.filename()); }
+ directory_iterator(const path& file_path) { _m_prepare(file_path); }
const value_type&
operator*() const { return value_; }
@@ -233,14 +252,14 @@ namespace filesystem
return (*p == 0);
}
- void _m_prepare(const nana::string& file_path)
+ void _m_prepare(const path& file_path)
{
+ auto path_ = file_path.native();
#if defined(NANA_WINDOWS)
- path_ = file_path;
- auto pat = file_path;
+ auto pat = path_;
DWORD attr = ::GetFileAttributes(pat.data());
if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
- pat += STR("\\*");
+ pat += L"\\*";
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_);
@@ -264,8 +283,7 @@ namespace filesystem
(FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY,
wfd_.nFileSizeLow);
- #elif defined(NANA_LINUX) || defined(NANA_MACOS)
- path_ = nana::charset(file_path);
+ #elif defined(NANA_POSIX)
if(path_.size() && (path_[path_.size() - 1] != '/'))
path_ += '/';
find_handle_t handle = opendir(path_.c_str());
@@ -293,7 +311,7 @@ namespace filesystem
is_directory = (0 != S_ISDIR(fst.st_mode));
size = fst.st_size;
}
- value_ = value_type(static_cast(nana::charset(dnt->d_name)), is_directory, size);
+ value_ = value_type(static_cast(nana::charset(dnt->d_name)), is_directory, size);
end_ = false;
}
}
@@ -340,7 +358,7 @@ namespace filesystem
}
}
- nana::string d_name = nana::charset(dnt->d_name);
+ std::wstring d_name = nana::charset(dnt->d_name, nana::unicode::utf8);
struct stat fst;
if(stat((path_ + "/" + dnt->d_name).c_str(), &fst) == 0)
value_ = value_type(std::move(d_name), (0 != S_ISDIR(fst.st_mode)), fst.st_size);
@@ -373,10 +391,9 @@ namespace filesystem
#if defined(NANA_WINDOWS)
WIN32_FIND_DATA wfd_;
- nana::string path_;
-#elif defined(NANA_LINUX) || defined(NANA_MACOS)
- std::string path_;
#endif
+ path::string_type path_;
+
std::shared_ptr find_ptr_;
find_handle_t handle_{nullptr};
value_type value_;
@@ -401,11 +418,10 @@ namespace filesystem
}
- // file_status status(const path& p);
- bool file_attrib(const nana::string& file, attribute&);
+ file_status status(const path& p);
inline bool is_directory(file_status s) { return s.type() == file_type::directory ;}
- inline bool is_directory(const path& p) { return directory_iterator(p)->attr.directory; }//works??
+ bool is_directory(const path& p);
inline bool is_directory(const directory_entry& d) { return d.attr.directory; }
//bool is_directory(const path& p, error_code& ec) noexcept;
@@ -419,46 +435,61 @@ namespace filesystem
}
//bool is_empty(const path& p, error_code& ec) noexcept;
- uintmax_t file_size(const nana::string& file); // deprecate?
- inline uintmax_t file_size(const path& p){return file_size(p.filename());}
- //uintmax_t file_size(const path& p, error_code& ec) noexcept;
- //long long filesize(const nana::string& file);
+ std::uintmax_t file_size(const path& p);
+ //uintmax_t file_size(const path& p, error_code& ec) noexcept;
- bool create_directories(const path& p);
- //bool create_directories(const path& p, error_code& ec) noexcept;
- bool create_directory(const path& p);
- //bool create_directory(const path& p, error_code& ec) noexcept;
- bool create_directory(const path& p, const path& attributes);
- //bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
- bool create_directory(const nana::string& dir, bool & if_exist);
- inline bool create_directory(const path& p, bool & if_exist)
- {
- return create_directory(p.filename(), if_exist);
- };
-
-
- bool modified_file_time(const nana::string& file, struct tm&);
-
-
- nana::string path_user();
+ bool create_directories(const path& p);
+ //bool create_directories(const path& p, error_code& ec) noexcept;
+ bool create_directory(const path& p);
+ //bool create_directory(const path& p, error_code& ec) noexcept;
+ bool create_directory(const path& p, const path& attributes);
+ //bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
-
- path current_path();
- //path current_path(error_code& ec);
- void current_path(const path& p);
- //void current_path(const path& p, error_code& ec) noexcept;
- //nana::string path_current();
+ bool modified_file_time(const std::wstring& file, struct tm&);
+ path path_user();
+
+ path current_path();
+ //path current_path(error_code& ec);
+ void current_path(const path& p);
+ //void current_path(const path& p, error_code& ec) noexcept;
- //bool remove(const path& p);
- //bool remove(const path& p, error_code& ec) noexcept;
- bool rmfile(const nana::char_t* file);
+ //bool remove(const path& p);
+ //bool remove(const path& p, error_code& ec) noexcept;
+ bool rmfile(const path& p);
- //uintmax_t remove_all(const path& p);
- //uintmax_t remove_all(const path& p, error_code& ec) noexcept;
- bool rmdir(const nana::char_t* dir, bool fails_if_not_empty);
- nana::string root(const nana::string& path);
+ //uintmax_t remove_all(const path& p);
+ //uintmax_t remove_all(const path& p, error_code& ec) noexcept;
+
+ bool rmdir(const path& p, bool fails_if_not_empty);
+
+ template
+ std::basic_string parent_path(const std::basic_string& path)
+ {
+ auto index = path.size();
+
+ if (index)
+ {
+ auto str = path.c_str();
+
+ for (--index; index > 0; --index)
+ {
+ auto c = str[index];
+ if (c != '\\' && c != '/')
+ break;
+ }
+
+ for (--index; index > 0; --index)
+ {
+ auto c = str[index];
+ if (c == '\\' || c == '/')
+ break;
+ }
+ }
+
+ return index ? path.substr(0, index + 1) : std::basic_string();
+ }
}//end namespace filesystem
diff --git a/include/nana/filesystem/fs_utility.hpp b/include/nana/filesystem/fs_utility.hpp
index d52e54dd..7ddd4298 100644
--- a/include/nana/filesystem/fs_utility.hpp
+++ b/include/nana/filesystem/fs_utility.hpp
@@ -24,41 +24,13 @@ namespace filesystem
tm modified;
};
- bool file_attrib(const nana::string& file, attribute&);
- long long filesize(const nana::string& file);
+ bool modified_file_time(const ::std::string& file, struct tm&);
- bool mkdir(const nana::string& dir, bool & if_exist);
- bool modified_file_time(const nana::string& file, struct tm&);
+ std::wstring path_user();
- nana::string path_user();
- nana::string path_current();
+ bool rmfile(const char* file_utf8);
+ bool rmdir(const char* dir, bool fails_if_not_empty);
- bool rmfile(const nana::char_t* file);
- bool rmdir(const nana::char_t* dir, bool fails_if_not_empty);
- nana::string root(const nana::string& path);
-
- class path
- {
- public:
- struct type
- { enum{not_exist, file, directory};
- };
-
- path();
- path(const nana::string&);
-
- bool empty() const;
- path root() const;
- int what() const;
-
- nana::string name() const;
- private:
-#if defined(NANA_WINDOWS)
- nana::string text_;
-#else
- std::string text_;
-#endif
- };
}//end namespace filesystem
}//end namespace nana
diff --git a/include/nana/fwd.hpp b/include/nana/fwd.hpp
index 62d824cb..c3795e3a 100644
--- a/include/nana/fwd.hpp
+++ b/include/nana/fwd.hpp
@@ -1,7 +1,7 @@
/*
* Forward Declarations
* Nana C++ Library(http://www.nanapro.org)
- * Copyright(C) 2003-2014 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
diff --git a/include/nana/gui/detail/basic_window.hpp b/include/nana/gui/detail/basic_window.hpp
index ac5db7c1..207f7e3b 100644
--- a/include/nana/gui/detail/basic_window.hpp
+++ b/include/nana/gui/detail/basic_window.hpp
@@ -145,7 +145,7 @@ namespace detail
basic_window *parent;
basic_window *owner;
- ::nana::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
diff --git a/include/nana/gui/detail/general_events.hpp b/include/nana/gui/detail/general_events.hpp
index a6f17bc6..8437f84d 100644
--- a/include/nana/gui/detail/general_events.hpp
+++ b/include/nana/gui/detail/general_events.hpp
@@ -460,7 +460,7 @@ namespace nana
{
::nana::window window_handle; ///< A handle to the event window
::nana::point pos; ///< cursor position in the event window
- std::vector files; ///< external filenames
+ std::vector files; ///< external filenames
};
struct arg_expose : public event_arg
@@ -480,7 +480,7 @@ namespace nana
{
event_code evt_code; ///< it is event_code::key_press in current event
::nana::window window_handle; ///< A handle to the event window
- mutable nana::char_t key; ///< the key corresponding to the key pressed
+ mutable wchar_t key; ///< the key corresponding to the key pressed
mutable bool ignore; ///< this member is not used
bool ctrl; ///< keyboard Ctrl is pressed?
bool shift; ///< keyboard Shift is pressed
diff --git a/include/nana/gui/detail/native_window_interface.hpp b/include/nana/gui/detail/native_window_interface.hpp
index 6a88c0a7..aade67a5 100644
--- a/include/nana/gui/detail/native_window_interface.hpp
+++ b/include/nana/gui/detail/native_window_interface.hpp
@@ -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 nana::string&);
- static nana::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);
diff --git a/include/nana/gui/detail/widget_notifier_interface.hpp b/include/nana/gui/detail/widget_notifier_interface.hpp
index 204bdeea..81a0a28f 100644
--- a/include/nana/gui/detail/widget_notifier_interface.hpp
+++ b/include/nana/gui/detail/widget_notifier_interface.hpp
@@ -30,8 +30,8 @@ namespace nana
virtual widget* widget_ptr() const = 0;
virtual void destroy() = 0;
- virtual std::wstring caption() = 0;
- virtual void caption(std::wstring) = 0;
+ virtual ::nana::detail::native_string_type caption() = 0;
+ virtual void caption(::nana::detail::native_string_type) = 0;
};
}
}
diff --git a/include/nana/gui/dragger.hpp b/include/nana/gui/dragger.hpp
index 9846b672..e34094ef 100644
--- a/include/nana/gui/dragger.hpp
+++ b/include/nana/gui/dragger.hpp
@@ -1,6 +1,20 @@
+/*
+* A Dragger Implementation
+* Nana C++ Library(http://www.nanapro.org)
+* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
+*
+* Distributed under the Boost Software License, Version 1.0.
+* (See accompanying file LICENSE_1_0.txt or copy at
+* http://www.boost.org/LICENSE_1_0.txt)
+*
+* @file: nana/gui/dragger.hpp
+*/
+
#ifndef NANA_GUI_DRAGGER_HPP
#define NANA_GUI_DRAGGER_HPP
-#include "programming_interface.hpp"
+#include "basis.hpp"
+#include "../basic_types.hpp"
+#include "../traits.hpp"
namespace nana
{
@@ -18,6 +32,10 @@ namespace nana
public:
dragger();
~dragger();
+
+ dragger(dragger&&);
+ dragger& operator=(dragger&&);
+
void target(window);
void target(window, const rectangle& restrict_area, nana::arrange);
void remove_target(window);
diff --git a/include/nana/gui/filebox.hpp b/include/nana/gui/filebox.hpp
index d60ec5c2..7d8b1b85 100644
--- a/include/nana/gui/filebox.hpp
+++ b/include/nana/gui/filebox.hpp
@@ -25,7 +25,7 @@ namespace nana
filebox(filebox&&) = delete;
filebox& operator=(filebox&&) = delete;
public:
- using filters = std::vector>;
+ using filters = std::vector>;
filebox(bool is_open_mode);
filebox(window owner, bool is_open_mode);
@@ -37,21 +37,21 @@ namespace nana
/// Change owner window
void owner(window);
- /** @brief specify a title for the dialog
- * @param string a text for title
- */
- nana::string title( nana::string new_title); ///< . Set a new title for the dialog and \return the old title
+ /// specify a title for the dialog
+ /// @param string a text for title
+ /// @return old title.
+ ::std::string title( ::std::string new_title); ///< . Set a new title for the dialog and \return the old title
/** @brief specify a suggestion directory
* @param string a path of initial directory
* @note the behavior of init_path is different between Win7 and Win2K/XP/Vista, but its behavior under Linux is conformed with Win7.
*/
- filebox& init_path(const nana::string&); ///< Suggested init path used to locate a directory when the filebox starts.
- filebox& init_file(const nana::string&); ///< Init file, if it contains a path, the init path is replaced by the path of init file.
+ filebox& init_path(const ::std::string&); ///< Suggested init path used to locate a directory when the filebox starts.
+ filebox& init_file(const ::std::string&); ///< Init file, if it contains a path, the init path is replaced by the path of init file.
/// \brief Add a filetype filter.
/// To specify multiple filter in a single description, use a semicolon to separate the patterns(for example,"*.TXT;*.DOC;*.BAK").
- filebox& add_filter(const nana::string& description, ///< for example. "Text File"
- const nana::string& filetype ///< filter pattern(for example, "*.TXT")
+ filebox& add_filter(const ::std::string& description, ///< for example. "Text File"
+ const ::std::string& filetype ///< filter pattern(for example, "*.TXT")
);
filebox& add_filter(const filters &ftres)
@@ -62,16 +62,14 @@ namespace nana
};
- nana::string path() const;
- nana::string file() const;
+ ::std::string path() const;
+ ::std::string file() const;
- /** @brief Display the filebox dialog
- */
+ /// Display the filebox dialog
bool show() const;
- /** @brief Display the filebox dialog
- * @note A function object method alternative to show()
- */
+ /// Display the filebox dialog
+ /// A function object method alternative to show()
bool operator()() const
{
return show();
diff --git a/include/nana/gui/msgbox.hpp b/include/nana/gui/msgbox.hpp
index 3bebcf79..af5a1437 100644
--- a/include/nana/gui/msgbox.hpp
+++ b/include/nana/gui/msgbox.hpp
@@ -43,10 +43,10 @@ namespace nana
msgbox& operator=(const msgbox&);
/// Construct that creates a message box with a specified title and default button.
- msgbox(const nana::string&);
+ msgbox(const ::std::string&);
/// Construct that creates a message box with an owner windoow, a specified title and buttons.
- msgbox(window, const nana::string&, button_t = ok);
+ msgbox(window, const ::std::string&, button_t = ok);
/// Sets an icon for informing user.
msgbox& icon(icon_t);
@@ -55,10 +55,10 @@ namespace nana
void clear();
/// Writes a string to the buffer.
- msgbox & operator<<(const nana::string&);
+ msgbox & operator<<(const std::wstring&);
/// Writes a string to the buffer.
- msgbox & operator<<(const nana::char_t*);
+ msgbox & operator<<(const wchar_t*);
/// Writes a string to the buffer.
msgbox & operator<<(const nana::charset&);
@@ -86,7 +86,7 @@ namespace nana
private:
std::stringstream sstream_;
window wd_;
- nana::string title_;
+ std::string title_;
button_t button_;
icon_t icon_;
};
@@ -97,7 +97,7 @@ namespace nana
{
virtual ~abstract_content() = default;
- virtual const ::nana::string& label() const = 0;
+ virtual const ::std::string& label() const = 0;
virtual window create(window, unsigned label_px) = 0;
virtual unsigned fixed_pixels() const;
};
@@ -107,13 +107,13 @@ namespace nana
{
struct implement;
public:
- integer(::nana::string label, int init_value, int begin, int last, int step);
+ integer(::std::string label, int init_value, int begin, int last, int step);
~integer();
int value() const;
private:
//Implementation of abstract_content
- const ::nana::string& label() const override;
+ const ::std::string& label() const override;
window create(window, unsigned label_px) override;
private:
std::unique_ptr impl_;
@@ -124,13 +124,13 @@ namespace nana
{
struct implement;
public:
- real(::nana::string label, double init_value, double begin, double last, double step);
+ real(::std::string label, double init_value, double begin, double last, double step);
~real();
double value() const;
private:
//Implementation of abstract_content
- const ::nana::string& label() const override;
+ const ::std::string& label() const override;
window create(window, unsigned label_px) override;
private:
std::unique_ptr impl_;
@@ -144,8 +144,8 @@ namespace nana
text(const text&) = delete;
text& operator=(const text&) = delete;
public:
- text(::nana::string label, ::nana::string init_text = ::nana::string());
- text(::nana::string label, std::vector<::nana::string>);
+ text(::std::string label, ::std::string init_text = ::std::string());
+ text(::std::string label, std::vector<::std::string>);
~text();
@@ -154,10 +154,10 @@ namespace nana
void mask_character(wchar_t ch);
- ::nana::string value() const;
+ ::std::string value() const;
private:
//Implementation of abstract_content
- const ::nana::string& label() const override;
+ const ::std::string& label() const override;
window create(window, unsigned label_px) override;
private:
std::unique_ptr impl_;
@@ -168,17 +168,17 @@ namespace nana
{
struct implement;
public:
- date(::nana::string label);
+ date(::std::string label);
~date();
- ::nana::string value() const;
+ ::std::string value() const;
int year() const;
int month() const; //[1, 12]
int day() const; //[1, 31]
private:
//Implementation of abstract_content
- const ::nana::string& label() const override;
+ const ::std::string& label() const override;
window create(window, unsigned label_px) override;
unsigned fixed_pixels() const override;
private:
@@ -190,19 +190,19 @@ namespace nana
{
struct implement;
public:
- path(::nana::string label, const ::nana::filebox&);
+ path(::std::string label, const ::nana::filebox&);
~path();
- ::nana::string value() const;
+ ::std::string value() const;
private:
//Implementation of abstract_content
- const ::nana::string& label() const override;
+ const ::std::string& label() const override;
window create(window, unsigned label_px) override;
private:
std::unique_ptr impl_;
};
- inputbox(window, ::nana::string description, ::nana::string title = ::nana::string());
+ inputbox(window, ::std::string description, ::std::string title = ::std::string());
void image(::nana::paint::image, bool is_left, const rectangle& valid_area = {});
void image_v(::nana::paint::image, bool is_top, const rectangle& valid_area = {});
@@ -246,8 +246,8 @@ namespace nana
bool _m_open(std::vector&, bool modal);
private:
window owner_;
- ::nana::string description_;
- ::nana::string title_;
+ ::std::string description_;
+ ::std::string title_;
std::function verifier_;
::nana::paint::image images_[4];
::nana::rectangle valid_areas_[4];
diff --git a/include/nana/gui/notifier.hpp b/include/nana/gui/notifier.hpp
index c6eea9da..a557fd45 100644
--- a/include/nana/gui/notifier.hpp
+++ b/include/nana/gui/notifier.hpp
@@ -55,9 +55,9 @@ namespace nana
notifier(window);
~notifier();
void close();
- void text(const nana::string&);
- void icon(const nana::string& icon_file);
- void insert_icon(const nana::string& icon_file);
+ void text(const ::std::string&);
+ void icon(const ::std::string& icon_file);
+ void insert_icon(const ::std::string& icon_file);
void period(unsigned millisecond);
detail::notifier_events& events();
window handle() const;
diff --git a/include/nana/gui/place.hpp b/include/nana/gui/place.hpp
index 2e3676de..8f32545b 100644
--- a/include/nana/gui/place.hpp
+++ b/include/nana/gui/place.hpp
@@ -42,13 +42,17 @@ namespace nana
: init_(std::move(initializer))
{}
- agent(const nana::char_t* text)
+ agent(const char* text)
: text_(text)
- {}
+ {
+ throw_not_utf8(text);
+ }
- agent(nana::string text, std::function initializer = {})
+ agent(std::string text, std::function initializer = {})
: text_(std::move(text)), init_(std::move(initializer))
- {}
+ {
+ throw_not_utf8(text_);
+ }
private:
std::unique_ptr create(nana::window handle) const override
@@ -60,7 +64,7 @@ namespace nana
return std::move(ptr);
}
private:
- nana::string text_;
+ std::string text_;
std::function init_;
};
@@ -79,8 +83,8 @@ namespace nana
public:
field_interface() = default;
virtual ~field_interface() = default;
- virtual field_interface& operator<<(const nana::char_t* label) = 0;
- virtual field_interface& operator<<(nana::string label) = 0;
+ virtual field_interface& operator<<(const char* label) = 0;
+ virtual field_interface& operator<<(std::string label) = 0;
virtual field_interface& operator<<(window) = 0;
virtual field_interface& fasten(window) = 0;
diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp
index 6227f6bb..1faba2a9 100644
--- a/include/nana/gui/programming_interface.hpp
+++ b/include/nana/gui/programming_interface.hpp
@@ -72,8 +72,8 @@ namespace API
widget_colors* get_scheme(window);
void attach_drawer(widget&, drawer_trigger&);
- nana::string window_caption(window) throw();
- void window_caption(window, nana::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);
@@ -83,6 +83,9 @@ namespace API
paint::graphics* window_graphics(window);
void delay_restore(bool);
+
+ void register_menu_window(window, bool has_keyboard);
+ void set_menubar(window wd, bool attach);
}//end namespace dev
@@ -140,7 +143,7 @@ namespace API
void exit();
- nana::string transform_shortkey_text(nana::string text, nana::string::value_type &shortkey, nana::string::size_type *skpos);
+ std::string transform_shortkey_text(std::string text, wchar_t &shortkey, std::string::size_type *skpos);
bool register_shortkey(window, unsigned long);
void unregister_shortkey(window);
@@ -271,8 +274,8 @@ 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);
- nana::string window_caption(window);
+ void window_caption(window, const std::wstring& title);
+ ::std::string window_caption(window);
void window_cursor(window, cursor);
cursor window_cursor(window);
@@ -310,8 +313,8 @@ namespace API
void eat_tabstop(window, bool);
window move_tabstop(window, bool next); ///< Sets the focus to the window which tabstop is near to the specified window.
- bool glass_window(window); /// \deprecated
- bool glass_window(window, bool); /// \deprecated
+ //bool glass_window(window); //deprecated
+ //bool glass_window(window, bool); //deprecated
/// Sets the window active state. If a window active state is false, the window will not obtain the focus when a mouse clicks on it wich will be obteined by take_if_has_active_false.
void take_active(window, bool has_active, window take_if_has_active_false);
@@ -328,10 +331,6 @@ namespace API
window find_window(const nana::point& mspos);
- void register_menu_window(window, bool has_keyboard);
- bool attach_menubar(window menubar);
- void detach_menubar(window menubar);
-
bool is_window_zoomed(window, bool ask_for_max); ///
void create_event_agent(::nana::categorize& wdg)
@@ -155,8 +155,9 @@ namespace nana
: public widget_object>
{
public:
- typedef T value_type; ///< The type of objects stored
- typedef drawerbase::categorize::renderer renderer; ///< The interface for user-defined renderer.
+ using native_string_type = widget::native_string_type;
+ using value_type = T; ///< The type of objects stored
+ using renderer = drawerbase::categorize::renderer; ///< The interface for user-defined renderer.
categorize()
{
@@ -174,13 +175,25 @@ namespace nana
{
}
- categorize(window wd, const nana::string& text, bool visible = true)
+ categorize(window wd, const std::string& text_utf8, bool visible = true)
+ : categorize(wd, ::nana::rectangle(), visible)
+ {
+ this->caption(text_utf8);
+ }
+
+ categorize(window wd, const char* text_utf8, bool visible = true)
+ : categorize(wd, ::nana::rectangle(), visible)
+ {
+ this->caption(text_utf8);
+ }
+
+ categorize(window wd, const std::wstring& text, bool visible = true)
: categorize(wd, ::nana::rectangle(), visible)
{
this->caption(text);
}
- categorize(window wd, const nana::char_t* text, bool visible = true)
+ categorize(window wd, const wchar_t* text, bool visible = true)
: categorize(wd, ::nana::rectangle(), visible)
{
this->caption(text);
@@ -189,7 +202,7 @@ namespace nana
/// Insert a new category with a specified name and the object of value type.
/// The new category would be inserted as a child in current category,
/// and after inserting, the new category is replaced of the current category as a new current one.
- categorize& insert(const nana::string& name, const value_type& value)
+ categorize& insert(const std::string& name, const value_type& value)
{
this->get_drawer_trigger().insert(name, value);
API::update_window(*this);
@@ -197,15 +210,16 @@ namespace nana
}
/// Inserts a child category into current category.
- categorize& childset(const nana::string& name, const value_type& value)
+ categorize& childset(const std::string& name, const value_type& value)
{
+ throw_not_utf8(name);
if(this->get_drawer_trigger().childset(name, value))
API::update_window(*this);
return *this;
}
/// Erases a child category with a specified name from current category.
- categorize& childset_erase(const nana::string& name)
+ categorize& childset_erase(const std::string& name)
{
if(this->get_drawer_trigger().childset_erase(name))
API::update_window(*this);
@@ -219,13 +233,13 @@ namespace nana
}
/// Sets the splitter string
- categorize& splitstr(const nana::string& sstr)
+ categorize& splitstr(const std::string& sstr)
{
this->get_drawer_trigger().splitstr(sstr);
return *this;
}
- nana::string splitstr() const
+ std::string splitstr() const
{
return this->get_drawer_trigger().splitstr();
}
@@ -237,10 +251,10 @@ namespace nana
}
private:
//Overrides widget's virtual functions
- void _m_caption(nana::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_nstring(this->get_drawer_trigger().path()) );
}
};
}//end namespace nana
diff --git a/include/nana/gui/widgets/checkbox.hpp b/include/nana/gui/widgets/checkbox.hpp
index 7af58e72..16af0d5e 100644
--- a/include/nana/gui/widgets/checkbox.hpp
+++ b/include/nana/gui/widgets/checkbox.hpp
@@ -56,8 +56,8 @@ namespace drawerbase
public:
checkbox();
checkbox(window, bool visible);
- checkbox(window, const nana::string& text, bool visible = true);
- checkbox(window, const nana::char_t* text, bool visible = true);
+ checkbox(window, const std::string& text, bool visible = true);
+ checkbox(window, const char* text, bool visible = true);
checkbox(window, const rectangle& = rectangle(), bool visible = true);
void element_set(const char* name);
diff --git a/include/nana/gui/widgets/combox.hpp b/include/nana/gui/widgets/combox.hpp
index b7e9286e..f31b3a18 100644
--- a/include/nana/gui/widgets/combox.hpp
+++ b/include/nana/gui/widgets/combox.hpp
@@ -75,8 +75,8 @@ namespace nana
{
public:
item_proxy(drawer_impl*, std::size_t pos);
- item_proxy& text(const nana::string&);
- nana::string text() const;
+ item_proxy& text(const ::std::string&);
+ ::std::string text() const;
item_proxy& select();
bool selected() const;
item_proxy& icon(const nana::paint::image&);
@@ -112,14 +112,13 @@ namespace nana
template
item_proxy& value(T&& t)
{
- *_m_anyobj(true) = std::move(t);
+ *_m_anyobj(true) = ::std::move(t);
return *this;
}
public:
/// Behavior of Iterator's value_type
- bool operator==(const nana::string&) const;
+ bool operator==(const ::std::string&) const;
bool operator==(const char*) const;
- bool operator==(const wchar_t*) const;
/// Behavior of Iterator
item_proxy & operator=(const item_proxy&);
@@ -166,19 +165,19 @@ namespace nana
combox();
combox(window, bool visible);
- combox(window, nana::string, bool visible = true);
- combox(window, const nana::char_t*, bool visible = true);
+ combox(window, ::std::string, bool visible = true);
+ combox(window, const char*, bool visible = true);
combox(window, const rectangle& r = rectangle(), bool visible = true);
void clear();
void editable(bool);
bool editable() const;
- void set_accept(std::function);
- combox& push_back(nana::string);
+ void set_accept(std::function);
+ combox& push_back(std::string);
std::size_t the_number_of_options() const;
std::size_t option() const; ///< Index of the last selected, from drop-down list, item.
void option(std::size_t); ///< Select the text specified by index
- nana::string text(std::size_t) const;
+ ::std::string text(std::size_t) const;
void erase(std::size_t pos);
template
@@ -224,8 +223,8 @@ namespace nana
const drawerbase::combox::drawer_impl& _m_impl() const;
private:
//Overrides widget's virtual functions
- nana::string _m_caption() const throw() override;
- void _m_caption(nana::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;
};
}
diff --git a/include/nana/gui/widgets/date_chooser.hpp b/include/nana/gui/widgets/date_chooser.hpp
index 9a168bfb..a4e685e1 100644
--- a/include/nana/gui/widgets/date_chooser.hpp
+++ b/include/nana/gui/widgets/date_chooser.hpp
@@ -42,12 +42,12 @@ namespace nana
trigger();
bool chose() const;
nana::date read() const;
- void week_name(unsigned index, const nana::string&);
+ void week_name(unsigned index, const std::string&);
private:
where _m_pos_where(graph_reference, const ::nana::point& pos);
void _m_draw_topbar(graph_reference);
void _m_make_drawing_basis(drawing_basis&, graph_reference, const nana::point& refpos);
- void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, const nana::string&, bool primary, bool sel);
+ void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, const ::std::string&, bool primary, bool sel);
void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, int number, bool primary, bool sel);
void _m_draw_ex_days(drawing_basis &, graph_reference, int begx, int begy, bool before);
void _m_draw_days(const nana::point& refpos, graph_reference);
@@ -61,7 +61,7 @@ namespace nana
void mouse_leave(graph_reference, const arg_mouse&) override;
void mouse_up(graph_reference, const arg_mouse&) override;
private:
- nana::string weekstr_[7];
+ ::std::string weekstr_[7];
widget * widget_;
@@ -105,13 +105,13 @@ namespace nana
public:
date_chooser();
date_chooser(window, bool visible);
- date_chooser(window, const nana::string& text, bool visible = true);
- date_chooser(window, const nana::char_t* text, bool visible = true);
+ date_chooser(window, const ::std::string& text, bool visible = true);
+ date_chooser(window, const char* text, bool visible = true);
date_chooser(window, const nana::rectangle& r = rectangle(), bool visible = true);
bool chose() const;
nana::date read() const;
- void weekstr(unsigned index, const nana::string&);///
struct tree_node
{
- typedef std::pair value_type;
+ typedef std::pair value_type;
value_type value;
@@ -108,7 +108,7 @@ namespace detail
return (verify(node) && (node->owner != &root_) ? node->owner : nullptr);
}
- node_type * node(node_type* node, const nana::string& key)
+ node_type * node(node_type* node, const std::string& key)
{
if(node)
{
@@ -121,7 +121,7 @@ namespace detail
return nullptr;
}
- node_type* insert(node_type* node, const nana::string& key, const element_type& elem)
+ node_type* insert(node_type* node, const std::string& key, const element_type& elem)
{
if(nullptr == node)
return insert(key, elem);
@@ -159,7 +159,7 @@ namespace detail
return nullptr;
}
- node_type* insert(const nana::string& key, const element_type& elem)
+ node_type* insert(const std::string& key, const element_type& elem)
{
auto node = _m_locate(key);
if(node)
@@ -173,12 +173,12 @@ namespace detail
delete node;
}
- node_type* find(const nana::string& path) const
+ node_type* find(const std::string& path) const
{
return _m_locate(path);
}
- node_type* ref(const nana::string& path)
+ node_type* ref(const std::string& path)
{
return _m_locate(path);
}
@@ -303,7 +303,7 @@ namespace detail
}
template
- unsigned child_size_if(const nana::string& key, PredAllowChild pac) const
+ unsigned child_size_if(const ::std::string& key, PredAllowChild pac) const
{
auto node = _m_locate(key);
return (node ? child_size_if(*node, pac) : 0);
@@ -392,7 +392,7 @@ namespace detail
:node(&(self.root_))
{}
- bool operator()(const nana::string& key_node)
+ bool operator()(const ::std::string& key_node)
{
node_type *child = node->child;
node_type *tail = nullptr;
@@ -428,7 +428,7 @@ namespace detail
:node(&self.root_)
{}
- bool operator()(const nana::string& key_node)
+ bool operator()(const ::std::string& key_node)
{
return ((node = _m_find(node->child, key_node)) != nullptr);
}
@@ -436,7 +436,7 @@ namespace detail
node_type *node;
};
private:
- static node_type* _m_find(node_type* node, const nana::string& key_node)
+ static node_type* _m_find(node_type* node, const ::std::string& key_node)
{
while(node)
{
@@ -449,14 +449,14 @@ namespace detail
}
template
- void _m_for_each(const nana::string& key, Function function) const
+ void _m_for_each(const ::std::string& key, Function function) const
{
if(key.size())
{
- nana::string::size_type beg = 0;
- auto end = key.find_first_of(STR("\\/"));
+ ::std::string::size_type beg = 0;
+ auto end = key.find_first_of("\\/");
- while(end != nana::string::npos)
+ while(end != ::std::string::npos)
{
if(beg != end)
{
@@ -464,11 +464,11 @@ namespace detail
return;
}
- auto next = key.find_first_not_of(STR("\\/"), end);
- if(next != nana::string::npos)
+ auto next = key.find_first_not_of("\\/", end);
+ if(next != ::std::string::npos)
{
beg = next;
- end = key.find_first_of(STR("\\/"), beg);
+ end = key.find_first_of("\\/", beg);
}
else
return;
@@ -479,7 +479,7 @@ namespace detail
}
template
- node_type* _m_locate(const nana::string& key)
+ node_type* _m_locate(const ::std::string& key)
{
if(key.size())
{
@@ -499,7 +499,7 @@ namespace detail
return &root_;
}
- node_type* _m_locate(const nana::string& key) const
+ node_type* _m_locate(const std::string& key) const
{
if(key.size())
{
diff --git a/include/nana/gui/widgets/float_listbox.hpp b/include/nana/gui/widgets/float_listbox.hpp
index f28840ea..79a66e2f 100644
--- a/include/nana/gui/widgets/float_listbox.hpp
+++ b/include/nana/gui/widgets/float_listbox.hpp
@@ -28,7 +28,7 @@ namespace nana
virtual ~item_interface(){}
virtual const nana::paint::image & image() const = 0;
- virtual const nana::char_t* text() const = 0;
+ virtual const char* text() const = 0;
};
//struct module_def
diff --git a/include/nana/gui/widgets/group.hpp b/include/nana/gui/widgets/group.hpp
index 82f34a5b..79162f06 100644
--- a/include/nana/gui/widgets/group.hpp
+++ b/include/nana/gui/widgets/group.hpp
@@ -37,7 +37,7 @@ namespace nana{
/// The construction that creates the widget and set the titel or caption
group(window parent, ///< a handle to the parent
- ::nana::string titel, ///< caption of the group
+ ::std::string titel, ///< caption of the group
bool formatted = false, ///< Enable/disable the formatted text for the title
unsigned gap = 2, ///< betwen the content and the external limit
const rectangle& r = {} ,
@@ -49,7 +49,7 @@ namespace nana{
~group();
/// Adds an option for user selection
- group& add_option(::nana::string);
+ group& add_option(::std::string);
/// Enables/disables the radio mode which is single selection
group& radio_mode(bool);
@@ -77,8 +77,8 @@ namespace nana{
void _m_add_child(const char* field, widget*);
void _m_init();
void _m_complete_creation() override;
- ::nana::string _m_caption() const throw() override;
- void _m_caption(::nana::string&&) override;
+ native_string_type _m_caption() const throw() override;
+ void _m_caption(native_string_type&&) override;
private:
std::unique_ptr impl_;
};
diff --git a/include/nana/gui/widgets/label.hpp b/include/nana/gui/widgets/label.hpp
index aa28effc..fef3b661 100644
--- a/include/nana/gui/widgets/label.hpp
+++ b/include/nana/gui/widgets/label.hpp
@@ -57,13 +57,13 @@ namespace nana
typedef drawerbase::label::command command;
label();
label(window, bool visible);
- label(window, const nana::string& text, bool visible = true);
- label(window parent, const nana::char_t* text, bool visible = true) :label(parent, nana::string(text),visible) {};
+ label(window, const std::string& text, bool visible = true);
+ label(window parent, const char* text, bool visible = true) :label(parent, std::string(text),visible) {};
label(window, const rectangle& = {}, bool visible = true);
label& transparent(bool); ///< Switchs the label widget to the transparent background mode.
bool transparent() const throw();
label& format(bool); ///< Switches the format mode of the widget.
- label& add_format_listener(std::function);
+ label& add_format_listener(std::function);
label& click_for(window associated_window) throw(); // as same as the "for" attribute of a label
@@ -71,12 +71,12 @@ namespace nana
/// "corrected" size that changes lines to fit the text into the specified width
nana::size measure(unsigned allowed_width_in_pixel) const;
- static ::nana::size measure(::nana::paint::graphics&, const ::nana::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
+ static ::nana::size measure(::nana::paint::graphics&, const ::std::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
label& text_align(align horizontal_align, align_v vertical_align= align_v::top);
private:
//Overrides widget's virtual function
- void _m_caption(nana::string&&) override;
+ void _m_caption(native_string_type&&) override;
};
}//end namespace nana
#endif
diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp
index 59324ef2..4aa7cfb7 100644
--- a/include/nana/gui/widgets/listbox.hpp
+++ b/include/nana/gui/widgets/listbox.hpp
@@ -31,6 +31,7 @@ namespace nana
namespace listbox
{
using size_type = std::size_t;
+ using native_string_type = ::nana::detail::native_string_type;
/// usefull for both absolute and display (sorted) positions
struct index_pair
@@ -81,7 +82,7 @@ namespace nana
using selection = std::vector;
- using inline_notifier_interface = detail::inline_widget_notifier_interface;
+ using inline_notifier_interface = detail::inline_widget_notifier_interface;
struct cell
{
@@ -94,17 +95,17 @@ namespace nana
format(const ::nana::color& bgcolor, const ::nana::color& fgcolor);
};
- using format_ptr = std::unique_ptr < format > ;
+ using format_ptr = ::std::unique_ptr;
- ::nana::string text;
- format_ptr custom_format;
+ ::std::string text;
+ format_ptr custom_format;
cell() = default;
cell(const cell&);
cell(cell&&);
- cell(nana::string);
- cell(nana::string, const format&);
- cell(nana::string, const ::nana::color& bgcolor, const ::nana::color& fgcolor);
+ cell(::std::string);
+ cell(::std::string, const format&);
+ cell(::std::string, const ::nana::color& bgcolor, const ::nana::color& fgcolor);
cell& operator=(const cell&);
cell& operator=(cell&&);
@@ -126,9 +127,9 @@ namespace nana
oresolver& operator<<(double);
oresolver& operator<<(long double);
- oresolver& operator<<(const char*);
+ oresolver& operator<<(const char* text_utf8);
oresolver& operator<<(const wchar_t*);
- oresolver& operator<<(const std::string&);
+ oresolver& operator<<(const std::string& text_utf8);
oresolver& operator<<(const std::wstring&);
oresolver& operator<<(std::wstring&&);
oresolver& operator<<(cell);
@@ -157,7 +158,7 @@ namespace nana
iresolver& operator>>(double&);
iresolver& operator>>(long double&);
- iresolver& operator>>(std::string&);
+ iresolver& operator>>(std::string& utf8_cast);
iresolver& operator>>(std::wstring&);
iresolver& operator>>(cell&);
iresolver& operator>>(std::nullptr_t);
@@ -241,8 +242,9 @@ namespace nana
size_type columns() const;
item_proxy& text(size_type col, cell);
- item_proxy& text(size_type col, nana::string);
- nana::string text(size_type col) const;
+ item_proxy& text(size_type col, std::string);
+ item_proxy& text(size_type col, std::wstring);
+ std::string text(size_type col) const;
void icon(const nana::paint::image&);
@@ -257,7 +259,7 @@ namespace nana
for (auto pos = 0u; pos < cols; ++pos)
{
auto & el = cells[pos];
- if (el.text.size() == 1 && el.text[0] == nana::char_t(0))
+ if (el.text.size() == 1 && el.text[0] == '\0')
continue;
text(pos, std::move(el));
}
@@ -300,9 +302,10 @@ namespace nana
}
/// Behavior of Iterator's value_type
- bool operator==(const nana::string& s) const;
bool operator==(const char * s) const;
bool operator==(const wchar_t * s) const;
+ bool operator==(const ::std::string& s) const;
+ bool operator==(const ::std::wstring& s) const;
/// Behavior of Iterator
item_proxy & operator=(const item_proxy&);
@@ -375,18 +378,20 @@ namespace nana
}
/// Appends one item at the end of this category with the specifies text in the column fields
- void append(std::initializer_list);
+ void append(std::initializer_list texts_utf8);
+ void append(std::initializer_list texts);
size_type columns() const;
- cat_proxy& text(nana::string);
- nana::string text() const;
+ cat_proxy& text(std::string);
+ cat_proxy& text(std::wstring);
+ std::string text() const;
cat_proxy & select(bool);
bool selected() const;
/// Behavior of a container
- void push_back(nana::string);
+ void push_back(std::string text_utf8);
item_proxy begin() const;
item_proxy end() const;
@@ -449,8 +454,8 @@ namespace nana
struct export_options
{
- nana::string sep = nana::string {STR("\t" )},
- endl= nana::string {STR("\n")};
+ std::string sep = ::std::string {"\t"},
+ endl= ::std::string {"\n"};
bool only_selected_items{true},
only_checked_items {false},
only_visible_columns{true};
@@ -510,16 +515,16 @@ By \a clicking on one header the list get \a reordered, first up, and then down
and
antisymmetry(comp(a, b) != comp(b, a) returns true)
A simple example.
- bool sort_compare( const nana::string& s1, nana::any*,
- const nana::string& s2, nana::any*, bool reverse)
+ bool sort_compare( const std::string& s1, nana::any*,
+ const std::string& s2, nana::any*, bool reverse)
{
return (reverse ? s1 > s2 : s1 < s2);
}
listbox.set_sort_compare(0, sort_compare);
The listbox supports attaching a customer's object for each item, therefore the items can be
sorted by comparing these customer's object.
- bool sort_compare( const nana::string&, nana::any* o1,
- const nana::string&, nana::any* o2, bool reverse)
+ bool sort_compare( const std::string&, nana::any* o1,
+ const std::string&, nana::any* o2, bool reverse)
{
if(o1 && o2) //some items may not attach a customer object.
{
@@ -565,15 +570,20 @@ By \a clicking on one header the list get \a reordered, first up, and then down
void scroll(bool to_bottom, const index_pair& pos);
/// Appends a new column with a header text and the specified width at the end, and return it position
- size_type append_header(nana::string header_text, unsigned width = 120);
+ size_type append_header(std::string text_utf8, unsigned width = 120);
+ size_type append_header(std::wstring text, unsigned width = 120);
listbox& header_width(size_type position, unsigned pixels);
unsigned header_width(size_type position) const;
unsigned auto_width(size_type position, unsigned max=3000);
- cat_proxy append(nana::string); ///< Appends a new category at the end
- void append(std::initializer_list); ///< Appends categories at the end
- cat_proxy insert(cat_proxy, nana::string);
+ cat_proxy append(std::string); ///< Appends a new category to the end
+ cat_proxy append(std::wstring); ///< Appends a new category to the end
+ void append(std::initializer_list); ///< Appends categories to the end
+ void append(std::initializer_list); ///< Appends categories to the end
+
+ cat_proxy insert(cat_proxy, ::std::string);
+ cat_proxy insert(cat_proxy, ::std::wstring);
cat_proxy at(size_type pos) const;
/// add categories in order when use a key?
@@ -606,7 +616,8 @@ By \a clicking on one header the list get \a reordered, first up, and then down
item_proxy at(const index_pair &abs_pos) const;
- void insert(const index_pair&, nana::string); /// strick_ordering);
+ void set_sort_compare(size_type col, std::function strick_ordering);
/// sort() and ivalidate any existing reference from display position to absolute item, that is: after sort() display offset point to different items
void sort_col(size_type col, bool reverse = false);
diff --git a/include/nana/gui/widgets/menu.hpp b/include/nana/gui/widgets/menu.hpp
index 512d30d7..335796d4 100644
--- a/include/nana/gui/widgets/menu.hpp
+++ b/include/nana/gui/widgets/menu.hpp
@@ -25,6 +25,8 @@ namespace nana
{
struct menu_type; //declaration
+ using native_string_type = ::nana::detail::native_string_type;
+
enum class checks
{
none,
@@ -56,7 +58,7 @@ namespace nana
//Default constructor initializes the item as a splitter
menu_item_type();
- menu_item_type(nana::string, const event_fn_t&);
+ menu_item_type(std::string, const event_fn_t&);
struct
{
@@ -66,11 +68,11 @@ namespace nana
}flags;
menu_type *sub_menu{nullptr};
- nana::string text;
+ std::string text;
event_fn_t functor;
checks style{checks::none};
paint::image image;
- mutable nana::char_t hotkey{0};
+ mutable wchar_t hotkey{0};
};
struct menu_type
@@ -89,7 +91,7 @@ namespace nana
class renderer_interface
{
public:
- typedef nana::paint::graphics & graph_reference;
+ using graph_reference = nana::paint::graphics &;
enum class state
{
@@ -109,7 +111,7 @@ namespace nana
virtual void background(graph_reference, window) = 0;
virtual void item(graph_reference, const nana::rectangle&, const attr&) = 0;
virtual void item_image(graph_reference, const nana::point&, unsigned image_px, const paint::image&) = 0;
- virtual void item_text(graph_reference, const nana::point&, const nana::string&, unsigned text_pixels, const attr&) = 0;
+ virtual void item_text(graph_reference, const nana::point&, const std::string&, unsigned text_pixels, const attr&) = 0;
virtual void sub_arrow(graph_reference, const nana::point&, unsigned item_pixels, const attr&) = 0;
};
}//end namespace menu
@@ -134,7 +136,7 @@ namespace nana
~menu();
/// Appends an item to the menu.
- item_proxy append(const nana::string& text, const event_fn_t& callback= event_fn_t());
+ item_proxy append(const std::string& text, const event_fn_t& callback= event_fn_t());
void append_splitter();
void clear(); ///< Erases all of the items.
/// Closes the menu. It does not destroy the menu; just close the window for the menu.
@@ -158,7 +160,7 @@ namespace nana
bool goto_submen();///< Popup the submenu of the current item if it has a sub menu. Returns true if succeeds.
bool exit_submenu(); ///< Closes the current window of the sub menu.
std::size_t size() const; ///< Return the number of items.
- int send_shortkey(nana::char_t key);
+ int send_shortkey(wchar_t key);
void pick();
menu& max_pixels(unsigned); ///< Sets the max width in pixels of the item.
diff --git a/include/nana/gui/widgets/menubar.hpp b/include/nana/gui/widgets/menubar.hpp
index 8e7270bc..365d9b1c 100644
--- a/include/nana/gui/widgets/menubar.hpp
+++ b/include/nana/gui/widgets/menubar.hpp
@@ -21,6 +21,8 @@ namespace nana
{
namespace menubar
{
+ using native_string_type = ::nana::detail::native_string_type;
+
class item_renderer
{
public:
@@ -33,7 +35,7 @@ namespace nana
item_renderer(window, graph_reference);
virtual void background(const point&, const ::nana::size&, state);
- virtual void caption(const point&, const ::nana::string&);
+ virtual void caption(const point&, const native_string_type&);
private:
window handle_;
graph_reference graph_;
@@ -46,7 +48,7 @@ namespace nana
public:
trigger();
~trigger();
- nana::menu* push_back(const nana::string&);
+ nana::menu* push_back(const std::string&);
nana::menu* at(size_t) const;
std::size_t size() const;
private:
@@ -108,7 +110,7 @@ namespace nana
menubar(window); ///< Create a menubar at the top of the specified window.
~menubar();
void create(window); ///< Create a menubar at the top of the specified window.
- menu& push_back(const nana::string&); ///< Appends a new (empty) menu.
+ menu& push_back(const std::string&); ///< Appends a new (empty) menu.
menu& at(size_t index) const; ///< Gets the menu specified by index.
std::size_t length() const; ///< Number of menus.
private:
diff --git a/include/nana/gui/widgets/scroll.hpp b/include/nana/gui/widgets/scroll.hpp
index f09b2046..96d1b023 100644
--- a/include/nana/gui/widgets/scroll.hpp
+++ b/include/nana/gui/widgets/scroll.hpp
@@ -186,7 +186,7 @@ namespace nana
{
graph_ = &graph;
widget_ = static_cast< ::nana::scroll*>(&widget);
- widget.caption(STR("Nana Scroll"));
+ widget.caption("nana scroll");
timer_.stop();
timer_.elapse(std::bind(&trigger::_m_tick, this));
diff --git a/include/nana/gui/widgets/skeletons/text_editor.hpp b/include/nana/gui/widgets/skeletons/text_editor.hpp
index cf1f207a..9da01f8c 100644
--- a/include/nana/gui/widgets/skeletons/text_editor.hpp
+++ b/include/nana/gui/widgets/skeletons/text_editor.hpp
@@ -131,7 +131,7 @@ namespace nana{ namespace widgets
struct keywords;
class keyword_parser;
public:
- using char_type = ::nana::char_t;
+ using char_type = wchar_t;
using size_type = textbase::size_type;
using string_type = textbase::string_type;
@@ -152,10 +152,10 @@ namespace nana{ namespace widgets
text_editor(window, graph_reference, const text_editor_scheme*);
~text_editor();
- void set_highlight(const std::string& name, const ::nana::color&, const ::nana::color&);
- void erase_highlight(const std::string& name);
- void set_keyword(const ::nana::string& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
- void erase_keyword(const ::nana::string& kw);
+ void set_highlight(const ::std::string& name, const ::nana::color&, const ::nana::color&);
+ void erase_highlight(const ::std::string& name);
+ void set_keyword(const ::std::wstring& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
+ void erase_keyword(const ::std::wstring& kw);
void set_accept(std::function);
void set_accept(accepts);
@@ -164,7 +164,7 @@ namespace nana{ namespace widgets
void typeface_changed();
- void indent(bool, std::function generator);
+ void indent(bool, std::function generator);
void set_event(event_interface*);
/// Determine whether the text_editor is line wrapped.
@@ -174,7 +174,7 @@ namespace nana{ namespace widgets
void border_renderer(std::function);
- bool load(const nana::char_t*);
+ bool load(const char*);
/// Sets the text area.
/// @return true if the area is changed with the new value.
@@ -183,7 +183,7 @@ namespace nana{ namespace widgets
/// Returns the text area
rectangle text_area(bool including_scroll) const;
- bool tip_string(nana::string&&);
+ bool tip_string(::std::string&&);
const attributes & attr() const;
bool multi_lines(bool);
@@ -201,9 +201,9 @@ namespace nana{ namespace widgets
unsigned line_height() const;
unsigned screen_lines() const;
- bool getline(std::size_t pos, nana::string&) const;
- void text(nana::string);
- nana::string text() const;
+ bool getline(std::size_t pos, ::std::wstring&) const;
+ void text(std::wstring);
+ std::wstring text() const;
/// Sets caret position through text coordinate.
void move_caret(const upoint&);
@@ -221,7 +221,7 @@ namespace nana{ namespace widgets
bool hit_select_area(nana::upoint pos) const;
bool move_select();
- bool mask(char_t);
+ bool mask(wchar_t);
/// Returns width of text area excluding the vscroll size.
unsigned width_pixels() const;
@@ -233,8 +233,8 @@ namespace nana{ namespace widgets
void draw_corner();
void render(bool focused);
public:
- void put(nana::string);
- void put(nana::char_t);
+ void put(std::wstring);
+ void put(wchar_t);
void copy() const;
void cut();
void paste();
@@ -253,8 +253,8 @@ namespace nana{ namespace widgets
bool mouse_move(bool left_button, const point& screen_pos);
bool mouse_pressed(const arg_mouse& arg);
- skeletons::textbase& textbase();
- const skeletons::textbase& textbase() const;
+ skeletons::textbase& textbase();
+ const skeletons::textbase& textbase() const;
private:
bool _m_accepts(char_type) const;
::nana::color _m_bgcolor() const;
@@ -264,11 +264,11 @@ namespace nana{ namespace widgets
::nana::size _m_text_area() const;
void _m_get_scrollbar_size();
void _m_reset();
- ::nana::upoint _m_put(nana::string);
+ ::nana::upoint _m_put(::std::wstring);
::nana::upoint _m_erase_select();
- bool _m_make_select_string(nana::string&) const;
- static bool _m_resolve_text(const nana::string&, std::vector> & lines);
+ bool _m_make_select_string(::std::wstring&) const;
+ static bool _m_resolve_text(const ::std::wstring&, std::vector> & lines);
bool _m_cancel_select(int align);
unsigned _m_tabs_pixels(size_type tabs) const;
@@ -283,10 +283,10 @@ namespace nana{ namespace widgets
/// Returns the right/bottom point of text area.
int _m_end_pos(bool right) const;
- void _m_draw_parse_string(const keyword_parser&, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const ::nana::char_t*, std::size_t len) const;
+ void _m_draw_parse_string(const keyword_parser&, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const wchar_t*, std::size_t len) const;
//_m_draw_string
//@brief: Draw a line of string
- void _m_draw_string(int top, const ::nana::color&, const nana::upoint& str_pos, const nana::string&, bool if_mask) const;
+ void _m_draw_string(int top, const ::nana::color&, const nana::upoint& str_pos, const ::std::wstring&, bool if_mask) const;
//_m_update_caret_line
//@brief: redraw whole line specified by caret pos.
//@return: true if caret overs the border
@@ -295,8 +295,8 @@ namespace nana{ namespace widgets
void _m_offset_y(int y);
- unsigned _m_char_by_pixels(const nana::char_t*, std::size_t len, unsigned* pxbuf, int str_px, int pixels, bool is_rtl);
- unsigned _m_pixels_by_char(const nana::string&, std::size_t pos) const;
+ unsigned _m_char_by_pixels(const wchar_t*, std::size_t len, unsigned* pxbuf, int str_px, int pixels, bool is_rtl);
+ unsigned _m_pixels_by_char(const ::std::wstring&, std::size_t pos) const;
void _handle_move_key(const arg_keyboard& arg);
private:
@@ -308,8 +308,8 @@ namespace nana{ namespace widgets
event_interface * event_handler_{ nullptr };
std::unique_ptr keywords_;
- skeletons::textbase textbase_;
- nana::char_t mask_char_{0};
+ skeletons::textbase textbase_;
+ wchar_t mask_char_{0};
mutable ext_renderer_tag ext_renderer_;
@@ -318,7 +318,7 @@ namespace nana{ namespace widgets
struct indent_rep
{
bool enabled{ false };
- std::function generator;
+ std::function generator;
}indent_;
struct attributes
@@ -326,7 +326,7 @@ namespace nana{ namespace widgets
accepts acceptive{ accepts::no_restrict };
std::function pred_acceptive;
- nana::string tip_string;
+ ::std::string tip_string;
bool line_wrapped{false};
bool multi_lines{true};
diff --git a/include/nana/gui/widgets/skeletons/text_token_stream.hpp b/include/nana/gui/widgets/skeletons/text_token_stream.hpp
index eef80358..ccd4db37 100644
--- a/include/nana/gui/widgets/skeletons/text_token_stream.hpp
+++ b/include/nana/gui/widgets/skeletons/text_token_stream.hpp
@@ -1,7 +1,7 @@
/*
* Text Token Stream
* Nana C++ Library(http://www.nanapro.org)
- * 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
@@ -42,7 +42,7 @@ namespace nana{ namespace widgets{ namespace skeletons
class tokenizer
{
public:
- tokenizer(const nana::string& s, bool format_enabled)
+ tokenizer(const std::wstring& s, bool format_enabled)
: iptr_(s.data()),
endptr_(s.data() + s.size()),
format_enabled_(format_enabled)
@@ -74,12 +74,12 @@ namespace nana{ namespace widgets{ namespace skeletons
return _m_token();
}
- const nana::string& idstr() const
+ const ::std::wstring& idstr() const
{
return idstr_;
}
- const std::pair& binary() const
+ const std::pair& binary() const
{
return binary_;
}
@@ -108,7 +108,7 @@ namespace nana{ namespace widgets{ namespace skeletons
return n;
}
private:
- static bool _m_unicode_word_breakable(nana::char_t ch)
+ static bool _m_unicode_word_breakable(wchar_t ch)
{
return ((0x4E00 <= ch) && (ch <= 0x9FFF));
}
@@ -116,7 +116,7 @@ namespace nana{ namespace widgets{ namespace skeletons
//Read the data token
token _m_token()
{
- nana::char_t ch = *iptr_;
+ wchar_t ch = *iptr_;
if(ch > 0xFF)
{
@@ -150,7 +150,7 @@ namespace nana{ namespace widgets{ namespace skeletons
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
{
- const nana::char_t * idstr = iptr_;
+ auto idstr = iptr_;
do
{
ch = *(++iptr_);
@@ -172,7 +172,7 @@ namespace nana{ namespace widgets{ namespace skeletons
{
//pos keeps the current position, and it used for restring
//iptr_ when the search is failed.
- const nana::char_t * pos = ++iptr_;
+ auto pos = ++iptr_;
_m_eat_whitespace();
if(*iptr_ == '/')
{
@@ -219,7 +219,7 @@ namespace nana{ namespace widgets{ namespace skeletons
{
_m_eat_whitespace();
- nana::char_t ch = *iptr_++;
+ auto ch = *iptr_++;
switch(ch)
{
@@ -232,7 +232,7 @@ namespace nana{ namespace widgets{ namespace skeletons
case '"':
//Here is a string and all the meta characters will be ignored except "
{
- const nana::char_t * str = iptr_;
+ auto str = iptr_;
while((iptr_ != endptr_) && (*iptr_ != '"'))
++iptr_;
@@ -244,7 +244,7 @@ namespace nana{ namespace widgets{ namespace skeletons
_m_eat_whitespace();
if((iptr_ < endptr_) && _m_is_idstr_element(*iptr_))
{
- const nana::char_t * pbegin = iptr_;
+ auto pbegin = iptr_;
while((iptr_ < endptr_) && _m_is_idstr_element(*iptr_))
++iptr_;
@@ -281,45 +281,45 @@ namespace nana{ namespace widgets{ namespace skeletons
//Here is a identifier
_m_read_idstr();
- if(STR("font") == idstr_)
+ if(L"font" == idstr_)
return token::font;
- else if(STR("bold") == idstr_)
+ else if(L"bold" == idstr_)
return token::bold;
- else if(STR("size") == idstr_)
+ else if(L"size" == idstr_)
return token::size;
- else if(STR("baseline") == idstr_)
+ else if(L"baseline" == idstr_)
return token::baseline;
- else if(STR("top") == idstr_)
+ else if(L"top" == idstr_)
return token::top;
- else if(STR("center") == idstr_)
+ else if(L"center" == idstr_)
return token::center;
- else if(STR("bottom") == idstr_)
+ else if(L"bottom" == idstr_)
return token::bottom;
- else if(STR("color") == idstr_)
+ else if(L"color" == idstr_)
return token::color;
- else if(STR("image") == idstr_)
+ else if(L"image" == idstr_)
return token::image;
- else if(STR("true") == idstr_)
+ else if(L"true" == idstr_)
return token::_true;
- else if(STR("url") == idstr_)
+ else if(L"url" == idstr_)
return token::url;
- else if(STR("target") == idstr_)
+ else if(L"target" == idstr_)
return token::target;
- else if(STR("false") == idstr_)
+ else if(L"false" == idstr_)
return token::_false;
- else if(STR("red") == idstr_)
+ else if(L"red" == idstr_)
return token::red;
- else if(STR("green") == idstr_)
+ else if(L"green" == idstr_)
return token::green;
- else if(STR("blue") == idstr_)
+ else if(L"blue" == idstr_)
return token::blue;
- else if(STR("white") == idstr_)
+ else if(L"white" == idstr_)
return token::white;
- else if(STR("black") == idstr_)
+ else if(L"black" == idstr_)
return token::black;
- else if(STR("min_limited") == idstr_)
+ else if(L"min_limited" == idstr_)
return token::min_limited;
- else if(STR("max_limited") == idstr_)
+ else if(L"max_limited" == idstr_)
return token::max_limited;
return token::string;
@@ -335,7 +335,7 @@ namespace nana{ namespace widgets{ namespace skeletons
return token::eof;
}
- static bool _m_is_idstr_element(nana::char_t ch)
+ static bool _m_is_idstr_element(wchar_t ch)
{
return (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || ('_' == ch) || ('0' <= ch && ch <= '9'));
}
@@ -343,9 +343,9 @@ namespace nana{ namespace widgets{ namespace skeletons
//Read the identifier.
void _m_read_idstr()
{
- const nana::char_t * idstr = iptr_;
+ auto idstr = iptr_;
- nana::char_t ch;
+ wchar_t ch;
do
{
ch = *(++iptr_);
@@ -360,7 +360,7 @@ namespace nana{ namespace widgets{ namespace skeletons
{
idstr_.clear();
- nana::char_t ch = *iptr_;
+ wchar_t ch = *iptr_;
idstr_ += ch;
@@ -412,13 +412,13 @@ namespace nana{ namespace widgets{ namespace skeletons
}
}
private:
- const ::nana::char_t * iptr_;
- const ::nana::char_t * endptr_;
+ const wchar_t * iptr_;
+ const wchar_t * endptr_;
const bool format_enabled_;
bool format_state_{false};
- ::nana::string idstr_;
- std::pair binary_;
+ std::wstring idstr_;
+ std::pair binary_;
token revert_token_{token::eof};
};
@@ -434,7 +434,7 @@ namespace nana{ namespace widgets{ namespace skeletons
};
};
- ::nana::string font;
+ ::std::string font;
std::size_t font_size;
bool bold;
bool bold_empty; //bold should be ignored if bold_empty is true
@@ -442,8 +442,8 @@ namespace nana{ namespace widgets{ namespace skeletons
::nana::color bgcolor; //If the color is not specified, it will be ignored, and the system will search for its parent.
::nana::color fgcolor; //ditto
- ::nana::string target;
- ::nana::string url;
+ ::std::wstring target;
+ ::std::wstring url;
fblock * parent;
};
@@ -458,7 +458,7 @@ namespace nana{ namespace widgets{ namespace skeletons
virtual bool is_text() const = 0;
virtual bool is_whitespace() const = 0;
- virtual const nana::string& text() const = 0;
+ virtual const std::wstring& text() const = 0;
virtual void measure(graph_reference) = 0;
virtual void nontext_render(graph_reference, int x, int y) = 0;
virtual const nana::size & size() const = 0;
@@ -470,7 +470,7 @@ namespace nana{ namespace widgets{ namespace skeletons
: public data
{
public:
- data_text(const nana::string& s)
+ data_text(const std::wstring& s)
: str_(s)
{}
private:
@@ -484,7 +484,7 @@ namespace nana{ namespace widgets{ namespace skeletons
return false;
}
- virtual const nana::string& text() const override
+ virtual const std::wstring& text() const override
{
return str_;
}
@@ -513,7 +513,7 @@ namespace nana{ namespace widgets{ namespace skeletons
return ascent_;
}
private:
- nana::string str_;
+ std::wstring str_;
nana::size size_;
std::size_t ascent_;
};
@@ -522,7 +522,7 @@ namespace nana{ namespace widgets{ namespace skeletons
: public data
{
public:
- data_image(const nana::string& imgpath, const nana::size & sz, std::size_t limited)
+ data_image(const std::wstring& imgpath, const nana::size & sz, std::size_t limited)
: image_(imgpath)//, limited_(limited)
{
size_ = image_.size();
@@ -562,7 +562,7 @@ namespace nana{ namespace widgets{ namespace skeletons
return false;
}
- virtual const nana::string& text() const override
+ virtual const std::wstring& text() const override
{
return str_;
}
@@ -589,7 +589,7 @@ namespace nana{ namespace widgets{ namespace skeletons
return size_.height;
}
private:
- nana::string str_;
+ std::wstring str_;
nana::paint::image image_;
nana::size size_;
};
@@ -626,7 +626,7 @@ namespace nana{ namespace widgets{ namespace skeletons
fblocks_.clear();
}
- void parse(const nana::string& s, bool format_enabled)
+ void parse(const std::wstring& s, bool format_enabled)
{
close();
@@ -706,7 +706,7 @@ namespace nana{ namespace widgets{ namespace skeletons
if(token::string != tknizer.read())
throw std::runtime_error("");
- fp->font = tknizer.idstr();
+ fp->font = to_utf8(tknizer.idstr());
break;
case token::size:
if(token::equal != tknizer.read())
@@ -893,7 +893,7 @@ namespace nana{ namespace widgets{ namespace skeletons
return fbp;
}
- void _m_data_factory(token tk, const nana::string& idstr, fblock* fp, std::deque& line)
+ void _m_data_factory(token tk, const std::wstring& idstr, fblock* fp, std::deque& line)
{
value v;
v.fblock_ptr = fp;
@@ -926,7 +926,7 @@ namespace nana{ namespace widgets{ namespace skeletons
struct attr_image_tag
{
- nana::string path;
+ std::wstring path;
nana::size size;
std::size_t limited;
diff --git a/include/nana/gui/widgets/skeletons/textbase.hpp b/include/nana/gui/widgets/skeletons/textbase.hpp
index 32527879..975025e1 100644
--- a/include/nana/gui/widgets/skeletons/textbase.hpp
+++ b/include/nana/gui/widgets/skeletons/textbase.hpp
@@ -57,13 +57,12 @@ namespace skeletons
((text_cont_.size() == 1) && (text_cont_[0].empty())));
}
- bool load(const nana::char_t* fs)
+ bool load(const char* file_utf8)
{
- if (nullptr == fs)
+ if (!file_utf8)
return false;
- std::string fs_mbs = nana::charset(fs);
- std::ifstream ifs(fs_mbs.data());
+ std::ifstream ifs(to_osmbstr(file_utf8));
if (!ifs)
return false;
@@ -81,7 +80,7 @@ namespace skeletons
if(0xBB == ch && 0xBF == ifs.get())
{
ifs.close();
- return load(fs, nana::unicode::utf8);
+ return load(file_utf8, nana::unicode::utf8);
}
}
else if(0xFF == ch)
@@ -94,11 +93,11 @@ namespace skeletons
if(ifs.get() == 0 && ifs.get() == 0)
{
ifs.close();
- return load(fs, nana::unicode::utf32);
+ return load(file_utf8, nana::unicode::utf32);
}
}
ifs.close();
- return load(fs, nana::unicode::utf16);
+ return load(file_utf8, nana::unicode::utf16);
}
}
else if(0xFE == ch)
@@ -107,7 +106,7 @@ namespace skeletons
{
//UTF16(big-endian)
ifs.close();
- return load(fs, nana::unicode::utf16);
+ return load(file_utf8, nana::unicode::utf16);
}
}
else if(0 == ch)
@@ -119,7 +118,7 @@ namespace skeletons
{
//UTF32(big_endian)
ifs.close();
- return load(fs, nana::unicode::utf32);
+ return load(file_utf8, nana::unicode::utf32);
}
}
}
@@ -143,7 +142,7 @@ namespace skeletons
}
}
- _m_saved(fs);
+ _m_saved(file_utf8);
return true;
}
@@ -175,13 +174,12 @@ namespace skeletons
}
}
- bool load(const nana::char_t * fs, nana::unicode encoding)
+ bool load(const char* file_utf8, nana::unicode encoding)
{
- if (nullptr == fs)
+ if (!file_utf8)
return false;
- std::string fs_mbs = nana::charset(fs);
- std::ifstream ifs(fs_mbs.data());
+ std::ifstream ifs(to_osmbstr(file_utf8));
if (!ifs)
return false;
@@ -245,14 +243,13 @@ namespace skeletons
}
}
- _m_saved(fs);
+ _m_saved(file_utf8);
return true;
}
- void store(nana::string fs, bool is_unicode, ::nana::unicode encoding) const
+ void store(std::string fs, bool is_unicode, ::nana::unicode encoding) const
{
- std::string fs_mbs = nana::charset(fs);
- std::ofstream ofs(fs_mbs.data(), std::ios::binary);
+ std::ofstream ofs(to_osmbstr(fs), std::ios::binary);
if(ofs && text_cont_.size())
{
std::string last_mbs;
@@ -410,7 +407,7 @@ namespace skeletons
{
std::deque().swap(text_cont_);
attr_max_.reset();
- _m_saved(nana::string());
+ _m_saved(std::string());
}
void merge(size_type pos)
@@ -427,7 +424,7 @@ namespace skeletons
}
}
- const nana::string& filename() const
+ const std::string& filename() const
{
return filename_;
}
@@ -489,7 +486,7 @@ namespace skeletons
evt_agent_->first_change();
}
- void _m_saved(nana::string && filename) const
+ void _m_saved(std::string && filename) const
{
if(filename_ != filename)
{
@@ -518,7 +515,7 @@ namespace skeletons
textbase_event_agent_interface* evt_agent_{ nullptr };
mutable bool changed_{ false };
- mutable nana::string filename_; //A string for the saved filename.
+ mutable std::string filename_; //A string for the saved filename.
const string_type nullstr_;
struct attr_max
diff --git a/include/nana/gui/widgets/slider.hpp b/include/nana/gui/widgets/slider.hpp
index 0e32237d..c5372034 100644
--- a/include/nana/gui/widgets/slider.hpp
+++ b/include/nana/gui/widgets/slider.hpp
@@ -45,7 +45,7 @@ namespace nana
{
public:
virtual ~provider() = default;
- virtual nana::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
+ virtual std::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
};
class renderer
@@ -81,7 +81,7 @@ namespace nana
virtual void background(window, graph_reference, bool isglass) = 0;
virtual void adorn(window, graph_reference, const adorn_t&) = 0;
- virtual void adorn_textbox(window, graph_reference, const nana::string&, const nana::rectangle&) = 0;
+ virtual void adorn_textbox(window, graph_reference, const ::std::string&, const nana::rectangle&) = 0;
virtual void bar(window, graph_reference, const bar_t&) = 0;
virtual void slider(window, graph_reference, const slider_t&) = 0;
};
diff --git a/include/nana/gui/widgets/spinbox.hpp b/include/nana/gui/widgets/spinbox.hpp
index dc081018..e3d28505 100644
--- a/include/nana/gui/widgets/spinbox.hpp
+++ b/include/nana/gui/widgets/spinbox.hpp
@@ -97,17 +97,17 @@ namespace nana
void range(std::initializer_list values);
/// Gets the spined value
- ::nana::string value() const;
- void value(const ::nana::string&);
+ ::std::string value() const;
+ void value(const ::std::string&);
int to_int() const;
double to_double() const;
/// Sets the modifiers
- void modifier(std::wstring prefix, std::wstring suffix);
- void modifier(const std::string & prefix_utf8, const std::string& suffix_utf8);
+ void modifier(std::string prefix_utf8, std::string suffix_utf8);
+ void modifier(const std::wstring & prefix, const std::wstring& suffix);
private:
- ::nana::string _m_caption() const throw();
- void _m_caption(::nana::string&&);
+ native_string_type _m_caption() const throw();
+ void _m_caption(native_string_type&&);
}; //end class spinbox
}//end namespace nana
diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp
index 8236f639..1981c3c7 100644
--- a/include/nana/gui/widgets/tabbar.hpp
+++ b/include/nana/gui/widgets/tabbar.hpp
@@ -144,12 +144,14 @@ namespace nana
: public drawer_trigger
{
public:
+ using native_string_type = ::nana::detail::native_string_type;
+
enum class kits
{
- add,
- scroll,
- list,
- close
+ add, ///< The type identifies the add button of the tabbar's toolbox.
+ scroll, ///< The type identifies the scroll button of the tabbar's toolbox
+ list, ///< The type identifies the list button of the tabbar's toolbox
+ close ///< The type identifies the close button of the tabbar's toolbox
};
trigger();
@@ -161,15 +163,15 @@ namespace nana
const pat::cloneable & ext_renderer() const;
void ext_renderer(const pat::cloneable&);
void set_event_agent(event_agent_interface*);
- void insert(std::size_t, nana::string&&, nana::any&&);
+ void insert(std::size_t, native_string_type&&, nana::any&&);
std::size_t length() const;
bool close_fly(bool);
void attach(std::size_t, window);
void erase(std::size_t);
void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&);
void tab_image(size_t, const nana::paint::image&);
- void text(std::size_t, const nana::string&);
- nana::string text(std::size_t) const;
+ void text(std::size_t, const native_string_type&);
+ native_string_type text(std::size_t) const;
bool toolbox(kits, bool);
private:
void attached(widget_reference, graph_reference) override;
@@ -191,30 +193,9 @@ namespace nana
{
typedef drawerbase::tabbar::trigger drawer_trigger_t;
public:
- typedef Type value_type; ///< The type of element data which is stored in the tabbar.
- typedef drawerbase::tabbar::item_renderer item_renderer; ///< A user-defined item renderer should be derived from this interface.
-
- //These member types is deprecated, they will be removed in Nana 1.3
- struct button_add{}; ///< The type identifies the add button of the tabbar's toolbox.
- struct button_scroll{}; ///< The type identifies the scroll button of the tabbar's toolbox.
- struct button_list{}; ///< The type identifies the list button of the tabbar's toolbox.
- struct button_close{}; ///< The type identifies the close button of the tabbar's toolbox.
-
- //This template class is deprecated, it will be removed in 1.3
- /// A template class identifies the buttons of the tabbar's toolbox. Refer to notes for more details.
- template
- struct button_container
- {
- typedef meta::fixed_type_set type_set;
- };
-
- enum class kits
- {
- add, ///< The type identifies the add button of the tabbar's toolbox.
- scroll, ///< The type identifies the scroll button of the tabbar's toolbox
- list, ///< The type identifies the list button of the tabbar's toolbox
- close ///< The type identifies the close button of the tabbar's toolbox
- };
+ using value_type = Type; ///< The type of element data which is stored in the tabbar.
+ using item_renderer = drawerbase::tabbar::item_renderer; ///< A user-defined item renderer should be derived from this interface.
+ using kits = drawer_trigger_t::kits;
tabbar()
{
@@ -298,15 +279,19 @@ namespace nana
return *this;
}
- void push_back(nana::string text) /// Append a new item.
+ void push_back(std::string text) /// Append a new item.
{
- this->get_drawer_trigger().insert(::nana::npos, std::move(text), value_type());
+ this->get_drawer_trigger().insert(::nana::npos, to_nstring(std::move(text)), value_type());
API::update_window(*this);
}
void insert(std::size_t pos, std::string text, value_type value = {})
{
- return this->insert(pos, static_cast(nana::charset(text, nana::unicode::utf8)), std::move(value));
+ if (pos > length())
+ throw std::out_of_range("tabbar::insert invalid position");
+
+ this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value));
+ API::update_window(*this);
}
void insert(std::size_t pos, std::wstring text, value_type value = {})
@@ -314,16 +299,10 @@ namespace nana
if (pos > length())
throw std::out_of_range("tabbar::insert invalid position");
- this->get_drawer_trigger().insert(pos, std::move(text), std::move(value));
+ this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value));
API::update_window(*this);
}
- //deprecated from 1.2.1, removed from 1.3
- void relate(std::size_t pos, window wd) /// Binds a window to an item specified by pos, if the item is selected, shows the window, otherwise, hides it.
- {
- this->get_drawer_trigger().attach(pos, wd);
- }
-
void attach(std::size_t pos, window attach_wd)
{
if (attach_wd && API::empty_window(attach_wd))
@@ -351,46 +330,22 @@ namespace nana
{
this->get_drawer_trigger().tab_image(pos, img);
}
+
/// Sets buttons of the tabbar's toolbox, refer to notes for more details.
- template
- void toolbox(const button_container&, bool enable)
- {
- typedef typename button_container::type_set type_set;
- auto & tg = this->get_drawer_trigger();
- bool redraw = false;
-
- using inner_kits = drawerbase::tabbar::trigger::kits;
-
- if(type_set::template count::value)
- redraw |= tg.toolbox(inner_kits::add, enable);
-
- if(type_set::template count::value)
- redraw |= tg.toolbox(inner_kits::scroll, enable);
-
- if(type_set::template count::value)
- redraw |= tg.toolbox(inner_kits::add, enable);
-
- if(type_set::template count::value)
- redraw |= tg.toolbox(inner_kits::close, enable);
-
- if(redraw)
- API::refresh_window(this->handle());
- }
-
void toolbox(kits kit, bool enable)
{
if (this->get_drawer_trigger().toolbox(kit, enable))
API::refresh_window(this->handle());
}
- void text(std::size_t pos, const nana::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
+ void text(std::size_t pos, const std::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
{
- this->get_drawer_trigger().text(pos, str);
+ this->get_drawer_trigger().text(pos, to_nstring(str));
}
- nana::string text(std::size_t pos) const /// Returns a title of a specified item, If pos is invalid, the method trhows a std::out_of_range object.
+ std::string text(std::size_t pos) const /// Returns a title of a specified item, If pos is invalid, the method trhows a std::out_of_range object.
{
- return this->get_drawer_trigger().text(pos);
+ return to_utf8(this->get_drawer_trigger().text(pos));
}
private:
std::unique_ptr > evt_agent_;
diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp
index f0d8ff02..69fda830 100644
--- a/include/nana/gui/widgets/textbox.hpp
+++ b/include/nana/gui/widgets/textbox.hpp
@@ -111,13 +111,13 @@ namespace nana
/// @param window A handle to the parent window of the widget being created.
/// @param text the text that will be displayed.
/// @param visible specifying the visible after creating.
- textbox(window, const nana::string& text, bool visible = true);
+ textbox(window, const std::string& text, bool visible = true);
/// \brief The construct that creates a widget with a specified text.
/// @param window A handle to the parent window of the widget being created.
/// @param text the text that will be displayed.
/// @param visible specifying the visible after creating.
- textbox(window, const nana::char_t* text, bool visible = true);
+ textbox(window, const char* text, bool visible = true);
/// \brief The construct that creates a widget.
/// @param window A handle to the parent window of the widget being created.
@@ -126,19 +126,19 @@ namespace nana
textbox(window, const rectangle& = rectangle(), bool visible = true);
/// \brief Loads a text file. When attempt to load a unicode encoded text file, be sure the file have a BOM header.
- void load(nana::string file);
- void store(nana::string file);
- void store(nana::string file, nana::unicode encoding);
+ void load(std::string file);
+ void store(std::string file);
+ void store(std::string file, nana::unicode encoding);
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
- textbox& indention(bool, std::function generator = {});
+ textbox& indention(bool, std::function generator = {});
//A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
- textbox& reset(nana::string = nana::string()); ///< discard the old text and set a new text
+ textbox& reset(const std::string& = std::string()); ///< discard the old text and set a new text
/// The file of last store operation.
- nana::string filename() const;
+ std::string filename() const;
/// Determine whether the text was edited.
bool edited() const;
@@ -150,7 +150,7 @@ namespace nana
bool saved() const;
/// Read the text from a specified line. It returns true for success.
- bool getline(std::size_t pos, nana::string&) const;
+ bool getline(std::size_t pos, std::string&) const;
/// Gets the caret position
/// Returns true if the caret is in the area of display, false otherwise.
@@ -160,7 +160,7 @@ namespace nana
textbox& caret_pos(const upoint&);
/// Appends an string. If `at_caret` is `true`, the string is inserted at the position of caret, otherwise, it is appended at end of the textbox.
- textbox& append(const nana::string& text, bool at_caret);
+ textbox& append(const std::string& text, bool at_caret);
/// Determine wheter the text is line wrapped.
bool line_wrapped() const;
@@ -171,12 +171,12 @@ namespace nana
textbox& multi_lines(bool);
bool editable() const;
textbox& editable(bool);
- void set_accept(std::function);
+ void set_accept(std::function);
- textbox& tip_string(nana::string);
+ textbox& tip_string(::std::string);
/// Set a mask character. Text is displayed as mask character if a mask character is set. This is used for hiding some special text, such as password.
- textbox& mask(nana::char_t);
+ textbox& mask(wchar_t);
/// Returns true if some text is selected.
bool selected() const;
@@ -195,10 +195,9 @@ namespace nana
void set_highlight(const std::string& name, const ::nana::color& fgcolor, const ::nana::color& bgcolor);
void erase_highlight(const std::string& name);
- void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list kw_list);
+ void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list kw_list);
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list kw_list_utf8);
- void erase_keyword(const nana::string& kw);
-
+ void erase_keyword(const std::string& kw);
/// Returns the text position of each line that currently displays on screen.
text_positions text_position() const;
@@ -210,8 +209,8 @@ namespace nana
unsigned line_pixels() const;
protected:
//Overrides widget's virtual functions
- ::nana::string _m_caption() const throw() override;
- void _m_caption(::nana::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
diff --git a/include/nana/gui/widgets/toolbar.hpp b/include/nana/gui/widgets/toolbar.hpp
index 0b097676..d23efcc6 100644
--- a/include/nana/gui/widgets/toolbar.hpp
+++ b/include/nana/gui/widgets/toolbar.hpp
@@ -87,8 +87,8 @@ namespace nana
toolbar(window, const rectangle& = rectangle(), bool visible = true);
void separate(); ///< Adds a separator.
- void append(const nana::string& text, const nana::paint::image& img); ///< Adds a control button.
- void append(const nana::string& text); ///< Adds a control button.
+ void append(const ::std::string& text, const nana::paint::image& img); ///< Adds a control button.
+ void append(const ::std::string& text); ///< Adds a control button.
bool enable(size_type index) const;
void enable(size_type index, bool enable_state);
void scale(unsigned s); ///< Sets the scale of control button.
diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp
index db445daf..5fd7a27a 100644
--- a/include/nana/gui/widgets/treebox.hpp
+++ b/include/nana/gui/widgets/treebox.hpp
@@ -55,7 +55,7 @@ namespace nana
nana::paint::image icon_normal;
nana::paint::image icon_hover;
nana::paint::image icon_expanded;
- nana::string text;
+ ::std::string text;
};
typedef widgets::detail::compset compset_interface;
@@ -98,14 +98,14 @@ namespace nana
struct treebox_node_type
{
treebox_node_type();
- treebox_node_type(nana::string);
+ treebox_node_type(std::string);
treebox_node_type& operator=(const treebox_node_type&);
- nana::string text;
+ ::std::string text;
nana::any value;
bool expanded;
checkstate checked;
- nana::string img_idstr;
+ ::std::string img_idstr;
};
struct pseudo_node_type{};
@@ -133,8 +133,8 @@ namespace nana
const ::nana::pat::cloneable& placer() const;
nana::any & value(node_type*) const;
- node_type* insert(node_type*, const nana::string& key, nana::string&&);
- node_type* insert(const nana::string& path, nana::string&&);
+ node_type* insert(node_type*, const std::string& key, std::string&&);
+ node_type* insert(const std::string& path, std::string&&);
bool verify(const void*) const;
bool verify_kinship(node_type* parent, node_type* child) const;
@@ -143,16 +143,15 @@ namespace nana
node_type * selected() const;
void selected(node_type*);
void set_expand(node_type*, bool);
- void set_expand(const nana::string& path, bool);
+ void set_expand(const ::std::string& path, bool);
- //void image(const nana::string& id, const node_image_tag&);
- node_image_tag& icon(const nana::string&) const;
- void icon_erase(const nana::string&);
- void node_icon(node_type*, const nana::string& id);
+ node_image_tag& icon(const ::std::string&) const;
+ void icon_erase(const ::std::string&);
+ void node_icon(node_type*, const ::std::string& id);
unsigned node_width(const node_type*) const;
- bool rename(node_type*, const nana::char_t* key, const nana::char_t* name);
+ bool rename(node_type*, const char* key, const char* name);
private:
//Overrides drawer_trigger methods
void attached(widget_reference, graph_reference) override;
@@ -182,11 +181,11 @@ namespace nana
item_proxy(trigger*, trigger::node_type*);
/// Append a child.
- item_proxy append(const nana::string& key, nana::string name);
+ item_proxy append(const ::std::string& key, ::std::string name);
/// Append a child with a specified value (user object.).
template
- item_proxy append(const nana::string& key, nana::string name, const T&t)
+ item_proxy append(const ::std::string& key, ::std::string name, const T&t)
{
item_proxy ip = append(key, std::move(name));
if(false == ip.empty())
@@ -220,22 +219,22 @@ namespace nana
item_proxy& select(bool);
/// Return the icon.
- const nana::string& icon() const;
+ const ::std::string& icon() const;
/// Set the icon, and returns itself..
- item_proxy& icon(const nana::string& id);
+ item_proxy& icon(const ::std::string& id);
/// Return the text.
- const nana::string& text() const;
-
- /// Set a new key, and returns itself..
- item_proxy& key(const nana::string& s);
-
- /// Return the key.
- const nana::string& key() const;
+ const ::std::string& text() const;
/// Set the text, and returns itself.
- item_proxy& text(const nana::string&);
+ item_proxy& text(const ::std::string&);
+
+ /// Set a new key, and returns itself..
+ item_proxy& key(const ::std::string& s);
+
+ /// Return the key.
+ const ::std::string& key() const;
std::size_t size() const; ///< Returns the number of child nodes.
@@ -257,7 +256,7 @@ namespace nana
/// Makes an action for each sub item recursively, returns the item that stops the action where action returns false.
item_proxy visit_recursively(std::function action);
- bool operator==(const nana::string& s) const; ///< Compare the text of node with s.
+ bool operator==(const ::std::string& s) const; ///< Compare the text of node with s.
bool operator==(const char* s ) const; ///< Compare the text of node with s.
bool operator==(const wchar_t* s ) const; ///< Compare the text of node with s.
@@ -428,28 +427,28 @@ namespace nana
/// These states are 'normal', 'hovered' and 'expanded'.
/// If 'hovered' or 'expanded' are not set, it uses 'normal' state image for these 2 states.
/// See also in [documentation](http://nanapro.org/en-us/help/widgets/treebox.htm)
- node_image_type& icon(const nana::string& id ///< the name of an icon scheme. If the name is not existing, it creates a new scheme for the name.
+ node_image_type& icon(const ::std::string& id ///< the name of an icon scheme. If the name is not existing, it creates a new scheme for the name.
) const;
- void icon_erase(const nana::string& id);
+ void icon_erase(const ::std::string& id);
- item_proxy find(const nana::string& keypath); ///< Find an item though a specified keypath.
+ item_proxy find(const ::std::string& keypath); ///< Find an item though a specified keypath.
/// Inserts a new node to treebox, but if the keypath exists returns the existing node.
- item_proxy insert(const nana::string& path_key, ///< specifies the node hierarchy
- nana::string title ///< used for displaying
+ item_proxy insert(const ::std::string& path_key, ///< specifies the node hierarchy
+ ::std::string title ///< used for displaying
);
/// Inserts a new node to treebox, but if the keypath exists returns the existing node.
item_proxy insert( item_proxy pos, ///< the parent item node
- const nana::string& key, ///< specifies the new node
- nana::string title ///< title used for displaying in the new node.
+ const ::std::string& key, ///< specifies the new node
+ ::std::string title ///< title used for displaying in the new node.
);
item_proxy erase(item_proxy i); ///< Removes the node at pos and return the Item proxy following the removed node
- void erase(const nana::string& keypath); ///< Removes the node by the key path.
+ void erase(const ::std::string& keypath); ///< Removes the node by the key path.
- nana::string make_key_path(item_proxy i, const nana::string& splitter) const;///
void i18n(std::string msgid, Args&&... args)
@@ -88,10 +93,10 @@ namespace nana
void umake_event(event_handle eh) const; ///< Deletes an event callback by a handle.
- widget& register_shortkey(char_t); ///< Registers a shortkey. To remove a registered key, pass 0.
+ widget& register_shortkey(wchar_t); ///< Registers a shortkey. To remove a registered key, pass 0.
widget& take_active(bool activated, window take_if_not_activated);
- widget& tooltip(const nana::string&);
+ widget& tooltip(const ::std::string&);
operator dummy_bool_type() const;
operator window() const;
@@ -105,8 +110,8 @@ namespace nana
virtual void _m_complete_creation();
virtual general_events& _m_get_general_events() const = 0;
- virtual nana::string _m_caption() const throw();
- virtual void _m_caption(nana::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();
diff --git a/include/nana/internationalization.hpp b/include/nana/internationalization.hpp
index 341c8e97..e1e2cbe3 100644
--- a/include/nana/internationalization.hpp
+++ b/include/nana/internationalization.hpp
@@ -28,34 +28,34 @@ namespace nana
void load_utf8(const std::string& file);
template
- nana::string get(std::string msgid_utf8, Args&&... args) const
+ ::std::string get(std::string msgid_utf8, Args&&... args) const
{
- std::vector arg_strs;
+ std::vector arg_strs;
_m_fetch_args(arg_strs, std::forward(args)...);
- nana::string msgstr;
+ ::std::string msgstr;
if (_m_get(msgid_utf8, msgstr))
_m_replace_args(msgstr, &arg_strs);
return msgstr;
}
- nana::string get(std::string msgid_utf8) const;
- void set(std::string msgid_utf8, nana::string msgstr);
+ ::std::string get(std::string msgid_utf8) const;
+ void set(std::string msgid_utf8, ::std::string msgstr);
template
- nana::string operator()(std::string msgid_utf8, Args&&... args) const
+ ::std::string operator()(std::string msgid_utf8, Args&&... args) const
{
return get(msgid_utf8, std::forward(args)...);
}
private:
- bool _m_get(std::string& msgid, nana::string& msgstr) const;
- void _m_replace_args(nana::string& str, std::vector * arg_strs) const;
+ bool _m_get(std::string& msgid, ::std::string& msgstr) const;
+ void _m_replace_args(::std::string& str, std::vector<::std::string> * arg_strs) const;
- void _m_fetch_args(std::vector&) const //Termination of _m_fetch_args
+ void _m_fetch_args(std::vector&) const //Termination of _m_fetch_args
{}
template
- void _m_fetch_args(std::vector& v, Arg&& arg) const
+ void _m_fetch_args(std::vector& v, Arg&& arg) const
{
std::wstringstream ss;
ss << arg;
@@ -63,52 +63,39 @@ namespace nana
}
template
- void _m_fetch_args(std::vector& v, const char* arg, Args&&... args) const
+ void _m_fetch_args(std::vector& v, const char* arg, Args&&... args) const
{
- std::wstringstream ss;
- ss << nana::string(nana::charset(arg));
- v.emplace_back(ss.str());
-
+ v.emplace_back(arg);
_m_fetch_args(v, std::forward(args)...);
}
template
- void _m_fetch_args(std::vector& v, const std::string& arg, Args&&... args) const
+ void _m_fetch_args(std::vector& v, const std::string& arg, Args&&... args) const
{
- std::wstringstream ss;
- ss << nana::string(nana::charset(arg));
- v.emplace_back(ss.str());
-
+ v.emplace_back(arg);
_m_fetch_args(v, std::forward(args)...);
}
template
- void _m_fetch_args(std::vector& v, std::string& arg, Args&&... args) const
+ void _m_fetch_args(std::vector& v, std::string& arg, Args&&... args) const
{
- std::wstringstream ss;
- ss << nana::string(nana::charset(arg));
- v.emplace_back(ss.str());
-
+ v.emplace_back(arg);
_m_fetch_args(v, std::forward(args)...);
}
template
- void _m_fetch_args(std::vector& v, std::string&& arg, Args&&... args) const
+ void _m_fetch_args(std::vector& v, std::string&& arg, Args&&... args) const
{
- std::wstringstream ss;
- ss << nana::string(nana::charset(arg));
- v.emplace_back(ss.str());
-
+ v.emplace_back(std::move(arg));
_m_fetch_args(v, std::forward(args)...);
}
template
- void _m_fetch_args(std::vector& v, Arg&& arg, Args&&... args) const
+ void _m_fetch_args(std::vector& v, Arg&& arg, Args&&... args) const
{
- std::wstringstream ss;
+ std::stringstream ss;
ss << arg;
v.emplace_back(ss.str());
-
_m_fetch_args(v, std::forward(args)...);
}
};//end class internationalization
@@ -119,7 +106,7 @@ namespace nana
{
public:
virtual ~eval_arg() = default;
- virtual nana::string eval() const = 0;
+ virtual std::string eval() const = 0;
virtual std::unique_ptr clone() const = 0;
};
@@ -134,7 +121,7 @@ namespace nana
: fn_(fn)
{}
- nana::string eval() const override
+ std::string eval() const override
{
std::wstringstream ss;
ss << fn_();
@@ -166,7 +153,7 @@ namespace nana
i18n_eval& operator=(const i18n_eval&);
i18n_eval& operator=(i18n_eval&& rhs);
- nana::string operator()() const;
+ std::string operator()() const;
private:
void _m_fetch_args(){} //Termination of _m_fetch_args
@@ -180,7 +167,7 @@ namespace nana
template
void _m_add_args(Arg&& arg)
{
- std::wstringstream ss;
+ std::stringstream ss;
ss << arg;
_m_add_args(ss.str());
}
diff --git a/include/nana/paint/detail/image_impl_interface.hpp b/include/nana/paint/detail/image_impl_interface.hpp
index 6cd604fb..379e8027 100644
--- a/include/nana/paint/detail/image_impl_interface.hpp
+++ b/include/nana/paint/detail/image_impl_interface.hpp
@@ -15,7 +15,7 @@ namespace nana{ namespace paint{
public:
typedef nana::paint::graphics& graph_reference;
virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp
- virtual bool open(const nana::char_t* filename) = 0;
+ virtual bool open(const nana::experimental::filesystem::path& file) = 0;
virtual bool open(const void* data, std::size_t bytes) = 0; // reads image from memory
virtual bool alpha_channel() const = 0;
virtual bool empty() const = 0;
diff --git a/include/nana/paint/detail/native_paint_interface.hpp b/include/nana/paint/detail/native_paint_interface.hpp
index 4281aca1..4a3dba44 100644
--- a/include/nana/paint/detail/native_paint_interface.hpp
+++ b/include/nana/paint/detail/native_paint_interface.hpp
@@ -32,9 +32,9 @@ namespace detail
void blend(drawable_type dw, const nana::rectangle& r, pixel_color_t, double fade_rate);
- nana::size raw_text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
- nana::size text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
- void draw_string(drawable_type, const nana::point&, const nana::char_t *, std::size_t len);
+ nana::size raw_text_extent_size(drawable_type, const wchar_t*, std::size_t len);
+ nana::size text_extent_size(drawable_type, const wchar_t*, std::size_t len);
+ void draw_string(drawable_type, const nana::point&, const wchar_t *, std::size_t len);
}//end namespace detail
}//end namespace paint
}//end namespace nana
diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp
index a194aa7e..501d30fc 100644
--- a/include/nana/paint/graphics.hpp
+++ b/include/nana/paint/graphics.hpp
@@ -36,14 +36,14 @@ namespace nana
font();
font(drawable_type);
font(const font&);
- font(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
+ font(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
~font();
bool empty() const;
- void make(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
- void make_raw(const char_t*, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
+ void make(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
+ void make_raw(const ::std::string& name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
void set_default() const;
- ::nana::string name() const;
+ ::std::string name() const;
unsigned size() const;
bool bold() const;
unsigned height() const;
@@ -89,13 +89,15 @@ namespace nana
void resize(const ::nana::size&);
void typeface(const font&); ///< Selects a specified font type into the graphics object.
font typeface() const;
- ::nana::size text_extent_size(const char_t*) const; ///< Computes the width and height of the specified string of text.
- ::nana::size text_extent_size(const string&) const; ///< Computes the width and height of the specified string of text.
- ::nana::size text_extent_size(const char_t*, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
- ::nana::size text_extent_size(const string&, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
- ::nana::size glyph_extent_size(const char_t*, std::size_t length, std::size_t begin, std::size_t end) const;
- ::nana::size glyph_extent_size(const string&, std::size_t length, std::size_t begin, std::size_t end) const;
- bool glyph_pixels(const char_t *, std::size_t length, unsigned* pxbuf) const;
+ ::nana::size text_extent_size(const ::std::string&) const;
+ ::nana::size text_extent_size(const char*, std::size_t len) const;
+ ::nana::size text_extent_size(const wchar_t*) const; ///< Computes the width and height of the specified string of text.
+ ::nana::size text_extent_size(const ::std::wstring&) const; ///< Computes the width and height of the specified string of text.
+ ::nana::size text_extent_size(const wchar_t*, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
+ ::nana::size text_extent_size(const ::std::wstring&, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
+ ::nana::size glyph_extent_size(const wchar_t*, std::size_t length, std::size_t begin, std::size_t end) const;
+ ::nana::size glyph_extent_size(const ::std::wstring&, std::size_t length, std::size_t begin, std::size_t end) const;
+ bool glyph_pixels(const wchar_t *, std::size_t length, unsigned* pxbuf) const;
::nana::size bidi_extent_size(const std::wstring&) const;
::nana::size bidi_extent_size(const std::string&) const;
@@ -136,13 +138,10 @@ namespace nana
/// @param file_utf8 A UTF-8 string to a filename
void save_as_file(const char* file_utf8) const throw();
- void set_color(const ::nana::color&); //deprecated, graphics::palette() instead
- void set_text_color(const ::nana::color&); //deprecated, graphics::palette() instead
-
::nana::color palette(bool for_text) const;
graphics& palette(bool for_text, const ::nana::color&);
- unsigned bidi_string(const nana::point&, const char_t *, std::size_t len);
+ unsigned bidi_string(const nana::point&, const wchar_t *, std::size_t len);
unsigned bidi_string(const point& pos, const char*, std::size_t len);
void blend(const ::nana::rectangle& r, const ::nana::color&, double fade_rate);
@@ -150,10 +149,13 @@ namespace nana
void set_pixel(int x, int y, const ::nana::color&);
void set_pixel(int x, int y);
- void string(point, const char_t*, std::size_t len);
- void string(const point&, const char_t*);
- void string(const point&, const ::nana::string&);
- void string(const point&, const ::nana::string&, const color&);
+ void string(const point&, const std::string& text_utf8);
+ void string(const point&, const std::string& text_utf8, const color&);
+
+ void string(point, const wchar_t*, std::size_t len);
+ void string(const point&, const wchar_t*);
+ void string(const point&, const ::std::wstring&);
+ void string(const point&, const ::std::wstring&, const color&);
void line(const point&, const point&);
void line(const point&, const point&, const color&);
diff --git a/include/nana/paint/image.hpp b/include/nana/paint/image.hpp
index b1c237bc..e3f0e37e 100644
--- a/include/nana/paint/image.hpp
+++ b/include/nana/paint/image.hpp
@@ -15,6 +15,7 @@
#define NANA_PAINT_IMAGE_HPP
#include "graphics.hpp"
+#include "../filesystem/filesystem.hpp"
namespace nana
{
@@ -31,12 +32,18 @@ namespace paint
image();
image(const image&);
image(image&&);
- image(const nana::char_t* file);
- image(const nana::string& filename);
+ image(const ::nana::experimental::filesystem::path& file);
+
+ template
+ image(const Source& source)
+ {
+ open(source);
+ }
+
~image();
image& operator=(const image& rhs);
image& operator=(image&&);
- bool open(const nana::string& filename);
+ bool open(const ::nana::experimental::filesystem::path& file);
/// Opens an icon from a specified buffer
bool open_icon(const void* data, std::size_t bytes);
diff --git a/include/nana/paint/text_renderer.hpp b/include/nana/paint/text_renderer.hpp
index 28bb4e8f..7234c57c 100644
--- a/include/nana/paint/text_renderer.hpp
+++ b/include/nana/paint/text_renderer.hpp
@@ -13,11 +13,11 @@ namespace nana
text_renderer(graph_reference graph, align = align::left);
- nana::size extent_size(int x, int y, const nana::char_t*, std::size_t len, unsigned restricted_pixels) const;
+ nana::size extent_size(int x, int y, const wchar_t*, std::size_t len, unsigned restricted_pixels) const;
- void render(const point&, const char_t*, std::size_t len);
- void render(const point&, const char_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
- void render(const point&, const char_t*, std::size_t len, unsigned restricted_pixels);
+ void render(const point&, const wchar_t*, std::size_t len);
+ void render(const point&, const wchar_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
+ void render(const point&, const wchar_t*, std::size_t len, unsigned restricted_pixels);
private:
graph_reference graph_;
align text_align_;
diff --git a/include/nana/system/dataexch.hpp b/include/nana/system/dataexch.hpp
index ecfe9b22..575a79c3 100644
--- a/include/nana/system/dataexch.hpp
+++ b/include/nana/system/dataexch.hpp
@@ -1,6 +1,6 @@
/*
* Data Exchanger 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
@@ -21,22 +21,26 @@ namespace paint{
}
namespace system{
- /// a data exchange mechanism through Windows Clipboard, X11 Selection.
+
+ /// a data exchange mechanism through Windows Clipboard, X11 Selection.
class dataexch
{
public:
- struct format
+ enum class format
{
- enum{ text, unicode, pixmap, end};
+ text, pixmap
};
- void set(const nana::char_t* text);
- void set(const nana::string& text);
+ void set(const std::string & text_utf8);
+ void set(const std::wstring& text);
+
bool set(const nana::paint::graphics& g);
- void get(nana::string& str);
+
+ void get(std::string& text_utf8);
+ void get(std::wstring& text);
private:
- bool _m_set(unsigned type, const void* buf, std::size_t size);
- void* _m_get(unsigned type, size_t& size);
+ bool _m_set(format, const void* buf, std::size_t size);
+ void* _m_get(format, size_t& size);
};
}//end namespace system
diff --git a/include/nana/system/platform.hpp b/include/nana/system/platform.hpp
index fd74f757..6a5f4ffd 100644
--- a/include/nana/system/platform.hpp
+++ b/include/nana/system/platform.hpp
@@ -38,7 +38,7 @@ namespace system
bool get_async_mouse_state(int button);
//open an url through a default browser
- void open_url(const nana::string& url);
+ void open_url(const std::string& url);
}//end namespace system
}//end namespace nana
diff --git a/include/nana/traits.hpp b/include/nana/traits.hpp
index d1c5c56e..ae27f9ff 100644
--- a/include/nana/traits.hpp
+++ b/include/nana/traits.hpp
@@ -1,6 +1,6 @@
/*
* Traits Implementation
- * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
+ * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* @file: nana/traits.hpp
*/
@@ -13,502 +13,24 @@ namespace nana
{
class null_type{};
- //The class noncopyable and nonmovable will be deprecated while the compiler
- //supports the deleted functions
- struct noncopyable
+ /// Prevent a class to be copyable
+ class noncopyable
{
noncopyable(const noncopyable&) = delete;
noncopyable& operator=(const noncopyable&) = delete;
- noncopyable();
+ protected:
+ noncopyable() = default;
};
- struct nonmovable
+ /// Prevent a class to be movable
+ class nonmovable
{
nonmovable(nonmovable&&) = delete;
nonmovable& operator=(nonmovable&&) = delete;
- nonmovable();
+ protected:
+ nonmovable() = default;
};
- namespace traits
- {
- //traits types for const-volatile specifier
-
- struct no_specifier{};
- struct const_specifier{};
- struct volatile_specifier{};
- struct const_volatile_specifier{};
-
- template
- struct cv_specifier
- {
- typedef no_specifier value_type;
- };
-
- template
- struct cv_specifier
- {
- typedef const_specifier value_type;
- };
-
- template
- struct cv_specifier
- {
- typedef volatile_specifier value_type;
- };
-
- template
- struct cv_specifier
- {
- typedef const_volatile_specifier value_type;
- };
-
- template
- struct is_function_pointer
- : public std::integral_constant::value && std::is_function::type>::value>
- {};
-
- //The traits of pointer to member function
- template
- struct mfptr_traits
- {
- typedef void function();
- typedef void return_type;
- typedef void concept_type;
- enum{parameter = 0};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef return_type function();
- enum{parameter = 0};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef return_type function();
- enum{parameter = 0};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef return_type function();
- enum{parameter = 0};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef return_type function();
- enum{parameter = 0};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P param0_type;
- typedef return_type function(param0_type);
- enum{parameter = 1};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P param0_type;
- typedef return_type function(param0_type);
- enum{parameter = 1};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P param0_type;
- typedef return_type function(param0_type);
- enum{parameter = 1};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef return_type function(param0_type, param1_type);
- enum{parameter = 2};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef return_type function(param0_type, param1_type);
- enum{parameter = 2};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef return_type function(param0_type, param1_type);
- enum{parameter = 2};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef return_type function(param0_type, param1_type, param2_type);
- enum{parameter =3};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef return_type function(param0_type, param1_type, param2_type);
- enum{parameter =3};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef return_type function(param0_type, param1_type, param2_type);
- enum{parameter =3};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef return_type function(param0_type, param1_type, param2_type);
- enum{parameter =3};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef P3 param3_type;
- typedef return_type function(param0_type, param1_type, param2_type, param3_type);
- enum{parameter = 4};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef P3 param3_type;
- typedef return_type function(param0_type, param1_type, param2_type, param3_type);
- enum{parameter = 4};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef P3 param3_type;
- typedef return_type function(param0_type, param1_type, param2_type, param3_type);
- enum{parameter = 4};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef P3 param3_type;
- typedef return_type function(param0_type, param1_type, param2_type, param3_type);
- enum{parameter = 4};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef P3 param3_type;
- typedef P4 param4_type;
- typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
- enum{parameter = 5};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef P3 param3_type;
- typedef P4 param4_type;
- typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
- enum{parameter = 5};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef P3 param3_type;
- typedef P4 param4_type;
- typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
- enum{parameter = 5};
- };
-
- template
- struct mfptr_traits
- {
- typedef Concept concept_type;
- typedef R return_type;
- typedef P0 param0_type;
- typedef P1 param1_type;
- typedef P2 param2_type;
- typedef P3 param3_type;
- typedef P4 param4_type;
- typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
- enum{parameter = 5};
- };
-
-
-
- template
- struct make_mf
- {
- typedef int type;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)();
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)() const;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)() volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)() const volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0);
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0) const;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0) volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0) const volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1);
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1) const;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1) volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1) const volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1, P2);
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1, P2) const;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1, P2) volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1, P2) const volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1, P2, P3);
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1, P2, P3) const;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1, P2, P3) volatile;
- };
-
- template
- struct make_mf
- {
- typedef R(Concept::*type)(P0, P1, P2, P3) const volatile;
- };
-
- template