use UTF-8 for string representation
This commit is contained in:
parent
443b3dcd87
commit
48254b6555
@ -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:
|
||||
|
||||
@ -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&);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -140,7 +140,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);
|
||||
|
||||
|
||||
@ -56,7 +56,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,7 +66,7 @@ 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;
|
||||
@ -134,7 +134,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.
|
||||
|
||||
@ -108,7 +108,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:
|
||||
|
||||
@ -79,7 +79,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return idstr_;
|
||||
}
|
||||
|
||||
const std::pair<nana::string, nana::string>& binary() const
|
||||
const std::pair<std::wstring, std::wstring>& binary() const
|
||||
{
|
||||
return binary_;
|
||||
}
|
||||
@ -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};
|
||||
};
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -90,13 +90,14 @@ namespace nana
|
||||
void typeface(const font&); ///< Selects a specified font type into the graphics object.
|
||||
font typeface() const;
|
||||
::nana::size text_extent_size(const ::std::string&) 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 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 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 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 char_t*, std::size_t length, std::size_t begin, std::size_t end) const;
|
||||
::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 char_t *, std::size_t length, unsigned* pxbuf) 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;
|
||||
|
||||
@ -154,10 +155,10 @@ namespace nana
|
||||
void string(const point&, const std::string& text_utf8);
|
||||
void string(const point&, const std::string& text_utf8, const color&);
|
||||
|
||||
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(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&);
|
||||
|
||||
@ -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))
|
||||
{
|
||||
|
||||
@ -108,7 +108,7 @@ namespace nana
|
||||
_m_icon(ico);
|
||||
}
|
||||
|
||||
void prompt(const nana::string& text)
|
||||
void prompt(const std::string& text)
|
||||
{
|
||||
if(text.size())
|
||||
{
|
||||
@ -376,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;
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -336,14 +336,14 @@ 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())
|
||||
|
||||
@ -212,11 +212,9 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void trigger::_m_draw_title(graph_reference graph, bool enabled)
|
||||
{
|
||||
std::wstring text = ::nana::charset(wdg_->caption(), ::nana::unicode::utf8);
|
||||
|
||||
std::wstring::value_type shortkey;
|
||||
std::wstring::size_type shortkey_pos;
|
||||
std::wstring str = API::transform_shortkey_text(text, shortkey, &shortkey_pos);
|
||||
wchar_t shortkey;
|
||||
std::string::size_type shortkey_pos;
|
||||
std::wstring str = to_wstring(API::transform_shortkey_text(wdg_->caption(), shortkey, &shortkey_pos));
|
||||
|
||||
nana::size ts = graph.text_extent_size(str);
|
||||
nana::size gsize = graph.size();
|
||||
@ -237,7 +235,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);
|
||||
@ -513,14 +511,14 @@ namespace nana{ namespace drawerbase
|
||||
{
|
||||
API::unregister_shortkey(handle());
|
||||
|
||||
std::wstring wtext = ::nana::to_wstring(text);
|
||||
native_string_type ntext = std::move(text);
|
||||
|
||||
wchar_t shortkey;
|
||||
API::transform_shortkey_text(wtext, shortkey, 0);
|
||||
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
|
||||
|
||||
@ -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;
|
||||
@ -148,7 +148,7 @@ 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::wstring& text, unsigned text_pixels, const attr& at)
|
||||
{
|
||||
graph.set_text_color(at.enabled ? colors::black : colors::gray_border);
|
||||
nana::paint::text_renderer tr(graph);
|
||||
@ -240,7 +240,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));
|
||||
@ -382,9 +382,9 @@ 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);
|
||||
@ -1108,7 +1108,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());
|
||||
|
||||
@ -30,11 +30,11 @@ namespace nana
|
||||
{
|
||||
struct item_type
|
||||
{
|
||||
item_type(const ::nana::string& text, unsigned long shortkey)
|
||||
item_type(const ::std::wstring& text, unsigned long shortkey)
|
||||
: text(text), shortkey(shortkey)
|
||||
{}
|
||||
|
||||
::nana::string text;
|
||||
::std::wstring 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 ::std::wstring& text, unsigned long shortkey)
|
||||
{
|
||||
if(shortkey && shortkey < 0x61) shortkey += (0x61 - 0x41);
|
||||
cont_.push_back(new item_type(text, shortkey));
|
||||
@ -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 std::wstring& text)
|
||||
{
|
||||
graph_.string(pos, text, colors::black);
|
||||
}
|
||||
@ -138,10 +138,10 @@ namespace nana
|
||||
delete items_;
|
||||
}
|
||||
|
||||
nana::menu* trigger::push_back(const ::nana::string& text)
|
||||
nana::menu* trigger::push_back(const ::std::wstring& text)
|
||||
{
|
||||
::nana::char_t shkey;
|
||||
API::transform_shortkey_text(text, shkey, nullptr);
|
||||
wchar_t shkey;
|
||||
API::transform_shortkey_text(to_utf8(text), shkey, nullptr);
|
||||
|
||||
if(shkey)
|
||||
API::register_shortkey(widget_->handle(), shkey);
|
||||
@ -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_wstring(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;
|
||||
@ -617,9 +617,9 @@ 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));
|
||||
return *(get_drawer_trigger().push_back(to_wstring(text)));
|
||||
}
|
||||
|
||||
menu& menubar::at(std::size_t index) const
|
||||
|
||||
@ -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
|
||||
@ -788,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();
|
||||
@ -1006,8 +1006,10 @@ namespace nana
|
||||
nana::size ts = basis_.graph->text_extent_size(item.text);
|
||||
basis_.graph->set_text_color(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -639,7 +639,7 @@ namespace nana
|
||||
|
||||
nana::paint::image* image(const node_type* node)
|
||||
{
|
||||
const nana::string& idstr = node->value.second.img_idstr;
|
||||
const std::string& idstr = node->value.second.img_idstr;
|
||||
if(idstr.size())
|
||||
{
|
||||
auto i = shape.image_table.find(idstr);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Platform Implementation
|
||||
* 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
|
||||
@ -129,7 +129,7 @@ namespace detail
|
||||
pixbuf.paste(nana::rectangle(r.x, 0, r.width, r.height), dw, point{r.x, r.y});
|
||||
}
|
||||
|
||||
nana::size raw_text_extent_size(drawable_type dw, const nana::char_t* text, std::size_t len)
|
||||
nana::size raw_text_extent_size(drawable_type dw, const wchar_t* text, std::size_t len)
|
||||
{
|
||||
if(nullptr == dw || nullptr == text || 0 == len) return nana::size();
|
||||
#if defined(NANA_WINDOWS)
|
||||
@ -138,7 +138,7 @@ namespace detail
|
||||
return nana::size(size.cx, size.cy);
|
||||
#elif defined(NANA_X11)
|
||||
#if defined(NANA_UNICODE)
|
||||
std::string utf8str = nana::charset(nana::string(text, len));
|
||||
std::string utf8str = to_utf8(text);
|
||||
XGlyphInfo ext;
|
||||
XftFont * fs = reinterpret_cast<XftFont*>(dw->font->handle);
|
||||
::XftTextExtentsUtf8(nana::detail::platform_spec::instance().open_display(), fs,
|
||||
@ -180,12 +180,6 @@ namespace detail
|
||||
#elif defined(NANA_X11)
|
||||
auto disp = ::nana::detail::platform_spec::instance().open_display();
|
||||
#if defined(NANA_UNICODE)
|
||||
/*
|
||||
std::string utf8str = nana::charset(nana::string(str, len));
|
||||
XftFont * fs = reinterpret_cast<XftFont*>(dw->font->handle);
|
||||
::XftDrawStringUtf8(dw->xftdraw, &(dw->xft_fgcolor), fs, pos.x, pos.y + fs->ascent,
|
||||
reinterpret_cast<XftChar8*>(const_cast<char*>(utf8str.c_str())), utf8str.size());
|
||||
*/
|
||||
auto fs = reinterpret_cast<XftFont*>(dw->font->handle);
|
||||
|
||||
//Fixed missing array declaration by dareg
|
||||
|
||||
@ -365,30 +365,35 @@ namespace paint
|
||||
::nana::size graphics::text_extent_size(const ::std::string& text) const
|
||||
{
|
||||
throw_not_utf8(text);
|
||||
return text_extent_size(static_cast<std::wstring>(::nana::charset(text, ::nana::unicode::utf8)));
|
||||
return text_extent_size(to_wstring(text));
|
||||
}
|
||||
|
||||
nana::size graphics::text_extent_size(const nana::char_t* text) const
|
||||
::nana::size graphics::text_extent_size(const char* text, std::size_t len) const
|
||||
{
|
||||
return text_extent_size(text, nana::strlen(text));
|
||||
return text_extent_size(std::string(text, text + len));
|
||||
}
|
||||
|
||||
nana::size graphics::text_extent_size(const nana::string& text) const
|
||||
nana::size graphics::text_extent_size(const wchar_t* text) const
|
||||
{
|
||||
return text_extent_size(text, std::wcslen(text));
|
||||
}
|
||||
|
||||
nana::size graphics::text_extent_size(const std::wstring& text) const
|
||||
{
|
||||
return text_extent_size(text.c_str(), static_cast<unsigned>(text.length()));
|
||||
}
|
||||
|
||||
nana::size graphics::text_extent_size(const nana::char_t* str, std::size_t len) const
|
||||
nana::size graphics::text_extent_size(const wchar_t* str, std::size_t len) const
|
||||
{
|
||||
return detail::text_extent_size(handle_, str, len);
|
||||
}
|
||||
|
||||
nana::size graphics::text_extent_size(const nana::string& str, std::size_t len) const
|
||||
nana::size graphics::text_extent_size(const std::wstring& str, std::size_t len) const
|
||||
{
|
||||
return detail::text_extent_size(handle_, str.c_str(), len);
|
||||
}
|
||||
|
||||
nana::size graphics::glyph_extent_size(const nana::char_t * str, std::size_t len, std::size_t begin, std::size_t end) const
|
||||
nana::size graphics::glyph_extent_size(const wchar_t * str, std::size_t len, std::size_t begin, std::size_t end) const
|
||||
{
|
||||
if(len < end) end = len;
|
||||
if (nullptr == handle_ || nullptr == str || 0 == len || begin >= end) return{};
|
||||
@ -414,12 +419,12 @@ namespace paint
|
||||
return sz;
|
||||
}
|
||||
|
||||
nana::size graphics::glyph_extent_size(const nana::string& str, std::size_t len, std::size_t begin, std::size_t end) const
|
||||
nana::size graphics::glyph_extent_size(const std::wstring& str, std::size_t len, std::size_t begin, std::size_t end) const
|
||||
{
|
||||
return glyph_extent_size(str.c_str(), len, begin, end);
|
||||
}
|
||||
|
||||
bool graphics::glyph_pixels(const nana::char_t * str, std::size_t len, unsigned* pxbuf) const
|
||||
bool graphics::glyph_pixels(const wchar_t * str, std::size_t len, unsigned* pxbuf) const
|
||||
{
|
||||
if(nullptr == handle_ || nullptr == handle_->context || nullptr == str || nullptr == pxbuf) return false;
|
||||
if(len == 0) return true;
|
||||
@ -966,12 +971,12 @@ namespace paint
|
||||
string(pos, text_utf8);
|
||||
}
|
||||
|
||||
void graphics::string(nana::point pos, const char_t* str, std::size_t len)
|
||||
void graphics::string(nana::point pos, const wchar_t* str, std::size_t len)
|
||||
{
|
||||
if (handle_ && str && len)
|
||||
{
|
||||
const nana::char_t * end = str + len;
|
||||
const nana::char_t * i = std::find(str, end, '\t');
|
||||
auto const end = str + len;
|
||||
auto i = std::find(str, end, '\t');
|
||||
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
handle_->update_text_color();
|
||||
#endif
|
||||
@ -1008,17 +1013,17 @@ namespace paint
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::string(const nana::point& pos, const char_t* str)
|
||||
void graphics::string(const nana::point& pos, const wchar_t* str)
|
||||
{
|
||||
string(pos, str, nana::strlen(str));
|
||||
string(pos, str, std::wcslen(str));
|
||||
}
|
||||
|
||||
void graphics::string(const nana::point& pos, const nana::string& str)
|
||||
void graphics::string(const nana::point& pos, const std::wstring& str)
|
||||
{
|
||||
string(pos, str.data(), str.size());
|
||||
}
|
||||
|
||||
void graphics::string(const point& pos, const ::nana::string& text, const color& clr)
|
||||
void graphics::string(const point& pos, const ::std::wstring& text, const color& clr)
|
||||
{
|
||||
set_text_color(clr);
|
||||
string(pos, text.data(), text.size());
|
||||
|
||||
@ -98,7 +98,7 @@ namespace system
|
||||
}
|
||||
|
||||
//open an url through a default browser
|
||||
void open_url(const nana::string& url)
|
||||
void open_url(const std::wstring& url)
|
||||
{
|
||||
if(url.empty())
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user