Fix for #7384 - From/To UTF8 conversation issue for text controls in Settings Tabs

+ BitmapComboBox: fixed warning under MSW
This commit is contained in:
YuSanka 2021-11-30 12:32:28 +01:00
parent 86afffa692
commit 8fc620375c
3 changed files with 12 additions and 7 deletions

View File

@ -167,7 +167,12 @@ int BitmapComboBox::Append(const wxString& item)
//3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct //3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
wxBitmap bitmap(1, int(1.6 * wxGetApp().em_unit() + 1)); wxBitmap bitmap(1, int(1.6 * wxGetApp().em_unit() + 1));
bitmap.SetWidth(0); {
// bitmap.SetWidth(0); is depricated now
// so, use next code
bitmap.UnShare();// AllocExclusive();
bitmap.GetGDIImageData()->m_width = 0;
}
OnAddBitmap(bitmap); OnAddBitmap(bitmap);
const int n = wxComboBox::Append(item); const int n = wxComboBox::Append(item);

View File

@ -316,7 +316,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
} }
else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) || else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) ||
(m_opt.sidetext.rfind("mm ") != std::string::npos && val > /*1*/m_opt.max_literal)) && (m_opt.sidetext.rfind("mm ") != std::string::npos && val > /*1*/m_opt.max_literal)) &&
(m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value))) (m_value.empty() || into_u8(str) != boost::any_cast<std::string>(m_value)))
{ {
if (!check_value) { if (!check_value) {
m_value.clear(); m_value.clear();
@ -340,7 +340,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
} }
} }
m_value = std::string(str.ToUTF8().data()); m_value = into_u8(str);
break; } break; }
case coPoints: { case coPoints: {
@ -1286,7 +1286,7 @@ void Choice::msw_rescale()
size_t counter = 0; size_t counter = 0;
bool labels = ! m_opt.enum_labels.empty(); bool labels = ! m_opt.enum_labels.empty();
for (const std::string &el : labels ? m_opt.enum_labels : m_opt.enum_values) { for (const std::string &el : labels ? m_opt.enum_labels : m_opt.enum_values) {
wxString text = labels ? _(el) : wxString::FromUTF8(el.c_str()); wxString text = labels ? _(el) : from_u8(el);
field->Append(text); field->Append(text);
if (text == selection) if (text == selection)
idx = counter; idx = counter;
@ -1574,7 +1574,7 @@ void StaticText::BUILD()
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
const wxString legend = wxString::FromUTF8(m_opt.get_default_value<ConfigOptionString>()->value.c_str()); const wxString legend = from_u8(m_opt.get_default_value<ConfigOptionString>()->value);
auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE); auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE);
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font()); temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetBackgroundStyle(wxBG_STYLE_PAINT); temp->SetBackgroundStyle(wxBG_STYLE_PAINT);

View File

@ -870,7 +870,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
} }
break; break;
case coString: case coString:
ret = static_cast<wxString>(config.opt_string(opt_key)); ret = from_u8(config.opt_string(opt_key));
break; break;
case coStrings: case coStrings:
if (opt_key == "compatible_printers" || opt_key == "compatible_prints") { if (opt_key == "compatible_printers" || opt_key == "compatible_prints") {
@ -891,7 +891,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
ret = text_value; ret = text_value;
} }
else else
ret = static_cast<wxString>(config.opt_string(opt_key, static_cast<unsigned int>(idx))); ret = from_u8(config.opt_string(opt_key, static_cast<unsigned int>(idx)));
break; break;
case coBool: case coBool:
ret = config.opt_bool(opt_key); ret = config.opt_bool(opt_key);