remove macro STR

This commit is contained in:
Jinhao 2015-11-29 22:38:22 +08:00
parent 12358a5dc0
commit c86a00bea5
31 changed files with 410 additions and 331 deletions

View File

@ -89,14 +89,12 @@ namespace nana
typedef char char_t; typedef char char_t;
typedef std::string string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE typedef std::string string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE
} }
#define STR(string) string
#else #else
namespace nana namespace nana
{ {
typedef wchar_t char_t; typedef wchar_t char_t;
typedef std::wstring string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE typedef std::wstring string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE
} }
#define STR(string) L##string
#endif #endif
namespace nana namespace nana

View File

@ -39,9 +39,9 @@ namespace filesystem
#ifdef NANA_WINDOWS #ifdef NANA_WINDOWS
fileinfo(const WIN32_FIND_DATA& wfd); fileinfo(const WIN32_FIND_DATA& wfd);
#elif NANA_LINUX or NANA_MACOS #elif NANA_LINUX or NANA_MACOS
fileinfo(const nana::string& filename, const struct stat &); fileinfo(const ::std::string& filename, const struct stat &);
#endif #endif
nana::string name; ::std::string name;
unsigned long size; unsigned long size;
bool directory; bool directory;
@ -56,7 +56,7 @@ namespace filesystem
basic_file_iterator():end_(true), handle_(nullptr){} 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) :end_(false), handle_(nullptr)
{ {
_m_prepare(file_path); _m_prepare(file_path);
@ -92,14 +92,13 @@ namespace filesystem
return (*p == 0); return (*p == 0);
} }
void _m_prepare(const nana::string& file_path) void _m_prepare(const std::string& file_path)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
path_ = file_path; auto pat = utf8_cast(file_path);
auto pat = file_path;
DWORD attr = ::GetFileAttributes(pat.data()); DWORD attr = ::GetFileAttributes(pat.data());
if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY)) if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
pat += STR("\\*"); pat += L"\\*";
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_); ::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_);
@ -120,10 +119,11 @@ namespace filesystem
} }
value_ = value_type(wfd_); value_ = value_type(wfd_);
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
path_ = nana::charset(file_path); auto path = file_path;
if(path_.size() && (path_[path_.size() - 1] != '/')) if(path.size() && path.back() != '/')
path_ += '/'; path += '/';
find_handle_t handle = opendir(path_.c_str()); auto handle = opendir(path.c_str());
end_ = true; end_ = true;
if(handle) if(handle)
{ {
@ -141,7 +141,7 @@ namespace filesystem
} }
struct stat fst; struct stat fst;
if(stat((path_ + dnt->d_name).c_str(), &fst) == 0) if(stat((path + dnt->d_name).c_str(), &fst) == 0)
{ {
value_ = value_type(nana::charset(dnt->d_name), fst); value_ = value_type(nana::charset(dnt->d_name), fst);
} }
@ -226,9 +226,6 @@ namespace filesystem
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
WIN32_FIND_DATA wfd_; WIN32_FIND_DATA wfd_;
nana::string path_;
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
std::string path_;
#endif #endif
std::shared_ptr<find_handle_t> find_ptr_; std::shared_ptr<find_handle_t> find_ptr_;

View File

@ -136,29 +136,41 @@ namespace filesystem
class path class path
{ {
public: 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<value_type>;
path(); path();
path(const nana::string&); path(const value_type* source);
path(const string_type& source);
int compare(const path& other) const;
bool empty() const; bool empty() const;
path root() const; path parent_path() const;
file_type what() const; file_type what() const;
nana::string filename() const; path filename() const;
#if defined(NANA_WINDOWS)
public: const value_type*c_str() const;
nana::string to_string() const { return text_; } const string_type& native() const;
operator nana::string() const { return text_; } operator string_type() const;
private: private:
nana::string text_; string_type pathstr_;
#else
public:
std::string to_string() const { return text_; }
operator std::string() const { return text_; }
private:
std::string text_;
#endif
}; };
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 struct directory_entry
{ {
using path_type = filesystem::path; using path_type = filesystem::path;
@ -193,9 +205,7 @@ namespace filesystem
typedef std::input_iterator_tag iterator_category; typedef std::input_iterator_tag iterator_category;
directory_iterator():end_(true), handle_(nullptr){} directory_iterator():end_(true), handle_(nullptr){}
directory_iterator(const path& file_path) { _m_prepare(file_path); }
directory_iterator(const nana::string& file_path) { _m_prepare(file_path); }
directory_iterator(const path& file_path) { _m_prepare(file_path.filename()); }
const value_type& const value_type&
operator*() const { return value_; } operator*() const { return value_; }
@ -233,14 +243,14 @@ namespace filesystem
return (*p == 0); 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) #if defined(NANA_WINDOWS)
path_ = file_path; auto pat = path_;
auto pat = file_path;
DWORD attr = ::GetFileAttributes(pat.data()); DWORD attr = ::GetFileAttributes(pat.data());
if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY)) if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
pat += STR("\\*"); pat += L"\\*";
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_); ::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_);
@ -265,7 +275,6 @@ namespace filesystem
wfd_.nFileSizeLow); wfd_.nFileSizeLow);
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
path_ = nana::charset(file_path);
if(path_.size() && (path_[path_.size() - 1] != '/')) if(path_.size() && (path_[path_.size() - 1] != '/'))
path_ += '/'; path_ += '/';
find_handle_t handle = opendir(path_.c_str()); find_handle_t handle = opendir(path_.c_str());
@ -373,10 +382,9 @@ namespace filesystem
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
WIN32_FIND_DATA wfd_; WIN32_FIND_DATA wfd_;
nana::string path_;
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
std::string path_;
#endif #endif
path::string_type path_;
std::shared_ptr<find_handle_t> find_ptr_; std::shared_ptr<find_handle_t> find_ptr_;
find_handle_t handle_{nullptr}; find_handle_t handle_{nullptr};
value_type value_; value_type value_;
@ -453,12 +461,39 @@ namespace filesystem
//bool remove(const path& p); //bool remove(const path& p);
//bool remove(const path& p, error_code& ec) noexcept; //bool remove(const path& p, error_code& ec) noexcept;
bool rmfile(const nana::char_t* file); bool rmfile(const char* file);
//uintmax_t remove_all(const path& p); //uintmax_t remove_all(const path& p);
//uintmax_t remove_all(const path& p, error_code& ec) noexcept; //uintmax_t remove_all(const path& p, error_code& ec) noexcept;
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty); bool rmdir(const char* dir, bool fails_if_not_empty);
nana::string root(const nana::string& path); bool rmdir(const wchar_t* dir, bool fails_if_not_empty);
template<typename CharType>
std::basic_string<CharType> parent_path(const std::basic_string<CharType>& 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<CharType>();
}
}//end namespace filesystem }//end namespace filesystem

View File

@ -27,14 +27,14 @@ namespace filesystem
bool file_attrib(const ::std::string& file, attribute&); bool file_attrib(const ::std::string& file, attribute&);
long long filesize(const nana::string& file); long long filesize(const nana::string& file);
bool mkdir(const nana::string& dir, bool & if_exist); bool mkdir(const ::std::string& dir, bool & if_exist);
bool modified_file_time(const nana::string& file, struct tm&); bool modified_file_time(const nana::string& file, struct tm&);
nana::string path_user(); nana::string path_user();
nana::string path_current(); nana::string path_current();
bool rmfile(const nana::char_t* file); bool rmfile(const char* file_utf8);
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty); bool rmdir(const char* dir, bool fails_if_not_empty);
nana::string root(const nana::string& path); nana::string root(const nana::string& path);
class path class path

View File

@ -1,7 +1,7 @@
/* /*
* Forward Declarations * Forward Declarations
* Nana C++ Library(http://www.nanapro.org) * 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. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at

View File

@ -460,7 +460,7 @@ namespace nana
{ {
::nana::window window_handle; ///< A handle to the event window ::nana::window window_handle; ///< A handle to the event window
::nana::point pos; ///< cursor position in the event window ::nana::point pos; ///< cursor position in the event window
std::vector<nana::string> files; ///< external filenames std::vector<std::string> files; ///< external filenames
}; };
struct arg_expose : public event_arg 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 event_code evt_code; ///< it is event_code::key_press in current event
::nana::window window_handle; ///< A handle to the event window ::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 mutable bool ignore; ///< this member is not used
bool ctrl; ///< keyboard Ctrl is pressed? bool ctrl; ///< keyboard Ctrl is pressed?
bool shift; ///< keyboard Shift is pressed bool shift; ///< keyboard Shift is pressed

View File

@ -94,7 +94,7 @@ namespace nana
virtual ~renderer() = 0; virtual ~renderer() = 0;
virtual void background(graph_reference, window wd, const nana::rectangle&, const ui_element&) = 0; virtual void background(graph_reference, window wd, const nana::rectangle&, const ui_element&) = 0;
virtual void root_arrow(graph_reference, const nana::rectangle&, mouse_action) = 0; virtual void root_arrow(graph_reference, const nana::rectangle&, mouse_action) = 0;
virtual void item(graph_reference, const nana::rectangle&, std::size_t index, const nana::string& name, unsigned textheight, bool has_child, mouse_action) = 0; virtual void item(graph_reference, const nana::rectangle&, std::size_t index, const ::std::string& name, unsigned textheight, bool has_child, mouse_action) = 0;
virtual void border(graph_reference) = 0; virtual void border(graph_reference) = 0;
}; };
@ -115,8 +115,8 @@ namespace nana
//splitstr //splitstr
//@brief: Sets the splitstr. If the parameter will be ingored if it is an empty string. //@brief: Sets the splitstr. If the parameter will be ingored if it is an empty string.
void splitstr(const nana::string&); void splitstr(const ::std::string&);
const nana::string& splitstr() const; const ::std::string& splitstr() const;
void path(const ::std::string&); void path(const ::std::string&);
::std::string path() const; ::std::string path() const;

View File

@ -22,7 +22,7 @@ namespace detail
template<typename T> template<typename T>
struct tree_node struct tree_node
{ {
typedef std::pair<nana::string, T> value_type; typedef std::pair<std::string, T> value_type;
value_type value; value_type value;
@ -108,7 +108,7 @@ namespace detail
return (verify(node) && (node->owner != &root_) ? node->owner : nullptr); 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) if(node)
{ {
@ -121,7 +121,7 @@ namespace detail
return nullptr; 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) if(nullptr == node)
return insert(key, elem); return insert(key, elem);
@ -159,7 +159,7 @@ namespace detail
return nullptr; 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<true>(key); auto node = _m_locate<true>(key);
if(node) if(node)
@ -173,12 +173,12 @@ namespace detail
delete node; delete node;
} }
node_type* find(const nana::string& path) const node_type* find(const std::string& path) const
{ {
return _m_locate(path); return _m_locate(path);
} }
node_type* ref(const nana::string& path) node_type* ref(const std::string& path)
{ {
return _m_locate<true>(path); return _m_locate<true>(path);
} }
@ -303,7 +303,7 @@ namespace detail
} }
template<typename PredAllowChild> template<typename PredAllowChild>
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); auto node = _m_locate(key);
return (node ? child_size_if<PredAllowChild>(*node, pac) : 0); return (node ? child_size_if<PredAllowChild>(*node, pac) : 0);
@ -392,7 +392,7 @@ namespace detail
:node(&(self.root_)) :node(&(self.root_))
{} {}
bool operator()(const nana::string& key_node) bool operator()(const ::std::string& key_node)
{ {
node_type *child = node->child; node_type *child = node->child;
node_type *tail = nullptr; node_type *tail = nullptr;
@ -428,7 +428,7 @@ namespace detail
:node(&self.root_) :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); return ((node = _m_find(node->child, key_node)) != nullptr);
} }
@ -436,7 +436,7 @@ namespace detail
node_type *node; node_type *node;
}; };
private: 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) while(node)
{ {
@ -449,14 +449,14 @@ namespace detail
} }
template<typename Function> template<typename Function>
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()) if(key.size())
{ {
nana::string::size_type beg = 0; ::std::string::size_type beg = 0;
auto end = key.find_first_of(STR("\\/")); auto end = key.find_first_of("\\/");
while(end != nana::string::npos) while(end != ::std::string::npos)
{ {
if(beg != end) if(beg != end)
{ {
@ -464,11 +464,11 @@ namespace detail
return; return;
} }
auto next = key.find_first_not_of(STR("\\/"), end); auto next = key.find_first_not_of("\\/", end);
if(next != nana::string::npos) if(next != ::std::string::npos)
{ {
beg = next; beg = next;
end = key.find_first_of(STR("\\/"), beg); end = key.find_first_of("\\/", beg);
} }
else else
return; return;
@ -479,7 +479,7 @@ namespace detail
} }
template<bool CreateIfNotExists> template<bool CreateIfNotExists>
node_type* _m_locate(const nana::string& key) node_type* _m_locate(const ::std::string& key)
{ {
if(key.size()) if(key.size())
{ {
@ -499,7 +499,7 @@ namespace detail
return &root_; return &root_;
} }
node_type* _m_locate(const nana::string& key) const node_type* _m_locate(const std::string& key) const
{ {
if(key.size()) if(key.size())
{ {

View File

@ -449,8 +449,8 @@ namespace nana
struct export_options struct export_options
{ {
nana::string sep = nana::string {STR("\t" )}, nana::string sep = nana::string {L"\t"},
endl= nana::string {STR("\n")}; endl= nana::string {L"\n"};
bool only_selected_items{true}, bool only_selected_items{true},
only_checked_items {false}, only_checked_items {false},
only_visible_columns{true}; only_visible_columns{true};

View File

@ -281,45 +281,45 @@ namespace nana{ namespace widgets{ namespace skeletons
//Here is a identifier //Here is a identifier
_m_read_idstr(); _m_read_idstr();
if(STR("font") == idstr_) if(L"font" == idstr_)
return token::font; return token::font;
else if(STR("bold") == idstr_) else if(L"bold" == idstr_)
return token::bold; return token::bold;
else if(STR("size") == idstr_) else if(L"size" == idstr_)
return token::size; return token::size;
else if(STR("baseline") == idstr_) else if(L"baseline" == idstr_)
return token::baseline; return token::baseline;
else if(STR("top") == idstr_) else if(L"top" == idstr_)
return token::top; return token::top;
else if(STR("center") == idstr_) else if(L"center" == idstr_)
return token::center; return token::center;
else if(STR("bottom") == idstr_) else if(L"bottom" == idstr_)
return token::bottom; return token::bottom;
else if(STR("color") == idstr_) else if(L"color" == idstr_)
return token::color; return token::color;
else if(STR("image") == idstr_) else if(L"image" == idstr_)
return token::image; return token::image;
else if(STR("true") == idstr_) else if(L"true" == idstr_)
return token::_true; return token::_true;
else if(STR("url") == idstr_) else if(L"url" == idstr_)
return token::url; return token::url;
else if(STR("target") == idstr_) else if(L"target" == idstr_)
return token::target; return token::target;
else if(STR("false") == idstr_) else if(L"false" == idstr_)
return token::_false; return token::_false;
else if(STR("red") == idstr_) else if(L"red" == idstr_)
return token::red; return token::red;
else if(STR("green") == idstr_) else if(L"green" == idstr_)
return token::green; return token::green;
else if(STR("blue") == idstr_) else if(L"blue" == idstr_)
return token::blue; return token::blue;
else if(STR("white") == idstr_) else if(L"white" == idstr_)
return token::white; return token::white;
else if(STR("black") == idstr_) else if(L"black" == idstr_)
return token::black; return token::black;
else if(STR("min_limited") == idstr_) else if(L"min_limited" == idstr_)
return token::min_limited; return token::min_limited;
else if(STR("max_limited") == idstr_) else if(L"max_limited" == idstr_)
return token::max_limited; return token::max_limited;
return token::string; return token::string;

View File

@ -140,8 +140,6 @@ namespace nana
: public drawer_trigger : public drawer_trigger
{ {
public: public:
//enum toolbox_button_t{ButtonAdd, ButtonScroll, ButtonList, ButtonClose}; //deprecated
enum class kits enum class kits
{ {
add, add,

View File

@ -55,7 +55,7 @@ namespace nana
nana::paint::image icon_normal; nana::paint::image icon_normal;
nana::paint::image icon_hover; nana::paint::image icon_hover;
nana::paint::image icon_expanded; nana::paint::image icon_expanded;
nana::string text; ::std::string text;
}; };
typedef widgets::detail::compset<component, node_attribute> compset_interface; typedef widgets::detail::compset<component, node_attribute> compset_interface;
@ -98,14 +98,14 @@ namespace nana
struct treebox_node_type struct treebox_node_type
{ {
treebox_node_type(); treebox_node_type();
treebox_node_type(nana::string); treebox_node_type(std::string);
treebox_node_type& operator=(const treebox_node_type&); treebox_node_type& operator=(const treebox_node_type&);
nana::string text; ::std::string text;
nana::any value; nana::any value;
bool expanded; bool expanded;
checkstate checked; checkstate checked;
nana::string img_idstr; ::std::string img_idstr;
}; };
struct pseudo_node_type{}; struct pseudo_node_type{};
@ -133,8 +133,8 @@ namespace nana
const ::nana::pat::cloneable<compset_placer_interface>& placer() const; const ::nana::pat::cloneable<compset_placer_interface>& placer() const;
nana::any & value(node_type*) const; nana::any & value(node_type*) const;
node_type* insert(node_type*, const nana::string& key, nana::string&&); node_type* insert(node_type*, const std::string& key, std::string&&);
node_type* insert(const nana::string& path, nana::string&&); node_type* insert(const std::string& path, std::string&&);
bool verify(const void*) const; bool verify(const void*) const;
bool verify_kinship(node_type* parent, node_type* child) const; bool verify_kinship(node_type* parent, node_type* child) const;
@ -143,16 +143,15 @@ namespace nana
node_type * selected() const; node_type * selected() const;
void selected(node_type*); void selected(node_type*);
void set_expand(node_type*, bool); 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 ::std::string&) const;
node_image_tag& icon(const nana::string&) const; void icon_erase(const ::std::string&);
void icon_erase(const nana::string&); void node_icon(node_type*, const ::std::string& id);
void node_icon(node_type*, const nana::string& id);
unsigned node_width(const node_type*) const; 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: private:
//Overrides drawer_trigger methods //Overrides drawer_trigger methods
void attached(widget_reference, graph_reference) override; void attached(widget_reference, graph_reference) override;
@ -182,11 +181,11 @@ namespace nana
item_proxy(trigger*, trigger::node_type*); item_proxy(trigger*, trigger::node_type*);
/// Append a child. /// 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.). /// Append a child with a specified value (user object.).
template<typename T> template<typename T>
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)); item_proxy ip = append(key, std::move(name));
if(false == ip.empty()) if(false == ip.empty())
@ -220,22 +219,22 @@ namespace nana
item_proxy& select(bool); item_proxy& select(bool);
/// Return the icon. /// Return the icon.
const nana::string& icon() const; const ::std::string& icon() const;
/// Set the icon, and returns itself.. /// Set the icon, and returns itself..
item_proxy& icon(const nana::string& id); item_proxy& icon(const ::std::string& id);
/// Return the text. /// Return the text.
const nana::string& text() const; const ::std::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;
/// Set the text, and returns itself. /// 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. 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. /// 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<bool(item_proxy)> action); item_proxy visit_recursively(std::function<bool(item_proxy)> 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 char* s ) const; ///< Compare the text of node with s.
bool operator==(const wchar_t* 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'. /// These states are 'normal', 'hovered' and 'expanded'.
/// If 'hovered' or 'expanded' are not set, it uses 'normal' state image for these 2 states. /// 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) /// 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; ) 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. /// 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 item_proxy insert(const ::std::string& path_key, ///< specifies the node hierarchy
nana::string title ///< used for displaying ::std::string title ///< used for displaying
); );
/// Inserts a new node to treebox, but if the keypath exists returns the existing node. /// 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 item_proxy insert( item_proxy pos, ///< the parent item node
const nana::string& key, ///< specifies the new node const ::std::string& key, ///< specifies the new node
nana::string title ///< title used for displaying in 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 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;///<returns the key path ::std::string make_key_path(item_proxy i, const ::std::string& splitter) const;///<returns the key path
item_proxy selected() const; ///< returns the selected node item_proxy selected() const; ///< returns the selected node
};//end class treebox };//end class treebox
}//end namespace nana }//end namespace nana

View File

@ -151,7 +151,9 @@ namespace nana
void set_pixel(int x, int y, const ::nana::color&); void set_pixel(int x, int y, const ::nana::color&);
void set_pixel(int x, int y); void set_pixel(int x, int y);
void string(const point&, const std::string&); void string(const point&, const std::string& text_utf8);
void string(const point&, const std::string& text_utf8, const color&);
void string(point, const char_t*, std::size_t len); void string(point, const char_t*, std::size_t len);
void string(const point&, const char_t*); void string(const point&, const char_t*);
void string(const point&, const ::nana::string&); void string(const point&, const ::nana::string&);

View File

@ -154,7 +154,7 @@ namespace detail
//class platform_spec //class platform_spec
platform_spec::co_initializer::co_initializer() platform_spec::co_initializer::co_initializer()
: ole32_(::LoadLibrary(STR("OLE32.DLL"))) : ole32_(::LoadLibrary(L"OLE32.DLL"))
{ {
if(ole32_) if(ole32_)
{ {

View File

@ -24,12 +24,12 @@ namespace filesystem
{} {}
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
fileinfo::fileinfo(const WIN32_FIND_DATA& wfd) fileinfo::fileinfo(const WIN32_FIND_DATA& wfd)
: name(wfd.cFileName), size(wfd.nFileSizeLow), : name(utf8_cast(wfd.cFileName)), size(wfd.nFileSizeLow),
directory((FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) directory((FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY)
{ {
} }
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
fileinfo::fileinfo(const nana::string& name, const struct stat& fst) fileinfo::fileinfo(const ::std::string& name, const struct stat& fst)
:name(name), size(fst.st_size), directory(0 != S_ISDIR(fst.st_mode)) :name(name), size(fst.st_size), directory(0 != S_ISDIR(fst.st_mode))
{ {
} }

View File

@ -43,51 +43,50 @@ namespace nana {
{ {
//Because of No wide character version of POSIX //Because of No wide character version of POSIX
#if defined(NANA_LINUX) || defined(NANA_MACOS) #if defined(NANA_LINUX) || defined(NANA_MACOS)
typedef std::string string_t; const char* splstr = "/";
const char* splstr = "/\\";
#else #else
typedef nana::string string_t; const wchar_t* splstr = L"/\\";
const nana::char_t* splstr = STR("/\\");
#endif #endif
//class path //class path
path::path() {} path::path() {}
path::path(const nana::string& text) path::path(const value_type* source)
#if defined(NANA_WINDOWS) : path(string_type{ source })
: text_(text) {}
path::path(const string_type& source)
: pathstr_(source)
{ {
#else auto pos = pathstr_.find_last_of(splstr);
:text_(nana::charset(text)) for (; (pos != string_type::npos) && (pos + 1 == pathstr_.size()); pos = pathstr_.find_last_of(splstr))
pathstr_.erase(pos);
}
int path::compare(const path& p) const
{ {
#endif return pathstr_.compare(p.pathstr_);
auto pos = text_.find_last_of(splstr);
for (; (pos != string_t::npos) && (pos + 1 == text_.size()); pos = text_.find_last_of(splstr))
text_.erase(pos);
} }
bool path::empty() const bool path::empty() const
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
return (::GetFileAttributes(text_.c_str()) == INVALID_FILE_ATTRIBUTES); return (::GetFileAttributes(pathstr_.c_str()) == INVALID_FILE_ATTRIBUTES);
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
struct stat sta; struct stat sta;
return (::stat(text_.c_str(), &sta) == -1); return (::stat(pathstr_.c_str(), &sta) == -1);
#endif #endif
} }
path path::root() const path path::parent_path() const
{ {
#if defined(NANA_WINDOWS) return{filesystem::parent_path(pathstr_)};
return path(filesystem::root(text_));
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
return path(filesystem::root(nana::charset(text_)));
#endif
} }
file_type path::what() const file_type path::what() const
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
unsigned long attr = ::GetFileAttributes(text_.c_str()); unsigned long attr = ::GetFileAttributes(pathstr_.c_str());
if (INVALID_FILE_ATTRIBUTES == attr) if (INVALID_FILE_ATTRIBUTES == attr)
return file_type::not_found; //?? return file_type::not_found; //??
@ -97,7 +96,7 @@ namespace nana {
return file_type::regular; return file_type::regular;
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
struct stat sta; struct stat sta;
if (-1 == ::stat(text_.c_str(), &sta)) if (-1 == ::stat(pathstr_.c_str(), &sta))
return file_type::not_found; //?? return file_type::not_found; //??
if ((S_IFDIR & sta.st_mode) == S_IFDIR) if ((S_IFDIR & sta.st_mode) == S_IFDIR)
@ -110,38 +109,85 @@ namespace nana {
#endif #endif
} }
nana::string path::filename() const path path::filename() const
{ {
string_t::size_type pos = text_.find_last_of(splstr); auto pos = pathstr_.find_last_of(splstr);
#if defined(NANA_WINDOWS) if (pos != pathstr_.npos)
return text_.substr(pos + 1); {
#else if (pos + 1 == pathstr_.size())
return nana::charset(text_.substr(pos + 1)); {
#endif value_type tmp[2] = {preferred_separator, 0};
if (pathstr_.npos != pathstr_.find_last_not_of(splstr, pos))
tmp[0] = '.';
return{ tmp };
}
return{ pathstr_.substr(pos + 1) };
}
return{ pathstr_ };
}
const path::value_type* path::c_str() const
{
return native().c_str();
}
const path::string_type& path::native() const
{
return pathstr_;
}
path::operator string_type() const
{
return native();
} }
//end class path //end class path
bool operator==(const path& lhs, const path& rhs)
{
return (lhs.compare(rhs) == 0);
}
bool operator!=(const path& lhs, const path& rhs)
{
return (lhs.native() != rhs.native());
}
bool operator<(const path& lhs, const path& rhs)
{
return (lhs.compare(rhs) < 0);
}
bool operator>(const path& lhs, const path& rhs)
{
return (rhs.compare(lhs) < 0);
}
namespace detail namespace detail
{ {
//rm_dir_recursive //rm_dir_recursive
//@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories //@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories
bool rm_dir_recursive(nana::string&& dir) template<typename CharT>
bool rm_dir_recursive(const CharT* dir)
{ {
std::vector<directory_iterator::value_type> files; std::vector<directory_iterator::value_type> files;
nana::string path = dir; std::basic_string<CharT> path = dir;
path += '\\'; path += '\\';
std::copy(directory_iterator(dir), directory_iterator(), std::back_inserter(files)); std::copy(directory_iterator(dir), directory_iterator(), std::back_inserter(files));
for (auto & f : files) for (auto & f : files)
{ {
auto subpath = path + f.path().filename().native();
if (f.attr.directory) if (f.attr.directory)
rm_dir_recursive(path + f.path().filename()); rm_dir_recursive(subpath.c_str());
else else
rmfile((path + f.path().filename()).c_str()); rmfile(subpath.c_str());
} }
return rmdir(dir.c_str(), true); return rmdir(dir, true);
} }
bool mkdir_helper(const nana::string& dir, bool & if_exist) bool mkdir_helper(const nana::string& dir, bool & if_exist)
@ -299,7 +345,7 @@ namespace nana {
nana::string root; nana::string root;
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
if (path.size() > 3 && path[1] == STR(':')) if (path.size() > 3 && path[1] == L':')
root = path.substr(0, 3); root = path.substr(0, 3);
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
if (path[0] == STR('/')) if (path[0] == STR('/'))
@ -310,11 +356,11 @@ namespace nana {
while (true) while (true)
{ {
beg = path.find_first_not_of(STR("/\\"), beg); beg = path.find_first_not_of(L"/\\", beg);
if (beg == path.npos) if (beg == path.npos)
break; break;
std::size_t pos = path.find_first_of(STR("/\\"), beg + 1); std::size_t pos = path.find_first_of(L"/\\", beg + 1);
if (pos != path.npos) if (pos != path.npos)
{ {
root += path.substr(beg, pos - beg); root += path.substr(beg, pos - beg);
@ -324,9 +370,9 @@ namespace nana {
return false; return false;
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
root += STR('\\'); root += L'\\';
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
root += STR('/'); root += L'/';
#endif #endif
} }
else else
@ -362,18 +408,18 @@ namespace nana {
#endif #endif
} }
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty) bool rmdir(const char* dir_utf8, bool fails_if_not_empty)
{ {
bool ret = false; bool ret = false;
if (dir) if (dir_utf8)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
ret = (::RemoveDirectory(dir) == TRUE); auto dir = utf8_cast(dir_utf8);
ret = (::RemoveDirectory(dir.c_str()) == TRUE);
if (!fails_if_not_empty && (::GetLastError() == ERROR_DIR_NOT_EMPTY)) if (!fails_if_not_empty && (::GetLastError() == ERROR_DIR_NOT_EMPTY))
ret = detail::rm_dir_recursive(dir); ret = detail::rm_dir_recursive(dir.c_str());
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
std::string mbstr = nana::charset(dir); if (::rmdir(dir_utf8))
if (::rmdir(mbstr.c_str()))
{ {
if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY)) if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
ret = detail::rm_dir_recursive(dir); ret = detail::rm_dir_recursive(dir);
@ -385,30 +431,26 @@ namespace nana {
return ret; return ret;
} }
nana::string root(const nana::string& path) bool rmdir(const wchar_t* dir, bool fails_if_not_empty)
{ {
std::size_t index = path.size(); bool ret = false;
if (dir)
if (index)
{ {
const nana::char_t * str = path.c_str(); #if defined(NANA_WINDOWS)
ret = (::RemoveDirectory(dir) == TRUE);
for (--index; index > 0; --index) if (!fails_if_not_empty && (::GetLastError() == ERROR_DIR_NOT_EMPTY))
ret = detail::rm_dir_recursive(dir);
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
if (::rmdir(utf8_cast(dir).c_str()))
{ {
nana::char_t c = str[index]; if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
if (c != '\\' && c != '/') ret = detail::rm_dir_recursive(dir);
break;
} }
else
for (--index; index > 0; --index) ret = true;
{ #endif
nana::char_t c = str[index];
if (c == '\\' || c == '/')
break;
} }
} return ret;
return index ? path.substr(0, index + 1) : nana::string();
} }
nana::string path_user() nana::string path_user()

View File

@ -13,6 +13,7 @@
#include <nana/filesystem/fs_utility.hpp> #include <nana/filesystem/fs_utility.hpp>
#include <nana/filesystem/file_iterator.hpp> #include <nana/filesystem/file_iterator.hpp>
#include <nana/deploy.hpp>
#include <vector> #include <vector>
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
#include <windows.h> #include <windows.h>
@ -47,7 +48,7 @@ namespace filesystem
const char* splstr = "/\\"; const char* splstr = "/\\";
#else #else
typedef nana::string string_t; typedef nana::string string_t;
const nana::char_t* splstr = STR("/\\"); const nana::char_t* splstr = L"/\\";
#endif #endif
//class path //class path
path::path(){} path::path(){}
@ -125,10 +126,10 @@ namespace filesystem
{ {
//rm_dir_recursive //rm_dir_recursive
//@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories //@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories
bool rm_dir_recursive(nana::string&& dir) bool rm_dir_recursive(std::string&& dir)
{ {
std::vector<file_iterator::value_type> files; std::vector<file_iterator::value_type> files;
nana::string path = dir; auto path = dir;
path += '\\'; path += '\\';
std::copy(file_iterator(dir), file_iterator(), std::back_inserter(files)); std::copy(file_iterator(dir), file_iterator(), std::back_inserter(files));
@ -144,10 +145,10 @@ namespace filesystem
return rmdir(dir.c_str(), true); return rmdir(dir.c_str(), true);
} }
bool mkdir_helper(const nana::string& dir, bool & if_exist) bool mkdir_helper(const std::string& dir, bool & if_exist)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
if(::CreateDirectory(dir.c_str(), 0)) if(::CreateDirectory(utf8_cast(dir).c_str(), 0))
{ {
if_exist = false; if_exist = false;
return true; return true;
@ -155,7 +156,7 @@ namespace filesystem
if_exist = (::GetLastError() == ERROR_ALREADY_EXISTS); if_exist = (::GetLastError() == ERROR_ALREADY_EXISTS);
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
if(0 == ::mkdir(static_cast<std::string>(nana::charset(dir)).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) if(0 == ::mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
{ {
if_exist = false; if_exist = false;
return true; return true;
@ -288,14 +289,14 @@ namespace filesystem
return false; return false;
} }
bool mkdir(const nana::string& path, bool & if_exist) bool mkdir(const std::string& path, bool & if_exist)
{ {
if_exist = false; if_exist = false;
if(path.size() == 0) return false; if(path.size() == 0) return false;
nana::string root; std::string root;
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
if(path.size() > 3 && path[1] == STR(':')) if(path.size() > 3 && path[1] == ':')
root = path.substr(0, 3); root = path.substr(0, 3);
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
if(path[0] == STR('/')) if(path[0] == STR('/'))
@ -306,11 +307,11 @@ namespace filesystem
while(true) while(true)
{ {
beg = path.find_first_not_of(STR("/\\"), beg); beg = path.find_first_not_of("/\\", beg);
if(beg == path.npos) if(beg == path.npos)
break; break;
std::size_t pos = path.find_first_of(STR("/\\"), beg + 1); std::size_t pos = path.find_first_of("/\\", beg + 1);
if(pos != path.npos) if(pos != path.npos)
{ {
root += path.substr(beg, pos - beg); root += path.substr(beg, pos - beg);
@ -320,9 +321,9 @@ namespace filesystem
return false; return false;
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
root += STR('\\'); root += L'\\';
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
root += STR('/'); root += L'/';
#endif #endif
} }
else else
@ -339,32 +340,32 @@ namespace filesystem
return mkstat; return mkstat;
} }
bool rmfile(const nana::char_t* file) bool rmfile(const char* file)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
bool ret = false; bool ret = false;
if(file) if(file)
{ {
ret = (::DeleteFile(file) == TRUE); ret = (::DeleteFile(utf8_cast(file).c_str()) == TRUE);
if(!ret) if(!ret)
ret = (ERROR_FILE_NOT_FOUND == ::GetLastError()); ret = (ERROR_FILE_NOT_FOUND == ::GetLastError());
} }
return ret; return ret;
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
if(std::remove(static_cast<std::string>(nana::charset(file)).c_str())) if(std::remove(file))
return (errno == ENOENT); return (errno == ENOENT);
return true; return true;
#endif #endif
} }
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty) bool rmdir(const char* dir, bool fails_if_not_empty)
{ {
bool ret = false; bool ret = false;
if(dir) if(dir)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
ret = (::RemoveDirectory(dir) == TRUE); ret = (::RemoveDirectory(utf8_cast(dir).c_str()) == TRUE);
if(!fails_if_not_empty && (::GetLastError() == ERROR_DIR_NOT_EMPTY)) if(!fails_if_not_empty && (::GetLastError() == ERROR_DIR_NOT_EMPTY))
ret = detail::rm_dir_recursive(dir); ret = detail::rm_dir_recursive(dir);
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)

View File

@ -202,7 +202,7 @@ namespace nana{
if(owner && (nested == false)) if(owner && (nested == false))
::ClientToScreen(reinterpret_cast<HWND>(owner), &pt); ::ClientToScreen(reinterpret_cast<HWND>(owner), &pt);
HWND native_wd = ::CreateWindowEx(style_ex, STR("NanaWindowInternal"), STR("Nana Window"), HWND native_wd = ::CreateWindowEx(style_ex, L"NanaWindowInternal", L"Nana Window",
style, style,
pt.x, pt.y, 100, 100, pt.x, pt.y, 100, 100,
reinterpret_cast<HWND>(owner), 0, ::GetModuleHandle(0), 0); reinterpret_cast<HWND>(owner), 0, ::GetModuleHandle(0), 0);
@ -377,8 +377,8 @@ namespace nana{
if(nullptr == parent) return nullptr; if(nullptr == parent) return nullptr;
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
HWND handle = ::CreateWindowEx(WS_EX_CONTROLPARENT, // Extended possibilites for variation HWND handle = ::CreateWindowEx(WS_EX_CONTROLPARENT, // Extended possibilites for variation
STR("NanaWindowInternal"), L"NanaWindowInternal",
STR("Nana Child Window"), // Title Text L"Nana Child Window", // Title Text
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS,
r.x, r.y, r.width, r.height, r.x, r.y, r.width, r.height,
reinterpret_cast<HWND>(parent), // The window is a child-window to desktop reinterpret_cast<HWND>(parent), // The window is a child-window to desktop

View File

@ -214,7 +214,7 @@ namespace detail
WNDCLASSEX wincl; WNDCLASSEX wincl;
wincl.hInstance = ::GetModuleHandle(0); wincl.hInstance = ::GetModuleHandle(0);
wincl.lpszClassName = STR("NanaWindowInternal"); wincl.lpszClassName = L"NanaWindowInternal";
wincl.lpfnWndProc = &Bedrock_WIN32_WindowProc; wincl.lpfnWndProc = &Bedrock_WIN32_WindowProc;
wincl.style = CS_DBLCLKS | CS_OWNDC; wincl.style = CS_DBLCLKS | CS_OWNDC;
wincl.cbSize = sizeof(wincl); wincl.cbSize = sizeof(wincl);
@ -1175,7 +1175,7 @@ namespace detail
{ {
arg_dropfiles dropfiles; arg_dropfiles dropfiles;
std::unique_ptr<nana::char_t[]> varbuf; std::unique_ptr<wchar_t[]> varbuf;
std::size_t bufsize = 0; std::size_t bufsize = 0;
unsigned size = ::DragQueryFile(drop, 0xFFFFFFFF, 0, 0); unsigned size = ::DragQueryFile(drop, 0xFFFFFFFF, 0, 0);
@ -1189,7 +1189,8 @@ namespace detail
} }
::DragQueryFile(drop, i, varbuf.get(), reqlen); ::DragQueryFile(drop, i, varbuf.get(), reqlen);
dropfiles.files.emplace_back(varbuf.get());
dropfiles.files.emplace_back(utf8_cast(varbuf.get()));
} }
while(msgwnd && (msgwnd->flags.dropable == false)) while(msgwnd && (msgwnd->flags.dropable == false))

View File

@ -105,7 +105,7 @@ namespace nana
arrow.draw(graph, {}, style_.fgcolor, arrow_r, element_state::normal); arrow.draw(graph, {}, style_.fgcolor, arrow_r, element_state::normal);
} }
void item(graph_reference graph, const nana::rectangle& r, std::size_t index, const nana::string& name, unsigned txtheight, bool has_child, mouse_action state) void item(graph_reference graph, const nana::rectangle& r, std::size_t index, const std::string& name_utf8, unsigned txtheight, bool has_child, mouse_action state)
{ {
nana::point strpos(r.x + 5, r.y + static_cast<int>(r.height - txtheight) / 2); nana::point strpos(r.x + 5, r.y + static_cast<int>(r.height - txtheight) / 2);
@ -141,7 +141,7 @@ namespace nana
_m_item_bground(graph, r.x + 1, top, width, height, state_name); _m_item_bground(graph, r.x + 1, top, width, height, state_name);
graph.rectangle(r, false, clr); graph.rectangle(r, false, clr);
} }
graph.string(strpos, name, style_.fgcolor); graph.string(strpos, name_utf8, style_.fgcolor);
if(has_child) if(has_child)
{ {
@ -218,7 +218,7 @@ namespace nana
using node_handle = container::node_type*; using node_handle = container::node_type*;
tree_wrapper() tree_wrapper()
:splitstr_(STR("\\")), cur_(nullptr) : splitstr_("\\")
{} {}
bool seq(std::size_t index, std::vector<node_handle> & seqv) const bool seq(std::size_t index, std::vector<node_handle> & seqv) const
@ -234,23 +234,23 @@ namespace nana
return false; return false;
} }
void splitstr(const nana::string& ss) void splitstr(const std::string& ss)
{ {
if(ss.size()) if(ss.size())
splitstr_ = ss; splitstr_ = ss;
} }
const nana::string& splitstr() const const std::string& splitstr() const
{ {
return splitstr_; return splitstr_;
} }
nana::string path() const std::string path() const
{ {
std::vector<node_handle> v; std::vector<node_handle> v;
_m_read_node_path(v); _m_read_node_path(v);
nana::string str; std::string str;
bool not_head = false; bool not_head = false;
for(auto i : v) for(auto i : v)
{ {
@ -263,7 +263,7 @@ namespace nana
return str; return str;
} }
void path(const nana::string& key) void path(const std::string& key)
{ {
cur_ = tree_.ref(key); cur_ = tree_.ref(key);
} }
@ -292,7 +292,7 @@ namespace nana
cur_ = i; cur_ = i;
} }
void insert(const nana::string& name, const nana::any& value) void insert(const std::string& name, const nana::any& value)
{ {
item_tag m; item_tag m;
m.pixels = 0; m.pixels = 0;
@ -300,7 +300,7 @@ namespace nana
cur_ = tree_.insert(cur_, name, m); cur_ = tree_.insert(cur_, name, m);
} }
bool childset(const nana::string& name, const nana::any& value) bool childset(const std::string& name, const nana::any& value)
{ {
if(cur_) if(cur_)
{ {
@ -313,7 +313,7 @@ namespace nana
return false; return false;
} }
bool childset_erase(const nana::string& name) bool childset_erase(const std::string& name)
{ {
if(cur_) if(cur_)
{ {
@ -329,7 +329,7 @@ namespace nana
return false; return false;
} }
node_handle find_child(const nana::string& name) const node_handle find_child(const std::string& name) const
{ {
if(cur_) if(cur_)
{ {
@ -360,8 +360,8 @@ namespace nana
} }
private: private:
container tree_; container tree_;
nana::string splitstr_; std::string splitstr_ ;
node_handle cur_; node_handle cur_{ nullptr };
}; };
//class scheme //class scheme
@ -543,7 +543,7 @@ namespace nana
{ {
if(node) if(node)
{ {
API::dev::window_caption(window_handle(), utf8_cast(tree().path())); API::dev::window_caption(window_handle(), tree().path());
if(evt_holder_.selected) if(evt_holder_.selected)
evt_holder_.selected(node->value.second.value); evt_holder_.selected(node->value.second.value);
} }
@ -565,7 +565,7 @@ namespace nana
if(i) if(i)
{ {
for(node_handle child = i->child; child; child = child->next) for(node_handle child = i->child; child; child = child->next)
style_.module.items.emplace_back(std::make_shared<item>(utf8_cast(child->value.first))); style_.module.items.emplace_back(std::make_shared<item>(child->value.first));
} }
r = style_.active_item_rectangle; r = style_.active_item_rectangle;
} }
@ -576,7 +576,7 @@ namespace nana
{ {
auto end = v.cbegin() + head_; auto end = v.cbegin() + head_;
for(auto i = v.cbegin(); i != end; ++i) for(auto i = v.cbegin(); i != end; ++i)
style_.module.items.emplace_back(std::make_shared<item>(utf8_cast((*i)->value.first))); style_.module.items.emplace_back(std::make_shared<item>((*i)->value.first));
} }
r = style_.active_item_rectangle; r = style_.active_item_rectangle;
} }
@ -603,8 +603,7 @@ namespace nana
case ui_element::item_arrow: case ui_element::item_arrow:
{ {
treebase_.tail(style_.active); treebase_.tail(style_.active);
nana::string name = utf8_cast(style_.module.items[style_.module.index]->text()); node_handle node = treebase_.find_child(style_.module.items[style_.module.index]->text());
node_handle node = treebase_.find_child(name);
if(node) if(node)
{ {
treebase_.cur(node); treebase_.cur(node);
@ -769,7 +768,6 @@ namespace nana
private: private:
window window_{nullptr}; window window_{nullptr};
nana::paint::graphics * graph_{nullptr}; nana::paint::graphics * graph_{nullptr};
nana::string splitstr_;
std::size_t head_; std::size_t head_;
unsigned item_height_; unsigned item_height_;
std::size_t item_lines_; std::size_t item_lines_;
@ -808,14 +806,14 @@ namespace nana
void trigger::insert(const std::string& str, nana::any value) void trigger::insert(const std::string& str, nana::any value)
{ {
throw_not_utf8(str); throw_not_utf8(str);
scheme_->tree().insert(utf8_cast(str), value); scheme_->tree().insert(str, value);
API::dev::window_caption(scheme_->window_handle(), utf8_cast(scheme_->tree().path())); API::dev::window_caption(scheme_->window_handle(), scheme_->tree().path());
scheme_->draw(); scheme_->draw();
} }
bool trigger::childset(const std::string& str, nana::any value) bool trigger::childset(const std::string& str, nana::any value)
{ {
if(scheme_->tree().childset(utf8_cast(str), value)) if(scheme_->tree().childset(str, value))
{ {
scheme_->draw(); scheme_->draw();
return true; return true;
@ -825,7 +823,7 @@ namespace nana
bool trigger::childset_erase(const std::string& str) bool trigger::childset_erase(const std::string& str)
{ {
if(scheme_->tree().childset_erase(utf8_cast(str))) if(scheme_->tree().childset_erase(str))
{ {
scheme_->draw(); scheme_->draw();
return true; return true;
@ -843,24 +841,24 @@ namespace nana
return false; return false;
} }
void trigger::splitstr(const nana::string& sstr) void trigger::splitstr(const std::string& sstr)
{ {
scheme_->tree().splitstr(sstr); scheme_->tree().splitstr(sstr);
} }
const nana::string& trigger::splitstr() const const std::string& trigger::splitstr() const
{ {
return scheme_->tree().splitstr(); return scheme_->tree().splitstr();
} }
void trigger::path(const std::string& str) void trigger::path(const std::string& str)
{ {
scheme_->tree().path(utf8_cast(str)); scheme_->tree().path(str);
} }
std::string trigger::path() const std::string trigger::path() const
{ {
return utf8_cast(scheme_->tree().path()); return scheme_->tree().path();
} }
nana::any& trigger::value() const nana::any& trigger::value() const

View File

@ -49,7 +49,7 @@ namespace checkbox
{ {
_m_draw_background(graph); _m_draw_background(graph);
_m_draw_title(graph); _m_draw_title(graph);
_m_draw_checkbox(graph, graph.text_extent_size(STR("jN"), 2).height + 2); _m_draw_checkbox(graph, graph.text_extent_size(L"jN", 2).height + 2);
} }
void drawer::mouse_down(graph_reference graph, const arg_mouse&) void drawer::mouse_down(graph_reference graph, const arg_mouse&)

View File

@ -109,7 +109,7 @@ namespace nana
unsigned item_pixels(graph_reference graph) const unsigned item_pixels(graph_reference graph) const
{ {
return graph.text_extent_size(STR("jHWn/?\\{[(0569")).height + 4; return graph.text_extent_size(L"jHWn/?\\{[(0569").height + 4;
} }
};//end class item_renderer };//end class item_renderer
@ -325,7 +325,7 @@ namespace nana
_m_open_scrollbar(*widget_, pages); _m_open_scrollbar(*widget_, pages);
} }
else else
graph_->string({ 4, 4 }, STR("Empty Listbox, No Module!"), static_cast<color_rgb>(0x808080)); graph_->string({ 4, 4 }, L"Empty Listbox, No Module!", static_cast<color_rgb>(0x808080));
//Draw border //Draw border
graph_->rectangle(false, colors::black); graph_->rectangle(false, colors::black);

View File

@ -82,7 +82,7 @@ namespace nana
nana::paint::font ft = graph.typeface(); //used for restoring the font nana::paint::font ft = graph.typeface(); //used for restoring the font
const unsigned def_line_pixels = graph.text_extent_size(STR(" "), 1).height; const unsigned def_line_pixels = graph.text_extent_size(L" ", 1).height;
font_ = ft; font_ = ft;
fblock_ = nullptr; fblock_ = nullptr;
@ -169,7 +169,7 @@ namespace nana
auto ft = graph.typeface(); //used for restoring the font auto ft = graph.typeface(); //used for restoring the font
const unsigned def_line_pixels = graph.text_extent_size(STR(" "), 1).height; const unsigned def_line_pixels = graph.text_extent_size(L" ", 1).height;
font_ = ft; font_ = ft;
fblock_ = nullptr; fblock_ = nullptr;

View File

@ -3146,7 +3146,7 @@ namespace nana
graph->set_color(it_bgcolor); // litter rect with the item bg end ... graph->set_color(it_bgcolor); // litter rect with the item bg end ...
graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true); graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true);
graph->string(point{ xpos, y + 2 }, STR("...")); graph->string(point{ xpos, y + 2 }, L"...");
//Erase the part that over the next subitem. //Erase the part that over the next subitem.
if (display_order + 1 < seqs.size()) // this is not the last column if (display_order + 1 < seqs.size()) // this is not the last column
@ -3284,9 +3284,9 @@ namespace nana
void trigger::typeface_changed(graph_reference graph) void trigger::typeface_changed(graph_reference graph)
{ {
essence_->text_height = graph.text_extent_size(STR("jHWn0123456789/<?'{[|\\_")).height; essence_->text_height = graph.text_extent_size(L"jHWn0123456789/<?'{[|\\_").height;
essence_->item_size = essence_->text_height + 6; essence_->item_size = essence_->text_height + 6;
essence_->suspension_width = graph.text_extent_size(STR("...")).width; essence_->suspension_width = graph.text_extent_size(L"...").width;
} }
void trigger::refresh(graph_reference) void trigger::refresh(graph_reference)
@ -3581,7 +3581,7 @@ namespace nana
case keyboard::os_arrow_down: case keyboard::os_arrow_down:
essence_->lister.move_select(up, !arg.shift, true); essence_->lister.move_select(up, !arg.shift, true);
break; break;
case STR(' ') : case L' ':
{ {
selection s; selection s;
bool ck = ! essence_->lister.item_selected_all_checked(s); bool ck = ! essence_->lister.item_selected_all_checked(s);

View File

@ -363,7 +363,7 @@ namespace nana
unsigned strpixels = item_r.width - 60; unsigned strpixels = item_r.width - 60;
int text_top_off = (item_h_px - graph.text_extent_size(STR("jh({[")).height) / 2; int text_top_off = (item_h_px - graph.text_extent_size(L"jh({[").height) / 2;
std::size_t pos = 0; std::size_t pos = 0;
for (auto & m : menu_->items) for (auto & m : menu_->items)

View File

@ -442,7 +442,7 @@ namespace nana{ namespace widgets
bool adjusted_cond = true; bool adjusted_cond = true;
if (static_cast<int>(text_w) < points.offset.x) if (static_cast<int>(text_w) < points.offset.x)
{ {
auto delta_pixels = editor_._m_text_extent_size(STR(" "), 4).width; auto delta_pixels = editor_._m_text_extent_size(L" ", 4).width;
points.offset.x = (text_w > delta_pixels ? text_w - delta_pixels : 0); points.offset.x = (text_w > delta_pixels ? text_w - delta_pixels : 0);
} }
else if (area_w && (text_w >= points.offset.x + area_w)) else if (area_w && (text_w >= points.offset.x + area_w))
@ -1614,7 +1614,7 @@ namespace nana{ namespace widgets
unsigned text_editor::line_height() const unsigned text_editor::line_height() const
{ {
return (graph_ ? (graph_.text_extent_size(STR("jH{")).height) : 0); return (graph_ ? (graph_.text_extent_size(L"jH{").height) : 0);
} }
unsigned text_editor::screen_lines() const unsigned text_editor::screen_lines() const
@ -1764,7 +1764,7 @@ namespace nana{ namespace widgets
str = textbase_.getline(0); str = textbase_.getline(0);
for(std::size_t i = 1; i < lines; ++i) for(std::size_t i = 1; i < lines; ++i)
{ {
str += STR("\n\r"); str += L"\n\r";
str += textbase_.getline(i); str += textbase_.getline(i);
} }
} }
@ -2756,11 +2756,11 @@ namespace nana{ namespace widgets
if(a.y != b.y) if(a.y != b.y)
{ {
text = textbase_.getline(a.y).substr(a.x); text = textbase_.getline(a.y).substr(a.x);
text += STR("\r\n"); text += L"\r\n";
for(unsigned i = a.y + 1; i < b.y; ++i) for(unsigned i = a.y + 1; i < b.y; ++i)
{ {
text += textbase_.getline(i); text += textbase_.getline(i);
text += STR("\r\n"); text += L"\r\n";
} }
text += textbase_.getline(b.y).substr(0, b.x); text += textbase_.getline(b.y).substr(0, b.x);
} }
@ -2801,7 +2801,7 @@ namespace nana{ namespace widgets
std::size_t begin = 0; std::size_t begin = 0;
while (true) while (true)
{ {
auto pos = text.find_first_of(STR("\r\n"), begin); auto pos = text.find_first_of(L"\r\n", begin);
if (text.npos == pos) if (text.npos == pos)
{ {
if (!lines.empty()) if (!lines.empty())
@ -2813,7 +2813,7 @@ namespace nana{ namespace widgets
pos = eat_endl(text_str, pos); pos = eat_endl(text_str, pos);
begin = text.find_first_not_of(STR("\r\n"), pos); begin = text.find_first_not_of(L"\r\n", pos);
//The number of new lines minus one //The number of new lines minus one
const auto chp_end = text_str + (begin == text.npos ? text.size() : begin); const auto chp_end = text_str + (begin == text.npos ? text.size() : begin);
@ -3068,7 +3068,7 @@ namespace nana{ namespace widgets
keyword_parser parser; keyword_parser parser;
parser.parse(linestr, keywords_.get()); parser.parse(linestr, keywords_.get());
auto whitespace_w = graph_.text_extent_size(STR(" "), 1).width; auto whitespace_w = graph_.text_extent_size(L" ", 1).width;
const auto line_h_pixels = line_height(); const auto line_h_pixels = line_height();

View File

@ -29,11 +29,11 @@ namespace nana
{ {
using node_type = trigger::node_type; using node_type = trigger::node_type;
bool no_sensitive_compare(const nana::string& text, const nana::char_t *pattern, std::size_t len) bool no_sensitive_compare(const std::string& text, const char *pattern, std::size_t len)
{ {
if(len <= text.length()) if(len <= text.length())
{ {
const nana::char_t * s = text.c_str(); auto s = text.c_str();
for(std::size_t i = 0; i < len; ++i) for(std::size_t i = 0; i < len; ++i)
{ {
if('a' <= s[i] && s[i] <= 'z') if('a' <= s[i] && s[i] <= 'z')
@ -49,7 +49,7 @@ namespace nana
return false; return false;
} }
const node_type* find_track_child_node(const node_type* node, const node_type * end, const nana::char_t* pattern, std::size_t len, bool &finish) const node_type* find_track_child_node(const node_type* node, const node_type * end, const char* pattern, std::size_t len, bool &finish)
{ {
if(node->value.second.expanded) if(node->value.second.expanded)
{ {
@ -217,7 +217,7 @@ namespace nana
nana::scroll<true> scroll; nana::scroll<true> scroll;
std::size_t prev_first_value; std::size_t prev_first_value;
mutable std::map<nana::string, node_image_tag> image_table; mutable std::map<std::string, node_image_tag> image_table;
tree_cont_type::node_type * first; tree_cont_type::node_type * first;
int indent_pixels; int indent_pixels;
@ -241,7 +241,7 @@ namespace nana
struct track_node_tag struct track_node_tag
{ {
nana::string key_buf; ::std::string key_buf;
std::size_t key_time; std::size_t key_time;
}track_node; }track_node;
@ -320,9 +320,9 @@ namespace nana
return false; return false;
} }
const trigger::node_type* find_track_node(nana::char_t key) const trigger::node_type* find_track_node(wchar_t key)
{ {
nana::string pattern; std::string pattern;
if('a' <= key && key <= 'z') key -= 'a' - 'A'; if('a' <= key && key <= 'z') key -= 'a' - 'A';
@ -334,8 +334,18 @@ namespace nana
pattern = track_node.key_buf; pattern = track_node.key_buf;
track_node.key_time = now; track_node.key_time = now;
pattern += key;
track_node.key_buf += key; if (key <= 0x7f)
{
pattern += static_cast<char>(key);
track_node.key_buf += static_cast<char>(key);
}
else
{
wchar_t wstr[2] = { key, 0 };
pattern += utf8_cast(wstr);
track_node.key_buf += utf8_cast(wstr);
}
const node_type *begin = node_state.selected ? node_state.selected : attr.tree_cont.get_root()->child; const node_type *begin = node_state.selected ? node_state.selected : attr.tree_cont.get_root()->child;
@ -604,7 +614,7 @@ namespace nana
std::size_t visual_item_size() const std::size_t visual_item_size() const
{ {
return attr.tree_cont.child_size_if(nana::string{}, pred_allow_child{}); return attr.tree_cont.child_size_if(std::string(), pred_allow_child{});
} }
int visible_w_pixels() const int visible_w_pixels() const
@ -820,7 +830,7 @@ namespace nana
} }
} }
item_proxy item_proxy::append(const nana::string& key, nana::string name) item_proxy item_proxy::append(const std::string& key, std::string name)
{ {
if(nullptr == trigger_ || nullptr == node_) if(nullptr == trigger_ || nullptr == node_)
return item_proxy(); return item_proxy();
@ -892,34 +902,34 @@ namespace nana
return *this; return *this;
} }
const nana::string& item_proxy::icon() const const std::string& item_proxy::icon() const
{ {
return node_->value.second.img_idstr; return node_->value.second.img_idstr;
} }
item_proxy& item_proxy::icon(const nana::string& id) item_proxy& item_proxy::icon(const std::string& id)
{ {
node_->value.second.img_idstr = id; node_->value.second.img_idstr = id;
return *this; return *this;
} }
item_proxy& item_proxy::key(const nana::string& kstr) item_proxy& item_proxy::key(const std::string& kstr)
{ {
trigger_->rename(node_, kstr.data(), nullptr); trigger_->rename(node_, kstr.data(), nullptr);
return *this; return *this;
} }
const nana::string& item_proxy::key() const const std::string& item_proxy::key() const
{ {
return node_->value.first; return node_->value.first;
} }
const nana::string& item_proxy::text() const const std::string& item_proxy::text() const
{ {
return node_->value.second.text; return node_->value.second.text;
} }
item_proxy& item_proxy::text(const nana::string& id) item_proxy& item_proxy::text(const std::string& id)
{ {
trigger_->rename(node_, nullptr, id.data()); trigger_->rename(node_, nullptr, id.data());
return *this; return *this;
@ -973,27 +983,19 @@ namespace nana
return end(); return end();
} }
bool item_proxy::operator==(const nana::string& s) const bool item_proxy::operator==(const std::string& s) const
{ {
return (node_ && (node_->value.second.text == s)); return (node_ && (node_->value.second.text == s));
} }
bool item_proxy::operator==(const char* s) const bool item_proxy::operator==(const char* s) const
{ {
#if defined(NANA_UNICODE) return (node_ && (node_->value.second.text == s));
return (node_ && (node_->value.second.text == nana::string(nana::charset(s))));
#else
return (node_ && s && (node_->value.second.text == s));
#endif
} }
bool item_proxy::operator==(const wchar_t* s) const bool item_proxy::operator==(const wchar_t* s) const
{ {
#if defined(NANA_UNICODE) return (node_ && s && (node_->value.second.text == utf8_cast(s)));
return (node_ && s && (node_->value.second.text == s));
#else
return (node_ && (node_->value.second.text == nana::string(nana::charset(s))));
#endif
} }
// Behavior of Iterator // Behavior of Iterator
@ -1114,7 +1116,7 @@ namespace nana
virtual unsigned item_height(graph_reference graph) const override virtual unsigned item_height(graph_reference graph) const override
{ {
return graph.text_extent_size(STR("jH{"), 3).height + 8; return graph.text_extent_size(L"jH{", 3).height + 8;
} }
virtual unsigned item_width(graph_reference graph, const item_attribute_t& attr) const override virtual unsigned item_width(graph_reference graph, const item_attribute_t& attr) const override
@ -1468,7 +1470,7 @@ namespace nana
:expanded(false), checked(checkstate::unchecked) :expanded(false), checked(checkstate::unchecked)
{} {}
trigger::treebox_node_type::treebox_node_type(nana::string text) trigger::treebox_node_type::treebox_node_type(std::string text)
:text(std::move(text)), expanded(false), checked(checkstate::unchecked) :text(std::move(text)), expanded(false), checked(checkstate::unchecked)
{} {}
@ -1702,7 +1704,7 @@ namespace nana
return node->value.second.value; return node->value.second.value;
} }
trigger::node_type* trigger::insert(node_type* node, const nana::string& key, nana::string&& title) trigger::node_type* trigger::insert(node_type* node, const std::string& key, std::string&& title)
{ {
node_type * p = impl_->attr.tree_cont.node(node, key); node_type * p = impl_->attr.tree_cont.node(node, key);
if(p) if(p)
@ -1715,7 +1717,7 @@ namespace nana
return p; return p;
} }
trigger::node_type* trigger::insert(const nana::string& path, nana::string&& title) trigger::node_type* trigger::insert(const std::string& path, std::string&& title)
{ {
auto x = impl_->attr.tree_cont.insert(path, treebox_node_type(std::move(title))); auto x = impl_->attr.tree_cont.insert(path, treebox_node_type(std::move(title)));
if(x && impl_->attr.auto_draw && impl_->draw(true)) if(x && impl_->attr.auto_draw && impl_->draw(true))
@ -1781,7 +1783,7 @@ namespace nana
} }
} }
void trigger::set_expand(const nana::string& path, bool exp) void trigger::set_expand(const std::string& path, bool exp)
{ {
if(impl_->set_expanded(impl_->attr.tree_cont.find(path), exp)) if(impl_->set_expanded(impl_->attr.tree_cont.find(path), exp))
{ {
@ -1790,7 +1792,7 @@ namespace nana
} }
} }
node_image_tag& trigger::icon(const nana::string& id) const node_image_tag& trigger::icon(const std::string& id) const
{ {
auto i = impl_->shape.image_table.find(id); auto i = impl_->shape.image_table.find(id);
if(i != impl_->shape.image_table.end()) if(i != impl_->shape.image_table.end())
@ -1801,14 +1803,14 @@ namespace nana
return impl_->shape.image_table[id]; return impl_->shape.image_table[id];
} }
void trigger::icon_erase(const nana::string& id) void trigger::icon_erase(const std::string& id)
{ {
impl_->shape.image_table.erase(id); impl_->shape.image_table.erase(id);
if(0 == impl_->shape.image_table.size()) if(0 == impl_->shape.image_table.size())
impl_->data.comp_placer->enable(component::icon, false); impl_->data.comp_placer->enable(component::icon, false);
} }
void trigger::node_icon(node_type* node, const nana::string& id) void trigger::node_icon(node_type* node, const std::string& id)
{ {
if(tree().verify(node)) if(tree().verify(node))
{ {
@ -1826,7 +1828,7 @@ namespace nana
return impl_->data.comp_placer->item_width(*impl_->data.graph, node_attr); return impl_->data.comp_placer->item_width(*impl_->data.graph, node_attr);
} }
bool trigger::rename(node_type *node, const nana::char_t* key, const nana::char_t* name) bool trigger::rename(node_type *node, const char* key, const char* name)
{ {
if((key || name ) && tree().verify(node)) if((key || name ) && tree().verify(node))
{ {
@ -2194,28 +2196,28 @@ namespace nana
return get_drawer_trigger().checkable(); return get_drawer_trigger().checkable();
} }
treebox::node_image_type& treebox::icon(const nana::string& id) const treebox::node_image_type& treebox::icon(const std::string& id) const
{ {
return get_drawer_trigger().icon(id); return get_drawer_trigger().icon(id);
} }
void treebox::icon_erase(const nana::string& id) void treebox::icon_erase(const std::string& id)
{ {
get_drawer_trigger().icon_erase(id); get_drawer_trigger().icon_erase(id);
} }
auto treebox::find(const nana::string& keypath) -> item_proxy auto treebox::find(const std::string& keypath) -> item_proxy
{ {
auto * trg = &get_drawer_trigger(); auto * trg = &get_drawer_trigger();
return item_proxy(trg, trg->tree().find(keypath)); return item_proxy(trg, trg->tree().find(keypath));
} }
treebox::item_proxy treebox::insert(const nana::string& path_key, nana::string title) treebox::item_proxy treebox::insert(const std::string& path_key, std::string title)
{ {
return item_proxy(&get_drawer_trigger(), get_drawer_trigger().insert(path_key, std::move(title))); return item_proxy(&get_drawer_trigger(), get_drawer_trigger().insert(path_key, std::move(title)));
} }
treebox::item_proxy treebox::insert(item_proxy i, const nana::string& key, nana::string title) treebox::item_proxy treebox::insert(item_proxy i, const std::string& key, std::string title)
{ {
return item_proxy(&get_drawer_trigger(), get_drawer_trigger().insert(i._m_node(), key, std::move(title))); return item_proxy(&get_drawer_trigger(), get_drawer_trigger().insert(i._m_node(), key, std::move(title)));
} }
@ -2227,22 +2229,22 @@ namespace nana
return next; return next;
} }
void treebox::erase(const nana::string& keypath) void treebox::erase(const std::string& keypath)
{ {
auto i = find(keypath); auto i = find(keypath);
if(!i.empty()) if(!i.empty())
get_drawer_trigger().remove(i._m_node()); get_drawer_trigger().remove(i._m_node());
} }
nana::string treebox::make_key_path(item_proxy i, const nana::string& splitter) const std::string treebox::make_key_path(item_proxy i, const std::string& splitter) const
{ {
auto & tree = get_drawer_trigger().tree(); auto & tree = get_drawer_trigger().tree();
auto pnode = i._m_node(); auto pnode = i._m_node();
if(tree.verify(pnode)) if(tree.verify(pnode))
{ {
auto root = tree.get_root(); auto root = tree.get_root();
nana::string path; std::string path;
nana::string temp; std::string temp;
while(pnode->owner != root) while(pnode->owner != root)
{ {
temp = splitter; temp = splitter;

View File

@ -322,8 +322,8 @@ namespace paint
handle_ = dw; handle_ = dw;
size_ = sz; size_ = sz;
handle_->string.tab_pixels = detail::raw_text_extent_size(handle_, STR("\t"), 1).width; handle_->string.tab_pixels = detail::raw_text_extent_size(handle_, L"\t", 1).width;
handle_->string.whitespace_pixels = detail::raw_text_extent_size(handle_, STR(" "), 1).width; handle_->string.whitespace_pixels = detail::raw_text_extent_size(handle_, L" ", 1).width;
} }
} }
@ -348,8 +348,8 @@ namespace paint
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
::SelectObject(handle_->context, reinterpret_cast<HFONT>(f.impl_->font_ptr->handle)); ::SelectObject(handle_->context, reinterpret_cast<HFONT>(f.impl_->font_ptr->handle));
#endif #endif
handle_->string.tab_pixels = detail::raw_text_extent_size(handle_, STR("\t"), 1).width; handle_->string.tab_pixels = detail::raw_text_extent_size(handle_, L"\t", 1).width;
handle_->string.whitespace_pixels = detail::raw_text_extent_size(handle_, STR(" "), 1).width; handle_->string.whitespace_pixels = detail::raw_text_extent_size(handle_, L" ", 1).width;
if(changed_ == false) changed_ = true; if(changed_ == false) changed_ = true;
} }
} }
@ -953,10 +953,16 @@ namespace paint
} }
} }
void graphics::string(const point& pos, const std::string& text) void graphics::string(const point& pos, const std::string& text_utf8)
{ {
throw_not_utf8(text); throw_not_utf8(text_utf8);
string(pos, static_cast<std::wstring>(::nana::charset(text, ::nana::unicode::utf8))); string(pos, utf8_cast(text_utf8));
}
void graphics::string(const point& pos, const std::string& text_utf8, const color& clr)
{
set_text_color(clr);
string(pos, text_utf8);
} }
void graphics::string(nana::point pos, const char_t* str, std::size_t len) void graphics::string(nana::point pos, const char_t* str, std::size_t len)

View File

@ -218,7 +218,7 @@ namespace paint
do do
{ {
if (STR("ICO") == type_str) if (L"ICO" == type_str)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
helper = new detail::image_ico(true); helper = new detail::image_ico(true);
@ -228,7 +228,7 @@ namespace paint
break; break;
} }
if (STR("PNG") == type_str) if (L"PNG" == type_str)
{ {
#if defined(NANA_ENABLE_PNG) #if defined(NANA_ENABLE_PNG)
helper = new detail::image_png; helper = new detail::image_png;
@ -238,7 +238,7 @@ namespace paint
break; break;
} }
if (STR("JPG") == type_str || STR("JPEG") == type_str) if (L"JPG" == type_str || L"JPEG" == type_str)
{ {
#if defined(NANA_ENABLE_JPEG) #if defined(NANA_ENABLE_JPEG)
helper = new detail::image_jpeg; helper = new detail::image_jpeg;

View File

@ -124,7 +124,7 @@ namespace nana
draw_string_omitted(graphics& graph, int x, int endpos, bool omitted) draw_string_omitted(graphics& graph, int x, int endpos, bool omitted)
: graph(graph), x(x), endpos(endpos) : graph(graph), x(x), endpos(endpos)
{ {
omitted_pixels = (omitted ? graph.text_extent_size(STR("..."), 3).width : 0); omitted_pixels = (omitted ? graph.text_extent_size(L"...", 3).width : 0);
if (endpos - x > static_cast<int>(omitted_pixels)) if (endpos - x > static_cast<int>(omitted_pixels))
this->endpos -= omitted_pixels; this->endpos -= omitted_pixels;
else else
@ -165,7 +165,7 @@ namespace nana
r.y = top; r.y = top;
graph.bitblt(r, dum_graph); graph.bitblt(r, dum_graph);
if(omitted_pixels) if(omitted_pixels)
detail::draw_string(dw, point{ endpos, top }, STR("..."), 3); detail::draw_string(dw, point{ endpos, top }, L"...", 3);
break; break;
} }
} }

View File

@ -104,14 +104,14 @@ namespace system
return; return;
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
if(::ShellExecute(0, STR("open"), url.c_str(), 0, 0, SW_SHOWNORMAL) < reinterpret_cast<HINSTANCE>(32)) if(::ShellExecute(0, L"open", url.c_str(), 0, 0, SW_SHOWNORMAL) < reinterpret_cast<HINSTANCE>(32))
{ {
//Because ShellExecute can delegate execution to Shell extensions (data sources, context menu handlers, //Because ShellExecute can delegate execution to Shell extensions (data sources, context menu handlers,
//verb implementations) that are activated using Component Object Model (COM), COM should be initialized //verb implementations) that are activated using Component Object Model (COM), COM should be initialized
//before ShellExecute is called. Some Shell extensions require the COM single-threaded apartment (STA) type. //before ShellExecute is called. Some Shell extensions require the COM single-threaded apartment (STA) type.
//In that case, COM should be initialized under WinXP. //In that case, COM should be initialized under WinXP.
nana::detail::platform_spec::co_initializer co_init; nana::detail::platform_spec::co_initializer co_init;
::ShellExecute(0, STR("open"), url.c_str(), 0, 0, SW_SHOWNORMAL); ::ShellExecute(0, L"open", url.c_str(), 0, 0, SW_SHOWNORMAL);
} }
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
#endif #endif