1325 {
1326 if (!c)
1327 return;
1330 auto cb = dynamic_cast<ComboBox *>(c->window);
1331 if (!cb)
1332 return;
1333 wxString old_selection = cb->GetStringSelection();
1334 int old_index = cb->GetSelection();
1335
1336
1337 int old_slot = old_index >= 0 && old_index < int(
slot_map.size()) ?
slot_map[old_index] : -1;
1338 cb->Clear();
1339 cb->Append(
_L(
"Default"));
1340 for (
auto i :
items) {
1341 cb->Append(i.first, i.second ? *i.second : wxNullBitmap);
1342 }
1343
1344 int restored =
index_of(wxString::Format(
"%d", old_slot));
1345 if (restored > 0 || old_slot == 0) {
1346 cb->SetSelection(restored);
1347 return;
1348 }
1349
1350 int new_index = cb->FindString(old_selection);
1351 if (old_index == cb->GetCount()) {
1352 cb->SetSelection(old_index - 1);
1353 } else if (new_index != wxNOT_FOUND) {
1354 cb->SetSelection(new_index);
1355 } else {
1356 cb->SetSelection(0);
1357 }
1358 }
#define _L(s)
Definition OBJ.cpp:34
void update()
Definition Field.cpp:1536
std::vector< int > slot_map
Definition Plater.cpp:1322
std::vector< std::pair< wxString, wxBitmap * > > items
Definition Plater.cpp:1321
int index_of(wxString value) override
Definition Plater.cpp:1365