Merge remote-tracking branch 'nana/develop' into develop_nana

This commit is contained in:
qPCR4vir 2015-02-27 19:50:53 +01:00
commit 073d409a22
12 changed files with 470 additions and 200 deletions

View File

@ -21,6 +21,56 @@
#undef NANA_WINDOWS #undef NANA_WINDOWS
#endif #endif
//Implement workarounds for MinGW
#if defined(NANA_MINGW)
namespace std
{
//Workaround for no implemenation of std::stoi in MinGW.
int stoi(const std::string&, std::size_t * pos = nullptr, int base = 10);
int stoi(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stof in MinGW.
float stof(const std::string&, std::size_t * pos = nullptr);
float stof(const std::wstring&, std::size_t* pos = nullptr);
//Workaround for no implemenation of std::stod in MinGW.
double stod(const std::string&, std::size_t * pos = nullptr);
double stod(const std::wstring&, std::size_t* pos = nullptr);
//Workaround for no implemenation of std::stold in MinGW.
long double stold(const std::string&, std::size_t * pos = nullptr);
long double stold(const std::wstring&, std::size_t* pos = nullptr);
//Workaround for no implemenation of std::stol in MinGW.
long stol(const std::string&, std::size_t* pos = nullptr, int base = 10);
long stol(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stoll in MinGW.
long long stoll(const std::string&, std::size_t* pos = nullptr, int base = 10);
long long stoll(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stoul in MinGW.
unsigned long stoul(const std::string&, std::size_t* pos = nullptr, int base = 10);
unsigned long stoul(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stoull in MinGW.
unsigned long long stoull(const std::string&, std::size_t* pos = nullptr, int base = 10);
unsigned long long stoull(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::to_wstring in MinGW.
std::wstring to_wstring(long double);
std::wstring to_wstring(double);
std::wstring to_wstring(unsigned);
std::wstring to_wstring(int);
std::wstring to_wstring(long);
std::wstring to_wstring(unsigned long);
std::wstring to_wstring(long long);
std::wstring to_wstring(unsigned long long);
std::wstring to_wstring(float);
}
#endif
#ifndef NANA_UNICODE #ifndef NANA_UNICODE
namespace nana namespace nana
{ {
@ -40,28 +90,7 @@
namespace nana namespace nana
{ {
std::size_t strlen(const char_t* str); std::size_t strlen(const char_t* str);
double strtod(const char_t* str, char_t** endptr);
char_t* strcpy(char_t* dest, const char_t* source); char_t* strcpy(char_t* dest, const char_t* source);
//Workaround for no implemenation of std::stoi in MinGW.
int stoi(const std::string&, std::size_t * pos = nullptr, int base = 10);
int stoi(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
//Workaround for no implemenation of std::stod in MinGW.
double stod(const std::string&, std::size_t * pos = nullptr);
double stod(const std::wstring&, std::size_t* pos = nullptr);
//Workaround for no implemenation of std::to_wstring in MinGW.
std::wstring to_wstring(long double);
std::wstring to_wstring(double);
std::wstring to_wstring(unsigned);
std::wstring to_wstring(int);
std::wstring to_wstring(long);
std::wstring to_wstring(unsigned long);
std::wstring to_wstring(long long);
std::wstring to_wstring(unsigned long long);
std::wstring to_wstring(float);
} }
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)

View File

@ -558,7 +558,6 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
private: private:
drawerbase::listbox::essence_t & _m_ess() const; drawerbase::listbox::essence_t & _m_ess() const;
nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const; nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const;
size_type _m_headers() const;
drawerbase::listbox::category_t* _m_at_key(std::shared_ptr<nana::detail::key_interface>); drawerbase::listbox::category_t* _m_at_key(std::shared_ptr<nana::detail::key_interface>);
void _m_ease_key(nana::detail::key_interface*); void _m_ease_key(nana::detail::key_interface*);
}; };

View File

@ -82,7 +82,7 @@ namespace nana{ namespace paint
return false; return false;
std::unique_ptr<char[]> buffer(new char[static_cast<int>(size)]); std::unique_ptr<char[]> buffer(new char[static_cast<int>(size)]);
ifs.read(buffer.get(), size); ifs.read(buffer.get(), size);
if(size == ifs.gcount()) if(size == ifs.gcount())
{ {
@ -94,7 +94,7 @@ namespace nana{ namespace paint
//Bitmap file is 4byte-aligned for each line. //Bitmap file is 4byte-aligned for each line.
std::size_t bytes_per_line; std::size_t bytes_per_line;
const std::size_t height_pixels = abs(info->bmiHeader.biHeight); const std::size_t height_pixels = std::abs(info->bmiHeader.biHeight);
if(0 == info->bmiHeader.biSizeImage) if(0 == info->bmiHeader.biSizeImage)
bytes_per_line = (((info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) & ~31) >> 3); bytes_per_line = (((info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) & ~31) >> 3);
else else
@ -204,7 +204,7 @@ namespace nana{ namespace paint
d = dpend; d = dpend;
s -= bytes_per_line; s -= bytes_per_line;
} }
} }
} }
else if(2 == info->bmiHeader.biBitCount) else if(2 == info->bmiHeader.biBitCount)
{ {
@ -257,7 +257,7 @@ namespace nana{ namespace paint
d = dpend; d = dpend;
s -= bytes_per_line; s -= bytes_per_line;
} }
} }
} }
else if(1 == info->bmiHeader.biBitCount) else if(1 == info->bmiHeader.biBitCount)
{ {
@ -310,7 +310,7 @@ namespace nana{ namespace paint
d = dpend; d = dpend;
s -= bytes_per_line; s -= bytes_per_line;
} }
} }
} }
} }
} }

View File

@ -11,7 +11,11 @@
*/ */
#include <nana/basic_types.hpp> #include <nana/basic_types.hpp>
#if defined(USE_STD_REGEX)
#include <regex> #include <regex>
#else
#include <vector>
#endif
#include <algorithm> #include <algorithm>
namespace nana namespace nana
@ -60,10 +64,46 @@ namespace nana
a_ = 1.0; a_ = 1.0;
} }
#if !defined(USE_STD_REGEX)
std::string read_number(std::string& str, std::size_t& pos)
{
pos = str.find_first_of("0123456789", pos);
if (pos == str.npos)
return{};
auto end = str.find_first_not_of("0123456789", pos + 1);
//integer part
if (end == str.npos)
{
pos = end;
return str.substr(pos);
}
if (str[end] == '.')
{
auto decimal_end = str.find_first_not_of("0123456789", end + 1);
if ((decimal_end == str.npos) || (decimal_end == end + 1)) //Because of missing %
return{};
end = decimal_end;
}
auto ch = str[end];
if (ch == '%' || ch == ' ' || ch == ',' || ch == ')')
{
auto start = pos;
pos = end + (ch == '%' ? 1 : 0);
return str.substr(start, pos - start);
}
return{};
}
#endif
//Initializes the color with a CSS-like string //Initializes the color with a CSS-like string
//contributor: BigDave(mortis2007 at hotmail co uk) //contributor: BigDave(mortis2007 at hotmail co uk)
//date: February 3, 2015 //date: February 3, 2015
//maintainor: Jinhao, extended the support of CSS-spec //maintainor: Jinhao, extended the support of CSS-spec
color::color(std::string css_color) color::color(std::string css_color)
: a_(1.0) : a_(1.0)
{ {
@ -85,7 +125,7 @@ namespace nana
if ((endpos - pos != 4) && (endpos - pos != 7)) if ((endpos - pos != 4) && (endpos - pos != 7))
throw std::invalid_argument(excpt_what); throw std::invalid_argument(excpt_what);
auto n = ::nana::stoi(css_color.substr(pos + 1, endpos - pos - 1), nullptr, 16); auto n = std::stoi(css_color.substr(pos + 1, endpos - pos - 1), nullptr, 16);
if (endpos - pos == 4) if (endpos - pos == 4)
{ {
@ -135,6 +175,7 @@ namespace nana
has_alpha = true; has_alpha = true;
} }
#if defined(USE_STD_REGEX)
std::regex pat; std::regex pat;
std::regex_iterator<std::string::iterator> i, end; std::regex_iterator<std::string::iterator> i, end;
auto type_name = css_color.substr(pos, 3); auto type_name = css_color.substr(pos, 3);
@ -222,6 +263,106 @@ namespace nana
throw std::invalid_argument(excpt_what); //invalid alpha value throw std::invalid_argument(excpt_what); //invalid alpha value
a_ = ::nana::stod(i->str()); a_ = ::nana::stod(i->str());
} }
#else
auto type_name = css_color.substr(pos, 3);
pos = css_color.find_first_not_of(' ', type_end);
if (pos == css_color.npos || css_color[pos] != '(')
throw std::invalid_argument(excpt_what);
auto str = read_number(css_color, ++pos);
if (str.empty())
throw std::invalid_argument(excpt_what);
if ("rgb" == type_name)
{
std::vector<std::string> rgb;
rgb.emplace_back(std::move(str));
const bool is_real = (rgb.back().back() == '%');
for (int i = 0; i < 2; ++i)
{
pos = css_color.find_first_not_of(' ', pos);
if (pos == css_color.npos || css_color[pos] != ',')
throw std::invalid_argument(excpt_what);
str = read_number(css_color, ++pos);
if (str.empty())
throw std::invalid_argument(excpt_what);
rgb.emplace_back(std::move(str));
if (rgb.size() == 3)
break;
}
if (rgb.size() != 3)
throw std::invalid_argument(excpt_what);
if (is_real)
{
auto pr = std::stod(rgb[0].substr(0, rgb[0].size() - 1));
r_ = (pr > 100 ? 255.0 : 2.55 * pr);
pr = std::stod(rgb[1].substr(0, rgb[1].size() - 1));
g_ = (pr > 100 ? 255.0 : 2.55 * pr);
pr = std::stod(rgb[2].substr(0, rgb[2].size() - 1));
b_ = (pr > 100 ? 255.0 : 2.55 * pr);
}
else
{
r_ = std::stod(rgb[0]);
if (r_ > 255.0) r_ = 255;
g_ = std::stod(rgb[1]);
if (g_ > 255.0) g_ = 255;
b_ = std::stod(rgb[2]);
if (b_ > 255.0) b_ = 255;
}
}
else if ("hsl" == type_name)
{
if (str.back() == '%')
throw std::invalid_argument(excpt_what);
auto h = std::stod(str);
pos = css_color.find_first_not_of(' ', pos);
if (pos == css_color.npos || css_color[pos] != ',')
throw std::invalid_argument(excpt_what);
str = read_number(css_color, ++pos);
if (str.empty() || str.back() != '%')
throw std::invalid_argument(excpt_what);
auto s = std::stod(str.substr(0, str.size() - 1));
pos = css_color.find_first_not_of(' ', pos);
if (pos == css_color.npos || css_color[pos] != ',')
throw std::invalid_argument(excpt_what);
str = read_number(css_color, ++pos);
if (str.empty() || str.back() != '%')
throw std::invalid_argument(excpt_what);
auto l = std::stod(str.substr(0, str.size() - 1));
from_hsl(h, s / 100, l / 100);
}
else
throw std::invalid_argument(excpt_what); //invalid color type
if (has_alpha)
{
str = read_number(css_color, ++pos);
if (str.empty() || str.back() == '%')
throw std::invalid_argument(excpt_what); //invalid alpha value
a_ = std::stod(str);
}
#endif
} }
color& color::from_rgb(unsigned red, unsigned green, unsigned blue) color& color::from_rgb(unsigned red, unsigned green, unsigned blue)

View File

@ -15,6 +15,7 @@
#include <nana/deploy.hpp> #include <nana/deploy.hpp>
#include <cstdlib> #include <cstdlib>
#include <stdexcept> #include <stdexcept>
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
#include <windows.h> #include <windows.h>
#elif defined(NANA_LINUX) #elif defined(NANA_LINUX)
@ -22,38 +23,12 @@
#include PLATFORM_SPEC_HPP #include PLATFORM_SPEC_HPP
#endif #endif
namespace nana #if defined(NANA_MINGW)
#include <sstream>
namespace std
{ {
std::size_t strlen(const char_t* str)
{
#if defined(NANA_UNICODE)
return ::wcslen(str);
#else
return ::strlen(str);
#endif
}
double strtod(const char_t* str, char_t** endptr)
{
#if defined(NANA_UNICODE)
return ::wcstod(str, endptr);
#else
return ::strtod(str, endptr);
#endif
}
char_t* strcpy(char_t* dest, const char_t* source)
{
#if defined(NANA_UNICODE)
return ::wcscpy(dest, source);
#else
return ::strcpy(dest, source);
#endif
}
int stoi(const std::string& str, std::size_t * pos, int base) int stoi(const std::string& str, std::size_t * pos, int base)
{ {
#if defined(NANA_MINGW)
auto sptr = str.c_str(); auto sptr = str.c_str();
char *end; char *end;
errno = 0; errno = 0;
@ -67,14 +42,10 @@ namespace nana
if (pos) if (pos)
*pos = (std::size_t)(end - sptr); *pos = (std::size_t)(end - sptr);
return ((int)result); return ((int)result);
#else
return std::stoi(str, pos, base);
#endif
} }
int stoi(const std::wstring& str, std::size_t* pos, int base) int stoi(const std::wstring& str, std::size_t* pos, int base)
{ {
#if defined(NANA_MINGW)
auto sptr = str.data(); auto sptr = str.data();
wchar_t *end; wchar_t *end;
errno = 0; errno = 0;
@ -88,14 +59,42 @@ namespace nana
if (pos) if (pos)
*pos = (std::size_t)(end - sptr); *pos = (std::size_t)(end - sptr);
return ((int)result); return ((int)result);
#else }
return std::stoi(str, pos, base);
#endif float stof(const std::string& str, std::size_t * pos)
{
auto *ptr = str.data();
errno = 0;
char *end;
auto result = std::strtof(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stof argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
float stof(const std::wstring& str, std::size_t* pos)
{
auto *ptr = str.data();
errno = 0;
wchar_t *end;
auto result = std::wcstof(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stof argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
} }
double stod(const std::string& str, std::size_t * pos) double stod(const std::string& str, std::size_t * pos)
{ {
#ifdef NANA_MINGW
auto *ptr = str.data(); auto *ptr = str.data();
errno = 0; errno = 0;
char *end; char *end;
@ -108,14 +107,10 @@ namespace nana
if (pos) if (pos)
*pos = (std::size_t)(end - ptr); *pos = (std::size_t)(end - ptr);
return result; return result;
#else
return std::stod(str, pos);
#endif
} }
double stod(const std::wstring& str, std::size_t* pos) double stod(const std::wstring& str, std::size_t* pos)
{ {
#ifdef NANA_MINGW
auto *ptr = str.data(); auto *ptr = str.data();
errno = 0; errno = 0;
wchar_t *end; wchar_t *end;
@ -128,110 +123,258 @@ namespace nana
if (pos) if (pos)
*pos = (std::size_t)(end - ptr); *pos = (std::size_t)(end - ptr);
return result; return result;
#else }
return std::stod(str, pos);
#endif long double stold(const std::string& str, std::size_t * pos)
{
auto *ptr = str.data();
errno = 0;
char *end;
auto result = std::strtold(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stold argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long double stold(const std::wstring& str, std::size_t* pos)
{
auto *ptr = str.data();
errno = 0;
wchar_t *end;
auto result = std::wcstold(ptr, &end);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stold argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long stol(const std::string& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
char *end;
auto result = std::strtol(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stol argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long stol(const std::wstring& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
wchar_t *end;
auto result = std::wcstol(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stol argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
//Workaround for no implemenation of std::stoll in MinGW.
long long stoll(const std::string& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
char* end;
auto result = std::strtoll(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoll argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
long long stoll(const std::wstring& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
wchar_t* end;
auto result = std::wcstoll(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoll argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
unsigned long long stoull(const std::string& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
char* end;
auto result = std::strtoull(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoull argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
unsigned long long stoull(const std::wstring& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
wchar_t* end;
auto result = std::wcstoull(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoull argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
//Workaround for no implemenation of std::stoul in MinGW.
unsigned long stoul(const std::string& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
char* end;
auto result = std::strtoul(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoul argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
}
unsigned long stoul(const std::wstring& str, std::size_t* pos, int base)
{
auto *ptr = str.data();
errno = 0;
wchar_t* end;
auto result = std::wcstoul(ptr, &end, base);
if (ptr == end)
throw std::invalid_argument("invalid stod argument");
if (errno == ERANGE)
throw std::out_of_range("stoul argument out of range");
if (pos)
*pos = (std::size_t)(end - ptr);
return result;
} }
std::wstring to_wstring(double v) std::wstring to_wstring(double v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
#else
return std::to_wstring(v);
#endif
} }
std::wstring to_wstring(long double v) std::wstring to_wstring(long double v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
#else
return std::to_wstring(v);
#endif
} }
std::wstring to_wstring(unsigned v) std::wstring to_wstring(unsigned v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
#else
return std::to_wstring(v);
#endif
} }
std::wstring to_wstring(int v) std::wstring to_wstring(int v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
#else
return std::to_wstring(v);
#endif
} }
std::wstring to_wstring(long v) std::wstring to_wstring(long v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
#else
return std::to_wstring(v);
#endif
} }
std::wstring to_wstring(unsigned long v) std::wstring to_wstring(unsigned long v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
#else
return std::to_wstring(v);
#endif
} }
std::wstring to_wstring(long long v) std::wstring to_wstring(long long v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
#else
return std::to_wstring(v);
#endif
} }
std::wstring to_wstring(unsigned long long v) std::wstring to_wstring(unsigned long long v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
#else
return std::to_wstring(v);
#endif
} }
std::wstring to_wstring(float v) std::wstring to_wstring(float v)
{ {
#ifdef NANA_MINGW
std::wstringstream ss; std::wstringstream ss;
ss << v; ss << v;
return ss.str(); return ss.str();
}
}
#endif
namespace nana
{
std::size_t strlen(const char_t* str)
{
#if defined(NANA_UNICODE)
return ::wcslen(str);
#else #else
return std::to_wstring(v); return ::strlen(str);
#endif #endif
} }
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) bool is_incomplete(const nana::string& str, unsigned pos)
{ {
#ifndef NANA_UNICODE #ifndef NANA_UNICODE

View File

@ -18,11 +18,11 @@ namespace nana
//overlap test if overlaped between r1 and r2 //overlap test if overlaped between r1 and r2
bool overlap(const rectangle& r1, const rectangle& r2) bool overlap(const rectangle& r1, const rectangle& r2)
{ {
if (r1.y + long long(r1.height) <= r2.y) return false; if (r1.y + (long long)(r1.height) <= r2.y) return false;
if(r1.y >= r2.y + long long(r2.height)) return false; if(r1.y >= r2.y + (long long)(r2.height)) return false;
if(r1.x + long long(r1.width) <= r2.x) return false; if(r1.x + (long long)(r1.width) <= r2.x) return false;
if(r1.x >= r2.x + long long(r2.width)) return false; if(r1.x >= r2.x + (long long)(r2.width)) return false;
return true; return true;
} }
@ -255,7 +255,7 @@ namespace nana
ref_s.width = static_cast<unsigned>(ref_s.height * rate_input); ref_s.width = static_cast<unsigned>(ref_s.height * rate_input);
else if (rate_input > rate_ref) else if (rate_input > rate_ref)
ref_s.height = static_cast<unsigned>(ref_s.width / rate_input); ref_s.height = static_cast<unsigned>(ref_s.width / rate_input);
return ref_s; return ref_s;
} }

View File

@ -701,12 +701,12 @@ namespace nana
//get the longest value //get the longest value
int longest = (std::abs((impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(impl->last < 0 ? impl->last * 10 : impl->last) ? impl->last : impl->begin); int longest = (std::abs((impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(impl->last < 0 ? impl->last * 10 : impl->last) ? impl->last : impl->begin);
paint::graphics graph{ ::nana::size{ 10, 10 } }; paint::graphics graph{ ::nana::size{ 10, 10 } };
auto value_px = graph.text_extent_size(::nana::to_wstring(longest)).width + 34; auto value_px = graph.text_extent_size(std::to_wstring(longest)).width + 34;
impl->spinbox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, value_px, 0 }); 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.range(impl->begin, impl->last, impl->step);
impl->spinbox.value(::nana::to_wstring(impl->value)); impl->spinbox.value(std::to_wstring(impl->value));
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg) impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg)
{ {
@ -779,12 +779,12 @@ namespace nana
//get the longest value //get the longest value
auto longest = (std::abs((impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(impl->last < 0 ? impl->last * 10 : impl->last) ? impl->last : impl->begin); auto longest = (std::abs((impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(impl->last < 0 ? impl->last * 10 : impl->last) ? impl->last : impl->begin);
paint::graphics graph{ ::nana::size{ 10, 10 } }; paint::graphics graph{ ::nana::size{ 10, 10 } };
auto value_px = graph.text_extent_size(::nana::to_wstring(longest)).width + 34; auto value_px = graph.text_extent_size(std::to_wstring(longest)).width + 34;
impl->spinbox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, value_px, 0 }); 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.range(impl->begin, impl->last, impl->step);
impl->spinbox.value(::nana::to_wstring(impl->value)); impl->spinbox.value(std::to_wstring(impl->value));
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg) impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg)
{ {
@ -947,7 +947,7 @@ namespace nana
::nana::string inputbox::date::value() const ::nana::string inputbox::date::value() const
{ {
return nana::to_wstring(impl_->month) + L'-' + nana::to_wstring(impl_->day) + L", " + nana::to_wstring(impl_->year); return std::to_wstring(impl_->month) + L'-' + std::to_wstring(impl_->day) + L", " + std::to_wstring(impl_->year);
} }
int inputbox::date::year() const int inputbox::date::year() const
@ -1008,8 +1008,8 @@ namespace nana
impl->wdg_month.option(today.month - 1); impl->wdg_month.option(today.month - 1);
impl->wdg_day.value(::nana::to_wstring(today.day)); impl->wdg_day.value(std::to_wstring(today.day));
impl->wdg_year.value(::nana::to_wstring(today.year)); impl->wdg_year.value(std::to_wstring(today.year));
impl->dock.events().resized.connect_unignorable([impl, label_px](const ::nana::arg_resized& arg) impl->dock.events().resized.connect_unignorable([impl, label_px](const ::nana::arg_resized& arg)
{ {
@ -1050,7 +1050,7 @@ namespace nana
if (day > days) if (day > days)
day = days; day = days;
impl->wdg_day.value(::nana::to_wstring(day)); impl->wdg_day.value(std::to_wstring(day));
}; };
impl->wdg_year.events().text_changed.connect_unignorable(make_days); impl->wdg_year.events().text_changed.connect_unignorable(make_days);

View File

@ -133,7 +133,7 @@ namespace nana
str = ::nana::internationalization()(monthstr[chmonth_.month - 1]); str = ::nana::internationalization()(monthstr[chmonth_.month - 1]);
str += STR(" "); str += STR(" ");
} }
str += ::nana::to_wstring(chmonth_.year); str += std::to_wstring(chmonth_.year);
nana::size txt_s = graph.text_extent_size(str); nana::size txt_s = graph.text_extent_size(str);
@ -203,7 +203,7 @@ namespace nana
void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, int number, bool primary, bool sel) 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, ::nana::to_wstring(number), primary, sel); _m_draw_pos(dbasis, graph, x, y, std::to_wstring(number), primary, sel);
} }
void trigger::_m_draw_ex_days(drawing_basis & dbasis, graph_reference graph, int begx, int begy, bool before) void trigger::_m_draw_ex_days(drawing_basis & dbasis, graph_reference graph, int begx, int begy, bool before)

View File

@ -18,7 +18,6 @@
#include <list> #include <list>
#include <deque> #include <deque>
#include <stdexcept> #include <stdexcept>
#include <sstream>
#include <algorithm> #include <algorithm>
namespace nana namespace nana
@ -87,66 +86,66 @@ namespace nana
} }
oresolver& oresolver::operator<<(short n) oresolver& oresolver::operator<<(short n)
{ {
cells_.emplace_back(::nana::to_wstring(n)); cells_.emplace_back(std::to_wstring(n));
return *this; return *this;
} }
oresolver& oresolver::operator<<(unsigned short n) oresolver& oresolver::operator<<(unsigned short n)
{ {
cells_.emplace_back(::nana::to_wstring(n)); cells_.emplace_back(std::to_wstring(n));
return *this; return *this;
} }
oresolver& oresolver::operator<<(int n) oresolver& oresolver::operator<<(int n)
{ {
cells_.emplace_back(::nana::to_wstring(n)); cells_.emplace_back(std::to_wstring(n));
return *this; return *this;
} }
oresolver& oresolver::operator<<(unsigned int n) oresolver& oresolver::operator<<(unsigned int n)
{ {
cells_.emplace_back(::nana::to_wstring(n)); cells_.emplace_back(std::to_wstring(n));
return *this; return *this;
} }
oresolver& oresolver::operator<<(long n) oresolver& oresolver::operator<<(long n)
{ {
cells_.emplace_back(::nana::to_wstring(n)); cells_.emplace_back(std::to_wstring(n));
return *this; return *this;
} }
oresolver& oresolver::operator<<(unsigned long n) oresolver& oresolver::operator<<(unsigned long n)
{ {
cells_.emplace_back(::nana::to_wstring(n)); cells_.emplace_back(std::to_wstring(n));
return *this; return *this;
} }
oresolver& oresolver::operator<<(long long n) oresolver& oresolver::operator<<(long long n)
{ {
cells_.emplace_back(::nana::to_wstring(n)); cells_.emplace_back(std::to_wstring(n));
return *this; return *this;
} }
oresolver& oresolver::operator<<(unsigned long long n) oresolver& oresolver::operator<<(unsigned long long n)
{ {
cells_.emplace_back(::nana::to_wstring(n)); cells_.emplace_back(std::to_wstring(n));
return *this; return *this;
} }
oresolver& oresolver::operator<<(float f) oresolver& oresolver::operator<<(float f)
{ {
cells_.emplace_back(::nana::to_wstring(f)); cells_.emplace_back(std::to_wstring(f));
return *this; return *this;
} }
oresolver& oresolver::operator<<(double f) oresolver& oresolver::operator<<(double f)
{ {
cells_.emplace_back(::nana::to_wstring(f)); cells_.emplace_back(std::to_wstring(f));
return *this; return *this;
} }
oresolver& oresolver::operator<<(long double f) oresolver& oresolver::operator<<(long double f)
{ {
cells_.emplace_back(::nana::to_wstring(f)); cells_.emplace_back(std::to_wstring(f));
return *this; return *this;
} }
@ -201,117 +200,82 @@ namespace nana
iresolver& iresolver::operator>>(bool& n) iresolver& iresolver::operator>>(bool& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = (std::stoi(cells_[pos_++].text) == 0);
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(short& n) iresolver& iresolver::operator>>(short& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = std::stoi(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(unsigned short& n) iresolver& iresolver::operator>>(unsigned short& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = static_cast<unsigned short>(std::stoul(cells_[pos_++].text));
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(int& n) iresolver& iresolver::operator>>(int& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = std::stoi(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(unsigned int& n) iresolver& iresolver::operator>>(unsigned int& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = std::stoul(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(long& n) iresolver& iresolver::operator>>(long& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = std::stol(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(unsigned long& n) iresolver& iresolver::operator>>(unsigned long& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = std::stoul(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(long long& n) iresolver& iresolver::operator>>(long long& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = std::stoll(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(unsigned long long& n) iresolver& iresolver::operator>>(unsigned long long& n)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ n = std::stoull(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> n;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(float& f) iresolver& iresolver::operator>>(float& f)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ f = std::stof(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> f;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(double& f) iresolver& iresolver::operator>>(double& f)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ f = std::stod(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> f;
}
return *this; return *this;
} }
iresolver& iresolver::operator>>(long double& f) iresolver& iresolver::operator>>(long double& f)
{ {
if (pos_ < cells_.size()) if (pos_ < cells_.size())
{ f = std::stold(cells_[pos_++].text);
std::wstringstream ss(cells_[pos_++].text);
ss >> f;
}
return *this; return *this;
} }
@ -1183,8 +1147,9 @@ namespace nana
} }
} }
void item_checked(selection& vec) const selection item_checked() const
{ {
selection vec;
index_pair id; index_pair id;
for(auto & cat : list_) for(auto & cat : list_)
{ {
@ -1197,6 +1162,7 @@ namespace nana
} }
++id.cat; ++id.cat;
} }
return vec;
} }
void select_range(index_pair fr, index_pair to, bool sel) void select_range(index_pair fr, index_pair to, bool sel)
@ -2595,7 +2561,7 @@ namespace nana
graph->string({ x + 20, y + txtoff }, categ.text, txt_color); graph->string({ x + 20, y + txtoff }, categ.text, txt_color);
::nana::string str = L'(' + ::nana::to_wstring(categ.items.size()) + L')'; ::nana::string str = L'(' + std::to_wstring(categ.items.size()) + L')';
unsigned str_w = graph->text_extent_size(str).width; unsigned str_w = graph->text_extent_size(str).width;
@ -3699,8 +3665,7 @@ namespace nana
auto & ess = _m_ess(); auto & ess = _m_ess();
if (ess.lister.insert(pos, std::move(text))) if (ess.lister.insert(pos, std::move(text)))
{ {
window wd = handle(); if (! empty())
if (false == API::empty_window(wd))
{ {
auto & item = ess.lister.at(pos); auto & item = ess.lister.at(pos);
item.bgcolor = bgcolor(); item.bgcolor = bgcolor();
@ -3722,9 +3687,7 @@ namespace nana
auto listbox::checked() const -> selection auto listbox::checked() const -> selection
{ {
selection s; return _m_ess().lister.item_checked();
_m_ess().lister.item_checked(s);
return std::move(s);
} }
void listbox::clear(size_type cat) void listbox::clear(size_type cat)
@ -3891,11 +3854,6 @@ namespace nana
return _m_ess().lister.anyobj(index_pair{cat, index}, allocate_if_empty); return _m_ess().lister.anyobj(index_pair{cat, index}, allocate_if_empty);
} }
auto listbox::_m_headers() const -> size_type
{
return _m_ess().header.cont().size();
}
drawerbase::listbox::category_t* listbox::_m_at_key(std::shared_ptr<nana::detail::key_interface> ptr) drawerbase::listbox::category_t* listbox::_m_at_key(std::shared_ptr<nana::detail::key_interface> ptr)
{ {
auto & ess = _m_ess(); auto & ess = _m_ess();

View File

@ -73,7 +73,7 @@ namespace nana
std::wstring value() const override std::wstring value() const override
{ {
return ::nana::to_wstring(value_); return std::to_wstring(value_);
} }
bool value(const std::wstring& value_str, bool & diff) override bool value(const std::wstring& value_str, bool & diff) override
@ -663,12 +663,12 @@ namespace nana
int spinbox::to_int() const int spinbox::to_int() const
{ {
return ::nana::stoi(value()); return std::stoi(value());
} }
double spinbox::to_double() const double spinbox::to_double() const
{ {
return ::nana::stod(value()); return std::stod(value());
} }
void spinbox::modifier(std::wstring prefix, std::wstring suffix) void spinbox::modifier(std::wstring prefix, std::wstring suffix)

View File

@ -456,13 +456,13 @@ namespace drawerbase {
textbox& textbox::from(int n) textbox& textbox::from(int n)
{ {
_m_caption(::nana::to_wstring(n)); _m_caption(std::to_wstring(n));
return *this; return *this;
} }
textbox& textbox::from(double d) textbox& textbox::from(double d)
{ {
_m_caption(::nana::to_wstring(d)); _m_caption(std::to_wstring(d));
return *this; return *this;
} }

View File

@ -343,7 +343,7 @@ namespace nana
erase_n = str.size() - offset; erase_n = str.size() - offset;
//If there is not a parameter for %argNNN, the %argNNN will be erased. //If there is not a parameter for %argNNN, the %argNNN will be erased.
std::size_t arg = static_cast<std::size_t>(::nana::stoi(str.substr(offset + 4, arg_n))); std::size_t arg = static_cast<std::size_t>(std::stoi(str.substr(offset + 4, arg_n)));
if (arg_strs && arg < arg_strs->size()) if (arg_strs && arg < arg_strs->size())
str.replace(offset, erase_n, (*arg_strs)[arg]); str.replace(offset, erase_n, (*arg_strs)[arg]);