remove macro STR
This commit is contained in:
parent
12358a5dc0
commit
c86a00bea5
@ -89,14 +89,12 @@ 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
|
||||
|
@ -39,9 +39,9 @@ namespace filesystem
|
||||
#ifdef NANA_WINDOWS
|
||||
fileinfo(const WIN32_FIND_DATA& wfd);
|
||||
#elif NANA_LINUX or NANA_MACOS
|
||||
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_ += '/';
|
||||
find_handle_t handle = opendir(path_.c_str());
|
||||
auto path = file_path;
|
||||
if(path.size() && path.back() != '/')
|
||||
path += '/';
|
||||
auto handle = opendir(path.c_str());
|
||||
|
||||
end_ = true;
|
||||
if(handle)
|
||||
{
|
||||
@ -141,7 +141,7 @@ namespace filesystem
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -226,9 +226,6 @@ namespace filesystem
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FIND_DATA wfd_;
|
||||
nana::string path_;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
std::string path_;
|
||||
#endif
|
||||
std::shared_ptr<find_handle_t> find_ptr_;
|
||||
|
||||
|
@ -136,29 +136,41 @@ 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<value_type>;
|
||||
|
||||
path();
|
||||
path(const nana::string&);
|
||||
path(const value_type* source);
|
||||
path(const string_type& source);
|
||||
|
||||
int compare(const path& other) const;
|
||||
|
||||
bool empty() const;
|
||||
path root() 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;
|
||||
private:
|
||||
nana::string text_;
|
||||
#else
|
||||
public:
|
||||
std::string to_string() const { return text_; }
|
||||
operator std::string() const { return text_; }
|
||||
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 +205,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 +243,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_);
|
||||
|
||||
@ -265,7 +275,6 @@ namespace filesystem
|
||||
wfd_.nFileSizeLow);
|
||||
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
path_ = nana::charset(file_path);
|
||||
if(path_.size() && (path_[path_.size() - 1] != '/'))
|
||||
path_ += '/';
|
||||
find_handle_t handle = opendir(path_.c_str());
|
||||
@ -373,10 +382,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_handle_t> find_ptr_;
|
||||
find_handle_t handle_{nullptr};
|
||||
value_type value_;
|
||||
@ -453,12 +461,39 @@ namespace filesystem
|
||||
|
||||
//bool remove(const path& p);
|
||||
//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, error_code& ec) noexcept;
|
||||
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty);
|
||||
nana::string root(const nana::string& path);
|
||||
bool rmdir(const char* dir, bool fails_if_not_empty);
|
||||
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
|
||||
|
@ -27,14 +27,14 @@ namespace filesystem
|
||||
bool file_attrib(const ::std::string& file, attribute&);
|
||||
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&);
|
||||
|
||||
nana::string path_user();
|
||||
nana::string path_current();
|
||||
|
||||
bool rmfile(const nana::char_t* file);
|
||||
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty);
|
||||
bool rmfile(const char* file_utf8);
|
||||
bool rmdir(const char* dir, bool fails_if_not_empty);
|
||||
nana::string root(const nana::string& path);
|
||||
|
||||
class path
|
||||
|
@ -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
|
||||
|
@ -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<nana::string> files; ///< external filenames
|
||||
std::vector<std::string> 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
|
||||
|
@ -94,7 +94,7 @@ namespace nana
|
||||
virtual ~renderer() = 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 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;
|
||||
};
|
||||
|
||||
@ -115,8 +115,8 @@ namespace nana
|
||||
|
||||
//splitstr
|
||||
//@brief: Sets the splitstr. If the parameter will be ingored if it is an empty string.
|
||||
void splitstr(const nana::string&);
|
||||
const nana::string& splitstr() const;
|
||||
void splitstr(const ::std::string&);
|
||||
const ::std::string& splitstr() const;
|
||||
|
||||
void path(const ::std::string&);
|
||||
::std::string path() const;
|
||||
|
@ -22,7 +22,7 @@ namespace detail
|
||||
template<typename T>
|
||||
struct tree_node
|
||||
{
|
||||
typedef std::pair<nana::string, T> value_type;
|
||||
typedef std::pair<std::string, T> 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<true>(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<true>(path);
|
||||
}
|
||||
@ -303,7 +303,7 @@ namespace detail
|
||||
}
|
||||
|
||||
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);
|
||||
return (node ? child_size_if<PredAllowChild>(*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<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())
|
||||
{
|
||||
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<bool CreateIfNotExists>
|
||||
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())
|
||||
{
|
||||
|
@ -449,8 +449,8 @@ namespace nana
|
||||
|
||||
struct export_options
|
||||
{
|
||||
nana::string sep = nana::string {STR("\t" )},
|
||||
endl= nana::string {STR("\n")};
|
||||
nana::string sep = nana::string {L"\t"},
|
||||
endl= nana::string {L"\n"};
|
||||
bool only_selected_items{true},
|
||||
only_checked_items {false},
|
||||
only_visible_columns{true};
|
||||
|
@ -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;
|
||||
|
@ -140,8 +140,6 @@ namespace nana
|
||||
: public drawer_trigger
|
||||
{
|
||||
public:
|
||||
//enum toolbox_button_t{ButtonAdd, ButtonScroll, ButtonList, ButtonClose}; //deprecated
|
||||
|
||||
enum class kits
|
||||
{
|
||||
add,
|
||||
|
@ -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<component, node_attribute> 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<compset_placer_interface>& 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<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));
|
||||
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<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 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;///<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
|
||||
};//end class treebox
|
||||
}//end namespace nana
|
||||
|
@ -151,7 +151,9 @@ namespace nana
|
||||
void set_pixel(int x, int y, const ::nana::color&);
|
||||
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(const point&, const char_t*);
|
||||
void string(const point&, const ::nana::string&);
|
||||
|
@ -154,7 +154,7 @@ namespace detail
|
||||
|
||||
//class platform_spec
|
||||
platform_spec::co_initializer::co_initializer()
|
||||
: ole32_(::LoadLibrary(STR("OLE32.DLL")))
|
||||
: ole32_(::LoadLibrary(L"OLE32.DLL"))
|
||||
{
|
||||
if(ole32_)
|
||||
{
|
||||
|
@ -24,12 +24,12 @@ namespace filesystem
|
||||
{}
|
||||
#if defined(NANA_WINDOWS)
|
||||
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)
|
||||
{
|
||||
}
|
||||
#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))
|
||||
{
|
||||
}
|
||||
|
@ -43,51 +43,50 @@ namespace nana {
|
||||
{
|
||||
//Because of No wide character version of POSIX
|
||||
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
typedef std::string string_t;
|
||||
const char* splstr = "/\\";
|
||||
const char* splstr = "/";
|
||||
#else
|
||||
typedef nana::string string_t;
|
||||
const nana::char_t* splstr = STR("/\\");
|
||||
const wchar_t* splstr = L"/\\";
|
||||
#endif
|
||||
|
||||
//class path
|
||||
path::path() {}
|
||||
|
||||
path::path(const nana::string& text)
|
||||
#if defined(NANA_WINDOWS)
|
||||
: text_(text)
|
||||
path::path(const value_type* source)
|
||||
: path(string_type{ source })
|
||||
{}
|
||||
|
||||
path::path(const string_type& source)
|
||||
: pathstr_(source)
|
||||
{
|
||||
#else
|
||||
:text_(nana::charset(text))
|
||||
auto pos = pathstr_.find_last_of(splstr);
|
||||
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
|
||||
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);
|
||||
return pathstr_.compare(p.pathstr_);
|
||||
}
|
||||
|
||||
bool path::empty() const
|
||||
{
|
||||
#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)
|
||||
struct stat sta;
|
||||
return (::stat(text_.c_str(), &sta) == -1);
|
||||
return (::stat(pathstr_.c_str(), &sta) == -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
path path::root() const
|
||||
path path::parent_path() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
return path(filesystem::root(text_));
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
return path(filesystem::root(nana::charset(text_)));
|
||||
#endif
|
||||
return{filesystem::parent_path(pathstr_)};
|
||||
}
|
||||
|
||||
file_type path::what() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
unsigned long attr = ::GetFileAttributes(text_.c_str());
|
||||
unsigned long attr = ::GetFileAttributes(pathstr_.c_str());
|
||||
if (INVALID_FILE_ATTRIBUTES == attr)
|
||||
return file_type::not_found; //??
|
||||
|
||||
@ -97,7 +96,7 @@ namespace nana {
|
||||
return file_type::regular;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat sta;
|
||||
if (-1 == ::stat(text_.c_str(), &sta))
|
||||
if (-1 == ::stat(pathstr_.c_str(), &sta))
|
||||
return file_type::not_found; //??
|
||||
|
||||
if ((S_IFDIR & sta.st_mode) == S_IFDIR)
|
||||
@ -110,38 +109,85 @@ namespace nana {
|
||||
#endif
|
||||
}
|
||||
|
||||
nana::string path::filename() const
|
||||
path path::filename() const
|
||||
{
|
||||
string_t::size_type pos = text_.find_last_of(splstr);
|
||||
#if defined(NANA_WINDOWS)
|
||||
return text_.substr(pos + 1);
|
||||
#else
|
||||
return nana::charset(text_.substr(pos + 1));
|
||||
#endif
|
||||
auto pos = pathstr_.find_last_of(splstr);
|
||||
if (pos != pathstr_.npos)
|
||||
{
|
||||
if (pos + 1 == pathstr_.size())
|
||||
{
|
||||
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
|
||||
|
||||
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
|
||||
{
|
||||
//rm_dir_recursive
|
||||
//@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;
|
||||
nana::string path = dir;
|
||||
std::basic_string<CharT> path = dir;
|
||||
path += '\\';
|
||||
|
||||
std::copy(directory_iterator(dir), directory_iterator(), std::back_inserter(files));
|
||||
|
||||
for (auto & f : files)
|
||||
{
|
||||
auto subpath = path + f.path().filename().native();
|
||||
if (f.attr.directory)
|
||||
rm_dir_recursive(path + f.path().filename());
|
||||
rm_dir_recursive(subpath.c_str());
|
||||
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)
|
||||
@ -299,7 +345,7 @@ namespace nana {
|
||||
|
||||
nana::string root;
|
||||
#if defined(NANA_WINDOWS)
|
||||
if (path.size() > 3 && path[1] == STR(':'))
|
||||
if (path.size() > 3 && path[1] == L':')
|
||||
root = path.substr(0, 3);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
if (path[0] == STR('/'))
|
||||
@ -310,11 +356,11 @@ namespace nana {
|
||||
|
||||
while (true)
|
||||
{
|
||||
beg = path.find_first_not_of(STR("/\\"), beg);
|
||||
beg = path.find_first_not_of(L"/\\", beg);
|
||||
if (beg == path.npos)
|
||||
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)
|
||||
{
|
||||
root += path.substr(beg, pos - beg);
|
||||
@ -324,9 +370,9 @@ namespace nana {
|
||||
return false;
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
root += STR('\\');
|
||||
root += L'\\';
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
root += STR('/');
|
||||
root += L'/';
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -362,18 +408,18 @@ namespace nana {
|
||||
#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;
|
||||
if (dir)
|
||||
if (dir_utf8)
|
||||
{
|
||||
#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))
|
||||
ret = detail::rm_dir_recursive(dir);
|
||||
ret = detail::rm_dir_recursive(dir.c_str());
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
std::string mbstr = nana::charset(dir);
|
||||
if (::rmdir(mbstr.c_str()))
|
||||
if (::rmdir(dir_utf8))
|
||||
{
|
||||
if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
|
||||
ret = detail::rm_dir_recursive(dir);
|
||||
@ -385,30 +431,26 @@ namespace nana {
|
||||
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();
|
||||
|
||||
if (index)
|
||||
bool ret = false;
|
||||
if (dir)
|
||||
{
|
||||
const nana::char_t * str = path.c_str();
|
||||
|
||||
for (--index; index > 0; --index)
|
||||
#if defined(NANA_WINDOWS)
|
||||
ret = (::RemoveDirectory(dir) == TRUE);
|
||||
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 (c != '\\' && c != '/')
|
||||
break;
|
||||
if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
|
||||
ret = detail::rm_dir_recursive(dir);
|
||||
}
|
||||
|
||||
for (--index; index > 0; --index)
|
||||
{
|
||||
nana::char_t c = str[index];
|
||||
if (c == '\\' || c == '/')
|
||||
break;
|
||||
else
|
||||
ret = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return index ? path.substr(0, index + 1) : nana::string();
|
||||
return ret;
|
||||
}
|
||||
|
||||
nana::string path_user()
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <nana/filesystem/fs_utility.hpp>
|
||||
#include <nana/filesystem/file_iterator.hpp>
|
||||
#include <nana/deploy.hpp>
|
||||
#include <vector>
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
@ -47,7 +48,7 @@ namespace filesystem
|
||||
const char* splstr = "/\\";
|
||||
#else
|
||||
typedef nana::string string_t;
|
||||
const nana::char_t* splstr = STR("/\\");
|
||||
const nana::char_t* splstr = L"/\\";
|
||||
#endif
|
||||
//class path
|
||||
path::path(){}
|
||||
@ -125,10 +126,10 @@ namespace filesystem
|
||||
{
|
||||
//rm_dir_recursive
|
||||
//@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;
|
||||
nana::string path = dir;
|
||||
auto path = dir;
|
||||
path += '\\';
|
||||
|
||||
std::copy(file_iterator(dir), file_iterator(), std::back_inserter(files));
|
||||
@ -144,10 +145,10 @@ namespace filesystem
|
||||
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(::CreateDirectory(dir.c_str(), 0))
|
||||
if(::CreateDirectory(utf8_cast(dir).c_str(), 0))
|
||||
{
|
||||
if_exist = false;
|
||||
return true;
|
||||
@ -155,7 +156,7 @@ namespace filesystem
|
||||
|
||||
if_exist = (::GetLastError() == ERROR_ALREADY_EXISTS);
|
||||
#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;
|
||||
return true;
|
||||
@ -288,14 +289,14 @@ namespace filesystem
|
||||
return false;
|
||||
}
|
||||
|
||||
bool mkdir(const nana::string& path, bool & if_exist)
|
||||
bool mkdir(const std::string& path, bool & if_exist)
|
||||
{
|
||||
if_exist = false;
|
||||
if(path.size() == 0) return false;
|
||||
|
||||
nana::string root;
|
||||
std::string root;
|
||||
#if defined(NANA_WINDOWS)
|
||||
if(path.size() > 3 && path[1] == STR(':'))
|
||||
if(path.size() > 3 && path[1] == ':')
|
||||
root = path.substr(0, 3);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
if(path[0] == STR('/'))
|
||||
@ -306,11 +307,11 @@ namespace filesystem
|
||||
|
||||
while(true)
|
||||
{
|
||||
beg = path.find_first_not_of(STR("/\\"), beg);
|
||||
beg = path.find_first_not_of("/\\", beg);
|
||||
if(beg == path.npos)
|
||||
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)
|
||||
{
|
||||
root += path.substr(beg, pos - beg);
|
||||
@ -320,9 +321,9 @@ namespace filesystem
|
||||
return false;
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
root += STR('\\');
|
||||
root += L'\\';
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
root += STR('/');
|
||||
root += L'/';
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -339,32 +340,32 @@ namespace filesystem
|
||||
return mkstat;
|
||||
}
|
||||
|
||||
bool rmfile(const nana::char_t* file)
|
||||
bool rmfile(const char* file)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
bool ret = false;
|
||||
if(file)
|
||||
{
|
||||
ret = (::DeleteFile(file) == TRUE);
|
||||
ret = (::DeleteFile(utf8_cast(file).c_str()) == TRUE);
|
||||
if(!ret)
|
||||
ret = (ERROR_FILE_NOT_FOUND == ::GetLastError());
|
||||
}
|
||||
|
||||
return ret;
|
||||
#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 true;
|
||||
#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;
|
||||
if(dir)
|
||||
{
|
||||
#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))
|
||||
ret = detail::rm_dir_recursive(dir);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
|
@ -202,7 +202,7 @@ namespace nana{
|
||||
if(owner && (nested == false))
|
||||
::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,
|
||||
pt.x, pt.y, 100, 100,
|
||||
reinterpret_cast<HWND>(owner), 0, ::GetModuleHandle(0), 0);
|
||||
@ -377,8 +377,8 @@ namespace nana{
|
||||
if(nullptr == parent) return nullptr;
|
||||
#if defined(NANA_WINDOWS)
|
||||
HWND handle = ::CreateWindowEx(WS_EX_CONTROLPARENT, // Extended possibilites for variation
|
||||
STR("NanaWindowInternal"),
|
||||
STR("Nana Child Window"), // Title Text
|
||||
L"NanaWindowInternal",
|
||||
L"Nana Child Window", // Title Text
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS,
|
||||
r.x, r.y, r.width, r.height,
|
||||
reinterpret_cast<HWND>(parent), // The window is a child-window to desktop
|
||||
|
@ -214,7 +214,7 @@ namespace detail
|
||||
|
||||
WNDCLASSEX wincl;
|
||||
wincl.hInstance = ::GetModuleHandle(0);
|
||||
wincl.lpszClassName = STR("NanaWindowInternal");
|
||||
wincl.lpszClassName = L"NanaWindowInternal";
|
||||
wincl.lpfnWndProc = &Bedrock_WIN32_WindowProc;
|
||||
wincl.style = CS_DBLCLKS | CS_OWNDC;
|
||||
wincl.cbSize = sizeof(wincl);
|
||||
@ -1175,7 +1175,7 @@ namespace detail
|
||||
{
|
||||
arg_dropfiles dropfiles;
|
||||
|
||||
std::unique_ptr<nana::char_t[]> varbuf;
|
||||
std::unique_ptr<wchar_t[]> varbuf;
|
||||
std::size_t bufsize = 0;
|
||||
|
||||
unsigned size = ::DragQueryFile(drop, 0xFFFFFFFF, 0, 0);
|
||||
@ -1189,7 +1189,8 @@ namespace detail
|
||||
}
|
||||
|
||||
::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))
|
||||
|
@ -105,7 +105,7 @@ namespace nana
|
||||
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);
|
||||
|
||||
@ -141,7 +141,7 @@ namespace nana
|
||||
_m_item_bground(graph, r.x + 1, top, width, height, state_name);
|
||||
graph.rectangle(r, false, clr);
|
||||
}
|
||||
graph.string(strpos, name, style_.fgcolor);
|
||||
graph.string(strpos, name_utf8, style_.fgcolor);
|
||||
|
||||
if(has_child)
|
||||
{
|
||||
@ -218,7 +218,7 @@ namespace nana
|
||||
using node_handle = container::node_type*;
|
||||
|
||||
tree_wrapper()
|
||||
:splitstr_(STR("\\")), cur_(nullptr)
|
||||
: splitstr_("\\")
|
||||
{}
|
||||
|
||||
bool seq(std::size_t index, std::vector<node_handle> & seqv) const
|
||||
@ -234,23 +234,23 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
void splitstr(const nana::string& ss)
|
||||
void splitstr(const std::string& ss)
|
||||
{
|
||||
if(ss.size())
|
||||
splitstr_ = ss;
|
||||
}
|
||||
|
||||
const nana::string& splitstr() const
|
||||
const std::string& splitstr() const
|
||||
{
|
||||
return splitstr_;
|
||||
}
|
||||
|
||||
nana::string path() const
|
||||
std::string path() const
|
||||
{
|
||||
std::vector<node_handle> v;
|
||||
_m_read_node_path(v);
|
||||
|
||||
nana::string str;
|
||||
std::string str;
|
||||
bool not_head = false;
|
||||
for(auto i : v)
|
||||
{
|
||||
@ -263,7 +263,7 @@ namespace nana
|
||||
return str;
|
||||
}
|
||||
|
||||
void path(const nana::string& key)
|
||||
void path(const std::string& key)
|
||||
{
|
||||
cur_ = tree_.ref(key);
|
||||
}
|
||||
@ -292,7 +292,7 @@ namespace nana
|
||||
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;
|
||||
m.pixels = 0;
|
||||
@ -300,7 +300,7 @@ namespace nana
|
||||
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_)
|
||||
{
|
||||
@ -313,7 +313,7 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
bool childset_erase(const nana::string& name)
|
||||
bool childset_erase(const std::string& name)
|
||||
{
|
||||
if(cur_)
|
||||
{
|
||||
@ -329,7 +329,7 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
node_handle find_child(const nana::string& name) const
|
||||
node_handle find_child(const std::string& name) const
|
||||
{
|
||||
if(cur_)
|
||||
{
|
||||
@ -360,8 +360,8 @@ namespace nana
|
||||
}
|
||||
private:
|
||||
container tree_;
|
||||
nana::string splitstr_;
|
||||
node_handle cur_;
|
||||
std::string splitstr_ ;
|
||||
node_handle cur_{ nullptr };
|
||||
};
|
||||
|
||||
//class scheme
|
||||
@ -543,7 +543,7 @@ namespace nana
|
||||
{
|
||||
if(node)
|
||||
{
|
||||
API::dev::window_caption(window_handle(), utf8_cast(tree().path()));
|
||||
API::dev::window_caption(window_handle(), tree().path());
|
||||
if(evt_holder_.selected)
|
||||
evt_holder_.selected(node->value.second.value);
|
||||
}
|
||||
@ -565,7 +565,7 @@ namespace nana
|
||||
if(i)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -576,7 +576,7 @@ namespace nana
|
||||
{
|
||||
auto end = v.cbegin() + head_;
|
||||
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;
|
||||
}
|
||||
@ -603,8 +603,7 @@ namespace nana
|
||||
case ui_element::item_arrow:
|
||||
{
|
||||
treebase_.tail(style_.active);
|
||||
nana::string name = utf8_cast(style_.module.items[style_.module.index]->text());
|
||||
node_handle node = treebase_.find_child(name);
|
||||
node_handle node = treebase_.find_child(style_.module.items[style_.module.index]->text());
|
||||
if(node)
|
||||
{
|
||||
treebase_.cur(node);
|
||||
@ -769,7 +768,6 @@ namespace nana
|
||||
private:
|
||||
window window_{nullptr};
|
||||
nana::paint::graphics * graph_{nullptr};
|
||||
nana::string splitstr_;
|
||||
std::size_t head_;
|
||||
unsigned item_height_;
|
||||
std::size_t item_lines_;
|
||||
@ -808,14 +806,14 @@ namespace nana
|
||||
void trigger::insert(const std::string& str, nana::any value)
|
||||
{
|
||||
throw_not_utf8(str);
|
||||
scheme_->tree().insert(utf8_cast(str), value);
|
||||
API::dev::window_caption(scheme_->window_handle(), utf8_cast(scheme_->tree().path()));
|
||||
scheme_->tree().insert(str, value);
|
||||
API::dev::window_caption(scheme_->window_handle(), scheme_->tree().path());
|
||||
scheme_->draw();
|
||||
}
|
||||
|
||||
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();
|
||||
return true;
|
||||
@ -825,7 +823,7 @@ namespace nana
|
||||
|
||||
bool trigger::childset_erase(const std::string& str)
|
||||
{
|
||||
if(scheme_->tree().childset_erase(utf8_cast(str)))
|
||||
if(scheme_->tree().childset_erase(str))
|
||||
{
|
||||
scheme_->draw();
|
||||
return true;
|
||||
@ -843,24 +841,24 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
void trigger::splitstr(const nana::string& sstr)
|
||||
void trigger::splitstr(const std::string& sstr)
|
||||
{
|
||||
scheme_->tree().splitstr(sstr);
|
||||
}
|
||||
|
||||
const nana::string& trigger::splitstr() const
|
||||
const std::string& trigger::splitstr() const
|
||||
{
|
||||
return scheme_->tree().splitstr();
|
||||
}
|
||||
|
||||
void trigger::path(const std::string& str)
|
||||
{
|
||||
scheme_->tree().path(utf8_cast(str));
|
||||
scheme_->tree().path(str);
|
||||
}
|
||||
|
||||
std::string trigger::path() const
|
||||
{
|
||||
return utf8_cast(scheme_->tree().path());
|
||||
return scheme_->tree().path();
|
||||
}
|
||||
|
||||
nana::any& trigger::value() const
|
||||
|
@ -49,7 +49,7 @@ namespace checkbox
|
||||
{
|
||||
_m_draw_background(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&)
|
||||
|
@ -109,7 +109,7 @@ namespace nana
|
||||
|
||||
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
|
||||
|
||||
@ -325,7 +325,7 @@ namespace nana
|
||||
_m_open_scrollbar(*widget_, pages);
|
||||
}
|
||||
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
|
||||
graph_->rectangle(false, colors::black);
|
||||
|
@ -82,7 +82,7 @@ namespace nana
|
||||
|
||||
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;
|
||||
fblock_ = nullptr;
|
||||
@ -169,7 +169,7 @@ namespace nana
|
||||
|
||||
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;
|
||||
fblock_ = nullptr;
|
||||
|
@ -3146,7 +3146,7 @@ namespace nana
|
||||
|
||||
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->string(point{ xpos, y + 2 }, STR("..."));
|
||||
graph->string(point{ xpos, y + 2 }, L"...");
|
||||
|
||||
//Erase the part that over the next subitem.
|
||||
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)
|
||||
{
|
||||
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_->suspension_width = graph.text_extent_size(STR("...")).width;
|
||||
essence_->suspension_width = graph.text_extent_size(L"...").width;
|
||||
}
|
||||
|
||||
void trigger::refresh(graph_reference)
|
||||
@ -3581,7 +3581,7 @@ namespace nana
|
||||
case keyboard::os_arrow_down:
|
||||
essence_->lister.move_select(up, !arg.shift, true);
|
||||
break;
|
||||
case STR(' ') :
|
||||
case L' ':
|
||||
{
|
||||
selection s;
|
||||
bool ck = ! essence_->lister.item_selected_all_checked(s);
|
||||
|
@ -363,7 +363,7 @@ namespace nana
|
||||
|
||||
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;
|
||||
for (auto & m : menu_->items)
|
||||
|
@ -442,7 +442,7 @@ namespace nana{ namespace widgets
|
||||
bool adjusted_cond = true;
|
||||
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);
|
||||
}
|
||||
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
|
||||
{
|
||||
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
|
||||
@ -1764,7 +1764,7 @@ namespace nana{ namespace widgets
|
||||
str = textbase_.getline(0);
|
||||
for(std::size_t i = 1; i < lines; ++i)
|
||||
{
|
||||
str += STR("\n\r");
|
||||
str += L"\n\r";
|
||||
str += textbase_.getline(i);
|
||||
}
|
||||
}
|
||||
@ -2756,11 +2756,11 @@ namespace nana{ namespace widgets
|
||||
if(a.y != b.y)
|
||||
{
|
||||
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)
|
||||
{
|
||||
text += textbase_.getline(i);
|
||||
text += STR("\r\n");
|
||||
text += L"\r\n";
|
||||
}
|
||||
text += textbase_.getline(b.y).substr(0, b.x);
|
||||
}
|
||||
@ -2801,7 +2801,7 @@ namespace nana{ namespace widgets
|
||||
std::size_t begin = 0;
|
||||
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 (!lines.empty())
|
||||
@ -2813,7 +2813,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
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
|
||||
const auto chp_end = text_str + (begin == text.npos ? text.size() : begin);
|
||||
@ -3068,7 +3068,7 @@ namespace nana{ namespace widgets
|
||||
keyword_parser parser;
|
||||
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();
|
||||
|
||||
|
@ -29,11 +29,11 @@ namespace nana
|
||||
{
|
||||
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())
|
||||
{
|
||||
const nana::char_t * s = text.c_str();
|
||||
auto s = text.c_str();
|
||||
for(std::size_t i = 0; i < len; ++i)
|
||||
{
|
||||
if('a' <= s[i] && s[i] <= 'z')
|
||||
@ -49,7 +49,7 @@ namespace nana
|
||||
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)
|
||||
{
|
||||
@ -217,7 +217,7 @@ namespace nana
|
||||
nana::scroll<true> scroll;
|
||||
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;
|
||||
int indent_pixels;
|
||||
@ -241,7 +241,7 @@ namespace nana
|
||||
|
||||
struct track_node_tag
|
||||
{
|
||||
nana::string key_buf;
|
||||
::std::string key_buf;
|
||||
std::size_t key_time;
|
||||
}track_node;
|
||||
|
||||
@ -320,9 +320,9 @@ namespace nana
|
||||
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';
|
||||
|
||||
@ -334,8 +334,18 @@ namespace nana
|
||||
pattern = track_node.key_buf;
|
||||
|
||||
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;
|
||||
|
||||
@ -604,7 +614,7 @@ namespace nana
|
||||
|
||||
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
|
||||
@ -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_)
|
||||
return item_proxy();
|
||||
@ -892,34 +902,34 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
const nana::string& item_proxy::icon() const
|
||||
const std::string& item_proxy::icon() const
|
||||
{
|
||||
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;
|
||||
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);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const nana::string& item_proxy::key() const
|
||||
const std::string& item_proxy::key() const
|
||||
{
|
||||
return node_->value.first;
|
||||
}
|
||||
|
||||
const nana::string& item_proxy::text() const
|
||||
const std::string& item_proxy::text() const
|
||||
{
|
||||
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());
|
||||
return *this;
|
||||
@ -973,27 +983,19 @@ namespace nana
|
||||
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));
|
||||
}
|
||||
|
||||
bool item_proxy::operator==(const char* s) const
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
return (node_ && (node_->value.second.text == nana::string(nana::charset(s))));
|
||||
#else
|
||||
return (node_ && s && (node_->value.second.text == s));
|
||||
#endif
|
||||
return (node_ && (node_->value.second.text == s));
|
||||
}
|
||||
|
||||
bool item_proxy::operator==(const wchar_t* s) const
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
return (node_ && s && (node_->value.second.text == s));
|
||||
#else
|
||||
return (node_ && (node_->value.second.text == nana::string(nana::charset(s))));
|
||||
#endif
|
||||
return (node_ && s && (node_->value.second.text == utf8_cast(s)));
|
||||
}
|
||||
|
||||
// Behavior of Iterator
|
||||
@ -1114,7 +1116,7 @@ namespace nana
|
||||
|
||||
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
|
||||
@ -1468,7 +1470,7 @@ namespace nana
|
||||
: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)
|
||||
{}
|
||||
|
||||
@ -1702,7 +1704,7 @@ namespace nana
|
||||
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);
|
||||
if(p)
|
||||
@ -1715,7 +1717,7 @@ namespace nana
|
||||
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)));
|
||||
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))
|
||||
{
|
||||
@ -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);
|
||||
if(i != impl_->shape.image_table.end())
|
||||
@ -1801,14 +1803,14 @@ namespace nana
|
||||
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);
|
||||
if(0 == impl_->shape.image_table.size())
|
||||
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))
|
||||
{
|
||||
@ -1826,7 +1828,7 @@ namespace nana
|
||||
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))
|
||||
{
|
||||
@ -2194,28 +2196,28 @@ namespace nana
|
||||
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);
|
||||
}
|
||||
|
||||
void treebox::icon_erase(const nana::string& id)
|
||||
void treebox::icon_erase(const std::string& 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();
|
||||
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)));
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
@ -2227,22 +2229,22 @@ namespace nana
|
||||
return next;
|
||||
}
|
||||
|
||||
void treebox::erase(const nana::string& keypath)
|
||||
void treebox::erase(const std::string& keypath)
|
||||
{
|
||||
auto i = find(keypath);
|
||||
if(!i.empty())
|
||||
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 pnode = i._m_node();
|
||||
if(tree.verify(pnode))
|
||||
{
|
||||
auto root = tree.get_root();
|
||||
nana::string path;
|
||||
nana::string temp;
|
||||
std::string path;
|
||||
std::string temp;
|
||||
while(pnode->owner != root)
|
||||
{
|
||||
temp = splitter;
|
||||
|
@ -322,8 +322,8 @@ namespace paint
|
||||
handle_ = dw;
|
||||
size_ = sz;
|
||||
|
||||
handle_->string.tab_pixels = detail::raw_text_extent_size(handle_, STR("\t"), 1).width;
|
||||
handle_->string.whitespace_pixels = detail::raw_text_extent_size(handle_, STR(" "), 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_, L" ", 1).width;
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,8 +348,8 @@ namespace paint
|
||||
#if defined(NANA_WINDOWS)
|
||||
::SelectObject(handle_->context, reinterpret_cast<HFONT>(f.impl_->font_ptr->handle));
|
||||
#endif
|
||||
handle_->string.tab_pixels = detail::raw_text_extent_size(handle_, STR("\t"), 1).width;
|
||||
handle_->string.whitespace_pixels = detail::raw_text_extent_size(handle_, STR(" "), 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_, L" ", 1).width;
|
||||
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);
|
||||
string(pos, static_cast<std::wstring>(::nana::charset(text, ::nana::unicode::utf8)));
|
||||
throw_not_utf8(text_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)
|
||||
|
@ -218,7 +218,7 @@ namespace paint
|
||||
|
||||
do
|
||||
{
|
||||
if (STR("ICO") == type_str)
|
||||
if (L"ICO" == type_str)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
helper = new detail::image_ico(true);
|
||||
@ -228,7 +228,7 @@ namespace paint
|
||||
break;
|
||||
}
|
||||
|
||||
if (STR("PNG") == type_str)
|
||||
if (L"PNG" == type_str)
|
||||
{
|
||||
#if defined(NANA_ENABLE_PNG)
|
||||
helper = new detail::image_png;
|
||||
@ -238,7 +238,7 @@ namespace paint
|
||||
break;
|
||||
}
|
||||
|
||||
if (STR("JPG") == type_str || STR("JPEG") == type_str)
|
||||
if (L"JPG" == type_str || L"JPEG" == type_str)
|
||||
{
|
||||
#if defined(NANA_ENABLE_JPEG)
|
||||
helper = new detail::image_jpeg;
|
||||
|
@ -124,7 +124,7 @@ namespace nana
|
||||
draw_string_omitted(graphics& graph, int x, int endpos, bool omitted)
|
||||
: 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))
|
||||
this->endpos -= omitted_pixels;
|
||||
else
|
||||
@ -165,7 +165,7 @@ namespace nana
|
||||
r.y = top;
|
||||
graph.bitblt(r, dum_graph);
|
||||
if(omitted_pixels)
|
||||
detail::draw_string(dw, point{ endpos, top }, STR("..."), 3);
|
||||
detail::draw_string(dw, point{ endpos, top }, L"...", 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -104,14 +104,14 @@ namespace system
|
||||
return;
|
||||
|
||||
#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,
|
||||
//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.
|
||||
//In that case, COM should be initialized under WinXP.
|
||||
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)
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user