Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
OS X Porting: Fixed right-click menu creation so that it appears properly in OS X.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 2 Apr 2016 07:52:34 +0000 (08:52 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 2 Apr 2016 07:52:34 +0000 (08:52 +0100)
source/widgets/XABContactMenu.cpp
source/widgets/XABContactMenu.h

index cfef818..d643c06 100644 (file)
 #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));
 
 }
index 13e0cff..95092a7 100644 (file)
 #include <wx/listctrl.h>
 #include <wx/app.h>
 
-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,
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy