Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
random: Implemented Win32 version
[xestiacalendar/.git] / source / widgets / XCCalendarMenu.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 "XCCalendarMenu.h"
21 XCCalendarMenu::XCCalendarMenu(){
22         
23         // Setup the menu items.
24         
25         AppendMenuItem(wxT("opencontact"), _("Edit Calendar"), wxT(""), ID_CALENDARMENU_EDIT, wxITEM_NORMAL);
26         AppendMenuItem(wxT("deletecontact"), _("Delete Calendar"), wxT(""), ID_CALENDARMENU_DELETE, wxITEM_NORMAL);
28 }
30 XCCalendarMenu::~XCCalendarMenu(){
32         // Destory the XCCalendarMenu 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(XCCalendarMenu::ProcessMenuItemClick) );
43                 delete(menuItemIter->second);
44                 menuItemIter->second = NULL;
45         
46         }
47         
48         menuItems.clear();
49         
50 }
52 void XCCalendarMenu::AppendMenuItem(wxString objectName, 
53         wxString menuName, 
54         wxString menuDescription,
55         XCCalendarMenuID itemID,
56         wxItemKind itemType){
57         
58         if (itemType == wxITEM_SEPARATOR){
59                 this->AppendSeparator();
60                 return;
61         }
62         
63         // Append a menu item to the XCCalendarMenu control.
65         wxMenuItem *menuitem = this->Append(itemID, menuName, menuDescription);
66         this->Connect(menuitem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(XCCalendarMenu::ProcessMenuItemClick));
67         menuItems.insert(std::make_pair(objectName.ToStdString(), menuitem));
69 }
71 wxMenu* XCCalendarMenu::MenuPointer(){
73         return this;
75 }
77 void XCCalendarMenu::ProcessMenuItemClick( wxCommandEvent& event){
79         // Process an action when a menu item in the XCCalendarMenu
80         // control is selected.
81         
82         int itemID = event.GetId();
83         
84         popupPtr->Dismiss();
85         
86         switch (itemID){
87                 
88                 case ID_CALENDARMENU_EDIT:
89                         {
90                                 wxCommandEvent editCalendar(XCMAIN_EDITCALENDAR);
91                                 editCalendar.SetId(ID_EDITCALENDAR);
92                                 editCalendar.SetInt(calendarID);
93                                 wxPostEvent(windowPtr->GetParent()->GetParent()->GetParent()->GetParent(), editCalendar);
94                         }
95                         break;
96                 case ID_CALENDARMENU_DELETE:
97                         {
98                                 CalendarProperties *calendarInfo = new CalendarProperties;
100                                 calendarInfo->calendarID = calendarID;
101                                 calendarInfo->accountPreferencesID = accountPreferencesID;
102                                 
103                                 wxCommandEvent deleteCalendar(XCMAIN_DELETECALENDAR);
104                                 deleteCalendar.SetId(ID_DELETECALENDAR);
105                                 deleteCalendar.SetClientData(calendarInfo);
106                                 wxPostEvent(windowPtr->GetParent()->GetParent()->GetParent()->GetParent(), deleteCalendar);
107                         }
108                         break;
109                         
110         }
114 void XCCalendarMenu::SetCalendarID(int calendarID){
115         
116         this->calendarID = calendarID;
117         
120 void XCCalendarMenu::SetAccountPreferencesID(int accountPreferencesID){
121         
122         this->accountPreferencesID = accountPreferencesID;
123         
126 void XCCalendarMenu::SetWindowPointer(wxWindow *windowPointer){
127         
128         windowPtr = windowPointer;
129         
132 void XCCalendarMenu::SetPopupPointer(wxPopupTransientWindow *popupPointer){
133         
134         popupPtr = popupPointer;
135         
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