Merge branch 'prepare-utf8' into develop
This commit is contained in:
commit
54357bee6d
@ -7,7 +7,7 @@
|
||||
|
||||
#https://cmake.org/cmake-tutorial/
|
||||
#https://cmake.org/cmake/help/v3.3/module/CMakeDependentOption.html?highlight=cmakedependentoption
|
||||
# use CACHE FORCE or set(USE_meganz_mingw_std_threads ON) or delete CMakecache.txt or the entirely build dir
|
||||
# use CACHE FORCE or set(USE_meganz_mingw_std_threads ON) or delete CMakecache.txt or the entirely build dir
|
||||
# if your changes don't execute
|
||||
option(USE_meganz_mingw_std_threads "replaced boost.thread with meganz's mingw-std-threads." OFF)
|
||||
option(USE_UNICODE "Use Unicode Character Set" ON)
|
||||
@ -143,16 +143,15 @@ aux_source_directory(${NANA_SOURCE_DIR}/paint/detail NANA_PAINT_DETAIL_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/system NANA_SYSTEM_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/threads NANA_THREADS_SOURCE)
|
||||
|
||||
#To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library
|
||||
#and Use SOURCE_GROUP if all your sources are in the same directory
|
||||
#To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library
|
||||
#and Use SOURCE_GROUP if all your sources are in the same directory
|
||||
|
||||
if(NOT APPLE)
|
||||
add_library(${PROJECT_NAME} ${NANA_SOURCE}
|
||||
${NANA_DETAIL_SOURCE}
|
||||
${NANA_FILESYSTEM_SOURCE}
|
||||
if(NOT APPLE)
|
||||
${NANA_AUDIO_SOURCE}
|
||||
${NANA_AUDIO_DETAIL_SOURCE}
|
||||
endif (NOT APPLE)
|
||||
${NANA_GUI_SOURCE}
|
||||
${NANA_GUI_DETAIL_SOURCE}
|
||||
${NANA_GUI_WIDGETS_SOURCE}
|
||||
@ -160,11 +159,26 @@ endif (NOT APPLE)
|
||||
${NANA_PAINT_SOURCE}
|
||||
${NANA_PAINT_DETAIL_SOURCE}
|
||||
${NANA_SYSTEM_SOURCE}
|
||||
${NANA_THREADS_SOURCE})
|
||||
${NANA_THREADS_SOURCE})
|
||||
endif (NOT APPLE)
|
||||
|
||||
|
||||
if(APPLE)
|
||||
#Headers: use INCLUDE_DIRECTORIES
|
||||
# Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES
|
||||
add_library(${PROJECT_NAME} ${NANA_SOURCE}
|
||||
${NANA_DETAIL_SOURCE}
|
||||
${NANA_FILESYSTEM_SOURCE}
|
||||
${NANA_AUDIO_SOURCE}
|
||||
${NANA_AUDIO_DETAIL_SOURCE}
|
||||
${NANA_GUI_SOURCE}
|
||||
${NANA_GUI_DETAIL_SOURCE}
|
||||
${NANA_GUI_WIDGETS_SOURCE}
|
||||
${NANA_GUI_WIDGETS_SKELETONS_SOURCE}
|
||||
${NANA_PAINT_SOURCE}
|
||||
${NANA_PAINT_DETAIL_SOURCE}
|
||||
${NANA_SYSTEM_SOURCE}
|
||||
${NANA_THREADS_SOURCE})
|
||||
#Headers: use INCLUDE_DIRECTORIES
|
||||
# Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES
|
||||
target_link_libraries(${PROJECT_NAME} -L/opt/X11/lib/ -lX11 -lXft -lpng -liconv)
|
||||
|
||||
endif(APPLE)
|
||||
|
||||
@ -119,7 +119,6 @@
|
||||
<Unit filename="../../source/system/shared_wrapper.cpp" />
|
||||
<Unit filename="../../source/system/timepiece.cpp" />
|
||||
<Unit filename="../../source/threads/pool.cpp" />
|
||||
<Unit filename="../../source/traits.cpp" />
|
||||
<Unit filename="../../source/unicode_bidi.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
|
||||
@ -256,7 +256,6 @@
|
||||
<ClCompile Include="..\..\source\system\shared_wrapper.cpp" />
|
||||
<ClCompile Include="..\..\source\system\timepiece.cpp" />
|
||||
<ClCompile Include="..\..\source\threads\pool.cpp" />
|
||||
<ClCompile Include="..\..\source\traits.cpp" />
|
||||
<ClCompile Include="..\..\source\unicode_bidi.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@ -291,9 +291,6 @@
|
||||
<ClCompile Include="..\..\source\deploy.cpp">
|
||||
<Filter>Source Files\nana</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\traits.cpp">
|
||||
<Filter>Source Files\nana</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\unicode_bidi.cpp">
|
||||
<Filter>Source Files\nana</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@ -249,7 +249,6 @@
|
||||
<ClCompile Include="..\..\source\system\platform.cpp" />
|
||||
<ClCompile Include="..\..\source\system\timepiece.cpp" />
|
||||
<ClCompile Include="..\..\source\threads\pool.cpp" />
|
||||
<ClCompile Include="..\..\source\traits.cpp" />
|
||||
<ClCompile Include="..\..\source\unicode_bidi.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@ -69,9 +69,6 @@
|
||||
<ClCompile Include="..\..\source\internationalization.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\traits.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\unicode_bidi.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@ -59,7 +59,7 @@ namespace nana{ namespace audio{
|
||||
unsigned cksize;
|
||||
};
|
||||
public:
|
||||
bool open(const nana::string& file);
|
||||
bool open(const std::string& file);
|
||||
void close();
|
||||
bool empty() const;
|
||||
const wave_spec::format_chunck & format() const;
|
||||
|
||||
@ -14,10 +14,10 @@ namespace nana{ namespace audio
|
||||
struct implementation;
|
||||
public:
|
||||
player();
|
||||
player(const nana::string& file);
|
||||
player(const std::string& file);
|
||||
~player();
|
||||
|
||||
bool open(const nana::string& file);
|
||||
bool open(const std::string& file);
|
||||
void play();
|
||||
void close();
|
||||
private:
|
||||
|
||||
@ -67,7 +67,8 @@ namespace nana
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::basic_string<nana::char_t, casei_char_traits<nana::char_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
|
||||
|
||||
@ -18,6 +18,24 @@
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace utf
|
||||
{
|
||||
/// Attempt to get a pointer to a character of UTF-8 string by a specifed character index.
|
||||
/// @param text_utf8 A string encoded as UTF-8.
|
||||
/// @param pos The unicode character index.
|
||||
/// @returns A pointer to the unicode character. It returns a null if pos is out of range.
|
||||
const char* char_ptr(const char* text_utf8, unsigned pos);
|
||||
const char* char_ptr(const ::std::string& text_utf8, unsigned pos);
|
||||
|
||||
/// Get the unicode character by a specified character index.
|
||||
/// @param text_utf8 A string encoded as UTF-8.
|
||||
/// @param pos The unicode character index.
|
||||
/// @param len A unsigned pointer to receive the number of bytes it takes in UTF-8 encoded. If len is a nullptr, it is ignored.
|
||||
/// @returns A unicode character. '\0' if pos is out of range.
|
||||
wchar_t char_at(const char* text_utf8, unsigned pos, unsigned * len);
|
||||
wchar_t char_at(const ::std::string& text_utf8, unsigned pos, unsigned * len);
|
||||
}
|
||||
|
||||
enum class unicode
|
||||
{
|
||||
utf8, utf16, utf32
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
#include <stdexcept>
|
||||
#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
|
||||
@ -93,56 +92,61 @@ namespace std
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NANA_UNICODE
|
||||
namespace nana
|
||||
{
|
||||
typedef char char_t;
|
||||
typedef std::string string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE
|
||||
}
|
||||
#define STR(string) string
|
||||
#else
|
||||
namespace nana
|
||||
{
|
||||
typedef wchar_t char_t;
|
||||
typedef std::wstring string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE
|
||||
}
|
||||
#define STR(string) L##string
|
||||
#endif
|
||||
|
||||
namespace nana
|
||||
{
|
||||
std::size_t strlen(const char_t* str);
|
||||
char_t* strcpy(char_t* dest, const char_t* source);
|
||||
#ifdef _MSC_VER
|
||||
template <size_t N>
|
||||
inline char* strcpy(char (&dest)[N], const char* source)
|
||||
{
|
||||
::strncpy_s(dest, source, _TRUNCATE);
|
||||
return dest;
|
||||
}
|
||||
template <size_t N>
|
||||
inline wchar_t* strcpy(wchar_t (&dest)[N], const wchar_t* source)
|
||||
{
|
||||
::wcsncpy_s(dest, source, _TRUNCATE);
|
||||
return dest;
|
||||
}
|
||||
#endif // #ifdef _MSC_VER
|
||||
}
|
||||
/// Checks whether a specified text is utf8 encoding
|
||||
bool is_utf8(const char* str, unsigned len);
|
||||
void throw_not_utf8(const std::string& text);
|
||||
void throw_not_utf8(const char*, unsigned len);
|
||||
void throw_not_utf8(const char*);
|
||||
|
||||
std::wstring utf8_cast(const std::string&);
|
||||
std::string utf8_cast(const std::wstring&);
|
||||
|
||||
const std::string& to_utf8(const std::string&);
|
||||
std::string to_utf8(const std::wstring&);
|
||||
|
||||
std::wstring to_wstring(const std::string& utf8_str);
|
||||
const std::wstring& to_wstring(const std::wstring& wstr);
|
||||
std::wstring&& to_wstring(std::wstring&& wstr);
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
#define NANA_SHARED_EXPORT extern "C" _declspec(dllexport)
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
#define NANA_SHARED_EXPORT extern "C"
|
||||
std::string to_osmbstr(const std::string& text_utf8);
|
||||
#else
|
||||
std::string to_osmbstr(std::string text_utf8);
|
||||
#endif
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
using native_string_type = std::wstring;
|
||||
#else //POSIX
|
||||
using native_string_type = std::string;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
const detail::native_string_type to_nstring(const std::string&);
|
||||
const detail::native_string_type& to_nstring(const std::wstring&);
|
||||
detail::native_string_type to_nstring(std::string&&);
|
||||
detail::native_string_type&& to_nstring(std::wstring&&);
|
||||
#else //POSIX
|
||||
const detail::native_string_type& to_nstring(const std::string&);
|
||||
const detail::native_string_type to_nstring(const std::wstring&);
|
||||
detail::native_string_type&& to_nstring(std::string&&);
|
||||
detail::native_string_type to_nstring(std::wstring&&);
|
||||
#endif
|
||||
detail::native_string_type to_nstring(int);
|
||||
detail::native_string_type to_nstring(double);
|
||||
detail::native_string_type to_nstring(std::size_t);
|
||||
}
|
||||
|
||||
|
||||
namespace nana
|
||||
{
|
||||
bool is_incomplete(const nana::string& str, unsigned pos);
|
||||
|
||||
inline unsigned make_rgb(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
|
||||
return ((unsigned(red) << 16)|((unsigned(green)<<8))|blue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ namespace detail
|
||||
Window window;
|
||||
int x;
|
||||
int y;
|
||||
std::vector<nana::string> * files;
|
||||
std::vector<std::string> * files;
|
||||
}mouse_drop;
|
||||
}u;
|
||||
};
|
||||
|
||||
@ -70,7 +70,7 @@ namespace detail
|
||||
|
||||
struct font_tag
|
||||
{
|
||||
nana::string name;
|
||||
std::string name;
|
||||
unsigned height;
|
||||
unsigned weight;
|
||||
bool italic;
|
||||
@ -102,7 +102,7 @@ namespace detail
|
||||
#if defined(NANA_UNICODE)
|
||||
XftDraw * xftdraw{nullptr};
|
||||
XftColor xft_fgcolor;
|
||||
const std::string charset(const nana::string& str, const std::string& strcode);
|
||||
const std::string charset(const std::wstring& str, const std::string& strcode);
|
||||
#endif
|
||||
drawable_impl_type();
|
||||
~drawable_impl_type();
|
||||
@ -203,7 +203,7 @@ namespace detail
|
||||
void default_native_font(const font_ptr_t&);
|
||||
unsigned font_size_to_height(unsigned) const;
|
||||
unsigned font_height_to_size(unsigned) const;
|
||||
font_ptr_t make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strick_out);
|
||||
font_ptr_t make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strick_out);
|
||||
|
||||
Display* open_display();
|
||||
void close_display();
|
||||
|
||||
@ -80,7 +80,7 @@ namespace detail
|
||||
|
||||
struct font_tag
|
||||
{
|
||||
nana::string name;
|
||||
native_string_type name;
|
||||
unsigned height;
|
||||
unsigned weight;
|
||||
bool italic;
|
||||
@ -186,7 +186,7 @@ namespace detail
|
||||
void default_native_font(const font_ptr_t&);
|
||||
unsigned font_size_to_height(unsigned) const;
|
||||
unsigned font_height_to_size(unsigned) const;
|
||||
font_ptr_t make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
|
||||
font_ptr_t make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
|
||||
|
||||
static platform_spec& instance();
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* A File Iterator Implementation
|
||||
* Copyright(C) 2003 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: stdex/filesystem/file_iterator.hpp
|
||||
* @file: filesystem/file_iterator.hpp
|
||||
* @description:
|
||||
* file_iterator is a toolkit for applying each file and directory in a
|
||||
* specified path.
|
||||
@ -39,9 +39,9 @@ namespace filesystem
|
||||
#ifdef NANA_WINDOWS
|
||||
fileinfo(const WIN32_FIND_DATA& wfd);
|
||||
#elif defined(NANA_POSIX)
|
||||
fileinfo(const nana::string& filename, const struct stat &);
|
||||
fileinfo(const std::string& filename, const struct stat &);
|
||||
#endif
|
||||
nana::string name;
|
||||
::std::string name;
|
||||
|
||||
unsigned long size;
|
||||
bool directory;
|
||||
@ -56,7 +56,7 @@ namespace filesystem
|
||||
|
||||
basic_file_iterator():end_(true), handle_(nullptr){}
|
||||
|
||||
basic_file_iterator(const nana::string& file_path)
|
||||
basic_file_iterator(const std::string& file_path)
|
||||
:end_(false), handle_(nullptr)
|
||||
{
|
||||
_m_prepare(file_path);
|
||||
@ -92,14 +92,13 @@ namespace filesystem
|
||||
return (*p == 0);
|
||||
}
|
||||
|
||||
void _m_prepare(const nana::string& file_path)
|
||||
void _m_prepare(const std::string& file_path)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
path_ = file_path;
|
||||
auto pat = file_path;
|
||||
auto pat = utf8_cast(file_path);
|
||||
DWORD attr = ::GetFileAttributes(pat.data());
|
||||
if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
|
||||
pat += STR("\\*");
|
||||
pat += L"\\*";
|
||||
|
||||
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_);
|
||||
|
||||
@ -120,10 +119,11 @@ namespace filesystem
|
||||
}
|
||||
value_ = value_type(wfd_);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
path_ = nana::charset(file_path);
|
||||
if(path_.size() && (path_[path_.size() - 1] != '/'))
|
||||
path_ = file_path;
|
||||
if(path_.size() && path_.back() != '/')
|
||||
path_ += '/';
|
||||
find_handle_t handle = opendir(path_.c_str());
|
||||
auto handle = opendir(path_.c_str());
|
||||
|
||||
end_ = true;
|
||||
if(handle)
|
||||
{
|
||||
@ -143,7 +143,7 @@ namespace filesystem
|
||||
struct stat fst;
|
||||
if(stat((path_ + dnt->d_name).c_str(), &fst) == 0)
|
||||
{
|
||||
value_ = value_type(nana::charset(dnt->d_name), fst);
|
||||
value_ = value_type(dnt->d_name, fst);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -226,9 +226,8 @@ namespace filesystem
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FIND_DATA wfd_;
|
||||
nana::string path_;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
std::string path_;
|
||||
#else
|
||||
std::string path_;
|
||||
#endif
|
||||
std::shared_ptr<find_handle_t> find_ptr_;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A ISO C++ filesystem Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -36,6 +36,7 @@
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <nana/deploy.hpp>
|
||||
|
||||
@ -55,25 +56,27 @@ namespace nana { namespace experimental
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
enum class file_type
|
||||
{
|
||||
none = 0, ///< has not been determined or an error occurred while trying to determine
|
||||
not_found = -1, ///< Pseudo-type: file was not found. Is not considered an error
|
||||
regular = 1,
|
||||
directory = 2 ,
|
||||
symlink =3, ///< Symbolic link file
|
||||
block =4, ///< Block special file
|
||||
character= 5 , ///< Character special file
|
||||
fifo = 6 , ///< FIFO or pipe file
|
||||
socket =7,
|
||||
unknown= 8 ///< The file does exist, but is of an operating system dependent type not covered by any of the other
|
||||
};
|
||||
enum class file_type
|
||||
{
|
||||
none = 0, ///< has not been determined or an error occurred while trying to determine
|
||||
not_found = -1, ///< Pseudo-type: file was not found. Is not considered an error
|
||||
regular = 1,
|
||||
directory = 2 ,
|
||||
symlink =3, ///< Symbolic link file
|
||||
block =4, ///< Block special file
|
||||
character= 5 , ///< Character special file
|
||||
fifo = 6 , ///< FIFO or pipe file
|
||||
socket =7,
|
||||
unknown= 8 ///< The file does exist, but is of an operating system dependent type not covered by any of the other
|
||||
};
|
||||
|
||||
enum class perms
|
||||
{
|
||||
none =0, ///< There are no permissions set for the file.
|
||||
unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
|
||||
};
|
||||
enum class perms
|
||||
{
|
||||
none = 0, ///< There are no permissions set for the file.
|
||||
all = 0x1FF, ///< owner_all | group_all | others_all
|
||||
mask = 0xFFF, ///< all | set_uid | set_gid | sticky_bit.
|
||||
unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
|
||||
};
|
||||
//enum class copy_options;
|
||||
//enum class directory_options;
|
||||
|
||||
@ -96,35 +99,28 @@ namespace filesystem
|
||||
uintmax_t free;
|
||||
uintmax_t available;
|
||||
};
|
||||
using file_time_type = std::chrono::time_point< std::chrono::system_clock>;// trivial-clock> ;
|
||||
|
||||
class file_status
|
||||
{
|
||||
file_type m_ft = file_type::none;
|
||||
perms m_prms = perms::unknown;
|
||||
using file_time_type = std::chrono::time_point<std::chrono::system_clock>;// trivial-clock> ;
|
||||
|
||||
public:
|
||||
explicit file_status(file_type ft = file_type::none, perms prms = perms::unknown)
|
||||
:m_ft{ft}, m_prms{prms}
|
||||
{}
|
||||
class file_status
|
||||
{
|
||||
file_type m_ft = file_type::none;
|
||||
perms m_prms = perms::unknown;
|
||||
|
||||
file_status(const file_status& fs) : m_ft{fs.m_ft}, m_prms{fs.m_prms}{} // = default;
|
||||
file_status(file_status&& fs) : m_ft{fs.m_ft}, m_prms{fs.m_prms}{} // = default;
|
||||
public:
|
||||
explicit file_status(file_type ft = file_type::none, perms prms = perms::unknown);
|
||||
|
||||
~file_status(){};
|
||||
file_status& operator=(const file_status&) = default;
|
||||
file_status& operator=(file_status&&fs) // = default;
|
||||
{
|
||||
m_ft=fs.m_ft; m_prms = fs.m_prms;
|
||||
return *this;
|
||||
}
|
||||
// observers
|
||||
file_type type() const { return m_ft;}
|
||||
perms permissions() const { return m_prms;}
|
||||
// modifiers
|
||||
void type (file_type ft) { m_ft=ft ;}
|
||||
void permissions(perms prms) { m_prms = prms; }
|
||||
};
|
||||
// observers
|
||||
file_type type() const;
|
||||
perms permissions() const;
|
||||
|
||||
// modifiers
|
||||
void type(file_type ft);
|
||||
void permissions(perms prms);
|
||||
private:
|
||||
file_type value_;
|
||||
perms perms_;
|
||||
};
|
||||
|
||||
/// concerned only with lexical and syntactic aspects and does not necessarily exist in
|
||||
/// external storage, and the pathname is not necessarily valid for the current operating system
|
||||
@ -136,29 +132,54 @@ namespace filesystem
|
||||
class path
|
||||
{
|
||||
public:
|
||||
#if defined(NANA_WINDOWS)
|
||||
using value_type = wchar_t;
|
||||
const static value_type preferred_separator = '\\';
|
||||
#else
|
||||
using value_type = char;
|
||||
const static value_type preferred_separator = '/';
|
||||
#endif
|
||||
using string_type = std::basic_string<value_type>;
|
||||
|
||||
path();
|
||||
path(const nana::string&);
|
||||
|
||||
template<typename Source>
|
||||
path(const Source& source)
|
||||
{
|
||||
_m_assign(source);
|
||||
}
|
||||
|
||||
int compare(const path& other) const;
|
||||
|
||||
bool empty() const;
|
||||
path root() const;
|
||||
path extension() const;
|
||||
|
||||
path parent_path() const;
|
||||
file_type what() const;
|
||||
|
||||
nana::string filename() const;
|
||||
#if defined(NANA_WINDOWS)
|
||||
public:
|
||||
nana::string to_string() const { return text_; }
|
||||
operator nana::string() const { return text_; }
|
||||
path filename() const;
|
||||
|
||||
const value_type*c_str() const;
|
||||
const string_type& native() const;
|
||||
operator string_type() const;
|
||||
|
||||
std::string string() const;
|
||||
std::wstring wstring() const;
|
||||
std::string u8string() const;
|
||||
private:
|
||||
nana::string text_;
|
||||
#else
|
||||
public:
|
||||
std::string to_string() const { return text_; }
|
||||
operator std::string() const { return text_; }
|
||||
void _m_assign(const std::string& source_utf8);
|
||||
void _m_assign(const std::wstring& source);
|
||||
private:
|
||||
std::string text_;
|
||||
#endif
|
||||
string_type pathstr_;
|
||||
};
|
||||
|
||||
bool operator==(const path& lhs, const path& rhs);
|
||||
bool operator!=(const path& lhs, const path& rhs);
|
||||
bool operator<(const path& lhs, const path& rhs);
|
||||
bool operator>(const path& lhs, const path& rhs);
|
||||
|
||||
|
||||
|
||||
struct directory_entry
|
||||
{
|
||||
using path_type = filesystem::path;
|
||||
@ -193,9 +214,7 @@ namespace filesystem
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
|
||||
directory_iterator():end_(true), handle_(nullptr){}
|
||||
|
||||
directory_iterator(const nana::string& file_path) { _m_prepare(file_path); }
|
||||
directory_iterator(const path& file_path) { _m_prepare(file_path.filename()); }
|
||||
directory_iterator(const path& file_path) { _m_prepare(file_path); }
|
||||
|
||||
const value_type&
|
||||
operator*() const { return value_; }
|
||||
@ -233,14 +252,14 @@ namespace filesystem
|
||||
return (*p == 0);
|
||||
}
|
||||
|
||||
void _m_prepare(const nana::string& file_path)
|
||||
void _m_prepare(const path& file_path)
|
||||
{
|
||||
auto path_ = file_path.native();
|
||||
#if defined(NANA_WINDOWS)
|
||||
path_ = file_path;
|
||||
auto pat = file_path;
|
||||
auto pat = path_;
|
||||
DWORD attr = ::GetFileAttributes(pat.data());
|
||||
if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
|
||||
pat += STR("\\*");
|
||||
pat += L"\\*";
|
||||
|
||||
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_);
|
||||
|
||||
@ -264,8 +283,7 @@ namespace filesystem
|
||||
(FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY,
|
||||
wfd_.nFileSizeLow);
|
||||
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
path_ = nana::charset(file_path);
|
||||
#elif defined(NANA_POSIX)
|
||||
if(path_.size() && (path_[path_.size() - 1] != '/'))
|
||||
path_ += '/';
|
||||
find_handle_t handle = opendir(path_.c_str());
|
||||
@ -293,7 +311,7 @@ namespace filesystem
|
||||
is_directory = (0 != S_ISDIR(fst.st_mode));
|
||||
size = fst.st_size;
|
||||
}
|
||||
value_ = value_type(static_cast<nana::string>(nana::charset(dnt->d_name)), is_directory, size);
|
||||
value_ = value_type(static_cast<std::wstring>(nana::charset(dnt->d_name)), is_directory, size);
|
||||
end_ = false;
|
||||
}
|
||||
}
|
||||
@ -340,7 +358,7 @@ namespace filesystem
|
||||
}
|
||||
}
|
||||
|
||||
nana::string d_name = nana::charset(dnt->d_name);
|
||||
std::wstring d_name = nana::charset(dnt->d_name, nana::unicode::utf8);
|
||||
struct stat fst;
|
||||
if(stat((path_ + "/" + dnt->d_name).c_str(), &fst) == 0)
|
||||
value_ = value_type(std::move(d_name), (0 != S_ISDIR(fst.st_mode)), fst.st_size);
|
||||
@ -373,10 +391,9 @@ namespace filesystem
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FIND_DATA wfd_;
|
||||
nana::string path_;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
std::string path_;
|
||||
#endif
|
||||
path::string_type path_;
|
||||
|
||||
std::shared_ptr<find_handle_t> find_ptr_;
|
||||
find_handle_t handle_{nullptr};
|
||||
value_type value_;
|
||||
@ -401,11 +418,10 @@ namespace filesystem
|
||||
}
|
||||
|
||||
|
||||
// file_status status(const path& p);
|
||||
bool file_attrib(const nana::string& file, attribute&);
|
||||
file_status status(const path& p);
|
||||
|
||||
inline bool is_directory(file_status s) { return s.type() == file_type::directory ;}
|
||||
inline bool is_directory(const path& p) { return directory_iterator(p)->attr.directory; }//works??
|
||||
bool is_directory(const path& p);
|
||||
inline bool is_directory(const directory_entry& d) { return d.attr.directory; }
|
||||
//bool is_directory(const path& p, error_code& ec) noexcept;
|
||||
|
||||
@ -419,46 +435,61 @@ namespace filesystem
|
||||
}
|
||||
//bool is_empty(const path& p, error_code& ec) noexcept;
|
||||
|
||||
uintmax_t file_size(const nana::string& file); // deprecate?
|
||||
inline uintmax_t file_size(const path& p){return file_size(p.filename());}
|
||||
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
||||
//long long filesize(const nana::string& file);
|
||||
std::uintmax_t file_size(const path& p);
|
||||
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
||||
|
||||
|
||||
bool create_directories(const path& p);
|
||||
//bool create_directories(const path& p, error_code& ec) noexcept;
|
||||
bool create_directory(const path& p);
|
||||
//bool create_directory(const path& p, error_code& ec) noexcept;
|
||||
bool create_directory(const path& p, const path& attributes);
|
||||
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
|
||||
bool create_directory(const nana::string& dir, bool & if_exist);
|
||||
inline bool create_directory(const path& p, bool & if_exist)
|
||||
{
|
||||
return create_directory(p.filename(), if_exist);
|
||||
};
|
||||
|
||||
|
||||
bool modified_file_time(const nana::string& file, struct tm&);
|
||||
|
||||
|
||||
nana::string path_user();
|
||||
bool create_directories(const path& p);
|
||||
//bool create_directories(const path& p, error_code& ec) noexcept;
|
||||
bool create_directory(const path& p);
|
||||
//bool create_directory(const path& p, error_code& ec) noexcept;
|
||||
bool create_directory(const path& p, const path& attributes);
|
||||
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
|
||||
|
||||
|
||||
path current_path();
|
||||
//path current_path(error_code& ec);
|
||||
void current_path(const path& p);
|
||||
//void current_path(const path& p, error_code& ec) noexcept;
|
||||
//nana::string path_current();
|
||||
bool modified_file_time(const std::wstring& file, struct tm&);
|
||||
path path_user();
|
||||
|
||||
path current_path();
|
||||
//path current_path(error_code& ec);
|
||||
void current_path(const path& p);
|
||||
//void current_path(const path& p, error_code& ec) noexcept;
|
||||
|
||||
|
||||
//bool remove(const path& p);
|
||||
//bool remove(const path& p, error_code& ec) noexcept;
|
||||
bool rmfile(const nana::char_t* file);
|
||||
//bool remove(const path& p);
|
||||
//bool remove(const path& p, error_code& ec) noexcept;
|
||||
bool rmfile(const path& p);
|
||||
|
||||
//uintmax_t remove_all(const path& p);
|
||||
//uintmax_t remove_all(const path& p, error_code& ec) noexcept;
|
||||
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty);
|
||||
nana::string root(const nana::string& path);
|
||||
//uintmax_t remove_all(const path& p);
|
||||
//uintmax_t remove_all(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool rmdir(const path& p, bool fails_if_not_empty);
|
||||
|
||||
template<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
|
||||
|
||||
@ -24,41 +24,13 @@ namespace filesystem
|
||||
tm modified;
|
||||
};
|
||||
|
||||
bool file_attrib(const nana::string& file, attribute&);
|
||||
long long filesize(const nana::string& file);
|
||||
bool modified_file_time(const ::std::string& file, struct tm&);
|
||||
|
||||
bool mkdir(const nana::string& dir, bool & if_exist);
|
||||
bool modified_file_time(const nana::string& file, struct tm&);
|
||||
std::wstring path_user();
|
||||
|
||||
nana::string path_user();
|
||||
nana::string path_current();
|
||||
bool rmfile(const char* file_utf8);
|
||||
bool rmdir(const char* dir, bool fails_if_not_empty);
|
||||
|
||||
bool rmfile(const nana::char_t* file);
|
||||
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty);
|
||||
nana::string root(const nana::string& path);
|
||||
|
||||
class path
|
||||
{
|
||||
public:
|
||||
struct type
|
||||
{ enum{not_exist, file, directory};
|
||||
};
|
||||
|
||||
path();
|
||||
path(const nana::string&);
|
||||
|
||||
bool empty() const;
|
||||
path root() const;
|
||||
int what() const;
|
||||
|
||||
nana::string name() const;
|
||||
private:
|
||||
#if defined(NANA_WINDOWS)
|
||||
nana::string text_;
|
||||
#else
|
||||
std::string text_;
|
||||
#endif
|
||||
};
|
||||
}//end namespace filesystem
|
||||
}//end namespace nana
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -145,7 +145,7 @@ namespace detail
|
||||
basic_window *parent;
|
||||
basic_window *owner;
|
||||
|
||||
::nana::string title;
|
||||
native_string_type title;
|
||||
::nana::detail::drawer drawer; //Self Drawer with owen graphics
|
||||
basic_window* root_widget; //A pointer refers to the root basic window, if the window is a root, the pointer refers to itself.
|
||||
paint::graphics* root_graph; //Refer to the root buffer graphics
|
||||
|
||||
@ -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
|
||||
|
||||
@ -34,6 +34,8 @@ namespace detail
|
||||
unsigned extra_height; //extra border size, it is useful in Windows, ignore in X11 always 0
|
||||
};
|
||||
|
||||
using native_string_type = ::nana::detail::native_string_type;
|
||||
|
||||
static nana::size primary_monitor_size();
|
||||
static rectangle screen_area_from_point(const point&);
|
||||
static window_result create_window(native_window_type, bool nested, const rectangle&, const appearance&);
|
||||
@ -65,8 +67,8 @@ namespace detail
|
||||
|
||||
static void window_size(native_window_type, const size&);
|
||||
static void get_window_rect(native_window_type, rectangle&);
|
||||
static void window_caption(native_window_type, const nana::string&);
|
||||
static nana::string window_caption(native_window_type);
|
||||
static void window_caption(native_window_type, const native_string_type&);
|
||||
static native_string_type window_caption(native_window_type);
|
||||
static void capture_window(native_window_type, bool);
|
||||
static nana::point cursor_position();
|
||||
static native_window_type get_owner_window(native_window_type);
|
||||
|
||||
@ -30,8 +30,8 @@ namespace nana
|
||||
|
||||
virtual widget* widget_ptr() const = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual std::wstring caption() = 0;
|
||||
virtual void caption(std::wstring) = 0;
|
||||
virtual ::nana::detail::native_string_type caption() = 0;
|
||||
virtual void caption(::nana::detail::native_string_type) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,20 @@
|
||||
/*
|
||||
* A Dragger Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/dragger.hpp
|
||||
*/
|
||||
|
||||
#ifndef NANA_GUI_DRAGGER_HPP
|
||||
#define NANA_GUI_DRAGGER_HPP
|
||||
#include "programming_interface.hpp"
|
||||
#include "basis.hpp"
|
||||
#include "../basic_types.hpp"
|
||||
#include "../traits.hpp"
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@ -18,6 +32,10 @@ namespace nana
|
||||
public:
|
||||
dragger();
|
||||
~dragger();
|
||||
|
||||
dragger(dragger&&);
|
||||
dragger& operator=(dragger&&);
|
||||
|
||||
void target(window);
|
||||
void target(window, const rectangle& restrict_area, nana::arrange);
|
||||
void remove_target(window);
|
||||
|
||||
@ -25,7 +25,7 @@ namespace nana
|
||||
filebox(filebox&&) = delete;
|
||||
filebox& operator=(filebox&&) = delete;
|
||||
public:
|
||||
using filters = std::vector<std::pair<nana::string, nana::string>>;
|
||||
using filters = std::vector<std::pair< ::std::string, ::std::string>>;
|
||||
|
||||
filebox(bool is_open_mode);
|
||||
filebox(window owner, bool is_open_mode);
|
||||
@ -37,21 +37,21 @@ namespace nana
|
||||
/// Change owner window
|
||||
void owner(window);
|
||||
|
||||
/** @brief specify a title for the dialog
|
||||
* @param string a text for title
|
||||
*/
|
||||
nana::string title( nana::string new_title); ///< . Set a new title for the dialog and \return the old title
|
||||
/// specify a title for the dialog
|
||||
/// @param string a text for title
|
||||
/// @return old title.
|
||||
::std::string title( ::std::string new_title); ///< . Set a new title for the dialog and \return the old title
|
||||
|
||||
/** @brief specify a suggestion directory
|
||||
* @param string a path of initial directory
|
||||
* @note the behavior of init_path is different between Win7 and Win2K/XP/Vista, but its behavior under Linux is conformed with Win7.
|
||||
*/
|
||||
filebox& init_path(const nana::string&); ///< Suggested init path used to locate a directory when the filebox starts.
|
||||
filebox& init_file(const nana::string&); ///< Init file, if it contains a path, the init path is replaced by the path of init file.
|
||||
filebox& init_path(const ::std::string&); ///< Suggested init path used to locate a directory when the filebox starts.
|
||||
filebox& init_file(const ::std::string&); ///< Init file, if it contains a path, the init path is replaced by the path of init file.
|
||||
/// \brief Add a filetype filter.
|
||||
/// To specify multiple filter in a single description, use a semicolon to separate the patterns(for example,"*.TXT;*.DOC;*.BAK").
|
||||
filebox& add_filter(const nana::string& description, ///< for example. "Text File"
|
||||
const nana::string& filetype ///< filter pattern(for example, "*.TXT")
|
||||
filebox& add_filter(const ::std::string& description, ///< for example. "Text File"
|
||||
const ::std::string& filetype ///< filter pattern(for example, "*.TXT")
|
||||
);
|
||||
|
||||
filebox& add_filter(const filters &ftres)
|
||||
@ -62,16 +62,14 @@ namespace nana
|
||||
};
|
||||
|
||||
|
||||
nana::string path() const;
|
||||
nana::string file() const;
|
||||
::std::string path() const;
|
||||
::std::string file() const;
|
||||
|
||||
/** @brief Display the filebox dialog
|
||||
*/
|
||||
/// Display the filebox dialog
|
||||
bool show() const;
|
||||
|
||||
/** @brief Display the filebox dialog
|
||||
* @note A function object method alternative to show()
|
||||
*/
|
||||
/// Display the filebox dialog
|
||||
/// A function object method alternative to show()
|
||||
bool operator()() const
|
||||
{
|
||||
return show();
|
||||
|
||||
@ -43,10 +43,10 @@ namespace nana
|
||||
msgbox& operator=(const msgbox&);
|
||||
|
||||
/// Construct that creates a message box with a specified title and default button.
|
||||
msgbox(const nana::string&);
|
||||
msgbox(const ::std::string&);
|
||||
|
||||
/// Construct that creates a message box with an owner windoow, a specified title and buttons.
|
||||
msgbox(window, const nana::string&, button_t = ok);
|
||||
msgbox(window, const ::std::string&, button_t = ok);
|
||||
|
||||
/// Sets an icon for informing user.
|
||||
msgbox& icon(icon_t);
|
||||
@ -55,10 +55,10 @@ namespace nana
|
||||
void clear();
|
||||
|
||||
/// Writes a string to the buffer.
|
||||
msgbox & operator<<(const nana::string&);
|
||||
msgbox & operator<<(const std::wstring&);
|
||||
|
||||
/// Writes a string to the buffer.
|
||||
msgbox & operator<<(const nana::char_t*);
|
||||
msgbox & operator<<(const wchar_t*);
|
||||
|
||||
/// Writes a string to the buffer.
|
||||
msgbox & operator<<(const nana::charset&);
|
||||
@ -86,7 +86,7 @@ namespace nana
|
||||
private:
|
||||
std::stringstream sstream_;
|
||||
window wd_;
|
||||
nana::string title_;
|
||||
std::string title_;
|
||||
button_t button_;
|
||||
icon_t icon_;
|
||||
};
|
||||
@ -97,7 +97,7 @@ namespace nana
|
||||
{
|
||||
virtual ~abstract_content() = default;
|
||||
|
||||
virtual const ::nana::string& label() const = 0;
|
||||
virtual const ::std::string& label() const = 0;
|
||||
virtual window create(window, unsigned label_px) = 0;
|
||||
virtual unsigned fixed_pixels() const;
|
||||
};
|
||||
@ -107,13 +107,13 @@ namespace nana
|
||||
{
|
||||
struct implement;
|
||||
public:
|
||||
integer(::nana::string label, int init_value, int begin, int last, int step);
|
||||
integer(::std::string label, int init_value, int begin, int last, int step);
|
||||
~integer();
|
||||
|
||||
int value() const;
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
const ::std::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
@ -124,13 +124,13 @@ namespace nana
|
||||
{
|
||||
struct implement;
|
||||
public:
|
||||
real(::nana::string label, double init_value, double begin, double last, double step);
|
||||
real(::std::string label, double init_value, double begin, double last, double step);
|
||||
~real();
|
||||
|
||||
double value() const;
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
const ::std::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
@ -144,8 +144,8 @@ namespace nana
|
||||
text(const text&) = delete;
|
||||
text& operator=(const text&) = delete;
|
||||
public:
|
||||
text(::nana::string label, ::nana::string init_text = ::nana::string());
|
||||
text(::nana::string label, std::vector<::nana::string>);
|
||||
text(::std::string label, ::std::string init_text = ::std::string());
|
||||
text(::std::string label, std::vector<::std::string>);
|
||||
|
||||
~text();
|
||||
|
||||
@ -154,10 +154,10 @@ namespace nana
|
||||
|
||||
void mask_character(wchar_t ch);
|
||||
|
||||
::nana::string value() const;
|
||||
::std::string value() const;
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
const ::std::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
@ -168,17 +168,17 @@ namespace nana
|
||||
{
|
||||
struct implement;
|
||||
public:
|
||||
date(::nana::string label);
|
||||
date(::std::string label);
|
||||
|
||||
~date();
|
||||
|
||||
::nana::string value() const;
|
||||
::std::string value() const;
|
||||
int year() const;
|
||||
int month() const; //[1, 12]
|
||||
int day() const; //[1, 31]
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
const ::std::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
unsigned fixed_pixels() const override;
|
||||
private:
|
||||
@ -190,19 +190,19 @@ namespace nana
|
||||
{
|
||||
struct implement;
|
||||
public:
|
||||
path(::nana::string label, const ::nana::filebox&);
|
||||
path(::std::string label, const ::nana::filebox&);
|
||||
~path();
|
||||
|
||||
::nana::string value() const;
|
||||
::std::string value() const;
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
const ::std::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
};
|
||||
|
||||
inputbox(window, ::nana::string description, ::nana::string title = ::nana::string());
|
||||
inputbox(window, ::std::string description, ::std::string title = ::std::string());
|
||||
|
||||
void image(::nana::paint::image, bool is_left, const rectangle& valid_area = {});
|
||||
void image_v(::nana::paint::image, bool is_top, const rectangle& valid_area = {});
|
||||
@ -246,8 +246,8 @@ namespace nana
|
||||
bool _m_open(std::vector<abstract_content*>&, bool modal);
|
||||
private:
|
||||
window owner_;
|
||||
::nana::string description_;
|
||||
::nana::string title_;
|
||||
::std::string description_;
|
||||
::std::string title_;
|
||||
std::function<bool(window)> verifier_;
|
||||
::nana::paint::image images_[4];
|
||||
::nana::rectangle valid_areas_[4];
|
||||
|
||||
@ -55,9 +55,9 @@ namespace nana
|
||||
notifier(window);
|
||||
~notifier();
|
||||
void close();
|
||||
void text(const nana::string&);
|
||||
void icon(const nana::string& icon_file);
|
||||
void insert_icon(const nana::string& icon_file);
|
||||
void text(const ::std::string&);
|
||||
void icon(const ::std::string& icon_file);
|
||||
void insert_icon(const ::std::string& icon_file);
|
||||
void period(unsigned millisecond);
|
||||
detail::notifier_events& events();
|
||||
window handle() const;
|
||||
|
||||
@ -42,13 +42,17 @@ namespace nana
|
||||
: init_(std::move(initializer))
|
||||
{}
|
||||
|
||||
agent(const nana::char_t* text)
|
||||
agent(const char* text)
|
||||
: text_(text)
|
||||
{}
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
}
|
||||
|
||||
agent(nana::string text, std::function<void(Widget&)> initializer = {})
|
||||
agent(std::string text, std::function<void(Widget&)> initializer = {})
|
||||
: text_(std::move(text)), init_(std::move(initializer))
|
||||
{}
|
||||
{
|
||||
throw_not_utf8(text_);
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<nana::widget> create(nana::window handle) const override
|
||||
@ -60,7 +64,7 @@ namespace nana
|
||||
return std::move(ptr);
|
||||
}
|
||||
private:
|
||||
nana::string text_;
|
||||
std::string text_;
|
||||
std::function<void(Widget&)> init_;
|
||||
};
|
||||
|
||||
@ -79,8 +83,8 @@ namespace nana
|
||||
public:
|
||||
field_interface() = default;
|
||||
virtual ~field_interface() = default;
|
||||
virtual field_interface& operator<<(const nana::char_t* label) = 0;
|
||||
virtual field_interface& operator<<(nana::string label) = 0;
|
||||
virtual field_interface& operator<<(const char* label) = 0;
|
||||
virtual field_interface& operator<<(std::string label) = 0;
|
||||
virtual field_interface& operator<<(window) = 0;
|
||||
virtual field_interface& fasten(window) = 0;
|
||||
|
||||
|
||||
@ -72,8 +72,8 @@ namespace API
|
||||
widget_colors* get_scheme(window);
|
||||
|
||||
void attach_drawer(widget&, drawer_trigger&);
|
||||
nana::string window_caption(window) throw();
|
||||
void window_caption(window, nana::string);
|
||||
::nana::detail::native_string_type window_caption(window) throw();
|
||||
void window_caption(window, ::nana::detail::native_string_type);
|
||||
|
||||
window create_window(window, bool nested, const rectangle&, const appearance&, widget* attached);
|
||||
window create_widget(window, const rectangle&, widget* attached);
|
||||
@ -83,6 +83,9 @@ namespace API
|
||||
paint::graphics* window_graphics(window);
|
||||
|
||||
void delay_restore(bool);
|
||||
|
||||
void register_menu_window(window, bool has_keyboard);
|
||||
void set_menubar(window wd, bool attach);
|
||||
}//end namespace dev
|
||||
|
||||
|
||||
@ -140,7 +143,7 @@ namespace API
|
||||
|
||||
void exit();
|
||||
|
||||
nana::string transform_shortkey_text(nana::string text, nana::string::value_type &shortkey, nana::string::size_type *skpos);
|
||||
std::string transform_shortkey_text(std::string text, wchar_t &shortkey, std::string::size_type *skpos);
|
||||
bool register_shortkey(window, unsigned long);
|
||||
void unregister_shortkey(window);
|
||||
|
||||
@ -271,8 +274,8 @@ namespace API
|
||||
void update_window(window); ///< Copies the off-screen buffer to the screen for immediate display.
|
||||
|
||||
void window_caption(window, const std::string& title_utf8);
|
||||
void window_caption(window, const nana::string& title);
|
||||
nana::string window_caption(window);
|
||||
void window_caption(window, const std::wstring& title);
|
||||
::std::string window_caption(window);
|
||||
|
||||
void window_cursor(window, cursor);
|
||||
cursor window_cursor(window);
|
||||
@ -310,8 +313,8 @@ namespace API
|
||||
void eat_tabstop(window, bool);
|
||||
window move_tabstop(window, bool next); ///< Sets the focus to the window which tabstop is near to the specified window.
|
||||
|
||||
bool glass_window(window); /// \deprecated
|
||||
bool glass_window(window, bool); /// \deprecated
|
||||
//bool glass_window(window); //deprecated
|
||||
//bool glass_window(window, bool); //deprecated
|
||||
|
||||
/// Sets the window active state. If a window active state is false, the window will not obtain the focus when a mouse clicks on it wich will be obteined by take_if_has_active_false.
|
||||
void take_active(window, bool has_active, window take_if_has_active_false);
|
||||
@ -328,10 +331,6 @@ namespace API
|
||||
|
||||
window find_window(const nana::point& mspos);
|
||||
|
||||
void register_menu_window(window, bool has_keyboard);
|
||||
bool attach_menubar(window menubar);
|
||||
void detach_menubar(window menubar);
|
||||
|
||||
bool is_window_zoomed(window, bool ask_for_max); ///<Tests a window whether it is maximized or minimized.
|
||||
|
||||
void widget_borderless(window, bool); ///<Enables or disables a borderless widget.
|
||||
|
||||
@ -24,7 +24,7 @@ namespace nana
|
||||
|
||||
virtual bool tooltip_empty() const = 0;
|
||||
virtual nana::size tooltip_size() const = 0;
|
||||
virtual void tooltip_text(const nana::string&) = 0;
|
||||
virtual void tooltip_text(const ::std::string&) = 0;
|
||||
virtual void tooltip_move(const nana::point& screen_pos, bool ignore_pos) = 0;
|
||||
virtual void duration(std::size_t) = 0;
|
||||
};
|
||||
@ -63,11 +63,11 @@ namespace nana
|
||||
}
|
||||
|
||||
tooltip(){}
|
||||
tooltip(window w, const nana::string &tip){set(w,tip);}
|
||||
tooltip(window w, const ::std::string &tip){set(w,tip);}
|
||||
|
||||
|
||||
static void set(window, const nana::string&);
|
||||
static void show(window, point pos, const nana::string&, std::size_t duration);
|
||||
static void set(window, const ::std::string&);
|
||||
static void show(window, point pos, const ::std::string&, std::size_t duration);
|
||||
static void close();
|
||||
private:
|
||||
static void _m_hold_factory(factory_interface*);
|
||||
|
||||
@ -83,8 +83,8 @@ namespace nana{
|
||||
public:
|
||||
button();
|
||||
button(window, bool visible);
|
||||
button(window, const nana::string& caption, bool visible = true);
|
||||
button(window, const nana::char_t* caption, bool visible = true);
|
||||
button(window, const ::std::string& caption, bool visible = true);
|
||||
button(window, const char* caption, bool visible = true);
|
||||
button(window, const nana::rectangle& = rectangle(), bool visible = true);
|
||||
|
||||
button& icon(const nana::paint::image&);
|
||||
@ -104,7 +104,7 @@ namespace nana{
|
||||
private:
|
||||
//Overrides widget virtual functions
|
||||
void _m_complete_creation() override;
|
||||
void _m_caption(nana::string&&) override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
};
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -108,18 +108,18 @@ namespace nana
|
||||
trigger();
|
||||
~trigger();
|
||||
|
||||
void insert(const nana::string&, nana::any);
|
||||
bool childset(const nana::string&, nana::any);
|
||||
bool childset_erase(const nana::string&);
|
||||
void insert(const ::std::string&, nana::any);
|
||||
bool childset(const ::std::string&, nana::any);
|
||||
bool childset_erase(const ::std::string&);
|
||||
bool clear();
|
||||
|
||||
//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 nana::string&);
|
||||
nana::string path() const;
|
||||
void path(const ::std::string&);
|
||||
::std::string path() const;
|
||||
|
||||
template<typename T>
|
||||
void create_event_agent(::nana::categorize<T>& wdg)
|
||||
@ -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()
|
||||
{
|
||||
@ -174,13 +175,25 @@ namespace nana
|
||||
{
|
||||
}
|
||||
|
||||
categorize(window wd, const nana::string& text, bool visible = true)
|
||||
categorize(window wd, const std::string& text_utf8, bool visible = true)
|
||||
: categorize(wd, ::nana::rectangle(), visible)
|
||||
{
|
||||
this->caption(text_utf8);
|
||||
}
|
||||
|
||||
categorize(window wd, const char* text_utf8, bool visible = true)
|
||||
: categorize(wd, ::nana::rectangle(), visible)
|
||||
{
|
||||
this->caption(text_utf8);
|
||||
}
|
||||
|
||||
categorize(window wd, const std::wstring& text, bool visible = true)
|
||||
: categorize(wd, ::nana::rectangle(), visible)
|
||||
{
|
||||
this->caption(text);
|
||||
}
|
||||
|
||||
categorize(window wd, const nana::char_t* text, bool visible = true)
|
||||
categorize(window wd, const wchar_t* text, bool visible = true)
|
||||
: categorize(wd, ::nana::rectangle(), visible)
|
||||
{
|
||||
this->caption(text);
|
||||
@ -189,7 +202,7 @@ namespace nana
|
||||
/// Insert a new category with a specified name and the object of value type.
|
||||
/// The new category would be inserted as a child in current category,
|
||||
/// and after inserting, the new category is replaced of the current category as a new current one.
|
||||
categorize& insert(const nana::string& name, const value_type& value)
|
||||
categorize& insert(const std::string& name, const value_type& value)
|
||||
{
|
||||
this->get_drawer_trigger().insert(name, value);
|
||||
API::update_window(*this);
|
||||
@ -197,15 +210,16 @@ namespace nana
|
||||
}
|
||||
|
||||
/// Inserts a child category into current category.
|
||||
categorize& childset(const nana::string& name, const value_type& value)
|
||||
categorize& childset(const std::string& name, const value_type& value)
|
||||
{
|
||||
throw_not_utf8(name);
|
||||
if(this->get_drawer_trigger().childset(name, value))
|
||||
API::update_window(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Erases a child category with a specified name from current category.
|
||||
categorize& childset_erase(const nana::string& name)
|
||||
categorize& childset_erase(const std::string& name)
|
||||
{
|
||||
if(this->get_drawer_trigger().childset_erase(name))
|
||||
API::update_window(*this);
|
||||
@ -219,13 +233,13 @@ namespace nana
|
||||
}
|
||||
|
||||
/// Sets the splitter string
|
||||
categorize& splitstr(const nana::string& sstr)
|
||||
categorize& splitstr(const std::string& sstr)
|
||||
{
|
||||
this->get_drawer_trigger().splitstr(sstr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
nana::string splitstr() const
|
||||
std::string splitstr() const
|
||||
{
|
||||
return this->get_drawer_trigger().splitstr();
|
||||
}
|
||||
@ -237,10 +251,10 @@ namespace nana
|
||||
}
|
||||
private:
|
||||
//Overrides widget's virtual functions
|
||||
void _m_caption(nana::string&& str) override
|
||||
void _m_caption(native_string_type&& str) override
|
||||
{
|
||||
this->get_drawer_trigger().path(str);
|
||||
API::dev::window_caption(*this, this->get_drawer_trigger().path());
|
||||
this->get_drawer_trigger().path(to_utf8(str));
|
||||
API::dev::window_caption(*this, to_nstring(this->get_drawer_trigger().path()) );
|
||||
}
|
||||
};
|
||||
}//end namespace nana
|
||||
|
||||
@ -56,8 +56,8 @@ namespace drawerbase
|
||||
public:
|
||||
checkbox();
|
||||
checkbox(window, bool visible);
|
||||
checkbox(window, const nana::string& text, bool visible = true);
|
||||
checkbox(window, const nana::char_t* text, bool visible = true);
|
||||
checkbox(window, const std::string& text, bool visible = true);
|
||||
checkbox(window, const char* text, bool visible = true);
|
||||
checkbox(window, const rectangle& = rectangle(), bool visible = true);
|
||||
|
||||
void element_set(const char* name);
|
||||
|
||||
@ -75,8 +75,8 @@ namespace nana
|
||||
{
|
||||
public:
|
||||
item_proxy(drawer_impl*, std::size_t pos);
|
||||
item_proxy& text(const nana::string&);
|
||||
nana::string text() const;
|
||||
item_proxy& text(const ::std::string&);
|
||||
::std::string text() const;
|
||||
item_proxy& select();
|
||||
bool selected() const;
|
||||
item_proxy& icon(const nana::paint::image&);
|
||||
@ -112,14 +112,13 @@ namespace nana
|
||||
template<typename T>
|
||||
item_proxy& value(T&& t)
|
||||
{
|
||||
*_m_anyobj(true) = std::move(t);
|
||||
*_m_anyobj(true) = ::std::move(t);
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
/// Behavior of Iterator's value_type
|
||||
bool operator==(const nana::string&) const;
|
||||
bool operator==(const ::std::string&) const;
|
||||
bool operator==(const char*) const;
|
||||
bool operator==(const wchar_t*) const;
|
||||
|
||||
/// Behavior of Iterator
|
||||
item_proxy & operator=(const item_proxy&);
|
||||
@ -166,19 +165,19 @@ namespace nana
|
||||
|
||||
combox();
|
||||
combox(window, bool visible);
|
||||
combox(window, nana::string, bool visible = true);
|
||||
combox(window, const nana::char_t*, bool visible = true);
|
||||
combox(window, ::std::string, bool visible = true);
|
||||
combox(window, const char*, bool visible = true);
|
||||
combox(window, const rectangle& r = rectangle(), bool visible = true);
|
||||
|
||||
void clear();
|
||||
void editable(bool);
|
||||
bool editable() const;
|
||||
void set_accept(std::function<bool(nana::char_t)>);
|
||||
combox& push_back(nana::string);
|
||||
void set_accept(std::function<bool(wchar_t)>);
|
||||
combox& push_back(std::string);
|
||||
std::size_t the_number_of_options() const;
|
||||
std::size_t option() const; ///< Index of the last selected, from drop-down list, item.
|
||||
void option(std::size_t); ///< Select the text specified by index
|
||||
nana::string text(std::size_t) const;
|
||||
::std::string text(std::size_t) const;
|
||||
void erase(std::size_t pos);
|
||||
|
||||
template<typename Key>
|
||||
@ -224,8 +223,8 @@ namespace nana
|
||||
const drawerbase::combox::drawer_impl& _m_impl() const;
|
||||
private:
|
||||
//Overrides widget's virtual functions
|
||||
nana::string _m_caption() const throw() override;
|
||||
void _m_caption(nana::string&&) override;
|
||||
native_string_type _m_caption() const throw() override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
nana::any * _m_anyobj(std::size_t pos, bool alloc_if_empty) const override;
|
||||
};
|
||||
}
|
||||
|
||||
@ -42,12 +42,12 @@ namespace nana
|
||||
trigger();
|
||||
bool chose() const;
|
||||
nana::date read() const;
|
||||
void week_name(unsigned index, const nana::string&);
|
||||
void week_name(unsigned index, const std::string&);
|
||||
private:
|
||||
where _m_pos_where(graph_reference, const ::nana::point& pos);
|
||||
void _m_draw_topbar(graph_reference);
|
||||
void _m_make_drawing_basis(drawing_basis&, graph_reference, const nana::point& refpos);
|
||||
void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, const nana::string&, bool primary, bool sel);
|
||||
void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, const ::std::string&, bool primary, bool sel);
|
||||
void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, int number, bool primary, bool sel);
|
||||
void _m_draw_ex_days(drawing_basis &, graph_reference, int begx, int begy, bool before);
|
||||
void _m_draw_days(const nana::point& refpos, graph_reference);
|
||||
@ -61,7 +61,7 @@ namespace nana
|
||||
void mouse_leave(graph_reference, const arg_mouse&) override;
|
||||
void mouse_up(graph_reference, const arg_mouse&) override;
|
||||
private:
|
||||
nana::string weekstr_[7];
|
||||
::std::string weekstr_[7];
|
||||
|
||||
widget * widget_;
|
||||
|
||||
@ -105,13 +105,13 @@ namespace nana
|
||||
public:
|
||||
date_chooser();
|
||||
date_chooser(window, bool visible);
|
||||
date_chooser(window, const nana::string& text, bool visible = true);
|
||||
date_chooser(window, const nana::char_t* text, bool visible = true);
|
||||
date_chooser(window, const ::std::string& text, bool visible = true);
|
||||
date_chooser(window, const char* text, bool visible = true);
|
||||
date_chooser(window, const nana::rectangle& r = rectangle(), bool visible = true);
|
||||
|
||||
bool chose() const;
|
||||
nana::date read() const;
|
||||
void weekstr(unsigned index, const nana::string&);///<Set the week strings which will be displayed for day, index is in range of [0, 6]
|
||||
void weekstr(unsigned index, const ::std::string&);///<Set the week strings which will be displayed for day, index is in range of [0, 6]
|
||||
};
|
||||
}//end namespace nana
|
||||
|
||||
|
||||
@ -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())
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@ namespace nana
|
||||
virtual ~item_interface(){}
|
||||
|
||||
virtual const nana::paint::image & image() const = 0;
|
||||
virtual const nana::char_t* text() const = 0;
|
||||
virtual const char* text() const = 0;
|
||||
};
|
||||
|
||||
//struct module_def
|
||||
|
||||
@ -37,7 +37,7 @@ namespace nana{
|
||||
/// The construction that creates the widget and set the titel or caption
|
||||
|
||||
group(window parent, ///< a handle to the parent
|
||||
::nana::string titel, ///< caption of the group
|
||||
::std::string titel, ///< caption of the group
|
||||
bool formatted = false, ///< Enable/disable the formatted text for the title
|
||||
unsigned gap = 2, ///< betwen the content and the external limit
|
||||
const rectangle& r = {} ,
|
||||
@ -49,7 +49,7 @@ namespace nana{
|
||||
~group();
|
||||
|
||||
/// Adds an option for user selection
|
||||
group& add_option(::nana::string);
|
||||
group& add_option(::std::string);
|
||||
|
||||
/// Enables/disables the radio mode which is single selection
|
||||
group& radio_mode(bool);
|
||||
@ -77,8 +77,8 @@ namespace nana{
|
||||
void _m_add_child(const char* field, widget*);
|
||||
void _m_init();
|
||||
void _m_complete_creation() override;
|
||||
::nana::string _m_caption() const throw() override;
|
||||
void _m_caption(::nana::string&&) override;
|
||||
native_string_type _m_caption() const throw() override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
};
|
||||
|
||||
@ -57,13 +57,13 @@ namespace nana
|
||||
typedef drawerbase::label::command command;
|
||||
label();
|
||||
label(window, bool visible);
|
||||
label(window, const nana::string& text, bool visible = true);
|
||||
label(window parent, const nana::char_t* text, bool visible = true) :label(parent, nana::string(text),visible) {};
|
||||
label(window, const std::string& text, bool visible = true);
|
||||
label(window parent, const char* text, bool visible = true) :label(parent, std::string(text),visible) {};
|
||||
label(window, const rectangle& = {}, bool visible = true);
|
||||
label& transparent(bool); ///< Switchs the label widget to the transparent background mode.
|
||||
bool transparent() const throw();
|
||||
label& format(bool); ///< Switches the format mode of the widget.
|
||||
label& add_format_listener(std::function<void(command, const nana::string&)>);
|
||||
label& add_format_listener(std::function<void(command, const std::string&)>);
|
||||
|
||||
label& click_for(window associated_window) throw(); // as same as the "for" attribute of a label
|
||||
|
||||
@ -71,12 +71,12 @@ namespace nana
|
||||
/// "corrected" size that changes lines to fit the text into the specified width
|
||||
nana::size measure(unsigned allowed_width_in_pixel) const;
|
||||
|
||||
static ::nana::size measure(::nana::paint::graphics&, const ::nana::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
|
||||
static ::nana::size measure(::nana::paint::graphics&, const ::std::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
|
||||
|
||||
label& text_align(align horizontal_align, align_v vertical_align= align_v::top);
|
||||
private:
|
||||
//Overrides widget's virtual function
|
||||
void _m_caption(nana::string&&) override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
};
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
||||
@ -31,6 +31,7 @@ namespace nana
|
||||
namespace listbox
|
||||
{
|
||||
using size_type = std::size_t;
|
||||
using native_string_type = ::nana::detail::native_string_type;
|
||||
|
||||
/// usefull for both absolute and display (sorted) positions
|
||||
struct index_pair
|
||||
@ -81,7 +82,7 @@ namespace nana
|
||||
|
||||
using selection = std::vector<index_pair>;
|
||||
|
||||
using inline_notifier_interface = detail::inline_widget_notifier_interface<index_pair, std::wstring>;
|
||||
using inline_notifier_interface = detail::inline_widget_notifier_interface<index_pair, std::string>;
|
||||
|
||||
struct cell
|
||||
{
|
||||
@ -94,17 +95,17 @@ namespace nana
|
||||
format(const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
||||
};
|
||||
|
||||
using format_ptr = std::unique_ptr < format > ;
|
||||
using format_ptr = ::std::unique_ptr<format>;
|
||||
|
||||
::nana::string text;
|
||||
format_ptr custom_format;
|
||||
::std::string text;
|
||||
format_ptr custom_format;
|
||||
|
||||
cell() = default;
|
||||
cell(const cell&);
|
||||
cell(cell&&);
|
||||
cell(nana::string);
|
||||
cell(nana::string, const format&);
|
||||
cell(nana::string, const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
||||
cell(::std::string);
|
||||
cell(::std::string, const format&);
|
||||
cell(::std::string, const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
||||
|
||||
cell& operator=(const cell&);
|
||||
cell& operator=(cell&&);
|
||||
@ -126,9 +127,9 @@ namespace nana
|
||||
oresolver& operator<<(double);
|
||||
oresolver& operator<<(long double);
|
||||
|
||||
oresolver& operator<<(const char*);
|
||||
oresolver& operator<<(const char* text_utf8);
|
||||
oresolver& operator<<(const wchar_t*);
|
||||
oresolver& operator<<(const std::string&);
|
||||
oresolver& operator<<(const std::string& text_utf8);
|
||||
oresolver& operator<<(const std::wstring&);
|
||||
oresolver& operator<<(std::wstring&&);
|
||||
oresolver& operator<<(cell);
|
||||
@ -157,7 +158,7 @@ namespace nana
|
||||
iresolver& operator>>(double&);
|
||||
iresolver& operator>>(long double&);
|
||||
|
||||
iresolver& operator>>(std::string&);
|
||||
iresolver& operator>>(std::string& utf8_cast);
|
||||
iresolver& operator>>(std::wstring&);
|
||||
iresolver& operator>>(cell&);
|
||||
iresolver& operator>>(std::nullptr_t);
|
||||
@ -241,8 +242,9 @@ namespace nana
|
||||
size_type columns() const;
|
||||
|
||||
item_proxy& text(size_type col, cell);
|
||||
item_proxy& text(size_type col, nana::string);
|
||||
nana::string text(size_type col) const;
|
||||
item_proxy& text(size_type col, std::string);
|
||||
item_proxy& text(size_type col, std::wstring);
|
||||
std::string text(size_type col) const;
|
||||
|
||||
void icon(const nana::paint::image&);
|
||||
|
||||
@ -257,7 +259,7 @@ namespace nana
|
||||
for (auto pos = 0u; pos < cols; ++pos)
|
||||
{
|
||||
auto & el = cells[pos];
|
||||
if (el.text.size() == 1 && el.text[0] == nana::char_t(0))
|
||||
if (el.text.size() == 1 && el.text[0] == '\0')
|
||||
continue;
|
||||
text(pos, std::move(el));
|
||||
}
|
||||
@ -300,9 +302,10 @@ namespace nana
|
||||
}
|
||||
|
||||
/// Behavior of Iterator's value_type
|
||||
bool operator==(const nana::string& s) const;
|
||||
bool operator==(const char * s) const;
|
||||
bool operator==(const wchar_t * s) const;
|
||||
bool operator==(const ::std::string& s) const;
|
||||
bool operator==(const ::std::wstring& s) const;
|
||||
|
||||
/// Behavior of Iterator
|
||||
item_proxy & operator=(const item_proxy&);
|
||||
@ -375,18 +378,20 @@ namespace nana
|
||||
}
|
||||
|
||||
/// Appends one item at the end of this category with the specifies text in the column fields
|
||||
void append(std::initializer_list<nana::string>);
|
||||
void append(std::initializer_list<std::string> texts_utf8);
|
||||
void append(std::initializer_list<std::wstring> texts);
|
||||
|
||||
size_type columns() const;
|
||||
|
||||
cat_proxy& text(nana::string);
|
||||
nana::string text() const;
|
||||
cat_proxy& text(std::string);
|
||||
cat_proxy& text(std::wstring);
|
||||
std::string text() const;
|
||||
|
||||
cat_proxy & select(bool);
|
||||
bool selected() const;
|
||||
|
||||
/// Behavior of a container
|
||||
void push_back(nana::string);
|
||||
void push_back(std::string text_utf8);
|
||||
|
||||
item_proxy begin() const;
|
||||
item_proxy end() const;
|
||||
@ -449,8 +454,8 @@ namespace nana
|
||||
|
||||
struct export_options
|
||||
{
|
||||
nana::string sep = nana::string {STR("\t" )},
|
||||
endl= nana::string {STR("\n")};
|
||||
std::string sep = ::std::string {"\t"},
|
||||
endl= ::std::string {"\n"};
|
||||
bool only_selected_items{true},
|
||||
only_checked_items {false},
|
||||
only_visible_columns{true};
|
||||
@ -510,16 +515,16 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
||||
and
|
||||
antisymmetry(comp(a, b) != comp(b, a) returns true)
|
||||
A simple example.
|
||||
bool sort_compare( const nana::string& s1, nana::any*,
|
||||
const nana::string& s2, nana::any*, bool reverse)
|
||||
bool sort_compare( const std::string& s1, nana::any*,
|
||||
const std::string& s2, nana::any*, bool reverse)
|
||||
{
|
||||
return (reverse ? s1 > s2 : s1 < s2);
|
||||
}
|
||||
listbox.set_sort_compare(0, sort_compare);
|
||||
The listbox supports attaching a customer's object for each item, therefore the items can be
|
||||
sorted by comparing these customer's object.
|
||||
bool sort_compare( const nana::string&, nana::any* o1,
|
||||
const nana::string&, nana::any* o2, bool reverse)
|
||||
bool sort_compare( const std::string&, nana::any* o1,
|
||||
const std::string&, nana::any* o2, bool reverse)
|
||||
{
|
||||
if(o1 && o2) //some items may not attach a customer object.
|
||||
{
|
||||
@ -565,15 +570,20 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
||||
void scroll(bool to_bottom, const index_pair& pos);
|
||||
|
||||
/// Appends a new column with a header text and the specified width at the end, and return it position
|
||||
size_type append_header(nana::string header_text, unsigned width = 120);
|
||||
size_type append_header(std::string text_utf8, unsigned width = 120);
|
||||
size_type append_header(std::wstring text, unsigned width = 120);
|
||||
listbox& header_width(size_type position, unsigned pixels);
|
||||
unsigned header_width(size_type position) const;
|
||||
unsigned auto_width(size_type position, unsigned max=3000);
|
||||
|
||||
|
||||
cat_proxy append(nana::string); ///< Appends a new category at the end
|
||||
void append(std::initializer_list<nana::string>); ///< Appends categories at the end
|
||||
cat_proxy insert(cat_proxy, nana::string);
|
||||
cat_proxy append(std::string); ///< Appends a new category to the end
|
||||
cat_proxy append(std::wstring); ///< Appends a new category to the end
|
||||
void append(std::initializer_list<std::string>); ///< Appends categories to the end
|
||||
void append(std::initializer_list<std::wstring>); ///< Appends categories to the end
|
||||
|
||||
cat_proxy insert(cat_proxy, ::std::string);
|
||||
cat_proxy insert(cat_proxy, ::std::wstring);
|
||||
cat_proxy at(size_type pos) const;
|
||||
|
||||
/// add categories in order when use a key?
|
||||
@ -606,7 +616,8 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
||||
|
||||
item_proxy at(const index_pair &abs_pos) const;
|
||||
|
||||
void insert(const index_pair&, nana::string); ///<Insert a new item with a text in the first column.
|
||||
void insert(const index_pair&, ::std::string); ///<Insert a new item with a text in the first column.
|
||||
void insert(const index_pair&, ::std::wstring); ///<Insert a new item with a text in the first column.
|
||||
|
||||
void checkable(bool);
|
||||
selection checked() const; ///<Returns the items which are checked.
|
||||
@ -637,8 +648,8 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
||||
void sortable(bool enable);
|
||||
|
||||
///Sets a strict weak ordering comparer for a column
|
||||
void set_sort_compare(size_type col, std::function<bool(const nana::string&, nana::any*,
|
||||
const nana::string&, nana::any*, bool reverse)> strick_ordering);
|
||||
void set_sort_compare(size_type col, std::function<bool(const std::string&, nana::any*,
|
||||
const std::string&, nana::any*, bool reverse)> strick_ordering);
|
||||
|
||||
/// sort() and ivalidate any existing reference from display position to absolute item, that is: after sort() display offset point to different items
|
||||
void sort_col(size_type col, bool reverse = false);
|
||||
|
||||
@ -25,6 +25,8 @@ namespace nana
|
||||
{
|
||||
struct menu_type; //declaration
|
||||
|
||||
using native_string_type = ::nana::detail::native_string_type;
|
||||
|
||||
enum class checks
|
||||
{
|
||||
none,
|
||||
@ -56,7 +58,7 @@ namespace nana
|
||||
|
||||
//Default constructor initializes the item as a splitter
|
||||
menu_item_type();
|
||||
menu_item_type(nana::string, const event_fn_t&);
|
||||
menu_item_type(std::string, const event_fn_t&);
|
||||
|
||||
struct
|
||||
{
|
||||
@ -66,11 +68,11 @@ namespace nana
|
||||
}flags;
|
||||
|
||||
menu_type *sub_menu{nullptr};
|
||||
nana::string text;
|
||||
std::string text;
|
||||
event_fn_t functor;
|
||||
checks style{checks::none};
|
||||
paint::image image;
|
||||
mutable nana::char_t hotkey{0};
|
||||
mutable wchar_t hotkey{0};
|
||||
};
|
||||
|
||||
struct menu_type
|
||||
@ -89,7 +91,7 @@ namespace nana
|
||||
class renderer_interface
|
||||
{
|
||||
public:
|
||||
typedef nana::paint::graphics & graph_reference;
|
||||
using graph_reference = nana::paint::graphics &;
|
||||
|
||||
enum class state
|
||||
{
|
||||
@ -109,7 +111,7 @@ namespace nana
|
||||
virtual void background(graph_reference, window) = 0;
|
||||
virtual void item(graph_reference, const nana::rectangle&, const attr&) = 0;
|
||||
virtual void item_image(graph_reference, const nana::point&, unsigned image_px, const paint::image&) = 0;
|
||||
virtual void item_text(graph_reference, const nana::point&, const nana::string&, unsigned text_pixels, const attr&) = 0;
|
||||
virtual void item_text(graph_reference, const nana::point&, const std::string&, unsigned text_pixels, const attr&) = 0;
|
||||
virtual void sub_arrow(graph_reference, const nana::point&, unsigned item_pixels, const attr&) = 0;
|
||||
};
|
||||
}//end namespace menu
|
||||
@ -134,7 +136,7 @@ namespace nana
|
||||
~menu();
|
||||
|
||||
/// Appends an item to the menu.
|
||||
item_proxy append(const nana::string& text, const event_fn_t& callback= event_fn_t());
|
||||
item_proxy append(const std::string& text, const event_fn_t& callback= event_fn_t());
|
||||
void append_splitter();
|
||||
void clear(); ///< Erases all of the items.
|
||||
/// Closes the menu. It does not destroy the menu; just close the window for the menu.
|
||||
@ -158,7 +160,7 @@ namespace nana
|
||||
bool goto_submen();///< Popup the submenu of the current item if it has a sub menu. Returns true if succeeds.
|
||||
bool exit_submenu(); ///< Closes the current window of the sub menu.
|
||||
std::size_t size() const; ///< Return the number of items.
|
||||
int send_shortkey(nana::char_t key);
|
||||
int send_shortkey(wchar_t key);
|
||||
void pick();
|
||||
|
||||
menu& max_pixels(unsigned); ///< Sets the max width in pixels of the item.
|
||||
|
||||
@ -21,6 +21,8 @@ namespace nana
|
||||
{
|
||||
namespace menubar
|
||||
{
|
||||
using native_string_type = ::nana::detail::native_string_type;
|
||||
|
||||
class item_renderer
|
||||
{
|
||||
public:
|
||||
@ -33,7 +35,7 @@ namespace nana
|
||||
|
||||
item_renderer(window, graph_reference);
|
||||
virtual void background(const point&, const ::nana::size&, state);
|
||||
virtual void caption(const point&, const ::nana::string&);
|
||||
virtual void caption(const point&, const native_string_type&);
|
||||
private:
|
||||
window handle_;
|
||||
graph_reference graph_;
|
||||
@ -46,7 +48,7 @@ namespace nana
|
||||
public:
|
||||
trigger();
|
||||
~trigger();
|
||||
nana::menu* push_back(const nana::string&);
|
||||
nana::menu* push_back(const std::string&);
|
||||
nana::menu* at(size_t) const;
|
||||
std::size_t size() const;
|
||||
private:
|
||||
@ -108,7 +110,7 @@ namespace nana
|
||||
menubar(window); ///< Create a menubar at the top of the specified window.
|
||||
~menubar();
|
||||
void create(window); ///< Create a menubar at the top of the specified window.
|
||||
menu& push_back(const nana::string&); ///< Appends a new (empty) menu.
|
||||
menu& push_back(const std::string&); ///< Appends a new (empty) menu.
|
||||
menu& at(size_t index) const; ///< Gets the menu specified by index.
|
||||
std::size_t length() const; ///< Number of menus.
|
||||
private:
|
||||
|
||||
@ -186,7 +186,7 @@ namespace nana
|
||||
{
|
||||
graph_ = &graph;
|
||||
widget_ = static_cast< ::nana::scroll<Vertical>*>(&widget);
|
||||
widget.caption(STR("Nana Scroll"));
|
||||
widget.caption("nana scroll");
|
||||
|
||||
timer_.stop();
|
||||
timer_.elapse(std::bind(&trigger::_m_tick, this));
|
||||
|
||||
@ -131,7 +131,7 @@ namespace nana{ namespace widgets
|
||||
struct keywords;
|
||||
class keyword_parser;
|
||||
public:
|
||||
using char_type = ::nana::char_t;
|
||||
using char_type = wchar_t;
|
||||
using size_type = textbase<char_type>::size_type;
|
||||
using string_type = textbase<char_type>::string_type;
|
||||
|
||||
@ -152,10 +152,10 @@ namespace nana{ namespace widgets
|
||||
text_editor(window, graph_reference, const text_editor_scheme*);
|
||||
~text_editor();
|
||||
|
||||
void set_highlight(const std::string& name, const ::nana::color&, const ::nana::color&);
|
||||
void erase_highlight(const std::string& name);
|
||||
void set_keyword(const ::nana::string& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
|
||||
void erase_keyword(const ::nana::string& kw);
|
||||
void set_highlight(const ::std::string& name, const ::nana::color&, const ::nana::color&);
|
||||
void erase_highlight(const ::std::string& name);
|
||||
void set_keyword(const ::std::wstring& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
|
||||
void erase_keyword(const ::std::wstring& kw);
|
||||
|
||||
void set_accept(std::function<bool(char_type)>);
|
||||
void set_accept(accepts);
|
||||
@ -164,7 +164,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
void typeface_changed();
|
||||
|
||||
void indent(bool, std::function<nana::string()> generator);
|
||||
void indent(bool, std::function<std::string()> generator);
|
||||
void set_event(event_interface*);
|
||||
|
||||
/// Determine whether the text_editor is line wrapped.
|
||||
@ -174,7 +174,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
void border_renderer(std::function<void(graph_reference, const ::nana::color& bgcolor)>);
|
||||
|
||||
bool load(const nana::char_t*);
|
||||
bool load(const char*);
|
||||
|
||||
/// Sets the text area.
|
||||
/// @return true if the area is changed with the new value.
|
||||
@ -183,7 +183,7 @@ namespace nana{ namespace widgets
|
||||
/// Returns the text area
|
||||
rectangle text_area(bool including_scroll) const;
|
||||
|
||||
bool tip_string(nana::string&&);
|
||||
bool tip_string(::std::string&&);
|
||||
|
||||
const attributes & attr() const;
|
||||
bool multi_lines(bool);
|
||||
@ -201,9 +201,9 @@ namespace nana{ namespace widgets
|
||||
unsigned line_height() const;
|
||||
unsigned screen_lines() const;
|
||||
|
||||
bool getline(std::size_t pos, nana::string&) const;
|
||||
void text(nana::string);
|
||||
nana::string text() const;
|
||||
bool getline(std::size_t pos, ::std::wstring&) const;
|
||||
void text(std::wstring);
|
||||
std::wstring text() const;
|
||||
|
||||
/// Sets caret position through text coordinate.
|
||||
void move_caret(const upoint&);
|
||||
@ -221,7 +221,7 @@ namespace nana{ namespace widgets
|
||||
bool hit_select_area(nana::upoint pos) const;
|
||||
|
||||
bool move_select();
|
||||
bool mask(char_t);
|
||||
bool mask(wchar_t);
|
||||
|
||||
/// Returns width of text area excluding the vscroll size.
|
||||
unsigned width_pixels() const;
|
||||
@ -233,8 +233,8 @@ namespace nana{ namespace widgets
|
||||
void draw_corner();
|
||||
void render(bool focused);
|
||||
public:
|
||||
void put(nana::string);
|
||||
void put(nana::char_t);
|
||||
void put(std::wstring);
|
||||
void put(wchar_t);
|
||||
void copy() const;
|
||||
void cut();
|
||||
void paste();
|
||||
@ -253,8 +253,8 @@ namespace nana{ namespace widgets
|
||||
bool mouse_move(bool left_button, const point& screen_pos);
|
||||
bool mouse_pressed(const arg_mouse& arg);
|
||||
|
||||
skeletons::textbase<nana::char_t>& textbase();
|
||||
const skeletons::textbase<nana::char_t>& textbase() const;
|
||||
skeletons::textbase<wchar_t>& textbase();
|
||||
const skeletons::textbase<wchar_t>& textbase() const;
|
||||
private:
|
||||
bool _m_accepts(char_type) const;
|
||||
::nana::color _m_bgcolor() const;
|
||||
@ -264,11 +264,11 @@ namespace nana{ namespace widgets
|
||||
::nana::size _m_text_area() const;
|
||||
void _m_get_scrollbar_size();
|
||||
void _m_reset();
|
||||
::nana::upoint _m_put(nana::string);
|
||||
::nana::upoint _m_put(::std::wstring);
|
||||
::nana::upoint _m_erase_select();
|
||||
|
||||
bool _m_make_select_string(nana::string&) const;
|
||||
static bool _m_resolve_text(const nana::string&, std::vector<std::pair<std::size_t, std::size_t>> & lines);
|
||||
bool _m_make_select_string(::std::wstring&) const;
|
||||
static bool _m_resolve_text(const ::std::wstring&, std::vector<std::pair<std::size_t, std::size_t>> & lines);
|
||||
|
||||
bool _m_cancel_select(int align);
|
||||
unsigned _m_tabs_pixels(size_type tabs) const;
|
||||
@ -283,10 +283,10 @@ namespace nana{ namespace widgets
|
||||
/// Returns the right/bottom point of text area.
|
||||
int _m_end_pos(bool right) const;
|
||||
|
||||
void _m_draw_parse_string(const keyword_parser&, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const ::nana::char_t*, std::size_t len) const;
|
||||
void _m_draw_parse_string(const keyword_parser&, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const wchar_t*, std::size_t len) const;
|
||||
//_m_draw_string
|
||||
//@brief: Draw a line of string
|
||||
void _m_draw_string(int top, const ::nana::color&, const nana::upoint& str_pos, const nana::string&, bool if_mask) const;
|
||||
void _m_draw_string(int top, const ::nana::color&, const nana::upoint& str_pos, const ::std::wstring&, bool if_mask) const;
|
||||
//_m_update_caret_line
|
||||
//@brief: redraw whole line specified by caret pos.
|
||||
//@return: true if caret overs the border
|
||||
@ -295,8 +295,8 @@ namespace nana{ namespace widgets
|
||||
|
||||
void _m_offset_y(int y);
|
||||
|
||||
unsigned _m_char_by_pixels(const nana::char_t*, std::size_t len, unsigned* pxbuf, int str_px, int pixels, bool is_rtl);
|
||||
unsigned _m_pixels_by_char(const nana::string&, std::size_t pos) const;
|
||||
unsigned _m_char_by_pixels(const wchar_t*, std::size_t len, unsigned* pxbuf, int str_px, int pixels, bool is_rtl);
|
||||
unsigned _m_pixels_by_char(const ::std::wstring&, std::size_t pos) const;
|
||||
void _handle_move_key(const arg_keyboard& arg);
|
||||
|
||||
private:
|
||||
@ -308,8 +308,8 @@ namespace nana{ namespace widgets
|
||||
event_interface * event_handler_{ nullptr };
|
||||
std::unique_ptr<keywords> keywords_;
|
||||
|
||||
skeletons::textbase<nana::char_t> textbase_;
|
||||
nana::char_t mask_char_{0};
|
||||
skeletons::textbase<wchar_t> textbase_;
|
||||
wchar_t mask_char_{0};
|
||||
|
||||
mutable ext_renderer_tag ext_renderer_;
|
||||
|
||||
@ -318,7 +318,7 @@ namespace nana{ namespace widgets
|
||||
struct indent_rep
|
||||
{
|
||||
bool enabled{ false };
|
||||
std::function<nana::string()> generator;
|
||||
std::function<std::string()> generator;
|
||||
}indent_;
|
||||
|
||||
struct attributes
|
||||
@ -326,7 +326,7 @@ namespace nana{ namespace widgets
|
||||
accepts acceptive{ accepts::no_restrict };
|
||||
std::function<bool(char_type)> pred_acceptive;
|
||||
|
||||
nana::string tip_string;
|
||||
::std::string tip_string;
|
||||
|
||||
bool line_wrapped{false};
|
||||
bool multi_lines{true};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Text Token Stream
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -42,7 +42,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
class tokenizer
|
||||
{
|
||||
public:
|
||||
tokenizer(const nana::string& s, bool format_enabled)
|
||||
tokenizer(const std::wstring& s, bool format_enabled)
|
||||
: iptr_(s.data()),
|
||||
endptr_(s.data() + s.size()),
|
||||
format_enabled_(format_enabled)
|
||||
@ -74,12 +74,12 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return _m_token();
|
||||
}
|
||||
|
||||
const nana::string& idstr() const
|
||||
const ::std::wstring& idstr() const
|
||||
{
|
||||
return idstr_;
|
||||
}
|
||||
|
||||
const std::pair<nana::string, nana::string>& binary() const
|
||||
const std::pair<std::wstring, std::wstring>& binary() const
|
||||
{
|
||||
return binary_;
|
||||
}
|
||||
@ -108,7 +108,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return n;
|
||||
}
|
||||
private:
|
||||
static bool _m_unicode_word_breakable(nana::char_t ch)
|
||||
static bool _m_unicode_word_breakable(wchar_t ch)
|
||||
{
|
||||
return ((0x4E00 <= ch) && (ch <= 0x9FFF));
|
||||
}
|
||||
@ -116,7 +116,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
//Read the data token
|
||||
token _m_token()
|
||||
{
|
||||
nana::char_t ch = *iptr_;
|
||||
wchar_t ch = *iptr_;
|
||||
|
||||
if(ch > 0xFF)
|
||||
{
|
||||
@ -150,7 +150,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
|
||||
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
|
||||
{
|
||||
const nana::char_t * idstr = iptr_;
|
||||
auto idstr = iptr_;
|
||||
do
|
||||
{
|
||||
ch = *(++iptr_);
|
||||
@ -172,7 +172,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
{
|
||||
//pos keeps the current position, and it used for restring
|
||||
//iptr_ when the search is failed.
|
||||
const nana::char_t * pos = ++iptr_;
|
||||
auto pos = ++iptr_;
|
||||
_m_eat_whitespace();
|
||||
if(*iptr_ == '/')
|
||||
{
|
||||
@ -219,7 +219,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
{
|
||||
_m_eat_whitespace();
|
||||
|
||||
nana::char_t ch = *iptr_++;
|
||||
auto ch = *iptr_++;
|
||||
|
||||
switch(ch)
|
||||
{
|
||||
@ -232,7 +232,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
case '"':
|
||||
//Here is a string and all the meta characters will be ignored except "
|
||||
{
|
||||
const nana::char_t * str = iptr_;
|
||||
auto str = iptr_;
|
||||
|
||||
while((iptr_ != endptr_) && (*iptr_ != '"'))
|
||||
++iptr_;
|
||||
@ -244,7 +244,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
_m_eat_whitespace();
|
||||
if((iptr_ < endptr_) && _m_is_idstr_element(*iptr_))
|
||||
{
|
||||
const nana::char_t * pbegin = iptr_;
|
||||
auto pbegin = iptr_;
|
||||
while((iptr_ < endptr_) && _m_is_idstr_element(*iptr_))
|
||||
++iptr_;
|
||||
|
||||
@ -281,45 +281,45 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
//Here is a identifier
|
||||
_m_read_idstr();
|
||||
|
||||
if(STR("font") == idstr_)
|
||||
if(L"font" == idstr_)
|
||||
return token::font;
|
||||
else if(STR("bold") == idstr_)
|
||||
else if(L"bold" == idstr_)
|
||||
return token::bold;
|
||||
else if(STR("size") == idstr_)
|
||||
else if(L"size" == idstr_)
|
||||
return token::size;
|
||||
else if(STR("baseline") == idstr_)
|
||||
else if(L"baseline" == idstr_)
|
||||
return token::baseline;
|
||||
else if(STR("top") == idstr_)
|
||||
else if(L"top" == idstr_)
|
||||
return token::top;
|
||||
else if(STR("center") == idstr_)
|
||||
else if(L"center" == idstr_)
|
||||
return token::center;
|
||||
else if(STR("bottom") == idstr_)
|
||||
else if(L"bottom" == idstr_)
|
||||
return token::bottom;
|
||||
else if(STR("color") == idstr_)
|
||||
else if(L"color" == idstr_)
|
||||
return token::color;
|
||||
else if(STR("image") == idstr_)
|
||||
else if(L"image" == idstr_)
|
||||
return token::image;
|
||||
else if(STR("true") == idstr_)
|
||||
else if(L"true" == idstr_)
|
||||
return token::_true;
|
||||
else if(STR("url") == idstr_)
|
||||
else if(L"url" == idstr_)
|
||||
return token::url;
|
||||
else if(STR("target") == idstr_)
|
||||
else if(L"target" == idstr_)
|
||||
return token::target;
|
||||
else if(STR("false") == idstr_)
|
||||
else if(L"false" == idstr_)
|
||||
return token::_false;
|
||||
else if(STR("red") == idstr_)
|
||||
else if(L"red" == idstr_)
|
||||
return token::red;
|
||||
else if(STR("green") == idstr_)
|
||||
else if(L"green" == idstr_)
|
||||
return token::green;
|
||||
else if(STR("blue") == idstr_)
|
||||
else if(L"blue" == idstr_)
|
||||
return token::blue;
|
||||
else if(STR("white") == idstr_)
|
||||
else if(L"white" == idstr_)
|
||||
return token::white;
|
||||
else if(STR("black") == idstr_)
|
||||
else if(L"black" == idstr_)
|
||||
return token::black;
|
||||
else if(STR("min_limited") == idstr_)
|
||||
else if(L"min_limited" == idstr_)
|
||||
return token::min_limited;
|
||||
else if(STR("max_limited") == idstr_)
|
||||
else if(L"max_limited" == idstr_)
|
||||
return token::max_limited;
|
||||
|
||||
return token::string;
|
||||
@ -335,7 +335,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return token::eof;
|
||||
}
|
||||
|
||||
static bool _m_is_idstr_element(nana::char_t ch)
|
||||
static bool _m_is_idstr_element(wchar_t ch)
|
||||
{
|
||||
return (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || ('_' == ch) || ('0' <= ch && ch <= '9'));
|
||||
}
|
||||
@ -343,9 +343,9 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
//Read the identifier.
|
||||
void _m_read_idstr()
|
||||
{
|
||||
const nana::char_t * idstr = iptr_;
|
||||
auto idstr = iptr_;
|
||||
|
||||
nana::char_t ch;
|
||||
wchar_t ch;
|
||||
do
|
||||
{
|
||||
ch = *(++iptr_);
|
||||
@ -360,7 +360,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
{
|
||||
idstr_.clear();
|
||||
|
||||
nana::char_t ch = *iptr_;
|
||||
wchar_t ch = *iptr_;
|
||||
|
||||
idstr_ += ch;
|
||||
|
||||
@ -412,13 +412,13 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
}
|
||||
}
|
||||
private:
|
||||
const ::nana::char_t * iptr_;
|
||||
const ::nana::char_t * endptr_;
|
||||
const wchar_t * iptr_;
|
||||
const wchar_t * endptr_;
|
||||
const bool format_enabled_;
|
||||
bool format_state_{false};
|
||||
|
||||
::nana::string idstr_;
|
||||
std::pair<nana::string, nana::string> binary_;
|
||||
std::wstring idstr_;
|
||||
std::pair<std::wstring, std::wstring> binary_;
|
||||
token revert_token_{token::eof};
|
||||
};
|
||||
|
||||
@ -434,7 +434,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
};
|
||||
};
|
||||
|
||||
::nana::string font;
|
||||
::std::string font;
|
||||
std::size_t font_size;
|
||||
bool bold;
|
||||
bool bold_empty; //bold should be ignored if bold_empty is true
|
||||
@ -442,8 +442,8 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
::nana::color bgcolor; //If the color is not specified, it will be ignored, and the system will search for its parent.
|
||||
::nana::color fgcolor; //ditto
|
||||
|
||||
::nana::string target;
|
||||
::nana::string url;
|
||||
::std::wstring target;
|
||||
::std::wstring url;
|
||||
|
||||
fblock * parent;
|
||||
};
|
||||
@ -458,7 +458,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
|
||||
virtual bool is_text() const = 0;
|
||||
virtual bool is_whitespace() const = 0;
|
||||
virtual const nana::string& text() const = 0;
|
||||
virtual const std::wstring& text() const = 0;
|
||||
virtual void measure(graph_reference) = 0;
|
||||
virtual void nontext_render(graph_reference, int x, int y) = 0;
|
||||
virtual const nana::size & size() const = 0;
|
||||
@ -470,7 +470,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
: public data
|
||||
{
|
||||
public:
|
||||
data_text(const nana::string& s)
|
||||
data_text(const std::wstring& s)
|
||||
: str_(s)
|
||||
{}
|
||||
private:
|
||||
@ -484,7 +484,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const nana::string& text() const override
|
||||
virtual const std::wstring& text() const override
|
||||
{
|
||||
return str_;
|
||||
}
|
||||
@ -513,7 +513,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return ascent_;
|
||||
}
|
||||
private:
|
||||
nana::string str_;
|
||||
std::wstring str_;
|
||||
nana::size size_;
|
||||
std::size_t ascent_;
|
||||
};
|
||||
@ -522,7 +522,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
: public data
|
||||
{
|
||||
public:
|
||||
data_image(const nana::string& imgpath, const nana::size & sz, std::size_t limited)
|
||||
data_image(const std::wstring& imgpath, const nana::size & sz, std::size_t limited)
|
||||
: image_(imgpath)//, limited_(limited)
|
||||
{
|
||||
size_ = image_.size();
|
||||
@ -562,7 +562,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const nana::string& text() const override
|
||||
virtual const std::wstring& text() const override
|
||||
{
|
||||
return str_;
|
||||
}
|
||||
@ -589,7 +589,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return size_.height;
|
||||
}
|
||||
private:
|
||||
nana::string str_;
|
||||
std::wstring str_;
|
||||
nana::paint::image image_;
|
||||
nana::size size_;
|
||||
};
|
||||
@ -626,7 +626,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
fblocks_.clear();
|
||||
}
|
||||
|
||||
void parse(const nana::string& s, bool format_enabled)
|
||||
void parse(const std::wstring& s, bool format_enabled)
|
||||
{
|
||||
close();
|
||||
|
||||
@ -706,7 +706,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
if(token::string != tknizer.read())
|
||||
throw std::runtime_error("");
|
||||
|
||||
fp->font = tknizer.idstr();
|
||||
fp->font = to_utf8(tknizer.idstr());
|
||||
break;
|
||||
case token::size:
|
||||
if(token::equal != tknizer.read())
|
||||
@ -893,7 +893,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return fbp;
|
||||
}
|
||||
|
||||
void _m_data_factory(token tk, const nana::string& idstr, fblock* fp, std::deque<value>& line)
|
||||
void _m_data_factory(token tk, const std::wstring& idstr, fblock* fp, std::deque<value>& line)
|
||||
{
|
||||
value v;
|
||||
v.fblock_ptr = fp;
|
||||
@ -926,7 +926,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
|
||||
struct attr_image_tag
|
||||
{
|
||||
nana::string path;
|
||||
std::wstring path;
|
||||
nana::size size;
|
||||
std::size_t limited;
|
||||
|
||||
|
||||
@ -57,13 +57,12 @@ namespace skeletons
|
||||
((text_cont_.size() == 1) && (text_cont_[0].empty())));
|
||||
}
|
||||
|
||||
bool load(const nana::char_t* fs)
|
||||
bool load(const char* file_utf8)
|
||||
{
|
||||
if (nullptr == fs)
|
||||
if (!file_utf8)
|
||||
return false;
|
||||
|
||||
std::string fs_mbs = nana::charset(fs);
|
||||
std::ifstream ifs(fs_mbs.data());
|
||||
std::ifstream ifs(to_osmbstr(file_utf8));
|
||||
if (!ifs)
|
||||
return false;
|
||||
|
||||
@ -81,7 +80,7 @@ namespace skeletons
|
||||
if(0xBB == ch && 0xBF == ifs.get())
|
||||
{
|
||||
ifs.close();
|
||||
return load(fs, nana::unicode::utf8);
|
||||
return load(file_utf8, nana::unicode::utf8);
|
||||
}
|
||||
}
|
||||
else if(0xFF == ch)
|
||||
@ -94,11 +93,11 @@ namespace skeletons
|
||||
if(ifs.get() == 0 && ifs.get() == 0)
|
||||
{
|
||||
ifs.close();
|
||||
return load(fs, nana::unicode::utf32);
|
||||
return load(file_utf8, nana::unicode::utf32);
|
||||
}
|
||||
}
|
||||
ifs.close();
|
||||
return load(fs, nana::unicode::utf16);
|
||||
return load(file_utf8, nana::unicode::utf16);
|
||||
}
|
||||
}
|
||||
else if(0xFE == ch)
|
||||
@ -107,7 +106,7 @@ namespace skeletons
|
||||
{
|
||||
//UTF16(big-endian)
|
||||
ifs.close();
|
||||
return load(fs, nana::unicode::utf16);
|
||||
return load(file_utf8, nana::unicode::utf16);
|
||||
}
|
||||
}
|
||||
else if(0 == ch)
|
||||
@ -119,7 +118,7 @@ namespace skeletons
|
||||
{
|
||||
//UTF32(big_endian)
|
||||
ifs.close();
|
||||
return load(fs, nana::unicode::utf32);
|
||||
return load(file_utf8, nana::unicode::utf32);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,7 +142,7 @@ namespace skeletons
|
||||
}
|
||||
}
|
||||
|
||||
_m_saved(fs);
|
||||
_m_saved(file_utf8);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -175,13 +174,12 @@ namespace skeletons
|
||||
}
|
||||
}
|
||||
|
||||
bool load(const nana::char_t * fs, nana::unicode encoding)
|
||||
bool load(const char* file_utf8, nana::unicode encoding)
|
||||
{
|
||||
if (nullptr == fs)
|
||||
if (!file_utf8)
|
||||
return false;
|
||||
|
||||
std::string fs_mbs = nana::charset(fs);
|
||||
std::ifstream ifs(fs_mbs.data());
|
||||
std::ifstream ifs(to_osmbstr(file_utf8));
|
||||
|
||||
if (!ifs)
|
||||
return false;
|
||||
@ -245,14 +243,13 @@ namespace skeletons
|
||||
}
|
||||
}
|
||||
|
||||
_m_saved(fs);
|
||||
_m_saved(file_utf8);
|
||||
return true;
|
||||
}
|
||||
|
||||
void store(nana::string fs, bool is_unicode, ::nana::unicode encoding) const
|
||||
void store(std::string fs, bool is_unicode, ::nana::unicode encoding) const
|
||||
{
|
||||
std::string fs_mbs = nana::charset(fs);
|
||||
std::ofstream ofs(fs_mbs.data(), std::ios::binary);
|
||||
std::ofstream ofs(to_osmbstr(fs), std::ios::binary);
|
||||
if(ofs && text_cont_.size())
|
||||
{
|
||||
std::string last_mbs;
|
||||
@ -410,7 +407,7 @@ namespace skeletons
|
||||
{
|
||||
std::deque<string_type>().swap(text_cont_);
|
||||
attr_max_.reset();
|
||||
_m_saved(nana::string());
|
||||
_m_saved(std::string());
|
||||
}
|
||||
|
||||
void merge(size_type pos)
|
||||
@ -427,7 +424,7 @@ namespace skeletons
|
||||
}
|
||||
}
|
||||
|
||||
const nana::string& filename() const
|
||||
const std::string& filename() const
|
||||
{
|
||||
return filename_;
|
||||
}
|
||||
@ -489,7 +486,7 @@ namespace skeletons
|
||||
evt_agent_->first_change();
|
||||
}
|
||||
|
||||
void _m_saved(nana::string && filename) const
|
||||
void _m_saved(std::string && filename) const
|
||||
{
|
||||
if(filename_ != filename)
|
||||
{
|
||||
@ -518,7 +515,7 @@ namespace skeletons
|
||||
textbase_event_agent_interface* evt_agent_{ nullptr };
|
||||
|
||||
mutable bool changed_{ false };
|
||||
mutable nana::string filename_; //A string for the saved filename.
|
||||
mutable std::string filename_; //A string for the saved filename.
|
||||
const string_type nullstr_;
|
||||
|
||||
struct attr_max
|
||||
|
||||
@ -45,7 +45,7 @@ namespace nana
|
||||
{
|
||||
public:
|
||||
virtual ~provider() = default;
|
||||
virtual nana::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
|
||||
virtual std::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
|
||||
};
|
||||
|
||||
class renderer
|
||||
@ -81,7 +81,7 @@ namespace nana
|
||||
|
||||
virtual void background(window, graph_reference, bool isglass) = 0;
|
||||
virtual void adorn(window, graph_reference, const adorn_t&) = 0;
|
||||
virtual void adorn_textbox(window, graph_reference, const nana::string&, const nana::rectangle&) = 0;
|
||||
virtual void adorn_textbox(window, graph_reference, const ::std::string&, const nana::rectangle&) = 0;
|
||||
virtual void bar(window, graph_reference, const bar_t&) = 0;
|
||||
virtual void slider(window, graph_reference, const slider_t&) = 0;
|
||||
};
|
||||
|
||||
@ -97,17 +97,17 @@ namespace nana
|
||||
void range(std::initializer_list<std::wstring> values);
|
||||
|
||||
/// Gets the spined value
|
||||
::nana::string value() const;
|
||||
void value(const ::nana::string&);
|
||||
::std::string value() const;
|
||||
void value(const ::std::string&);
|
||||
int to_int() const;
|
||||
double to_double() const;
|
||||
|
||||
/// Sets the modifiers
|
||||
void modifier(std::wstring prefix, std::wstring suffix);
|
||||
void modifier(const std::string & prefix_utf8, const std::string& suffix_utf8);
|
||||
void modifier(std::string prefix_utf8, std::string suffix_utf8);
|
||||
void modifier(const std::wstring & prefix, const std::wstring& suffix);
|
||||
private:
|
||||
::nana::string _m_caption() const throw();
|
||||
void _m_caption(::nana::string&&);
|
||||
native_string_type _m_caption() const throw();
|
||||
void _m_caption(native_string_type&&);
|
||||
}; //end class spinbox
|
||||
}//end namespace nana
|
||||
|
||||
|
||||
@ -144,12 +144,14 @@ namespace nana
|
||||
: public drawer_trigger
|
||||
{
|
||||
public:
|
||||
using native_string_type = ::nana::detail::native_string_type;
|
||||
|
||||
enum class kits
|
||||
{
|
||||
add,
|
||||
scroll,
|
||||
list,
|
||||
close
|
||||
add, ///< The type identifies the add button of the tabbar's toolbox.
|
||||
scroll, ///< The type identifies the scroll button of the tabbar's toolbox
|
||||
list, ///< The type identifies the list button of the tabbar's toolbox
|
||||
close ///< The type identifies the close button of the tabbar's toolbox
|
||||
};
|
||||
|
||||
trigger();
|
||||
@ -161,15 +163,15 @@ namespace nana
|
||||
const pat::cloneable<item_renderer> & ext_renderer() const;
|
||||
void ext_renderer(const pat::cloneable<item_renderer>&);
|
||||
void set_event_agent(event_agent_interface*);
|
||||
void insert(std::size_t, nana::string&&, nana::any&&);
|
||||
void insert(std::size_t, native_string_type&&, nana::any&&);
|
||||
std::size_t length() const;
|
||||
bool close_fly(bool);
|
||||
void attach(std::size_t, window);
|
||||
void erase(std::size_t);
|
||||
void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&);
|
||||
void tab_image(size_t, const nana::paint::image&);
|
||||
void text(std::size_t, const nana::string&);
|
||||
nana::string text(std::size_t) const;
|
||||
void text(std::size_t, const native_string_type&);
|
||||
native_string_type text(std::size_t) const;
|
||||
bool toolbox(kits, bool);
|
||||
private:
|
||||
void attached(widget_reference, graph_reference) override;
|
||||
@ -191,30 +193,9 @@ namespace nana
|
||||
{
|
||||
typedef drawerbase::tabbar::trigger drawer_trigger_t;
|
||||
public:
|
||||
typedef Type value_type; ///< The type of element data which is stored in the tabbar.
|
||||
typedef drawerbase::tabbar::item_renderer item_renderer; ///< A user-defined item renderer should be derived from this interface.
|
||||
|
||||
//These member types is deprecated, they will be removed in Nana 1.3
|
||||
struct button_add{}; ///< The type identifies the add button of the tabbar's toolbox.
|
||||
struct button_scroll{}; ///< The type identifies the scroll button of the tabbar's toolbox.
|
||||
struct button_list{}; ///< The type identifies the list button of the tabbar's toolbox.
|
||||
struct button_close{}; ///< The type identifies the close button of the tabbar's toolbox.
|
||||
|
||||
//This template class is deprecated, it will be removed in 1.3
|
||||
/// A template class identifies the buttons of the tabbar's toolbox. Refer to notes for more details.
|
||||
template<typename ButtonAdd = nana::null_type, typename ButtonScroll = nana::null_type, typename ButtonList = nana::null_type, typename ButtonClose = nana::null_type>
|
||||
struct button_container
|
||||
{
|
||||
typedef meta::fixed_type_set<ButtonAdd, ButtonScroll, ButtonList, ButtonClose> type_set;
|
||||
};
|
||||
|
||||
enum class kits
|
||||
{
|
||||
add, ///< The type identifies the add button of the tabbar's toolbox.
|
||||
scroll, ///< The type identifies the scroll button of the tabbar's toolbox
|
||||
list, ///< The type identifies the list button of the tabbar's toolbox
|
||||
close ///< The type identifies the close button of the tabbar's toolbox
|
||||
};
|
||||
using value_type = Type; ///< The type of element data which is stored in the tabbar.
|
||||
using item_renderer = drawerbase::tabbar::item_renderer; ///< A user-defined item renderer should be derived from this interface.
|
||||
using kits = drawer_trigger_t::kits;
|
||||
|
||||
tabbar()
|
||||
{
|
||||
@ -298,15 +279,19 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
void push_back(nana::string text) /// Append a new item.
|
||||
void push_back(std::string text) /// Append a new item.
|
||||
{
|
||||
this->get_drawer_trigger().insert(::nana::npos, std::move(text), value_type());
|
||||
this->get_drawer_trigger().insert(::nana::npos, to_nstring(std::move(text)), value_type());
|
||||
API::update_window(*this);
|
||||
}
|
||||
|
||||
void insert(std::size_t pos, std::string text, value_type value = {})
|
||||
{
|
||||
return this->insert(pos, static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), std::move(value));
|
||||
if (pos > length())
|
||||
throw std::out_of_range("tabbar::insert invalid position");
|
||||
|
||||
this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value));
|
||||
API::update_window(*this);
|
||||
}
|
||||
|
||||
void insert(std::size_t pos, std::wstring text, value_type value = {})
|
||||
@ -314,16 +299,10 @@ namespace nana
|
||||
if (pos > length())
|
||||
throw std::out_of_range("tabbar::insert invalid position");
|
||||
|
||||
this->get_drawer_trigger().insert(pos, std::move(text), std::move(value));
|
||||
this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value));
|
||||
API::update_window(*this);
|
||||
}
|
||||
|
||||
//deprecated from 1.2.1, removed from 1.3
|
||||
void relate(std::size_t pos, window wd) /// Binds a window to an item specified by pos, if the item is selected, shows the window, otherwise, hides it.
|
||||
{
|
||||
this->get_drawer_trigger().attach(pos, wd);
|
||||
}
|
||||
|
||||
void attach(std::size_t pos, window attach_wd)
|
||||
{
|
||||
if (attach_wd && API::empty_window(attach_wd))
|
||||
@ -351,46 +330,22 @@ namespace nana
|
||||
{
|
||||
this->get_drawer_trigger().tab_image(pos, img);
|
||||
}
|
||||
|
||||
/// Sets buttons of the tabbar's toolbox, refer to notes for more details.
|
||||
template<typename Add, typename Scroll, typename List, typename Close>
|
||||
void toolbox(const button_container<Add, Scroll, List, Close>&, bool enable)
|
||||
{
|
||||
typedef typename button_container<Add, Scroll, List, Close>::type_set type_set;
|
||||
auto & tg = this->get_drawer_trigger();
|
||||
bool redraw = false;
|
||||
|
||||
using inner_kits = drawerbase::tabbar::trigger::kits;
|
||||
|
||||
if(type_set::template count<button_add>::value)
|
||||
redraw |= tg.toolbox(inner_kits::add, enable);
|
||||
|
||||
if(type_set::template count<button_scroll>::value)
|
||||
redraw |= tg.toolbox(inner_kits::scroll, enable);
|
||||
|
||||
if(type_set::template count<button_list>::value)
|
||||
redraw |= tg.toolbox(inner_kits::add, enable);
|
||||
|
||||
if(type_set::template count<button_close>::value)
|
||||
redraw |= tg.toolbox(inner_kits::close, enable);
|
||||
|
||||
if(redraw)
|
||||
API::refresh_window(this->handle());
|
||||
}
|
||||
|
||||
void toolbox(kits kit, bool enable)
|
||||
{
|
||||
if (this->get_drawer_trigger().toolbox(kit, enable))
|
||||
API::refresh_window(this->handle());
|
||||
}
|
||||
|
||||
void text(std::size_t pos, const nana::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
|
||||
void text(std::size_t pos, const std::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
|
||||
{
|
||||
this->get_drawer_trigger().text(pos, str);
|
||||
this->get_drawer_trigger().text(pos, to_nstring(str));
|
||||
}
|
||||
|
||||
nana::string text(std::size_t pos) const /// Returns a title of a specified item, If pos is invalid, the method trhows a std::out_of_range object.
|
||||
std::string text(std::size_t pos) const /// Returns a title of a specified item, If pos is invalid, the method trhows a std::out_of_range object.
|
||||
{
|
||||
return this->get_drawer_trigger().text(pos);
|
||||
return to_utf8(this->get_drawer_trigger().text(pos));
|
||||
}
|
||||
private:
|
||||
std::unique_ptr<drawerbase::tabbar::event_agent<value_type, drawerbase::tabbar::trigger> > evt_agent_;
|
||||
|
||||
@ -111,13 +111,13 @@ namespace nana
|
||||
/// @param window A handle to the parent window of the widget being created.
|
||||
/// @param text the text that will be displayed.
|
||||
/// @param visible specifying the visible after creating.
|
||||
textbox(window, const nana::string& text, bool visible = true);
|
||||
textbox(window, const std::string& text, bool visible = true);
|
||||
|
||||
/// \brief The construct that creates a widget with a specified text.
|
||||
/// @param window A handle to the parent window of the widget being created.
|
||||
/// @param text the text that will be displayed.
|
||||
/// @param visible specifying the visible after creating.
|
||||
textbox(window, const nana::char_t* text, bool visible = true);
|
||||
textbox(window, const char* text, bool visible = true);
|
||||
|
||||
/// \brief The construct that creates a widget.
|
||||
/// @param window A handle to the parent window of the widget being created.
|
||||
@ -126,19 +126,19 @@ namespace nana
|
||||
textbox(window, const rectangle& = rectangle(), bool visible = true);
|
||||
|
||||
/// \brief Loads a text file. When attempt to load a unicode encoded text file, be sure the file have a BOM header.
|
||||
void load(nana::string file);
|
||||
void store(nana::string file);
|
||||
void store(nana::string file, nana::unicode encoding);
|
||||
void load(std::string file);
|
||||
void store(std::string file);
|
||||
void store(std::string file, nana::unicode encoding);
|
||||
|
||||
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
|
||||
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
|
||||
textbox& indention(bool, std::function<nana::string()> generator = {});
|
||||
textbox& indention(bool, std::function<std::string()> generator = {});
|
||||
|
||||
//A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
|
||||
textbox& reset(nana::string = nana::string()); ///< discard the old text and set a new text
|
||||
textbox& reset(const std::string& = std::string()); ///< discard the old text and set a new text
|
||||
|
||||
/// The file of last store operation.
|
||||
nana::string filename() const;
|
||||
std::string filename() const;
|
||||
|
||||
/// Determine whether the text was edited.
|
||||
bool edited() const;
|
||||
@ -150,7 +150,7 @@ namespace nana
|
||||
bool saved() const;
|
||||
|
||||
/// Read the text from a specified line. It returns true for success.
|
||||
bool getline(std::size_t pos, nana::string&) const;
|
||||
bool getline(std::size_t pos, std::string&) const;
|
||||
|
||||
/// Gets the caret position
|
||||
/// Returns true if the caret is in the area of display, false otherwise.
|
||||
@ -160,7 +160,7 @@ namespace nana
|
||||
textbox& caret_pos(const upoint&);
|
||||
|
||||
/// Appends an string. If `at_caret` is `true`, the string is inserted at the position of caret, otherwise, it is appended at end of the textbox.
|
||||
textbox& append(const nana::string& text, bool at_caret);
|
||||
textbox& append(const std::string& text, bool at_caret);
|
||||
|
||||
/// Determine wheter the text is line wrapped.
|
||||
bool line_wrapped() const;
|
||||
@ -171,12 +171,12 @@ namespace nana
|
||||
textbox& multi_lines(bool);
|
||||
bool editable() const;
|
||||
textbox& editable(bool);
|
||||
void set_accept(std::function<bool(nana::char_t)>);
|
||||
void set_accept(std::function<bool(wchar_t)>);
|
||||
|
||||
textbox& tip_string(nana::string);
|
||||
textbox& tip_string(::std::string);
|
||||
|
||||
/// Set a mask character. Text is displayed as mask character if a mask character is set. This is used for hiding some special text, such as password.
|
||||
textbox& mask(nana::char_t);
|
||||
textbox& mask(wchar_t);
|
||||
|
||||
/// Returns true if some text is selected.
|
||||
bool selected() const;
|
||||
@ -195,10 +195,9 @@ namespace nana
|
||||
|
||||
void set_highlight(const std::string& name, const ::nana::color& fgcolor, const ::nana::color& bgcolor);
|
||||
void erase_highlight(const std::string& name);
|
||||
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<nana::string> kw_list);
|
||||
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::wstring> kw_list);
|
||||
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::string> kw_list_utf8);
|
||||
void erase_keyword(const nana::string& kw);
|
||||
|
||||
void erase_keyword(const std::string& kw);
|
||||
|
||||
/// Returns the text position of each line that currently displays on screen.
|
||||
text_positions text_position() const;
|
||||
@ -210,8 +209,8 @@ namespace nana
|
||||
unsigned line_pixels() const;
|
||||
protected:
|
||||
//Overrides widget's virtual functions
|
||||
::nana::string _m_caption() const throw() override;
|
||||
void _m_caption(::nana::string&&) override;
|
||||
native_string_type _m_caption() const throw() override;
|
||||
void _m_caption(native_string_type&&) override;
|
||||
void _m_typeface(const paint::font&) override;
|
||||
};
|
||||
}//end namespace nana
|
||||
|
||||
@ -87,8 +87,8 @@ namespace nana
|
||||
toolbar(window, const rectangle& = rectangle(), bool visible = true);
|
||||
|
||||
void separate(); ///< Adds a separator.
|
||||
void append(const nana::string& text, const nana::paint::image& img); ///< Adds a control button.
|
||||
void append(const nana::string& text); ///< Adds a control button.
|
||||
void append(const ::std::string& text, const nana::paint::image& img); ///< Adds a control button.
|
||||
void append(const ::std::string& text); ///< Adds a control button.
|
||||
bool enable(size_type index) const;
|
||||
void enable(size_type index, bool enable_state);
|
||||
void scale(unsigned s); ///< Sets the scale of control button.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -34,6 +34,8 @@ namespace nana
|
||||
class inner_widget_notifier;
|
||||
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
|
||||
public:
|
||||
using native_string_type = detail::native_string_type;
|
||||
|
||||
virtual ~widget() = default;
|
||||
virtual window handle() const = 0; ///< Returns the handle of window, returns 0 if window is not created.
|
||||
bool empty() const; ///< Determines whether the manipulator is handling a window.
|
||||
@ -41,9 +43,12 @@ namespace nana
|
||||
|
||||
window parent() const;
|
||||
|
||||
nana::string caption() const throw();
|
||||
void caption(std::string utf8);
|
||||
void caption(std::wstring);
|
||||
::std::string caption() const throw();
|
||||
::std::wstring caption_wstring() const throw();
|
||||
native_string_type caption_native() const throw();
|
||||
|
||||
widget& caption(std::string utf8);
|
||||
widget& caption(std::wstring);
|
||||
|
||||
template<typename ...Args>
|
||||
void i18n(std::string msgid, Args&&... args)
|
||||
@ -88,10 +93,10 @@ namespace nana
|
||||
|
||||
void umake_event(event_handle eh) const; ///< Deletes an event callback by a handle.
|
||||
|
||||
widget& register_shortkey(char_t); ///< Registers a shortkey. To remove a registered key, pass 0.
|
||||
widget& register_shortkey(wchar_t); ///< Registers a shortkey. To remove a registered key, pass 0.
|
||||
|
||||
widget& take_active(bool activated, window take_if_not_activated);
|
||||
widget& tooltip(const nana::string&);
|
||||
widget& tooltip(const ::std::string&);
|
||||
|
||||
operator dummy_bool_type() const;
|
||||
operator window() const;
|
||||
@ -105,8 +110,8 @@ namespace nana
|
||||
virtual void _m_complete_creation();
|
||||
|
||||
virtual general_events& _m_get_general_events() const = 0;
|
||||
virtual nana::string _m_caption() const throw();
|
||||
virtual void _m_caption(nana::string&&);
|
||||
virtual native_string_type _m_caption() const throw();
|
||||
virtual void _m_caption(native_string_type&&);
|
||||
virtual nana::cursor _m_cursor() const;
|
||||
virtual void _m_cursor(nana::cursor);
|
||||
virtual void _m_close();
|
||||
|
||||
@ -28,34 +28,34 @@ namespace nana
|
||||
void load_utf8(const std::string& file);
|
||||
|
||||
template<typename ...Args>
|
||||
nana::string get(std::string msgid_utf8, Args&&... args) const
|
||||
::std::string get(std::string msgid_utf8, Args&&... args) const
|
||||
{
|
||||
std::vector<nana::string> arg_strs;
|
||||
std::vector<std::string> arg_strs;
|
||||
_m_fetch_args(arg_strs, std::forward<Args>(args)...);
|
||||
|
||||
nana::string msgstr;
|
||||
::std::string msgstr;
|
||||
if (_m_get(msgid_utf8, msgstr))
|
||||
_m_replace_args(msgstr, &arg_strs);
|
||||
return msgstr;
|
||||
}
|
||||
|
||||
nana::string get(std::string msgid_utf8) const;
|
||||
void set(std::string msgid_utf8, nana::string msgstr);
|
||||
::std::string get(std::string msgid_utf8) const;
|
||||
void set(std::string msgid_utf8, ::std::string msgstr);
|
||||
|
||||
template<typename ...Args>
|
||||
nana::string operator()(std::string msgid_utf8, Args&&... args) const
|
||||
::std::string operator()(std::string msgid_utf8, Args&&... args) const
|
||||
{
|
||||
return get(msgid_utf8, std::forward<Args>(args)...);
|
||||
}
|
||||
private:
|
||||
bool _m_get(std::string& msgid, nana::string& msgstr) const;
|
||||
void _m_replace_args(nana::string& str, std::vector<nana::string> * arg_strs) const;
|
||||
bool _m_get(std::string& msgid, ::std::string& msgstr) const;
|
||||
void _m_replace_args(::std::string& str, std::vector<::std::string> * arg_strs) const;
|
||||
|
||||
void _m_fetch_args(std::vector<nana::string>&) const //Termination of _m_fetch_args
|
||||
void _m_fetch_args(std::vector<std::string>&) const //Termination of _m_fetch_args
|
||||
{}
|
||||
|
||||
template<typename Arg>
|
||||
void _m_fetch_args(std::vector<nana::string>& v, Arg&& arg) const
|
||||
void _m_fetch_args(std::vector<std::string>& v, Arg&& arg) const
|
||||
{
|
||||
std::wstringstream ss;
|
||||
ss << arg;
|
||||
@ -63,52 +63,39 @@ namespace nana
|
||||
}
|
||||
|
||||
template<typename ...Args>
|
||||
void _m_fetch_args(std::vector<nana::string>& v, const char* arg, Args&&... args) const
|
||||
void _m_fetch_args(std::vector<std::string>& v, const char* arg, Args&&... args) const
|
||||
{
|
||||
std::wstringstream ss;
|
||||
ss << nana::string(nana::charset(arg));
|
||||
v.emplace_back(ss.str());
|
||||
|
||||
v.emplace_back(arg);
|
||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename ...Args>
|
||||
void _m_fetch_args(std::vector<nana::string>& v, const std::string& arg, Args&&... args) const
|
||||
void _m_fetch_args(std::vector<std::string>& v, const std::string& arg, Args&&... args) const
|
||||
{
|
||||
std::wstringstream ss;
|
||||
ss << nana::string(nana::charset(arg));
|
||||
v.emplace_back(ss.str());
|
||||
|
||||
v.emplace_back(arg);
|
||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename ...Args>
|
||||
void _m_fetch_args(std::vector<nana::string>& v, std::string& arg, Args&&... args) const
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::string& arg, Args&&... args) const
|
||||
{
|
||||
std::wstringstream ss;
|
||||
ss << nana::string(nana::charset(arg));
|
||||
v.emplace_back(ss.str());
|
||||
|
||||
v.emplace_back(arg);
|
||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename ...Args>
|
||||
void _m_fetch_args(std::vector<nana::string>& v, std::string&& arg, Args&&... args) const
|
||||
void _m_fetch_args(std::vector<std::string>& v, std::string&& arg, Args&&... args) const
|
||||
{
|
||||
std::wstringstream ss;
|
||||
ss << nana::string(nana::charset(arg));
|
||||
v.emplace_back(ss.str());
|
||||
|
||||
v.emplace_back(std::move(arg));
|
||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename Arg, typename ...Args>
|
||||
void _m_fetch_args(std::vector<nana::string>& v, Arg&& arg, Args&&... args) const
|
||||
void _m_fetch_args(std::vector<std::string>& v, Arg&& arg, Args&&... args) const
|
||||
{
|
||||
std::wstringstream ss;
|
||||
std::stringstream ss;
|
||||
ss << arg;
|
||||
v.emplace_back(ss.str());
|
||||
|
||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||
}
|
||||
};//end class internationalization
|
||||
@ -119,7 +106,7 @@ namespace nana
|
||||
{
|
||||
public:
|
||||
virtual ~eval_arg() = default;
|
||||
virtual nana::string eval() const = 0;
|
||||
virtual std::string eval() const = 0;
|
||||
virtual std::unique_ptr<eval_arg> clone() const = 0;
|
||||
};
|
||||
|
||||
@ -134,7 +121,7 @@ namespace nana
|
||||
: fn_(fn)
|
||||
{}
|
||||
|
||||
nana::string eval() const override
|
||||
std::string eval() const override
|
||||
{
|
||||
std::wstringstream ss;
|
||||
ss << fn_();
|
||||
@ -166,7 +153,7 @@ namespace nana
|
||||
i18n_eval& operator=(const i18n_eval&);
|
||||
i18n_eval& operator=(i18n_eval&& rhs);
|
||||
|
||||
nana::string operator()() const;
|
||||
std::string operator()() const;
|
||||
private:
|
||||
void _m_fetch_args(){} //Termination of _m_fetch_args
|
||||
|
||||
@ -180,7 +167,7 @@ namespace nana
|
||||
template<typename Arg>
|
||||
void _m_add_args(Arg&& arg)
|
||||
{
|
||||
std::wstringstream ss;
|
||||
std::stringstream ss;
|
||||
ss << arg;
|
||||
_m_add_args(ss.str());
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ namespace nana{ namespace paint{
|
||||
public:
|
||||
typedef nana::paint::graphics& graph_reference;
|
||||
virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp
|
||||
virtual bool open(const nana::char_t* filename) = 0;
|
||||
virtual bool open(const nana::experimental::filesystem::path& file) = 0;
|
||||
virtual bool open(const void* data, std::size_t bytes) = 0; // reads image from memory
|
||||
virtual bool alpha_channel() const = 0;
|
||||
virtual bool empty() const = 0;
|
||||
|
||||
@ -32,9 +32,9 @@ namespace detail
|
||||
|
||||
void blend(drawable_type dw, const nana::rectangle& r, pixel_color_t, double fade_rate);
|
||||
|
||||
nana::size raw_text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
|
||||
nana::size text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
|
||||
void draw_string(drawable_type, const nana::point&, const nana::char_t *, std::size_t len);
|
||||
nana::size raw_text_extent_size(drawable_type, const wchar_t*, std::size_t len);
|
||||
nana::size text_extent_size(drawable_type, const wchar_t*, std::size_t len);
|
||||
void draw_string(drawable_type, const nana::point&, const wchar_t *, std::size_t len);
|
||||
}//end namespace detail
|
||||
}//end namespace paint
|
||||
}//end namespace nana
|
||||
|
||||
@ -36,14 +36,14 @@ namespace nana
|
||||
font();
|
||||
font(drawable_type);
|
||||
font(const font&);
|
||||
font(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
|
||||
font(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
|
||||
~font();
|
||||
bool empty() const;
|
||||
void make(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
|
||||
void make_raw(const char_t*, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
|
||||
void make(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
|
||||
void make_raw(const ::std::string& name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
|
||||
|
||||
void set_default() const;
|
||||
::nana::string name() const;
|
||||
::std::string name() const;
|
||||
unsigned size() const;
|
||||
bool bold() const;
|
||||
unsigned height() const;
|
||||
@ -89,13 +89,15 @@ namespace nana
|
||||
void resize(const ::nana::size&);
|
||||
void typeface(const font&); ///< Selects a specified font type into the graphics object.
|
||||
font typeface() const;
|
||||
::nana::size text_extent_size(const char_t*) const; ///< Computes the width and height of the specified string of text.
|
||||
::nana::size text_extent_size(const string&) const; ///< Computes the width and height of the specified string of text.
|
||||
::nana::size text_extent_size(const char_t*, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
|
||||
::nana::size text_extent_size(const string&, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
|
||||
::nana::size glyph_extent_size(const char_t*, std::size_t length, std::size_t begin, std::size_t end) const;
|
||||
::nana::size glyph_extent_size(const string&, std::size_t length, std::size_t begin, std::size_t end) const;
|
||||
bool glyph_pixels(const char_t *, std::size_t length, unsigned* pxbuf) const;
|
||||
::nana::size text_extent_size(const ::std::string&) const;
|
||||
::nana::size text_extent_size(const char*, std::size_t len) const;
|
||||
::nana::size text_extent_size(const wchar_t*) const; ///< Computes the width and height of the specified string of text.
|
||||
::nana::size text_extent_size(const ::std::wstring&) const; ///< Computes the width and height of the specified string of text.
|
||||
::nana::size text_extent_size(const wchar_t*, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
|
||||
::nana::size text_extent_size(const ::std::wstring&, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
|
||||
::nana::size glyph_extent_size(const wchar_t*, std::size_t length, std::size_t begin, std::size_t end) const;
|
||||
::nana::size glyph_extent_size(const ::std::wstring&, std::size_t length, std::size_t begin, std::size_t end) const;
|
||||
bool glyph_pixels(const wchar_t *, std::size_t length, unsigned* pxbuf) const;
|
||||
::nana::size bidi_extent_size(const std::wstring&) const;
|
||||
::nana::size bidi_extent_size(const std::string&) const;
|
||||
|
||||
@ -136,13 +138,10 @@ namespace nana
|
||||
/// @param file_utf8 A UTF-8 string to a filename
|
||||
void save_as_file(const char* file_utf8) const throw();
|
||||
|
||||
void set_color(const ::nana::color&); //deprecated, graphics::palette() instead
|
||||
void set_text_color(const ::nana::color&); //deprecated, graphics::palette() instead
|
||||
|
||||
::nana::color palette(bool for_text) const;
|
||||
graphics& palette(bool for_text, const ::nana::color&);
|
||||
|
||||
unsigned bidi_string(const nana::point&, const char_t *, std::size_t len);
|
||||
unsigned bidi_string(const nana::point&, const wchar_t *, std::size_t len);
|
||||
unsigned bidi_string(const point& pos, const char*, std::size_t len);
|
||||
|
||||
void blend(const ::nana::rectangle& r, const ::nana::color&, double fade_rate);
|
||||
@ -150,10 +149,13 @@ namespace nana
|
||||
void set_pixel(int x, int y, const ::nana::color&);
|
||||
void set_pixel(int x, int y);
|
||||
|
||||
void string(point, const char_t*, std::size_t len);
|
||||
void string(const point&, const char_t*);
|
||||
void string(const point&, const ::nana::string&);
|
||||
void string(const point&, const ::nana::string&, const color&);
|
||||
void string(const point&, const std::string& text_utf8);
|
||||
void string(const point&, const std::string& text_utf8, const color&);
|
||||
|
||||
void string(point, const wchar_t*, std::size_t len);
|
||||
void string(const point&, const wchar_t*);
|
||||
void string(const point&, const ::std::wstring&);
|
||||
void string(const point&, const ::std::wstring&, const color&);
|
||||
|
||||
void line(const point&, const point&);
|
||||
void line(const point&, const point&, const color&);
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#define NANA_PAINT_IMAGE_HPP
|
||||
|
||||
#include "graphics.hpp"
|
||||
#include "../filesystem/filesystem.hpp"
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@ -31,12 +32,18 @@ namespace paint
|
||||
image();
|
||||
image(const image&);
|
||||
image(image&&);
|
||||
image(const nana::char_t* file);
|
||||
image(const nana::string& filename);
|
||||
image(const ::nana::experimental::filesystem::path& file);
|
||||
|
||||
template<typename Source>
|
||||
image(const Source& source)
|
||||
{
|
||||
open(source);
|
||||
}
|
||||
|
||||
~image();
|
||||
image& operator=(const image& rhs);
|
||||
image& operator=(image&&);
|
||||
bool open(const nana::string& filename);
|
||||
bool open(const ::nana::experimental::filesystem::path& file);
|
||||
|
||||
/// Opens an icon from a specified buffer
|
||||
bool open_icon(const void* data, std::size_t bytes);
|
||||
|
||||
@ -13,11 +13,11 @@ namespace nana
|
||||
|
||||
text_renderer(graph_reference graph, align = align::left);
|
||||
|
||||
nana::size extent_size(int x, int y, const nana::char_t*, std::size_t len, unsigned restricted_pixels) const;
|
||||
nana::size extent_size(int x, int y, const wchar_t*, std::size_t len, unsigned restricted_pixels) const;
|
||||
|
||||
void render(const point&, const char_t*, std::size_t len);
|
||||
void render(const point&, const char_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
|
||||
void render(const point&, const char_t*, std::size_t len, unsigned restricted_pixels);
|
||||
void render(const point&, const wchar_t*, std::size_t len);
|
||||
void render(const point&, const wchar_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
|
||||
void render(const point&, const wchar_t*, std::size_t len, unsigned restricted_pixels);
|
||||
private:
|
||||
graph_reference graph_;
|
||||
align text_align_;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Data Exchanger Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -21,22 +21,26 @@ namespace paint{
|
||||
}
|
||||
|
||||
namespace system{
|
||||
/// a data exchange mechanism through Windows Clipboard, X11 Selection.
|
||||
|
||||
/// a data exchange mechanism through Windows Clipboard, X11 Selection.
|
||||
class dataexch
|
||||
{
|
||||
public:
|
||||
struct format
|
||||
enum class format
|
||||
{
|
||||
enum{ text, unicode, pixmap, end};
|
||||
text, pixmap
|
||||
};
|
||||
|
||||
void set(const nana::char_t* text);
|
||||
void set(const nana::string& text);
|
||||
void set(const std::string & text_utf8);
|
||||
void set(const std::wstring& text);
|
||||
|
||||
bool set(const nana::paint::graphics& g);
|
||||
void get(nana::string& str);
|
||||
|
||||
void get(std::string& text_utf8);
|
||||
void get(std::wstring& text);
|
||||
private:
|
||||
bool _m_set(unsigned type, const void* buf, std::size_t size);
|
||||
void* _m_get(unsigned type, size_t& size);
|
||||
bool _m_set(format, const void* buf, std::size_t size);
|
||||
void* _m_get(format, size_t& size);
|
||||
};
|
||||
|
||||
}//end namespace system
|
||||
|
||||
@ -38,7 +38,7 @@ namespace system
|
||||
bool get_async_mouse_state(int button);
|
||||
|
||||
//open an url through a default browser
|
||||
void open_url(const nana::string& url);
|
||||
void open_url(const std::string& url);
|
||||
|
||||
}//end namespace system
|
||||
}//end namespace nana
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Traits Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* @file: nana/traits.hpp
|
||||
*/
|
||||
@ -13,502 +13,24 @@ namespace nana
|
||||
{
|
||||
class null_type{};
|
||||
|
||||
//The class noncopyable and nonmovable will be deprecated while the compiler
|
||||
//supports the deleted functions
|
||||
struct noncopyable
|
||||
/// Prevent a class to be copyable
|
||||
class noncopyable
|
||||
{
|
||||
noncopyable(const noncopyable&) = delete;
|
||||
noncopyable& operator=(const noncopyable&) = delete;
|
||||
noncopyable();
|
||||
protected:
|
||||
noncopyable() = default;
|
||||
};
|
||||
|
||||
struct nonmovable
|
||||
/// Prevent a class to be movable
|
||||
class nonmovable
|
||||
{
|
||||
nonmovable(nonmovable&&) = delete;
|
||||
nonmovable& operator=(nonmovable&&) = delete;
|
||||
nonmovable();
|
||||
protected:
|
||||
nonmovable() = default;
|
||||
};
|
||||
|
||||
namespace traits
|
||||
{
|
||||
//traits types for const-volatile specifier
|
||||
|
||||
struct no_specifier{};
|
||||
struct const_specifier{};
|
||||
struct volatile_specifier{};
|
||||
struct const_volatile_specifier{};
|
||||
|
||||
template<typename T>
|
||||
struct cv_specifier
|
||||
{
|
||||
typedef no_specifier value_type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct cv_specifier<const T>
|
||||
{
|
||||
typedef const_specifier value_type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct cv_specifier<volatile T>
|
||||
{
|
||||
typedef volatile_specifier value_type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct cv_specifier<const volatile T>
|
||||
{
|
||||
typedef const_volatile_specifier value_type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct is_function_pointer
|
||||
: public std::integral_constant<bool, std::is_pointer<T>::value && std::is_function<typename std::remove_pointer<T>::type>::value>
|
||||
{};
|
||||
|
||||
//The traits of pointer to member function
|
||||
template<typename MF>
|
||||
struct mfptr_traits
|
||||
{
|
||||
typedef void function();
|
||||
typedef void return_type;
|
||||
typedef void concept_type;
|
||||
enum{parameter = 0};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept>
|
||||
struct mfptr_traits<R(Concept::*)()>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef return_type function();
|
||||
enum{parameter = 0};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept>
|
||||
struct mfptr_traits<R(Concept::*)() const>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef return_type function();
|
||||
enum{parameter = 0};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept>
|
||||
struct mfptr_traits<R(Concept::*)() volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef return_type function();
|
||||
enum{parameter = 0};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept>
|
||||
struct mfptr_traits<R(Concept::*)() const volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef return_type function();
|
||||
enum{parameter = 0};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P>
|
||||
struct mfptr_traits<R(Concept::*)(P)>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P param0_type;
|
||||
typedef return_type function(param0_type);
|
||||
enum{parameter = 1};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P>
|
||||
struct mfptr_traits<R(Concept::*)(P) const>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P param0_type;
|
||||
typedef return_type function(param0_type);
|
||||
enum{parameter = 1};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P>
|
||||
struct mfptr_traits<R(Concept::*)(P) const volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P param0_type;
|
||||
typedef return_type function(param0_type);
|
||||
enum{parameter = 1};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1)>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef return_type function(param0_type, param1_type);
|
||||
enum{parameter = 2};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1) const>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef return_type function(param0_type, param1_type);
|
||||
enum{parameter = 2};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1) const volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef return_type function(param0_type, param1_type);
|
||||
enum{parameter = 2};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2)>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type);
|
||||
enum{parameter =3};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2) const>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type);
|
||||
enum{parameter =3};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2) volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type);
|
||||
enum{parameter =3};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2) const volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type);
|
||||
enum{parameter =3};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3)>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef P3 param3_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type);
|
||||
enum{parameter = 4};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3) const>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef P3 param3_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type);
|
||||
enum{parameter = 4};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3) volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef P3 param3_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type);
|
||||
enum{parameter = 4};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3) const volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef P3 param3_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type);
|
||||
enum{parameter = 4};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3, typename P4>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3, P4)>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef P3 param3_type;
|
||||
typedef P4 param4_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
|
||||
enum{parameter = 5};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3, typename P4>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3, P4) const>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef P3 param3_type;
|
||||
typedef P4 param4_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
|
||||
enum{parameter = 5};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3, typename P4>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3, P4) volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef P3 param3_type;
|
||||
typedef P4 param4_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
|
||||
enum{parameter = 5};
|
||||
};
|
||||
|
||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3, typename P4>
|
||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3, P4) const volatile>
|
||||
{
|
||||
typedef Concept concept_type;
|
||||
typedef R return_type;
|
||||
typedef P0 param0_type;
|
||||
typedef P1 param1_type;
|
||||
typedef P2 param2_type;
|
||||
typedef P3 param3_type;
|
||||
typedef P4 param4_type;
|
||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
|
||||
enum{parameter = 5};
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename Function, typename Concept, typename CVSpecifier>
|
||||
struct make_mf
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template<typename R, typename Concept>
|
||||
struct make_mf<R(), Concept, no_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)();
|
||||
};
|
||||
|
||||
template<typename R, typename Concept>
|
||||
struct make_mf<R(), Concept, const_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)() const;
|
||||
};
|
||||
|
||||
template<typename R, typename Concept>
|
||||
struct make_mf<R(), Concept, volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)() volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename Concept>
|
||||
struct make_mf<R(), Concept, const_volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)() const volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename Concept>
|
||||
struct make_mf<R(P0), Concept, no_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0);
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename Concept>
|
||||
struct make_mf<R(P0), Concept, const_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0) const;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename Concept>
|
||||
struct make_mf<R(P0), Concept, volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0) volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename Concept>
|
||||
struct make_mf<R(P0), Concept, const_volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0) const volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename Concept>
|
||||
struct make_mf<R(P0, P1), Concept, no_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1);
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename Concept>
|
||||
struct make_mf<R(P0, P1), Concept, const_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1) const;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename Concept>
|
||||
struct make_mf<R(P0, P1), Concept, volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1) volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename Concept>
|
||||
struct make_mf<R(P0, P1), Concept, const_volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1) const volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2), Concept, no_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2);
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2), Concept, const_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2) const;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2), Concept, volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2) volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2), Concept, const_volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2) const volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3), Concept, no_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3);
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3), Concept, const_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3) const;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3), Concept, volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3) volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3), Concept, const_volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3) const volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3, P4), Concept, no_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4);
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3, P4), Concept, const_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4) const;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3, P4), Concept, volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4) volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3, P4), Concept, const_volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4) const volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3, P4, P5), Concept, no_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4, P5);
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3, P4, P5), Concept, const_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4, P5) const;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3, P4, P5), Concept, volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4, P5) volatile;
|
||||
};
|
||||
|
||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename Concept>
|
||||
struct make_mf<R(P0, P1, P2, P3, P4, P5), Concept, const_volatile_specifier>
|
||||
{
|
||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4, P5) const volatile;
|
||||
};
|
||||
}//end namespace traits
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template< typename Param0 = null_type, typename Param1 = null_type,
|
||||
|
||||
@ -6,9 +6,9 @@ namespace nana{ namespace audio
|
||||
namespace detail
|
||||
{
|
||||
//class audio_stream
|
||||
bool audio_stream::open(const nana::string& file)
|
||||
bool audio_stream::open(const std::string& file)
|
||||
{
|
||||
fs_.open(static_cast<std::string>(charset(file)), std::ios::binary);
|
||||
fs_.open(to_osmbstr(file), std::ios::binary);
|
||||
if(fs_)
|
||||
{
|
||||
wave_spec::master_riff_chunk riff;
|
||||
|
||||
@ -17,7 +17,7 @@ namespace nana{ namespace audio
|
||||
: impl_(new implementation)
|
||||
{}
|
||||
|
||||
player::player(const nana::string& file)
|
||||
player::player(const std::string& file)
|
||||
: impl_(new implementation)
|
||||
{
|
||||
open(file);
|
||||
@ -28,7 +28,7 @@ namespace nana{ namespace audio
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
bool player::open(const nana::string& file)
|
||||
bool player::open(const std::string& file)
|
||||
{
|
||||
if(impl_->stream.open(file))
|
||||
{
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <nana/deploy.hpp>
|
||||
#include <cwchar>
|
||||
#include <clocale>
|
||||
#include <cstring>
|
||||
|
||||
//GCC 4.7.0 does not implement the <codecvt> and codecvt_utfx classes
|
||||
#ifndef STD_CODECVT_NOT_SUPPORTED
|
||||
@ -30,6 +31,183 @@
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace utf
|
||||
{
|
||||
const char* char_ptr(const char* text, unsigned pos)
|
||||
{
|
||||
auto ustr = reinterpret_cast<const unsigned char*>(text);
|
||||
auto const end = ustr + std::strlen(text);
|
||||
|
||||
for (unsigned i = 0; i != pos; ++i)
|
||||
{
|
||||
const auto uch = *ustr;
|
||||
if (uch < 0x80)
|
||||
{
|
||||
++ustr;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (uch < 0xC0)
|
||||
return nullptr;
|
||||
|
||||
if ((uch < 0xE0) && (ustr + 1 < end))
|
||||
ustr += 2;
|
||||
else if (uch < 0xF0 && (ustr + 2 <= end))
|
||||
ustr += 3;
|
||||
else if (uch < 0x1F && (ustr + 3 <= end))
|
||||
ustr += 4;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return reinterpret_cast<const char*>(ustr);
|
||||
}
|
||||
|
||||
const char* char_ptr(const std::string& text_utf8, unsigned pos)
|
||||
{
|
||||
auto ustr = reinterpret_cast<const unsigned char*>(text_utf8.c_str());
|
||||
auto const end = ustr + text_utf8.size();
|
||||
|
||||
for (unsigned i = 0; i != pos; ++i)
|
||||
{
|
||||
const auto uch = *ustr;
|
||||
if (uch < 0x80)
|
||||
{
|
||||
++ustr;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (uch < 0xC0)
|
||||
return nullptr;
|
||||
|
||||
if ((uch < 0xE0) && (ustr + 1 < end))
|
||||
ustr += 2;
|
||||
else if (uch < 0xF0 && (ustr + 2 <= end))
|
||||
ustr += 3;
|
||||
else if (uch < 0x1F && (ustr + 3 <= end))
|
||||
ustr += 4;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return reinterpret_cast<const char*>(ustr);
|
||||
}
|
||||
|
||||
wchar_t char_at(const char* text_utf8, unsigned pos, unsigned * len)
|
||||
{
|
||||
if (!text_utf8)
|
||||
return 0;
|
||||
|
||||
if (pos)
|
||||
{
|
||||
text_utf8 = char_ptr(text_utf8, pos);
|
||||
if (!text_utf8)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const wchar_t uch = *reinterpret_cast<const unsigned char*>(text_utf8);
|
||||
if (uch < 0x80)
|
||||
{
|
||||
if (len)
|
||||
*len = 1;
|
||||
|
||||
return *text_utf8;
|
||||
}
|
||||
|
||||
if (uch < 0xC0)
|
||||
{
|
||||
if (len)
|
||||
*len = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto end = text_utf8 + std::strlen(text_utf8);
|
||||
|
||||
if (uch < 0xE0 && (text_utf8 + 1 <= end))
|
||||
{
|
||||
if (len)
|
||||
*len = 2;
|
||||
return (wchar_t(uch & 0x1F) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[1] & 0x3F);
|
||||
}
|
||||
else if (uch < 0xF0 && (text_utf8 + 2 <= end))
|
||||
{
|
||||
if (len)
|
||||
*len = 3;
|
||||
|
||||
return ((((uch & 0xF) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[1] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[2] & 0x3F);
|
||||
}
|
||||
else if (uch < 0x1F && (text_utf8 + 3 <= end))
|
||||
{
|
||||
if (len)
|
||||
*len = 4;
|
||||
return ((((((uch & 0x7) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[1] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[2] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[3] & 0x3F);
|
||||
}
|
||||
|
||||
if (len)
|
||||
*len = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
wchar_t char_at(const ::std::string& text_utf8, unsigned pos, unsigned * len)
|
||||
{
|
||||
const char* ptr;
|
||||
if (pos)
|
||||
{
|
||||
ptr = char_ptr(text_utf8, pos);
|
||||
if (!ptr)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
ptr = text_utf8.c_str();
|
||||
|
||||
const wchar_t uch = *reinterpret_cast<const unsigned char*>(ptr);
|
||||
if (uch < 0x80)
|
||||
{
|
||||
if (len)
|
||||
*len = 1;
|
||||
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
if (uch < 0xC0)
|
||||
{
|
||||
if (len)
|
||||
*len = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto end = text_utf8.c_str() + text_utf8.size();
|
||||
|
||||
if (uch < 0xE0 && (ptr + 1 <= end))
|
||||
{
|
||||
if (len)
|
||||
*len = 2;
|
||||
return (wchar_t(uch & 0x1F) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[1] & 0x3F);
|
||||
}
|
||||
else if (uch < 0xF0 && (ptr + 2 <= end))
|
||||
{
|
||||
if (len)
|
||||
*len = 3;
|
||||
|
||||
return ((((uch & 0xF) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[1] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[2] & 0x3F);
|
||||
}
|
||||
else if (uch < 0x1F && (ptr + 3 <= end))
|
||||
{
|
||||
if (len)
|
||||
*len = 4;
|
||||
return ((((((uch & 0x7) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[1] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[2] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[3] & 0x3F);
|
||||
}
|
||||
|
||||
if (len)
|
||||
*len = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
class locale_initializer
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
#include <nana/deploy.hpp>
|
||||
#include <cstdlib>
|
||||
#include <cstring> //std::strlen
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
@ -437,46 +438,174 @@ namespace std
|
||||
|
||||
namespace nana
|
||||
{
|
||||
std::size_t strlen(const char_t* str)
|
||||
bool is_utf8(const char* str, unsigned len)
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
return ::wcslen(str);
|
||||
#else
|
||||
return ::strlen(str);
|
||||
#endif
|
||||
}
|
||||
auto ustr = reinterpret_cast<const unsigned char*>(str);
|
||||
auto end = ustr + len;
|
||||
|
||||
char_t* strcpy(char_t* dest, const char_t* source)
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
return ::wcscpy(dest, source);
|
||||
#else
|
||||
return ::strcpy(dest, source);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
namespace nana
|
||||
{
|
||||
bool is_incomplete(const nana::string& str, unsigned pos)
|
||||
{
|
||||
#ifndef NANA_UNICODE
|
||||
if(pos > str.size())
|
||||
pos = static_cast<unsigned>(str.size());
|
||||
const nana::char_t * pstr = str.c_str();
|
||||
if(pstr[pos] < 0)
|
||||
while (ustr < end)
|
||||
{
|
||||
bool incomp = false;
|
||||
for(unsigned i = 0; i < pos; ++i)
|
||||
const auto uv = *ustr;
|
||||
if (uv < 0x80)
|
||||
{
|
||||
if(pstr[i] < 0)
|
||||
incomp = !incomp;
|
||||
else
|
||||
incomp = false;
|
||||
++ustr;
|
||||
continue;
|
||||
}
|
||||
return incomp;
|
||||
|
||||
if (uv < 0xC0)
|
||||
return false;
|
||||
|
||||
if ((uv < 0xE0) && (ustr + 1 < end))
|
||||
ustr += 2;
|
||||
else if (uv < 0xF0 && (ustr + 2 <= end))
|
||||
ustr += 3;
|
||||
else if (uv < 0x1F && (ustr + 3 <= end))
|
||||
ustr += 4;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void throw_not_utf8(const std::string& text)
|
||||
{
|
||||
if (!is_utf8(text.c_str(), text.length()))
|
||||
throw std::invalid_argument("The text is not encoded in UTF8");
|
||||
}
|
||||
|
||||
void throw_not_utf8(const char* text, unsigned len)
|
||||
{
|
||||
if (!is_utf8(text, len))
|
||||
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);
|
||||
}
|
||||
|
||||
std::string utf8_cast(const std::wstring& text)
|
||||
{
|
||||
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
const std::string& to_utf8(const std::string& str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string to_utf8(const std::wstring& text)
|
||||
{
|
||||
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
std::wstring to_wstring(const std::string& utf8_str)
|
||||
{
|
||||
return ::nana::charset(utf8_str, ::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
const std::wstring& to_wstring(const std::wstring& wstr)
|
||||
{
|
||||
return wstr;
|
||||
}
|
||||
|
||||
std::wstring&& to_wstring(std::wstring&& wstr)
|
||||
{
|
||||
return static_cast<std::wstring&&>(wstr);
|
||||
}
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
std::string to_osmbstr(const std::string& text_utf8)
|
||||
{
|
||||
return ::nana::charset(text_utf8, ::nana::unicode::utf8);
|
||||
}
|
||||
#else
|
||||
std::string to_osmbstr(std::string text_utf8)
|
||||
{
|
||||
return text_utf8;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
const detail::native_string_type to_nstring(const std::string& text)
|
||||
{
|
||||
return ::nana::charset(text, ::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
const detail::native_string_type& to_nstring(const std::wstring& text)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
detail::native_string_type to_nstring(std::string&& text)
|
||||
{
|
||||
return ::nana::charset(text, ::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
detail::native_string_type&& to_nstring(std::wstring&& text)
|
||||
{
|
||||
return std::move(text);
|
||||
}
|
||||
|
||||
detail::native_string_type to_nstring(int n)
|
||||
{
|
||||
return std::to_wstring(n);
|
||||
}
|
||||
|
||||
detail::native_string_type to_nstring(double d)
|
||||
{
|
||||
return std::to_wstring(d);
|
||||
}
|
||||
|
||||
detail::native_string_type to_nstring(std::size_t d)
|
||||
{
|
||||
return std::to_wstring(d);
|
||||
}
|
||||
#else //POSIX
|
||||
const detail::native_string_type& to_nstring(const std::string& text)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
const detail::native_string_type to_nstring(const std::wstring& text)
|
||||
{
|
||||
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
detail::native_string_type&& to_nstring(std::string&& text)
|
||||
{
|
||||
return std::move(text);
|
||||
}
|
||||
|
||||
detail::native_string_type to_nstring(std::wstring&& text)
|
||||
{
|
||||
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||
}
|
||||
|
||||
detail::native_string_type to_nstring(int n)
|
||||
{
|
||||
return std::to_string(n);
|
||||
}
|
||||
|
||||
detail::native_string_type to_nstring(double d)
|
||||
{
|
||||
return std::to_string(d);
|
||||
}
|
||||
|
||||
detail::native_string_type to_nstring(std::size_t d)
|
||||
{
|
||||
return std::to_string(d);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -515,7 +515,7 @@ namespace detail
|
||||
atombase_.xdnd_finished = ::XInternAtom(display_, "XdndFinished", False);
|
||||
|
||||
//Create default font object.
|
||||
def_font_ptr_ = make_native_font(0, font_size_to_height(10), 400, false, false, false);
|
||||
def_font_ptr_ = make_native_font(nullptr, font_size_to_height(10), 400, false, false, false);
|
||||
msg_dispatcher_ = new msg_dispatcher(display_);
|
||||
}
|
||||
|
||||
@ -550,17 +550,16 @@ namespace detail
|
||||
return height;
|
||||
}
|
||||
|
||||
platform_spec::font_ptr_t platform_spec::make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
platform_spec::font_ptr_t platform_spec::make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
{
|
||||
font_ptr_t ref;
|
||||
#if defined(NANA_UNICODE)
|
||||
#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);
|
||||
|
||||
@ -158,7 +158,7 @@ namespace detail
|
||||
|
||||
//class platform_spec
|
||||
platform_spec::co_initializer::co_initializer()
|
||||
: ole32_(::LoadLibrary(STR("OLE32.DLL")))
|
||||
: ole32_(::LoadLibrary(L"OLE32.DLL"))
|
||||
{
|
||||
if(ole32_)
|
||||
{
|
||||
@ -207,7 +207,7 @@ namespace detail
|
||||
#endif
|
||||
#endif
|
||||
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof metrics, &metrics, 0);
|
||||
def_font_ptr_ = make_native_font(metrics.lfMessageFont.lfFaceName, font_size_to_height(9), 400, false, false, false);
|
||||
def_font_ptr_ = make_native_font(utf8_cast(metrics.lfMessageFont.lfFaceName).c_str(), font_size_to_height(9), 400, false, false, false);
|
||||
}
|
||||
|
||||
const platform_spec::font_ptr_t& platform_spec::default_native_font() const
|
||||
@ -238,12 +238,15 @@ namespace detail
|
||||
return height;
|
||||
}
|
||||
|
||||
platform_spec::font_ptr_t platform_spec::make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
platform_spec::font_ptr_t platform_spec::make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
{
|
||||
::LOGFONT logfont;
|
||||
memset(&logfont, 0, sizeof logfont);
|
||||
|
||||
strcpy(logfont.lfFaceName, (name && *name ? name : def_font_ptr_->name.c_str()));
|
||||
if (name && *name)
|
||||
std::wcscpy(logfont.lfFaceName, utf8_cast(name).c_str());
|
||||
else
|
||||
std::wcscpy(logfont.lfFaceName, def_font_ptr_->name.c_str());
|
||||
|
||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||
HDC hdc = ::GetDC(0);
|
||||
|
||||
@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* A ISO C++ FileSystem Implementation
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -36,134 +36,220 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
namespace nana {
|
||||
namespace experimental
|
||||
namespace nana { namespace experimental {
|
||||
namespace filesystem
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
//Because of No wide character version of POSIX
|
||||
//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)
|
||||
//class file_status
|
||||
file_status::file_status(file_type ft, perms prms)
|
||||
: value_{ft}, perms_{prms}
|
||||
{}
|
||||
|
||||
file_type file_status::type() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
void file_status::type(file_type ft)
|
||||
{
|
||||
value_ = ft;
|
||||
}
|
||||
|
||||
perms file_status::permissions() const
|
||||
{
|
||||
return perms_;
|
||||
}
|
||||
|
||||
void file_status::permissions(perms prms)
|
||||
{
|
||||
perms_ = prms;
|
||||
}
|
||||
//end filestatus
|
||||
|
||||
//class path
|
||||
path::path() {}
|
||||
|
||||
int path::compare(const path& p) const
|
||||
{
|
||||
return pathstr_.compare(p.pathstr_);
|
||||
}
|
||||
|
||||
bool path::empty() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
: text_(text)
|
||||
{
|
||||
return (::GetFileAttributes(pathstr_.c_str()) == INVALID_FILE_ATTRIBUTES);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat sta;
|
||||
return (::stat(pathstr_.c_str(), &sta) == -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
path path::extension() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
auto pos = pathstr_.find_last_of(L"\\/.");
|
||||
#else
|
||||
:text_(nana::charset(text))
|
||||
{
|
||||
auto pos = pathstr_.find_last_of("\\/.");
|
||||
#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);
|
||||
}
|
||||
if ((pos == pathstr_.npos) || (pathstr_[pos] != '.'))
|
||||
return path();
|
||||
|
||||
bool path::empty() const
|
||||
{
|
||||
|
||||
if (pos + 1 == pathstr_.size())
|
||||
return path();
|
||||
|
||||
return path(pathstr_.substr(pos));
|
||||
}
|
||||
|
||||
path path::parent_path() const
|
||||
{
|
||||
return{filesystem::parent_path(pathstr_)};
|
||||
}
|
||||
|
||||
file_type path::what() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
return (::GetFileAttributes(text_.c_str()) == INVALID_FILE_ATTRIBUTES);
|
||||
unsigned long attr = ::GetFileAttributes(pathstr_.c_str());
|
||||
if (INVALID_FILE_ATTRIBUTES == attr)
|
||||
return file_type::not_found; //??
|
||||
|
||||
if (FILE_ATTRIBUTE_DIRECTORY & attr)
|
||||
return file_type::directory;
|
||||
|
||||
return file_type::regular;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat sta;
|
||||
return (::stat(text_.c_str(), &sta) == -1);
|
||||
#endif
|
||||
}
|
||||
struct stat sta;
|
||||
if (-1 == ::stat(pathstr_.c_str(), &sta))
|
||||
return file_type::not_found; //??
|
||||
|
||||
path path::root() 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
|
||||
}
|
||||
|
||||
file_type path::what() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
unsigned long attr = ::GetFileAttributes(text_.c_str());
|
||||
if (INVALID_FILE_ATTRIBUTES == attr)
|
||||
return file_type::not_found; //??
|
||||
|
||||
if (FILE_ATTRIBUTE_DIRECTORY & attr)
|
||||
return file_type::directory;
|
||||
if ((S_IFDIR & sta.st_mode) == S_IFDIR)
|
||||
return file_type::directory;
|
||||
|
||||
if ((S_IFREG & sta.st_mode) == S_IFREG)
|
||||
return file_type::regular;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat sta;
|
||||
if (-1 == ::stat(text_.c_str(), &sta))
|
||||
return file_type::not_found; //??
|
||||
|
||||
if ((S_IFDIR & sta.st_mode) == S_IFDIR)
|
||||
return file_type::directory;
|
||||
|
||||
if ((S_IFREG & sta.st_mode) == S_IFREG)
|
||||
return file_type::regular;
|
||||
|
||||
return file_type::none;
|
||||
return file_type::none;
|
||||
#endif
|
||||
}
|
||||
|
||||
path path::filename() const
|
||||
{
|
||||
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) };
|
||||
}
|
||||
|
||||
nana::string path::filename() const
|
||||
{
|
||||
string_t::size_type pos = text_.find_last_of(splstr);
|
||||
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();
|
||||
}
|
||||
|
||||
std::string path::string() const
|
||||
{
|
||||
return to_osmbstr(to_utf8(pathstr_));
|
||||
}
|
||||
|
||||
std::wstring path::wstring() const
|
||||
{
|
||||
return to_wstring(pathstr_);
|
||||
}
|
||||
|
||||
std::string path::u8string() const
|
||||
{
|
||||
return to_utf8(pathstr_);
|
||||
}
|
||||
|
||||
void path::_m_assign(const std::string& source_utf8)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
return text_.substr(pos + 1);
|
||||
pathstr_ = utf8_cast(source_utf8);
|
||||
#else
|
||||
return nana::charset(text_.substr(pos + 1));
|
||||
pathstr_ = source_utf8;
|
||||
#endif
|
||||
}
|
||||
//end class path
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
void path::_m_assign(const std::wstring& source)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
pathstr_ = source;
|
||||
#else
|
||||
pathstr_ = utf8_cast(source);
|
||||
#endif
|
||||
}
|
||||
//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);
|
||||
}
|
||||
|
||||
bool mkdir_helper(const nana::string& dir, bool & if_exist)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
if (::CreateDirectory(dir.c_str(), 0))
|
||||
{
|
||||
if_exist = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
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_exist = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if_exist = (errno == EEXIST);
|
||||
#endif
|
||||
return false;
|
||||
return rmdir(dir, true);
|
||||
}
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
@ -188,34 +274,83 @@ namespace nana {
|
||||
#endif
|
||||
}//end namespace detail
|
||||
|
||||
bool file_attrib(const nana::string& file, attribute& attr)
|
||||
{
|
||||
bool not_found_error(int errval)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
if (::GetFileAttributesEx(file.c_str(), GetFileExInfoStandard, &fad))
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
li.u.LowPart = fad.nFileSizeLow;
|
||||
li.u.HighPart = fad.nFileSizeHigh;
|
||||
attr.size = li.QuadPart;
|
||||
attr.directory = (0 != (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
|
||||
detail::filetime_to_c_tm(fad.ftLastWriteTime, attr.modified);
|
||||
return true;
|
||||
}
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat fst;
|
||||
if (0 == ::stat(static_cast<std::string>(nana::charset(file)).c_str(), &fst))
|
||||
{
|
||||
attr.size = fst.st_size;
|
||||
attr.directory = (0 != (040000 & fst.st_mode));
|
||||
attr.modified = *(::localtime(&fst.st_ctime));
|
||||
return true;
|
||||
}
|
||||
switch (errval)
|
||||
{
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
case ERROR_INVALID_NAME:
|
||||
case ERROR_INVALID_DRIVE:
|
||||
case ERROR_NOT_READY:
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
case ERROR_BAD_PATHNAME:
|
||||
case ERROR_BAD_NETPATH:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#elif defined(NANA_POSIX)
|
||||
return (errval == ENOENT || errval == ENOTDIR);
|
||||
#else
|
||||
static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
file_status status(const path& p)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
auto attr = ::GetFileAttributesW(p.c_str());
|
||||
if (INVALID_FILE_ATTRIBUTES == attr)
|
||||
{
|
||||
if (not_found_error(static_cast<int>(::GetLastError())))
|
||||
return file_status{file_type::not_found};
|
||||
return file_status{ file_type::unknown };
|
||||
}
|
||||
return file_status{(FILE_ATTRIBUTE_DIRECTORY & attr) ? file_type::directory : file_type::regular, perms::all};
|
||||
#elif defined(NANA_POSIX)
|
||||
struct stat path_stat;
|
||||
if(0 != ::stat(p.c_str(), &path_stat))
|
||||
{
|
||||
if(errno == ENOENT || errno == ENOTDIR)
|
||||
return file_status{file_type::not_found};
|
||||
|
||||
return file_status{file_type::unknown};
|
||||
}
|
||||
|
||||
uintmax_t file_size(const nana::string& file)
|
||||
auto prms = static_cast<perms>(path_stat.st_mode & static_cast<unsigned>(perms::mask));
|
||||
|
||||
if(S_ISREG(path_stat.st_mode))
|
||||
return file_status{file_type::regular, prms};
|
||||
|
||||
if(S_ISDIR(path_stat.st_mode))
|
||||
return file_status{file_type::directory, prms};
|
||||
|
||||
if(S_ISLNK(path_stat.st_mode))
|
||||
return file_status{file_type::symlink, prms};
|
||||
|
||||
if(S_ISBLK(path_stat.st_mode))
|
||||
return file_status{file_type::block, prms};
|
||||
|
||||
if(S_ISCHR(path_stat.st_mode))
|
||||
return file_status{file_type::character, prms};
|
||||
|
||||
if(S_ISFIFO(path_stat.st_mode))
|
||||
return file_status{file_type::fifo, prms};
|
||||
|
||||
if(S_ISSOCK(path_stat.st_mode))
|
||||
return file_status{file_type::socket, prms};
|
||||
|
||||
return file_status{file_type::unknown};
|
||||
#endif
|
||||
}
|
||||
|
||||
bool is_directory(const path& p)
|
||||
{
|
||||
return (status(p).type() == file_type::directory);
|
||||
}
|
||||
|
||||
std::uintmax_t file_size(const path& p)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
//Some compilation environment may fail to link to GetFileSizeEx
|
||||
@ -223,7 +358,7 @@ namespace nana {
|
||||
GetFileSizeEx_fptr_t get_file_size_ex = reinterpret_cast<GetFileSizeEx_fptr_t>(::GetProcAddress(::GetModuleHandleA("Kernel32.DLL"), "GetFileSizeEx"));
|
||||
if (get_file_size_ex)
|
||||
{
|
||||
HANDLE handle = ::CreateFile(file.c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
HANDLE handle = ::CreateFile(p.c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (INVALID_HANDLE_VALUE != handle)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
@ -235,30 +370,26 @@ namespace nana {
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#elif defined(NANA_LINUX)
|
||||
FILE * stream = ::fopen(static_cast<std::string>(nana::charset(file)).c_str(), "rb");
|
||||
#elif defined(NANA_POSIX)
|
||||
FILE * stream = ::fopen(p.c_str(), "rb");
|
||||
long long size = 0;
|
||||
if (stream)
|
||||
{
|
||||
# if defined(NANA_LINUX)
|
||||
fseeko64(stream, 0, SEEK_END);
|
||||
size = ftello64(stream);
|
||||
fclose(stream);
|
||||
}
|
||||
return size;
|
||||
#elif defined(NANA_MACOS)
|
||||
FILE * stream = ::fopen(static_cast<std::string>(nana::charset(file)).c_str(), "rb");
|
||||
long long size = 0;
|
||||
if (stream)
|
||||
{
|
||||
# elif defined(NANA_MACOS)
|
||||
fseeko(stream, 0, SEEK_END);
|
||||
size = ftello(stream);
|
||||
fclose(stream);
|
||||
# endif
|
||||
::fclose(stream);
|
||||
}
|
||||
return size;
|
||||
return size;
|
||||
#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;
|
||||
@ -292,162 +423,116 @@ namespace nana {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool create_directory(const nana::string& path, bool & if_exist)
|
||||
|
||||
bool create_directory(const path& p)
|
||||
{
|
||||
if_exist = false;
|
||||
if (path.size() == 0) return false;
|
||||
|
||||
nana::string root;
|
||||
#if defined(NANA_WINDOWS)
|
||||
if (path.size() > 3 && path[1] == STR(':'))
|
||||
root = path.substr(0, 3);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
if (path[0] == STR('/'))
|
||||
root = '/';
|
||||
return (FALSE != ::CreateDirectoryW(p.c_str(), 0));
|
||||
#elif defined(NANA_POSIX)
|
||||
return (0 == ::mkdir(p.c_str(), static_cast<int>(perms::all)));
|
||||
#endif
|
||||
bool mkstat = false;
|
||||
std::size_t beg = root.size();
|
||||
|
||||
while (true)
|
||||
{
|
||||
beg = path.find_first_not_of(STR("/\\"), beg);
|
||||
if (beg == path.npos)
|
||||
break;
|
||||
|
||||
std::size_t pos = path.find_first_of(STR("/\\"), beg + 1);
|
||||
if (pos != path.npos)
|
||||
{
|
||||
root += path.substr(beg, pos - beg);
|
||||
|
||||
mkstat = detail::mkdir_helper(root, if_exist);
|
||||
if (mkstat == false && if_exist == false)
|
||||
return false;
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
root += STR('\\');
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
root += STR('/');
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (beg + 1 < path.size())
|
||||
{
|
||||
root += path.substr(beg);
|
||||
mkstat = detail::mkdir_helper(root, if_exist);
|
||||
}
|
||||
break;
|
||||
}
|
||||
beg = pos + 1;
|
||||
}
|
||||
return mkstat;
|
||||
}
|
||||
|
||||
bool rmfile(const nana::char_t* file)
|
||||
bool rmfile(const path& p)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
bool ret = false;
|
||||
if (file)
|
||||
{
|
||||
ret = (::DeleteFile(file) == TRUE);
|
||||
if (!ret)
|
||||
ret = (ERROR_FILE_NOT_FOUND == ::GetLastError());
|
||||
}
|
||||
if(p.empty())
|
||||
return false;
|
||||
#if defined(NANA_WINDOWS)
|
||||
if (FALSE == ::DeleteFileW(p.c_str()))
|
||||
return (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()))
|
||||
return true;
|
||||
#elif defined(NANA_POSIX)
|
||||
if (std::remove(p.c_str()))
|
||||
return (errno == ENOENT);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty)
|
||||
|
||||
bool rmdir(const path& p, bool fails_if_not_empty)
|
||||
{
|
||||
bool ret = false;
|
||||
if (dir)
|
||||
{
|
||||
if(p.empty())
|
||||
return false;
|
||||
|
||||
#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)
|
||||
std::string mbstr = nana::charset(dir);
|
||||
if (::rmdir(mbstr.c_str()))
|
||||
{
|
||||
if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
|
||||
ret = detail::rm_dir_recursive(dir);
|
||||
}
|
||||
else
|
||||
ret = true;
|
||||
#endif
|
||||
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))
|
||||
return detail::rm_dir_recursive(p.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
nana::string root(const nana::string& path)
|
||||
{
|
||||
std::size_t index = path.size();
|
||||
|
||||
if (index)
|
||||
{
|
||||
const nana::char_t * str = path.c_str();
|
||||
|
||||
for (--index; index > 0; --index)
|
||||
{
|
||||
nana::char_t c = str[index];
|
||||
if (c != '\\' && c != '/')
|
||||
break;
|
||||
}
|
||||
|
||||
for (--index; index > 0; --index)
|
||||
{
|
||||
nana::char_t c = str[index];
|
||||
if (c == '\\' || c == '/')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return index ? path.substr(0, index + 1) : nana::string();
|
||||
}
|
||||
|
||||
nana::string path_user()
|
||||
path 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;
|
||||
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)
|
||||
const char * s = ::getenv("HOME");
|
||||
if (s)
|
||||
return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8);
|
||||
const char * pstr = ::getenv("HOME");
|
||||
if (pstr)
|
||||
return pstr;
|
||||
#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_POSIX)
|
||||
char buf[260];
|
||||
auto pstr = ::getcwd(buf, 260);
|
||||
if (pstr)
|
||||
return pstr;
|
||||
|
||||
int bytes = 260 + 260;
|
||||
while (ERANGE == errno)
|
||||
{
|
||||
std::unique_ptr<char[]> buf(new char[bytes]);
|
||||
auto pstr = ::getcwd(buf.get(), bytes);
|
||||
if (pstr)
|
||||
return path(pstr);
|
||||
|
||||
bytes += 260;
|
||||
}
|
||||
#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));
|
||||
#endif
|
||||
return nana::string();
|
||||
return path();
|
||||
}
|
||||
|
||||
void current_path(const path& p)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
::SetCurrentDirectoryW(p.c_str());
|
||||
#elif defined(NANA_POSIX)
|
||||
::chdir(p.c_str());
|
||||
#endif
|
||||
}
|
||||
}//end namespace filesystem
|
||||
} //end namespace experimental
|
||||
|
||||
@ -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>
|
||||
@ -46,89 +47,18 @@ namespace filesystem
|
||||
typedef std::string string_t;
|
||||
const char* splstr = "/\\";
|
||||
#else
|
||||
typedef nana::string string_t;
|
||||
const nana::char_t* splstr = STR("/\\");
|
||||
typedef std::wstring string_t;
|
||||
const wchar_t* splstr = L"/\\";
|
||||
#endif
|
||||
//class path
|
||||
path::path(){}
|
||||
|
||||
path::path(const nana::string& text)
|
||||
#if defined(NANA_WINDOWS)
|
||||
:text_(text)
|
||||
{
|
||||
#else
|
||||
:text_(nana::charset(text))
|
||||
{
|
||||
#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);
|
||||
}
|
||||
|
||||
bool path::empty() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
return (::GetFileAttributes(text_.c_str()) == INVALID_FILE_ATTRIBUTES);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat sta;
|
||||
return (::stat(text_.c_str(), &sta) == -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
path path::root() 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
|
||||
}
|
||||
|
||||
int path::what() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
unsigned long attr = ::GetFileAttributes(text_.c_str());
|
||||
if(INVALID_FILE_ATTRIBUTES == attr)
|
||||
return type::not_exist;
|
||||
|
||||
if(FILE_ATTRIBUTE_DIRECTORY & attr)
|
||||
return type::directory;
|
||||
|
||||
return type::file;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat sta;
|
||||
if(-1 == ::stat(text_.c_str(), &sta))
|
||||
return type::not_exist;
|
||||
|
||||
if((S_IFDIR & sta.st_mode) == S_IFDIR)
|
||||
return type::directory;
|
||||
|
||||
if((S_IFREG & sta.st_mode) == S_IFREG)
|
||||
return type::file;
|
||||
|
||||
return type::not_exist;
|
||||
#endif
|
||||
}
|
||||
|
||||
nana::string path::name() 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
|
||||
}
|
||||
//end class path
|
||||
|
||||
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)
|
||||
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,28 +74,6 @@ namespace filesystem
|
||||
return rmdir(dir.c_str(), true);
|
||||
}
|
||||
|
||||
bool mkdir_helper(const nana::string& dir, bool & if_exist)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
if(::CreateDirectory(dir.c_str(), 0))
|
||||
{
|
||||
if_exist = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
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_exist = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if_exist = (errno == EEXIST);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
void filetime_to_c_tm(FILETIME& ft, struct tm& t)
|
||||
{
|
||||
@ -188,81 +96,12 @@ namespace filesystem
|
||||
#endif
|
||||
}//end namespace detail
|
||||
|
||||
bool file_attrib(const nana::string& file, attribute& attr)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
if(::GetFileAttributesEx(file.c_str(), GetFileExInfoStandard, &fad))
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
li.u.LowPart = fad.nFileSizeLow;
|
||||
li.u.HighPart = fad.nFileSizeHigh;
|
||||
attr.bytes = li.QuadPart;
|
||||
attr.is_directory = (0 != (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
|
||||
detail::filetime_to_c_tm(fad.ftLastWriteTime, attr.modified);
|
||||
return true;
|
||||
}
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
struct stat fst;
|
||||
if(0 == ::stat(static_cast<std::string>(nana::charset(file)).c_str(), &fst))
|
||||
{
|
||||
attr.bytes = fst.st_size;
|
||||
attr.is_directory = (0 != (040000 & fst.st_mode));
|
||||
attr.modified = *(::localtime(&fst.st_ctime));
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
long long filesize(const nana::string& file)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
//Some compilation environment may fail to link to GetFileSizeEx
|
||||
typedef BOOL (__stdcall *GetFileSizeEx_fptr_t)(HANDLE, PLARGE_INTEGER);
|
||||
GetFileSizeEx_fptr_t get_file_size_ex = reinterpret_cast<GetFileSizeEx_fptr_t>(::GetProcAddress(::GetModuleHandleA("Kernel32.DLL"), "GetFileSizeEx"));
|
||||
if(get_file_size_ex)
|
||||
{
|
||||
HANDLE handle = ::CreateFile(file.c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if(INVALID_HANDLE_VALUE != handle)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
if(!get_file_size_ex(handle, &li))
|
||||
li.QuadPart = 0;
|
||||
|
||||
::CloseHandle(handle);
|
||||
return li.QuadPart;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#elif defined(NANA_LINUX)
|
||||
FILE * stream = ::fopen(static_cast<std::string>(nana::charset(file)).c_str(), "rb");
|
||||
long long size = 0;
|
||||
if(stream)
|
||||
{
|
||||
fseeko64(stream, 0, SEEK_END);
|
||||
size = ftello64(stream);
|
||||
fclose(stream);
|
||||
}
|
||||
return size;
|
||||
#elif defined(NANA_MACOS)
|
||||
FILE * stream = ::fopen(static_cast<std::string>(nana::charset(file)).c_str(), "rb");
|
||||
long long size = 0;
|
||||
if (stream)
|
||||
{
|
||||
fseeko(stream, 0, SEEK_END);
|
||||
size = ftello(stream);
|
||||
fclose(stream);
|
||||
}
|
||||
return size;
|
||||
#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))
|
||||
@ -283,7 +122,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;
|
||||
@ -292,83 +131,32 @@ namespace filesystem
|
||||
return false;
|
||||
}
|
||||
|
||||
bool mkdir(const nana::string& path, bool & if_exist)
|
||||
{
|
||||
if_exist = false;
|
||||
if(path.size() == 0) return false;
|
||||
|
||||
nana::string root;
|
||||
#if defined(NANA_WINDOWS)
|
||||
if(path.size() > 3 && path[1] == STR(':'))
|
||||
root = path.substr(0, 3);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
if(path[0] == STR('/'))
|
||||
root = '/';
|
||||
#endif
|
||||
bool mkstat = false;
|
||||
std::size_t beg = root.size();
|
||||
|
||||
while(true)
|
||||
{
|
||||
beg = path.find_first_not_of(STR("/\\"), beg);
|
||||
if(beg == path.npos)
|
||||
break;
|
||||
|
||||
std::size_t pos = path.find_first_of(STR("/\\"), beg + 1);
|
||||
if(pos != path.npos)
|
||||
{
|
||||
root += path.substr(beg, pos - beg);
|
||||
|
||||
mkstat = detail::mkdir_helper(root, if_exist);
|
||||
if(mkstat == false && if_exist == false)
|
||||
return false;
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
root += STR('\\');
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
root += STR('/');
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if(beg + 1 < path.size())
|
||||
{
|
||||
root += path.substr(beg);
|
||||
mkstat = detail::mkdir_helper(root, if_exist);
|
||||
}
|
||||
break;
|
||||
}
|
||||
beg = pos + 1;
|
||||
}
|
||||
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)
|
||||
@ -385,36 +173,10 @@ namespace filesystem
|
||||
return ret;
|
||||
}
|
||||
|
||||
nana::string root(const nana::string& path)
|
||||
{
|
||||
std::size_t index = path.size();
|
||||
|
||||
if(index)
|
||||
{
|
||||
const nana::char_t * str = path.c_str();
|
||||
|
||||
for(--index; index > 0; --index)
|
||||
{
|
||||
nana::char_t c = str[index];
|
||||
if(c != '\\' && c != '/')
|
||||
break;
|
||||
}
|
||||
|
||||
for(--index; index > 0; --index)
|
||||
{
|
||||
nana::char_t c = str[index];
|
||||
if(c == '\\' || c == '/')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return index?path.substr(0, index + 1):nana::string();
|
||||
}
|
||||
|
||||
nana::string path_user()
|
||||
std::wstring path_user()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
nana::char_t path[MAX_PATH];
|
||||
wchar_t path[MAX_PATH];
|
||||
if(SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, path)))
|
||||
return path;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
@ -422,32 +184,7 @@ namespace filesystem
|
||||
if(s)
|
||||
return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8);
|
||||
#endif
|
||||
return nana::string();
|
||||
}
|
||||
|
||||
nana::string path_current()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
nana::char_t buf[MAX_PATH];
|
||||
DWORD len = ::GetCurrentDirectory(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;
|
||||
delete [] p;
|
||||
return s;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
const char * s = ::getenv("PWD");
|
||||
if(s)
|
||||
return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8);
|
||||
#endif
|
||||
return nana::string();
|
||||
return std::wstring();
|
||||
}
|
||||
}//end namespace filesystem
|
||||
}//end namespace nana
|
||||
|
||||
@ -1017,7 +1017,7 @@ namespace detail
|
||||
}
|
||||
|
||||
keybuf[len] = 0;
|
||||
::nana::char_t os_code = 0;
|
||||
wchar_t os_code = 0;
|
||||
switch(status)
|
||||
{
|
||||
case XLookupKeySym:
|
||||
@ -1074,7 +1074,7 @@ namespace detail
|
||||
|
||||
if(brock.wd_manager().available(msgwnd) && (msgwnd->root_widget->other.attribute.root->menubar == msgwnd))
|
||||
{
|
||||
int cmd = (menu_wd && (keyboard::escape == static_cast<nana::char_t>(arg.key)) ? 1 : 0 );
|
||||
int cmd = (menu_wd && (keyboard::escape == static_cast<wchar_t>(arg.key)) ? 1 : 0 );
|
||||
brock.delay_restore(cmd);
|
||||
}
|
||||
}
|
||||
@ -1087,11 +1087,11 @@ namespace detail
|
||||
case XLookupChars:
|
||||
if (msgwnd->flags.enabled)
|
||||
{
|
||||
const ::nana::char_t* charbuf;
|
||||
const wchar_t* charbuf;
|
||||
#if defined(NANA_UNICODE)
|
||||
nana::detail::charset_conv charset("UTF-32", "UTF-8");
|
||||
const std::string& str = charset.charset(std::string(keybuf, keybuf + len));
|
||||
charbuf = reinterpret_cast<const nana::char_t*>(str.c_str()) + 1;
|
||||
charbuf = reinterpret_cast<const wchar_t*>(str.c_str()) + 1;
|
||||
len = str.size() / sizeof(wchar_t) - 1;
|
||||
#else
|
||||
charbuf = keybuf;
|
||||
@ -1400,4 +1400,4 @@ namespace detail
|
||||
}
|
||||
}//end namespace detail
|
||||
}//end namespace nana
|
||||
#endif //NANA_POSIX && NANA_X11
|
||||
#endif //NANA_POSIX && NANA_X11
|
||||
|
||||
@ -141,7 +141,7 @@ namespace detail
|
||||
|
||||
struct platform_detail_tag
|
||||
{
|
||||
nana::char_t keychar;
|
||||
wchar_t keychar;
|
||||
}platform;
|
||||
|
||||
struct cursor_tag
|
||||
@ -215,7 +215,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);
|
||||
@ -441,9 +441,9 @@ namespace detail
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
(msgbox(modal_window, STR("An uncaptured std::exception during message pumping: ")).icon(msgbox::icon_information)
|
||||
<<STR("\n in form: ") << API::window_caption(modal_window)
|
||||
<<STR("\n exception : ") << e.what()
|
||||
(msgbox(modal_window, "An uncaptured std::exception during message pumping: ").icon(msgbox::icon_information)
|
||||
<<"\n in form: "<< API::window_caption(modal_window)
|
||||
<<"\n exception : "<< e.what()
|
||||
).show();
|
||||
|
||||
internal_scope_guard lock;
|
||||
@ -459,8 +459,8 @@ namespace detail
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
(msgbox(modal_window, STR("An exception during message pumping!")).icon(msgbox::icon_information)
|
||||
<< STR("An uncaptured non-std exception during message pumping!")
|
||||
(msgbox(modal_window, "An exception during message pumping!").icon(msgbox::icon_information)
|
||||
<<"An uncaptured non-std exception during message pumping!"
|
||||
).show();
|
||||
internal_scope_guard lock;
|
||||
_m_except_handler();
|
||||
@ -1176,7 +1176,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);
|
||||
@ -1185,12 +1185,13 @@ namespace detail
|
||||
unsigned reqlen = ::DragQueryFile(drop, i, 0, 0) + 1;
|
||||
if(bufsize < reqlen)
|
||||
{
|
||||
varbuf.reset(new nana::char_t[reqlen]);
|
||||
varbuf.reset(new wchar_t[reqlen]);
|
||||
bufsize = reqlen;
|
||||
}
|
||||
|
||||
::DragQueryFile(drop, i, varbuf.get(), reqlen);
|
||||
dropfiles.files.emplace_back(varbuf.get());
|
||||
|
||||
dropfiles.files.emplace_back(utf8_cast(varbuf.get()));
|
||||
}
|
||||
|
||||
while(msgwnd && (msgwnd->flags.dropable == false))
|
||||
@ -1344,7 +1345,7 @@ namespace detail
|
||||
arg.evt_code = event_code::key_press;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
arg.ignore = false;
|
||||
arg.key = static_cast<nana::char_t>(wParam);
|
||||
arg.key = static_cast<wchar_t>(wParam);
|
||||
brock.get_key_state(arg);
|
||||
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
|
||||
|
||||
@ -1372,7 +1373,7 @@ namespace detail
|
||||
arg.evt_code = event_code::key_release;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
arg.ignore = false;
|
||||
arg.key = static_cast<nana::char_t>(wParam);
|
||||
arg.key = static_cast<wchar_t>(wParam);
|
||||
brock.get_key_state(arg);
|
||||
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
||||
|
||||
@ -1414,7 +1415,7 @@ namespace detail
|
||||
arg.evt_code = event_code::key_press;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
arg.ignore = false;
|
||||
arg.key = static_cast<nana::char_t>(wParam);
|
||||
arg.key = static_cast<wchar_t>(wParam);
|
||||
brock.get_key_state(arg);
|
||||
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
|
||||
|
||||
@ -1425,7 +1426,7 @@ namespace detail
|
||||
//If no menu popuped by the menubar, it should enable delay restore to
|
||||
//restore the focus for taken window.
|
||||
|
||||
int cmd = (menu_wd && (keyboard::escape == static_cast<nana::char_t>(wParam)) ? 1 : 0);
|
||||
int cmd = (menu_wd && (keyboard::escape == static_cast<wchar_t>(wParam)) ? 1 : 0);
|
||||
brock.delay_restore(cmd);
|
||||
}
|
||||
}
|
||||
@ -1442,7 +1443,7 @@ namespace detail
|
||||
arg_keyboard arg;
|
||||
arg.evt_code = event_code::key_char;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
arg.key = static_cast<nana::char_t>(wParam);
|
||||
arg.key = static_cast<wchar_t>(wParam);
|
||||
brock.get_key_state(arg);
|
||||
arg.ignore = false;
|
||||
|
||||
@ -1463,7 +1464,7 @@ namespace detail
|
||||
arg_keyboard arg;
|
||||
arg.evt_code = event_code::key_release;
|
||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||
arg.key = static_cast<nana::char_t>(wParam);
|
||||
arg.key = static_cast<wchar_t>(wParam);
|
||||
brock.get_key_state(arg);
|
||||
arg.ignore = false;
|
||||
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
||||
@ -1728,9 +1729,9 @@ namespace detail
|
||||
return true;
|
||||
}
|
||||
|
||||
const nana::char_t* translate(cursor id)
|
||||
const wchar_t* translate(cursor id)
|
||||
{
|
||||
const nana::char_t* name = IDC_ARROW;
|
||||
const wchar_t* name = IDC_ARROW;
|
||||
|
||||
switch(id)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
@ -378,8 +378,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
|
||||
@ -1084,48 +1084,37 @@ namespace nana{
|
||||
#endif
|
||||
}
|
||||
|
||||
void native_interface::window_caption(native_window_type wd, const nana::string& title)
|
||||
void native_interface::window_caption(native_window_type wd, const native_string_type& title)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
if(::GetCurrentThreadId() != ::GetWindowThreadProcessId(reinterpret_cast<HWND>(wd), 0))
|
||||
{
|
||||
wchar_t * wstr;
|
||||
#if defined(NANA_UNICODE)
|
||||
wstr = new wchar_t[title.length() + 1];
|
||||
wcscpy(wstr, title.c_str());
|
||||
#else
|
||||
std::wstring str = nana::charset(title);
|
||||
wstr = new wchar_t[str.length() + 1];
|
||||
wcscpy(wstr, str.c_str());
|
||||
#endif
|
||||
wchar_t * wstr = new wchar_t[title.length() + 1];
|
||||
std::wcscpy(wstr, title.c_str());
|
||||
::PostMessage(reinterpret_cast<HWND>(wd), nana::detail::messages::remote_thread_set_window_text, reinterpret_cast<WPARAM>(wstr), 0);
|
||||
}
|
||||
else
|
||||
::SetWindowText(reinterpret_cast<HWND>(wd), title.c_str());
|
||||
#elif defined(NANA_X11)
|
||||
::XTextProperty name;
|
||||
#if defined(NANA_UNICODE)
|
||||
std::string mbstr = nana::charset(title);
|
||||
char* text = const_cast<char*>(mbstr.c_str());
|
||||
#else
|
||||
char* text = const_cast<char*>(title.c_str());
|
||||
#endif
|
||||
char * text = const_cast<char*>(title.c_str());
|
||||
|
||||
nana::detail::platform_scope_guard psg;
|
||||
::XStringListToTextProperty(&text, 1, &name);
|
||||
::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
|
||||
}
|
||||
|
||||
nana::string native_interface::window_caption(native_window_type wd)
|
||||
auto native_interface::window_caption(native_window_type wd) -> native_string_type
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
int length = ::GetWindowTextLength(reinterpret_cast<HWND>(wd));
|
||||
if(length > 0)
|
||||
{
|
||||
nana::string str;
|
||||
native_string_type str;
|
||||
//One for NULL terminator which GetWindowText will write.
|
||||
str.resize(length+1);
|
||||
|
||||
@ -1136,7 +1125,6 @@ namespace nana{
|
||||
|
||||
return str;
|
||||
}
|
||||
return nana::string();
|
||||
#elif defined(NANA_X11)
|
||||
nana::detail::platform_scope_guard psg;
|
||||
::XTextProperty txtpro;
|
||||
@ -1148,14 +1136,14 @@ namespace nana{
|
||||
{
|
||||
if(size > 1)
|
||||
{
|
||||
nana::string str = nana::charset(*strlist);
|
||||
std::string text = *strlist;
|
||||
::XFreeStringList(strlist);
|
||||
return str;
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nana::string();
|
||||
#endif
|
||||
return native_string_type();
|
||||
}
|
||||
|
||||
void native_interface::capture_window(native_window_type wd, bool cap)
|
||||
|
||||
@ -1,5 +1,17 @@
|
||||
/*
|
||||
* A Dragger Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/dragger.cpp
|
||||
*/
|
||||
|
||||
#include <nana/gui/dragger.hpp>
|
||||
#include <nana/gui/programming_interface.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@ -180,6 +192,23 @@ namespace nana
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
dragger::dragger(dragger&& other)
|
||||
: impl_(other.impl_)
|
||||
{
|
||||
other.impl_ = nullptr;
|
||||
}
|
||||
|
||||
dragger& dragger::operator=(dragger&& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
delete impl_;
|
||||
impl_ = other.impl_;
|
||||
other.impl_ = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void dragger::target(window wd)
|
||||
{
|
||||
impl_->drag_target(wd, rectangle(), nana::arrange::horizontal_vertical);
|
||||
|
||||
@ -173,11 +173,8 @@ namespace nana
|
||||
const int x = r.x + 1;
|
||||
const int y = r.y + 1;
|
||||
|
||||
graph.set_color(bld_bgcolor);
|
||||
graph.rectangle(rectangle{ x + 1, y + 1, 11, 11 }, true);
|
||||
|
||||
graph.set_color(bld_fgcolor);
|
||||
graph.rectangle(rectangle{ x, y, 13, 13 }, false);
|
||||
graph.rectangle(rectangle{ x + 1, y + 1, 11, 11 }, true, bld_bgcolor);
|
||||
graph.rectangle(rectangle{ x, y, 13, 13 }, false, bld_fgcolor);
|
||||
|
||||
switch(crook_data.check_state)
|
||||
{
|
||||
@ -252,11 +249,11 @@ namespace nana
|
||||
int x = r.x + (static_cast<int>(r.width) - 16) / 2;
|
||||
int y = r.y + (static_cast<int>(r.height) - 16) / 2;
|
||||
|
||||
graph.set_color(fgcolor);
|
||||
graph.palette(false, fgcolor);
|
||||
graph.line(point{ x + 3, y + 7 }, point{ x + 6, y + 10 });
|
||||
graph.line(point{ x + 7, y + 9 }, point{ x + 12, y + 4 });
|
||||
|
||||
graph.set_color(fgcolor.blend(colors::white, 0.5));
|
||||
graph.palette(false, fgcolor.blend(colors::white, 0.5));
|
||||
graph.line(point{ x + 3, y + 8 }, point{ x + 6, y + 11 });
|
||||
graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 });
|
||||
graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 });
|
||||
@ -515,16 +512,16 @@ namespace nana
|
||||
::nana::point left_mid{ r.x + 1, r.y + 1 + static_cast<int>(part_px) }, right_mid{ right_top.x, left_mid.y };
|
||||
::nana::point left_bottom{ r.x + 1, r.bottom() - 2 }, right_bottom{ r.right() - 2, r.bottom() - 2 };
|
||||
|
||||
graph.set_color(bgcolor.blend(colors::white, 0.9));
|
||||
graph.palette(false, bgcolor.blend(colors::white, 0.9));
|
||||
graph.line(left_top, left_mid);
|
||||
graph.line(right_top, right_mid);
|
||||
|
||||
graph.set_color(bgcolor.blend(colors::white, 0.5));
|
||||
graph.palette(false, bgcolor.blend(colors::white, 0.5));
|
||||
graph.line(left_top, right_top);
|
||||
|
||||
left_mid.y++;
|
||||
right_mid.y++;
|
||||
graph.set_color(bgcolor.blend(colors::black, 0.8));
|
||||
graph.palette(false, bgcolor.blend(colors::black, 0.8));
|
||||
graph.line(left_mid, left_bottom);
|
||||
graph.line(right_mid, right_bottom);
|
||||
|
||||
@ -557,7 +554,7 @@ namespace nana
|
||||
break;
|
||||
}
|
||||
|
||||
graph.set_color(clr);
|
||||
graph.palette(false, clr);
|
||||
|
||||
const int x = r.x + 4;
|
||||
const int y = r.y + 4;
|
||||
@ -959,13 +956,13 @@ namespace nana
|
||||
ps[11].x = r.x + gap;
|
||||
ps[11].y = r.y + gap;
|
||||
|
||||
graph.set_color(fgcolor.blend(colors::black, true));
|
||||
graph.palette(false, fgcolor.blend(colors::black, true));
|
||||
|
||||
for (int i = 0; i < 11; ++i)
|
||||
graph.line(ps[i], ps[i + 1]);
|
||||
graph.line(ps[11], ps[0]);
|
||||
|
||||
graph.set_color(fgcolor);
|
||||
graph.palette(false, fgcolor);
|
||||
|
||||
unsigned thk_minus_2 = thickness_ - 2;
|
||||
graph.rectangle(rectangle{ ps[10].x + 1, ps[10].y + 1, (gap << 1) + thk_minus_2, thk_minus_2 }, true);
|
||||
@ -1010,7 +1007,7 @@ namespace nana
|
||||
//Implement element_interface
|
||||
bool facade<element::arrow>::draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state estate)
|
||||
{
|
||||
graph.set_color(fgcolor);
|
||||
graph.palette(false, fgcolor);
|
||||
return (*cite_)->draw(graph, bgcolor, fgcolor, r, estate, dir_);
|
||||
}
|
||||
//end class facade<element::arrow>
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <nana/gui.hpp>
|
||||
#include <nana/gui/filebox.hpp>
|
||||
#include <nana/filesystem/fs_utility.hpp>
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
@ -38,16 +39,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 +66,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,15 +88,15 @@ 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)
|
||||
{
|
||||
double cap = bytes / 1024.0;
|
||||
std::size_t uid = 0;
|
||||
while((cap >= 1024.0) && (uid < (sizeof(ustr) / sizeof(nana::char_t*))))
|
||||
while((cap >= 1024.0) && (uid < (sizeof(ustr) / sizeof(char*))))
|
||||
{
|
||||
cap /= 1024.0;
|
||||
++uid;
|
||||
@ -108,10 +109,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 +133,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 +163,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 +191,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 +213,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 +224,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 +255,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 +264,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 +272,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 +288,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 +307,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 +345,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 +383,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 +425,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 +443,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,56 +464,59 @@ 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();
|
||||
|
||||
using namespace nana::filesystem;
|
||||
attribute fattr;
|
||||
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;
|
||||
if(file_attrib(path + m.name, fattr))
|
||||
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
auto fattr = fs::status(path + m.name);
|
||||
|
||||
if(fattr.type() != fs::file_type::not_found && fattr.type() != fs::file_type::unknown)
|
||||
{
|
||||
m.bytes = fattr.bytes;
|
||||
m.directory = fattr.is_directory;
|
||||
m.modified_time = fattr.modified;
|
||||
m.bytes = fs::file_size(path + m.name);
|
||||
m.directory = fs::is_directory(fattr);
|
||||
modified_file_time(path + m.name, m.modified_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
m.bytes = 0;
|
||||
m.directory = i->directory;
|
||||
modified_file_time(path + i->name, m.modified_time);
|
||||
modified_file_time(path + i->name, m.modified_time);
|
||||
}
|
||||
|
||||
file_container_.push_back(m);
|
||||
@ -522,32 +527,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 +561,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 +588,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 +606,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 +623,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,25 +640,35 @@ 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;
|
||||
}
|
||||
|
||||
bool if_exist;
|
||||
if(false == nana::filesystem::mkdir(fb_.addr_.filesystem + path, if_exist))
|
||||
|
||||
using file_type = nana::experimental::filesystem::file_type;
|
||||
|
||||
experimental::filesystem::path fspath(fb_.addr_.filesystem + path);
|
||||
|
||||
auto fs = experimental::filesystem::status(fspath);
|
||||
|
||||
if(fs.type() != file_type::not_found && fs.type() != file_type::none)
|
||||
{
|
||||
if(if_exist)
|
||||
mb<<STR("The folder is existing, please rename it.");
|
||||
else
|
||||
mb<<STR("Failed to create the folder, please rename it.");
|
||||
mb<<L"The folder is existing, please rename it.";
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
|
||||
if(false == experimental::filesystem::create_directory(fspath))
|
||||
{
|
||||
mb<<L"Failed to create the folder, please rename it.";
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
|
||||
fb_._m_load_cat_path(fb_.addr_.filesystem);
|
||||
fm_.close();
|
||||
}
|
||||
@ -663,29 +678,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 +718,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,34 +739,34 @@ 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;
|
||||
|
||||
|
||||
bool good = true;
|
||||
nana::filesystem::attribute attr;
|
||||
if(nana::filesystem::file_attrib(tar, attr) == false)
|
||||
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
auto fattr = fs::status(tar);
|
||||
if(fattr.type() == fs::file_type::not_found)
|
||||
{
|
||||
if(_m_append_def_extension(tar))
|
||||
good = nana::filesystem::file_attrib(tar, attr);
|
||||
else
|
||||
good = false;
|
||||
good = (_m_append_def_extension(tar) && (fs::status(tar).type() == fs::file_type::not_found));
|
||||
}
|
||||
|
||||
if(good && attr.is_directory)
|
||||
|
||||
if(good && fs::is_directory(fattr))
|
||||
{
|
||||
_m_load_cat_path(tar);
|
||||
tb_file_.caption(STR(""));
|
||||
tb_file_.caption("");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -761,7 +776,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 +788,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 +806,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 +829,7 @@ namespace nana
|
||||
}
|
||||
private:
|
||||
bool io_read_;
|
||||
nana::string def_ext_;
|
||||
std::string def_ext_;
|
||||
|
||||
place place_;
|
||||
categorize<int> path_;
|
||||
@ -835,22 +850,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
|
||||
@ -858,16 +873,16 @@ namespace nana
|
||||
{
|
||||
struct filter
|
||||
{
|
||||
nana::string des;
|
||||
nana::string type;
|
||||
std::string des;
|
||||
std::string type;
|
||||
};
|
||||
|
||||
window owner;
|
||||
bool open_or_save;
|
||||
|
||||
nana::string file;
|
||||
nana::string title;
|
||||
nana::string path;
|
||||
std::string file;
|
||||
std::string title;
|
||||
std::string path;
|
||||
std::vector<filter> filters;
|
||||
};
|
||||
|
||||
@ -885,9 +900,12 @@ namespace nana
|
||||
auto len = ::GetCurrentDirectory(0, nullptr);
|
||||
if(len)
|
||||
{
|
||||
impl_->path.resize(len + 1);
|
||||
::GetCurrentDirectory(len, &(impl_->path[0]));
|
||||
impl_->path.resize(len);
|
||||
std::wstring path;
|
||||
path.resize(len + 1);
|
||||
::GetCurrentDirectory(len, &(path[0]));
|
||||
path.resize(len);
|
||||
|
||||
impl_->path = utf8_cast(path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -913,13 +931,13 @@ namespace nana
|
||||
impl_->owner = wd;
|
||||
}
|
||||
|
||||
nana::string filebox::title(nana::string s)
|
||||
std::string filebox::title(std::string s)
|
||||
{
|
||||
impl_->title.swap(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
filebox& filebox::init_path(const nana::string& ipstr)
|
||||
filebox& filebox::init_path(const std::string& ipstr)
|
||||
{
|
||||
if(ipstr.empty())
|
||||
{
|
||||
@ -927,33 +945,32 @@ namespace nana
|
||||
}
|
||||
else
|
||||
{
|
||||
nana::filesystem::attribute attr;
|
||||
if (nana::filesystem::file_attrib(ipstr, attr))
|
||||
if (attr.is_directory)
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
if (fs::is_directory(ipstr))
|
||||
impl_->path = ipstr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
filebox& filebox::init_file(const nana::string& ifstr)
|
||||
filebox& filebox::init_file(const std::string& ifstr)
|
||||
{
|
||||
impl_->file = ifstr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
filebox& filebox::add_filter(const nana::string& description, const nana::string& filetype)
|
||||
filebox& filebox::add_filter(const std::string& description, const std::string& filetype)
|
||||
{
|
||||
implement::filter flt = {description, filetype};
|
||||
impl_->filters.push_back(flt);
|
||||
return *this;
|
||||
}
|
||||
|
||||
nana::string filebox::path() const
|
||||
std::string filebox::path() const
|
||||
{
|
||||
return impl_->path;
|
||||
}
|
||||
|
||||
nana::string filebox::file() const
|
||||
std::string filebox::file() const
|
||||
{
|
||||
return impl_->file;
|
||||
}
|
||||
@ -961,36 +978,36 @@ namespace nana
|
||||
bool filebox::show() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
if(impl_->file.size() < 520)
|
||||
impl_->file.resize(520);
|
||||
std::wstring wfile;
|
||||
wfile.resize(520);
|
||||
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof ofn);
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = reinterpret_cast<HWND>(API::root(impl_->owner));
|
||||
ofn.lpstrFile = &(impl_->file[0]);
|
||||
ofn.nMaxFile = static_cast<DWORD>(impl_->file.size() - 1);
|
||||
ofn.lpstrFile = &(wfile[0]);
|
||||
ofn.nMaxFile = static_cast<DWORD>(wfile.size() - 1);
|
||||
|
||||
const nana::char_t * filter;
|
||||
nana::string filter_holder;
|
||||
nana::string default_extension;
|
||||
const wchar_t * filter;
|
||||
std::wstring filter_holder;
|
||||
std::wstring default_extension;
|
||||
if(impl_->filters.size())
|
||||
{
|
||||
for(auto & f : impl_->filters)
|
||||
{
|
||||
filter_holder += f.des;
|
||||
filter_holder += static_cast<nana::string::value_type>('\0');
|
||||
nana::string fs = f.type;
|
||||
filter_holder += utf8_cast(f.des);
|
||||
filter_holder += static_cast<std::wstring::value_type>('\0');
|
||||
std::wstring fs = utf8_cast(f.type);
|
||||
std::size_t pos = 0;
|
||||
while(true)
|
||||
{
|
||||
pos = fs.find(STR(" "), pos);
|
||||
pos = fs.find(L" ", pos);
|
||||
if(pos == fs.npos)
|
||||
break;
|
||||
fs.erase(pos);
|
||||
}
|
||||
filter_holder += fs;
|
||||
filter_holder += static_cast<nana::string::value_type>('\0');
|
||||
filter_holder += static_cast<std::wstring::value_type>('\0');
|
||||
|
||||
//Get the default file extentsion
|
||||
if (default_extension.empty())
|
||||
@ -1010,14 +1027,16 @@ namespace nana
|
||||
filter = filter_holder.data();
|
||||
}
|
||||
else
|
||||
filter = STR("All Files\0*.*\0");
|
||||
filter = L"All Files\0*.*\0";
|
||||
|
||||
auto wtitle = utf8_cast(impl_->title);
|
||||
auto wpath = utf8_cast(impl_->path);
|
||||
ofn.lpstrFilter = filter;
|
||||
ofn.lpstrTitle = (impl_->title.size() ? impl_->title.c_str() : nullptr);
|
||||
ofn.lpstrTitle = (wtitle.empty() ? nullptr : wtitle.c_str());
|
||||
ofn.nFilterIndex = 0;
|
||||
ofn.lpstrFileTitle = nullptr;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = (impl_->path.size() ? impl_->path.c_str() : nullptr);
|
||||
ofn.lpstrInitialDir = (wpath.empty() ? nullptr : wpath.c_str());
|
||||
|
||||
if (!impl_->open_or_save)
|
||||
ofn.Flags = OFN_OVERWRITEPROMPT; //Overwrite prompt if it is save mode
|
||||
@ -1026,7 +1045,8 @@ namespace nana
|
||||
if(FALSE == (impl_->open_or_save ? ::GetOpenFileName(&ofn) : ::GetSaveFileName(&ofn)))
|
||||
return false;
|
||||
|
||||
impl_->file.resize(nana::strlen(impl_->file.data()));
|
||||
wfile.resize(std::wcslen(wfile.data()));
|
||||
impl_->file = utf8_cast(wfile);
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
filebox_implement fb(impl_->owner, impl_->open_or_save, impl_->title);
|
||||
|
||||
@ -1034,11 +1054,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);
|
||||
@ -1047,7 +1067,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
else
|
||||
fb.add_filter(STR("All Files"), STR("*.*"));
|
||||
fb.add_filter("All Files", "*.*");
|
||||
|
||||
fb.load_fs(impl_->path, impl_->file);
|
||||
|
||||
@ -1055,7 +1075,7 @@ namespace nana
|
||||
if(false == fb.file(impl_->file))
|
||||
return false;
|
||||
#endif
|
||||
auto tpos = impl_->file.find_last_of(STR("\\/"));
|
||||
auto tpos = impl_->file.find_last_of("\\/");
|
||||
if(tpos != impl_->file.npos)
|
||||
impl_->path = impl_->file.substr(0, tpos);
|
||||
else
|
||||
|
||||
@ -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);
|
||||
@ -108,7 +108,7 @@ namespace nana
|
||||
_m_icon(ico);
|
||||
}
|
||||
|
||||
void prompt(const nana::string& text)
|
||||
void prompt(const std::string& text)
|
||||
{
|
||||
if(text.size())
|
||||
{
|
||||
@ -352,13 +352,17 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
msgbox::msgbox(const nana::string& title)
|
||||
msgbox::msgbox(const std::string& title)
|
||||
: wd_(nullptr), title_(title), button_(ok), icon_(icon_none)
|
||||
{}
|
||||
{
|
||||
throw_not_utf8(title_);
|
||||
}
|
||||
|
||||
msgbox::msgbox(window wd, const nana::string& title, button_t b)
|
||||
msgbox::msgbox(window wd, const std::string& title, button_t b)
|
||||
: wd_(wd), title_(title), button_(b), icon_(icon_none)
|
||||
{}
|
||||
{
|
||||
throw_not_utf8(title_);
|
||||
}
|
||||
|
||||
msgbox& msgbox::icon(icon_t ic)
|
||||
{
|
||||
@ -372,23 +376,15 @@ namespace nana
|
||||
sstream_.clear();
|
||||
}
|
||||
|
||||
msgbox & msgbox::operator<<(const nana::string& str)
|
||||
msgbox & msgbox::operator<<(const std::wstring& str)
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
sstream_<<static_cast<std::string>(nana::charset(str));
|
||||
#else
|
||||
sstream_<<str;
|
||||
#endif
|
||||
sstream_ << to_osmbstr(to_utf8(str));
|
||||
return *this;
|
||||
}
|
||||
|
||||
msgbox & msgbox::operator<<(const nana::char_t* str)
|
||||
msgbox & msgbox::operator<<(const wchar_t* str)
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
sstream_<<static_cast<std::string>(nana::charset(str));;
|
||||
#else
|
||||
sstream_<<str;
|
||||
#endif
|
||||
sstream_ << to_osmbstr(to_utf8(str));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -439,11 +435,8 @@ namespace nana
|
||||
default: break;
|
||||
}
|
||||
|
||||
#if defined(NANA_UNICODE)
|
||||
int bt = ::MessageBoxW(reinterpret_cast<HWND>(API::root(wd_)), static_cast<std::wstring>(nana::charset(sstream_.str())).c_str(), title_.c_str(), type);
|
||||
#else
|
||||
int bt = ::MessageBoxA(reinterpret_cast<HWND>(API::root(wd_), sstream_.str().c_str(), title_.c_str(), type);
|
||||
#endif
|
||||
auto bt = ::MessageBoxW(reinterpret_cast<HWND>(API::root(wd_)), utf8_cast(sstream_.str()).c_str(), utf8_cast(title_).c_str(), type);
|
||||
|
||||
switch(bt)
|
||||
{
|
||||
case IDOK:
|
||||
@ -473,9 +466,12 @@ namespace nana
|
||||
: public ::nana::form
|
||||
{
|
||||
public:
|
||||
inputbox_window(window owner, paint::image (&imgs)[4], ::nana::rectangle (&valid_areas)[4], const ::nana::string & desc, const ::nana::string& title, std::size_t contents, unsigned fixed_pixels, const std::vector<unsigned>& each_height)
|
||||
inputbox_window(window owner, paint::image (&imgs)[4], ::nana::rectangle (&valid_areas)[4], const ::std::string & desc, const ::std::string& title, std::size_t contents, unsigned fixed_pixels, const std::vector<unsigned>& each_height)
|
||||
: form(owner, API::make_center(owner, 500, 300), appear::decorate<>())
|
||||
{
|
||||
throw_not_utf8(desc);
|
||||
throw_not_utf8(title);
|
||||
|
||||
desc_.create(*this);
|
||||
desc_.format(true).caption(desc);
|
||||
auto desc_extent = desc_.measure(470);
|
||||
@ -652,13 +648,13 @@ namespace nana
|
||||
int last;
|
||||
int step;
|
||||
|
||||
::nana::string label_text;
|
||||
::std::string label_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::spinbox spinbox;
|
||||
};
|
||||
|
||||
inputbox::integer::integer(::nana::string label, int init_value, int begin, int last, int step)
|
||||
inputbox::integer::integer(::std::string label, int init_value, int begin, int last, int step)
|
||||
: impl_(new implement)
|
||||
{
|
||||
auto impl = impl_.get();
|
||||
@ -681,7 +677,7 @@ namespace nana
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::integer::label() const
|
||||
const ::std::string& inputbox::integer::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
@ -704,7 +700,7 @@ namespace nana
|
||||
impl->spinbox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, value_px, 0 });
|
||||
impl->spinbox.range(impl->begin, impl->last, impl->step);
|
||||
|
||||
impl->spinbox.value(std::to_wstring(impl->value));
|
||||
impl->spinbox.value(std::to_string(impl->value));
|
||||
|
||||
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg)
|
||||
{
|
||||
@ -730,13 +726,13 @@ namespace nana
|
||||
double last;
|
||||
double step;
|
||||
|
||||
::nana::string label_text;
|
||||
::std::string label_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::spinbox spinbox;
|
||||
};
|
||||
|
||||
inputbox::real::real(::nana::string label, double init_value, double begin, double last, double step)
|
||||
inputbox::real::real(::std::string label, double init_value, double begin, double last, double step)
|
||||
: impl_(new implement)
|
||||
{
|
||||
auto impl = impl_.get();
|
||||
@ -759,7 +755,7 @@ namespace nana
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::real::label() const
|
||||
const ::std::string& inputbox::real::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
@ -782,7 +778,7 @@ namespace nana
|
||||
impl->spinbox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, value_px, 0 });
|
||||
impl->spinbox.range(impl->begin, impl->last, impl->step);
|
||||
|
||||
impl->spinbox.value(std::to_wstring(impl->value));
|
||||
impl->spinbox.value(std::to_string(impl->value));
|
||||
|
||||
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg)
|
||||
{
|
||||
@ -803,29 +799,33 @@ namespace nana
|
||||
//class text
|
||||
struct inputbox::text::implement
|
||||
{
|
||||
::nana::string value;
|
||||
::nana::string tip;
|
||||
::std::string value;
|
||||
::std::string tip;
|
||||
wchar_t mask_character{0};
|
||||
std::vector< ::nana::string> options;
|
||||
std::vector< ::std::string> options;
|
||||
|
||||
::nana::string label_text;
|
||||
::nana::string init_text;
|
||||
::std::string label_text;
|
||||
::std::string init_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::combox combox;
|
||||
::nana::textbox textbox;
|
||||
};
|
||||
|
||||
inputbox::text::text(::nana::string label, ::nana::string init_text)
|
||||
inputbox::text::text(::std::string label, ::std::string init_text)
|
||||
: impl_(new implement)
|
||||
{
|
||||
impl_->label_text.swap(label);
|
||||
impl_->init_text.swap(init_text);
|
||||
}
|
||||
|
||||
inputbox::text::text(::nana::string label, std::vector<::nana::string> options)
|
||||
inputbox::text::text(::std::string label, std::vector<::std::string> options)
|
||||
: impl_(new implement)
|
||||
{
|
||||
throw_not_utf8(label);
|
||||
for (auto & text : options)
|
||||
throw_not_utf8(text);
|
||||
|
||||
impl_->options.swap(options);
|
||||
impl_->label_text.swap(label);
|
||||
}
|
||||
@ -835,12 +835,12 @@ namespace nana
|
||||
|
||||
void inputbox::text::tip_string(std::wstring tip)
|
||||
{
|
||||
impl_->tip.swap(tip);
|
||||
impl_->tip = utf8_cast(tip);
|
||||
}
|
||||
|
||||
void inputbox::text::tip_string(std::string tip_utf8)
|
||||
{
|
||||
impl_->tip = ::nana::charset(tip_utf8, ::nana::unicode::utf8);
|
||||
impl_->tip.swap(tip_utf8);
|
||||
}
|
||||
|
||||
void inputbox::text::mask_character(wchar_t ch)
|
||||
@ -848,7 +848,7 @@ namespace nana
|
||||
impl_->mask_character = ch;
|
||||
}
|
||||
|
||||
::nana::string inputbox::text::value() const
|
||||
::std::string inputbox::text::value() const
|
||||
{
|
||||
if (!impl_->textbox.empty())
|
||||
return impl_->textbox.caption();
|
||||
@ -859,7 +859,7 @@ namespace nana
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::text::label() const
|
||||
const ::std::string& inputbox::text::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
@ -929,7 +929,7 @@ namespace nana
|
||||
int month;
|
||||
int day;
|
||||
|
||||
::nana::string label_text;
|
||||
::std::string label_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::combox wdg_month;
|
||||
@ -937,18 +937,18 @@ namespace nana
|
||||
::nana::spinbox wdg_year;
|
||||
};
|
||||
|
||||
inputbox::date::date(::nana::string label)
|
||||
inputbox::date::date(::std::string label)
|
||||
: impl_(new implement)
|
||||
{
|
||||
impl_->label_text = std::move(label);
|
||||
impl_->label_text.swap(label);
|
||||
}
|
||||
|
||||
//Instance for impl_ because implmenet is incomplete type at the point of declaration
|
||||
inputbox::date::~date(){}
|
||||
|
||||
::nana::string inputbox::date::value() const
|
||||
::std::string inputbox::date::value() const
|
||||
{
|
||||
return std::to_wstring(impl_->month) + L'-' + std::to_wstring(impl_->day) + L", " + std::to_wstring(impl_->year);
|
||||
return std::to_string(impl_->month) + '-' + std::to_string(impl_->day) + ", " + std::to_string(impl_->year);
|
||||
}
|
||||
|
||||
int inputbox::date::year() const
|
||||
@ -974,7 +974,7 @@ namespace nana
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::date::label() const
|
||||
const ::std::string& inputbox::date::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
@ -1009,8 +1009,8 @@ namespace nana
|
||||
|
||||
impl->wdg_month.option(today.month - 1);
|
||||
|
||||
impl->wdg_day.value(std::to_wstring(today.day));
|
||||
impl->wdg_year.value(std::to_wstring(today.year));
|
||||
impl->wdg_day.value(std::to_string(today.day));
|
||||
impl->wdg_year.value(std::to_string(today.year));
|
||||
|
||||
impl->dock.events().resized.connect_unignorable([impl, label_px](const ::nana::arg_resized& arg)
|
||||
{
|
||||
@ -1051,7 +1051,7 @@ namespace nana
|
||||
if (day > days)
|
||||
day = days;
|
||||
|
||||
impl->wdg_day.value(std::to_wstring(day));
|
||||
impl->wdg_day.value(std::to_string(day));
|
||||
};
|
||||
|
||||
impl->wdg_year.events().text_changed.connect_unignorable(make_days);
|
||||
@ -1071,19 +1071,21 @@ namespace nana
|
||||
{
|
||||
filebox fbox;
|
||||
|
||||
::nana::string value;
|
||||
::nana::string label_text;
|
||||
::std::string value;
|
||||
::std::string label_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::textbox path_edit;
|
||||
::nana::button browse;
|
||||
|
||||
implement(const filebox& fb, ::nana::string&& labelstr)
|
||||
implement(const filebox& fb, ::std::string&& labelstr)
|
||||
: fbox(fb), label_text(std::move(labelstr))
|
||||
{}
|
||||
{
|
||||
throw_not_utf8(label_text);
|
||||
}
|
||||
};
|
||||
|
||||
inputbox::path::path(::nana::string label, const filebox& fb)
|
||||
inputbox::path::path(::std::string label, const filebox& fb)
|
||||
: impl_(new implement(fb, std::move(label)))
|
||||
{
|
||||
}
|
||||
@ -1091,7 +1093,7 @@ namespace nana
|
||||
//Instance for impl_ because implmenet is incomplete type at the point of declaration
|
||||
inputbox::path::~path(){}
|
||||
|
||||
::nana::string inputbox::path::value() const
|
||||
::std::string inputbox::path::value() const
|
||||
{
|
||||
if (!impl_->path_edit.empty())
|
||||
return impl_->path_edit.caption();
|
||||
@ -1100,7 +1102,7 @@ namespace nana
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::path::label() const
|
||||
const ::std::string& inputbox::path::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
@ -1148,7 +1150,7 @@ namespace nana
|
||||
//end class path
|
||||
|
||||
|
||||
inputbox::inputbox(window owner, ::nana::string desc, ::nana::string title)
|
||||
inputbox::inputbox(window owner, ::std::string desc, ::std::string title)
|
||||
: owner_{ owner },
|
||||
description_(std::move(desc)),
|
||||
title_(std::move(title))
|
||||
|
||||
@ -299,10 +299,10 @@ namespace nana
|
||||
impl_->native_handle = nullptr;
|
||||
}
|
||||
|
||||
void notifier::text(const nana::string& str)
|
||||
void notifier::text(const std::string& str)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
NOTIFYICONDATA icon_data;
|
||||
NOTIFYICONDATAW icon_data;
|
||||
memset(&icon_data, 0, sizeof icon_data);
|
||||
icon_data.cbSize = sizeof icon_data;
|
||||
icon_data.hWnd = reinterpret_cast<HWND>(impl_->native_handle);
|
||||
@ -310,18 +310,18 @@ namespace nana
|
||||
icon_data.uFlags = NIF_MESSAGE | NIF_TIP;
|
||||
icon_data.uCallbackMessage = nana::detail::messages::tray;
|
||||
|
||||
strcpy(icon_data.szTip, str.data());
|
||||
std::wcscpy(icon_data.szTip, to_wstring(str).c_str());
|
||||
|
||||
::Shell_NotifyIcon(impl_->icon_added ? NIM_MODIFY : NIM_ADD, &icon_data);
|
||||
impl_->icon_added = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void notifier::icon(const nana::string& icon_file)
|
||||
void notifier::icon(const std::string& icon_file)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
auto pre_icon = impl_->icon_handle;
|
||||
auto ico = (HICON)::LoadImage(0, icon_file.data(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
||||
auto ico = (HICON)::LoadImageW(0, to_wstring(icon_file).data(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
||||
if (ico)
|
||||
{
|
||||
impl_->icon_handle = ico;
|
||||
@ -333,10 +333,10 @@ namespace nana
|
||||
#endif
|
||||
}
|
||||
|
||||
void notifier::insert_icon(const nana::string& icon_file)
|
||||
void notifier::insert_icon(const std::string& icon_file)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
auto icon = (HICON)::LoadImage(0, icon_file.data(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
||||
auto icon = (HICON)::LoadImage(0, to_wstring(icon_file).data(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
||||
impl_->icons.push_back(icon);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -534,12 +534,12 @@ namespace nana
|
||||
});
|
||||
}
|
||||
|
||||
field_interface& operator<<(const nana::char_t* label_text) override
|
||||
field_interface& operator<<(const char* label_text) override
|
||||
{
|
||||
return static_cast<field_interface*>(this)->operator<<(agent<label>(label_text ? label_text : L""));
|
||||
return static_cast<field_interface*>(this)->operator<<(agent<label>(label_text ? label_text : ""));
|
||||
}
|
||||
|
||||
virtual field_interface& operator<<(nana::string label_text) override
|
||||
field_interface& operator<<(std::string label_text) override
|
||||
{
|
||||
return static_cast<field_interface*>(this)->operator<<(agent<label>(label_text));
|
||||
}
|
||||
@ -1009,7 +1009,7 @@ namespace nana
|
||||
|
||||
auto find_lowest = [&revises](double level_px)
|
||||
{
|
||||
double v = std::numeric_limits<double>::max();
|
||||
double v = (std::numeric_limits<double>::max)();
|
||||
for (auto i = revises.begin(); i != revises.end(); ++i)
|
||||
{
|
||||
if (i->min_px >= 0 && i->min_px < v && i->min_px > level_px)
|
||||
|
||||
@ -79,12 +79,11 @@ namespace nana
|
||||
|
||||
void refresh(graph_reference& graph) override
|
||||
{
|
||||
graph.set_color(static_cast<color_rgb>(0x83EB));
|
||||
graph.set_text_color(colors::white);
|
||||
graph.rectangle(true);
|
||||
graph.palette(true, colors::white);
|
||||
graph.rectangle(true, static_cast<color_rgb>(0x83EB));
|
||||
|
||||
//draw caption
|
||||
auto text = API::window_caption(window_handle_);
|
||||
auto text = utf8_cast(API::window_caption(window_handle_));
|
||||
text_rd_->render({ 3, 1 }, text.data(), text.size(), graph.size().width - 20, true);
|
||||
|
||||
//draw x button
|
||||
@ -300,7 +299,7 @@ namespace nana
|
||||
if (handle)
|
||||
caption_.caption(API::window_caption(handle));
|
||||
else
|
||||
caption_.caption(::nana::string());
|
||||
caption_.caption(::std::string());
|
||||
});
|
||||
|
||||
tabbar_->move({ 0, r.bottom() - 20, r.width, 20 });
|
||||
|
||||
@ -220,7 +220,7 @@ namespace API
|
||||
}
|
||||
}
|
||||
|
||||
nana::string window_caption(window wd) throw()
|
||||
::nana::detail::native_string_type window_caption(window wd) throw()
|
||||
{
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard isg;
|
||||
@ -234,7 +234,7 @@ namespace API
|
||||
return {};
|
||||
}
|
||||
|
||||
void window_caption(window wd, nana::string title)
|
||||
void window_caption(window wd, ::nana::detail::native_string_type title)
|
||||
{
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
@ -280,6 +280,33 @@ namespace API
|
||||
{
|
||||
restrict::bedrock.delay_restore(enable ? 0 : 1);
|
||||
}
|
||||
|
||||
void register_menu_window(window wd, bool has_keyboard)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd)))
|
||||
restrict::bedrock.set_menu(reinterpret_cast<basic_window*>(wd)->root, has_keyboard);
|
||||
}
|
||||
|
||||
void set_menubar(window wd, bool attach)
|
||||
{
|
||||
auto iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(iwd))
|
||||
{
|
||||
auto root_attr = iwd->root_widget->other.attribute.root;
|
||||
if (attach)
|
||||
{
|
||||
if (!root_attr->menubar)
|
||||
root_attr->menubar = iwd;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iwd == root_attr->menubar)
|
||||
root_attr->menubar = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}//end namespace dev
|
||||
|
||||
|
||||
@ -336,19 +363,19 @@ namespace API
|
||||
//@param, text: the text is transformed.
|
||||
//@param, shortkey: the character which indicates a short key.
|
||||
//@param, skpos: retrives the shortkey position if it is not a null_ptr;
|
||||
nana::string transform_shortkey_text(nana::string text, nana::string::value_type &shortkey, nana::string::size_type *skpos)
|
||||
std::string transform_shortkey_text(std::string text, wchar_t &shortkey, std::string::size_type *skpos)
|
||||
{
|
||||
shortkey = 0;
|
||||
nana::string::size_type off = 0;
|
||||
std::string::size_type off = 0;
|
||||
while(true)
|
||||
{
|
||||
nana::string::size_type pos = text.find_first_of('&', off);
|
||||
if(pos != nana::string::npos)
|
||||
auto pos = text.find_first_of('&', off);
|
||||
if(pos != std::wstring::npos)
|
||||
{
|
||||
text.erase(pos, 1);
|
||||
if(shortkey == 0 && pos < text.length())
|
||||
{
|
||||
shortkey = text.at(pos);
|
||||
shortkey = utf::char_at(text.c_str() + pos, 0, nullptr);
|
||||
if(shortkey == '&') //This indicates the text contains "&&", it means the symbol have to be ignored.
|
||||
shortkey = 0;
|
||||
else if(skpos)
|
||||
@ -819,23 +846,27 @@ namespace API
|
||||
|
||||
void window_caption(window wd, const std::string& title_utf8)
|
||||
{
|
||||
window_caption(wd, std::wstring(::nana::charset(title_utf8, ::nana::unicode::utf8)));
|
||||
throw_not_utf8(title_utf8);
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(iwd))
|
||||
iwd->widget_notifier->caption(to_nstring(title_utf8));
|
||||
}
|
||||
|
||||
void window_caption(window wd, const nana::string& title)
|
||||
void window_caption(window wd, const std::wstring& title)
|
||||
{
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(iwd))
|
||||
iwd->widget_notifier->caption(title);
|
||||
iwd->widget_notifier->caption(to_nstring(title));
|
||||
}
|
||||
|
||||
nana::string window_caption(window wd)
|
||||
std::string window_caption(window wd)
|
||||
{
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(iwd))
|
||||
return iwd->widget_notifier->caption();
|
||||
return to_utf8(iwd->widget_notifier->caption());
|
||||
|
||||
return{};
|
||||
}
|
||||
@ -1137,6 +1168,7 @@ namespace API
|
||||
return reinterpret_cast<window>(ts_wd);
|
||||
}
|
||||
|
||||
/*
|
||||
//glass_window deprecated
|
||||
//@brief: Test a window whether it is a glass attribute.
|
||||
bool glass_window(window wd)
|
||||
@ -1152,6 +1184,7 @@ namespace API
|
||||
effects_bground_remove(wd);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
void take_active(window wd, bool active, window take_if_active_false)
|
||||
{
|
||||
@ -1243,36 +1276,6 @@ namespace API
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void register_menu_window(window wd, bool has_keyboard)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if(restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd)))
|
||||
restrict::bedrock.set_menu(reinterpret_cast<basic_window*>(wd)->root, has_keyboard);
|
||||
}
|
||||
|
||||
bool attach_menubar(window menubar)
|
||||
{
|
||||
auto iwd = reinterpret_cast<basic_window*>(menubar);
|
||||
internal_scope_guard lock;
|
||||
if(restrict::wd_manager().available(iwd) && (nullptr == iwd->root_widget->other.attribute.root->menubar))
|
||||
{
|
||||
iwd->root_widget->other.attribute.root->menubar = iwd;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void detach_menubar(window menubar)
|
||||
{
|
||||
auto iwd = reinterpret_cast<basic_window*>(menubar);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::wd_manager().available(iwd))
|
||||
{
|
||||
if (iwd->root_widget->other.attribute.root->menubar == iwd)
|
||||
iwd->root_widget->other.attribute.root->menubar = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_window_zoomed(window wd, bool ask_for_max)
|
||||
{
|
||||
auto const iwd = reinterpret_cast<basic_window*>(wd);
|
||||
|
||||
@ -75,7 +75,7 @@ namespace nana
|
||||
return this->empty();
|
||||
}
|
||||
|
||||
void tooltip_text(const nana::string& text) override
|
||||
void tooltip_text(const std::string& text) override
|
||||
{
|
||||
label_.caption(text);
|
||||
auto text_s = label_.measure(screen().from_window(label_).workarea().width * 2 / 3);
|
||||
@ -157,7 +157,7 @@ namespace nana
|
||||
|
||||
class controller
|
||||
{
|
||||
typedef std::pair<window, nana::string> pair_t;
|
||||
typedef std::pair<window, std::string> pair_t;
|
||||
|
||||
typedef std::function<void(tooltip_interface*)> deleter_type;
|
||||
|
||||
@ -202,7 +202,7 @@ namespace nana
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void set(window wd, const nana::string& str)
|
||||
void set(window wd, const std::string& str)
|
||||
{
|
||||
if (str.empty())
|
||||
_m_untip(wd);
|
||||
@ -210,7 +210,7 @@ namespace nana
|
||||
_m_get(wd).second = str;
|
||||
}
|
||||
|
||||
void show(const nana::string& text)
|
||||
void show(const std::string& text)
|
||||
{
|
||||
if (nullptr == window_ || window_->tooltip_empty())
|
||||
{
|
||||
@ -227,7 +227,7 @@ namespace nana
|
||||
window_->tooltip_move(API::cursor_position(), true);
|
||||
}
|
||||
|
||||
void show_duration(window wd, point pos, const nana::string& text, std::size_t duration)
|
||||
void show_duration(window wd, point pos, const std::string& text, std::size_t duration)
|
||||
{
|
||||
if (nullptr == window_ || window_->tooltip_empty())
|
||||
{
|
||||
@ -298,7 +298,7 @@ namespace nana
|
||||
_m_untip(arg.window_handle);
|
||||
});
|
||||
|
||||
cont_.emplace_back(wd, nana::string());
|
||||
cont_.emplace_back(wd, std::string());
|
||||
return cont_.back();
|
||||
}
|
||||
private:
|
||||
@ -311,7 +311,7 @@ namespace nana
|
||||
//class tooltip
|
||||
typedef drawerbase::tooltip::controller ctrl;
|
||||
|
||||
void tooltip::set(window wd, const nana::string& text)
|
||||
void tooltip::set(window wd, const std::string& text)
|
||||
{
|
||||
if(false == API::empty_window(wd))
|
||||
{
|
||||
@ -320,7 +320,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void tooltip::show(window wd, point pos, const nana::string& text, std::size_t duration)
|
||||
void tooltip::show(window wd, point pos, const std::string& text, std::size_t duration)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
API::calc_screen_point(wd, pos);
|
||||
|
||||
@ -164,13 +164,13 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void trigger::key_char(graph_reference, const arg_keyboard& arg)
|
||||
{
|
||||
if (static_cast<char_t>(keyboard::enter) == arg.key)
|
||||
if (static_cast<wchar_t>(keyboard::enter) == arg.key)
|
||||
emit_click();
|
||||
}
|
||||
|
||||
void trigger::key_press(graph_reference graph, const arg_keyboard& arg)
|
||||
{
|
||||
if (keyboard::space == static_cast<char_t>(arg.key))
|
||||
if (keyboard::space == static_cast<wchar_t>(arg.key))
|
||||
{
|
||||
_m_press(graph, true);
|
||||
return;
|
||||
@ -193,7 +193,7 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void trigger::key_release(graph_reference graph, const arg_keyboard& arg)
|
||||
{
|
||||
if (arg.key != static_cast<char_t>(keyboard::space))
|
||||
if (arg.key != static_cast<wchar_t>(keyboard::space))
|
||||
return;
|
||||
|
||||
emit_click();
|
||||
@ -212,11 +212,10 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void trigger::_m_draw_title(graph_reference graph, bool enabled)
|
||||
{
|
||||
nana::string text = wdg_->caption();
|
||||
|
||||
nana::string::value_type shortkey;
|
||||
nana::string::size_type shortkey_pos;
|
||||
nana::string str = API::transform_shortkey_text(text, shortkey, &shortkey_pos);
|
||||
wchar_t shortkey;
|
||||
std::string::size_type shortkey_pos;
|
||||
std::string mbstr = API::transform_shortkey_text(wdg_->caption(), shortkey, &shortkey_pos);
|
||||
std::wstring str = to_wstring(mbstr);
|
||||
|
||||
nana::size ts = graph.text_extent_size(str);
|
||||
nana::size gsize = graph.size();
|
||||
@ -237,7 +236,7 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
unsigned omitted_pixels = gsize.width - icon_sz.width;
|
||||
std::size_t txtlen = str.size();
|
||||
const nana::char_t* txtptr = str.c_str();
|
||||
const auto txtptr = str.c_str();
|
||||
if(ts.width)
|
||||
{
|
||||
nana::paint::text_renderer tr(graph);
|
||||
@ -249,7 +248,7 @@ namespace nana{ namespace drawerbase
|
||||
++pos.y;
|
||||
}
|
||||
|
||||
graph.set_text_color(attr_.focus_color && attr_.focused ? ::nana::color(colors::blue) : attr_.fgcolor);
|
||||
graph.palette(true, attr_.focus_color && attr_.focused ? ::nana::color(colors::blue) : attr_.fgcolor);
|
||||
|
||||
if (attr_.omitted)
|
||||
tr.render(pos, txtptr, txtlen, omitted_pixels, true);
|
||||
@ -258,27 +257,33 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
if(shortkey)
|
||||
{
|
||||
unsigned off_w = (shortkey_pos ? graph.text_extent_size(str, static_cast<unsigned>(shortkey_pos)).width : 0);
|
||||
nana::size shortkey_size = graph.text_extent_size(txtptr + shortkey_pos, 1);
|
||||
unsigned off_w = (shortkey_pos ? graph.text_extent_size(mbstr.c_str(), static_cast<unsigned>(shortkey_pos)).width : 0);
|
||||
|
||||
wchar_t keystr[2] = {nana::utf::char_at(mbstr.c_str() + shortkey_pos, 0, 0), 0};
|
||||
auto shortkey_size = graph.text_extent_size(keystr, 1);
|
||||
|
||||
unsigned ascent, descent, inleading;
|
||||
graph.text_metrics(ascent, descent, inleading);
|
||||
|
||||
pos.x += off_w;
|
||||
pos.y += static_cast<int>(shortkey_size.height);
|
||||
graph.set_color(colors::black);
|
||||
graph.line(pos, point{ pos.x + static_cast<int>(shortkey_size.width) - 1, pos.y });
|
||||
pos.y += static_cast<int>(ascent + 2);
|
||||
|
||||
graph.line(pos, point{ pos.x + static_cast<int>(shortkey_size.width) - 1, pos.y }, colors::black);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.set_text_color(::nana::color(colors::white));
|
||||
graph.palette(true, ::nana::color(colors::white));
|
||||
if(attr_.omitted)
|
||||
{
|
||||
tr.render(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen, omitted_pixels, true);
|
||||
graph.set_text_color(::nana::color(colors::gray));
|
||||
graph.palette(true, ::nana::color(colors::gray));
|
||||
tr.render(pos, txtptr, txtlen, omitted_pixels, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.bidi_string(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen);
|
||||
graph.set_text_color(::nana::color(colors::gray));
|
||||
graph.palette(true, ::nana::color(colors::gray));
|
||||
graph.bidi_string(pos, txtptr, txtlen);
|
||||
}
|
||||
}
|
||||
@ -319,10 +324,10 @@ namespace nana{ namespace drawerbase
|
||||
::nana::color lt(static_cast<color_rgb>(0x7f7f7f)), rb(static_cast<color_rgb>(0x707070));
|
||||
graph.frame_rectangle(r, lt, lt, rb, rb);
|
||||
|
||||
graph.set_color(colors::button_face);
|
||||
graph.palette(false, colors::button_face);
|
||||
draw_corner_point(graph, r);
|
||||
|
||||
graph.set_color(static_cast<color_rgb>(0x919191));
|
||||
graph.palette(false, static_cast<color_rgb>(0x919191));
|
||||
draw_corner_point(graph, r.pare_off(1));
|
||||
|
||||
if (element_state::pressed == attr_.e_state)
|
||||
@ -398,13 +403,13 @@ namespace nana{ namespace drawerbase
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
button::button(window wd, const nana::string& text, bool visible)
|
||||
button::button(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
button::button(window wd, const nana::char_t* text, bool visible)
|
||||
button::button(window wd, const char* text, bool visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
@ -509,16 +514,18 @@ namespace nana{ namespace drawerbase
|
||||
});
|
||||
}
|
||||
|
||||
void button::_m_caption(nana::string&& text)
|
||||
void button::_m_caption(native_string_type&& text)
|
||||
{
|
||||
API::unregister_shortkey(handle());
|
||||
|
||||
nana::char_t shortkey;
|
||||
API::transform_shortkey_text(text, shortkey, 0);
|
||||
native_string_type ntext = std::move(text);
|
||||
|
||||
wchar_t shortkey;
|
||||
API::transform_shortkey_text(to_utf8(ntext), shortkey, nullptr);
|
||||
if (shortkey)
|
||||
API::register_shortkey(handle(), shortkey);
|
||||
|
||||
base_type::_m_caption(std::move(text));
|
||||
base_type::_m_caption(std::move(ntext));
|
||||
}
|
||||
//end class button
|
||||
}//end namespace nana
|
||||
|
||||
@ -32,9 +32,9 @@ namespace nana
|
||||
: public float_listbox::item_interface
|
||||
{
|
||||
nana::paint::image item_image;
|
||||
nana::string item_text;
|
||||
std::string item_text;
|
||||
public:
|
||||
item(const nana::string& s)
|
||||
item(const std::string& s)
|
||||
: item_text(s)
|
||||
{}
|
||||
public:
|
||||
@ -44,7 +44,7 @@ namespace nana
|
||||
return item_image;
|
||||
}
|
||||
|
||||
const nana::char_t * text() const override
|
||||
const char * text() const override
|
||||
{
|
||||
return item_text.data();
|
||||
}
|
||||
@ -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)
|
||||
{
|
||||
@ -191,12 +191,12 @@ namespace nana
|
||||
int bottom = y + height - 1;
|
||||
int right = x + width - 1;
|
||||
|
||||
graph.set_color(static_cast<color_rgb>(0x6E8D9F));
|
||||
graph.palette(false, static_cast<color_rgb>(0x6E8D9F));
|
||||
graph.line(point{ x, y }, point{right, y});
|
||||
graph.line(point{ x, y + 1 }, point{ x, bottom });
|
||||
++x;
|
||||
++y;
|
||||
graph.set_color(color(0xa6, 0xc7, 0xd9));
|
||||
graph.palette(false, color(0xa6, 0xc7, 0xd9));
|
||||
graph.line(point{ x, y }, point{ right, y });
|
||||
graph.line(point{ x, y + 1 }, point{ x, bottom });
|
||||
}
|
||||
@ -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(), tree().path());
|
||||
API::dev::window_caption(window_handle(), to_nstring(tree().path()));
|
||||
if(evt_holder_.selected)
|
||||
evt_holder_.selected(node->value.second.value);
|
||||
}
|
||||
@ -603,8 +603,7 @@ namespace nana
|
||||
case ui_element::item_arrow:
|
||||
{
|
||||
treebase_.tail(style_.active);
|
||||
nana::string name = 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_;
|
||||
@ -805,14 +803,15 @@ namespace nana
|
||||
delete scheme_;
|
||||
}
|
||||
|
||||
void trigger::insert(const nana::string& str, nana::any value)
|
||||
void trigger::insert(const std::string& str, nana::any value)
|
||||
{
|
||||
throw_not_utf8(str);
|
||||
scheme_->tree().insert(str, value);
|
||||
API::dev::window_caption(scheme_->window_handle(), scheme_->tree().path());
|
||||
API::dev::window_caption(scheme_->window_handle(), to_nstring(scheme_->tree().path()));
|
||||
scheme_->draw();
|
||||
}
|
||||
|
||||
bool trigger::childset(const nana::string& str, nana::any value)
|
||||
bool trigger::childset(const std::string& str, nana::any value)
|
||||
{
|
||||
if(scheme_->tree().childset(str, value))
|
||||
{
|
||||
@ -822,7 +821,7 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
bool trigger::childset_erase(const nana::string& str)
|
||||
bool trigger::childset_erase(const std::string& str)
|
||||
{
|
||||
if(scheme_->tree().childset_erase(str))
|
||||
{
|
||||
@ -842,22 +841,22 @@ 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 nana::string& str)
|
||||
void trigger::path(const std::string& str)
|
||||
{
|
||||
scheme_->tree().path(str);
|
||||
}
|
||||
|
||||
nana::string trigger::path() const
|
||||
std::string trigger::path() const
|
||||
{
|
||||
return scheme_->tree().path();
|
||||
}
|
||||
|
||||
@ -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&)
|
||||
@ -98,19 +98,19 @@ namespace checkbox
|
||||
{
|
||||
if (graph.width() > 16 + interval)
|
||||
{
|
||||
nana::string title = widget_->caption();
|
||||
std::wstring title = ::nana::charset(widget_->caption(), ::nana::unicode::utf8);
|
||||
|
||||
unsigned pixels = graph.width() - (16 + interval);
|
||||
|
||||
nana::paint::text_renderer tr(graph);
|
||||
if (API::window_enabled(widget_->handle()) == false)
|
||||
{
|
||||
graph.set_text_color(colors::white);
|
||||
graph.palette(true, colors::white);
|
||||
tr.render({ 17 + interval, 2 }, title.c_str(), title.length(), pixels);
|
||||
graph.set_text_color({ 0x80, 0x80, 0x80 });
|
||||
graph.palette(true, { 0x80, 0x80, 0x80 });
|
||||
}
|
||||
else
|
||||
graph.set_text_color(widget_->fgcolor());
|
||||
graph.palette(true, widget_->fgcolor());
|
||||
|
||||
tr.render({ 16 + interval, 1 }, title.c_str(), title.length(), pixels);
|
||||
}
|
||||
@ -129,18 +129,16 @@ namespace checkbox
|
||||
bgcolor(API::bgcolor(wd));
|
||||
}
|
||||
|
||||
checkbox::checkbox(window wd, const nana::string& text, bool visible)
|
||||
checkbox::checkbox(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
bgcolor(API::bgcolor(wd));
|
||||
caption(text);
|
||||
}
|
||||
|
||||
checkbox::checkbox(window wd, const nana::char_t* text, bool visible)
|
||||
checkbox::checkbox(window wd, const char* text, bool visible)
|
||||
: checkbox(wd, std::string(text), visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
bgcolor(API::bgcolor(wd));
|
||||
caption(text);
|
||||
}
|
||||
|
||||
checkbox::checkbox(window wd, const nana::rectangle& r, bool visible)
|
||||
|
||||
@ -54,7 +54,7 @@ namespace nana
|
||||
std::shared_ptr<nana::detail::key_interface> key;
|
||||
|
||||
nana::paint::image item_image;
|
||||
nana::string item_text;
|
||||
std::string item_text;
|
||||
mutable std::shared_ptr<nana::any> any_ptr;
|
||||
|
||||
item(std::shared_ptr<nana::detail::key_interface> && kv)
|
||||
@ -62,7 +62,7 @@ namespace nana
|
||||
{
|
||||
}
|
||||
|
||||
item(nana::string&& s)
|
||||
item(std::string&& s)
|
||||
: item_text(std::move(s))
|
||||
{}
|
||||
private:
|
||||
@ -72,7 +72,7 @@ namespace nana
|
||||
return item_image;
|
||||
}
|
||||
|
||||
const nana::char_t* text() const override
|
||||
const char* text() const override
|
||||
{
|
||||
return item_text.data();
|
||||
}
|
||||
@ -120,7 +120,7 @@ namespace nana
|
||||
graph_ = nullptr;
|
||||
}
|
||||
|
||||
void insert(nana::string&& text)
|
||||
void insert(std::string&& text)
|
||||
{
|
||||
items_.emplace_back(std::make_shared<item>(std::move(text)));
|
||||
API::refresh_window(widget_->handle());
|
||||
@ -338,7 +338,7 @@ namespace nana
|
||||
if (calc_where(*graph_, pos.x, pos.y))
|
||||
state_.button_state = element_state::normal;
|
||||
|
||||
editor_->text(items_[index]->item_text);
|
||||
editor_->text(::nana::charset(items_[index]->item_text, ::nana::unicode::utf8));
|
||||
_m_draw_push_button(widget_->enabled());
|
||||
_m_draw_image();
|
||||
|
||||
@ -398,7 +398,7 @@ namespace nana
|
||||
if (pos == module_.index)
|
||||
{
|
||||
module_.index = ::nana::npos;
|
||||
this->widget_->caption(L"");
|
||||
this->widget_->caption("");
|
||||
}
|
||||
else if ((::nana::npos != module_.index) && (pos < module_.index))
|
||||
--module_.index;
|
||||
@ -731,13 +731,14 @@ namespace nana
|
||||
pos_(pos)
|
||||
{}
|
||||
|
||||
item_proxy& item_proxy::text(const nana::string& s)
|
||||
item_proxy& item_proxy::text(const ::std::string& s)
|
||||
{
|
||||
throw_not_utf8(s);
|
||||
impl_->at(pos_).item_text = s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
nana::string item_proxy::text() const
|
||||
::std::string item_proxy::text() const
|
||||
{
|
||||
return impl_->at(pos_).item_text;
|
||||
}
|
||||
@ -767,7 +768,7 @@ namespace nana
|
||||
}
|
||||
|
||||
/// Behavior of Iterator's value_type
|
||||
bool item_proxy::operator == (const nana::string& s) const
|
||||
bool item_proxy::operator == (const ::std::string& s) const
|
||||
{
|
||||
if (pos_ == nana::npos)
|
||||
return false;
|
||||
@ -778,17 +779,10 @@ namespace nana
|
||||
{
|
||||
if (pos_ == nana::npos)
|
||||
return false;
|
||||
return (impl_->at(pos_).item_text == static_cast<nana::string>(nana::charset(s, nana::unicode::utf8)));
|
||||
}
|
||||
|
||||
bool item_proxy::operator == (const wchar_t * s) const
|
||||
{
|
||||
if (pos_ == nana::npos)
|
||||
return false;
|
||||
|
||||
return (impl_->at(pos_).item_text == s);
|
||||
}
|
||||
|
||||
|
||||
/// Behavior of Iterator
|
||||
item_proxy & item_proxy::operator=(const item_proxy& r)
|
||||
{
|
||||
@ -876,16 +870,16 @@ namespace nana
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
combox::combox(window wd, nana::string text, bool visible)
|
||||
combox::combox(window wd, std::string text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(std::move(text));
|
||||
}
|
||||
|
||||
combox::combox(window wd, const nana::char_t* text, bool visible)
|
||||
combox::combox(window wd, const char* text, bool visible)
|
||||
: combox(wd, std::string(text), visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
combox::combox(window wd, const nana::rectangle& r, bool visible)
|
||||
@ -912,7 +906,7 @@ namespace nana
|
||||
return _m_impl().editable();
|
||||
}
|
||||
|
||||
void combox::set_accept(std::function<bool(nana::char_t)> pred)
|
||||
void combox::set_accept(std::function<bool(wchar_t)> pred)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = _m_impl().editor();
|
||||
@ -920,7 +914,7 @@ namespace nana
|
||||
editor->set_accept(std::move(pred));
|
||||
}
|
||||
|
||||
combox& combox::push_back(nana::string text)
|
||||
combox& combox::push_back(std::string text)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
_m_impl().insert(std::move(text));
|
||||
@ -946,7 +940,7 @@ namespace nana
|
||||
API::update_window(handle());
|
||||
}
|
||||
|
||||
nana::string combox::text(std::size_t pos) const
|
||||
::std::string combox::text(std::size_t pos) const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
return _m_impl().at(pos).item_text;
|
||||
@ -988,20 +982,22 @@ namespace nana
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
nana::string combox::_m_caption() const throw()
|
||||
auto combox::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = _m_impl().editor();
|
||||
return (editor ? editor->text() : nana::string());
|
||||
if (editor)
|
||||
return to_nstring(editor->text());
|
||||
return native_string_type();
|
||||
}
|
||||
|
||||
void combox::_m_caption(nana::string&& str)
|
||||
void combox::_m_caption(native_string_type&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
|
||||
auto editor = _m_impl().editor();
|
||||
if (editor)
|
||||
editor->text(std::move(str));
|
||||
editor->text(to_wstring(str));
|
||||
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ namespace nana
|
||||
trigger::trigger()
|
||||
: widget_(nullptr), chose_(false), page_(page::date), pos_(where::none)
|
||||
{
|
||||
const nana::string ws[] = {STR("S"), STR("M"), STR("T"), STR("W"), STR("T"), STR("F"), STR("S")};
|
||||
const std::string ws[] = {"S", "M", "T", "W", "T", "F", "S"};
|
||||
for(int i = 0; i < 7; ++i) weekstr_[i] = ws[i];
|
||||
|
||||
nana::date d;
|
||||
@ -50,8 +50,9 @@ namespace nana
|
||||
return nana::date(chdate_.year, chdate_.month, chdate_.day);
|
||||
}
|
||||
|
||||
void trigger::week_name(unsigned index, const nana::string& str)
|
||||
void trigger::week_name(unsigned index, const std::string& str)
|
||||
{
|
||||
throw_not_utf8(str);
|
||||
if(index < 7)
|
||||
this->weekstr_[index] = str;
|
||||
}
|
||||
@ -95,13 +96,13 @@ namespace nana
|
||||
|
||||
if(graph.width() > 32 + border_size * 2)
|
||||
{
|
||||
nana::string str;
|
||||
std::string str;
|
||||
if(page_ == page::date)
|
||||
{
|
||||
str = ::nana::internationalization()(monthstr[chmonth_.month - 1]);
|
||||
str += STR(" ");
|
||||
str += " ";
|
||||
}
|
||||
str += std::to_wstring(chmonth_.year);
|
||||
str += std::to_string(chmonth_.year);
|
||||
|
||||
nana::size txt_s = graph.text_extent_size(str);
|
||||
|
||||
@ -134,7 +135,7 @@ namespace nana
|
||||
dbasis_ = dbasis;
|
||||
}
|
||||
|
||||
void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, const nana::string& str, bool primary, bool sel)
|
||||
void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, const std::string& str_utf8, bool primary, bool sel)
|
||||
{
|
||||
nana::rectangle r(static_cast<int>(x * dbasis.row_s), static_cast<int>(y * dbasis.line_s),
|
||||
static_cast<int>(dbasis.row_s), static_cast<int>(dbasis.line_s));
|
||||
@ -165,13 +166,13 @@ namespace nana
|
||||
if(false == primary)
|
||||
color = { 0xB0, 0xB0, 0xB0 };
|
||||
|
||||
nana::size txt_s = graph.text_extent_size(str);
|
||||
graph.string({ r.x + static_cast<int>(r.width - txt_s.width) / 2, r.y + static_cast<int>(r.height - txt_s.height) / 2 }, str, color);
|
||||
auto txt_s = graph.text_extent_size(str_utf8);
|
||||
graph.string({ r.x + static_cast<int>(r.width - txt_s.width) / 2, r.y + static_cast<int>(r.height - txt_s.height) / 2 }, str_utf8, color);
|
||||
}
|
||||
|
||||
void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, int number, bool primary, bool sel)
|
||||
{
|
||||
_m_draw_pos(dbasis, graph, x, y, std::to_wstring(number), primary, sel);
|
||||
_m_draw_pos(dbasis, graph, x, y, std::to_string(number), primary, sel);
|
||||
}
|
||||
|
||||
void trigger::_m_draw_ex_days(drawing_basis & dbasis, graph_reference graph, int begx, int begy, bool before)
|
||||
@ -615,16 +616,16 @@ namespace nana
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
date_chooser::date_chooser(window wd, const nana::string& text, bool visible)
|
||||
date_chooser::date_chooser(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
date_chooser::date_chooser(window wd, const nana::char_t* text, bool visible)
|
||||
date_chooser::date_chooser(window wd, const char* text, bool visible)
|
||||
: date_chooser(wd, std::string(text), visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
date_chooser::date_chooser(window wd, const rectangle& r, bool visible)
|
||||
@ -642,7 +643,7 @@ namespace nana
|
||||
return get_drawer_trigger().read();
|
||||
}
|
||||
|
||||
void date_chooser::weekstr(unsigned index, const nana::string& str)
|
||||
void date_chooser::weekstr(unsigned index, const ::std::string& str)
|
||||
{
|
||||
get_drawer_trigger().week_name(index, str);
|
||||
API::refresh_window(*this);
|
||||
|
||||
@ -39,7 +39,7 @@ namespace nana
|
||||
|
||||
auto right = r.right() - 1;
|
||||
auto bottom = r.bottom() - 1;
|
||||
graph.set_color(colors::white);
|
||||
graph.palette(false, colors::white);
|
||||
graph.set_pixel(r.x, r.y);
|
||||
graph.set_pixel(right, r.y);
|
||||
graph.set_pixel(r.x, bottom);
|
||||
@ -47,7 +47,7 @@ namespace nana
|
||||
|
||||
--right;
|
||||
--bottom;
|
||||
graph.set_color(clr);
|
||||
graph.palette(false, clr);
|
||||
graph.set_pixel(r.x + 1, r.y + 1);
|
||||
graph.set_pixel(right, r.y + 1);
|
||||
graph.set_pixel(r.x + 1, bottom);
|
||||
@ -103,13 +103,13 @@ namespace nana
|
||||
}
|
||||
x += (image_pixels_ + 2);
|
||||
}
|
||||
graph.set_text_color(colors::black);
|
||||
graph.string({ x, r.y + 2 }, item->text());
|
||||
|
||||
graph.string({ x, r.y + 2 }, item->text(), colors::black);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -41,7 +41,7 @@ namespace nana{
|
||||
|
||||
implement() = default;
|
||||
|
||||
implement(window grp_panel, ::nana::string titel, bool vsb, unsigned gap=2)
|
||||
implement(window grp_panel, ::std::string titel, bool vsb, unsigned gap=2)
|
||||
: caption (grp_panel, std::move(titel), vsb),
|
||||
place_content{grp_panel},
|
||||
gap{gap}
|
||||
@ -51,7 +51,7 @@ namespace nana{
|
||||
void create(window pnl)
|
||||
{
|
||||
caption.create(pnl);
|
||||
caption.caption(STR(""));
|
||||
caption.caption("");
|
||||
place_content.bind(pnl);
|
||||
|
||||
if (!radio_logic)
|
||||
@ -90,7 +90,7 @@ namespace nana{
|
||||
create(parent, r, vsb);
|
||||
}
|
||||
|
||||
group::group(window parent, ::nana::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb)
|
||||
group::group(window parent, ::std::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb)
|
||||
: panel(parent, r, vsb),
|
||||
impl_(new implement(*this, std::move(titel), vsb, gap))
|
||||
{
|
||||
@ -103,7 +103,7 @@ namespace nana{
|
||||
delete impl_->radio_logic;
|
||||
}
|
||||
|
||||
group& group::add_option(::nana::string text)
|
||||
group& group::add_option(std::string text)
|
||||
{
|
||||
_THROW_IF_EMPTY()
|
||||
|
||||
@ -234,12 +234,12 @@ namespace nana{
|
||||
_m_init();
|
||||
}
|
||||
|
||||
::nana::string group::_m_caption() const throw()
|
||||
auto group::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
return impl_->caption.caption();
|
||||
return impl_->caption.caption_native();
|
||||
}
|
||||
|
||||
void group::_m_caption(::nana::string&& str)
|
||||
void group::_m_caption(native_string_type&& str)
|
||||
{
|
||||
impl_->caption.caption(std::move(str));
|
||||
impl_->update_div();
|
||||
|
||||
@ -52,8 +52,8 @@ namespace nana
|
||||
struct traceable
|
||||
{
|
||||
nana::rectangle r;
|
||||
nana::string target;
|
||||
nana::string url;
|
||||
std::wstring target;
|
||||
std::wstring url;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -62,7 +62,7 @@ namespace nana
|
||||
typedef widgets::skeletons::fblock fblock;
|
||||
typedef widgets::skeletons::data data;
|
||||
|
||||
void parse(const nana::string& s)
|
||||
void parse(const std::wstring& s)
|
||||
{
|
||||
dstream_.parse(s, format_enabled_);
|
||||
}
|
||||
@ -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;
|
||||
@ -148,7 +148,7 @@ namespace nana
|
||||
graph.typeface(ft);
|
||||
}
|
||||
|
||||
bool find(int x, int y, nana::string& target, nana::string& url) const
|
||||
bool find(int x, int y, std::wstring& target, std::wstring& url) const
|
||||
{
|
||||
for (auto & t : traceable_)
|
||||
{
|
||||
@ -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;
|
||||
@ -259,7 +259,7 @@ namespace nana
|
||||
return fp->bold;
|
||||
}
|
||||
|
||||
const nana::string& _m_fontname(nana::widgets::skeletons::fblock* fp)
|
||||
const std::string& _m_fontname(nana::widgets::skeletons::fblock* fp)
|
||||
{
|
||||
while(fp->font.empty())
|
||||
{
|
||||
@ -274,13 +274,13 @@ namespace nana
|
||||
{
|
||||
if(fp != fblock_)
|
||||
{
|
||||
const nana::string& name = _m_fontname(fp);
|
||||
auto& name = _m_fontname(fp);
|
||||
auto fontsize = static_cast<unsigned>(_m_font_size(fp));
|
||||
bool bold = _m_bold(fp);
|
||||
|
||||
if((fontsize != font_.size()) || bold != font_.bold() || name != font_.name())
|
||||
{
|
||||
font_.make(name.data(), fontsize, bold);
|
||||
font_.make(name, fontsize, bold);
|
||||
graph.typeface(font_);
|
||||
}
|
||||
fblock_ = fp;
|
||||
@ -439,7 +439,7 @@ namespace nana
|
||||
|
||||
bool _m_each_line(graph_reference graph, dstream::linecontainer& line, render_status& rs)
|
||||
{
|
||||
nana::string text;
|
||||
std::wstring text;
|
||||
iterator block_start;
|
||||
|
||||
const int lastpos = static_cast<int>(graph.height()) - 1;
|
||||
@ -521,7 +521,7 @@ namespace nana
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _m_draw_block(graph_reference graph, const nana::string& s, dstream::linecontainer::iterator block_start, render_status& rs)
|
||||
void _m_draw_block(graph_reference graph, const std::wstring& s, dstream::linecontainer::iterator block_start, render_status& rs)
|
||||
{
|
||||
nana::unicode_bidi bidi;
|
||||
std::vector<nana::unicode_bidi::entity> reordered;
|
||||
@ -568,7 +568,7 @@ namespace nana
|
||||
}
|
||||
else
|
||||
{
|
||||
nana::string str = data_ptr->text().substr(text_range.first, text_range.second);
|
||||
auto str = data_ptr->text().substr(text_range.first, text_range.second);
|
||||
graph.string({ rs.pos.x, y }, str, _m_fgcolor(fblock_ptr));
|
||||
sz = graph.text_extent_size(str);
|
||||
}
|
||||
@ -606,7 +606,7 @@ namespace nana
|
||||
::nana::paint::font font_;
|
||||
struct def_font_tag
|
||||
{
|
||||
::nana::string font_name;
|
||||
::std::string font_name;
|
||||
std::size_t font_size;
|
||||
bool font_bold;
|
||||
::nana::color fgcolor;
|
||||
@ -625,23 +625,24 @@ namespace nana
|
||||
|
||||
class renderer renderer;
|
||||
|
||||
nana::string target; //It indicates which target is tracing.
|
||||
nana::string url;
|
||||
std::wstring target; //It indicates which target is tracing.
|
||||
std::wstring url;
|
||||
|
||||
window for_associated_wd{ nullptr };
|
||||
|
||||
void add_listener(std::function<void(command, const nana::string&)>&& fn)
|
||||
void add_listener(std::function<void(command, const std::string&)>&& fn)
|
||||
{
|
||||
listener_.emplace_back(std::move(fn));
|
||||
}
|
||||
|
||||
void call_listener(command cmd, const nana::string& tar)
|
||||
void call_listener(command cmd, const std::wstring& tar)
|
||||
{
|
||||
auto str = to_utf8(tar);
|
||||
for (auto & fn : listener_)
|
||||
fn(cmd, tar);
|
||||
fn(cmd, str);
|
||||
}
|
||||
private:
|
||||
std::vector<std::function<void(command, const nana::string&)>> listener_;
|
||||
std::vector<std::function<void(command, const std::string&)>> listener_;
|
||||
};
|
||||
|
||||
trigger::trigger()
|
||||
@ -666,7 +667,7 @@ namespace nana
|
||||
|
||||
void trigger::mouse_move(graph_reference, const arg_mouse& arg)
|
||||
{
|
||||
nana::string target, url;
|
||||
std::wstring target, url;
|
||||
|
||||
if(impl_->renderer.find(arg.pos.x, arg.pos.y, target, url))
|
||||
{
|
||||
@ -741,7 +742,7 @@ namespace nana
|
||||
if(impl_->target.size())
|
||||
impl_->call_listener(command::click, impl_->target);
|
||||
|
||||
system::open_url(url);
|
||||
system::open_url(to_utf8(url));
|
||||
|
||||
API::focus_window(impl_->for_associated_wd);
|
||||
}
|
||||
@ -772,8 +773,9 @@ namespace nana
|
||||
bgcolor(API::bgcolor(wd));
|
||||
}
|
||||
|
||||
label::label(window wd, const nana::string& text, bool visible)
|
||||
label::label(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
bgcolor(API::bgcolor(wd));
|
||||
caption(text);
|
||||
@ -806,13 +808,13 @@ namespace nana
|
||||
if(impl->renderer.format(f))
|
||||
{
|
||||
window wd = *this;
|
||||
impl->renderer.parse(API::dev::window_caption(wd));
|
||||
impl->renderer.parse(::nana::to_wstring(API::dev::window_caption(wd)));
|
||||
API::refresh_window(wd);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
label& label::add_format_listener(std::function<void(command, const nana::string&)> f)
|
||||
label& label::add_format_listener(std::function<void(command, const std::string&)> f)
|
||||
{
|
||||
get_drawer_trigger().impl()->add_listener(std::move(f));
|
||||
return *this;
|
||||
@ -844,11 +846,12 @@ namespace nana
|
||||
return impl->renderer.measure(*graph_ptr, limited, impl->text_align, impl->text_align_v);
|
||||
}
|
||||
|
||||
::nana::size label::measure(paint::graphics& graph, const ::nana::string& str, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align)
|
||||
::nana::size label::measure(paint::graphics& graph, const ::std::string& str, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align)
|
||||
{
|
||||
throw_not_utf8(str);
|
||||
drawerbase::label::renderer rd;
|
||||
rd.format(format_enabled);
|
||||
rd.parse(str);
|
||||
rd.parse(utf8_cast(str));
|
||||
return rd.measure(graph, allowed_width_in_pixel, h_align, v_align);
|
||||
}
|
||||
|
||||
@ -867,11 +870,11 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
void label::_m_caption(nana::string&& str)
|
||||
void label::_m_caption(native_string_type&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
window wd = *this;
|
||||
get_drawer_trigger().impl()->renderer.parse(str);
|
||||
get_drawer_trigger().impl()->renderer.parse(to_wstring(str));
|
||||
API::dev::window_caption(wd, std::move(str));
|
||||
API::refresh_window(wd);
|
||||
}
|
||||
|
||||
@ -52,16 +52,16 @@ namespace nana
|
||||
{
|
||||
}
|
||||
|
||||
cell::cell(nana::string text)
|
||||
cell::cell(std::string text)
|
||||
: text(std::move(text))
|
||||
{}
|
||||
|
||||
cell::cell(nana::string text, const format& fmt)
|
||||
cell::cell(std::string text, const format& fmt)
|
||||
: text(std::move(text)),
|
||||
custom_format(std::make_unique<format>( fmt )) // or custom_format(new format{ fmt })
|
||||
{}
|
||||
|
||||
cell::cell(nana::string text, const ::nana::color& bgcolor, const ::nana::color& fgcolor)
|
||||
cell::cell(std::string text, const ::nana::color& bgcolor, const ::nana::color& fgcolor)
|
||||
: text(std::move(text)),
|
||||
custom_format{std::make_unique<format>( bgcolor, fgcolor ) } //custom_format{ new format{ bgcolor, fgcolor } }
|
||||
{}
|
||||
@ -90,101 +90,101 @@ namespace nana
|
||||
//definition of iresolver/oresolver
|
||||
oresolver& oresolver::operator<<(bool n)
|
||||
{
|
||||
cells_.emplace_back(n ? L"true" : L"false");
|
||||
cells_.emplace_back(n ? "true" : "false");
|
||||
return *this;
|
||||
}
|
||||
oresolver& oresolver::operator<<(short n)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(n));
|
||||
cells_.emplace_back(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(unsigned short n)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(n));
|
||||
cells_.emplace_back(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(int n)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(n));
|
||||
cells_.emplace_back(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(unsigned int n)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(n));
|
||||
cells_.emplace_back(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(long n)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(n));
|
||||
cells_.emplace_back(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(unsigned long n)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(n));
|
||||
cells_.emplace_back(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
oresolver& oresolver::operator<<(long long n)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(n));
|
||||
cells_.emplace_back(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(unsigned long long n)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(n));
|
||||
cells_.emplace_back(std::to_string(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(float f)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(f));
|
||||
cells_.emplace_back(std::to_string(f));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(double f)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(f));
|
||||
cells_.emplace_back(std::to_string(f));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(long double f)
|
||||
{
|
||||
cells_.emplace_back(std::to_wstring(f));
|
||||
cells_.emplace_back(std::to_string(f));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(const char* text)
|
||||
{
|
||||
cells_.emplace_back(std::wstring(charset(text)));
|
||||
cells_.emplace_back(text);
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(const wchar_t* text)
|
||||
{
|
||||
cells_.emplace_back(text);
|
||||
cells_.emplace_back(to_utf8(text));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(const std::string& text)
|
||||
{
|
||||
cells_.emplace_back(std::wstring(charset(text)));
|
||||
cells_.emplace_back(text);
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(const std::wstring& text)
|
||||
{
|
||||
cells_.emplace_back(text);
|
||||
cells_.emplace_back(to_utf8(text));
|
||||
return *this;
|
||||
}
|
||||
|
||||
oresolver& oresolver::operator<<(std::wstring&& text)
|
||||
{
|
||||
cells_.emplace_back(std::move(text));
|
||||
cells_.emplace_back(to_utf8(text));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ namespace nana
|
||||
oresolver& oresolver::operator<<(std::nullptr_t)
|
||||
{
|
||||
cells_.emplace_back();
|
||||
cells_.back().text.assign(1, nana::char_t(0)); //means invalid cell
|
||||
cells_.back().text.assign(1, wchar_t(0)); //means invalid cell
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -291,14 +291,14 @@ namespace nana
|
||||
iresolver& iresolver::operator>>(std::string& text)
|
||||
{
|
||||
if (pos_ < cells_.size())
|
||||
text = charset(cells_[pos_++].text);
|
||||
text = cells_[pos_++].text;
|
||||
return *this;
|
||||
}
|
||||
|
||||
iresolver& iresolver::operator>>(std::wstring& text)
|
||||
{
|
||||
if (pos_ < cells_.size())
|
||||
text = cells_[pos_++].text;
|
||||
text = to_wstring(cells_[pos_++].text);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -328,14 +328,14 @@ namespace nana
|
||||
|
||||
struct column_t
|
||||
{
|
||||
nana::string text; ///< "text" header of the column number "index" with weigth "pixels"
|
||||
native_string_type text; ///< "text" header of the column number "index" with weigth "pixels"
|
||||
unsigned pixels;
|
||||
bool visible{true};
|
||||
size_type index;
|
||||
std::function<bool(const nana::string&, nana::any*, const nana::string&, nana::any*, bool reverse)> weak_ordering;
|
||||
std::function<bool(const std::string&, nana::any*, const std::string&, nana::any*, bool reverse)> weak_ordering;
|
||||
|
||||
column_t() = default;
|
||||
column_t(nana::string&& txt, unsigned px, size_type pos)
|
||||
column_t(native_string_type&& txt, unsigned px, size_type pos)
|
||||
: text(std::move(txt)), pixels(px), index(pos)
|
||||
{}
|
||||
};
|
||||
@ -353,21 +353,20 @@ namespace nana
|
||||
return idx;
|
||||
}
|
||||
|
||||
nana::string to_string(const export_options& exp_opt) const
|
||||
{
|
||||
nana::string head_str;
|
||||
bool first{true};
|
||||
for( size_type idx{}; idx<exp_opt.columns_order.size(); ++idx)
|
||||
std::string to_string(const export_options& exp_opt) const
|
||||
{
|
||||
std::string head_str;
|
||||
bool first{true};
|
||||
for( size_type idx{}; idx<exp_opt.columns_order.size(); ++idx)
|
||||
{
|
||||
if(first)
|
||||
first=false;
|
||||
else
|
||||
head_str += exp_opt.sep;
|
||||
|
||||
head_str += column_ref(exp_opt.columns_order[idx]).text;
|
||||
if(first)
|
||||
first=false;
|
||||
else
|
||||
head_str += exp_opt.sep;
|
||||
head_str += to_utf8(column_ref(exp_opt.columns_order[idx]).text);
|
||||
}
|
||||
return head_str;
|
||||
}
|
||||
return head_str;
|
||||
}
|
||||
|
||||
bool visible() const
|
||||
{
|
||||
@ -393,7 +392,7 @@ namespace nana
|
||||
sortable_ = enable;
|
||||
}
|
||||
|
||||
std::function<bool(const nana::string&, nana::any*, const nana::string&, nana::any*, bool reverse)> fetch_comp(std::size_t pos) const
|
||||
std::function<bool(const std::string&, nana::any*, const std::string&, nana::any*, bool reverse)> fetch_comp(std::size_t pos) const
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -405,7 +404,7 @@ namespace nana
|
||||
return{};
|
||||
}
|
||||
|
||||
size_type create(nana::string&& text, unsigned pixels)
|
||||
size_type create(native_string_type&& text, unsigned pixels)
|
||||
{
|
||||
cont_.emplace_back(std::move(text), pixels, static_cast<size_type>(cont_.size()));
|
||||
return cont_.back().index;
|
||||
@ -604,13 +603,13 @@ namespace nana
|
||||
flags.selected = flags.checked = false;
|
||||
}
|
||||
|
||||
item_t(nana::string&& s)
|
||||
item_t(std::string&& s)
|
||||
{
|
||||
flags.selected = flags.checked = false;
|
||||
cells.emplace_back(std::move(s));
|
||||
}
|
||||
|
||||
item_t(nana::string&& s, const nana::color& bg, const nana::color& fg)
|
||||
item_t(std::string&& s, const nana::color& bg, const nana::color& fg)
|
||||
: bgcolor(bg),
|
||||
fgcolor(fg)
|
||||
{
|
||||
@ -632,9 +631,9 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
nana::string to_string(const export_options& exp_opt) const
|
||||
std::string to_string(const export_options& exp_opt) const
|
||||
{
|
||||
nana::string item_str;
|
||||
std::string item_str;
|
||||
|
||||
bool ignore_first = true;
|
||||
for (size_type idx{}; idx < exp_opt.columns_order.size(); ++idx)
|
||||
@ -657,7 +656,7 @@ namespace nana
|
||||
{
|
||||
using container = std::deque<item_t>;
|
||||
|
||||
::nana::string text;
|
||||
native_string_type text;
|
||||
std::vector<std::size_t> sorted;
|
||||
container items;
|
||||
bool expand{true};
|
||||
@ -670,7 +669,7 @@ namespace nana
|
||||
|
||||
category_t() = default;
|
||||
|
||||
category_t(nana::string str)
|
||||
category_t(native_string_type str)
|
||||
:text(std::move(str))
|
||||
{}
|
||||
|
||||
@ -689,8 +688,8 @@ namespace nana
|
||||
public:
|
||||
using container = std::list<category_t>;
|
||||
|
||||
std::function<std::function<bool(const ::nana::string&, ::nana::any*,
|
||||
const ::nana::string&, ::nana::any*, bool reverse)>(std::size_t) > fetch_ordering_comparer;
|
||||
std::function<std::function<bool(const ::std::string&, ::nana::any*,
|
||||
const ::std::string&, ::nana::any*, bool reverse)>(std::size_t) > fetch_ordering_comparer;
|
||||
|
||||
es_lister()
|
||||
{
|
||||
@ -727,7 +726,8 @@ namespace nana
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
nana::string to_string(const export_options& exp_opt) const;
|
||||
|
||||
std::string to_string(const export_options& exp_opt) const;
|
||||
|
||||
/// each sort() ivalidate any existing reference from display position to absolute item, that is after sort() display offset point to different items
|
||||
void sort()
|
||||
@ -749,11 +749,11 @@ namespace nana
|
||||
auto & my = cat.items[y];
|
||||
if (mx.cells.size() <= sorted_index_ || my.cells.size() <= sorted_index_)
|
||||
{
|
||||
nana::string a;
|
||||
std::string a;
|
||||
if (mx.cells.size() > sorted_index_)
|
||||
a = mx.cells[sorted_index_].text;
|
||||
|
||||
nana::string b;
|
||||
std::string b;
|
||||
if (my.cells.size() > sorted_index_)
|
||||
b = my.cells[sorted_index_].text;
|
||||
|
||||
@ -774,11 +774,11 @@ namespace nana
|
||||
|
||||
if (item_x.cells.size() <= sorted_index_ || item_y.cells.size() <= sorted_index_)
|
||||
{
|
||||
nana::string a;
|
||||
std::string a;
|
||||
if (item_x.cells.size() > sorted_index_)
|
||||
a = item_x.cells[sorted_index_].text;
|
||||
|
||||
nana::string b;
|
||||
std::string b;
|
||||
if (item_y.cells.size() > sorted_index_)
|
||||
b = item_y.cells[sorted_index_].text;
|
||||
|
||||
@ -856,7 +856,7 @@ namespace nana
|
||||
void scroll(const index_pair& pos, bool to_bottom);
|
||||
|
||||
///Append a new category with a specified name and return a pointer to it.
|
||||
category_t* create_cat(nana::string&& text)
|
||||
category_t* create_cat(native_string_type&& text)
|
||||
{
|
||||
list_.emplace_back(std::move(text));
|
||||
return &list_.back();
|
||||
@ -880,13 +880,13 @@ namespace nana
|
||||
return &list_.back();
|
||||
}
|
||||
/// add a new cat created at "pos" and return a ref to it
|
||||
category_t* create_cat(std::size_t pos, nana::string&& text)
|
||||
category_t* create_cat(std::size_t pos, native_string_type&& text)
|
||||
{
|
||||
return &(*list_.emplace(this->get(pos), std::move(text)));
|
||||
}
|
||||
|
||||
/// Insert before item in absolute "pos" a new item with "text" in column 0, and place it in last display position of this cat
|
||||
bool insert(const index_pair& pos, nana::string&& text)
|
||||
bool insert(const index_pair& pos, std::string&& text)
|
||||
{
|
||||
auto & catobj = *get(pos.cat);
|
||||
|
||||
@ -1094,7 +1094,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void text(category_t* cat, size_type pos, size_type col, nana::string&& str, size_type columns)
|
||||
void text(category_t* cat, size_type pos, size_type col, std::string&& str, size_type columns)
|
||||
{
|
||||
if ((col < columns) && (pos < cat->items.size()))
|
||||
{
|
||||
@ -1876,7 +1876,7 @@ namespace nana
|
||||
inline_indicator * indicator;
|
||||
index_pair item_pos; //The item index of the inline widget
|
||||
std::size_t column_pos;
|
||||
::nana::string text;
|
||||
::std::string text; //text in UTF-8 encoded
|
||||
};
|
||||
|
||||
std::map<pat::detail::abstract_factory_base*, std::deque<std::unique_ptr<inline_pane>>> inline_table, inline_buffered_table;
|
||||
@ -1888,7 +1888,7 @@ namespace nana
|
||||
lister.fetch_ordering_comparer = std::bind(&es_header::fetch_comp, &header, std::placeholders::_1);
|
||||
}
|
||||
|
||||
nana::string to_string(const export_options& exp_opt) const
|
||||
std::string to_string(const export_options& exp_opt) const
|
||||
{
|
||||
return header.to_string(exp_opt) + exp_opt.endl + lister.to_string(exp_opt) ;
|
||||
}
|
||||
@ -2359,7 +2359,7 @@ namespace nana
|
||||
};
|
||||
|
||||
class inline_indicator
|
||||
: public ::nana::detail::inline_widget_indicator<index_pair, std::wstring>
|
||||
: public ::nana::detail::inline_widget_indicator<index_pair, std::string>
|
||||
{
|
||||
public:
|
||||
using parts = essence_t::parts;
|
||||
@ -2589,16 +2589,16 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
nana::string es_lister::to_string(const export_options& exp_opt) const
|
||||
std::string es_lister::to_string(const export_options& exp_opt) const
|
||||
{
|
||||
nana::string list_str;
|
||||
std::string list_str;
|
||||
bool first{true};
|
||||
for(auto & cat: cat_container())
|
||||
{
|
||||
if(first)
|
||||
first=false;
|
||||
else
|
||||
list_str += (cat.text + exp_opt.endl);
|
||||
list_str += (to_utf8(cat.text) + exp_opt.endl);
|
||||
|
||||
for (auto i : cat.sorted)
|
||||
{
|
||||
@ -2855,7 +2855,7 @@ namespace nana
|
||||
auto fgcolor = wdptr->fgcolor();
|
||||
|
||||
unsigned header_w = essence_->header.pixels();
|
||||
essence_->graph->set_color(bgcolor);
|
||||
essence_->graph->palette(false, bgcolor);
|
||||
if(header_w - essence_->scroll.offset_x < rect.width)
|
||||
essence_->graph->rectangle(rectangle{ point(rect.x + static_cast<int>(header_w)-essence_->scroll.offset_x, rect.y),
|
||||
size(static_cast<int>(rect.width) + essence_->scroll.offset_x - static_cast<int>(header_w), rect.height) },
|
||||
@ -2978,7 +2978,7 @@ namespace nana
|
||||
|
||||
graph->string({ x + 20, y + txtoff }, categ.text, txt_color);
|
||||
|
||||
::nana::string str = L'(' + std::to_wstring(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;
|
||||
@ -3154,35 +3154,32 @@ namespace nana
|
||||
if (item_state::highlighted == state)
|
||||
it_bgcolor = it_bgcolor.blend(static_cast<color_rgb>(0x99defd), 0.8);
|
||||
|
||||
graph->set_color(it_bgcolor);
|
||||
|
||||
graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true);
|
||||
graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true, it_bgcolor);
|
||||
|
||||
cell_txtcolor = m_cell.custom_format->fgcolor;
|
||||
}
|
||||
|
||||
if (draw_column)
|
||||
{
|
||||
graph->set_text_color(cell_txtcolor);
|
||||
graph->string(point{ item_xpos + content_pos, y + txtoff }, m_cell.text); // draw full text of the cell index (column)
|
||||
graph->string(point{ item_xpos + content_pos, y + txtoff }, m_cell.text, cell_txtcolor); // draw full text of the cell index (column)
|
||||
|
||||
if (static_cast<int>(ts.width) > static_cast<int>(header.pixels) - (content_pos + item_xpos)) // it was an excess
|
||||
{
|
||||
//The text is painted over the next subitem // here beging the ...
|
||||
int xpos = item_xpos + static_cast<int>(header.pixels) - static_cast<int>(essence_->suspension_width);
|
||||
|
||||
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("..."));
|
||||
// litter rect with the item bg end ...
|
||||
graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true, it_bgcolor);
|
||||
graph->string(point{ xpos, y + 2 }, L"...");
|
||||
|
||||
//Erase the part that over the next subitem only if the right of column is less than right of listbox
|
||||
if (item_xpos + content_pos < content_r.right() - static_cast<int>(header.pixels))
|
||||
{
|
||||
graph->set_color(bgcolor); // we need to erase the excess, because some cell may not draw text over
|
||||
graph->palette(false, bgcolor); // we need to erase the excess, because some cell may not draw text over
|
||||
graph->rectangle(rectangle{ item_xpos + static_cast<int>(header.pixels), y + 2,
|
||||
ts.width + static_cast<unsigned>(content_pos)-header.pixels, essence_->item_size - 4 }, true);
|
||||
}
|
||||
extreme_text = std::max(extreme_text, item_xpos + content_pos + ts.width);
|
||||
extreme_text = (std::max)(extreme_text, item_xpos + content_pos + ts.width);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3193,10 +3190,9 @@ namespace nana
|
||||
|
||||
item_xpos += static_cast<int>(header.pixels);
|
||||
if (display_order + 1 >= seqs.size() && static_cast<int>(extreme_text) > item_xpos)
|
||||
{
|
||||
graph->set_color(item.bgcolor);
|
||||
graph->rectangle(rectangle{item_xpos , y + 2, extreme_text - item_xpos, essence_->item_size - 4}, true);
|
||||
}
|
||||
{
|
||||
graph->rectangle(rectangle{item_xpos , y + 2, extreme_text - item_xpos, essence_->item_size - 4}, true, item.bgcolor);
|
||||
}
|
||||
}
|
||||
|
||||
//Draw selecting inner rectangle
|
||||
@ -3311,9 +3307,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)
|
||||
@ -3608,7 +3604,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);
|
||||
@ -3812,14 +3808,21 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
item_proxy& item_proxy::text(size_type col, nana::string str)
|
||||
item_proxy& item_proxy::text(size_type col, std::string str)
|
||||
{
|
||||
ess_->lister.text(cat_, pos_.item, col, std::move(str), columns());
|
||||
ess_->update();
|
||||
return *this;
|
||||
}
|
||||
|
||||
nana::string item_proxy::text(size_type col) const
|
||||
item_proxy& item_proxy::text(size_type col, std::wstring str)
|
||||
{
|
||||
ess_->lister.text(cat_, pos_.item, col, to_utf8(str), columns());
|
||||
ess_->update();
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string item_proxy::text(size_type col) const
|
||||
{
|
||||
return ess_->lister.get_cells(cat_, pos_.item).at(col).text;
|
||||
}
|
||||
@ -3839,20 +3842,24 @@ namespace nana
|
||||
|
||||
|
||||
//Behavior of Iterator's value_type
|
||||
bool item_proxy::operator==(const nana::string& s) const
|
||||
{
|
||||
return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == s);
|
||||
}
|
||||
|
||||
bool item_proxy::operator==(const char * s) const
|
||||
{
|
||||
return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == nana::string(nana::charset(s)));
|
||||
|
||||
return this->operator==(std::string(s));
|
||||
}
|
||||
|
||||
bool item_proxy::operator==(const wchar_t * s) const
|
||||
{
|
||||
return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == nana::string(nana::charset(s)));
|
||||
return this->operator==(std::wstring(s));
|
||||
}
|
||||
|
||||
bool item_proxy::operator==(const std::string& s) const
|
||||
{
|
||||
return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == s);
|
||||
}
|
||||
|
||||
bool item_proxy::operator==(const std::wstring& s) const
|
||||
{
|
||||
return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == to_utf8(s));
|
||||
}
|
||||
|
||||
item_proxy & item_proxy::operator=(const item_proxy& rhs)
|
||||
@ -3973,10 +3980,10 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void cat_proxy::append(std::initializer_list<nana::string> arg)
|
||||
void cat_proxy::append(std::initializer_list<std::string> arg)
|
||||
{
|
||||
const auto items = columns();
|
||||
push_back(nana::string{});
|
||||
push_back(std::string{});
|
||||
item_proxy ip{ ess_, index_pair(pos_, size() - 1) };
|
||||
size_type pos = 0;
|
||||
for (auto & txt : arg)
|
||||
@ -3987,6 +3994,20 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void cat_proxy::append(std::initializer_list<std::wstring> arg)
|
||||
{
|
||||
const auto items = columns();
|
||||
push_back(std::string{});
|
||||
item_proxy ip{ ess_, index_pair(pos_, size() - 1) };
|
||||
size_type pos = 0;
|
||||
for (auto & txt : arg)
|
||||
{
|
||||
ip.text(pos++, to_utf8(txt));
|
||||
if (pos >= items)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cat_proxy & cat_proxy::select(bool sel)
|
||||
{
|
||||
for (item_proxy &it : *this )
|
||||
@ -4009,24 +4030,37 @@ namespace nana
|
||||
return ess_->header.cont().size();
|
||||
}
|
||||
|
||||
cat_proxy& cat_proxy::text(nana::string s)
|
||||
cat_proxy& cat_proxy::text(std::string s)
|
||||
{
|
||||
auto text = to_nstring(s);
|
||||
internal_scope_guard lock;
|
||||
if (s != cat_->text)
|
||||
if (text != cat_->text)
|
||||
{
|
||||
cat_->text.swap(s);
|
||||
cat_->text.swap(text);
|
||||
ess_->update();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
nana::string cat_proxy::text() const
|
||||
cat_proxy& cat_proxy::text(std::wstring s)
|
||||
{
|
||||
auto text = to_nstring(s);
|
||||
internal_scope_guard lock;
|
||||
return cat_->text;
|
||||
if (text != cat_->text)
|
||||
{
|
||||
cat_->text.swap(text);
|
||||
ess_->update();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void cat_proxy::push_back(nana::string s)
|
||||
std::string cat_proxy::text() const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
return to_utf8(cat_->text);
|
||||
}
|
||||
|
||||
void cat_proxy::push_back(std::string s)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
|
||||
@ -4201,7 +4235,7 @@ namespace nana
|
||||
//check invalid cells
|
||||
for (auto & cl : cells)
|
||||
{
|
||||
if (cl.text.size() == 1 && cl.text[0] == nana::char_t(0))
|
||||
if (cl.text.size() == 1 && cl.text[0] == wchar_t(0))
|
||||
{
|
||||
cl.text.clear();
|
||||
cl.custom_format.reset();
|
||||
@ -4303,14 +4337,24 @@ namespace nana
|
||||
ess.update();
|
||||
}
|
||||
|
||||
listbox::size_type listbox::append_header(nana::string text, unsigned width)
|
||||
listbox::size_type listbox::append_header(std::string s, unsigned width)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
auto pos = ess.header.create(std::move(text), width);
|
||||
auto pos = ess.header.create(to_nstring(std::move(s)), width);
|
||||
ess.update();
|
||||
return pos;
|
||||
}
|
||||
|
||||
listbox::size_type listbox::append_header(std::wstring s, unsigned width)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
auto pos = ess.header.create(to_nstring(std::move(s)), width);
|
||||
ess.update();
|
||||
return pos;
|
||||
}
|
||||
|
||||
listbox& listbox::header_width(size_type pos, unsigned pixels)
|
||||
{
|
||||
auto & ess = _m_ess();
|
||||
@ -4331,31 +4375,58 @@ namespace nana
|
||||
return _m_ess().header.item_width(pos);
|
||||
}
|
||||
|
||||
listbox::cat_proxy listbox::append(nana::string s)
|
||||
listbox::cat_proxy listbox::append(std::string s)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
auto new_cat_ptr = ess.lister.create_cat(std::move(s));
|
||||
auto new_cat_ptr = ess.lister.create_cat(to_nstring(std::move(s)));
|
||||
ess.update();
|
||||
|
||||
return cat_proxy{ &ess, new_cat_ptr };
|
||||
}
|
||||
|
||||
void listbox::append(std::initializer_list<nana::string> args)
|
||||
listbox::cat_proxy listbox::append(std::wstring s)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
auto new_cat_ptr = ess.lister.create_cat(to_nstring(std::move(s)));
|
||||
ess.update();
|
||||
return cat_proxy{ &ess, new_cat_ptr };
|
||||
}
|
||||
|
||||
void listbox::append(std::initializer_list<std::string> args)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
|
||||
for (auto & arg : args)
|
||||
ess.lister.create_cat(nana::string{ arg });
|
||||
ess.lister.create_cat(native_string_type(to_nstring(arg)));
|
||||
ess.update();
|
||||
}
|
||||
|
||||
auto listbox::insert(cat_proxy cat, nana::string str) -> cat_proxy
|
||||
void listbox::append(std::initializer_list<std::wstring> args)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
auto new_cat_ptr = ess.lister.create_cat(cat.position(), std::move(str));
|
||||
|
||||
for (auto & arg : args)
|
||||
ess.lister.create_cat(native_string_type(to_nstring(arg)));
|
||||
ess.update();
|
||||
}
|
||||
|
||||
auto listbox::insert(cat_proxy cat, std::string str) -> cat_proxy
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
auto new_cat_ptr = ess.lister.create_cat(cat.position(), to_nstring(std::move(str)));
|
||||
return cat_proxy{ &ess, new_cat_ptr };
|
||||
}
|
||||
|
||||
auto listbox::insert(cat_proxy cat, std::wstring str) -> cat_proxy
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
auto new_cat_ptr = ess.lister.create_cat(cat.position(), to_nstring(std::move(str)));
|
||||
return cat_proxy{ &ess, new_cat_ptr };
|
||||
}
|
||||
|
||||
@ -4385,13 +4456,13 @@ namespace nana
|
||||
return at(pos_abs.cat).at(pos_abs.item);
|
||||
}
|
||||
|
||||
void listbox::insert(const index_pair& pos, nana::string text)
|
||||
void listbox::insert(const index_pair& pos, std::string text)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto & ess = _m_ess();
|
||||
if (ess.lister.insert(pos, std::move(text)))
|
||||
{
|
||||
if (! empty())
|
||||
if (!empty())
|
||||
{
|
||||
auto & item = ess.lister.at(pos);
|
||||
item.bgcolor = bgcolor();
|
||||
@ -4401,6 +4472,11 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void listbox::insert(const index_pair& pos, std::wstring text)
|
||||
{
|
||||
insert(pos, to_utf8(text));
|
||||
}
|
||||
|
||||
void listbox::checkable(bool chkable)
|
||||
{
|
||||
auto & ess = _m_ess();
|
||||
@ -4519,7 +4595,7 @@ namespace nana
|
||||
_m_ess().header.sortable(enable);
|
||||
}
|
||||
|
||||
void listbox::set_sort_compare(size_type col, std::function<bool(const nana::string&, nana::any*, const nana::string&, nana::any*, bool reverse)> strick_ordering)
|
||||
void listbox::set_sort_compare(size_type col, std::function<bool(const std::string&, nana::any*, const std::string&, nana::any*, bool reverse)> strick_ordering)
|
||||
{
|
||||
_m_ess().header.column(col).weak_ordering = std::move(strick_ordering);
|
||||
}
|
||||
@ -4633,7 +4709,7 @@ namespace nana
|
||||
}
|
||||
else
|
||||
{
|
||||
cat = ess.lister.create_cat(nana::string{});
|
||||
cat = ess.lister.create_cat(native_string_type{});
|
||||
cat->key_ptr = ptr;
|
||||
}
|
||||
ess.update();
|
||||
|
||||
@ -79,7 +79,7 @@ namespace nana
|
||||
flags.checked = false;
|
||||
}
|
||||
|
||||
menu_item_type::menu_item_type(nana::string text, const event_fn_t& f)
|
||||
menu_item_type::menu_item_type(std::string text, const event_fn_t& f)
|
||||
: text(std::move(text)), functor(f)
|
||||
{
|
||||
flags.enabled = true;
|
||||
@ -121,7 +121,7 @@ namespace nana
|
||||
nana::point(r.x + r.width - 1, r.y + r.height - 1)
|
||||
};
|
||||
|
||||
graph.set_color(static_cast<color_rgb>(0xc0ddfc));
|
||||
graph.palette(false, static_cast<color_rgb>(0xc0ddfc));
|
||||
for(int i = 0; i < 4; ++i)
|
||||
graph.set_pixel(points[i].x, points[i].y);
|
||||
|
||||
@ -148,11 +148,13 @@ namespace nana
|
||||
img.stretch(rectangle{ img.size() }, graph, rectangle{ pos, ::nana::size(image_px, image_px) });
|
||||
}
|
||||
|
||||
void item_text(graph_reference graph, const nana::point& pos, const nana::string& text, unsigned text_pixels, const attr& at)
|
||||
void item_text(graph_reference graph, const nana::point& pos, const std::string& text, unsigned text_pixels, const attr& at)
|
||||
{
|
||||
graph.set_text_color(at.enabled ? colors::black : colors::gray_border);
|
||||
graph.palette(true, at.enabled ? colors::black : colors::gray_border);
|
||||
nana::paint::text_renderer tr(graph);
|
||||
tr.render(pos, text.c_str(), text.length(), text_pixels, true);
|
||||
|
||||
auto wstr = to_wstring(text);
|
||||
tr.render(pos, wstr.c_str(), wstr.length(), text_pixels, true);
|
||||
}
|
||||
|
||||
void sub_arrow(graph_reference graph, const nana::point& pos, unsigned pixels, const attr&)
|
||||
@ -240,7 +242,7 @@ namespace nana
|
||||
return root_;
|
||||
}
|
||||
|
||||
void insert(std::size_t pos, nana::string&& text, const event_fn_t& fn)
|
||||
void insert(std::size_t pos, std::string&& text, const event_fn_t& fn)
|
||||
{
|
||||
if(pos < root_.items.size())
|
||||
root_.items.emplace(root_.items.begin() + pos, std::move(text), std::ref(fn));
|
||||
@ -363,15 +365,14 @@ 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)
|
||||
{
|
||||
if (m.flags.splitter)
|
||||
{
|
||||
graph_->set_color(colors::gray_border);
|
||||
graph_->line({ item_r.x + 40, item_r.y }, { static_cast<int>(graph.width()) - 1, item_r.y });
|
||||
graph_->line({ item_r.x + 40, item_r.y }, { static_cast<int>(graph.width()) - 1, item_r.y }, colors::gray_border);
|
||||
item_r.y += 2;
|
||||
++pos;
|
||||
continue;
|
||||
@ -382,14 +383,14 @@ namespace nana
|
||||
renderer->item(*graph_, item_r, attr);
|
||||
|
||||
//Draw text, the text is transformed from orignal for hotkey character
|
||||
nana::char_t hotkey;
|
||||
nana::string::size_type hotkey_pos;
|
||||
nana::string text = API::transform_shortkey_text(m.text, hotkey, &hotkey_pos);
|
||||
wchar_t hotkey;
|
||||
std::string::size_type hotkey_pos;
|
||||
auto text = to_wstring(API::transform_shortkey_text(m.text, hotkey, &hotkey_pos));
|
||||
|
||||
if (m.image.empty() == false)
|
||||
renderer->item_image(graph, nana::point(item_r.x + 5, item_r.y + static_cast<int>(item_h_px - image_px) / 2 - 1), image_px, m.image);
|
||||
|
||||
renderer->item_text(graph, nana::point(item_r.x + 40, item_r.y + text_top_off), text, strpixels, attr);
|
||||
renderer->item_text(graph, nana::point(item_r.x + 40, item_r.y + text_top_off), to_utf8(text), strpixels, attr);
|
||||
|
||||
if (hotkey)
|
||||
{
|
||||
@ -401,8 +402,7 @@ namespace nana
|
||||
int x = item_r.x + 40 + off_w;
|
||||
int y = item_r.y + text_top_off + hotkey_size.height;
|
||||
|
||||
graph_->set_color(colors::black);
|
||||
graph_->line({ x, y }, { x + static_cast<int>(hotkey_size.width) - 1, y });
|
||||
graph_->line({ x, y }, { x + static_cast<int>(hotkey_size.width) - 1, y }, colors::black);
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,7 +545,7 @@ namespace nana
|
||||
}
|
||||
|
||||
//send_shortkey has 3 states, 0 = UNKNOWN KEY, 1 = ITEM, 2 = GOTO SUBMENU
|
||||
int send_shortkey(nana::char_t key)
|
||||
int send_shortkey(wchar_t key)
|
||||
{
|
||||
key = std::tolower(key);
|
||||
std::size_t index = 0;
|
||||
@ -712,7 +712,7 @@ namespace nana
|
||||
want_focus_{ (!wd) || ((!is_wd_parent_menu) && (API::focus_window() != wd)) },
|
||||
event_focus_{ nullptr }
|
||||
{
|
||||
caption(STR("nana menu window"));
|
||||
caption("nana menu window");
|
||||
get_drawer_trigger().close_menu_tree([this]{ this->_m_close_all(); });
|
||||
get_drawer_trigger().renderer = rdptr;
|
||||
state_.owner_menubar = state_.self_submenu = false;
|
||||
@ -749,7 +749,7 @@ namespace nana
|
||||
if(submenu_.parent == nullptr)
|
||||
{
|
||||
state_.owner_menubar = owner_menubar;
|
||||
API::register_menu_window(this->handle(), !owner_menubar);
|
||||
API::dev::register_menu_window(this->handle(), !owner_menubar);
|
||||
}
|
||||
|
||||
auto & events = this->events();
|
||||
@ -844,7 +844,7 @@ namespace nana
|
||||
return menu_wd->_m_manipulate_sub(0, true);
|
||||
}
|
||||
|
||||
int send_shortkey(nana::char_t key)
|
||||
int send_shortkey(wchar_t key)
|
||||
{
|
||||
menu_window * object = this;
|
||||
while(object->submenu_.child)
|
||||
@ -1107,7 +1107,7 @@ namespace nana
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
auto menu::append(const nana::string& text, const menu::event_fn_t& f) -> item_proxy
|
||||
auto menu::append(const std::string& text, const menu::event_fn_t& f) -> item_proxy
|
||||
{
|
||||
impl_->mbuilder.data().items.emplace_back(text, f);
|
||||
return item_proxy(size() - 1, impl_->mbuilder.data().items.back());
|
||||
@ -1253,7 +1253,7 @@ namespace nana
|
||||
return impl_->mbuilder.data().items.size();
|
||||
}
|
||||
|
||||
int menu::send_shortkey(nana::char_t key)
|
||||
int menu::send_shortkey(wchar_t key)
|
||||
{
|
||||
return (impl_->uiobj ? impl_->uiobj->send_shortkey(key) : 0);
|
||||
}
|
||||
|
||||
@ -30,11 +30,11 @@ namespace nana
|
||||
{
|
||||
struct item_type
|
||||
{
|
||||
item_type(const ::nana::string& text, unsigned long shortkey)
|
||||
item_type(const native_string_type text, unsigned long shortkey)
|
||||
: text(text), shortkey(shortkey)
|
||||
{}
|
||||
|
||||
::nana::string text;
|
||||
native_string_type text;
|
||||
unsigned long shortkey;
|
||||
::nana::menu menu_obj;
|
||||
::nana::point pos;
|
||||
@ -52,7 +52,7 @@ namespace nana
|
||||
delete i;
|
||||
}
|
||||
|
||||
void append(const ::nana::string& text, unsigned long shortkey)
|
||||
void append(const native_string_type& text, unsigned long shortkey)
|
||||
{
|
||||
if(shortkey && shortkey < 0x61) shortkey += (0x61 - 0x41);
|
||||
cont_.push_back(new item_type(text, shortkey));
|
||||
@ -114,7 +114,7 @@ namespace nana
|
||||
|
||||
int right = pos.x + static_cast<int>(size.width) - 1;
|
||||
int bottom = pos.y + static_cast<int>(size.height) - 1;
|
||||
graph_.set_color(corner);
|
||||
graph_.palette(false, corner);
|
||||
graph_.set_pixel(pos.x, pos.y);
|
||||
graph_.set_pixel(right, pos.y);
|
||||
graph_.set_pixel(pos.x, bottom);
|
||||
@ -122,7 +122,7 @@ namespace nana
|
||||
graph_.rectangle(r.pare_off(1), true, body);
|
||||
}
|
||||
|
||||
void item_renderer::caption(const point& pos, const nana::string& text)
|
||||
void item_renderer::caption(const point& pos, const native_string_type& text)
|
||||
{
|
||||
graph_.string(pos, text, colors::black);
|
||||
}
|
||||
@ -138,16 +138,16 @@ namespace nana
|
||||
delete items_;
|
||||
}
|
||||
|
||||
nana::menu* trigger::push_back(const ::nana::string& text)
|
||||
nana::menu* trigger::push_back(const std::string& text)
|
||||
{
|
||||
::nana::char_t shkey;
|
||||
wchar_t shkey;
|
||||
API::transform_shortkey_text(text, shkey, nullptr);
|
||||
|
||||
if(shkey)
|
||||
API::register_shortkey(widget_->handle(), shkey);
|
||||
|
||||
auto pos = items_->cont().size();
|
||||
items_->append(text, shkey);
|
||||
items_->append(to_nstring(text), shkey);
|
||||
refresh(*graph_);
|
||||
API::update_window(*widget_);
|
||||
|
||||
@ -187,9 +187,9 @@ namespace nana
|
||||
for (auto i : items_->cont())
|
||||
{
|
||||
//Transform the text if it contains the hotkey character
|
||||
::nana::char_t hotkey;
|
||||
::nana::string::size_type hotkey_pos;
|
||||
auto text = API::transform_shortkey_text(i->text, hotkey, &hotkey_pos);
|
||||
wchar_t hotkey;
|
||||
::std::wstring::size_type hotkey_pos;
|
||||
auto text = API::transform_shortkey_text(to_utf8(i->text), hotkey, &hotkey_pos);
|
||||
|
||||
nana::size text_s = graph.text_extent_size(text);
|
||||
|
||||
@ -212,11 +212,11 @@ namespace nana
|
||||
|
||||
//Draw text, the text is transformed from orignal for hotkey character
|
||||
int text_top_off = (item_s.height - text_s.height) / 2;
|
||||
ird.caption({ item_pos.x + 8, item_pos.y + text_top_off }, text);
|
||||
ird.caption({ item_pos.x + 8, item_pos.y + text_top_off }, to_nstring(text));
|
||||
|
||||
if (hotkey)
|
||||
{
|
||||
unsigned off_w = (hotkey_pos ? graph.text_extent_size(text, static_cast<unsigned>(hotkey_pos)).width : 0);
|
||||
unsigned off_w = (hotkey_pos ? graph.text_extent_size(text.c_str(), static_cast<unsigned>(hotkey_pos)).width : 0);
|
||||
nana::size hotkey_size = graph.text_extent_size(text.c_str() + hotkey_pos, 1);
|
||||
|
||||
unsigned ascent, descent, inleading;
|
||||
@ -608,7 +608,8 @@ namespace nana
|
||||
{
|
||||
widget_object<category::widget_tag, drawerbase::menubar::trigger>
|
||||
::create(wd, rectangle(nana::size(API::window_size(wd).width, 28)));
|
||||
API::attach_menubar(handle());
|
||||
|
||||
API::dev::set_menubar(handle(), true);
|
||||
evt_resized_ = API::events(wd).resized([this](const ::nana::arg_resized& arg)
|
||||
{
|
||||
auto sz = this->size();
|
||||
@ -617,7 +618,7 @@ namespace nana
|
||||
});
|
||||
}
|
||||
|
||||
menu& menubar::push_back(const nana::string& text)
|
||||
menu& menubar::push_back(const std::string& text)
|
||||
{
|
||||
return *(get_drawer_trigger().push_back(text));
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ namespace nana
|
||||
//class drawer
|
||||
void drawer::attached(widget_reference wdg, graph_reference)
|
||||
{
|
||||
wdg.caption(STR("panel widget"));
|
||||
wdg.caption("panel widget");
|
||||
window_ = wdg.handle();
|
||||
|
||||
API::ignore_mouse_focus(wdg, true);
|
||||
|
||||
@ -199,7 +199,7 @@ namespace nana
|
||||
graph.rectangle(r, false, clr);
|
||||
|
||||
clr = clr.blend(colors::white, 0.5);
|
||||
graph.set_color(clr);
|
||||
graph.palette(false, clr);
|
||||
|
||||
r.pare_off(2);
|
||||
if(vertical_)
|
||||
|
||||
@ -61,7 +61,7 @@ namespace nana{ namespace widgets
|
||||
text_editor & editor_;
|
||||
upoint pos_;
|
||||
upoint sel_a_, sel_b_;
|
||||
nana::string selected_text_;
|
||||
std::wstring selected_text_;
|
||||
private:
|
||||
const EnumCommand cmd_;
|
||||
};
|
||||
@ -75,7 +75,7 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
}
|
||||
|
||||
void set_removed(nana::string str)
|
||||
void set_removed(std::wstring str)
|
||||
{
|
||||
//use selected_text_ as removed text
|
||||
selected_text_ = str;
|
||||
@ -136,7 +136,7 @@ namespace nana{ namespace widgets
|
||||
: public basic_undoable <command>
|
||||
{
|
||||
public:
|
||||
undo_input_text(text_editor & editor, const nana::string& text)
|
||||
undo_input_text(text_editor & editor, const std::wstring& text)
|
||||
: basic_undoable<command>(editor, command::input_text),
|
||||
text_(text)
|
||||
{
|
||||
@ -199,7 +199,7 @@ namespace nana{ namespace widgets
|
||||
editor_.move_caret(editor_.points_.caret);
|
||||
}
|
||||
private:
|
||||
nana::string text_;
|
||||
std::wstring text_;
|
||||
};
|
||||
|
||||
class text_editor::undo_move_text
|
||||
@ -325,9 +325,9 @@ namespace nana{ namespace widgets
|
||||
if (pos.y > static_cast<unsigned>(textbase.lines()))
|
||||
pos.y = static_cast<unsigned>(textbase.lines());
|
||||
|
||||
std::unique_ptr<nana::string> mask_str;
|
||||
std::unique_ptr<std::wstring> mask_str;
|
||||
if (editor_.mask_char_)
|
||||
mask_str.reset(new nana::string(textbase.getline(pos.y).size(), editor_.mask_char_));
|
||||
mask_str.reset(new std::wstring(textbase.getline(pos.y).size(), editor_.mask_char_));
|
||||
|
||||
auto & lnstr = editor_.mask_char_ ? *mask_str : textbase.getline(pos.y);
|
||||
|
||||
@ -345,9 +345,9 @@ namespace nana{ namespace widgets
|
||||
//Convert the screen point to text caret point
|
||||
const string_type& real_str = editor_.textbase_.getline(res.y);
|
||||
|
||||
std::unique_ptr<nana::string> mask_str;
|
||||
std::unique_ptr<std::wstring> mask_str;
|
||||
if (editor_.mask_char_)
|
||||
mask_str.reset(new nana::string(real_str.size(), editor_.mask_char_));
|
||||
mask_str.reset(new std::wstring(real_str.size(), editor_.mask_char_));
|
||||
|
||||
auto & lnstr = (editor_.mask_char_ ? *mask_str : real_str);
|
||||
if (lnstr.size() > 0)
|
||||
@ -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))
|
||||
@ -500,8 +500,8 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
struct text_section
|
||||
{
|
||||
const nana::char_t* begin;
|
||||
const nana::char_t* end;
|
||||
const wchar_t* begin;
|
||||
const wchar_t* end;
|
||||
unsigned pixels;
|
||||
|
||||
text_section()
|
||||
@ -509,7 +509,7 @@ namespace nana{ namespace widgets
|
||||
throw std::runtime_error("text_section default construction is forbidden.");
|
||||
}
|
||||
|
||||
text_section(const nana::char_t* ptr, const nana::char_t* endptr)
|
||||
text_section(const wchar_t* ptr, const wchar_t* endptr)
|
||||
: begin(ptr), end(endptr)
|
||||
{}
|
||||
};
|
||||
@ -539,8 +539,8 @@ namespace nana{ namespace widgets
|
||||
std::size_t line = 0;
|
||||
for (auto & mtr: linemtr_)
|
||||
{
|
||||
const nana::string& linestr = editor_.textbase_.getline(line);
|
||||
const nana::char_t * p = mtr.line_sections.front().begin;
|
||||
auto& linestr = editor_.textbase_.getline(line);
|
||||
auto p = mtr.line_sections.front().begin;
|
||||
if (p < linestr.data() || (linestr.data() + linestr.size() < p))
|
||||
pre_calc_line(line, editor_.width_pixels());
|
||||
|
||||
@ -562,8 +562,8 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
if (line < pos || (pos + lines) <= line)
|
||||
{
|
||||
const nana::string& linestr = editor_.textbase_.getline(line);
|
||||
const nana::char_t * p = mtr.line_sections.front().begin;
|
||||
auto & linestr = editor_.textbase_.getline(line);
|
||||
auto p = mtr.line_sections.front().begin;
|
||||
if (p < linestr.data() || (linestr.data() + linestr.size() < p))
|
||||
pre_calc_line(line, editor_.width_pixels());
|
||||
}
|
||||
@ -591,7 +591,7 @@ namespace nana{ namespace widgets
|
||||
std::vector<text_section> line_sections;
|
||||
|
||||
unsigned text_px = 0;
|
||||
const nana::char_t * secondary_begin = nullptr;
|
||||
const wchar_t * secondary_begin = nullptr;
|
||||
for (auto & ts : sections)
|
||||
{
|
||||
if (!secondary_begin)
|
||||
@ -627,7 +627,7 @@ namespace nana{ namespace widgets
|
||||
if (text_px < pixels)
|
||||
continue;
|
||||
|
||||
const nana::char_t * endptr = ts.begin + (pxi - pxptr) + (text_px == pixels ? 1 : 0);
|
||||
const wchar_t * endptr = ts.begin + (pxi - pxptr) + (text_px == pixels ? 1 : 0);
|
||||
line_sections.emplace_back(secondary_begin, endptr);
|
||||
line_sections.back().pixels = text_px - (text_px == pixels ? 0 : *pxi);
|
||||
secondary_begin = endptr;
|
||||
@ -697,7 +697,7 @@ namespace nana{ namespace widgets
|
||||
for (std::size_t pos = 0; pos < secondary_before; ++pos, top+=pixels)
|
||||
{
|
||||
auto & sct = linemtr_[textline].line_sections[pos];
|
||||
editor_._m_draw_string(top, fgcolor, nana::upoint(static_cast<unsigned>(sct.begin - text_ptr), editor_.points_.caret.y), nana::string(sct.begin, sct.end), true);
|
||||
editor_._m_draw_string(top, fgcolor, nana::upoint(static_cast<unsigned>(sct.begin - text_ptr), editor_.points_.caret.y), std::wstring(sct.begin, sct.end), true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -727,7 +727,7 @@ namespace nana{ namespace widgets
|
||||
auto & mtr = linemtr_[primary];
|
||||
auto & section = mtr.line_sections[secondary];
|
||||
|
||||
nana::string text(section.begin, section.end);
|
||||
std::wstring text(section.begin, section.end);
|
||||
editor_._m_draw_string(top, fgcolor, str_pos, text, true);
|
||||
line_index.push_back(str_pos);
|
||||
++secondary;
|
||||
@ -767,7 +767,7 @@ namespace nana{ namespace widgets
|
||||
nana::point scrpos;
|
||||
if (0 != pos.x)
|
||||
{
|
||||
nana::string str;
|
||||
std::wstring str;
|
||||
for (auto & sec : mtr.line_sections)
|
||||
{
|
||||
std::size_t chsize = sec.end - sec.begin;
|
||||
@ -812,11 +812,11 @@ namespace nana{ namespace widgets
|
||||
//First of all, find the text of secondary.
|
||||
auto real_str = mtr.line_sections[secondary];
|
||||
|
||||
std::unique_ptr<nana::string> mask_str;
|
||||
std::unique_ptr<std::wstring> mask_str;
|
||||
if (editor_.mask_char_)
|
||||
mask_str.reset(new nana::string(real_str.end - real_str.begin, editor_.mask_char_));
|
||||
mask_str.reset(new std::wstring(real_str.end - real_str.begin, editor_.mask_char_));
|
||||
|
||||
const ::nana::char_t * str = (editor_.mask_char_ ? mask_str->data() : real_str.begin);
|
||||
const wchar_t * str = (editor_.mask_char_ ? mask_str->data() : real_str.begin);
|
||||
|
||||
std::vector<unicode_bidi::entity> reordered;
|
||||
unicode_bidi bidi;
|
||||
@ -925,7 +925,7 @@ namespace nana{ namespace widgets
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
void _m_text_section(const nana::string& str, std::vector<text_section>& tsec)
|
||||
void _m_text_section(const std::wstring& str, std::vector<text_section>& tsec)
|
||||
{
|
||||
if (str.empty())
|
||||
{
|
||||
@ -934,10 +934,10 @@ namespace nana{ namespace widgets
|
||||
}
|
||||
const auto end = str.data() + str.size();
|
||||
|
||||
const nana::char_t * word = nullptr;
|
||||
const wchar_t * word = nullptr;
|
||||
for (auto i = str.data(); i != end; ++i)
|
||||
{
|
||||
nana::char_t const ch = *i;
|
||||
wchar_t const ch = *i;
|
||||
|
||||
//CKJ characters and whitespace
|
||||
if (' ' == ch || '\t' == ch || (0x4E00 <= ch && ch <= 0x9FCF))
|
||||
@ -1148,12 +1148,12 @@ namespace nana{ namespace widgets
|
||||
|
||||
struct keyword_desc
|
||||
{
|
||||
::nana::string text;
|
||||
std::wstring text;
|
||||
std::string scheme;
|
||||
bool case_sensitive;
|
||||
bool whole_word_matched;
|
||||
|
||||
keyword_desc(const ::nana::string& txt, const std::string& schm, bool cs, bool wwm)
|
||||
keyword_desc(const std::wstring& txt, const std::string& schm, bool cs, bool wwm)
|
||||
: text(txt), scheme(schm), case_sensitive(cs), whole_word_matched(wwm)
|
||||
{}
|
||||
};
|
||||
@ -1166,20 +1166,20 @@ namespace nana{ namespace widgets
|
||||
|
||||
struct entity
|
||||
{
|
||||
const ::nana::char_t* begin;
|
||||
const ::nana::char_t* end;
|
||||
const wchar_t* begin;
|
||||
const wchar_t* end;
|
||||
const keyword_scheme * scheme;
|
||||
};
|
||||
|
||||
class text_editor::keyword_parser
|
||||
{
|
||||
public:
|
||||
void parse(const ::nana::string& text, const keywords* kwptr)
|
||||
void parse(const std::wstring& text, const keywords* kwptr)
|
||||
{
|
||||
if ( kwptr->kwbase.empty() || text.empty() )
|
||||
return;
|
||||
|
||||
using index = ::nana::string::size_type;
|
||||
using index = std::wstring::size_type;
|
||||
|
||||
std::vector<entity> entities;
|
||||
|
||||
@ -1202,7 +1202,7 @@ namespace nana{ namespace widgets
|
||||
return true;
|
||||
};
|
||||
|
||||
::nana::cistring cistr;
|
||||
::nana::ciwstring cistr;
|
||||
for (auto & ds : kwptr->kwbase)
|
||||
{
|
||||
index pos{0} ;
|
||||
@ -1329,7 +1329,7 @@ namespace nana{ namespace widgets
|
||||
keywords_->schemes.erase(name);
|
||||
}
|
||||
|
||||
void text_editor::set_keyword(const ::nana::string& kw, const std::string& name, bool case_sensitive, bool whole_word_matched)
|
||||
void text_editor::set_keyword(const ::std::wstring& kw, const std::string& name, bool case_sensitive, bool whole_word_matched)
|
||||
{
|
||||
for (auto & ds : keywords_->kwbase)
|
||||
{
|
||||
@ -1344,7 +1344,7 @@ namespace nana{ namespace widgets
|
||||
keywords_->kwbase.emplace_back(kw, name, case_sensitive, whole_word_matched);
|
||||
}
|
||||
|
||||
void text_editor::erase_keyword(const ::nana::string& kw)
|
||||
void text_editor::erase_keyword(const ::std::wstring& kw)
|
||||
{
|
||||
for (auto i = keywords_->kwbase.begin(); i != keywords_->kwbase.end(); ++i)
|
||||
if (i->text == kw)
|
||||
@ -1388,7 +1388,7 @@ namespace nana{ namespace widgets
|
||||
case keyboard::sync_idel:
|
||||
paste(); break;
|
||||
case keyboard::tab:
|
||||
put(static_cast<char_t>(keyboard::tab)); break;
|
||||
put(static_cast<wchar_t>(keyboard::tab)); break;
|
||||
case keyboard::cancel:
|
||||
cut();
|
||||
break;
|
||||
@ -1404,11 +1404,6 @@ namespace nana{ namespace widgets
|
||||
|
||||
if (key > 0x7F || (32 <= key && key <= 126))
|
||||
put(key);
|
||||
else if (sizeof(nana::char_t) == sizeof(char))
|
||||
{ //Non-Unicode Version for Non-English characters
|
||||
if (key & (1 << (sizeof(nana::char_t) * 8 - 1)))
|
||||
put(key);
|
||||
}
|
||||
}
|
||||
reset_caret();
|
||||
return true;
|
||||
@ -1446,7 +1441,7 @@ namespace nana{ namespace widgets
|
||||
behavior_->pre_calc_lines(width_pixels());
|
||||
}
|
||||
|
||||
void text_editor::indent(bool enb, std::function<nana::string()> generator)
|
||||
void text_editor::indent(bool enb, std::function<std::string()> generator)
|
||||
{
|
||||
indent_.enabled = enb;
|
||||
indent_.generator.swap(generator);
|
||||
@ -1493,7 +1488,7 @@ namespace nana{ namespace widgets
|
||||
text_area_.border_renderer = f;
|
||||
}
|
||||
|
||||
bool text_editor::load(const nana::char_t* fs)
|
||||
bool text_editor::load(const char* fs)
|
||||
{
|
||||
if (!textbase_.load(fs))
|
||||
return false;
|
||||
@ -1533,7 +1528,7 @@ namespace nana{ namespace widgets
|
||||
return r;
|
||||
}
|
||||
|
||||
bool text_editor::tip_string(nana::string&& str)
|
||||
bool text_editor::tip_string(::std::string&& str)
|
||||
{
|
||||
if(attributes_.tip_string == str)
|
||||
return false;
|
||||
@ -1614,7 +1609,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
|
||||
@ -1729,17 +1724,17 @@ namespace nana{ namespace widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
textbase<nana::char_t> & text_editor::textbase()
|
||||
textbase<wchar_t> & text_editor::textbase()
|
||||
{
|
||||
return textbase_;
|
||||
}
|
||||
|
||||
const textbase<nana::char_t> & text_editor::textbase() const
|
||||
const textbase<wchar_t> & text_editor::textbase() const
|
||||
{
|
||||
return textbase_;
|
||||
}
|
||||
|
||||
bool text_editor::getline(std::size_t pos, nana::string& text) const
|
||||
bool text_editor::getline(std::size_t pos, std::wstring& text) const
|
||||
{
|
||||
if (textbase_.lines() <= pos)
|
||||
return false;
|
||||
@ -1748,23 +1743,23 @@ namespace nana{ namespace widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
void text_editor::text(nana::string str)
|
||||
void text_editor::text(std::wstring str)
|
||||
{
|
||||
textbase_.erase_all();
|
||||
_m_reset();
|
||||
put(std::move(str));
|
||||
}
|
||||
|
||||
nana::string text_editor::text() const
|
||||
std::wstring text_editor::text() const
|
||||
{
|
||||
nana::string str;
|
||||
std::wstring str;
|
||||
std::size_t lines = textbase_.lines();
|
||||
if(lines > 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1896,7 +1891,7 @@ namespace nana{ namespace widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
bool text_editor::mask(nana::char_t ch)
|
||||
bool text_editor::mask(wchar_t ch)
|
||||
{
|
||||
if (mask_char_ == ch)
|
||||
return false;
|
||||
@ -1984,7 +1979,7 @@ namespace nana{ namespace widgets
|
||||
text_area_.border_renderer(graph_, bgcolor);
|
||||
}
|
||||
//public:
|
||||
void text_editor::put(nana::string text)
|
||||
void text_editor::put(std::wstring text)
|
||||
{
|
||||
auto undo_ptr = std::unique_ptr<undo_input_text>{ new undo_input_text(*this, text) };
|
||||
|
||||
@ -2010,9 +2005,11 @@ namespace nana{ namespace widgets
|
||||
}
|
||||
}
|
||||
|
||||
void text_editor::put(nana::char_t c)
|
||||
void text_editor::put(wchar_t ch)
|
||||
{
|
||||
auto undo_ptr = std::unique_ptr < undo_input_text > {new undo_input_text(*this, nana::string(1, c))};
|
||||
std::wstring ch_str(1, ch);
|
||||
|
||||
auto undo_ptr = std::unique_ptr < undo_input_text > {new undo_input_text(*this, ch_str)};
|
||||
bool refresh = (select_.a != select_.b);
|
||||
|
||||
undo_ptr->set_selected_text();
|
||||
@ -2023,7 +2020,7 @@ namespace nana{ namespace widgets
|
||||
undo_.push(std::move(undo_ptr));
|
||||
|
||||
auto secondary_before = behavior_->take_lines(points_.caret.y);
|
||||
textbase_.insert(points_.caret, nana::string(1, c));
|
||||
textbase_.insert(points_.caret, std::move(ch_str));
|
||||
behavior_->pre_calc_line(points_.caret.y, width_pixels());
|
||||
points_.caret.x ++;
|
||||
|
||||
@ -2039,7 +2036,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
void text_editor::copy() const
|
||||
{
|
||||
nana::string str;
|
||||
std::wstring str;
|
||||
if(_m_make_select_string(str))
|
||||
nana::system::dataexch().set(str);
|
||||
}
|
||||
@ -2052,7 +2049,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
void text_editor::paste()
|
||||
{
|
||||
nana::string text;
|
||||
std::wstring text;
|
||||
nana::system::dataexch().get(text);
|
||||
|
||||
//If it is required check the acceptable
|
||||
@ -2077,7 +2074,7 @@ namespace nana{ namespace widgets
|
||||
if(false == attributes_.multi_lines)
|
||||
return;
|
||||
|
||||
auto undo_ptr = std::unique_ptr<undo_input_text>(new undo_input_text(*this, nana::string(1, '\n')));
|
||||
auto undo_ptr = std::unique_ptr<undo_input_text>(new undo_input_text(*this, std::wstring(1, '\n')));
|
||||
bool need_refresh = (select_.a != select_.b);
|
||||
|
||||
undo_ptr->set_selected_text();
|
||||
@ -2098,8 +2095,8 @@ namespace nana{ namespace widgets
|
||||
else
|
||||
{
|
||||
if (textbase_.lines() == 0)
|
||||
textbase_.insertln(0, nana::string{});
|
||||
textbase_.insertln(points_.caret.y, nana::string{});
|
||||
textbase_.insertln(0, std::wstring{});
|
||||
textbase_.insertln(points_.caret.y, std::wstring{});
|
||||
}
|
||||
|
||||
if (record_undo)
|
||||
@ -2120,10 +2117,10 @@ namespace nana{ namespace widgets
|
||||
|
||||
if (indent_.enabled)
|
||||
{
|
||||
nana::string indent_text;
|
||||
std::wstring indent_text;
|
||||
if (indent_.generator)
|
||||
{
|
||||
indent_text = indent_.generator();
|
||||
indent_text = to_wstring(indent_.generator());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2183,15 +2180,8 @@ namespace nana{ namespace widgets
|
||||
unsigned erase_number = 1;
|
||||
--points_.caret.x;
|
||||
|
||||
const string_type& lnstr = textbase_.getline(points_.caret.y);
|
||||
#ifndef NANA_UNICODE
|
||||
if(is_incomplete(lnstr, points_.caret.x) && (points_.caret.x))
|
||||
{
|
||||
textbase_.erase(points_.caret.y, points_.caret.x, 1);
|
||||
--points_.caret.x;
|
||||
erase_number = 2;
|
||||
}
|
||||
#endif
|
||||
auto& lnstr = textbase_.getline(points_.caret.y);
|
||||
|
||||
undo_ptr->set_caret_pos();
|
||||
undo_ptr->set_removed(lnstr.substr(points_.caret.x, erase_number));
|
||||
auto secondary = behavior_->take_lines(points_.caret.y);
|
||||
@ -2210,7 +2200,7 @@ namespace nana{ namespace widgets
|
||||
textbase_.merge(points_.caret.y);
|
||||
behavior_->merge_lines(points_.caret.y, points_.caret.y + 1);
|
||||
undo_ptr->set_caret_pos();
|
||||
undo_ptr->set_removed(nana::string(1, '\n'));
|
||||
undo_ptr->set_removed(std::wstring(1, '\n'));
|
||||
}
|
||||
else
|
||||
undo_ptr.reset();
|
||||
@ -2264,10 +2254,7 @@ namespace nana{ namespace widgets
|
||||
if(points_.caret.x)
|
||||
{
|
||||
--points_.caret.x;
|
||||
#ifndef NANA_UNICODE
|
||||
if(is_incomplete(textbase_.getline(points_.caret.y), points_.caret.x))
|
||||
--points_.caret.x;
|
||||
#endif
|
||||
|
||||
pending = false;
|
||||
bool adjust_y = (attributes_.line_wrapped && behavior_->adjust_caret_into_screen());
|
||||
if (_m_move_offset_x_while_over_border(-2) || adjust_y)
|
||||
@ -2291,14 +2278,11 @@ namespace nana{ namespace widgets
|
||||
bool do_render = false;
|
||||
if(_m_cancel_select(2) == false)
|
||||
{
|
||||
nana::string lnstr = textbase_.getline(points_.caret.y);
|
||||
auto lnstr = textbase_.getline(points_.caret.y);
|
||||
if(lnstr.size() > points_.caret.x)
|
||||
{
|
||||
++points_.caret.x;
|
||||
#ifndef NANA_UNICODE
|
||||
if(is_incomplete(lnstr, points_.caret.x))
|
||||
++points_.caret.x;
|
||||
#endif
|
||||
|
||||
bool adjust_y = (attributes_.line_wrapped && behavior_->adjust_caret_into_screen());
|
||||
do_render = (_m_move_offset_x_while_over_border(2) || adjust_y);
|
||||
}
|
||||
@ -2326,7 +2310,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
bool changed = false;
|
||||
nana::upoint caret = points_.caret;
|
||||
char_t key = arg.key;
|
||||
wchar_t key = arg.key;
|
||||
size_t nlines = textbase_.lines();
|
||||
if (arg.ctrl) {
|
||||
switch (key) {
|
||||
@ -2671,13 +2655,13 @@ namespace nana{ namespace widgets
|
||||
select_.a = select_.b;
|
||||
}
|
||||
|
||||
nana::upoint text_editor::_m_put(nana::string text)
|
||||
nana::upoint text_editor::_m_put(std::wstring text)
|
||||
{
|
||||
auto crtpos = points_.caret;
|
||||
std::vector<std::pair<std::size_t, std::size_t>> lines;
|
||||
if (_m_resolve_text(text, lines) && attributes_.multi_lines)
|
||||
{
|
||||
nana::string str_orig = textbase_.getline(crtpos.y);
|
||||
auto str_orig = textbase_.getline(crtpos.y);
|
||||
auto x_orig = crtpos.x;
|
||||
|
||||
auto subpos = lines.front();
|
||||
@ -2726,7 +2710,7 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
if(a.y != b.y)
|
||||
{
|
||||
textbase_.erase(a.y, a.x, nana::string::npos);
|
||||
textbase_.erase(a.y, a.x, std::wstring::npos);
|
||||
textbase_.erase(a.y + 1, b.y - a.y - 1);
|
||||
|
||||
textbase_.erase(a.y + 1, 0, b.x);
|
||||
@ -2747,7 +2731,7 @@ namespace nana{ namespace widgets
|
||||
return points_.caret;
|
||||
}
|
||||
|
||||
bool text_editor::_m_make_select_string(nana::string& text) const
|
||||
bool text_editor::_m_make_select_string(std::wstring& text) const
|
||||
{
|
||||
nana::upoint a, b;
|
||||
if (!_m_get_sort_select_points(a, b))
|
||||
@ -2756,11 +2740,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);
|
||||
}
|
||||
@ -2795,13 +2779,13 @@ namespace nana{ namespace widgets
|
||||
return pos + 1;
|
||||
}
|
||||
|
||||
bool text_editor::_m_resolve_text(const nana::string& text, std::vector<std::pair<std::size_t, std::size_t>> & lines)
|
||||
bool text_editor::_m_resolve_text(const std::wstring& text, std::vector<std::pair<std::size_t, std::size_t>> & lines)
|
||||
{
|
||||
auto const text_str = text.data();
|
||||
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 +2797,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);
|
||||
@ -2864,7 +2848,7 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
if(0 == tabs) return 0;
|
||||
|
||||
nana::char_t ws[2] = {};
|
||||
wchar_t ws[2] = {};
|
||||
ws[0] = mask_char_ ? mask_char_ : ' ';
|
||||
return static_cast<unsigned>(tabs * graph_.text_extent_size(ws).width * text_area_.tab_space);
|
||||
}
|
||||
@ -2876,7 +2860,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
if(mask_char_)
|
||||
{
|
||||
nana::string maskstr;
|
||||
std::wstring maskstr;
|
||||
maskstr.append(n, mask_char_);
|
||||
return graph_.text_extent_size(maskstr);
|
||||
}
|
||||
@ -2923,7 +2907,7 @@ namespace nana{ namespace widgets
|
||||
bool text_editor::_m_move_select(bool record_undo)
|
||||
{
|
||||
nana::upoint caret = points_.caret;
|
||||
nana::string text;
|
||||
std::wstring text;
|
||||
if (_m_make_select_string(text))
|
||||
{
|
||||
auto undo_ptr = std::unique_ptr<undo_move_text>(new undo_move_text(*this));
|
||||
@ -2985,9 +2969,9 @@ namespace nana{ namespace widgets
|
||||
return static_cast<int>(text_area_.area.y + text_area_.area.height - text_area_.hscroll);
|
||||
}
|
||||
|
||||
void text_editor::_m_draw_parse_string(const keyword_parser& parser, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const ::nana::char_t* str, std::size_t len) const
|
||||
void text_editor::_m_draw_parse_string(const keyword_parser& parser, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const wchar_t* str, std::size_t len) const
|
||||
{
|
||||
graph_.set_text_color(fgcolor);
|
||||
graph_.palette(true, fgcolor);
|
||||
graph_.string(pos, str, len);
|
||||
if (parser.entities().empty())
|
||||
return;
|
||||
@ -3010,7 +2994,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
for (auto & ent : entities)
|
||||
{
|
||||
const ::nana::char_t* ent_begin = nullptr;
|
||||
const wchar_t* ent_begin = nullptr;
|
||||
|
||||
int ent_off = 0;
|
||||
if (str <= ent.begin && ent.begin < str_end)
|
||||
@ -3026,8 +3010,8 @@ namespace nana{ namespace widgets
|
||||
auto ent_end = (ent.end < str_end ? ent.end : str_end);
|
||||
auto ent_pixels = std::accumulate(glyphs + (ent_begin - str), glyphs + (ent_end - str), unsigned{});
|
||||
|
||||
canvas.set_color(ent.scheme->bgcolor.invisible() ? _m_bgcolor() : ent.scheme->bgcolor);
|
||||
canvas.set_text_color(ent.scheme->fgcolor.invisible() ? fgcolor : ent.scheme->fgcolor);
|
||||
canvas.palette(false, ent.scheme->bgcolor.invisible() ? _m_bgcolor() : ent.scheme->bgcolor);
|
||||
canvas.palette(true, ent.scheme->fgcolor.invisible() ? fgcolor : ent.scheme->fgcolor);
|
||||
|
||||
canvas.rectangle(true);
|
||||
|
||||
@ -3047,14 +3031,14 @@ namespace nana{ namespace widgets
|
||||
}
|
||||
}
|
||||
|
||||
void text_editor::_m_draw_string(int top, const ::nana::color& clr, const nana::upoint& str_pos, const nana::string& str, bool if_mask) const
|
||||
void text_editor::_m_draw_string(int top, const ::nana::color& clr, const nana::upoint& str_pos, const std::wstring& str, bool if_mask) const
|
||||
{
|
||||
::nana::point text_pos{ text_area_.area.x - points_.offset.x, top };
|
||||
const int text_right = text_area_.area.right();
|
||||
|
||||
std::unique_ptr<nana::string> mask_str;
|
||||
std::unique_ptr<std::wstring> mask_str;
|
||||
if (if_mask && mask_char_)
|
||||
mask_str.reset(new nana::string(str.size(), mask_char_));
|
||||
mask_str.reset(new std::wstring(str.size(), mask_char_));
|
||||
|
||||
bool focused = API::is_focus_ready(window_);
|
||||
|
||||
@ -3068,15 +3052,14 @@ 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();
|
||||
|
||||
//The line of text is in the range of selection
|
||||
nana::upoint a, b;
|
||||
graph_.set_text_color(clr);
|
||||
|
||||
graph_.set_color(scheme_->selection.get_color());
|
||||
graph_.palette(true, clr);
|
||||
graph_.palette(false, scheme_->selection.get_color());
|
||||
|
||||
//The text is not selected or the whole line text is selected
|
||||
if (!focused || (!_m_get_sort_select_points(a, b)) || (select_.a.y != str_pos.y && select_.b.y != str_pos.y))
|
||||
@ -3091,7 +3074,7 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
if (selected && focused)
|
||||
{
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph_.palette(true, scheme_->selection_text.get_color());
|
||||
graph_.rectangle(::nana::rectangle{ text_pos, { str_w, line_h_pixels } }, true);
|
||||
graph_.string(text_pos, ent.begin, len);
|
||||
}
|
||||
@ -3105,7 +3088,7 @@ namespace nana{ namespace widgets
|
||||
}
|
||||
else
|
||||
{
|
||||
auto rtl_string = [this, line_h_pixels, &parser, &clr](point strpos, const nana::char_t* str, std::size_t len, std::size_t str_px, unsigned glyph_front, unsigned glyph_selected){
|
||||
auto rtl_string = [this, line_h_pixels, &parser, &clr](point strpos, const wchar_t* str, std::size_t len, std::size_t str_px, unsigned glyph_front, unsigned glyph_selected){
|
||||
this->_m_draw_parse_string(parser, true, strpos, clr, str, len);
|
||||
|
||||
//Draw selected part
|
||||
@ -3115,12 +3098,12 @@ namespace nana{ namespace widgets
|
||||
|
||||
int sel_xpos = static_cast<int>(str_px - (glyph_front + glyph_selected));
|
||||
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph.palette(true, scheme_->selection_text.get_color());
|
||||
graph.string({-sel_xpos, 0}, str, len);
|
||||
graph_.bitblt(nana::rectangle(strpos.x + sel_xpos, strpos.y, glyph_selected, line_h_pixels), graph);
|
||||
};
|
||||
|
||||
const nana::char_t * strbeg = linestr.c_str();
|
||||
const wchar_t * strbeg = linestr.c_str();
|
||||
if (a.y == b.y)
|
||||
{
|
||||
for (auto & ent : reordered)
|
||||
@ -3139,7 +3122,7 @@ namespace nana{ namespace widgets
|
||||
if (a.x <= pos && str_end <= b.x)
|
||||
{
|
||||
graph_.rectangle(::nana::rectangle{ text_pos, { str_w, line_h_pixels } }, true);
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph_.palette(true, scheme_->selection_text.get_color());
|
||||
graph_.string(text_pos, ent.begin, len);
|
||||
}
|
||||
else
|
||||
@ -3155,7 +3138,7 @@ namespace nana{ namespace widgets
|
||||
auto head_w = std::accumulate(pxbuf, pxbuf + (a.x - pos), unsigned());
|
||||
auto sel_w = std::accumulate(pxbuf + (a.x - pos), pxbuf + (endpos - pos), unsigned());
|
||||
|
||||
graph_.set_text_color(clr);
|
||||
graph_.palette(true, clr);
|
||||
if (is_right_text(ent))
|
||||
{ //RTL
|
||||
rtl_string(text_pos, ent.begin, len, str_w, head_w, sel_w);
|
||||
@ -3169,7 +3152,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
//Draw selected part
|
||||
graph_.rectangle(::nana::rectangle{ part_pos, { sel_w, line_h_pixels } }, true);
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph_.palette(true, scheme_->selection_text.get_color());
|
||||
graph_.string(part_pos, ent.begin + (a.x - pos), endpos - a.x);
|
||||
|
||||
if (static_cast<size_t>(endpos) < str_end)
|
||||
@ -3187,14 +3170,14 @@ namespace nana{ namespace widgets
|
||||
|
||||
if (is_right_text(ent))
|
||||
{ //RTL
|
||||
graph_.set_text_color(clr);
|
||||
graph_.palette(true, clr);
|
||||
rtl_string(text_pos, ent.begin, len, str_w, 0, sel_w);
|
||||
}
|
||||
else
|
||||
{ //LTR
|
||||
//Draw selected part
|
||||
graph_.rectangle(::nana::rectangle{ text_pos, { sel_w, line_h_pixels } }, true);
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph_.palette(true, scheme_->selection_text.get_color());
|
||||
graph_.string(text_pos, ent.begin, endpos - pos);
|
||||
|
||||
_m_draw_parse_string(parser, false, text_pos + ::nana::point(static_cast<int>(sel_w), 0), clr, ent.begin + (endpos - pos), str_end - endpos);
|
||||
@ -3212,7 +3195,7 @@ namespace nana{ namespace widgets
|
||||
unsigned str_w = graph_.text_extent_size(ent.begin, len).width;
|
||||
if ((text_pos.x + static_cast<int>(str_w) > text_area_.area.x) && (text_pos.x < text_right))
|
||||
{
|
||||
graph_.set_text_color(clr);
|
||||
graph_.palette(true, clr);
|
||||
std::size_t pos = ent.begin - strbeg + str_pos.x;
|
||||
if ((pos + len <= a.x) || (a.x < pos)) //Not selected or selected all
|
||||
{
|
||||
@ -3220,7 +3203,7 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
//Draw selected all
|
||||
graph_.rectangle(::nana::rectangle{ text_pos, { str_w, line_h_pixels } }, true, static_cast<color_rgb>(0x3399FF));
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph_.palette(true, scheme_->selection_text.get_color());
|
||||
graph_.string(text_pos, ent.begin, len);
|
||||
}
|
||||
else
|
||||
@ -3241,7 +3224,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
//Draw selected part
|
||||
graph_.rectangle(::nana::rectangle{ part_pos, {str_w - head_w, line_h_pixels } }, true);
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph_.palette(true, scheme_->selection_text.get_color());
|
||||
graph_.string(part_pos, ent.begin + a.x - pos, len - (a.x - pos));
|
||||
}
|
||||
}
|
||||
@ -3265,12 +3248,12 @@ namespace nana{ namespace widgets
|
||||
if ((text_pos.x + static_cast<int>(str_w) > text_area_.area.x) && (text_pos.x < text_right))
|
||||
{
|
||||
std::size_t pos = ent.begin - strbeg + str_pos.x;
|
||||
graph_.set_text_color(clr);
|
||||
graph_.palette(true, clr);
|
||||
if (pos + len <= b.x)
|
||||
{
|
||||
//Draw selected part
|
||||
graph_.rectangle(::nana::rectangle{ text_pos, { str_w, line_h_pixels } }, true);
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph_.palette(true, scheme_->selection_text.get_color());
|
||||
graph_.string(text_pos, ent.begin, len);
|
||||
}
|
||||
else if (pos <= b.x && b.x < pos + len)
|
||||
@ -3284,7 +3267,7 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
//draw selected part
|
||||
graph_.rectangle(::nana::rectangle{ text_pos, { sel_w, line_h_pixels } }, true);
|
||||
graph_.set_text_color(scheme_->selection_text.get_color());
|
||||
graph_.palette(true, scheme_->selection_text.get_color());
|
||||
graph_.string(text_pos, ent.begin, b.x - pos);
|
||||
|
||||
_m_draw_parse_string(parser, false, text_pos + ::nana::point(static_cast<int>(sel_w), 0), clr, ent.begin + b.x - pos, len - (b.x - pos));
|
||||
@ -3335,7 +3318,7 @@ namespace nana{ namespace widgets
|
||||
points_.offset.y = y;
|
||||
}
|
||||
|
||||
unsigned text_editor::_m_char_by_pixels(const nana::char_t* str, std::size_t len, unsigned * pxbuf, int str_px, int pixels, bool is_rtl)
|
||||
unsigned text_editor::_m_char_by_pixels(const wchar_t* str, std::size_t len, unsigned * pxbuf, int str_px, int pixels, bool is_rtl)
|
||||
{
|
||||
if (graph_.glyph_pixels(str, len, pxbuf))
|
||||
{
|
||||
@ -3374,7 +3357,7 @@ namespace nana{ namespace widgets
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned text_editor::_m_pixels_by_char(const nana::string& lnstr, std::size_t pos) const
|
||||
unsigned text_editor::_m_pixels_by_char(const std::wstring& lnstr, std::size_t pos) const
|
||||
{
|
||||
if (pos > lnstr.size())
|
||||
return 0;
|
||||
|
||||
@ -47,7 +47,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
virtual void adorn_textbox(window, graph_reference graph, const nana::string& str, const nana::rectangle & r)
|
||||
virtual void adorn_textbox(window, graph_reference graph, const std::string& str, const nana::rectangle & r)
|
||||
{
|
||||
graph.rectangle(r, false, colors::white);
|
||||
graph.string({ r.x + 2, r.y + 1 }, str, colors::white);
|
||||
@ -512,7 +512,7 @@ namespace nana
|
||||
if(proto_.provider && attr_.is_draw_adorn)
|
||||
{
|
||||
unsigned vadorn = _m_value_by_pos(attr_.adorn_pos);
|
||||
nana::string str = proto_.provider->adorn_trace(attr_.vmax, vadorn);
|
||||
auto str = proto_.provider->adorn_trace(attr_.vmax, vadorn);
|
||||
if(str.size())
|
||||
{
|
||||
nana::size ts = other_.graph->text_extent_size(str);
|
||||
|
||||
@ -25,6 +25,7 @@ namespace nana
|
||||
{
|
||||
namespace spinbox
|
||||
{
|
||||
|
||||
class event_agent
|
||||
: public widgets::skeletons::textbase_event_agent_interface
|
||||
{
|
||||
@ -53,13 +54,13 @@ namespace nana
|
||||
public:
|
||||
virtual ~range_interface() = default;
|
||||
|
||||
virtual std::wstring value() const = 0;
|
||||
virtual std::string value() const = 0;
|
||||
|
||||
//sets a new value, the diff indicates whether the new value is different from the current value.
|
||||
//returns true if the new value is acceptable.
|
||||
virtual bool value(const std::wstring& new_value, bool& diff) = 0;
|
||||
virtual bool value(const std::string& new_value, bool& diff) = 0;
|
||||
|
||||
virtual bool check_value(const std::wstring&) const = 0;
|
||||
virtual bool check_value(const std::string&) const = 0;
|
||||
virtual void spin(bool increase) = 0;
|
||||
};
|
||||
|
||||
@ -72,14 +73,14 @@ namespace nana
|
||||
: begin_{ vbegin }, last_{ vlast }, step_{ step }, value_{ vbegin }
|
||||
{}
|
||||
|
||||
std::wstring value() const override
|
||||
std::string value() const override
|
||||
{
|
||||
return std::to_wstring(value_);
|
||||
return std::to_string(value_);
|
||||
}
|
||||
|
||||
bool value(const std::wstring& value_str, bool & diff) override
|
||||
bool value(const std::string& value_str, bool & diff) override
|
||||
{
|
||||
std::wstringstream ss;
|
||||
std::stringstream ss;
|
||||
ss << value_str;
|
||||
|
||||
T v;
|
||||
@ -92,7 +93,7 @@ namespace nana
|
||||
return true;
|
||||
}
|
||||
|
||||
bool check_value(const std::wstring& str) const override
|
||||
bool check_value(const std::string& str) const override
|
||||
{
|
||||
if (str.empty())
|
||||
return true;
|
||||
@ -157,6 +158,7 @@ namespace nana
|
||||
{
|
||||
public:
|
||||
range_text(std::initializer_list<std::string> & initlist)
|
||||
: texts_(initlist)
|
||||
{
|
||||
for (auto & s : initlist)
|
||||
{
|
||||
@ -165,10 +167,12 @@ namespace nana
|
||||
}
|
||||
|
||||
range_text(std::initializer_list<std::wstring>& initlist)
|
||||
: texts_(initlist)
|
||||
{}
|
||||
{
|
||||
for (auto & s : initlist)
|
||||
texts_.emplace_back(to_utf8(s));
|
||||
}
|
||||
|
||||
std::wstring value() const override
|
||||
std::string value() const override
|
||||
{
|
||||
if (texts_.empty())
|
||||
return{};
|
||||
@ -176,7 +180,7 @@ namespace nana
|
||||
return texts_[pos_];
|
||||
}
|
||||
|
||||
bool value(const std::wstring& value_str, bool & diff) override
|
||||
bool value(const std::string& value_str, bool & diff) override
|
||||
{
|
||||
auto i = std::find(texts_.cbegin(), texts_.cend(), value_str);
|
||||
if (i != texts_.cend())
|
||||
@ -188,7 +192,7 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
bool check_value(const std::wstring& str) const override
|
||||
bool check_value(const std::string& str) const override
|
||||
{
|
||||
if (str.empty())
|
||||
return true;
|
||||
@ -219,7 +223,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
private:
|
||||
std::vector<std::wstring> texts_;
|
||||
std::vector<std::string> texts_;
|
||||
std::size_t pos_{0};
|
||||
};
|
||||
|
||||
@ -250,7 +254,7 @@ namespace nana
|
||||
auto scheme = static_cast<::nana::widgets::skeletons::text_editor_scheme*>(API::dev::get_scheme(wd));
|
||||
editor_ = new ::nana::widgets::skeletons::text_editor(wd, graph, scheme);
|
||||
editor_->multi_lines(false);
|
||||
editor_->set_accept([this](::nana::char_t ch)
|
||||
editor_->set_accept([this](wchar_t ch)
|
||||
{
|
||||
auto str = editor_->text();
|
||||
auto pos = editor_->caret().x;
|
||||
@ -262,7 +266,7 @@ namespace nana
|
||||
else
|
||||
str.insert(pos, 1, ch);
|
||||
|
||||
return range_->check_value(str);
|
||||
return range_->check_value(to_utf8(str));
|
||||
});
|
||||
|
||||
evt_agent_.reset(new event_agent(static_cast<nana::spinbox&>(wdg)));
|
||||
@ -286,12 +290,12 @@ namespace nana
|
||||
editor_ = nullptr;
|
||||
}
|
||||
|
||||
::nana::string value() const
|
||||
std::string value() const
|
||||
{
|
||||
return range_->value();
|
||||
}
|
||||
|
||||
bool value(const ::nana::string& value_str)
|
||||
bool value(const ::std::string& value_str)
|
||||
{
|
||||
bool diff;
|
||||
if (!range_->value(value_str, diff))
|
||||
@ -309,7 +313,7 @@ namespace nana
|
||||
reset_text();
|
||||
}
|
||||
|
||||
void modifier(std::wstring&& prefix, std::wstring&& suffix)
|
||||
void modifier(std::string&& prefix, std::string&& suffix)
|
||||
{
|
||||
modifier_.prefix = std::move(prefix);
|
||||
modifier_.suffix = std::move(suffix);
|
||||
@ -417,9 +421,9 @@ namespace nana
|
||||
return;
|
||||
|
||||
if (API::is_focus_ready(editor_->window_handle()))
|
||||
editor_->text(range_->value());
|
||||
editor_->text(to_wstring(range_->value()));
|
||||
else
|
||||
editor_->text(modifier_.prefix + range_->value() + modifier_.suffix);
|
||||
editor_->text(to_wstring(modifier_.prefix + range_->value() + modifier_.suffix));
|
||||
|
||||
_m_draw_spins(spin_stated_);
|
||||
}
|
||||
@ -483,8 +487,8 @@ namespace nana
|
||||
|
||||
struct modifiers
|
||||
{
|
||||
std::wstring prefix;
|
||||
std::wstring suffix;
|
||||
std::string prefix;
|
||||
std::string suffix;
|
||||
}modifier_;
|
||||
};
|
||||
|
||||
@ -567,7 +571,7 @@ namespace nana
|
||||
{
|
||||
if (impl_->editor()->respond_char(arg))
|
||||
{
|
||||
if (!impl_->value(impl_->editor()->text()))
|
||||
if (!impl_->value(to_utf8(impl_->editor()->text())))
|
||||
impl_->draw_spins();
|
||||
|
||||
API::lazy_refresh();
|
||||
@ -639,7 +643,7 @@ namespace nana
|
||||
API::refresh_window(handle());
|
||||
}
|
||||
|
||||
::nana::string spinbox::value() const
|
||||
::std::string spinbox::value() const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if (handle())
|
||||
@ -647,7 +651,7 @@ namespace nana
|
||||
return{};
|
||||
}
|
||||
|
||||
void spinbox::value(const ::nana::string& s)
|
||||
void spinbox::value(const ::std::string& s)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if (handle())
|
||||
@ -667,30 +671,32 @@ namespace nana
|
||||
return std::stod(value());
|
||||
}
|
||||
|
||||
void spinbox::modifier(std::wstring prefix, std::wstring suffix)
|
||||
void spinbox::modifier(std::string prefix, std::string suffix)
|
||||
{
|
||||
get_drawer_trigger().impl()->modifier(std::move(prefix), std::move(suffix));
|
||||
}
|
||||
|
||||
void spinbox::modifier(const std::string & prefix_utf8, const std::string& suffix_utf8)
|
||||
void spinbox::modifier(const std::wstring & prefix, const std::wstring& suffix)
|
||||
{
|
||||
modifier(static_cast<std::wstring>(::nana::charset(prefix_utf8, ::nana::unicode::utf8)), static_cast<std::wstring>(::nana::charset(suffix_utf8, ::nana::unicode::utf8)));
|
||||
modifier(to_utf8(prefix), to_utf8(suffix));
|
||||
}
|
||||
|
||||
::nana::string spinbox::_m_caption() const throw()
|
||||
auto spinbox::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().impl()->editor();
|
||||
return (editor ? editor->text() : nana::string());
|
||||
if (editor)
|
||||
return to_nstring(editor->text());
|
||||
return native_string_type();
|
||||
}
|
||||
|
||||
void spinbox::_m_caption(::nana::string&& text)
|
||||
void spinbox::_m_caption(native_string_type&& text)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().impl()->editor();
|
||||
if (editor)
|
||||
{
|
||||
editor->text(std::move(text));
|
||||
editor->text(to_wstring(text));
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* A Tabbar Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -21,11 +21,12 @@ namespace nana
|
||||
{
|
||||
namespace tabbar
|
||||
{
|
||||
using native_string_type = ::nana::detail::native_string_type;
|
||||
struct item_t
|
||||
{
|
||||
window relative{nullptr};
|
||||
paint::image img;
|
||||
nana::string text;
|
||||
native_string_type text;
|
||||
any value;
|
||||
|
||||
::nana::color bgcolor;
|
||||
@ -33,7 +34,7 @@ namespace nana
|
||||
|
||||
item_t() = default;
|
||||
|
||||
item_t(nana::string&& text, any && value)
|
||||
item_t(native_string_type&& text, any && value)
|
||||
: text(std::move(text)), value(std::move(value))
|
||||
{}
|
||||
};
|
||||
@ -420,7 +421,7 @@ namespace nana
|
||||
evt_agent_ = evt;
|
||||
}
|
||||
|
||||
void insert(std::size_t pos, nana::string&& text, nana::any&& value)
|
||||
void insert(std::size_t pos, native_string_type&& text, nana::any&& value)
|
||||
{
|
||||
if (pos >= list_.size())
|
||||
pos = list_.size();
|
||||
@ -639,7 +640,7 @@ namespace nana
|
||||
m.img.close();
|
||||
}
|
||||
|
||||
bool text(std::size_t pos, const nana::string& str)
|
||||
bool text(std::size_t pos, const native_string_type& str)
|
||||
{
|
||||
if (pos >= list_.size())
|
||||
throw std::out_of_range("tabbar: invalid position");
|
||||
@ -654,7 +655,7 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
nana::string text(std::size_t pos) const
|
||||
native_string_type text(std::size_t pos) const
|
||||
{
|
||||
if (pos >= list_.size())
|
||||
throw std::out_of_range("tabbar: invalid position");
|
||||
@ -787,7 +788,7 @@ namespace nana
|
||||
};
|
||||
|
||||
for(auto & m : list_)
|
||||
menulister_.append(m.text, fn);
|
||||
menulister_.append(to_utf8(m.text), fn);
|
||||
|
||||
auto r = toolbox_.area(toolbox_.ButtonList, basis_.graph->height());
|
||||
r.x += _m_toolbox_pos();
|
||||
@ -1003,10 +1004,12 @@ namespace nana
|
||||
if(item.text.size())
|
||||
{
|
||||
nana::size ts = basis_.graph->text_extent_size(item.text);
|
||||
basis_.graph->set_text_color(m.fgcolor.invisible() ? fgcolor : m.fgcolor);
|
||||
basis_.graph->palette(true, m.fgcolor.invisible() ? fgcolor : m.fgcolor);
|
||||
nana::paint::text_renderer tr(*basis_.graph);
|
||||
|
||||
std::wstring wtext = to_wstring(item.text);
|
||||
tr.render({ m.r.x + 24, m.r.y + static_cast<int>(m.r.height - ts.height) / 2 },
|
||||
item.text.c_str(), item.text.length(), basis_.item_pixels - 24 - 18, true);
|
||||
wtext.c_str(), wtext.length(), basis_.item_pixels - 24 - 18, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1027,7 +1030,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
basis_.graph->set_color(static_cast<color_rgb>(0x808080));
|
||||
basis_.graph->palette(false, static_cast<color_rgb>(0x808080));
|
||||
|
||||
int right = static_cast<int>(basis_.graph->width());
|
||||
int end = active_m.r.x + static_cast<int>(active_m.r.width);
|
||||
@ -1163,7 +1166,7 @@ namespace nana
|
||||
layouter_->event_agent(evt);
|
||||
}
|
||||
|
||||
void trigger::insert(std::size_t pos, nana::string&& text, nana::any&& value)
|
||||
void trigger::insert(std::size_t pos, native_string_type&& text, nana::any&& value)
|
||||
{
|
||||
layouter_->insert(pos, std::move(text), std::move(value));
|
||||
}
|
||||
@ -1200,13 +1203,13 @@ namespace nana
|
||||
API::refresh_window(layouter_->widget_handle());
|
||||
}
|
||||
|
||||
void trigger::text(std::size_t i, const nana::string& str)
|
||||
void trigger::text(std::size_t i, const native_string_type& str)
|
||||
{
|
||||
if(layouter_->text(i, str))
|
||||
API::refresh_window(layouter_->widget_handle());
|
||||
}
|
||||
|
||||
nana::string trigger::text(std::size_t i) const
|
||||
native_string_type trigger::text(std::size_t i) const
|
||||
{
|
||||
return layouter_->text(i);
|
||||
}
|
||||
@ -1450,8 +1453,8 @@ namespace nana
|
||||
rectangle r{ m.pos_ends.first, 0, static_cast<unsigned>(m.pos_ends.second - m.pos_ends.first), graph.height() };
|
||||
if (indexes.active_pos == pos)
|
||||
{
|
||||
graph.set_color(colors::white);
|
||||
graph.set_text_color(colors::black);
|
||||
graph.palette(false, colors::white);
|
||||
graph.palette(true, colors::black);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1460,8 +1463,8 @@ namespace nana
|
||||
if (pos == indexes.hovered_pos)
|
||||
bgcolor = bgcolor.blend(colors::white, 0.5);
|
||||
|
||||
graph.set_color(bgcolor);
|
||||
graph.set_text_color(colors::white);
|
||||
graph.palette(false, bgcolor);
|
||||
graph.palette(true, colors::white);
|
||||
}
|
||||
|
||||
graph.rectangle(r, true);
|
||||
|
||||
@ -209,14 +209,16 @@ namespace drawerbase {
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
textbox::textbox(window wd, const nana::string& text, bool visible)
|
||||
textbox::textbox(window wd, const std::string& text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
|
||||
textbox::textbox(window wd, const nana::char_t* text, bool visible)
|
||||
textbox::textbox(window wd, const char* text, bool visible)
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
}
|
||||
@ -226,7 +228,7 @@ namespace drawerbase {
|
||||
create(wd, r, visible);
|
||||
}
|
||||
|
||||
void textbox::load(nana::string file)
|
||||
void textbox::load(std::string file)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -234,7 +236,7 @@ namespace drawerbase {
|
||||
API::update_window(handle());
|
||||
}
|
||||
|
||||
void textbox::store(nana::string file)
|
||||
void textbox::store(std::string file)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -242,7 +244,7 @@ namespace drawerbase {
|
||||
editor->textbase().store(std::move(file), false, nana::unicode::utf8); //3rd parameter is just for syntax, it will be ignored
|
||||
}
|
||||
|
||||
void textbox::store(nana::string file, nana::unicode encoding)
|
||||
void textbox::store(std::string file, nana::unicode encoding)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -252,7 +254,7 @@ namespace drawerbase {
|
||||
|
||||
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
|
||||
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
|
||||
textbox& textbox::indention(bool enb, std::function<nana::string()> generator)
|
||||
textbox& textbox::indention(bool enb, std::function<std::string()> generator)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -261,20 +263,20 @@ namespace drawerbase {
|
||||
return *this;
|
||||
}
|
||||
|
||||
textbox& textbox::reset(nana::string str)
|
||||
textbox& textbox::reset(const std::string& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if (editor)
|
||||
{
|
||||
editor->text(std::move(str));
|
||||
editor->text(to_wstring(str));
|
||||
editor->textbase().reset();
|
||||
API::update_window(this->handle());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
nana::string textbox::filename() const
|
||||
std::string textbox::filename() const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -308,11 +310,20 @@ namespace drawerbase {
|
||||
return (editor ? editor->textbase().saved() : false);
|
||||
}
|
||||
|
||||
bool textbox::getline(std::size_t line_index, nana::string& text) const
|
||||
bool textbox::getline(std::size_t line_index, std::string& text) const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
return (editor ? editor->getline(line_index, text) : false);
|
||||
if (editor)
|
||||
{
|
||||
std::wstring line_text;
|
||||
if (editor->getline(line_index, line_text))
|
||||
{
|
||||
text = utf8_cast(line_text);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Gets the caret position
|
||||
@ -347,7 +358,7 @@ namespace drawerbase {
|
||||
return *this;
|
||||
}
|
||||
|
||||
textbox& textbox::append(const nana::string& text, bool at_caret)
|
||||
textbox& textbox::append(const std::string& text, bool at_caret)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -356,7 +367,7 @@ namespace drawerbase {
|
||||
if(at_caret == false)
|
||||
editor->move_caret_end();
|
||||
|
||||
editor->put(text);
|
||||
editor->put(to_wstring(text));
|
||||
API::update_window(this->handle());
|
||||
}
|
||||
return *this;
|
||||
@ -411,7 +422,7 @@ namespace drawerbase {
|
||||
return *this;
|
||||
}
|
||||
|
||||
void textbox::set_accept(std::function<bool(nana::char_t)> fn)
|
||||
void textbox::set_accept(std::function<bool(wchar_t)> fn)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -419,7 +430,7 @@ namespace drawerbase {
|
||||
editor->set_accept(std::move(fn));
|
||||
}
|
||||
|
||||
textbox& textbox::tip_string(nana::string str)
|
||||
textbox& textbox::tip_string(std::string str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -428,7 +439,7 @@ namespace drawerbase {
|
||||
return *this;
|
||||
}
|
||||
|
||||
textbox& textbox::mask(nana::char_t ch)
|
||||
textbox& textbox::mask(wchar_t ch)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -484,45 +495,37 @@ namespace drawerbase {
|
||||
|
||||
int textbox::to_int() const
|
||||
{
|
||||
nana::string s = _m_caption();
|
||||
auto s = _m_caption();
|
||||
if (s.empty()) return 0;
|
||||
|
||||
#ifdef NANA_UNICODE
|
||||
std::wstringstream ss;
|
||||
#else
|
||||
std::stringstream ss;
|
||||
#endif
|
||||
int value;
|
||||
ss << s;
|
||||
ss << to_utf8(s);
|
||||
ss >> value;
|
||||
return value;
|
||||
}
|
||||
|
||||
double textbox::to_double() const
|
||||
{
|
||||
nana::string s = _m_caption();
|
||||
auto s = _m_caption();
|
||||
if (s.empty()) return 0;
|
||||
|
||||
#ifdef NANA_UNICODE
|
||||
std::wstringstream ss;
|
||||
#else
|
||||
std::stringstream ss;
|
||||
#endif
|
||||
double value;
|
||||
ss << s;
|
||||
ss << to_utf8(s);
|
||||
ss >> value;
|
||||
return value;
|
||||
}
|
||||
|
||||
textbox& textbox::from(int n)
|
||||
{
|
||||
_m_caption(std::to_wstring(n));
|
||||
_m_caption(to_nstring(n));
|
||||
return *this;
|
||||
}
|
||||
|
||||
textbox& textbox::from(double d)
|
||||
{
|
||||
_m_caption(std::to_wstring(d));
|
||||
_m_caption(to_nstring(d));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -542,7 +545,7 @@ namespace drawerbase {
|
||||
editor->erase_highlight(name);
|
||||
}
|
||||
|
||||
void textbox::set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<nana::string> kw_list)
|
||||
void textbox::set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::wstring> kw_list)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
@ -564,12 +567,12 @@ namespace drawerbase {
|
||||
}
|
||||
}
|
||||
|
||||
void textbox::erase_keyword(const nana::string& kw)
|
||||
void textbox::erase_keyword(const std::string& kw)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if (editor)
|
||||
editor->erase_keyword(kw);
|
||||
editor->erase_keyword(to_wstring(kw));
|
||||
}
|
||||
|
||||
std::vector<upoint> textbox::text_position() const
|
||||
@ -600,20 +603,23 @@ namespace drawerbase {
|
||||
}
|
||||
|
||||
//Override _m_caption for caption()
|
||||
nana::string textbox::_m_caption() const throw()
|
||||
auto textbox::_m_caption() const throw() -> native_string_type
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
return (editor ? editor->text() : nana::string());
|
||||
if (editor)
|
||||
return to_nstring(editor->text());
|
||||
|
||||
return native_string_type();
|
||||
}
|
||||
|
||||
void textbox::_m_caption(nana::string&& str)
|
||||
void textbox::_m_caption(native_string_type&& str)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if (editor)
|
||||
{
|
||||
editor->text(std::move(str));
|
||||
editor->text(to_wstring(str));
|
||||
API::update_window(this->handle());
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user