From f8559862b41902d7661a5875e87c69c3b03272af Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 2 Apr 2016 08:52:34 +0100 Subject: [PATCH] OS X Porting: Fixed right-click menu creation so that it appears properly in OS X. --- source/widgets/XABContactMenu.cpp | 35 ++++++++++--------------------- source/widgets/XABContactMenu.h | 16 +++++++++++--- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/source/widgets/XABContactMenu.cpp b/source/widgets/XABContactMenu.cpp index cfef818..d643c06 100644 --- a/source/widgets/XABContactMenu.cpp +++ b/source/widgets/XABContactMenu.cpp @@ -20,16 +20,7 @@ #include "../frmMain.h" #include "../search/frmSearch.h" -enum { - ID_CONTACTMENU_OPEN, - ID_CONTACTMENU_NEW, - ID_CONTACTMENU_EDIT, - ID_CONTACTMENU_DELETE, - ID_CONTACTMENU_REFRESHAB, - ID_CONTACTMENU_REVEAL -}; - -XABContactMenu::XABContactMenu(int MenuTypeIn){ +XABContactMenu::XABContactMenu(XABContactMenuType MenuTypeIn){ // Setup the XABContactMenu control. @@ -38,7 +29,7 @@ XABContactMenu::XABContactMenu(int MenuTypeIn){ // Setup the menu items. AppendMenuItem(wxT("opencontact"), _("Open Contact..."), _(""), ID_CONTACTMENU_OPEN, wxITEM_NORMAL); - AppendMenuItem(wxT("sep1"), _(""), _(""), wxID_ANY, wxITEM_SEPARATOR); + AppendMenuItem(wxT("sep1"), _(""), _(""), ID_CONTACTMENU_SEPARATOR, wxITEM_SEPARATOR); if (MenuType == XABCONTACTMENU_MAIN){ @@ -63,7 +54,7 @@ XABContactMenu::XABContactMenu(int MenuTypeIn){ // Setup the delete and refresh contact options if in the main window. AppendMenuItem(wxT("deletecontact"), _("Delete Contact..."), _(""), ID_CONTACTMENU_DELETE, wxITEM_NORMAL); - AppendMenuItem(wxT("sep2"), _(""), _(""), wxID_ANY, wxITEM_SEPARATOR); + AppendMenuItem(wxT("sep2"), _(""), _(""), ID_CONTACTMENU_SEPARATOR, wxITEM_SEPARATOR); AppendMenuItem(wxT("refreshab"), _("Refresh Address Book"), _(""), ID_CONTACTMENU_REFRESHAB, wxITEM_NORMAL); } @@ -95,22 +86,18 @@ XABContactMenu::~XABContactMenu(){ void XABContactMenu::AppendMenuItem(wxString ObjectName, wxString MenuName, wxString MenuDescription, - int ItemID, + XABContactMenuID ItemID, wxItemKind ItemType){ - // Append a menu item to the XABContactMenu control. - - wxMenuItem *menuitem = new wxMenuItem( - NULL, - ItemID, - MenuName, - MenuDescription, - ItemType, - NULL - ); + if (ItemType == wxITEM_SEPARATOR){ + this->AppendSeparator(); + return; + } + // Append a menu item to the XABContactMenu control. + + wxMenuItem *menuitem = this->Append(ItemID, MenuName, MenuDescription); this->Connect(menuitem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(XABContactMenu::ProcessMenuItemClick)); - this->Append(menuitem); MenuItems.insert(std::make_pair(ObjectName.ToStdString(), menuitem)); } diff --git a/source/widgets/XABContactMenu.h b/source/widgets/XABContactMenu.h index 13e0cff..95092a7 100644 --- a/source/widgets/XABContactMenu.h +++ b/source/widgets/XABContactMenu.h @@ -25,7 +25,17 @@ #include #include -enum { +enum XABContactMenuID { + ID_CONTACTMENU_OPEN = 1, + ID_CONTACTMENU_NEW, + ID_CONTACTMENU_EDIT, + ID_CONTACTMENU_DELETE, + ID_CONTACTMENU_REFRESHAB, + ID_CONTACTMENU_REVEAL, + ID_CONTACTMENU_SEPARATOR +}; + +enum XABContactMenuType { XABCONTACTMENU_MAIN, XABCONTACTMENU_SEARCH }; @@ -55,12 +65,12 @@ class XABContactMenu : public XABContactMenuADT void AppendMenuItem(wxString ObjectName, wxString MenuName, wxString MenuDescription, - int ItemID, + XABContactMenuID ItemID, wxItemKind ItemType); protected: void ProcessMenuItemClick(wxCommandEvent& event); public: - XABContactMenu(int MenuType); + XABContactMenu(XABContactMenuType MenuType); ~XABContactMenu(); void SetupPointersSearch(wxWindow* WindowPtrIn, wxListCtrl* ContactListCtrlIn, -- 2.39.5