use UTF-8 for string representation

This commit is contained in:
Jinhao
2015-12-31 01:09:52 +08:00
parent 0a396c12c2
commit a42ebe19b4
38 changed files with 182 additions and 416 deletions

View File

@@ -11,7 +11,7 @@ namespace nana
namespace helper
{
template<typename F>
void for_each_line(const nana::char_t * str, std::size_t len, int top, F & f)
void for_each_line(const wchar_t * str, std::size_t len, int top, F & f)
{
auto head = str;
auto end = str + len;
@@ -39,7 +39,7 @@ namespace nana
: dw(dw), x(x), endpos(endpos), text_align(ta)
{}
unsigned operator()(const int top, const nana::char_t * buf, std::size_t bufsize)
unsigned operator()(const int top, const wchar_t * buf, std::size_t bufsize)
{
nana::point pos{ x, top };
unsigned pixels = 0;
@@ -131,7 +131,7 @@ namespace nana
this->endpos = x;
}
unsigned operator()(const int top, const nana::char_t * buf, std::size_t bufsize)
unsigned operator()(const int top, const wchar_t * buf, std::size_t bufsize)
{
drawable_type dw = graph.handle();
::nana::point pos{ x, top };
@@ -187,7 +187,7 @@ namespace nana
: graph(graph), x(x), endpos(endpos), text_align(ta)
{}
unsigned operator()(const int top, const nana::char_t * buf, std::size_t bufsize)
unsigned operator()(const int top, const wchar_t * buf, std::size_t bufsize)
{
unsigned pixels = 0;
@@ -249,8 +249,8 @@ namespace nana
else
{
//Search the splittable character from idx_head to idx_splitted
const nana::char_t * u = i.begin + idx_splitted;
const nana::char_t * head = i.begin + idx_head;
const wchar_t * u = i.begin + idx_splitted;
const wchar_t * head = i.begin + idx_head;
for(; head < u; --u)
{
@@ -269,7 +269,7 @@ namespace nana
else
{
u = i.begin + idx_splitted;
const nana::char_t * end = i.begin + len;
const wchar_t * end = i.begin + len;
for(; u < end; ++u)
{
if(splittable(head, u - head))
@@ -372,12 +372,12 @@ namespace nana
return end;
}
static bool splittable(const nana::char_t * str, std::size_t index)
static bool splittable(const wchar_t * str, std::size_t index)
{
nana::char_t ch = str[index];
wchar_t ch = str[index];
if(('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
{
nana::char_t prch;
wchar_t prch;
if(index)
{
prch = str[index - 1];
@@ -406,7 +406,7 @@ namespace nana
: graph(graph), x(x), endpos(endpos), extents(0)
{}
unsigned operator()(int top, const nana::char_t * buf, std::size_t bufsize)
unsigned operator()(int top, const wchar_t * buf, std::size_t bufsize)
{
unsigned pixels = 0;
@@ -467,8 +467,8 @@ namespace nana
else
{
//Search the splittable character from idx_head to idx_splitted
const nana::char_t * u = i.begin + idx_splitted;
const nana::char_t * head = i.begin + idx_head;
const wchar_t * u = i.begin + idx_splitted;
const wchar_t * head = i.begin + idx_head;
for(; head < u; --u)
{
@@ -486,7 +486,7 @@ namespace nana
else
{
u = i.begin + idx_splitted;
const nana::char_t * end = i.begin + len;
const wchar_t * end = i.begin + len;
for(; u < end; ++u)
{
if(draw_string_auto_changing_lines::splittable(head, u - head))
@@ -542,7 +542,7 @@ namespace nana
: graph_(graph), text_align_(ta)
{}
nana::size text_renderer::extent_size(int x, int y, const char_t* str, std::size_t len, unsigned restricted_pixels) const
nana::size text_renderer::extent_size(int x, int y, const wchar_t* str, std::size_t len, unsigned restricted_pixels) const
{
nana::size extents;
if(graph_)
@@ -555,7 +555,7 @@ namespace nana
return extents;
}
void text_renderer::render(const point& pos, const char_t * str, std::size_t len)
void text_renderer::render(const point& pos, const wchar_t * str, std::size_t len)
{
if (graph_)
{
@@ -564,7 +564,7 @@ namespace nana
}
}
void text_renderer::render(const point& pos, const char_t* str, std::size_t len, unsigned restricted_pixels, bool omitted)
void text_renderer::render(const point& pos, const wchar_t* str, std::size_t len, unsigned restricted_pixels, bool omitted)
{
if (graph_)
{
@@ -573,7 +573,7 @@ namespace nana
}
}
void text_renderer::render(const point& pos, const char_t * str, std::size_t len, unsigned restricted_pixels)
void text_renderer::render(const point& pos, const wchar_t * str, std::size_t len, unsigned restricted_pixels)
{
if (graph_)
{