Get rid of win32-crap.[ch]pp
[lsnes.git] / platform / wxwidgets / src / labelcombobox.cpp
blobd15ca74d316d4f7bfc2eb5a3c478822dbc9345d0
1 #include "labelcombobox.hpp"
2 #include "command.hpp"
4 labeledcombobox::labeledcombobox(wxSizer* sizer, wxWindow* parent, const std::string& label, wxString* choices,
5 size_t choice_count, size_t defaultidx, bool start_enabled, wxEvtHandler* dispatch_to,
6 wxObjectEventFunction on_fn_change)
8 sizer->Add(new wxStaticText(parent, wxID_ANY, towxstring(label)), 0, wxGROW);
9 sizer->Add(combo = new wxComboBox(parent, wxID_ANY, choices[defaultidx], wxDefaultPosition, wxDefaultSize,
10 choice_count, choices, wxCB_READONLY), 0, wxGROW);
11 if(dispatch_to)
12 combo->Connect(wxEVT_COMMAND_COMBOBOX_SELECTED, on_fn_change, NULL, dispatch_to);
13 combo->Enable(start_enabled);
14 enabled = start_enabled;
15 forced = false;
18 std::string labeledcombobox::get_choice()
20 return tostdstring(combo->GetValue());
23 void labeledcombobox::enable()
25 if(forced && !enabled)
26 combo->SetValue(remembered);
27 combo->Enable();
28 enabled = true;
31 void labeledcombobox::disable(const wxString& choice)
33 combo->Disable();
34 if(enabled)
35 remembered = combo->GetValue();
36 combo->SetValue(choice);
37 enabled = false;
38 forced = true;
41 void labeledcombobox::disable()
43 combo->Disable();
44 if(enabled)
45 remembered = combo->GetValue();
46 enabled = false;
47 forced = false;