Skip to content

Commit

Permalink
Fix for #7384 - From/To UTF8 conversation issue for text controls in …
Browse files Browse the repository at this point in the history
…Settings Tabs

+ BitmapComboBox: fixed warning under MSW
  • Loading branch information
YuSanka committed Nov 30, 2021
1 parent 86afffa commit 8fc6203
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/slic3r/GUI/BitmapComboBox.cpp
Expand Up @@ -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

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);
const int n = wxComboBox::Append(item);
Expand Down
8 changes: 4 additions & 4 deletions src/slic3r/GUI/Field.cpp
Expand Up @@ -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) ||
(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) {
m_value.clear();
Expand All @@ -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; }

case coPoints: {
Expand Down Expand Up @@ -1286,7 +1286,7 @@ void Choice::msw_rescale()
size_t counter = 0;
bool labels = ! m_opt.enum_labels.empty();
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);
if (text == selection)
idx = counter;
Expand Down Expand Up @@ -1574,7 +1574,7 @@ void StaticText::BUILD()
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);

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);
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/OptionsGroup.cpp
Expand Up @@ -870,7 +870,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
}
break;
case coString:
ret = static_cast<wxString>(config.opt_string(opt_key));
ret = from_u8(config.opt_string(opt_key));
break;
case coStrings:
if (opt_key == "compatible_printers" || opt_key == "compatible_prints") {
Expand All @@ -891,7 +891,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
ret = text_value;
}
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;
case coBool:
ret = config.opt_bool(opt_key);
Expand Down

0 comments on commit 8fc6203

Please sign in to comment.