diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 55c785317..dc28ac993 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -798,15 +798,21 @@ void SpinCtrl::msw_rescale(bool rescale_sidetext/* = false*/) field->SetMinSize(wxSize(def_width() * m_em_unit, int(1.9f*field->GetFont().GetPixelSize().y))); } +#ifdef __WXOSX__ +using choice_ctrl = wxBitmapComboBox; +#else +using choice_ctrl = wxComboBox; +#endif // __WXOSX__ + void Choice::BUILD() { wxSize size(def_width_wider() * m_em_unit, wxDefaultCoord); 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); - wxBitmapComboBox* temp; + choice_ctrl* temp; if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0) { m_is_editable = true; - temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size); + temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size); } else { #ifdef __WXOSX__ @@ -814,11 +820,11 @@ void Choice::BUILD() { * so ToolTip doesn't shown. * Next workaround helps to solve this problem */ - temp = new wxBitmapComboBox(); + temp = new choice_ctrl(); temp->SetTextCtrlStyle(wxTE_READONLY); temp->Create(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr); #else - temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY); + temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY); #endif //__WXOSX__ } @@ -841,7 +847,8 @@ void Choice::BUILD() { set_selection(); } -#ifndef __WXGTK__ +#ifdef __WXOSX__ +//#ifndef __WXGTK__ /* Workaround for a correct rendering of the control without Bitmap (under MSW and OSX): * * 1. We should create small Bitmap to fill Bitmaps RefData, @@ -868,7 +875,7 @@ void Choice::BUILD() { } double old_val = !m_value.empty() ? boost::any_cast(m_value) : -99999; - if (is_defined_input_value(window, m_opt.type)) { + if (is_defined_input_value(window, m_opt.type)) { if (fabs(old_val - boost::any_cast(get_value())) <= 0.0001) return; else @@ -891,7 +898,7 @@ void Choice::set_selection() wxString text_value = wxString(""); - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); switch (m_opt.type) { case coFloat: case coPercent: { @@ -961,7 +968,7 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda ++idx; } - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); idx == m_opt.enum_values.size() ? field->SetValue(value) : field->SetSelection(idx); @@ -973,7 +980,7 @@ void Choice::set_value(const boost::any& value, bool change_event) { m_disable_change_event = !change_event; - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); switch (m_opt.type) { case coInt: @@ -1049,7 +1056,7 @@ void Choice::set_values(const std::vector& values) // # it looks that Clear() also clears the text field in recent wxWidgets versions, // # but we want to preserve it - auto ww = dynamic_cast(window); + auto ww = dynamic_cast(window); auto value = ww->GetValue(); ww->Clear(); ww->Append(""); @@ -1082,7 +1089,7 @@ void Choice::set_values(const wxArrayString &values) boost::any& Choice::get_value() { - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); wxString ret_str = field->GetValue(); @@ -1142,11 +1149,14 @@ boost::any& Choice::get_value() return m_value; } +void Choice::enable() { dynamic_cast(window)->Enable(); }; +void Choice::disable() { dynamic_cast(window)->Disable(); }; + void Choice::msw_rescale(bool rescale_sidetext/* = false*/) { Field::msw_rescale(); - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); const wxString selection = field->GetValue();// field->GetString(index); /* To correct scaling (set new controll size) of a wxBitmapCombobox @@ -1177,9 +1187,11 @@ void Choice::msw_rescale(bool rescale_sidetext/* = false*/) } } +#ifdef __WXOSX__ wxBitmap empty_bmp(1, field->GetFont().GetPixelSize().y + 2); empty_bmp.SetWidth(0); field->SetItemBitmap(0, empty_bmp); +#endif idx == m_opt.enum_values.size() ? field->SetValue(selection) : diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index c716259db..d775abf3e 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -416,8 +416,8 @@ public: void msw_rescale(bool rescale_sidetext = false) override; - void enable() override { dynamic_cast(window)->Enable(); }; - void disable() override{ dynamic_cast(window)->Disable(); }; + void enable() override ;//{ dynamic_cast(window)->Enable(); }; + void disable() override;//{ dynamic_cast(window)->Disable(); }; wxWindow* getWindow() override { return window; } };