OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::CaliComboBox Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/CalibrationWizardPresetPage.hpp>

Inheritance diagram for Slic3r::GUI::CaliComboBox:
Collaboration diagram for Slic3r::GUI::CaliComboBox:

Public Member Functions

 CaliComboBox (wxWindow *parent, wxString title, wxArrayString values, int default_index=0, std::function< void(wxCommandEvent &)> on_value_change=nullptr, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
int get_selection () const
wxString get_value () const
void set_values (const wxArrayString &values)

Private Attributes

wxBoxSizer * m_top_sizer
wxString m_title
ComboBox * m_combo_box
std::function< void(wxCommandEvent &)> m_on_value_change_call_back

Detailed Description

Constructor & Destructor Documentation

◆ CaliComboBox()

Slic3r::GUI::CaliComboBox::CaliComboBox ( wxWindow * parent,
wxString title,
wxArrayString values,
int default_index = 0,
std::function< void(wxCommandEvent &)> on_value_change = nullptr,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxTAB_TRAVERSAL )
219 : wxPanel(parent, id, pos, size, style)
220 , m_title(title)
221 , m_on_value_change_call_back(on_value_change)
222{
223 SetBackgroundColour(*wxWHITE);
224 m_top_sizer = new wxBoxSizer(wxVERTICAL);
225 m_top_sizer->AddSpacer(PRESET_GAP);
226 auto combo_title = new Label(this, title);
227 combo_title->SetFont(Label::Head_14);
228 combo_title->Wrap(-1);
229 m_top_sizer->Add(combo_title, 0, wxALL, 0);
230 m_top_sizer->AddSpacer(FromDIP(10));
231 m_combo_box = new ComboBox(this, wxID_ANY, "", wxDefaultPosition, CALIBRATION_COMBOX_SIZE, 0, nullptr, wxCB_READONLY);
232 m_top_sizer->Add(m_combo_box, 0, wxALL, 0);
233 m_top_sizer->AddSpacer(PRESET_GAP);
234
235 this->SetSizer(m_top_sizer);
236 m_top_sizer->Fit(this);
237
238 // set values
239 for (int i = 0; i < values.size(); ++i) {
240 m_combo_box->AppendString(values[i]);
241 }
242 m_combo_box->SetSelection(default_index);
243
244 // bind call back function
246 m_combo_box->Bind(wxEVT_COMBOBOX, m_on_value_change_call_back);
247}
#define PRESET_GAP
Definition CalibrationWizardPage.hpp:34
#define CALIBRATION_COMBOX_SIZE
Definition CalibrationWizardPage.hpp:35
#define style
Definition WipeTowerDialog.cpp:101
static wxFont Head_14
Definition Label.hpp:45
std::function< void(wxCommandEvent &)> m_on_value_change_call_back
Definition CalibrationWizardPresetPage.hpp:95
ComboBox * m_combo_box
Definition CalibrationWizardPresetPage.hpp:94
wxBoxSizer * m_top_sizer
Definition CalibrationWizardPresetPage.hpp:92
wxString m_title
Definition CalibrationWizardPresetPage.hpp:93

References CALIBRATION_COMBOX_SIZE, Label::Head_14, m_combo_box, m_on_value_change_call_back, m_title, m_top_sizer, PRESET_GAP, and style.

Member Function Documentation

◆ get_selection()

int Slic3r::GUI::CaliComboBox::get_selection ( ) const
250{
251 if (m_combo_box)
252 return m_combo_box->GetSelection();
253
254 return 0;
255}

References m_combo_box.

◆ get_value()

wxString Slic3r::GUI::CaliComboBox::get_value ( ) const
258{
259 if (m_combo_box)
260 return m_combo_box->GetValue();
261
262 return wxString();
263}

References m_combo_box.

◆ set_values()

void Slic3r::GUI::CaliComboBox::set_values ( const wxArrayString & values)
266{
267 if (m_combo_box) {
268 for (int i = 0; i < values.size(); ++i) {
269 m_combo_box->AppendString(values[i]);
270 }
271 m_combo_box->SetSelection(0);
272 }
273}

References m_combo_box.

Member Data Documentation

◆ m_combo_box

ComboBox* Slic3r::GUI::CaliComboBox::m_combo_box
private

◆ m_on_value_change_call_back

std::function<void(wxCommandEvent&)> Slic3r::GUI::CaliComboBox::m_on_value_change_call_back
private

Referenced by CaliComboBox().

◆ m_title

wxString Slic3r::GUI::CaliComboBox::m_title
private

Referenced by CaliComboBox().

◆ m_top_sizer

wxBoxSizer* Slic3r::GUI::CaliComboBox::m_top_sizer
private

Referenced by CaliComboBox().


The documentation for this class was generated from the following files: