[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 004e438 2/3: Don't derive SingleChoicePopupMe
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 004e438 2/3: Don't derive SingleChoicePopupMenu from wxWindow |
Date: |
Sun, 5 Nov 2017 12:57:17 -0500 (EST) |
branch: master
commit 004e4381ed60f1c3bbe392b6326017a1c1cc9c8d
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Don't derive SingleChoicePopupMenu from wxWindow
There doesn't seem to be any need to do it, so avoid creating an
unnecessary new window just to show a popup menu in it -- use the
existing window instead.
Also change the "parent" constructor argument to be a reference, not
pointer, as it can never be null.
---
single_choice_popup_menu.cpp | 8 ++++----
single_choice_popup_menu.hpp | 7 ++-----
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/single_choice_popup_menu.cpp b/single_choice_popup_menu.cpp
index 0c7dbc6..276b234 100644
--- a/single_choice_popup_menu.cpp
+++ b/single_choice_popup_menu.cpp
@@ -23,14 +23,14 @@
#include "single_choice_popup_menu.hpp"
-#include <wx/gdicmn.h> // wxDefaultPosition, wxSize
+#include <wx/window.h>
SingleChoicePopupMenu::SingleChoicePopupMenu
(wxArrayString const& choices
,wxString const& title
- ,wxWindow* parent
+ ,wxWindow& parent
)
- :wxWindow (parent, wxID_ANY, wxDefaultPosition, wxSize(0, 0))
+ :parent_(parent)
{
if(!title.IsEmpty())
{
@@ -50,6 +50,6 @@ SingleChoicePopupMenu::SingleChoicePopupMenu
// WX !! Can't be const because PopupMenu() isn't.
int SingleChoicePopupMenu::Choose()
{
- int const selection_index = GetPopupMenuSelectionFromUser(menu_);
+ int const selection_index = parent_.GetPopupMenuSelectionFromUser(menu_);
return selection_index != wxID_NONE ? selection_index : -1;
}
diff --git a/single_choice_popup_menu.hpp b/single_choice_popup_menu.hpp
index 5a9b0f3..f965526 100644
--- a/single_choice_popup_menu.hpp
+++ b/single_choice_popup_menu.hpp
@@ -29,7 +29,6 @@
#include <wx/arrstr.h> // wxArrayString
#include <wx/menu.h>
#include <wx/string.h>
-#include <wx/window.h>
/// Design notes for class SingleChoicePopupMenu.
///
@@ -41,21 +40,19 @@
/// the same character as its own accelerator.
class SingleChoicePopupMenu
- :public wxWindow
{
public:
SingleChoicePopupMenu
(wxArrayString const& choices
,wxString const& title = wxEmptyString
- ,wxWindow* parent = &TopWindow()
+ ,wxWindow& parent = TopWindow()
);
- ~SingleChoicePopupMenu() override = default;
-
int Choose();
private:
wxMenu menu_;
+ wxWindow& parent_;
};
#endif // single_choice_popup_menu_hpp