forked from d-j-hirst/aus-polling-analyser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChoiceInput.cpp
More file actions
23 lines (19 loc) · 914 Bytes
/
ChoiceInput.cpp
File metadata and controls
23 lines (19 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "ChoiceInput.h"
ChoiceInput::ChoiceInput(wxWindow* parent, wxWindowID choiceCtrlId, std::string labelText, wxArrayString choices, int initialChoice, wxPoint topLeft,
ChoiceChangeFunc choiceChangeFunc, int labelWidth, int textInputWidth)
: choiceChangeFunc(choiceChangeFunc), parent(parent)
{
initialChoice = std::clamp(initialChoice, 0, int(choices.size()) - 1);
staticText = new wxStaticText(parent, 0, labelText, topLeft, wxSize(labelWidth, Height));
comboBox = new wxComboBox(parent, choiceCtrlId, choices[initialChoice], topLeft + wxSize(labelWidth, 0), wxSize(textInputWidth, Height), choices);
comboBox->SetSelection(initialChoice);
parent->Bind(wxEVT_COMBOBOX, &ChoiceInput::updateChoice, this, comboBox->GetId());
}
int ChoiceInput::getSelection() const
{
return comboBox->GetSelection();
}
void ChoiceInput::updateChoice(wxCommandEvent & event)
{
choiceChangeFunc(event.GetInt());
}