[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1ddf486 1/3: Simplify SingleChoicePopupMenu b
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1ddf486 1/3: Simplify SingleChoicePopupMenu by using wxWidgets functionality |
Date: |
Sun, 5 Nov 2017 12:57:17 -0500 (EST) |
branch: master
commit 1ddf486fc96e33c08e61925c384567ab9bf08361
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Simplify SingleChoicePopupMenu by using wxWidgets functionality
Use the existing wxWindow::GetPopupMenuSelectionFromUser() function
instead of reproducing what it does in our own code.
---
single_choice_popup_menu.cpp | 17 ++---------------
single_choice_popup_menu.hpp | 3 ---
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/single_choice_popup_menu.cpp b/single_choice_popup_menu.cpp
index 4ce027e..0c7dbc6 100644
--- a/single_choice_popup_menu.cpp
+++ b/single_choice_popup_menu.cpp
@@ -31,7 +31,6 @@ SingleChoicePopupMenu::SingleChoicePopupMenu
,wxWindow* parent
)
:wxWindow (parent, wxID_ANY, wxDefaultPosition, wxSize(0, 0))
- ,selection_index_(-1)
{
if(!title.IsEmpty())
{
@@ -46,23 +45,11 @@ SingleChoicePopupMenu::SingleChoicePopupMenu
}
menu_.Append(j, s);
}
- Connect
- (0
- ,choices.GetCount()
- ,wxEVT_COMMAND_MENU_SELECTED
- ,wxCommandEventHandler(SingleChoicePopupMenu::UponMenuChoice)
- );
}
// WX !! Can't be const because PopupMenu() isn't.
int SingleChoicePopupMenu::Choose()
{
- PopupMenu(&menu_);
- return selection_index_;
+ int const selection_index = GetPopupMenuSelectionFromUser(menu_);
+ return selection_index != wxID_NONE ? selection_index : -1;
}
-
-void SingleChoicePopupMenu::UponMenuChoice(wxCommandEvent& e)
-{
- selection_index_ = e.GetId();
-}
-
diff --git a/single_choice_popup_menu.hpp b/single_choice_popup_menu.hpp
index d4e345f..5a9b0f3 100644
--- a/single_choice_popup_menu.hpp
+++ b/single_choice_popup_menu.hpp
@@ -55,10 +55,7 @@ class SingleChoicePopupMenu
int Choose();
private:
- void UponMenuChoice(wxCommandEvent&);
-
wxMenu menu_;
- int selection_index_;
};
#endif // single_choice_popup_menu_hpp