Fix zero luma corner case
[lsnes.git] / src / plat-wxwidgets / labelcombobox.cpp
blobb2101288bf3389514c6c6fd32d39f21f3c90360c
1 #include "core/command.hpp"
3 #include "plat-wxwidgets/labelcombobox.hpp"
5 labeledcombobox::labeledcombobox(wxSizer* sizer, wxWindow* parent, const std::string& label, wxString* choices,
6 size_t choice_count, size_t defaultidx, bool start_enabled, wxEvtHandler* dispatch_to,
7 wxObjectEventFunction on_fn_change)
9 sizer->Add(new wxStaticText(parent, wxID_ANY, towxstring(label)), 0, wxGROW);
10 sizer->Add(combo = new wxComboBox(parent, wxID_ANY, choices[defaultidx], wxDefaultPosition, wxDefaultSize,
11 choice_count, choices, wxCB_READONLY), 0, wxGROW);
12 if(dispatch_to)
13 combo->Connect(wxEVT_COMMAND_COMBOBOX_SELECTED, on_fn_change, NULL, dispatch_to);
14 combo->Enable(start_enabled);
15 enabled = start_enabled;
16 forced = false;
19 std::string labeledcombobox::get_choice()
21 return tostdstring(combo->GetValue());
24 void labeledcombobox::enable()
26 if(forced && !enabled)
27 combo->SetValue(remembered);
28 combo->Enable();
29 enabled = true;
32 void labeledcombobox::disable(const wxString& choice)
34 combo->Disable();
35 if(enabled)
36 remembered = combo->GetValue();
37 combo->SetValue(choice);
38 enabled = false;
39 forced = true;
42 void labeledcombobox::disable()
44 combo->Disable();
45 if(enabled)
46 remembered = combo->GetValue();
47 enabled = false;
48 forced = false;