21#ifndef __ANTARES_TOOLBOX_WX_WIDGETS_HXX__
22#define __ANTARES_TOOLBOX_WX_WIDGETS_HXX__
24inline wxString wxStringFromUTF8(
const std::string& s)
27 return wxString::FromUTF8(s.c_str(), s.size());
29 return wxString(s.c_str(), s.size());
33inline wxString wxStringFromUTF8(
const char* s)
36 return wxString::FromUTF8(s);
42inline wxString wxStringFromUTF8(
const Yuni::String& s)
45 return wxString::FromUTF8(s.c_str(), s.size());
47 return wxString(s.c_str(), s.size());
51inline wxString wxStringFromUTF8(
const char*
const s, uint length)
54 return wxString::FromUTF8(s, length);
56 return wxString(s, length);
60template<u
int ChunkT,
bool FixedT>
61inline wxString wxStringFromUTF8(
const Yuni::CString<ChunkT, FixedT>& s)
64 return wxString::FromUTF8(s.c_str(), s.size());
66 return wxString(s.c_str(), s.size());
70template<
class StringT>
71inline void wxStringToString(
const wxString& s, StringT& out)
74 const wxCharBuffer buffer(s.mb_str(wxConvUTF8));
75 out.assign((
const char*)buffer, (uint)strlen((
const char*)buffer));
77 out = (
const char*)s.mb_str();
81template<
int PrecisionT>
82wxString DoubleToWxStringS(
double f)
84 Yuni::CString<128, false> tmp;
88 tmp.format(
"%.0f", f);
91 tmp.format(
"%.1f", f);
94 tmp.format(
"%.2f", f);
97 tmp.format(
"%.3f", f);
100 tmp.format(
"%.4f", f);
103 tmp.format(
"%.5f", f);
106 tmp.format(
"%.6f", f);
109 tmp.format(
"%.7f", f);
112 tmp.format(
"%.8f", f);
115 tmp.format(
"%.9f", f);
118 tmp.format(
"%.f", f);
121 if (tmp.contains(
'.'))
124 if (tmp.last() ==
'.')
127 return wxStringFromUTF8(tmp);
130template<
class StringT1,
class StringT2>
131void AppendWithQuotes(StringT1& out,
const StringT2& text)
135 if (text.contains(
'"'))
137 Yuni::String copy = text;
138 copy.replace(
"\"",
"\\\"");
139 out <<
'"' << copy <<
'"';
142 out <<
'"' << text <<
'"';