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

diff --git a/source/widgets/XCEventMenu.cpp b/source/widgets/XCEventMenu.cpp
new file mode 100644 (file)
index 0000000..c526987
--- /dev/null
@@ -0,0 +1,128 @@
+// 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
diff --git a/source/widgets/XCEventMenu.h b/source/widgets/XCEventMenu.h
new file mode 100644 (file)
index 0000000..b4411af
--- /dev/null
@@ -0,0 +1,71 @@
+// 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
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