fix compile errors under Linux
This commit is contained in:
parent
c260eebbc3
commit
2ca11d4e25
@ -67,7 +67,8 @@ namespace nana
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::basic_string<wchar_t, casei_char_traits<wchar_t> > cistring;
|
||||
using cistring = std::basic_string<char, casei_char_traits<char>>;
|
||||
using ciwstring = std::basic_string<wchar_t, casei_char_traits<wchar_t>>;
|
||||
|
||||
|
||||
namespace detail
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <nana/config.hpp>
|
||||
#include <nana/charset.hpp>
|
||||
|
||||
|
||||
//Implement workarounds for GCC/MinGW which version is below 4.8.2
|
||||
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)
|
||||
namespace std
|
||||
@ -91,6 +90,7 @@ namespace nana
|
||||
bool is_utf8(const char* str, unsigned len);
|
||||
void throw_not_utf8(const std::string& text);
|
||||
void throw_not_utf8(const char*, unsigned len);
|
||||
void throw_not_utf8(const char*);
|
||||
|
||||
std::wstring utf8_cast(const std::string&);
|
||||
std::string utf8_cast(const std::wstring&);
|
||||
@ -105,7 +105,7 @@ namespace nana
|
||||
#if defined(NANA_WINDOWS)
|
||||
std::string to_osmbstr(const std::string& text_utf8);
|
||||
#else
|
||||
std::string to_osmbstr(std::string text_utf8)
|
||||
std::string to_osmbstr(std::string text_utf8);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* A File Iterator Implementation
|
||||
* Copyright(C) 2003 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: stdex/filesystem/file_iterator.hpp
|
||||
* @file: filesystem/file_iterator.hpp
|
||||
* @description:
|
||||
* file_iterator is a toolkit for applying each file and directory in a
|
||||
* specified path.
|
||||
@ -39,7 +39,7 @@ namespace filesystem
|
||||
#ifdef NANA_WINDOWS
|
||||
fileinfo(const WIN32_FIND_DATA& wfd);
|
||||
#elif defined(NANA_POSIX)
|
||||
fileinfo(const nana::string& filename, const struct stat &);
|
||||
fileinfo(const std::string& filename, const struct stat &);
|
||||
#endif
|
||||
::std::string name;
|
||||
|
||||
@ -119,10 +119,10 @@ namespace filesystem
|
||||
}
|
||||
value_ = value_type(wfd_);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
auto path = file_path;
|
||||
if(path.size() && path.back() != '/')
|
||||
path += '/';
|
||||
auto handle = opendir(path.c_str());
|
||||
path_ = file_path;
|
||||
if(path_.size() && path_.back() != '/')
|
||||
path_ += '/';
|
||||
auto handle = opendir(path_.c_str());
|
||||
|
||||
end_ = true;
|
||||
if(handle)
|
||||
@ -141,9 +141,9 @@ 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);
|
||||
value_ = value_type(dnt->d_name, fst);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -226,6 +226,8 @@ namespace filesystem
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FIND_DATA wfd_;
|
||||
#else
|
||||
std::string path_;
|
||||
#endif
|
||||
std::shared_ptr<find_handle_t> find_ptr_;
|
||||
|
||||
|
@ -448,17 +448,16 @@ namespace filesystem
|
||||
//bool create_directory(const path& p, error_code& ec) noexcept;
|
||||
bool create_directory(const path& p, const path& attributes);
|
||||
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
|
||||
bool create_directory(const nana::string& dir, bool & if_exist);
|
||||
bool create_directory(const std::wstring& p, bool & if_exist);
|
||||
inline bool create_directory(const path& p, bool & if_exist)
|
||||
{
|
||||
return create_directory(p.filename(), if_exist);
|
||||
};
|
||||
|
||||
|
||||
bool modified_file_time(const nana::string& file, struct tm&);
|
||||
bool modified_file_time(const std::wstring& file, struct tm&);
|
||||
|
||||
|
||||
nana::string path_user();
|
||||
path path_user();
|
||||
|
||||
|
||||
path current_path();
|
||||
@ -470,12 +469,12 @@ namespace filesystem
|
||||
|
||||
//bool remove(const path& p);
|
||||
//bool remove(const path& p, error_code& ec) noexcept;
|
||||
bool rmfile(const char* file);
|
||||
bool rmfile(const path& p);
|
||||
|
||||
//uintmax_t remove_all(const path& p);
|
||||
//uintmax_t remove_all(const path& p, error_code& ec) noexcept;
|
||||
bool rmdir(const char* dir, bool fails_if_not_empty);
|
||||
bool rmdir(const wchar_t* dir, bool fails_if_not_empty);
|
||||
|
||||
bool rmdir(const path& p, bool fails_if_not_empty);
|
||||
|
||||
template<typename CharType>
|
||||
std::basic_string<CharType> parent_path(const std::basic_string<CharType>& path)
|
||||
|
@ -28,10 +28,10 @@ namespace filesystem
|
||||
long long filesize(const nana::string& file);
|
||||
|
||||
bool mkdir(const ::std::string& dir, bool & if_exist);
|
||||
bool modified_file_time(const nana::string& file, struct tm&);
|
||||
bool modified_file_time(const ::std::string& file, struct tm&);
|
||||
|
||||
nana::string path_user();
|
||||
nana::string path_current();
|
||||
std::wstring path_user();
|
||||
std::wstring path_current();
|
||||
|
||||
bool rmfile(const char* file_utf8);
|
||||
bool rmdir(const char* dir, bool fails_if_not_empty);
|
||||
@ -59,6 +59,7 @@ namespace filesystem
|
||||
std::string text_;
|
||||
#endif
|
||||
};
|
||||
|
||||
}//end namespace filesystem
|
||||
}//end namespace nana
|
||||
|
||||
|
@ -155,8 +155,9 @@ namespace nana
|
||||
: public widget_object<category::widget_tag, drawerbase::categorize::trigger, drawerbase::categorize::categorize_events<T>>
|
||||
{
|
||||
public:
|
||||
typedef T value_type; ///< The type of objects stored
|
||||
typedef drawerbase::categorize::renderer renderer; ///< The interface for user-defined renderer.
|
||||
using native_string_type = widget::native_string_type;
|
||||
using value_type = T; ///< The type of objects stored
|
||||
using renderer = drawerbase::categorize::renderer; ///< The interface for user-defined renderer.
|
||||
|
||||
categorize()
|
||||
{
|
||||
@ -177,13 +178,13 @@ namespace nana
|
||||
categorize(window wd, const std::string& text_utf8, bool visible = true)
|
||||
: categorize(wd, ::nana::rectangle(), visible)
|
||||
{
|
||||
this->caption(text);
|
||||
this->caption(text_utf8);
|
||||
}
|
||||
|
||||
categorize(window wd, const char* text_utf8, bool visible = true)
|
||||
: categorize(wd, ::nana::rectangle(), visible)
|
||||
{
|
||||
this->caption(text);
|
||||
this->caption(text_utf8);
|
||||
}
|
||||
|
||||
categorize(window wd, const std::wstring& text, bool visible = true)
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include <nana/deploy.hpp>
|
||||
#include <cstdlib>
|
||||
#include <cstring> //std::strlen
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
@ -472,6 +473,13 @@ namespace nana
|
||||
throw std::invalid_argument("The text is not encoded in UTF8");
|
||||
}
|
||||
|
||||
void throw_not_utf8(const char* text)
|
||||
{
|
||||
if (!is_utf8(text, std::strlen(text)))
|
||||
throw std::invalid_argument("The text is not encoded in UTF8");
|
||||
|
||||
}
|
||||
|
||||
std::wstring utf8_cast(const std::string& text)
|
||||
{
|
||||
return ::nana::charset(text, ::nana::unicode::utf8);
|
||||
|
@ -555,12 +555,11 @@ namespace detail
|
||||
font_ptr_t ref;
|
||||
#if 1 //Xft
|
||||
if(0 == name || *name == 0)
|
||||
name = STR("*");
|
||||
name = "*";
|
||||
|
||||
std::string nmstr = nana::charset(name);
|
||||
XftFont* handle = 0;
|
||||
std::stringstream ss;
|
||||
ss<<nmstr<<"-"<<(height ? height : 10);
|
||||
ss<<name<<"-"<<(height ? height : 10);
|
||||
XftPattern * pat = ::XftNameParse(ss.str().c_str());
|
||||
XftResult res;
|
||||
XftPattern * match_pat = ::XftFontMatch(display_, ::XDefaultScreen(display_), pat, &res);
|
||||
@ -1216,7 +1215,7 @@ namespace detail
|
||||
0, AnyPropertyType, &type, &format, &len,
|
||||
&dummy_bytes_left, &data))
|
||||
{
|
||||
std::vector<nana::string> * files = new std::vector<nana::string>;
|
||||
auto files = new std::vector<std::string>;
|
||||
std::stringstream ss(reinterpret_cast<char*>(data));
|
||||
while(true)
|
||||
{
|
||||
@ -1235,7 +1234,7 @@ namespace detail
|
||||
break;
|
||||
}
|
||||
|
||||
files->push_back(nana::charset(file));
|
||||
files->push_back(file);
|
||||
}
|
||||
if(files->size())
|
||||
{
|
||||
@ -1244,6 +1243,8 @@ namespace detail
|
||||
msg.u.mouse_drop.y = self.xdnd_.pos.y;
|
||||
msg.u.mouse_drop.files = files;
|
||||
}
|
||||
else
|
||||
delete files;
|
||||
|
||||
accepted = true;
|
||||
::XFree(data);
|
||||
|
@ -327,7 +327,7 @@ namespace nana {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool modified_file_time(const nana::string& file, struct tm& t)
|
||||
bool modified_file_time(const std::wstring& file, struct tm& t)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||
@ -361,17 +361,17 @@ namespace nana {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool create_directory(const nana::string& path, bool & if_exist)
|
||||
bool create_directory(const std::wstring& path, bool & if_exist)
|
||||
{
|
||||
if_exist = false;
|
||||
if (path.size() == 0) return false;
|
||||
|
||||
nana::string root;
|
||||
std::wstring root;
|
||||
#if defined(NANA_WINDOWS)
|
||||
if (path.size() > 3 && path[1] == L':')
|
||||
root = path.substr(0, 3);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
if (path[0] == STR('/'))
|
||||
if (path[0] == L'/')
|
||||
root = '/';
|
||||
#endif
|
||||
bool mkstat = false;
|
||||
@ -412,107 +412,86 @@ namespace nana {
|
||||
return mkstat;
|
||||
}
|
||||
|
||||
bool rmfile(const nana::char_t* file)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
bool ret = false;
|
||||
if (file)
|
||||
{
|
||||
ret = (::DeleteFile(file) == 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()))
|
||||
bool rmfile(const path& p)
|
||||
{
|
||||
if(p.empty())
|
||||
return false;
|
||||
#if defined(NANA_WINDOWS)
|
||||
if (FALSE == ::DeleteFileW(p.c_str()))
|
||||
return (ERROR_FILE_NOT_FOUND == ::GetLastError());
|
||||
|
||||
return true;
|
||||
#elif defined(NANA_POSIX)
|
||||
if (std::remove(p.c_str()))
|
||||
return (errno == ENOENT);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rmdir(const char* dir_utf8, bool fails_if_not_empty)
|
||||
{
|
||||
bool ret = false;
|
||||
if (dir_utf8)
|
||||
|
||||
bool rmdir(const path& p, bool fails_if_not_empty)
|
||||
{
|
||||
if(p.empty())
|
||||
return false;
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
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.c_str());
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
if (::rmdir(dir_utf8))
|
||||
if(FALSE != ::RemoveDirectoryW(p.c_str()))
|
||||
return true;
|
||||
|
||||
if(!fails_if_not_empty && (ERROR_DIR_NOT_EMPTY == ::GetLastError()))
|
||||
return detail::rm_dir_recursive(p.c_str());
|
||||
|
||||
return false;
|
||||
#elif defined(NANA_POSIX)
|
||||
if(::rmdir(p.c_str()))
|
||||
{
|
||||
if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
|
||||
ret = detail::rm_dir_recursive(dir);
|
||||
return detail::rm_dir_recursive(p.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
ret = true;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool rmdir(const wchar_t* dir, bool fails_if_not_empty)
|
||||
{
|
||||
bool ret = false;
|
||||
if (dir)
|
||||
path path_user()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
ret = (::RemoveDirectory(dir) == TRUE);
|
||||
if (!fails_if_not_empty && (::GetLastError() == ERROR_DIR_NOT_EMPTY))
|
||||
ret = detail::rm_dir_recursive(dir);
|
||||
wchar_t pstr[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, pstr)))
|
||||
return pstr;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
if (::rmdir(utf8_cast(dir).c_str()))
|
||||
{
|
||||
if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
|
||||
ret = detail::rm_dir_recursive(dir);
|
||||
}
|
||||
else
|
||||
ret = true;
|
||||
const char * pstr = ::getenv("HOME");
|
||||
if (pstr)
|
||||
return pstr;
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
nana::string path_user()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
nana::char_t path[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, path)))
|
||||
return path;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
const char * s = ::getenv("HOME");
|
||||
if (s)
|
||||
return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8);
|
||||
#endif
|
||||
return nana::string();
|
||||
return path();
|
||||
}
|
||||
|
||||
path current_path()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
nana::char_t buf[MAX_PATH];
|
||||
DWORD len = ::GetCurrentDirectory(MAX_PATH, buf);
|
||||
wchar_t buf[MAX_PATH];
|
||||
DWORD len = ::GetCurrentDirectoryW(MAX_PATH, buf);
|
||||
if (len)
|
||||
{
|
||||
if (len > MAX_PATH)
|
||||
{
|
||||
nana::char_t * p = new nana::char_t[len + 1];
|
||||
::GetCurrentDirectory(len + 1, p);
|
||||
nana::string s = p;
|
||||
wchar_t * p = new wchar_t[len + 1];
|
||||
::GetCurrentDirectoryW(len + 1, p);
|
||||
std::wstring s = p;
|
||||
delete[] p;
|
||||
return s;
|
||||
}
|
||||
return nana::string(buf);
|
||||
return buf;
|
||||
}
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
const char * s = ::getenv("PWD");
|
||||
if (s)
|
||||
return static_cast<nana::string>(nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8));
|
||||
auto pstr = ::getenv("PWD");
|
||||
if (pstr)
|
||||
return pstr;
|
||||
#endif
|
||||
return nana::string();
|
||||
return path();
|
||||
}
|
||||
}//end namespace filesystem
|
||||
} //end namespace experimental
|
||||
|
@ -257,11 +257,11 @@ namespace filesystem
|
||||
#endif
|
||||
}
|
||||
|
||||
bool modified_file_time(const nana::string& file, struct tm& t)
|
||||
bool modified_file_time(const ::std::string& file, struct tm& t)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||
if(::GetFileAttributesEx(file.c_str(), GetFileExInfoStandard, &attr))
|
||||
if(::GetFileAttributesExW(to_nstring(file).c_str(), GetFileExInfoStandard, &attr))
|
||||
{
|
||||
FILETIME local_file_time;
|
||||
if(::FileTimeToLocalFileTime(&attr.ftLastWriteTime, &local_file_time))
|
||||
@ -282,7 +282,7 @@ namespace filesystem
|
||||
}
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat attr;
|
||||
if(0 == ::stat(static_cast<std::string>(nana::charset(file)).c_str(), &attr))
|
||||
if(0 == ::stat(file.c_str(), &attr))
|
||||
{
|
||||
t = *(::localtime(&attr.st_ctime));
|
||||
return true;
|
||||
@ -301,7 +301,7 @@ namespace filesystem
|
||||
if(path.size() > 3 && path[1] == ':')
|
||||
root = path.substr(0, 3);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
if(path[0] == STR('/'))
|
||||
if(path[0] == '/')
|
||||
root = '/';
|
||||
#endif
|
||||
bool mkstat = false;
|
||||
|
@ -1096,7 +1096,7 @@ namespace nana{
|
||||
::XSetWMName(restrict::spec.open_display(), reinterpret_cast<Window>(wd), &name);
|
||||
::XChangeProperty(restrict::spec.open_display(), reinterpret_cast<Window>(wd),
|
||||
restrict::spec.atombase().net_wm_name, restrict::spec.atombase().utf8_string, 8,
|
||||
PropModeReplace, reinterpret_cast<unsigned char*>(text), mbstr.size());
|
||||
PropModeReplace, reinterpret_cast<unsigned char*>(text), title.size());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -38,16 +38,16 @@ namespace nana
|
||||
{
|
||||
struct item_fs
|
||||
{
|
||||
nana::string name;
|
||||
std::string name;
|
||||
::tm modified_time;
|
||||
bool directory;
|
||||
nana::long_long_t bytes;
|
||||
|
||||
friend listbox::iresolver& operator>>(listbox::iresolver& ires, item_fs& m)
|
||||
{
|
||||
nana::string type;
|
||||
std::wstring type;
|
||||
ires>>m.name>>type>>type;
|
||||
m.directory = (type == STR("Directory"));
|
||||
m.directory = (type == L"Directory");
|
||||
return ires;
|
||||
}
|
||||
|
||||
@ -65,16 +65,16 @@ namespace nana
|
||||
ores<<item.name<<tm.str();
|
||||
if(!item.directory)
|
||||
{
|
||||
auto pos = item.name.find_last_of(STR('.'));
|
||||
auto pos = item.name.find_last_of('.');
|
||||
if(pos != item.name.npos && (pos + 1 < item.name.size()))
|
||||
ores<<item.name.substr(pos + 1);
|
||||
else
|
||||
ores<<STR("File");
|
||||
ores<<L"File";
|
||||
|
||||
ores<<_m_trans(item.bytes);
|
||||
}
|
||||
else
|
||||
ores<<STR("Directory");
|
||||
ores<<L"Directory";
|
||||
return ores;
|
||||
}
|
||||
|
||||
@ -87,9 +87,9 @@ namespace nana
|
||||
return ss;
|
||||
}
|
||||
|
||||
static nana::string _m_trans(std::size_t bytes)
|
||||
static std::string _m_trans(std::size_t bytes)
|
||||
{
|
||||
const nana::char_t * ustr[] = {STR(" KB"), STR(" MB"), STR(" GB"), STR(" TB")};
|
||||
const char * ustr[] = {" KB", " MB", " GB", " TB"};
|
||||
std::stringstream ss;
|
||||
if(bytes >= 1024)
|
||||
{
|
||||
@ -108,10 +108,11 @@ namespace nana
|
||||
if(pos + 2 < s.size())
|
||||
s.erase(pos + 2);
|
||||
}
|
||||
return static_cast<nana::string>(nana::charset(s)) + ustr[uid];
|
||||
|
||||
return s + ustr[uid];
|
||||
}
|
||||
ss<<bytes<<" Bytes";
|
||||
return nana::charset(ss.str());
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
@ -131,29 +132,29 @@ namespace nana
|
||||
typedef treebox::item_proxy item_proxy;
|
||||
public:
|
||||
|
||||
filebox_implement(window owner, bool io_read, const nana::string& title)
|
||||
filebox_implement(window owner, bool io_read, const std::string& title)
|
||||
: form(owner, API::make_center(owner, 630, 440)), io_read_(io_read)
|
||||
{
|
||||
path_.create(*this);
|
||||
path_.splitstr(STR("/"));
|
||||
path_.splitstr("/");
|
||||
path_.events().selected.connect_unignorable([this](const arg_categorize<int>&)
|
||||
{
|
||||
auto path = path_.caption();
|
||||
auto root = path.substr(0, path.find(STR('/')));
|
||||
if(root == STR("HOME"))
|
||||
path.replace(0, 4, nana::filesystem::path_user());
|
||||
else if(root == STR("FILESYSTEM"))
|
||||
auto root = path.substr(0, path.find('/'));
|
||||
if(root == "HOME")
|
||||
path.replace(0, 4, to_nstring(nana::filesystem::path_user()));
|
||||
else if(root == "FILESYSTEM")
|
||||
path.erase(0, 10);
|
||||
else
|
||||
throw std::runtime_error("Nana.GUI.Filebox: Wrong categorize path");
|
||||
|
||||
if(path.size() == 0) path = STR("/");
|
||||
if(path.size() == 0) path = "/";
|
||||
_m_load_cat_path(path);
|
||||
});
|
||||
|
||||
filter_.create(*this);
|
||||
filter_.multi_lines(false);
|
||||
filter_.tip_string(STR("Filter"));
|
||||
filter_.tip_string("Filter");
|
||||
|
||||
filter_.events().key_release.connect_unignorable([this](const arg_keyboard&)
|
||||
{
|
||||
@ -161,23 +162,23 @@ namespace nana
|
||||
});
|
||||
|
||||
btn_folder_.create(*this);
|
||||
btn_folder_.caption(STR("&New Folder"));
|
||||
btn_folder_.caption("&New Folder");
|
||||
|
||||
btn_folder_.events().click.connect_unignorable([this](const arg_click&)
|
||||
{
|
||||
form fm(this->handle(), API::make_center(*this, 300, 35));
|
||||
fm.caption(STR("Name the new folder"));
|
||||
fm.caption("Name the new folder");
|
||||
|
||||
textbox folder(fm, nana::rectangle(5, 5, 160, 25));
|
||||
folder.multi_lines(false);
|
||||
|
||||
button btn(fm, nana::rectangle(170, 5, 60, 25));
|
||||
btn.caption(STR("Create"));
|
||||
btn.caption("Create");
|
||||
|
||||
btn.events().click.connect_unignorable(folder_creator(*this, fm, folder));
|
||||
|
||||
button btn_cancel(fm, nana::rectangle(235, 5, 60, 25));
|
||||
btn_cancel.caption(STR("Cancel"));
|
||||
btn_cancel.caption("Cancel");
|
||||
|
||||
btn_cancel.events().click.connect_unignorable([&fm](const arg_click&)
|
||||
{
|
||||
@ -189,17 +190,17 @@ namespace nana
|
||||
tree_.create(*this);
|
||||
|
||||
ls_file_.create(*this);
|
||||
ls_file_.append_header(STR("Name"), 190);
|
||||
ls_file_.append_header(STR("Modified"), 145);
|
||||
ls_file_.append_header(STR("Type"), 80);
|
||||
ls_file_.append_header(STR("Size"), 70);
|
||||
ls_file_.append_header("Name", 190);
|
||||
ls_file_.append_header("Modified", 145);
|
||||
ls_file_.append_header("Type", 80);
|
||||
ls_file_.append_header("Size", 70);
|
||||
|
||||
auto fn_sel_file = [this](const arg_mouse& arg){
|
||||
_m_sel_file(arg);
|
||||
};
|
||||
ls_file_.events().dbl_click.connect_unignorable(fn_sel_file);
|
||||
ls_file_.events().mouse_down.connect_unignorable(fn_sel_file);
|
||||
ls_file_.set_sort_compare(0, [](const nana::string& a, nana::any* fs_a, const nana::string& b, nana::any* fs_b, bool reverse) -> bool
|
||||
ls_file_.set_sort_compare(0, [](const std::string& a, nana::any* fs_a, const std::string& b, nana::any* fs_b, bool reverse) -> bool
|
||||
{
|
||||
int dira = fs_a->get<item_fs>()->directory ? 1 : 0;
|
||||
int dirb = fs_b->get<item_fs>()->directory ? 1 : 0;
|
||||
@ -211,8 +212,8 @@ namespace nana
|
||||
|
||||
while(true)
|
||||
{
|
||||
std::size_t pos_a = a.find_first_of(STR("0123456789"), seek_a);
|
||||
std::size_t pos_b = b.find_first_of(STR("0123456789"), seek_b);
|
||||
std::size_t pos_a = a.find_first_of("0123456789", seek_a);
|
||||
std::size_t pos_b = b.find_first_of("0123456789", seek_b);
|
||||
|
||||
if((pos_a != a.npos) && (pos_a == pos_b))
|
||||
{
|
||||
@ -222,11 +223,11 @@ namespace nana
|
||||
if(text_a != text_b)
|
||||
return (reverse ? text_a > text_b : text_a < text_b);
|
||||
|
||||
std::size_t end_a = a.find_first_not_of(STR("0123456789"), pos_a + 1);
|
||||
std::size_t end_b = b.find_first_not_of(STR("0123456789"), pos_b + 1);
|
||||
std::size_t end_a = a.find_first_not_of("0123456789", pos_a + 1);
|
||||
std::size_t end_b = b.find_first_not_of("0123456789", pos_b + 1);
|
||||
|
||||
nana::string num_a = a.substr(pos_a, end_a != a.npos ? end_a - pos_a : a.npos);
|
||||
nana::string num_b = b.substr(pos_b, end_b != b.npos ? end_b - pos_b : b.npos);
|
||||
auto num_a = a.substr(pos_a, end_a != a.npos ? end_a - pos_a : a.npos);
|
||||
auto num_b = b.substr(pos_b, end_b != b.npos ? end_b - pos_b : b.npos);
|
||||
|
||||
if(num_a != num_b)
|
||||
{
|
||||
@ -253,7 +254,7 @@ namespace nana
|
||||
return (reverse ? cia > cib : cia < cib);
|
||||
return (reverse ? cia.substr(seek_a) > cib.substr(seek_b) : cia.substr(seek_a) < cib.substr(seek_b));
|
||||
});
|
||||
ls_file_.set_sort_compare(2, [](const nana::string& a, nana::any* anyptr_a, const nana::string& b, nana::any* anyptr_b, bool reverse) -> bool
|
||||
ls_file_.set_sort_compare(2, [](const std::string& a, nana::any* anyptr_a, const std::string& b, nana::any* anyptr_b, bool reverse) -> bool
|
||||
{
|
||||
int dir1 = anyptr_a->get<item_fs>()->directory ? 1 : 0;
|
||||
int dir2 = anyptr_b->get<item_fs>()->directory ? 1 : 0;
|
||||
@ -262,7 +263,7 @@ namespace nana
|
||||
|
||||
return (reverse ? a > b : a < b);
|
||||
});
|
||||
ls_file_.set_sort_compare(3, [this](const nana::string&, nana::any* anyptr_a, const nana::string&, nana::any* anyptr_b, bool reverse) -> bool
|
||||
ls_file_.set_sort_compare(3, [this](const std::string&, nana::any* anyptr_a, const std::string&, nana::any* anyptr_b, bool reverse) -> bool
|
||||
{
|
||||
item_fs * fsa = anyptr_a->get<item_fs>();
|
||||
item_fs * fsb = anyptr_b->get<item_fs>();
|
||||
@ -270,7 +271,7 @@ namespace nana
|
||||
});
|
||||
|
||||
lb_file_.create(*this);
|
||||
lb_file_.caption(STR("File:"));
|
||||
lb_file_.caption("File:");
|
||||
|
||||
tb_file_.create(*this);
|
||||
tb_file_.multi_lines(false);
|
||||
@ -286,14 +287,14 @@ namespace nana
|
||||
cb_types_.events().selected.connect_unignorable([this](const arg_combox&){ _m_list_fs(); });
|
||||
|
||||
btn_ok_.create(*this);
|
||||
btn_ok_.caption(STR("&OK"));
|
||||
btn_ok_.caption("&OK");
|
||||
|
||||
btn_ok_.events().click.connect_unignorable([this](const arg_click&)
|
||||
{
|
||||
_m_ok();
|
||||
});
|
||||
btn_cancel_.create(*this);
|
||||
btn_cancel_.caption(STR("&Cancel"));
|
||||
btn_cancel_.caption("&Cancel");
|
||||
|
||||
btn_cancel_.events().click.connect_unignorable([this](const arg_click&)
|
||||
{
|
||||
@ -305,25 +306,25 @@ namespace nana
|
||||
_m_init_tree();
|
||||
|
||||
if(0 == title.size())
|
||||
caption(io_read ? STR("Open") : STR("Save As"));
|
||||
caption(io_read ? "Open" : "Save As");
|
||||
else
|
||||
caption(title);
|
||||
}
|
||||
|
||||
void def_extension(const nana::string& ext)
|
||||
void def_extension(const std::string& ext)
|
||||
{
|
||||
def_ext_ = ext;
|
||||
}
|
||||
|
||||
void load_fs(const nana::string& init_path, const nana::string& init_file)
|
||||
void load_fs(const std::string& init_path, const std::string& init_file)
|
||||
{
|
||||
//Simulate the behavior like Windows7's lpstrInitialDir(http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx)
|
||||
|
||||
//Phase 1
|
||||
nana::string dir;
|
||||
std::string dir;
|
||||
|
||||
auto pos = init_file.find_last_of(STR("\\/"));
|
||||
nana::string file_with_path_removed = (pos != init_file.npos ? init_file.substr(pos + 1) : init_file);
|
||||
auto pos = init_file.find_last_of("\\/");
|
||||
auto file_with_path_removed = (pos != init_file.npos ? init_file.substr(pos + 1) : init_file);
|
||||
|
||||
if(saved_init_path != init_path)
|
||||
{
|
||||
@ -343,29 +344,29 @@ namespace nana
|
||||
else
|
||||
dir = saved_selected_path;
|
||||
|
||||
_m_load_cat_path(dir.size() ? dir : nana::filesystem::path_user());
|
||||
_m_load_cat_path(dir.size() ? dir : to_nstring(nana::filesystem::path_user()));
|
||||
|
||||
tb_file_.caption(file_with_path_removed);
|
||||
}
|
||||
|
||||
void add_filter(const nana::string& desc, const nana::string& type)
|
||||
void add_filter(const std::string& desc, const std::string& type)
|
||||
{
|
||||
std::size_t i = cb_types_.the_number_of_options();
|
||||
cb_types_.push_back(desc);
|
||||
if(0 == i)
|
||||
cb_types_.option(0);
|
||||
|
||||
std::vector<nana::string> v;
|
||||
std::vector<std::string> v;
|
||||
std::size_t beg = 0;
|
||||
while(true)
|
||||
{
|
||||
auto pos = type.find(STR(';'), beg);
|
||||
auto pos = type.find(';', beg);
|
||||
auto ext = type.substr(beg, pos == type.npos ? type.npos : pos - beg);
|
||||
auto dot = ext.find(STR('.'));
|
||||
auto dot = ext.find('.');
|
||||
if((dot != ext.npos) && (dot + 1 < ext.size()))
|
||||
{
|
||||
ext.erase(0, dot + 1);
|
||||
if(ext == STR("*"))
|
||||
if(ext == "*")
|
||||
{
|
||||
v.clear();
|
||||
break;
|
||||
@ -381,12 +382,12 @@ namespace nana
|
||||
cb_types_.anyobj(i, v);
|
||||
}
|
||||
|
||||
bool file(nana::string& fs) const
|
||||
bool file(std::string& fs) const
|
||||
{
|
||||
if(selection_.type == kind::none)
|
||||
return false;
|
||||
|
||||
auto pos = selection_.target.find_last_of(STR("\\/"));
|
||||
auto pos = selection_.target.find_last_of("\\/");
|
||||
if(pos != selection_.target.npos)
|
||||
saved_selected_path = selection_.target.substr(0, pos);
|
||||
else
|
||||
@ -423,13 +424,13 @@ namespace nana
|
||||
|
||||
//The path in linux is starting with the character '/', the name of root key should be
|
||||
//"FS.HOME", "FS.ROOT". Because a key of the tree widget should not be '/'
|
||||
nodes_.home = tree_.insert(STR("FS.HOME"), STR("Home"));
|
||||
nodes_.home = tree_.insert("FS.HOME", "Home");
|
||||
nodes_.home.value(kind::filesystem);
|
||||
nodes_.filesystem = tree_.insert(STR("FS.ROOT"), STR("Filesystem"));
|
||||
nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem");
|
||||
nodes_.filesystem.value(kind::filesystem);
|
||||
|
||||
file_iterator end;
|
||||
for(file_iterator i(path_user()); i != end; ++i)
|
||||
for(file_iterator i(to_nstring(path_user())); i != end; ++i)
|
||||
{
|
||||
if((false == i->directory) || (i->name.size() && i->name[0] == '.')) continue;
|
||||
|
||||
@ -441,7 +442,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
for(file_iterator i(STR("/")); i != end; ++i)
|
||||
for(file_iterator i("/"); i != end; ++i)
|
||||
{
|
||||
if((false == i->directory) || (i->name.size() && i->name[0] == '.')) continue;
|
||||
|
||||
@ -462,33 +463,33 @@ namespace nana
|
||||
{
|
||||
if(arg.operated && (arg.item.value<kind::t>() == kind::filesystem))
|
||||
{
|
||||
auto path = tree_.make_key_path(arg.item, STR("/")) + STR("/");
|
||||
auto path = tree_.make_key_path(arg.item, "/") + "/";
|
||||
_m_resolute_path(path);
|
||||
_m_load_cat_path(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
nana::string _m_resolute_path(nana::string& path)
|
||||
std::string _m_resolute_path(std::string& path)
|
||||
{
|
||||
auto pos = path.find(STR('/'));
|
||||
auto pos = path.find('/');
|
||||
if(pos != path.npos)
|
||||
{
|
||||
auto begstr = path.substr(0, pos);
|
||||
if(begstr == STR("FS.HOME"))
|
||||
path.replace(0, 7, nana::filesystem::path_user());
|
||||
if(begstr == "FS.HOME")
|
||||
path.replace(0, 7, to_nstring(nana::filesystem::path_user()));
|
||||
else
|
||||
path.erase(0, pos);
|
||||
return begstr;
|
||||
}
|
||||
return nana::string();
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void _m_load_path(const nana::string& path)
|
||||
void _m_load_path(const std::string& path)
|
||||
{
|
||||
addr_.filesystem = path;
|
||||
if(addr_.filesystem.size() && addr_.filesystem[addr_.filesystem.size() - 1] != STR('/'))
|
||||
addr_.filesystem += STR('/');
|
||||
if(addr_.filesystem.size() && addr_.filesystem[addr_.filesystem.size() - 1] != '/')
|
||||
addr_.filesystem += '/';
|
||||
|
||||
file_container_.clear();
|
||||
|
||||
@ -497,7 +498,7 @@ namespace nana
|
||||
file_iterator end;
|
||||
for(file_iterator i(path); i != end; ++i)
|
||||
{
|
||||
if((i->name.size() == 0) || (i->name[0] == STR('.')))
|
||||
if((i->name.size() == 0) || (i->name[0] == '.'))
|
||||
continue;
|
||||
item_fs m;
|
||||
m.name = i->name;
|
||||
@ -522,32 +523,32 @@ namespace nana
|
||||
std::sort(file_container_.begin(), file_container_.end(), pred_sort_fs());
|
||||
}
|
||||
|
||||
void _m_load_cat_path(nana::string path)
|
||||
void _m_load_cat_path(std::string path)
|
||||
{
|
||||
if((path.size() == 0) || (path[path.size() - 1] != STR('/')))
|
||||
path += STR('/');
|
||||
if((path.size() == 0) || (path[path.size() - 1] != '/'))
|
||||
path += '/';
|
||||
|
||||
auto beg_node = tree_.selected();
|
||||
while(!beg_node.empty() && (beg_node != nodes_.home) && (beg_node != nodes_.filesystem))
|
||||
beg_node = beg_node.owner();
|
||||
|
||||
auto head = nana::filesystem::path_user();
|
||||
auto head = to_nstring(nana::filesystem::path_user());
|
||||
if(path.size() >= head.size() && (path.substr(0, head.size()) == head))
|
||||
{//This is HOME
|
||||
path_.caption(STR("HOME"));
|
||||
path_.caption("HOME");
|
||||
if(beg_node != nodes_.home)
|
||||
nodes_.home->select(true);
|
||||
}
|
||||
else
|
||||
{ //Redirect to '/'
|
||||
path_.caption(STR("FILESYSTEM"));
|
||||
path_.caption("FILESYSTEM");
|
||||
if(beg_node != nodes_.filesystem)
|
||||
nodes_.filesystem->select(true);
|
||||
head.clear();
|
||||
}
|
||||
|
||||
if(head.size() == 0 || head[head.size() - 1] != STR('/'))
|
||||
head += STR('/');
|
||||
if(head.size() == 0 || head[head.size() - 1] != '/')
|
||||
head += '/';
|
||||
|
||||
nana::filesystem::file_iterator end;
|
||||
for(nana::filesystem::file_iterator i(head); i != end; ++i)
|
||||
@ -556,17 +557,17 @@ namespace nana
|
||||
path_.childset(i->name, 0);
|
||||
}
|
||||
auto cat_path = path_.caption();
|
||||
if(cat_path.size() && cat_path[cat_path.size() - 1] != STR('/'))
|
||||
cat_path += STR('/');
|
||||
if(cat_path.size() && cat_path[cat_path.size() - 1] != '/')
|
||||
cat_path += '/';
|
||||
|
||||
auto beg = head.size();
|
||||
while(true)
|
||||
{
|
||||
auto pos = path.find(STR('/'), beg);
|
||||
auto pos = path.find('/', beg);
|
||||
auto folder = path.substr(beg, pos != path.npos ? pos - beg: path.npos);
|
||||
if(folder.size() == 0) break;
|
||||
(cat_path += folder) += STR('/');
|
||||
(head += folder) += STR('/');
|
||||
(cat_path += folder) += '/';
|
||||
(head += folder) += '/';
|
||||
path_.caption(cat_path);
|
||||
|
||||
for(nana::filesystem::file_iterator i(head); i != end; ++i)
|
||||
@ -583,7 +584,7 @@ namespace nana
|
||||
_m_list_fs();
|
||||
}
|
||||
|
||||
bool _m_filter_allowed(const nana::string& name, bool is_dir, const nana::string& filter, const std::vector<nana::string>* extension) const
|
||||
bool _m_filter_allowed(const std::string& name, bool is_dir, const std::string& filter, const std::vector<std::string>* extension) const
|
||||
{
|
||||
if(filter.size() && (name.find(filter) == filter.npos))
|
||||
return false;
|
||||
@ -601,12 +602,12 @@ namespace nana
|
||||
|
||||
void _m_list_fs()
|
||||
{
|
||||
nana::string filter = filter_.caption();
|
||||
auto filter = filter_.caption();
|
||||
ls_file_.auto_draw(false);
|
||||
|
||||
ls_file_.clear();
|
||||
|
||||
std::vector<nana::string>* ext_types = cb_types_.anyobj<std::vector<nana::string> >(cb_types_.option());
|
||||
auto ext_types = cb_types_.anyobj<std::vector<std::string> >(cb_types_.option());
|
||||
auto cat = ls_file_.at(0);
|
||||
for(auto & fs: file_container_)
|
||||
{
|
||||
@ -618,7 +619,7 @@ namespace nana
|
||||
ls_file_.auto_draw(true);
|
||||
}
|
||||
|
||||
void _m_finish(kind::t type, const nana::string& tar)
|
||||
void _m_finish(kind::t type, const std::string& tar)
|
||||
{
|
||||
selection_.target = tar;
|
||||
selection_.type = type;
|
||||
@ -635,11 +636,11 @@ namespace nana
|
||||
{
|
||||
auto path = tx_path_.caption();
|
||||
|
||||
msgbox mb(fm_, STR("Create Folder"));
|
||||
msgbox mb(fm_, "Create Folder");
|
||||
mb.icon(msgbox::icon_warning);
|
||||
if(0 == path.size() || path[0] == STR('.') || path[0] == STR('/'))
|
||||
if(0 == path.size() || path[0] == '.' || path[0] == '/')
|
||||
{
|
||||
mb<<STR("Please input a valid name for the new folder.");
|
||||
mb<<L"Please input a valid name for the new folder.";
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
@ -648,9 +649,9 @@ namespace nana
|
||||
if(false == nana::filesystem::mkdir(fb_.addr_.filesystem + path, if_exist))
|
||||
{
|
||||
if(if_exist)
|
||||
mb<<STR("The folder is existing, please rename it.");
|
||||
mb<<L"The folder is existing, please rename it.";
|
||||
else
|
||||
mb<<STR("Failed to create the folder, please rename it.");
|
||||
mb<<L"Failed to create the folder, please rename it.";
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
@ -663,29 +664,29 @@ namespace nana
|
||||
textbox & tx_path_;
|
||||
};
|
||||
|
||||
bool _m_append_def_extension(nana::string& tar) const
|
||||
bool _m_append_def_extension(std::string& tar) const
|
||||
{
|
||||
auto dotpos = tar.find_last_of(STR('.'));
|
||||
auto dotpos = tar.find_last_of('.');
|
||||
if(dotpos != tar.npos)
|
||||
{
|
||||
auto pos = tar.find_last_of(STR("/\\"));
|
||||
auto pos = tar.find_last_of("/\\");
|
||||
if(pos == tar.npos || pos < dotpos)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(def_ext_.size())
|
||||
{
|
||||
if(def_ext_[0] != STR('.'))
|
||||
tar += STR('.');
|
||||
if(def_ext_[0] != '.')
|
||||
tar += '.';
|
||||
tar += def_ext_;
|
||||
}
|
||||
|
||||
std::vector<nana::string> * exts = cb_types_.anyobj<std::vector<nana::string> >(cb_types_.option());
|
||||
auto exts = cb_types_.anyobj<std::vector<std::string> >(cb_types_.option());
|
||||
if(0 == exts || exts->size() == 0) return false;
|
||||
|
||||
auto & ext = exts->at(0);
|
||||
if(def_ext_[0] != STR('.'))
|
||||
tar += STR('.');
|
||||
if(def_ext_[0] != '.')
|
||||
tar += '.';
|
||||
tar += ext;
|
||||
return true;
|
||||
}
|
||||
@ -703,7 +704,7 @@ namespace nana
|
||||
if(event_code::dbl_click == arg.evt_code)
|
||||
{
|
||||
if(m.directory)
|
||||
_m_load_cat_path(addr_.filesystem + m.name + STR("/"));
|
||||
_m_load_cat_path(addr_.filesystem + m.name + "/");
|
||||
else
|
||||
_m_finish(kind::filesystem, addr_.filesystem + m.name);
|
||||
}
|
||||
@ -724,16 +725,16 @@ namespace nana
|
||||
auto file = tb_file_.caption();
|
||||
if(file.size())
|
||||
{
|
||||
if(file[0] == STR('.'))
|
||||
if(file[0] == L'.')
|
||||
{
|
||||
msgbox mb(*this, caption());
|
||||
mb.icon(msgbox::icon_warning);
|
||||
mb<<file<<std::endl<<STR("The filename is invalid.");
|
||||
mb<<file<<std::endl<<L"The filename is invalid.";
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
nana::string tar;
|
||||
if(file[0] == STR('/'))
|
||||
std::string tar;
|
||||
if(file[0] == '/')
|
||||
tar = file;
|
||||
else
|
||||
tar = addr_.filesystem + file;
|
||||
@ -751,7 +752,7 @@ namespace nana
|
||||
if(good && attr.is_directory)
|
||||
{
|
||||
_m_load_cat_path(tar);
|
||||
tb_file_.caption(STR(""));
|
||||
tb_file_.caption("");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -761,7 +762,7 @@ namespace nana
|
||||
{
|
||||
msgbox mb(*this, caption());
|
||||
mb.icon(msgbox::icon_information);
|
||||
mb<<STR("The file \"")<<tar<<STR("\"\n is not existing. Please check and retry.");
|
||||
mb<<L"The file \""<<nana::charset(tar, nana::unicode::utf8)<<L"\"\n is not existing. Please check and retry.";
|
||||
mb();
|
||||
}
|
||||
else
|
||||
@ -773,7 +774,7 @@ namespace nana
|
||||
{
|
||||
msgbox mb(*this, caption(), msgbox::yes_no);
|
||||
mb.icon(msgbox::icon_question);
|
||||
mb<<STR("The input file is existing, do you want to overwrite it?");
|
||||
mb<<L"The input file is existing, do you want to overwrite it?";
|
||||
if(msgbox::pick_no == mb())
|
||||
return;
|
||||
}
|
||||
@ -791,7 +792,7 @@ namespace nana
|
||||
|
||||
if(kind::filesystem == node.value<kind::t>())
|
||||
{
|
||||
nana::string path = tree_.make_key_path(node, STR("/")) + STR("/");
|
||||
auto path = tree_.make_key_path(node, "/") + "/";
|
||||
_m_resolute_path(path);
|
||||
|
||||
nana::filesystem::file_iterator end;
|
||||
@ -814,7 +815,7 @@ namespace nana
|
||||
}
|
||||
private:
|
||||
bool io_read_;
|
||||
nana::string def_ext_;
|
||||
std::string def_ext_;
|
||||
|
||||
place place_;
|
||||
categorize<int> path_;
|
||||
@ -835,22 +836,22 @@ namespace nana
|
||||
}nodes_;
|
||||
|
||||
std::vector<item_fs> file_container_;
|
||||
struct path_tag
|
||||
struct path_rep
|
||||
{
|
||||
nana::string filesystem;
|
||||
std::string filesystem;
|
||||
}addr_;
|
||||
|
||||
struct selection_tag
|
||||
struct selection_rep
|
||||
{
|
||||
kind::t type;
|
||||
nana::string target;
|
||||
std::string target;
|
||||
}selection_;
|
||||
|
||||
static nana::string saved_init_path;
|
||||
static nana::string saved_selected_path;
|
||||
static std::string saved_init_path;
|
||||
static std::string saved_selected_path;
|
||||
};//end class filebox_implement
|
||||
nana::string filebox_implement::saved_init_path;
|
||||
nana::string filebox_implement::saved_selected_path;
|
||||
std::string filebox_implement::saved_init_path;
|
||||
std::string filebox_implement::saved_selected_path;
|
||||
|
||||
#endif
|
||||
//class filebox
|
||||
@ -1040,11 +1041,11 @@ namespace nana
|
||||
{
|
||||
for(auto & f: impl_->filters)
|
||||
{
|
||||
nana::string fs = f.type;
|
||||
std::string fs = f.type;
|
||||
std::size_t pos = 0;
|
||||
while(true)
|
||||
{
|
||||
pos = fs.find(STR(" "), pos);
|
||||
pos = fs.find(" ", pos);
|
||||
if(pos == fs.npos)
|
||||
break;
|
||||
fs.erase(pos);
|
||||
@ -1053,7 +1054,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
else
|
||||
fb.add_filter(STR("All Files"), STR("*.*"));
|
||||
fb.add_filter("All Files", "*.*");
|
||||
|
||||
fb.load_fs(impl_->path, impl_->file);
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace nana
|
||||
: public form
|
||||
{
|
||||
public:
|
||||
msgbox_window(window wd, const ::nana::string& title, msgbox::button_t btn, msgbox::icon_t ico)
|
||||
msgbox_window(window wd, const std::string& title, msgbox::button_t btn, msgbox::icon_t ico)
|
||||
: form(wd, rectangle(1, 1, 1, 1), appear::decorate<>()),
|
||||
owner_(wd), pick_(msgbox::pick_yes)
|
||||
{
|
||||
@ -61,14 +61,14 @@ namespace nana
|
||||
{
|
||||
_m_click(arg);
|
||||
});
|
||||
yes_.caption(STR("OK"));
|
||||
yes_.caption("OK");
|
||||
width_pixel += 77;
|
||||
|
||||
if(msgbox::yes_no == btn || msgbox::yes_no_cancel == btn)
|
||||
{
|
||||
yes_.caption(STR("Yes"));
|
||||
yes_.caption("Yes");
|
||||
no_.create(*this);
|
||||
no_.caption(STR("No"));
|
||||
no_.caption("No");
|
||||
no_.events().click.connect_unignorable([this](const arg_click& arg)
|
||||
{
|
||||
_m_click(arg);
|
||||
@ -79,7 +79,7 @@ namespace nana
|
||||
if(msgbox::yes_no_cancel == btn)
|
||||
{
|
||||
cancel_.create(*this);
|
||||
cancel_.caption(STR("Cancel"));
|
||||
cancel_.caption("Cancel");
|
||||
cancel_.events().click.connect_unignorable([this](const arg_click& arg)
|
||||
{
|
||||
_m_click(arg);
|
||||
@ -843,7 +843,7 @@ namespace nana
|
||||
|
||||
void inputbox::text::tip_string(std::wstring tip)
|
||||
{
|
||||
impl_->tip.swap(utf8_cast(tip));
|
||||
impl_->tip = utf8_cast(tip);
|
||||
}
|
||||
|
||||
void inputbox::text::tip_string(std::string tip_utf8)
|
||||
|
@ -400,14 +400,12 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
button::button(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
button::button(window wd, const char* text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text, std::strlen(text));
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
@ -997,7 +997,7 @@ namespace nana
|
||||
|
||||
auto editor = _m_impl().editor();
|
||||
if (editor)
|
||||
editor->text(to_nstring(str));
|
||||
editor->text(to_wstring(str));
|
||||
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ namespace nana
|
||||
|
||||
oresolver& oresolver::operator<<(const wchar_t* text)
|
||||
{
|
||||
cells_.emplace_back(utf8_cast(text));
|
||||
cells_.emplace_back(to_utf8(text));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -178,13 +178,13 @@ namespace nana
|
||||
|
||||
oresolver& oresolver::operator<<(const std::wstring& text)
|
||||
{
|
||||
cells_.emplace_back(utf8_cast(text));
|
||||
cells_.emplace_back(to_utf8(text));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(std::wstring&& text)
|
||||
{
|
||||
cells_.emplace_back(utf8_cast(text));
|
||||
cells_.emplace_back(to_utf8(text));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ namespace nana
|
||||
iresolver& iresolver::operator>>(std::wstring& text)
|
||||
{
|
||||
if (pos_ < cells_.size())
|
||||
text = utf8_cast(cells_[pos_++].text);
|
||||
text = to_wstring(cells_[pos_++].text);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -363,8 +363,7 @@ namespace nana
|
||||
first=false;
|
||||
else
|
||||
head_str += exp_opt.sep;
|
||||
|
||||
head_str += utf8_cast(column_ref(exp_opt.columns_order[idx]).text);
|
||||
head_str += to_utf8(column_ref(exp_opt.columns_order[idx]).text);
|
||||
}
|
||||
return head_str;
|
||||
}
|
||||
@ -2599,7 +2598,7 @@ namespace nana
|
||||
if(first)
|
||||
first=false;
|
||||
else
|
||||
list_str += (utf8_cast(cat.text) + exp_opt.endl);
|
||||
list_str += (to_utf8(cat.text) + exp_opt.endl);
|
||||
|
||||
for (auto i : cat.sorted)
|
||||
{
|
||||
@ -2979,7 +2978,7 @@ namespace nana
|
||||
|
||||
graph->string({ x + 20, y + txtoff }, categ.text, txt_color);
|
||||
|
||||
native_string_type str = L'(' + to_nstring(categ.items.size()) + L')';
|
||||
native_string_type str = to_nstring('(' + std::to_string(categ.items.size()) + ')');
|
||||
|
||||
auto text_s = graph->text_extent_size(categ.text).width;
|
||||
auto extend_text_w = text_s + graph->text_extent_size(str).width;
|
||||
@ -3822,7 +3821,7 @@ namespace nana
|
||||
|
||||
item_proxy& item_proxy::text(size_type col, std::wstring str)
|
||||
{
|
||||
ess_->lister.text(cat_, pos_.item, col, utf8_cast(str), columns());
|
||||
ess_->lister.text(cat_, pos_.item, col, to_utf8(str), columns());
|
||||
ess_->update();
|
||||
return *this;
|
||||
}
|
||||
@ -3864,7 +3863,7 @@ namespace nana
|
||||
|
||||
bool item_proxy::operator==(const std::wstring& s) const
|
||||
{
|
||||
return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == utf8_cast(s));
|
||||
return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == to_utf8(s));
|
||||
}
|
||||
|
||||
item_proxy & item_proxy::operator=(const item_proxy& rhs)
|
||||
@ -4007,7 +4006,7 @@ namespace nana
|
||||
size_type pos = 0;
|
||||
for (auto & txt : arg)
|
||||
{
|
||||
ip.text(pos++, utf8_cast(txt));
|
||||
ip.text(pos++, to_utf8(txt));
|
||||
if (pos >= items)
|
||||
break;
|
||||
}
|
||||
@ -4062,7 +4061,7 @@ namespace nana
|
||||
std::string cat_proxy::text() const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
return utf8_cast(cat_->text);
|
||||
return to_utf8(cat_->text);
|
||||
}
|
||||
|
||||
void cat_proxy::push_back(std::string s)
|
||||
@ -4479,7 +4478,7 @@ namespace nana
|
||||
|
||||
void listbox::insert(const index_pair& pos, std::wstring text)
|
||||
{
|
||||
insert(pos, utf8_cast(text));
|
||||
insert(pos, to_utf8(text));
|
||||
}
|
||||
|
||||
void listbox::checkable(bool chkable)
|
||||
|
@ -1202,7 +1202,7 @@ namespace nana{ namespace widgets
|
||||
return true;
|
||||
};
|
||||
|
||||
::nana::cistring cistr;
|
||||
::nana::ciwstring cistr;
|
||||
for (auto & ds : kwptr->kwbase)
|
||||
{
|
||||
index pos{0} ;
|
||||
|
@ -218,7 +218,7 @@ namespace drawerbase {
|
||||
|
||||
textbox::textbox(window wd, const char* text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text, std::strlen(text));
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace nana
|
||||
|
||||
std::string widget::caption() const throw()
|
||||
{
|
||||
return utf8_cast(_m_caption());
|
||||
return to_utf8(_m_caption());
|
||||
}
|
||||
|
||||
std::wstring widget::caption_wstring() const throw()
|
||||
@ -64,7 +64,7 @@ namespace nana
|
||||
#if defined(NANA_WINDOWS)
|
||||
return _m_caption();
|
||||
#else
|
||||
return utf8_cast(_m_caption());
|
||||
return to_wstring(_m_caption());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,12 @@ namespace paint
|
||||
image::image_impl_interface * helper = nullptr;
|
||||
|
||||
{
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), std::tolower);
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), [](int ch)
|
||||
{
|
||||
if('A' <= ch && ch <= 'Z')
|
||||
ch -= ('A' - 'a');
|
||||
return ch;
|
||||
});
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
const wchar_t* ext_ico = L".ico";
|
||||
|
@ -32,8 +32,8 @@ namespace nana{ namespace system{
|
||||
#ifdef NANA_WINDOWS
|
||||
std::wstring wstr = ::nana::charset(text, nana::unicode::utf8);
|
||||
_m_set(format::text, wstr.c_str(), (wstr.length() + 1) * sizeof(wchar_t));
|
||||
#else
|
||||
_m_set(format::text, text, std::strlen(text) + 1);
|
||||
#elif defined(NANA_X11)
|
||||
_m_set(format::text, text.c_str(), text.length() + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -212,14 +212,14 @@ namespace nana{ namespace system{
|
||||
if(owner)
|
||||
{
|
||||
Atom atom_type;
|
||||
switch(type)
|
||||
switch(fmt)
|
||||
{
|
||||
case format::text: atom_type = spec.atombase().utf8_string; break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
spec.write_selection(owner, spec.atombase().utf8_string, buf, size);
|
||||
spec.write_selection(owner, atom_type, buf, size);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@ -265,7 +265,7 @@ namespace nana{ namespace system{
|
||||
{
|
||||
Atom atom;
|
||||
|
||||
switch(type)
|
||||
switch(fmt)
|
||||
{
|
||||
case format::text: atom = spec.atombase().utf8_string; break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user