remove utf8_cast functions
This commit is contained in:
parent
b961ff51d7
commit
325961a277
@ -100,9 +100,6 @@ namespace nana
|
||||
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&);
|
||||
|
||||
|
@ -332,8 +332,6 @@ namespace filesystem
|
||||
//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); //deprecated
|
||||
|
||||
template<typename CharType>
|
||||
std::basic_string<CharType> parent_path(const std::basic_string<CharType>& path)
|
||||
{
|
||||
|
@ -56,14 +56,8 @@ namespace drawerbase
|
||||
void mouse_up(graph_reference, const arg_mouse&) override;
|
||||
public:
|
||||
implement * impl() const;
|
||||
private:
|
||||
void _m_draw_background(graph_reference);
|
||||
void _m_draw_checkbox(graph_reference, unsigned first_line_height);
|
||||
void _m_draw_title(graph_reference);
|
||||
private:
|
||||
static const int interval = 4;
|
||||
widget* widget_;
|
||||
std::unique_ptr<implement> imptr_;
|
||||
implement * impl_;
|
||||
};
|
||||
}//end namespace checkbox
|
||||
|
@ -158,7 +158,7 @@ namespace nana
|
||||
iresolver& operator>>(double&);
|
||||
iresolver& operator>>(long double&);
|
||||
|
||||
iresolver& operator>>(std::string& utf8_cast);
|
||||
iresolver& operator>>(std::string& text_utf8);
|
||||
iresolver& operator>>(std::wstring&);
|
||||
iresolver& operator>>(cell&);
|
||||
iresolver& operator>>(std::nullptr_t);
|
||||
|
@ -487,16 +487,6 @@ namespace nana
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -207,7 +207,7 @@ namespace detail
|
||||
#endif
|
||||
#endif
|
||||
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof metrics, &metrics, 0);
|
||||
def_font_ptr_ = make_native_font(utf8_cast(metrics.lfMessageFont.lfFaceName).c_str(), font_size_to_height(9), 400, false, false, false);
|
||||
def_font_ptr_ = make_native_font(to_utf8(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
|
||||
@ -244,7 +244,7 @@ namespace detail
|
||||
memset(&logfont, 0, sizeof logfont);
|
||||
|
||||
if (name && *name)
|
||||
std::wcscpy(logfont.lfFaceName, utf8_cast(name).c_str());
|
||||
std::wcscpy(logfont.lfFaceName, to_wstring(name).c_str());
|
||||
else
|
||||
std::wcscpy(logfont.lfFaceName, def_font_ptr_->name.c_str());
|
||||
|
||||
|
@ -282,20 +282,12 @@ namespace nana { namespace experimental {
|
||||
|
||||
void path::_m_assign(const std::string& source_utf8)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
pathstr_ = utf8_cast(source_utf8);
|
||||
#else
|
||||
pathstr_ = source_utf8;
|
||||
#endif
|
||||
pathstr_ = to_nstring(source_utf8);
|
||||
}
|
||||
|
||||
void path::_m_assign(const std::wstring& source)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
pathstr_ = source;
|
||||
#else
|
||||
pathstr_ = utf8_cast(source);
|
||||
#endif
|
||||
pathstr_ = to_nstring(source);
|
||||
}
|
||||
//end class path
|
||||
|
||||
|
@ -1191,7 +1191,7 @@ namespace detail
|
||||
|
||||
::DragQueryFile(drop, i, varbuf.get(), reqlen);
|
||||
|
||||
dropfiles.files.emplace_back(utf8_cast(varbuf.get()));
|
||||
dropfiles.files.emplace_back(to_utf8(varbuf.get()));
|
||||
}
|
||||
|
||||
while(msgwnd && (msgwnd->flags.dropable == false))
|
||||
|
@ -912,7 +912,7 @@ namespace nana
|
||||
::GetCurrentDirectory(len, &(path[0]));
|
||||
path.resize(len);
|
||||
|
||||
impl_->path = utf8_cast(path);
|
||||
impl_->path = to_utf8(path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1002,9 +1002,9 @@ namespace nana
|
||||
{
|
||||
for(auto & f : impl_->filters)
|
||||
{
|
||||
filter_holder += utf8_cast(f.des);
|
||||
filter_holder += to_wstring(f.des);
|
||||
filter_holder += static_cast<std::wstring::value_type>('\0');
|
||||
std::wstring fs = utf8_cast(f.type);
|
||||
std::wstring fs = to_wstring(f.type);
|
||||
std::size_t pos = 0;
|
||||
while(true)
|
||||
{
|
||||
@ -1036,8 +1036,8 @@ namespace nana
|
||||
else
|
||||
filter = L"All Files\0*.*\0";
|
||||
|
||||
auto wtitle = utf8_cast(impl_->title);
|
||||
auto wpath = utf8_cast(impl_->path);
|
||||
auto wtitle = to_wstring(impl_->title);
|
||||
auto wpath = to_wstring(impl_->path);
|
||||
ofn.lpstrFilter = filter;
|
||||
ofn.lpstrTitle = (wtitle.empty() ? nullptr : wtitle.c_str());
|
||||
ofn.nFilterIndex = 0;
|
||||
@ -1053,7 +1053,7 @@ namespace nana
|
||||
return false;
|
||||
|
||||
wfile.resize(std::wcslen(wfile.data()));
|
||||
impl_->file = utf8_cast(wfile);
|
||||
impl_->file = to_utf8(wfile);
|
||||
#elif defined(NANA_POSIX)
|
||||
filebox_implement fb(impl_->owner, impl_->open_or_save, impl_->title);
|
||||
|
||||
|
@ -435,7 +435,7 @@ namespace nana
|
||||
default: break;
|
||||
}
|
||||
|
||||
auto bt = ::MessageBoxW(reinterpret_cast<HWND>(API::root(wd_)), utf8_cast(sstream_.str()).c_str(), utf8_cast(title_).c_str(), type);
|
||||
auto bt = ::MessageBoxW(reinterpret_cast<HWND>(API::root(wd_)), to_wstring(sstream_.str()).c_str(), to_wstring(title_).c_str(), type);
|
||||
|
||||
switch(bt)
|
||||
{
|
||||
@ -835,7 +835,7 @@ namespace nana
|
||||
|
||||
void inputbox::text::tip_string(std::wstring tip)
|
||||
{
|
||||
impl_->tip = utf8_cast(tip);
|
||||
impl_->tip = to_utf8(tip);
|
||||
}
|
||||
|
||||
void inputbox::text::tip_string(std::string tip_utf8)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* An Implementation of Place for Layout
|
||||
* 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
|
||||
|
@ -83,7 +83,7 @@ namespace nana
|
||||
graph.rectangle(true, static_cast<color_rgb>(0x83EB));
|
||||
|
||||
//draw caption
|
||||
auto text = utf8_cast(API::window_caption(window_handle_));
|
||||
auto text = to_wstring(API::window_caption(window_handle_));
|
||||
text_rd_->render({ 3, 1 }, text.data(), text.size(), graph.size().width - 20, true);
|
||||
|
||||
//draw x button
|
||||
|
@ -17,39 +17,68 @@
|
||||
|
||||
namespace nana{ namespace drawerbase
|
||||
{
|
||||
namespace checkbox
|
||||
{
|
||||
typedef element::crook_interface::state crook_state;
|
||||
|
||||
struct drawer::implement
|
||||
namespace checkbox
|
||||
{
|
||||
bool react;
|
||||
bool radio;
|
||||
facade<element::crook> crook;
|
||||
};
|
||||
typedef element::crook_interface::state crook_state;
|
||||
|
||||
struct drawer::implement
|
||||
{
|
||||
widget * widget_ptr;
|
||||
bool react;
|
||||
bool radio;
|
||||
facade<element::crook> crook;
|
||||
};
|
||||
|
||||
//class drawer
|
||||
|
||||
drawer::drawer()
|
||||
: widget_(nullptr),
|
||||
imptr_(new drawer::implement),
|
||||
impl_(imptr_.get())
|
||||
: impl_(new implement)
|
||||
{
|
||||
impl_->widget_ptr = nullptr;
|
||||
impl_->react = true;
|
||||
impl_->radio = false;
|
||||
}
|
||||
|
||||
drawer::~drawer()
|
||||
{}
|
||||
{
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
void drawer::attached(widget_reference widget, graph_reference)
|
||||
{
|
||||
widget_ = &widget;
|
||||
impl_->widget_ptr = &widget;
|
||||
}
|
||||
|
||||
void drawer::refresh(graph_reference graph)
|
||||
{
|
||||
_m_draw_background(graph);
|
||||
_m_draw_title(graph);
|
||||
_m_draw_checkbox(graph, graph.text_extent_size(L"jN", 2).height + 2);
|
||||
auto wdg = impl_->widget_ptr;
|
||||
|
||||
//draw background
|
||||
if (bground_mode::basic != API::effects_bground_mode(*wdg))
|
||||
graph.rectangle(true, wdg->bgcolor());
|
||||
|
||||
//draw title
|
||||
if (graph.width() > 16 + interval)
|
||||
{
|
||||
auto title = to_wstring(wdg->caption_native());
|
||||
unsigned pixels = graph.width() - (16 + interval);
|
||||
|
||||
nana::paint::text_renderer tr(graph);
|
||||
if (!wdg->enabled())
|
||||
{
|
||||
graph.palette(true, colors::white);
|
||||
tr.render({ 17 + interval, 2 }, title.c_str(), title.length(), pixels);
|
||||
graph.palette(true, static_cast<color_rgb>(0x808080));
|
||||
}
|
||||
else
|
||||
graph.palette(true, wdg->fgcolor());
|
||||
|
||||
tr.render({ 16 + interval, 1 }, title.c_str(), title.length(), pixels);
|
||||
}
|
||||
|
||||
//draw crook
|
||||
auto txt_px = graph.text_extent_size(L"jN", 2).height + 2;
|
||||
impl_->crook.draw(graph, wdg->bgcolor(), wdg->fgcolor(), rectangle(0, txt_px > 16 ? (txt_px - 16) / 2 : 0, 16, 16), API::element_state(*wdg));
|
||||
}
|
||||
|
||||
void drawer::mouse_down(graph_reference graph, const arg_mouse&)
|
||||
@ -63,8 +92,8 @@ namespace checkbox
|
||||
if (impl_->react)
|
||||
{
|
||||
impl_->crook.reverse();
|
||||
arg_checkbox arg{ static_cast<nana::checkbox*>(widget_) };
|
||||
API::events<nana::checkbox>(widget_->handle()).checked.emit(arg);
|
||||
arg_checkbox arg{ static_cast<nana::checkbox*>(impl_->widget_ptr) };
|
||||
API::events<nana::checkbox>(impl_->widget_ptr->handle()).checked.emit(arg);
|
||||
}
|
||||
refresh(graph);
|
||||
API::lazy_refresh();
|
||||
@ -86,39 +115,6 @@ namespace checkbox
|
||||
{
|
||||
return impl_;
|
||||
}
|
||||
|
||||
void drawer::_m_draw_background(graph_reference graph)
|
||||
{
|
||||
if(bground_mode::basic != API::effects_bground_mode(*widget_))
|
||||
graph.rectangle(true, API::bgcolor(*widget_));
|
||||
}
|
||||
|
||||
void drawer::_m_draw_checkbox(graph_reference graph, unsigned first_line_height)
|
||||
{
|
||||
impl_->crook.draw(graph, widget_->bgcolor(), widget_->fgcolor(), rectangle(0, first_line_height > 16 ? (first_line_height - 16) / 2 : 0, 16, 16), API::element_state(*widget_));
|
||||
}
|
||||
|
||||
void drawer::_m_draw_title(graph_reference graph)
|
||||
{
|
||||
if (graph.width() > 16 + interval)
|
||||
{
|
||||
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.palette(true, colors::white);
|
||||
tr.render({ 17 + interval, 2 }, title.c_str(), title.length(), pixels);
|
||||
graph.palette(true, { 0x80, 0x80, 0x80 });
|
||||
}
|
||||
else
|
||||
graph.palette(true, widget_->fgcolor());
|
||||
|
||||
tr.render({ 16 + interval, 1 }, title.c_str(), title.length(), pixels);
|
||||
}
|
||||
}
|
||||
//end class drawer
|
||||
} //end namespace checkbox
|
||||
}//end namespace drawerbase
|
||||
@ -209,6 +205,7 @@ namespace checkbox
|
||||
e.uiobj->react(true);
|
||||
API::umake_event(e.eh_checked);
|
||||
API::umake_event(e.eh_destroy);
|
||||
API::umake_event(e.eh_keyboard);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -851,7 +851,7 @@ namespace nana
|
||||
throw_not_utf8(str);
|
||||
drawerbase::label::renderer rd;
|
||||
rd.format(format_enabled);
|
||||
rd.parse(utf8_cast(str));
|
||||
rd.parse(to_wstring(str));
|
||||
return rd.measure(graph, allowed_width_in_pixel, h_align, v_align);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A text editor 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
|
||||
@ -1255,11 +1255,12 @@ namespace nana{ namespace widgets
|
||||
return (a.begin < b.begin);
|
||||
});
|
||||
|
||||
auto previous = entities.begin();
|
||||
auto i = previous + 1;
|
||||
while(i != entities.end())
|
||||
auto i = entities.begin();
|
||||
auto bound = i->end;
|
||||
|
||||
for (++i; i != entities.end(); )
|
||||
{
|
||||
if (previous->end > i->begin)
|
||||
if (bound > i->begin)
|
||||
i = entities.erase(i); // erase overlaping. Left only the first.
|
||||
else
|
||||
++i;
|
||||
@ -1321,7 +1322,7 @@ namespace nana{ namespace widgets
|
||||
auto sp = std::make_shared<keyword_scheme>();
|
||||
sp->fgcolor = fgcolor;
|
||||
sp->bgcolor = bgcolor;
|
||||
keywords_->schemes[name] = sp;
|
||||
keywords_->schemes[name].swap(sp);
|
||||
}
|
||||
|
||||
void text_editor::erase_highlight(const std::string& name)
|
||||
|
@ -319,7 +319,7 @@ namespace drawerbase {
|
||||
std::wstring line_text;
|
||||
if (editor->getline(line_index, line_text))
|
||||
{
|
||||
text = utf8_cast(line_text);
|
||||
text = to_utf8(line_text);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -343,8 +343,8 @@ namespace nana
|
||||
else
|
||||
{
|
||||
wchar_t wstr[2] = { key, 0 };
|
||||
pattern += utf8_cast(wstr);
|
||||
track_node.key_buf += utf8_cast(wstr);
|
||||
pattern += to_utf8(wstr);
|
||||
track_node.key_buf += to_utf8(wstr);
|
||||
}
|
||||
|
||||
const node_type *begin = node_state.selected ? node_state.selected : attr.tree_cont.get_root()->child;
|
||||
@ -995,7 +995,7 @@ namespace nana
|
||||
|
||||
bool item_proxy::operator==(const wchar_t* s) const
|
||||
{
|
||||
return (node_ && s && (node_->value.second.text == utf8_cast(s)));
|
||||
return (node_ && s && (node_->value.second.text == to_utf8(s)));
|
||||
}
|
||||
|
||||
// Behavior of Iterator
|
||||
|
@ -949,8 +949,7 @@ namespace paint
|
||||
|
||||
void graphics::string(const point& pos, const std::string& text_utf8)
|
||||
{
|
||||
throw_not_utf8(text_utf8);
|
||||
string(pos, utf8_cast(text_utf8));
|
||||
string(pos, to_wstring(text_utf8));
|
||||
}
|
||||
|
||||
void graphics::string(const point& pos, const std::string& text_utf8, const color& clr)
|
||||
|
@ -43,7 +43,7 @@ namespace nana{ namespace system{
|
||||
#ifdef NANA_WINDOWS
|
||||
_m_set(format::text, text.c_str(), (text.length() + 1) * sizeof(wchar_t));
|
||||
#else
|
||||
std::string str = utf8_cast(text);
|
||||
std::string str = to_utf8(text);
|
||||
_m_set(format::text, str.c_str(), str.size() + 1);
|
||||
#endif
|
||||
}
|
||||
@ -129,7 +129,7 @@ namespace nana{ namespace system{
|
||||
if (pos != wstr.npos)
|
||||
wstr.erase(pos + 1);
|
||||
|
||||
text_utf8 = utf8_cast(wstr);
|
||||
text_utf8 = to_utf8(wstr);
|
||||
#else
|
||||
text_utf8.reserve(size);
|
||||
text_utf8.append(reinterpret_cast<char*>(res), reinterpret_cast<char*>(res) + size);
|
||||
@ -169,7 +169,7 @@ namespace nana{ namespace system{
|
||||
text_utf8.erase(pos + 1);
|
||||
::XFree(res);
|
||||
|
||||
str = utf8_cast(text_utf8);
|
||||
str = to_wstring(text_utf8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user