--- /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 "XCEventMenu.h"
+
+XCEventMenu::XCEventMenu(){
+
+ // Setup the menu items.
+
+ AppendMenuItem(wxT("editevent"), _("Edit Event"), wxT(""), ID_EVENTMENU_EDIT, wxITEM_NORMAL);
+ AppendMenuItem(wxT("deleteevent"), _("Delete Event"), wxT(""), ID_EVENTMENU_DELETE, wxITEM_NORMAL);
+
+}
+
+XCEventMenu::~XCEventMenu(){
+
+ // Destory the XCEventMenu 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(XCEventMenu::ProcessMenuItemClick) );
+ delete(MenuItemIter->second);
+ MenuItemIter->second = NULL;
+
+ }
+
+ MenuItems.clear();
+
+}
+
+void XCEventMenu::AppendMenuItem(wxString ObjectName,
+ wxString MenuName,
+ wxString MenuDescription,
+ XCEventMenuID ItemID,
+ wxItemKind ItemType){
+
+ if (ItemType == wxITEM_SEPARATOR){
+ this->AppendSeparator();
+ return;
+ }
+
+ // Append a menu item to the XCEventMenu control.
+
+ wxMenuItem *menuitem = this->Append(ItemID, MenuName, MenuDescription);
+ this->Connect(menuitem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(XCEventMenu::ProcessMenuItemClick));
+ MenuItems.insert(std::make_pair(ObjectName.ToStdString(), menuitem));
+
+}
+
+wxMenu* XCEventMenu::MenuPointer(){
+
+ return this;
+
+}
+
+void XCEventMenu::ProcessMenuItemClick( wxCommandEvent& event){
+
+ // Process an action when a menu item in the XCEventMenu
+ // control is selected.
+
+ int ItemID = event.GetId();
+
+ switch (ItemID){
+
+ case ID_EVENTMENU_EDIT:
+ {
+ wxCommandEvent editEntry(XCMAIN_EDITEVENT);
+ editEntry.SetId(ID_EDITEVENT);
+ editEntry.SetInt(eventID);
+ wxPostEvent(WindowPtr, editEntry);
+ }
+ break;
+ case ID_EVENTMENU_DELETE:
+ {
+ EventProperties *eventInfo = new EventProperties;
+
+ eventInfo->calendarID = calendarID;
+ eventInfo->eventID = eventID;
+
+ wxCommandEvent deleteEvent(XCMAIN_DELETEEVENT);
+ deleteEvent.SetId(ID_DELETEEVENT);
+ deleteEvent.SetClientData(eventInfo);
+ wxPostEvent(WindowPtr, deleteEvent);
+ }
+ break;
+
+ }
+
+}
+
+void XCEventMenu::SetCalendarID(int calendarID){
+
+ this->calendarID = calendarID;
+
+}
+
+void XCEventMenu::SetEventID(int eventID){
+
+ this->eventID = eventID;
+
+}
+
+void XCEventMenu::SetWindowPointer(wxWindow *windowPointer){
+
+ WindowPtr = windowPointer;
+
+}
\ No newline at end of file
--- /dev/null
+// XCEventMenu.cpp - XCEventMenu 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_XCEVENTMENU__
+#define __WIDGETS_XCEVENTMENU__
+
+#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 XCEventMenuADT : public wxMenu
+{
+
+ private:
+
+ protected:
+ virtual void ProcessMenuItemClick(wxCommandEvent& event) {event.Skip();};
+ public:
+ XCEventMenuADT(){};
+ ~XCEventMenuADT(){};
+
+};
+
+class XCEventMenu : public XCEventMenuADT
+{
+ private:
+ std::map<std::string, wxMenuItem*> MenuItems = {};
+ wxWindow *WindowPtr = NULL;
+ bool EnableAccountSettings = FALSE;
+ bool SearchModeOnly = FALSE;
+ void AppendMenuItem(wxString ObjectName,
+ wxString MenuName,
+ wxString MenuDescription,
+ XCEventMenuID ItemID,
+ wxItemKind ItemType);
+ int calendarID = 0;
+ int eventID = 0;
+ protected:
+ void ProcessMenuItemClick(wxCommandEvent& event);
+ public:
+ XCEventMenu();
+ ~XCEventMenu();
+ wxMenu* MenuPointer();
+ void SetCalendarID(int calendarID);
+ void SetEventID(int eventID);
+ void SetWindowPointer(wxWindow *windowPointer);
+
+};
+
+#endif
\ No newline at end of file