[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] popup menus cleanup
From: |
Vaclav Slavik |
Subject: |
[lmi] popup menus cleanup |
Date: |
Mon, 05 Jul 2010 17:02:49 +0200 |
Hi,
please apply the patch below. It cleans up popup menus code:
1. It is better not to pass coordinates to PopupMenu. From
http://docs.wxwidgets.org/trunk/classwx_window.html#8f715d238cf74a845488b0e2645e98df
:
It is recommended to not explicitly specify coordinates
when calling PopupMenu in response to mouse click,
because some of the ports (namely, wxGTK) can do a
better job of positioning the menu in that case.
(I found out because CensusView::UponRightClick2() position
calculation was incorrect and visibly off in wxGTK.)
2. While I was at it, I removed CensusView::UponRightClick{0,1} -- the
one currently in use, with EVT_CONTEXT_MENU, is the right thing to
do.
Thanks,
Vaclav
diff --git a/census_view.cpp b/census_view.cpp
index 7b08876..20efdbe 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -87,11 +87,7 @@ namespace
IMPLEMENT_DYNAMIC_CLASS(CensusView, ViewEx)
BEGIN_EVENT_TABLE(CensusView, ViewEx)
-// TODO ?? Experimental: (Ask Vadim whether wxGTK supports this.)
-// EVT_COMMAND_RIGHT_CLICK(ID_LISTWINDOW ,CensusView::UponRightClick0)
-// TODO ?? No effect--dunno why; but prolly wanted for gtk:
-// EVT_RIGHT_UP( CensusView::UponRightClick1)
- EVT_CONTEXT_MENU( CensusView::UponRightClick2)
+ EVT_CONTEXT_MENU( CensusView::UponRightClick)
EVT_MENU(XRCID("edit_cell" ),CensusView::UponEditCell )
EVT_MENU(XRCID("edit_class" ),CensusView::UponEditClass)
EVT_MENU(XRCID("edit_case" ),CensusView::UponEditCase )
@@ -711,50 +707,7 @@ void CensusView::UponColumnWidthFixed(wxCommandEvent&)
}
}
-// TODO ?? Right-click handlers: pick one approach, and remove failed
experiments.
-
-void CensusView::UponRightClick0(wxCommandEvent&)
-{
- status() << "UponRightClick0()" << LMI_FLUSH;
- wxMenuBar* menu_bar = MenuBar();
- if(menu_bar)
- {
- int census_menu_index = menu_bar->FindMenu("Census");
- if(wxNOT_FOUND != census_menu_index)
- {
- status() << "Menu found." << LMI_FLUSH;
- wxMenu* census_menu = menu_bar->GetMenu(census_menu_index);
- list_window_->PopupMenu(census_menu, list_window_->GetPosition());
- }
- else
- {
- status() << "Menu not found." << LMI_FLUSH;
- }
- }
-}
-
-void CensusView::UponRightClick1(wxMouseEvent& e)
-{
- status() << "UponRightClick1()" << LMI_FLUSH;
- wxMenuBar* menu_bar = MenuBar();
- if(menu_bar)
- {
- int census_menu_index = menu_bar->FindMenu("Census");
- if(wxNOT_FOUND != census_menu_index)
- {
- status() << "Menu found." << LMI_FLUSH;
- wxMenu* census_menu = menu_bar->GetMenu(census_menu_index);
- wxPoint* point = new wxPoint(e.m_x, e.m_y);
- list_window_->PopupMenu(census_menu, *point);
- }
- else
- {
- status() << "Menu not found." << LMI_FLUSH;
- }
- }
-}
-
-void CensusView::UponRightClick2(wxContextMenuEvent& e)
+void CensusView::UponRightClick(wxContextMenuEvent& e)
{
wxMenuBar* menu_bar = MenuBar();
if(menu_bar)
@@ -763,7 +716,7 @@ void CensusView::UponRightClick2(wxContextMenuEvent& e)
if(wxNOT_FOUND != census_menu_index)
{
wxMenu* census_menu = menu_bar->GetMenu(census_menu_index);
- list_window_->PopupMenu(census_menu,
GetFrame()->ScreenToClient(e.GetPosition()));
+ list_window_->PopupMenu(census_menu);
}
else
{
diff --git a/census_view.hpp b/census_view.hpp
index f983fa6..44f9459 100644
--- a/census_view.hpp
+++ b/census_view.hpp
@@ -75,9 +75,7 @@ class CensusView
void UponColumnWidthVarying (wxCommandEvent&);
void UponColumnWidthFixed (wxCommandEvent&);
void UponPasteCensus (wxCommandEvent&);
- void UponRightClick0 (wxCommandEvent&);
- void UponRightClick1 (wxMouseEvent&);
- void UponRightClick2 (wxContextMenuEvent&);
+ void UponRightClick (wxContextMenuEvent&);
void UponPrintCase (wxCommandEvent&);
void UponPrintCaseToDisk (wxCommandEvent&);
void UponRunCell (wxCommandEvent&);
diff --git a/single_choice_popup_menu.cpp b/single_choice_popup_menu.cpp
index 466b115..05f0c0d 100644
--- a/single_choice_popup_menu.cpp
+++ b/single_choice_popup_menu.cpp
@@ -73,7 +73,7 @@ SingleChoicePopupMenu::~SingleChoicePopupMenu()
// WX !! Can't be const because PopupMenu() isn't.
int SingleChoicePopupMenu::Choose()
{
- PopupMenu(&menu_, ScreenToClient(wxGetMousePosition()));
+ PopupMenu(&menu_);
return selection_index_;
}
- [lmi] popup menus cleanup,
Vaclav Slavik <=