--- /dev/null
+// 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
--- /dev/null
+// 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