use UTF-8 for string representation

This commit is contained in:
Jinhao
2015-12-29 01:26:19 +08:00
parent 443b3dcd87
commit 48254b6555
22 changed files with 116 additions and 124 deletions

View File

@@ -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;

View File

@@ -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:

View File

@@ -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&);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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.

View File

@@ -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:

View File

@@ -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;

View File

@@ -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&);