Fix compilation with UTF-8 wxString

This commit is contained in:
Thomas Goyne 2014-05-30 09:09:49 -07:00
parent eebd1dba21
commit fa68b5ee1a
3 changed files with 15 additions and 5 deletions

View file

@ -23,14 +23,14 @@ namespace agi {
template<>
struct writer<char, wxString> {
static void write(std::basic_ostream<char>& out, int max_len, wxString const& value) {
writer<char, const wxChar *>::write(out, max_len, value.wx_str());
writer<char, const wxStringCharType *>::write(out, max_len, value.wx_str());
}
};
template<>
struct writer<wchar_t, wxString> {
static void write(std::basic_ostream<wchar_t>& out, int max_len, wxString const& value) {
writer<wchar_t, const wxChar *>::write(out, max_len, value.wx_str());
writer<wchar_t, const wxStringCharType *>::write(out, max_len, value.wx_str());
}
};
@ -43,14 +43,14 @@ std::string format(wxString const& fmt, Args&&... args) {
template<typename... Args>
wxString wxformat(wxString const& fmt, Args&&... args) {
boost::interprocess::basic_vectorstream<std::basic_string<wxChar>> out;
boost::interprocess::basic_vectorstream<std::basic_string<wxStringCharType>> out;
format(out, fmt.wx_str(), std::forward<Args>(args)...);
return out.vector();
}
template<typename... Args>
wxString wxformat(const wxChar *fmt, Args&&... args) {
boost::interprocess::basic_vectorstream<std::basic_string<wxChar>> out;
wxString wxformat(const wxStringCharType *fmt, Args&&... args) {
boost::interprocess::basic_vectorstream<std::basic_string<wxStringCharType>> out;
format(out, fmt, std::forward<Args>(args)...);
return out.vector();
}

View file

@ -44,6 +44,14 @@ int WidthHelper::operator()(wxString const& str) {
return dc.GetTextExtent(str).GetWidth();
}
int WidthHelper::operator()(const char *str) {
return dc.GetTextExtent(wxString::FromUTF8(str)).GetWidth();
}
int WidthHelper::operator()(const wchar_t *str) {
return dc.GetTextExtent(str).GetWidth();
}
void GridColumn::UpdateWidth(const agi::Context *c, WidthHelper &helper) {
if (!visible) {
width = 0;

View file

@ -41,6 +41,8 @@ struct WidthHelper {
int operator()(boost::flyweight<std::string> const& str);
int operator()(std::string const& str);
int operator()(wxString const& str);
int operator()(const char *str);
int operator()(const wchar_t *str);
};
class GridColumn {