forked from mia/Aegisub
Fix compilation with UTF-8 wxString
This commit is contained in:
parent
eebd1dba21
commit
fa68b5ee1a
3 changed files with 15 additions and 5 deletions
10
src/format.h
10
src/format.h
|
@ -23,14 +23,14 @@ namespace agi {
|
||||||
template<>
|
template<>
|
||||||
struct writer<char, wxString> {
|
struct writer<char, wxString> {
|
||||||
static void write(std::basic_ostream<char>& out, int max_len, wxString const& value) {
|
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<>
|
template<>
|
||||||
struct writer<wchar_t, wxString> {
|
struct writer<wchar_t, wxString> {
|
||||||
static void write(std::basic_ostream<wchar_t>& out, int max_len, wxString const& value) {
|
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>
|
template<typename... Args>
|
||||||
wxString wxformat(wxString const& fmt, Args&&... 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)...);
|
format(out, fmt.wx_str(), std::forward<Args>(args)...);
|
||||||
return out.vector();
|
return out.vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
wxString wxformat(const wxChar *fmt, Args&&... args) {
|
wxString wxformat(const wxStringCharType *fmt, Args&&... args) {
|
||||||
boost::interprocess::basic_vectorstream<std::basic_string<wxChar>> out;
|
boost::interprocess::basic_vectorstream<std::basic_string<wxStringCharType>> out;
|
||||||
format(out, fmt, std::forward<Args>(args)...);
|
format(out, fmt, std::forward<Args>(args)...);
|
||||||
return out.vector();
|
return out.vector();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,14 @@ int WidthHelper::operator()(wxString const& str) {
|
||||||
return dc.GetTextExtent(str).GetWidth();
|
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) {
|
void GridColumn::UpdateWidth(const agi::Context *c, WidthHelper &helper) {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
width = 0;
|
width = 0;
|
||||||
|
|
|
@ -41,6 +41,8 @@ struct WidthHelper {
|
||||||
int operator()(boost::flyweight<std::string> const& str);
|
int operator()(boost::flyweight<std::string> const& str);
|
||||||
int operator()(std::string const& str);
|
int operator()(std::string const& str);
|
||||||
int operator()(wxString const& str);
|
int operator()(wxString const& str);
|
||||||
|
int operator()(const char *str);
|
||||||
|
int operator()(const wchar_t *str);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GridColumn {
|
class GridColumn {
|
||||||
|
|
Loading…
Reference in a new issue