Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
73735458112a662aa841887d99eda3e3c3a82f86
[xestiacalendar/.git] / source / widgets / XCEventMenu.cpp
1 // XCCalendarMenu.cpp - XCCalendarMenu widget
2 //
3 // (c) 2012-2017 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar. Original code from Xestia Address Book.
6 //
7 // Xestia Calendar is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Calendar is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "XCEventMenu.h"
21 XCEventMenu::XCEventMenu(){
22         
23         // Setup the menu items.
24         
25         AppendMenuItem(wxT("editevent"), _("Edit Event"), wxT(""), ID_EVENTMENU_EDIT, wxITEM_NORMAL);
26         AppendMenuItem(wxT("deleteevent"), _("Delete Event"), wxT(""), ID_EVENTMENU_DELETE, wxITEM_NORMAL);
28 }
30 XCEventMenu::~XCEventMenu(){
32         // Destory the XCEventMenu object.
33         
34         // Delete the menu items.
35         
36         for (std::map<std::string, wxMenuItem*>::iterator menuItemIter = menuItems.begin(); 
37                 menuItemIter != menuItems.end(); ++menuItemIter){
38         
39                 // Delete the wxMenuItem object.
40                 
41                 this->Disconnect(menuItemIter->second->GetId(), wxEVT_COMMAND_MENU_SELECTED, 
42                         wxCommandEventHandler(XCEventMenu::ProcessMenuItemClick) );
43                 delete(menuItemIter->second);
44                 menuItemIter->second = NULL;
45         
46         }
47         
48         menuItems.clear();
49         
50 }
52 void XCEventMenu::AppendMenuItem(wxString objectName, 
53         wxString menuName, 
54         wxString menuDescription,
55         XCEventMenuID itemID,
56         wxItemKind itemType){
57         
58         if (itemType == wxITEM_SEPARATOR){
59                 this->AppendSeparator();
60                 return;
61         }
62         
63         // Append a menu item to the XCEventMenu control.
65         wxMenuItem *menuitem = this->Append(itemID, menuName, menuDescription);
66         this->Connect(menuitem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(XCEventMenu::ProcessMenuItemClick));
67         menuItems.insert(std::make_pair(objectName.ToStdString(), menuitem));
69 }
71 wxMenu* XCEventMenu::MenuPointer(){
73         return this;
75 }
77 void XCEventMenu::ProcessMenuItemClick( wxCommandEvent& event){
79         // Process an action when a menu item in the XCEventMenu
80         // control is selected.
81         
82         int itemID = event.GetId();
83         
84         switch (itemID){
85                 
86                 case ID_EVENTMENU_EDIT:
87                         {
88                                 wxCommandEvent editEntry(XCMAIN_EDITEVENT);
89                                 editEntry.SetId(ID_EDITEVENT);
90                                 editEntry.SetInt(eventID);
91                                 wxPostEvent(WindowPtr, editEntry);
92                         }
93                         break;
94                 case ID_EVENTMENU_DELETE:
95                         {
96                                 EventProperties *eventInfo = new EventProperties;
98                                 eventInfo->calendarID = calendarID;
99                                 eventInfo->eventID = eventID;
100                                 
101                                 wxCommandEvent deleteEvent(XCMAIN_DELETEEVENT);
102                                 deleteEvent.SetId(ID_DELETEEVENT);
103                                 deleteEvent.SetClientData(eventInfo);
104                                 wxPostEvent(WindowPtr, deleteEvent);
105                         }
106                         break;
107                         
108         }
112 void XCEventMenu::SetCalendarID(int calendarID){
113         
114         this->calendarID = calendarID;
115         
118 void XCEventMenu::SetEventID(int eventID){
119         
120         this->eventID = eventID;
121         
124 void XCEventMenu::SetWindowPointer(wxWindow *windowPointer){
125         
126         windowPtr = windowPointer;
127         
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