Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/slic3r/GUI/Field.cpp')
-rw-r--r--src/slic3r/GUI/Field.cpp64
1 files changed, 37 insertions, 27 deletions
diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp
index f691a8065..217b9380a 100644
--- a/src/slic3r/GUI/Field.cpp
+++ b/src/slic3r/GUI/Field.cpp
@@ -2,6 +2,7 @@
#include "GUI_App.hpp"
#include "I18N.hpp"
#include "Field.hpp"
+#include "wxExtensions.hpp"
#include "libslic3r/PrintConfig.hpp"
@@ -505,15 +506,17 @@ void SpinCtrl::propagate_value()
}
void Choice::BUILD() {
- auto size = wxSize(wxDefaultSize);
+ wxSize size(15 * wxGetApp().em_unit(), -1);
if (m_opt.height >= 0) size.SetHeight(m_opt.height);
if (m_opt.width >= 0) size.SetWidth(m_opt.width);
- wxComboBox* temp;
- if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0)
- temp = new wxComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
+ wxBitmapComboBox* 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);
+ }
else
- temp = new wxComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, NULL, wxCB_READONLY);
+ temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
@@ -525,19 +528,19 @@ void Choice::BUILD() {
else{
for (auto el : m_opt.enum_labels.empty() ? m_opt.enum_values : m_opt.enum_labels) {
const wxString& str = _(el);//m_opt_id == "support" ? _(el) : el;
- temp->Append(str);
+ temp->Append(str, create_scaled_bitmap("empty_icon.png"));
}
set_selection();
}
// temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
temp->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
- if (temp->GetWindowStyle() != wxCB_READONLY) {
+ if (m_is_editable) {
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
e.Skip();
if (m_opt.type == coStrings) return;
double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999;
- if (is_defined_input_value<wxComboBox>(window, m_opt.type)) {
+ if (is_defined_input_value<wxBitmapComboBox>(window, m_opt.type)) {
if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001)
return;
else
@@ -554,6 +557,8 @@ void Choice::BUILD() {
void Choice::set_selection()
{
wxString text_value = wxString("");
+
+ wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
switch (m_opt.type) {
case coFloat:
case coPercent: {
@@ -568,13 +573,13 @@ void Choice::set_selection()
}
// if (m_opt.type == coPercent) text_value += "%";
idx == m_opt.enum_values.size() ?
- dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
- dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+ field->SetValue(text_value) :
+ field->SetSelection(idx);
break;
}
case coEnum:{
int id_value = static_cast<const ConfigOptionEnum<SeamPosition>*>(m_opt.default_value)->value; //!!
- dynamic_cast<wxComboBox*>(window)->SetSelection(id_value);
+ field->SetSelection(id_value);
break;
}
case coInt:{
@@ -588,8 +593,8 @@ void Choice::set_selection()
++idx;
}
idx == m_opt.enum_values.size() ?
- dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
- dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+ field->SetValue(text_value) :
+ field->SetSelection(idx);
break;
}
case coStrings:{
@@ -603,8 +608,8 @@ void Choice::set_selection()
++idx;
}
idx == m_opt.enum_values.size() ?
- dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
- dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+ field->SetValue(text_value) :
+ field->SetSelection(idx);
break;
}
}
@@ -622,9 +627,10 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda
++idx;
}
+ wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
idx == m_opt.enum_values.size() ?
- dynamic_cast<wxComboBox*>(window)->SetValue(value) :
- dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+ field->SetValue(value) :
+ field->SetSelection(idx);
m_disable_change_event = false;
}
@@ -633,6 +639,8 @@ void Choice::set_value(const boost::any& value, bool change_event)
{
m_disable_change_event = !change_event;
+ wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
+
switch (m_opt.type) {
case coInt:
case coFloat:
@@ -654,11 +662,11 @@ void Choice::set_value(const boost::any& value, bool change_event)
if (idx == m_opt.enum_values.size()) {
// For editable Combobox under OSX is needed to set selection to -1 explicitly,
// otherwise selection doesn't be changed
- dynamic_cast<wxComboBox*>(window)->SetSelection(-1);
- dynamic_cast<wxComboBox*>(window)->SetValue(text_value);
+ field->SetSelection(-1);
+ field->SetValue(text_value);
}
else
- dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+ field->SetSelection(idx);
break;
}
case coEnum: {
@@ -688,7 +696,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
else
val = 0;
}
- dynamic_cast<wxComboBox*>(window)->SetSelection(val);
+ field->SetSelection(val);
break;
}
default:
@@ -707,7 +715,7 @@ void Choice::set_values(const std::vector<std::string>& values)
// # it looks that Clear() also clears the text field in recent wxWidgets versions,
// # but we want to preserve it
- auto ww = dynamic_cast<wxComboBox*>(window);
+ auto ww = dynamic_cast<wxBitmapComboBox*>(window);
auto value = ww->GetValue();
ww->Clear();
ww->Append("");
@@ -720,8 +728,9 @@ void Choice::set_values(const std::vector<std::string>& values)
boost::any& Choice::get_value()
{
-// boost::any m_value;
- wxString ret_str = static_cast<wxComboBox*>(window)->GetValue();
+ wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
+
+ wxString ret_str = field->GetValue();
// options from right panel
std::vector <std::string> right_panel_options{ "support", "scale_unit" };
@@ -731,7 +740,7 @@ boost::any& Choice::get_value()
if (m_opt.type == coEnum)
{
- int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
+ int ret_enum = field->GetSelection();
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern")
{
if (!m_opt.enum_values.empty()) {
@@ -760,8 +769,9 @@ boost::any& Choice::get_value()
m_value = static_cast<SLAPillarConnectionMode>(ret_enum);
}
else if (m_opt.gui_type == "f_enum_open") {
- const int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
- if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings)
+ const int ret_enum = field->GetSelection();
+ if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings ||
+ ret_str != m_opt.enum_values[ret_enum] && ret_str != m_opt.enum_labels[ret_enum] )
// modifies ret_string!
get_value_by_opt_type(ret_str);
else