Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
XCCalendarMenu: Added menu when right clicking calendars
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Wed, 11 Jan 2017 18:19:12 +0000 (18:19 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Wed, 11 Jan 2017 18:19:12 +0000 (18:19 +0000)
source/widgets/XCCalendarMenu.cpp [new file with mode: 0644]
source/widgets/XCCalendarMenu.h [new file with mode: 0644]

diff --git a/source/widgets/XCCalendarMenu.cpp b/source/widgets/XCCalendarMenu.cpp
new file mode 100644 (file)
index 0000000..7c2ec51
--- /dev/null
@@ -0,0 +1,136 @@
+// XCCalendarMenu.cpp - XCCalendarMenu widget
+//
+// (c) 2012-2017 Xestia Software Development.
+//
+// This file is part of Xestia Calendar. Original code from Xestia Address Book.
+//
+// Xestia Calendar is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Calendar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
+
+#include "XCCalendarMenu.h"
+
+XCCalendarMenu::XCCalendarMenu(){
+       
+       // Setup the menu items.
+       
+       AppendMenuItem(wxT("opencontact"), _("Edit Calendar"), wxT(""), ID_CALENDARMENU_EDIT, wxITEM_NORMAL);
+       AppendMenuItem(wxT("deletecontact"), _("Delete Calendar"), wxT(""), ID_CALENDARMENU_DELETE, wxITEM_NORMAL);
+
+}
+
+XCCalendarMenu::~XCCalendarMenu(){
+
+       // Destory the XCCalendarMenu object.
+       
+       // 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(XCCalendarMenu::ProcessMenuItemClick) );
+               delete(MenuItemIter->second);
+               MenuItemIter->second = NULL;
+       
+       }
+       
+       MenuItems.clear();
+       
+}
+
+void XCCalendarMenu::AppendMenuItem(wxString ObjectName, 
+       wxString MenuName, 
+       wxString MenuDescription,
+       XCCalendarMenuID ItemID,
+       wxItemKind ItemType){
+       
+       if (ItemType == wxITEM_SEPARATOR){
+               this->AppendSeparator();
+               return;
+       }
+       
+       // Append a menu item to the XCCalendarMenu control.
+
+       wxMenuItem *menuitem = this->Append(ItemID, MenuName, MenuDescription);
+       this->Connect(menuitem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(XCCalendarMenu::ProcessMenuItemClick));
+       MenuItems.insert(std::make_pair(ObjectName.ToStdString(), menuitem));
+
+}
+
+wxMenu* XCCalendarMenu::MenuPointer(){
+
+       return this;
+
+}
+
+void XCCalendarMenu::ProcessMenuItemClick( wxCommandEvent& event){
+
+       // Process an action when a menu item in the XCCalendarMenu
+       // control is selected.
+       
+       int ItemID = event.GetId();
+       
+       PopupPtr->Dismiss();
+       
+       switch (ItemID){
+               
+               case ID_CALENDARMENU_EDIT:
+                       {
+                               wxCommandEvent editCalendar(XCMAIN_EDITCALENDAR);
+                               editCalendar.SetId(ID_EDITCALENDAR);
+                               editCalendar.SetInt(calendarID);
+                               wxPostEvent(WindowPtr->GetParent()->GetParent()->GetParent()->GetParent(), editCalendar);
+                       }
+                       break;
+               case ID_CALENDARMENU_DELETE:
+                       {
+                               CalendarProperties *calendarInfo = new CalendarProperties;
+
+                               calendarInfo->calendarID = calendarID;
+                               calendarInfo->accountPreferencesID = accountPreferencesID;
+                               
+                               wxCommandEvent deleteCalendar(XCMAIN_DELETECALENDAR);
+                               deleteCalendar.SetId(ID_DELETECALENDAR);
+                               deleteCalendar.SetClientData(calendarInfo);
+                               wxPostEvent(WindowPtr->GetParent()->GetParent()->GetParent()->GetParent(), deleteCalendar);
+                       }
+                       break;
+                       
+       }
+
+}
+
+void XCCalendarMenu::SetCalendarID(int calendarID){
+       
+       this->calendarID = calendarID;
+       
+}
+
+void XCCalendarMenu::SetAccountPreferencesID(int accountPreferencesID){
+       
+       this->accountPreferencesID = accountPreferencesID;
+       
+}
+
+void XCCalendarMenu::SetWindowPointer(wxWindow *windowPointer){
+       
+       WindowPtr = windowPointer;
+       
+}
+
+void XCCalendarMenu::SetPopupPointer(wxPopupTransientWindow *popupPointer){
+       
+       PopupPtr = popupPointer;
+       
+}
\ No newline at end of file
diff --git a/source/widgets/XCCalendarMenu.h b/source/widgets/XCCalendarMenu.h
new file mode 100644 (file)
index 0000000..9a5bb2c
--- /dev/null
@@ -0,0 +1,74 @@
+// XCCalendarMenu.cpp - XCCalendarMenu widget header
+//
+// (c) 2012-2017 Xestia Software Development.
+//
+// This file is part of Xestia Calendar. Original code from Xestia Address Book.
+//
+// Xestia Calendar is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Calendar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
+
+#ifndef __WIDGETS_XCCALENDARMENU__
+#define __WIDGETS_XCCALENDARMENU__
+
+#include <map>
+#include <string>
+#include <wx/wx.h>
+#include <wx/listctrl.h>
+#include <wx/popupwin.h>
+#include <wx/app.h>
+
+#include "structs.h"
+#include "events.h"
+
+class XCCalendarMenuADT : public wxMenu
+{
+
+       private:
+               
+       protected:
+               virtual void ProcessMenuItemClick(wxCommandEvent& event) {event.Skip();};
+       public:
+               XCCalendarMenuADT(){};
+               ~XCCalendarMenuADT(){};
+
+};
+
+class XCCalendarMenu : public XCCalendarMenuADT
+{
+       private:
+               std::map<std::string, wxMenuItem*> MenuItems = {};
+               wxListCtrl *ContactListCtrl = NULL;
+               wxWindow *WindowPtr = NULL;
+               wxPopupTransientWindow *PopupPtr = NULL;
+               bool EnableAccountSettings = FALSE;
+               bool SearchModeOnly = FALSE;
+               void AppendMenuItem(wxString ObjectName,
+                       wxString MenuName, 
+                       wxString MenuDescription,
+                       XCCalendarMenuID ItemID,
+                       wxItemKind ItemType);
+               int calendarID = 0;
+               int accountPreferencesID = 0;
+       protected:
+               void ProcessMenuItemClick(wxCommandEvent& event);
+       public:
+               XCCalendarMenu();
+               ~XCCalendarMenu();
+               wxMenu* MenuPointer();
+               void SetCalendarID(int calendarID);
+               void SetAccountPreferencesID(int accountPreferencesID);
+               void SetWindowPointer(wxWindow *windowPointer);
+               void SetPopupPointer(wxPopupTransientWindow *popupPointer);
+       
+};
+
+#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