| 237 | } |
| 238 | |
| 239 | void SelectionBar::AddSelectionSetupButton(wxSizer* pSizer) |
| 240 | { |
| 241 | auto setupBtn = MakeSetupButton(); |
| 242 | |
| 243 | auto showMenu = [this, setupBtn]() |
| 244 | { |
| 245 | static const wxString choices[4] = { |
| 246 | _("Start and End of Selection"), |
| 247 | _("Start and Length of Selection"), |
| 248 | _("Length and End of Selection"), |
| 249 | _("Length and Center of Selection"), |
| 250 | }; |
| 251 | |
| 252 | wxMenu menu; |
| 253 | int selectionMode {}; |
| 254 | for (auto& choice : choices) |
| 255 | { |
| 256 | auto subMenu = menu.AppendRadioItem(wxID_ANY, choice); |
| 257 | |
| 258 | if (static_cast<SelectionMode>(selectionMode) == mSelectionMode) |
| 259 | subMenu->Check(); |
| 260 | |
| 261 | menu.Bind( |
| 262 | wxEVT_MENU, |
| 263 | [this, selectionMode](auto& evt) |
| 264 | { |
| 265 | SetSelectionMode(static_cast<SelectionMode>(selectionMode)); |
| 266 | SelectionModeUpdated(); |
| 267 | }, |
| 268 | subMenu->GetId()); |
| 269 | |
| 270 | ++selectionMode; |
| 271 | } |
| 272 | |
| 273 | menu.Bind(wxEVT_MENU_CLOSE, [setupBtn](auto&) { setupBtn->PopUp(); }); |
| 274 | |
| 275 | BasicMenu::Handle { &menu }.Popup(wxWidgetsWindowPlacement { setupBtn }); |
| 276 | }; |
| 277 | |
| 278 | setupBtn->Bind(wxEVT_BUTTON, [this, showMenu](auto&) { showMenu(); }); |
| 279 | pSizer->Add(setupBtn, 0, wxALIGN_RIGHT | wxBOTTOM | wxRIGHT, 5); |
| 280 | |
| 281 | mSetupButton = setupBtn; |
| 282 | } |
| 283 | |
| 284 | void SelectionBar::Populate() |
| 285 | { |