Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Right click menu support added for the contact list and search results.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Fri, 27 Nov 2015 19:15:00 +0000 (19:15 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Fri, 27 Nov 2015 19:15:00 +0000 (19:15 +0000)
source/AppXestiaAddrBk.cpp
source/AppXestiaAddrBk.h
source/Makefile.in
source/frmMain.cpp
source/frmMain.h
source/frmSearch.cpp
source/frmSearch.h
source/widgets/XABContactMenu.cpp [new file with mode: 0644]
source/widgets/XABContactMenu.h [new file with mode: 0644]

index e754057..0755c34 100644 (file)
@@ -239,9 +239,10 @@ frmMainADT::frmMainADT( wxWindow* parent, wxWindowID id, const wxString& title,
        this->Connect( showHelp->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmMainADT::ShowHelp ) );\r
        this->Connect( mnuHelpUpdates->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmMainADT::CheckUpdates ) );\r
        this->Connect( mnuAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmMainADT::ShowAboutWindow ) );\r
-       lstContacts->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( frmMainADT::OpenContactInfo ), NULL, this );\r
+       lstContacts->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( frmMainADT::OpenContactInfoList ), NULL, this );\r
        lstContacts->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( frmMainADT::ShowContactInfo ), NULL, this );\r
        lstContacts->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( frmMainADT::ShowContactInfo ), NULL, this );\r
+       lstContacts->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( frmMainADT::ShowContactMenu ), NULL, this );\r
        htmContactData->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( frmMainADT::ShowContactSubmenu ), NULL, this );\r
        stbBottom->Connect( wxEVT_SIZE, wxSizeEventHandler( frmMainADT::UpdateSBIconPlacement ), NULL, this );\r
 }\r
@@ -274,9 +275,10 @@ frmMainADT::~frmMainADT()
        this->Disconnect( ID_HELP_SHOW, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmMainADT::ShowHelp ) );\r
        this->Disconnect( ID_MANAGE_UPDATE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmMainADT::CheckUpdates ) );\r
        this->Disconnect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmMainADT::ShowAboutWindow ) );\r
-       lstContacts->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( frmMainADT::OpenContactInfo ), NULL, this );\r
+       lstContacts->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( frmMainADT::OpenContactInfoList ), NULL, this );\r
        lstContacts->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( frmMainADT::ShowContactInfo ), NULL, this );\r
        lstContacts->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( frmMainADT::ShowContactInfo ), NULL, this );\r
+       lstContacts->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( frmMainADT::ShowContactMenu ), NULL, this );\r
        htmContactData->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( frmMainADT::ShowContactSubmenu ), NULL, this );\r
        stbBottom->Disconnect( wxEVT_SIZE, wxSizeEventHandler( frmMainADT::UpdateSBIconPlacement ), NULL, this );\r
        \r
@@ -488,6 +490,7 @@ frmSearchADT::frmSearchADT( wxWindow* parent, wxWindowID id, const wxString& tit
        btnSelectAccounts->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmSearchADT::SelectAccounts ), NULL, this );\r
        btnSearch->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmSearchADT::SearchContacts ), NULL, this );\r
        btnReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmSearchADT::ResetContacts ), NULL, this );\r
+       lstResults->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( frmSearchADT::ShowContactMenu ), NULL, this );\r
        this->Connect( mnuContactOpen->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmSearchADT::OpenContact ) );\r
        this->Connect( mnuContactEdit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmSearchADT::EditContact ) );\r
        this->Connect( mnuContactReveal->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmSearchADT::RevealContact ) );\r
@@ -501,6 +504,7 @@ frmSearchADT::~frmSearchADT()
        btnSelectAccounts->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmSearchADT::SelectAccounts ), NULL, this );\r
        btnSearch->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmSearchADT::SearchContacts ), NULL, this );\r
        btnReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmSearchADT::ResetContacts ), NULL, this );\r
+       lstResults->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( frmSearchADT::ShowContactMenu ), NULL, this );\r
        this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmSearchADT::OpenContact ) );\r
        this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmSearchADT::EditContact ) );\r
        this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( frmSearchADT::RevealContact ) );\r
index 97dba60..72fe433 100644 (file)
@@ -128,8 +128,9 @@ class frmMainADT : public wxFrame
                virtual void ShowHelp( wxCommandEvent& event ) { event.Skip(); }\r
                virtual void CheckUpdates( wxCommandEvent& event ) { event.Skip(); }\r
                virtual void ShowAboutWindow( wxCommandEvent& event ) { event.Skip(); }\r
-               virtual void OpenContactInfo( wxListEvent& event ) { event.Skip(); }\r
+               virtual void OpenContactInfoList( wxListEvent& event ) { event.Skip(); }\r
                virtual void ShowContactInfo( wxListEvent& event ) { event.Skip(); }\r
+               virtual void ShowContactMenu( wxMouseEvent& event ) { event.Skip(); }\r
                virtual void ShowContactSubmenu( wxMouseEvent& event ) { event.Skip(); }\r
                virtual void UpdateSBIconPlacement( wxSizeEvent& event ) { event.Skip(); }\r
                \r
@@ -212,6 +213,7 @@ class frmSearchADT : public wxFrame
                virtual void SelectAccounts( wxCommandEvent& event ) { event.Skip(); }\r
                virtual void SearchContacts( wxCommandEvent& event ) { event.Skip(); }\r
                virtual void ResetContacts( wxCommandEvent& event ) { event.Skip(); }\r
+               virtual void ShowContactMenu( wxMouseEvent& event ) { event.Skip(); }\r
                virtual void OpenContact( wxCommandEvent& event ) { event.Skip(); }\r
                virtual void EditContact( wxCommandEvent& event ) { event.Skip(); }\r
                virtual void RevealContact( wxCommandEvent& event ) { event.Skip(); }\r
index 3765ce6..3b89cd6 100644 (file)
@@ -91,7 +91,7 @@ FORMOBJS=AppXestiaAddrBk.o frmActivityMgr.o frmAbout.o frmMain.o \
  frmNewAccount.o frmPreferences.o frmContact.o frmConflictResolution.o \\r
  frmEditAccount.o frmInvalidSSLCertificate.o frmSSLCertificate.o \\r
  frmUpdate.o\r
-WIDGETOBJS=widgets/XABAccountView.o\r
+WIDGETOBJS=widgets/XABAccountView.o widgets/XABContactMenu.o\r
 BMCOOBJS=tools/bitmapcode.o\r
 \r
 xestiaab: bitmaphelper formobjs widgetobjs commonobjs vcardobjs carddavobjs \\r
index 4c37555..83eaa16 100644 (file)
@@ -13,6 +13,7 @@
 #include <wx/dir.h>
 #include <wx/stdpaths.h>
 #include <wx/fileconf.h>
+#include <wx/gdicmn.h>
 //#include <boost/filesystem/fstream.hpp>
 
 // Include the forms.
@@ -40,6 +41,7 @@
 #include "contacteditor/frmContactEditor.h"
 #include "import/import.h"
 #include "export/export.h"
+#include "widgets/XABContactMenu.h"
 #include "widgets/XABAccountView.h"
 
 #include "version.h"
@@ -53,7 +55,10 @@ DEFINE_EVENT_TYPE(CE_UPDATECONTACTLIST);
 DEFINE_EVENT_TYPE(CE_UPDATEACCOUNTLIST);
 DEFINE_EVENT_TYPE(SE_UPDATECONTACTNOTIF);
 DEFINE_EVENT_TYPE(CE_OPENCONTACT);
+DEFINE_EVENT_TYPE(CE_OPENCONTACTLIST);
+DEFINE_EVENT_TYPE(CE_NEWCONTACT);
 DEFINE_EVENT_TYPE(CE_EDITCONTACT);
+DEFINE_EVENT_TYPE(CE_DELETECONTACT);
 DEFINE_EVENT_TYPE(CE_REVEALCONTACT);
 DEFINE_EVENT_TYPE(CE_REMOVECONTACT);
 DEFINE_EVENT_TYPE(CE_REMOVESEARCH);
@@ -63,7 +68,6 @@ DEFINE_EVENT_TYPE(ACTMGR_SHUFFLE);
 DEFINE_EVENT_TYPE(ACTMGR_STOP);
 DEFINE_EVENT_TYPE(WINDOW_ADD);
 DEFINE_EVENT_TYPE(WINDOW_EDIT);
-//DEFINE_EVENT_TYPE(WINDOW_DELETE);
 DEFINE_EVENT_TYPE(WINDOW_CLOSE);
 DEFINE_EVENT_TYPE(CONNSTAT_UPDATE);
 DEFINE_EVENT_TYPE(INVALIDSSLCERT);
@@ -71,6 +75,7 @@ DEFINE_EVENT_TYPE(GETSELECTEDLIST);
 DEFINE_EVENT_TYPE(SYNCACCOUNT);
 DEFINE_EVENT_TYPE(IMPORT_RESULTSSHOW);
 DEFINE_EVENT_TYPE(RELOADCONTACTLIST);
+DEFINE_EVENT_TYPE(REFRESHADDRESSBOOK);
 
 BEGIN_EVENT_TABLE(frmMain, wxFrame)
 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, frmMain::ConflictResolution)
@@ -78,7 +83,10 @@ EVT_COMMAND(wxID_ANY, CE_UPDATECONTACTLIST, frmMain::UpdateContactList)
 EVT_COMMAND(wxID_ANY, CE_UPDATEACCOUNTLIST, frmMain::UpdateAccountList)
 EVT_COMMAND(wxID_ANY, SE_UPDATECONTACTNOTIF, frmMain::UpdateSearchContactLists)
 EVT_COMMAND(wxID_ANY, CE_OPENCONTACT, frmMain::OpenContactInfo)
+EVT_COMMAND(wxID_ANY, CE_OPENCONTACTLIST, frmMain::OpenContactInfoList)
+EVT_COMMAND(wxID_ANY, CE_NEWCONTACT, frmMain::ShowContactEditorNew)
 EVT_COMMAND(wxID_ANY, CE_EDITCONTACT, frmMain::ShowContactEditorEdit)
+EVT_COMMAND(wxID_ANY, CE_DELETECONTACT, frmMain::DeleteContact)
 EVT_COMMAND(wxID_ANY, CE_REVEALCONTACT, frmMain::RevealContact)
 EVT_COMMAND(wxID_ANY, CE_REMOVESEARCH, frmMain::RemoveContactsWindowPointer)
 EVT_COMMAND(wxID_ANY, SYNC_EMPTYSERVER, frmMain::EmptyServerDialog)
@@ -94,6 +102,7 @@ EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList)
 EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount)
 EVT_COMMAND(wxID_ANY, IMPORT_RESULTSSHOW, frmMain::ShowImportResults)
 EVT_COMMAND(wxID_ANY, RELOADCONTACTLIST, frmMain::ReloadContactList)
+EVT_COMMAND(wxID_ANY, REFRESHADDRESSBOOK, frmMain::RefreshAddressBook)
 END_EVENT_TABLE()
 
 frmMain::frmMain( wxWindow* parent )
@@ -1248,7 +1257,7 @@ void frmMain::RefreshAddressBook( wxCommandEvent& event ){
     
 }
 
-void frmMain::OpenContactInfo( wxListEvent& event )
+void frmMain::OpenContactInfoList( wxListEvent& event )
 {
     
     wxStringTokenizer vcardfileline;
@@ -1305,6 +1314,13 @@ void frmMain::OpenContactInfo( wxListEvent& event )
     
 }
 
+void frmMain::OpenContactInfoList( wxCommandEvent& event ){
+
+       wxListEvent pevent;
+       OpenContactInfoList(pevent);
+
+}
+
 void frmMain::OpenContactInfo( wxCommandEvent& event )
 {
     
@@ -2854,4 +2870,20 @@ void frmMain::ReloadContactList( wxCommandEvent &event ){
        
        }
 
+}
+
+void frmMain::ShowContactMenu( wxMouseEvent& event ){
+
+       bool EnableRefresh = FALSE;
+
+       if (!ActiveAccount.IsEmpty()){
+
+               EnableRefresh = TRUE;
+       
+       }
+
+       ContactMenu->SetupPointers(this, lstContacts, EnableRefresh);
+
+       this->PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition);
+
 }
\ No newline at end of file
index 497c13f..d4661df 100644 (file)
@@ -22,9 +22,10 @@ Subclass of frmMainADT, which is generated by wxFormBuilder.
 #include "common/timers.h"
 #include "common/events.h"
 #include "common/etag.h"
-#include "widgets/XABAccountView.h"
 #include "bitmaps.h"
 #include "common/sslcertstructs.h"
+#include "widgets/XABContactMenu.h"
+#include "widgets/XABAccountView.h"
 
 //// end generated include
 
@@ -32,7 +33,10 @@ DECLARE_EVENT_TYPE(CE_UPDATECONTACTLIST, wxID_ANY)
 DECLARE_EVENT_TYPE(CE_UPDATEACCOUNTLIST, wxID_ANY)
 DECLARE_EVENT_TYPE(SE_UPDATECONTACTNOTIF, wxID_ANY)
 DECLARE_EVENT_TYPE(CE_OPENCONTACT, wxID_ANY)
+DECLARE_EVENT_TYPE(CE_OPENCONTACTLIST, wxID_ANY)
+DECLARE_EVENT_TYPE(CE_NEWCONTACT, wxID_ANY)
 DECLARE_EVENT_TYPE(CE_EDITCONTACT, wxID_ANY)
+DECLARE_EVENT_TYPE(CE_DELETECONTACT, wxID_ANY)
 DECLARE_EVENT_TYPE(CE_REVEALCONTACT, wxID_ANY)
 DECLARE_EVENT_TYPE(CE_REMOVESEARCH, wxID_ANY)
 DECLARE_EVENT_TYPE(CE_REMOVECONTACT, wxID_ANY)
@@ -50,6 +54,7 @@ DECLARE_EVENT_TYPE(GETSELECTEDLIST, wxID_ANY);
 DECLARE_EVENT_TYPE(SYNCACCOUNT, wxID_ANY);
 DECLARE_EVENT_TYPE(IMPORT_RESULTSSHOW, wxID_ANY);
 DECLARE_EVENT_TYPE(RELOADCONTACTLIST, wxID_ANY);
+DECLARE_EVENT_TYPE(REFRESHADDRESSBOOK, wxID_ANY);
 
 struct UCNotif{
        wxString ContactAccount;
@@ -153,6 +158,7 @@ class frmMain : public frmMainADT
                int ContactUID = 0;
                int ContactEditorUID = 0;
                int WindowMenuItemID = 0;
+               XABContactMenu *ContactMenu = new XABContactMenu(XABCONTACTMENU_MAIN); 
        protected:
                // Handlers for frmMainADT events.
                void QuitApp( wxCloseEvent& event );
@@ -164,7 +170,8 @@ class frmMain : public frmMainADT
                void LoadPreferences( wxActivateEvent& event );
                void LoadPreferences();
                void ShowContactInfo( wxListEvent& event );
-               void OpenContactInfo( wxListEvent& event );
+               void OpenContactInfoList( wxListEvent& event );
+               void OpenContactInfoList( wxCommandEvent& event );
                void OpenContactInfo( wxCommandEvent& event );
                void ShowContactEditorNew( wxCommandEvent& event );             
                void ShowContactEditorEdit( wxCommandEvent& event );
@@ -213,6 +220,8 @@ class frmMain : public frmMainADT
                void GetSelectedList( wxCommandEvent& event );
                void SyncAccount( wxCommandEvent& event );
                void ShowHelp( wxCommandEvent& event );
+               void ShowContactMenu( wxMouseEvent& event );
+               void ProcessMenuItemClick( wxCommandEvent &event );
        public:
                /** Constructor */
                frmMain( wxWindow* parent );
index f3ae077..5e8610a 100644 (file)
@@ -23,6 +23,9 @@ DEFINE_EVENT_TYPE(SE_SBUPDATE);
 DEFINE_EVENT_TYPE(SE_SEARCHFINISHED);
 DEFINE_EVENT_TYPE(SE_UPDATERESULT);
 DEFINE_EVENT_TYPE(SE_DELETERESULT);
+DEFINE_EVENT_TYPE(SE_OPENCONTACT);
+DEFINE_EVENT_TYPE(SE_EDITCONTACT);
+DEFINE_EVENT_TYPE(SE_REVEALCONTACT);
 
 BEGIN_EVENT_TABLE(frmSearch, wxFrame)
   EVT_COMMAND(wxID_ANY, SE_ADDSEARCHSETTING, frmSearch::AddSearchSetting)
@@ -33,6 +36,9 @@ BEGIN_EVENT_TABLE(frmSearch, wxFrame)
   EVT_COMMAND(wxID_ANY, SE_SEARCHFINISHED, frmSearch::SearchFinished)
   EVT_COMMAND(wxID_ANY, SE_UPDATERESULT, frmSearch::UpdateResult)
   EVT_COMMAND(wxID_ANY, SE_DELETERESULT, frmSearch::DeleteResult)
+  EVT_COMMAND(wxID_ANY, SE_OPENCONTACT, frmSearch::OpenContact)
+  EVT_COMMAND(wxID_ANY, SE_EDITCONTACT, frmSearch::EditContact)
+  EVT_COMMAND(wxID_ANY, SE_REVEALCONTACT, frmSearch::RevealContact)
 END_EVENT_TABLE()
 
 //namespace boostfs = boost::filesystem;
@@ -1740,4 +1746,12 @@ void frmSearch::SetSearchMode(bool SearchModeIn){
        
        }
        
+}
+
+void frmSearch::ShowContactMenu( wxMouseEvent& event ){
+
+       ContactMenu->SetupPointers(this, lstResults);
+
+       PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition);
+
 }
\ No newline at end of file
index c167f0c..90998fd 100644 (file)
@@ -8,10 +8,10 @@ Subclass of frmSearchADT, which is generated by wxFormBuilder.
 
 #include "AppXestiaAddrBk.h"
 #include "vcard/vcard.h"
+#include "widgets/XABContactMenu.h"
 
 #include <map>
 
-
 //// end generated include
 
 DECLARE_EVENT_TYPE(SE_ADDSEARCHSETTING, wxID_ANY)
@@ -22,6 +22,9 @@ DECLARE_EVENT_TYPE(SE_SBUPDATE, wxID_ANY)
 DECLARE_EVENT_TYPE(SE_SEARCHFINISHED, wxID_ANY)
 DECLARE_EVENT_TYPE(SE_UPDATERESULT, wxID_ANY)
 DECLARE_EVENT_TYPE(SE_DELETERESULT, wxID_ANY)
+DECLARE_EVENT_TYPE(SE_OPENCONTACT, wxID_ANY)
+DECLARE_EVENT_TYPE(SE_EDITCONTACT, wxID_ANY)
+DECLARE_EVENT_TYPE(SE_REVEALCONTACT, wxID_ANY)
 
 struct SRNotif{
        vCardName ContactName;
@@ -52,6 +55,7 @@ class frmSearch : public frmSearchADT
                        wxString Account,
                        std::map<long,wxString> *SRAcc,
                        std::map<long,wxString> *SRFN);
+               XABContactMenu *ContactMenu = new XABContactMenu(XABCONTACTMENU_SEARCH);
        protected:
                // Handlers for frmSearchADT events.
                void SelectAccounts( wxCommandEvent& event );
@@ -72,6 +76,7 @@ class frmSearch : public frmSearchADT
                void UpdateResult( wxCommandEvent& event );
                void DeleteResult( wxCommandEvent& event );
                void CloseWindow( wxCloseEvent& event );
+               void ShowContactMenu( wxMouseEvent& event );
        public:
                /** Constructor */
                frmSearch( wxWindow* parent );
diff --git a/source/widgets/XABContactMenu.cpp b/source/widgets/XABContactMenu.cpp
new file mode 100644 (file)
index 0000000..18003d5
--- /dev/null
@@ -0,0 +1,241 @@
+#include "XABContactMenu.h"
+#include "../frmMain.h"
+#include "../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){
+
+       MenuType = MenuTypeIn;
+
+       // Setup the menu items.
+       
+       AppendMenuItem(wxT("opencontact"), _("Open Contact..."), _(""), ID_CONTACTMENU_OPEN, wxITEM_NORMAL);
+       AppendMenuItem(wxT("sep1"), _(""), _(""), wxID_ANY, wxITEM_SEPARATOR);
+       
+       if (MenuType == XABCONTACTMENU_MAIN){
+       
+               // Setup up the add contact option if in the main window.
+
+               AppendMenuItem(wxT("newcontact"), _("New Contact..."), _(""), ID_CONTACTMENU_NEW, wxITEM_NORMAL);
+       
+       }
+       
+       AppendMenuItem(wxT("editcontact"), _("Edit Contact..."), _(""), ID_CONTACTMENU_EDIT, wxITEM_NORMAL);
+
+       if (MenuType == XABCONTACTMENU_SEARCH){
+       
+               // Setup up the reveal contact option if in the search window.
+       
+               AppendMenuItem(wxT("revealcontact"), _("Reveal Contact..."), _(""), ID_CONTACTMENU_REVEAL, wxITEM_NORMAL);
+       
+       }
+       
+       if (MenuType == XABCONTACTMENU_MAIN){
+       
+               // 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("refreshab"), _("Refresh Address Book"), _(""), ID_CONTACTMENU_REFRESHAB, wxITEM_NORMAL);
+       
+       }
+
+}
+
+XABContactMenu::~XABContactMenu(){
+
+       // Delete the menu items.
+       
+       for (std::map<std::string, wxMenuItem*>::iterator MenuItemIter = MenuItems.begin(); 
+               MenuItemIter != MenuItems.end(); ++MenuItemIter){
+       
+               // Delete the wxMenuItem object.
+               
+               this->Disconnect(MenuItemIter->second->GetId(), wxEVT_COMMAND_MENU_SELECTED, 
+                       wxCommandEventHandler(XABContactMenu::ProcessMenuItemClick) );
+               delete(MenuItemIter->second);
+               MenuItemIter->second = NULL;
+       
+       }
+       
+       MenuItems.clear();
+       
+}
+
+void XABContactMenu::AppendMenuItem(wxString ObjectName, 
+       wxString MenuName, 
+       wxString MenuDescription,
+       int ItemID,
+       wxItemKind ItemType){
+       
+       wxMenuItem *menuitem = new wxMenuItem(
+               NULL,
+               ItemID,
+               MenuName,
+               MenuDescription,
+               ItemType,
+               NULL
+       );
+       
+       this->Connect(menuitem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(XABContactMenu::ProcessMenuItemClick));
+       this->Append(menuitem);
+       MenuItems.insert(std::make_pair(ObjectName.ToStdString(), menuitem));
+
+}
+
+void XABContactMenu::SetupPointers(wxWindow* WindowPtrIn,
+       wxListCtrl* ContactListCtrlIn){
+
+       WindowPtr = WindowPtrIn;
+       ContactListCtrl = ContactListCtrlIn;
+
+}
+
+void XABContactMenu::SetupPointers(wxWindow* WindowPtrIn,
+       wxListCtrl* ContactListCtrlIn, 
+       bool EnableAccountSettingsIn){
+
+       WindowPtr = WindowPtrIn;
+       ContactListCtrl = ContactListCtrlIn;
+       EnableAccountSettings = EnableAccountSettingsIn;
+
+}
+
+wxMenu* XABContactMenu::MenuPointer(){
+
+       // Check for the following before passing the pointer:
+       // If an account has been selected.
+       // - Disable Refresh Address Book if not.
+       // If one or more contacts have been selected.
+       // - Disable New, Edit, Delete and Reveal contact as needed.
+
+       bool ContactSelected = FALSE;
+       long ItemIndex = -1;
+       int ContactCount = 0;
+       
+       for (;;){
+        
+               ItemIndex = ContactListCtrl->GetNextItem(ItemIndex,
+                                               wxLIST_NEXT_ALL,
+                                               wxLIST_STATE_SELECTED);
+        
+               if (ItemIndex == -1){
+            
+                   break;
+            
+               }
+        
+               ContactSelected = TRUE;
+               break;
+        
+       }
+
+       if (MenuType == XABCONTACTMENU_MAIN){
+       
+               std::map<std::string, wxMenuItem*>::iterator MenuItemIter = MenuItems.find("refreshab");
+               
+               if (EnableAccountSettings == FALSE){
+                       MenuItemIter->second->Enable(FALSE);
+                       MenuItemIter = MenuItems.find("newcontact");
+                       MenuItemIter->second->Enable(FALSE);
+               }
+               
+               MenuItemIter = MenuItems.find("opencontact");
+               MenuItemIter->second->Enable(ContactSelected);
+               MenuItemIter = MenuItems.find("editcontact");
+               MenuItemIter->second->Enable(ContactSelected);
+               MenuItemIter = MenuItems.find("deletecontact");
+               MenuItemIter->second->Enable(ContactSelected);
+       
+       } else if (MenuType == XABCONTACTMENU_SEARCH){
+       
+               std::map<std::string, wxMenuItem*>::iterator MenuItemIter = MenuItems.find("opencontact");
+               MenuItemIter->second->Enable(ContactSelected);
+               MenuItemIter = MenuItems.find("editcontact");
+               MenuItemIter->second->Enable(ContactSelected);
+               MenuItemIter = MenuItems.find("revealcontact");
+               MenuItemIter->second->Enable(ContactSelected);
+       
+       }
+
+       return this;
+
+}
+
+void XABContactMenu::ProcessMenuItemClick( wxCommandEvent& event){
+
+       int ItemID = event.GetId();
+       
+       if (MenuType == XABCONTACTMENU_MAIN){
+       
+               switch (ItemID){
+               
+                       case ID_CONTACTMENU_OPEN:
+                               {
+                                       wxCommandEvent rcevent(CE_OPENCONTACTLIST);
+                                       wxPostEvent(WindowPtr, rcevent);
+                               }
+                               break;
+                       case ID_CONTACTMENU_NEW:
+                               {
+                                       wxCommandEvent rcevent(CE_NEWCONTACT);
+                                       wxPostEvent(WindowPtr, rcevent);
+                               }
+                               break;
+                       case ID_CONTACTMENU_EDIT:
+                               {
+                                       wxCommandEvent rcevent(CE_EDITCONTACT);
+                                       wxPostEvent(WindowPtr, rcevent);
+                               }
+                               break;
+                       case ID_CONTACTMENU_DELETE:
+                               {
+                                       wxCommandEvent rcevent(CE_DELETECONTACT);
+                                       wxPostEvent(WindowPtr, rcevent);
+                               }
+                               break;
+                       case ID_CONTACTMENU_REFRESHAB:
+                               {
+                                       wxCommandEvent rcevent(REFRESHADDRESSBOOK);
+                                       wxPostEvent(WindowPtr, rcevent);
+                               }
+                               break;
+                               
+               }
+               
+       } else if (MenuType == XABCONTACTMENU_SEARCH){
+       
+               switch (ItemID){
+               
+                       case ID_CONTACTMENU_OPEN:
+                               {
+                                       wxCommandEvent rcevent(SE_OPENCONTACT);
+                                       wxPostEvent(WindowPtr, rcevent);
+                               }
+                               break;
+                       case ID_CONTACTMENU_EDIT:
+                               {
+                                       wxCommandEvent rcevent(SE_EDITCONTACT);
+                                       wxPostEvent(WindowPtr, rcevent);
+                               }
+                               break;
+                       case ID_CONTACTMENU_REVEAL:
+                               {
+                                       wxCommandEvent rcevent(SE_REVEALCONTACT);
+                                       wxPostEvent(WindowPtr, rcevent);
+                               }
+                               break;
+                               
+               }
+       
+       }
+
+}
\ No newline at end of file
diff --git a/source/widgets/XABContactMenu.h b/source/widgets/XABContactMenu.h
new file mode 100644 (file)
index 0000000..d5b7b6a
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __WIDGETS_XABCONTACTMENU__
+#define __WIDGETS_XABCONTACTMENU__
+
+#include <map>
+#include <string>
+#include <wx/wx.h>
+#include <wx/listctrl.h>
+#include <wx/app.h>
+
+enum {
+       XABCONTACTMENU_MAIN,
+       XABCONTACTMENU_SEARCH
+};
+
+class XABContactMenuADT : public wxMenu
+{
+
+       private:
+               
+       protected:
+               virtual void ProcessMenuItemClick(wxCommandEvent& event) {event.Skip();};
+       public:
+               XABContactMenuADT(){};
+               ~XABContactMenuADT(){};
+
+};
+
+class XABContactMenu : public XABContactMenuADT
+{
+       private:
+               std::map<std::string, wxMenuItem*> MenuItems = {};
+               int MenuType = XABCONTACTMENU_MAIN;
+               wxListCtrl *ContactListCtrl = NULL;
+               wxWindow *WindowPtr = NULL;
+               bool EnableAccountSettings = FALSE;
+               void AppendMenuItem(wxString ObjectName,
+                       wxString MenuName, 
+                       wxString MenuDescription,
+                       int ItemID,
+                       wxItemKind ItemType);
+       protected:
+               void ProcessMenuItemClick(wxCommandEvent& event);
+       public:
+               XABContactMenu(int MenuType);
+               ~XABContactMenu();
+               void SetupPointers(wxWindow* WindowPtrIn,
+                       wxListCtrl* ContactListCtrlIn);
+               void SetupPointers(wxWindow* WindowPtrIn,
+                       wxListCtrl* ContactListCtrlIn, 
+                       bool EnableAccountSettingsIn);
+               wxMenu* MenuPointer();
+               
+};
+
+#endif
\ No newline at end of file
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