Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
widgets: Cleanup objects in destructors and minor code cleanup
[xestiacalendar/.git] / source / widgets / XCCalendarDay.cpp
1 // XCCalendarDay.cpp - Xestia Calendar XCCalendarDay widget class.
2 //
3 // (c) 2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
7 // Xestia Address Book 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 Address Book 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 "XCCalendarDay.h"
21 using namespace std;
23 wxDEFINE_EVENT(XCCALENDARDAY_DESELECTOTHERENTRIES, wxCommandEvent);
24 wxDEFINE_EVENT(XCCALENDARDAY_DESELECTALLENTRIES, wxCommandEvent);
25 wxDEFINE_EVENT(XCCALENDARDAY_HIDEACCOUNTENTRIES, wxCommandEvent);
26 wxDEFINE_EVENT(XCCALENDARDAY_SHOWACCOUNTENTRIES, wxCommandEvent);
27 wxDEFINE_EVENT(XCCALENDARDAY_HIDECALENDARENTRIES, wxCommandEvent);
28 wxDEFINE_EVENT(XCCALENDARDAY_SHOWCALENDARENTRIES, wxCommandEvent);
29 wxDEFINE_EVENT(XCCALENDARDAY_DELETECALENDARENTRIES, wxCommandEvent);
30 wxDEFINE_EVENT(XCCALENDARDAY_DELETEENTRY, wxCommandEvent);
31 wxDEFINE_EVENT(XCCALENDARDAY_ADDENTRY, wxCommandEvent);
32 wxDEFINE_EVENT(XCCALENDARDAY_UPDATEENTRY, wxCommandEvent);
33 wxDEFINE_EVENT(XCCALENDARDAY_UPDATECALENDARCOLOUR, wxCommandEvent);
35 BEGIN_EVENT_TABLE(XCCalendarDay, wxPanel)
36 END_EVENT_TABLE()
38 XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size)
39         : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){
40         this->SetMinSize( wxSize( 100,100 ) );
41         
42         // Setup the top panel.
43                 
44         topPanel = new wxPanel(this, wxID_ANY, wxPoint(0,0), wxSize(50, 40), wxTAB_TRAVERSAL);
45         mainPanel = new wxPanel(this, wxID_ANY, wxPoint(0,0), wxSize(200, 200), wxTAB_TRAVERSAL);
46                 
47         // Setip the icons.
48                 
49         highPriorityIcon = new wxStaticBitmap(topPanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(32,32), 0);
50         alertIcon = new wxStaticBitmap(topPanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(32,32), 0);
51                 
52         wxMemoryInputStream alerticon(icons_alert32_png, sizeof(icons_alert32_png));
53         wxMemoryInputStream priorityicon(icons_priority32_png, sizeof(icons_priority32_png));
54         
55         wxImage icons_alert_png(alerticon, wxBITMAP_TYPE_PNG);
56         wxBitmap imgAlertIcon(icons_alert_png, -1);
58         wxImage icons_priority_png(priorityicon, wxBITMAP_TYPE_PNG);
59         wxBitmap imgPriorityIcon(icons_priority_png, -1);
60         
61         alertIcon->SetBitmap(imgAlertIcon);
62         highPriorityIcon->SetBitmap(imgPriorityIcon);
63         
64         numberText = new wxStaticText(topPanel, wxID_ANY, wxT("09"), wxDefaultPosition, wxDefaultSize, 0);
65         numberText->SetFont(wxFont(24, 70, 90, 92, false, wxEmptyString));
66         
67         topSectionSizer->Add(highPriorityIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
68         topSectionSizer->Add(alertIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
69         topSectionSizer->Add(0, 0, 1, wxEXPAND, 5);
70         topSectionSizer->Add(numberText, 0, wxALL|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5);
72         // Setup the scrollable section.
73         
74         eventListFrame = new wxScrolledWindow(mainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
75         
76         Colour eventColour;
77         eventColour.red = 40; eventColour.green = 80; eventColour.blue = 80;
78         
79         eventListFrame->SetSizer(eventListFrameSizer);
81         eventListFrame->SetScrollRate(0,1);
82         eventListFrameSizer->Fit(eventListFrame);
83         eventListFrameSizer->Layout();
85         // Setup the scroll window.
86         
87         mainSectionSizer->Add(eventListFrame, 1, wxGROW | wxALL, 5);
88         
89         topPanel->SetSizer(topSectionSizer);
90         mainPanel->SetSizer(mainSectionSizer);
91         
92         windowSizer->Add(topPanel, 1, wxEXPAND, 0);
93         windowSizer->Add(mainPanel, 1, wxEXPAND, 0);
95         this->SetSizer(windowSizer);
96         this->SetSize(size);
97         this->Layout();
98         this->Centre(wxBOTH);
99         
100         UpdateTopIcons();
101         
102         // Bind events to the control.
103         
104         Bind(XCCALENDARDAY_DESELECTOTHERENTRIES, &XCCalendarDay::DeselectOthersEvent, this, ID_DESELECTOTHERENTRIES);
105         Bind(XCCALENDARDAY_DESELECTALLENTRIES, &XCCalendarDay::DeselectAllEvent, this, ID_DESELECTALLITEMS);
106         Bind(XCCALENDARDAY_HIDEACCOUNTENTRIES, &XCCalendarDay::HideAccountEntries, this, ID_HIDEENTRIES);
107         Bind(XCCALENDARDAY_SHOWACCOUNTENTRIES, &XCCalendarDay::ShowAccountEntries, this, ID_SHOWENTRIES);
108         Bind(XCCALENDARDAY_HIDECALENDARENTRIES, &XCCalendarDay::HideCalendarEntries, this, ID_HIDECALENDARENTRIES);
109         Bind(XCCALENDARDAY_SHOWCALENDARENTRIES, &XCCalendarDay::ShowCalendarEntries, this, ID_SHOWCALENDARENTRIES);
110         Bind(XCCALENDARDAY_DELETECALENDARENTRIES, &XCCalendarDay::DeleteCalendarEntries, this, ID_DELETECALENDARENTRIES);
111         Bind(XCCALENDARDAY_DELETEENTRY, &XCCalendarDay::DeleteCalendarEntry, this, ID_DELETEENTRY);
112         Bind(XCCALENDARDAY_ADDENTRY, &XCCalendarDay::AddCalendarEntry, this, ID_ADDENTRY);
113         Bind(XCCALENDARDAY_UPDATEENTRY, &XCCalendarDay::UpdateCalendarEntry, this, ID_UPDATEENTRY);
114         Bind(XCCALENDARDAY_UPDATECALENDARCOLOUR, &XCCalendarDay::UpdateCalendarColour, this, ID_UPDATECOLOUR);
117 XCCalendarDay::~XCCalendarDay(){
118         
119         // Destory the controls from the widget.
120         
121         Unbind(XCCALENDARDAY_DESELECTOTHERENTRIES, &XCCalendarDay::DeselectOthersEvent, this, ID_DESELECTOTHERENTRIES);
122         Unbind(XCCALENDARDAY_DESELECTALLENTRIES, &XCCalendarDay::DeselectAllEvent, this, ID_DESELECTALLITEMS);
123         Unbind(XCCALENDARDAY_HIDEACCOUNTENTRIES, &XCCalendarDay::HideAccountEntries, this, ID_HIDEENTRIES);
124         Unbind(XCCALENDARDAY_SHOWACCOUNTENTRIES, &XCCalendarDay::ShowAccountEntries, this, ID_SHOWENTRIES);
125         Unbind(XCCALENDARDAY_HIDECALENDARENTRIES, &XCCalendarDay::HideCalendarEntries, this, ID_HIDECALENDARENTRIES);
126         Unbind(XCCALENDARDAY_SHOWCALENDARENTRIES, &XCCalendarDay::ShowCalendarEntries, this, ID_SHOWCALENDARENTRIES);
127         Unbind(XCCALENDARDAY_DELETECALENDARENTRIES, &XCCalendarDay::DeleteCalendarEntries, this, ID_DELETECALENDARENTRIES);
128         Unbind(XCCALENDARDAY_DELETEENTRY, &XCCalendarDay::DeleteCalendarEntry, this, ID_DELETEENTRY);
129         Unbind(XCCALENDARDAY_ADDENTRY, &XCCalendarDay::AddCalendarEntry, this, ID_ADDENTRY);
130         Unbind(XCCALENDARDAY_UPDATEENTRY, &XCCalendarDay::UpdateCalendarEntry, this, ID_UPDATEENTRY);
131         Unbind(XCCALENDARDAY_UPDATECALENDARCOLOUR, &XCCalendarDay::UpdateCalendarColour, this, ID_UPDATECOLOUR);
132         
133         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
134                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
135                         
136                 delete((*calendarEntryIter));
137                         
138         }
140         eventListFrameSizer->Clear();
141         
142         eventListFrame->SetSizer(nullptr, true);
143         
144         mainSectionSizer->Clear();
145         topSectionSizer->Clear();
146         windowSizer->Clear();
148         delete alertIcon;
149         alertIcon = nullptr;
150         
151         delete highPriorityIcon;
152         highPriorityIcon = nullptr;
153         
154         delete eventListFrame;
155         eventListFrame = nullptr;
156         
157         delete numberText;
158         numberText = nullptr;
160         delete topPanel;
161         topPanel = nullptr;
163         delete mainPanel;
164         mainPanel = nullptr;
165         
166         calendarEntryList.clear();
167         
168         this->SetSizer(nullptr, true);
169         
170         monthViewPointer = nullptr;
171         dataStorage = nullptr;
172         
175 void XCCalendarDay::UpdateTopIcons(){
176         
177         bool alarmFound = false;
178         bool highPriorityFound = false;
179         
180         for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
181                 entryIter != calendarEntryList.end(); entryIter++){
183                 if ((*entryIter)->GetDisplayAlarm() == true){
184                         
185                         alarmFound = true;
186                         
187                 }
189                 if ((*entryIter)->GetDisplayHighPriority() == true){
190                         
191                         highPriorityFound = true;
192                         
193                 }
194                 
195                 if (alarmFound == true && highPriorityFound == true){
196                         
197                         break;
198                         
199                 }
200                 
201         }
202         
203         alertIcon->Show(alarmFound);
204         highPriorityIcon->Show(highPriorityFound);
205         
208 void XCCalendarDay::ResizeFrameEvent(wxSizeEvent &sizeEvent)
211         // TODO: Check if window size is less than 120 pixels and if it is,
212         // switch to the small block mode.
213         
214         // Refresh the window.
215         
216         this->Refresh();
217         topPanel->Refresh();
218         mainPanel->Refresh();
219         topSectionSizer->Layout();
220         mainSectionSizer->Layout();
221         windowSizer->Layout();
222         
225 void XCCalendarDay::DeselectOthersEvent(wxCommandEvent &deselectEvent)
227         
228         int selectedEntryID = deselectEvent.GetInt();
230         wxCommandEvent deselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
231         deselectEntryEvent.SetId(ID_ENTRYDESELECT);
232         
233         for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
234                 entryIter != calendarEntryList.end(); entryIter++){
235                         
236                 if ((*entryIter)->GetID() != selectedEntryID){
237                         
238                         wxPostEvent((*entryIter), deselectEntryEvent);
239                         
240                 }
241                 
242         }
243         
244         // Send event notification to deselect the other calendar entries.
245         
246         if (this->monthViewPointer != nullptr){
247                 
248                 wxCommandEvent deselectMonthEvent(XCCALENDARMONTH_DESELECTOTHERENTRIES);
249                 deselectMonthEvent.SetClientData(this);
250                 deselectMonthEvent.SetId(ID_MONTHVIEWCLEARSELECTION);
251                 wxPostEvent(this->monthViewPointer, deselectMonthEvent);
252                 
253         }
254         
257 void XCCalendarDay::DeselectAllEvent(wxCommandEvent &deselectEvent)
259         
260         int selectedEntryID = deselectEvent.GetInt();
261         
262         wxCommandEvent deselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
263         deselectEntryEvent.SetId(ID_ENTRYDESELECT);
264         
265         for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
266                 entryIter != calendarEntryList.end(); entryIter++){
268                 wxPostEvent((*entryIter), deselectEntryEvent);
269                         
270         }
271         
274 void XCCalendarDay::SetupControl(int setupDay, int setupMonth, int setupYear, bool setupIsInMonth, XCCalendarMonthView *monthViewPointer, CalendarDataStorage *dataStorage, vector<int> *hideAccounts, vector<int> *hideCalendars)
276         
277         this->dataStorage = dataStorage;
278         
279         // Set the day
280         
281         numberText->SetLabel(wxString::Format("%02i", setupDay));
282         calendarDay = setupDay;
283         
284         // Set the month
286         calendarMonth = setupMonth;
287         
288         // Set the year.
290         calendarYear = setupYear;
291         
292         // Setup the Is In Month value.
293         
294         isInMonth = setupIsInMonth;
295         if (isInMonth)
296         {
297                 topPanel->SetBackgroundColour(wxColor(255,255,255));
298                 mainPanel->SetBackgroundColour(wxColor(225,225,225));
299                 eventListFrame->SetBackgroundColour(wxColor(225,225,225));
300         }
301         else
302         {
303                 topPanel->SetBackgroundColour(wxColor(185,185,185));
304                 mainPanel->SetBackgroundColour(wxColor(155,155,155));
305                 eventListFrame->SetBackgroundColour(wxColor(155,155,155));
306         }
307         
308         // Setup the month view pointer.
309         
310         this->monthViewPointer = monthViewPointer;
311         
312         // Setup the calendar items.
313         
314         CDSEntryList calendarItems = dataStorage->GetEventListByDate(setupYear, setupMonth, setupDay);
315         
316         for (int entrySeek = 0; entrySeek < calendarItems.entryList.size(); entrySeek++){
317                 
318                 // Get the information about the calendar entry.
319                 
320                 CDSGetCalendarEntryInfo newEntryInfo = dataStorage->GetEvent(calendarItems.entryList[entrySeek]);
321                 CDSGetCalendarInfo newEntryCalendarInfo = dataStorage->GetCalendar(newEntryInfo.calendarID);
322                 
323                 // Setup the calendar entry.
324                 
325                 XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(eventListFrame, newEntryInfo.entryName, wxDefaultPosition, wxDefaultSize, calendarItems.entryList[entrySeek]);
326                 
327                 newEntry->SetColour(&newEntryCalendarInfo.calendarColour);
328                 newEntry->SetTime(newEntryInfo.entryStartHour, newEntryInfo.entryStartMinute, newEntryInfo.entryStartSecond);
329                 newEntry->SetEntryIDs(newEntryCalendarInfo.accountID, newEntryInfo.calendarID, newEntryInfo.calendarEntryID);           
330                 
331                 eventListFrameSizer->Add(newEntry, 0, wxEXPAND, 5);
332                 wxSizerItem *afterSpacer = eventListFrameSizer->Add(0, 5, 0, 0, 5);
333                 
334                 newEntry->SetAfterSpacer(afterSpacer);
335                 
336                 // Go through the list of calendar entries to hide by account.
337                 
338                 for (vector<int>::iterator hideAccountsItem = hideAccounts->begin();
339                         hideAccountsItem != hideAccounts->end(); hideAccountsItem++){
340                                 
341                         if (*hideAccountsItem == newEntryCalendarInfo.accountID){
342                                 newEntry->Show(false);
343                                 newEntry->GetAfterSpacer()->Show(false);
344                         }
345                                 
346                 }
347                 
348                 // Go through the list of calendar entries to hide by calendar.
349                 
350                 for (vector<int>::iterator hideCalendarsItem = hideCalendars->begin();
351                         hideCalendarsItem != hideCalendars->end(); hideCalendarsItem++){
352                                 
353                         if (*hideCalendarsItem == newEntryInfo.calendarID){
354                                 newEntry->Show(false);
355                                 newEntry->GetAfterSpacer()->Show(false);
356                         }
357                                 
358                 }
359                 
360                 calendarEntryList.push_back(newEntry);
361         }
362         
365 void XCCalendarDay::HideAccountEntries(wxCommandEvent &accountData){
366         
367         // Go through each of the controls and hide the controls (and spacing) that
368         // have the matched account IDs.
369         
370         int sizerPosition = 0;
371         
372         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
373                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
374                 
375                 (*calendarEntryIter)->SetShowAccountStatus(false);
376                         
377                 if ((*calendarEntryIter)->GetAccountID() == accountData.GetInt()){
378                         
379                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
380                         (*calendarEntryIter)->Show(false);
381                         
382                         // Get the spacing and hide it as well.
383                         
384                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
385                         afterSpacer->Show(false);
386                         
387                 }
388                         
389         }
390         
391         this->Refresh();
392         
395 void XCCalendarDay::ShowAccountEntries(wxCommandEvent &accountData){
396         
397         // Go through each of the controls and hide the controls (and spacing) that
398         // have the matched account IDs.
399         
400         int sizerPosition = 0;
401         
402         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
403                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
404                 
405                 (*calendarEntryIter)->SetShowAccountStatus(true);
406                         
407                 if ((*calendarEntryIter)->GetShowCalendarStatus() == false){
408                         continue;
409                 }
410                         
411                 if ((*calendarEntryIter)->GetAccountID() == accountData.GetInt()){
412                         
413                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
414                         (*calendarEntryIter)->Show(true);
415                         
416                         // Get the spacing and hide it as well.
417                         
418                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
419                         afterSpacer->Show(true);
420                         
421                 }
422                 
423         }
424         
425         this->Refresh();
426         
429 void XCCalendarDay::HideCalendarEntries(wxCommandEvent &calendarData){
430         
431         // Go through each of the controls and hide the controls (and spacing) that
432         // have the matched account IDs.
433         
434         int sizerPosition = 0;
435         
436         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
437                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
438                         
439                 if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
440                         
441                         (*calendarEntryIter)->SetShowCalendarStatus(false);
442                         
443                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
444                         (*calendarEntryIter)->Show(false);
445                         
446                         // Get the spacing and hide it as well.
447                         
448                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
449                         afterSpacer->Show(false);
450                         
451                 }
452                         
453         }
454         
455         this->Refresh();
456         
459 void XCCalendarDay::ShowCalendarEntries(wxCommandEvent &calendarData){
460         
461         // Go through each of the controls and hide the controls (and spacing) that
462         // have the matched account IDs.
463         
464         int sizerPosition = 0;
465         
466         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
467                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
468                         
469                 if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
470                         
471                         (*calendarEntryIter)->SetShowCalendarStatus(true);
472                         
473                         if ((*calendarEntryIter)->GetShowAccountStatus() == false){
474                                 
475                                 // Don't show the calendar entry because the account status
476                                 // is set to hidden. Continue to the next one.
477                                 
478                                 continue;
479                                 
480                         }
481                         
482                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
483                         (*calendarEntryIter)->Show(true);
484                         
485                         // Get the spacing and hide it as well.
486                         
487                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
488                         afterSpacer->Show(true);
489                         
490                 }
491                         
492         }
493         
494         this->Refresh();
495         
498 void XCCalendarDay::DeleteCalendarEntries(wxCommandEvent &calendarData){
499         
500         vector<vector<XCCalendarDayEntry*>::iterator> deleteEntriesList;
501         
502         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
503                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
504         
505                 if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
506                         
507                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
508                         (*calendarEntryIter)->Show(false);
509                         
510                         // Get the spacing and hide it as well.
511                         
512                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
513                         afterSpacer->Show(false);
514                         
515                         delete afterSpacer;
516                         afterSpacer = nullptr;
517         
518                         delete (*calendarEntryIter);
519                         deleteEntriesList.push_back(calendarEntryIter);
520                         
521                 }               
522                         
523         }
524         
525         this->Refresh();
526         mainPanel->Layout();
527         eventListFrame->Layout();
528         eventListFrameSizer->Layout();
529         
530         for (auto deleteIter : deleteEntriesList){
531                 calendarEntryList.erase(deleteIter);
532         }
533         
536 void XCCalendarDay::DeleteCalendarEntry(wxCommandEvent &eventData){
537         
538         vector<vector<XCCalendarDayEntry*>::iterator> deleteEntriesList;
539         
540         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
541                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
542         
543                 if ((*calendarEntryIter)->GetEventID() == eventData.GetInt()){
544                         
545                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
546                         (*calendarEntryIter)->Show(false);
547                         
548                         // Get the spacing and hide it as well.
549                         
550                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
551                         afterSpacer->Show(false);
552                         
553                         delete (*calendarEntryIter);
554                         deleteEntriesList.push_back(calendarEntryIter);                 
555                         
556                 }               
557                         
558         }
559         
560         for (auto deleteIter : deleteEntriesList){
561                 calendarEntryList.erase(deleteIter);
562         }
563         
564         this->Refresh();
565         this->Layout();
566         eventListFrame->Layout();
567         eventListFrameSizer->Layout();
568         
571 void XCCalendarDay::AddCalendarEntry(wxCommandEvent &eventData){
572         
573         EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
574         
575         // TODO: Fix conversion from string to wxString
576         XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(eventListFrame, wxString(eventInfo->eventName.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, eventInfo->eventID);
577                 
578         CDSGetCalendarInfo calendarInfo = dataStorage->GetCalendar(eventInfo->calendarID);
579         
580         newEntry->SetColour(&calendarInfo.calendarColour);
581         newEntry->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
582         newEntry->SetEntryIDs(calendarInfo.accountID, eventInfo->calendarID, eventInfo->eventID);               
583                 
584         eventListFrameSizer->Add(newEntry, 0, wxEXPAND, 5);
585         wxSizerItem *afterSpacer = eventListFrameSizer->Add(0, 5, 0, 0, 5);
586                 
587         newEntry->SetAfterSpacer(afterSpacer);
588         
589         // Go through the list of calendar entries to hide by account.
590                 
591         for (vector<int>::iterator hideAccountsItem = eventInfo->hideAccountsList.begin();
592                 hideAccountsItem != eventInfo->hideAccountsList.end(); hideAccountsItem++){
593                                 
594                 if (*hideAccountsItem = calendarInfo.accountID){
595                         newEntry->Show(false);
596                         newEntry->GetAfterSpacer()->Show(false);
597                 }
598                                 
599         }
600                 
601         // Go through the list of calendar entries to hide by calendar.
602                 
603         for (vector<int>::iterator hideCalendarsItem = eventInfo->hideCalendarsList.begin();
604                 hideCalendarsItem != eventInfo->hideCalendarsList.end(); hideCalendarsItem++){
605                                 
606                 if (*hideCalendarsItem == eventInfo->calendarID){
607                         newEntry->Show(false);
608                         newEntry->GetAfterSpacer()->Show(false);
609                 }                       
610                                 
611         }
612                 
613         calendarEntryList.push_back(newEntry);
614         
615         this->Refresh();
616         mainPanel->Layout();
617         eventListFrame->Layout();
618         eventListFrameSizer->Layout();
619         
622 void XCCalendarDay::UpdateCalendarEntry(wxCommandEvent &eventData){
623         
624         // Go thorugh each of the entries in the day and
625         // then update it.
626         
627         EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
628         
629         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
630                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
631                 
632                 if ((*calendarEntryIter)->GetEventID() == eventInfo->eventID){
633                         
634                         (*calendarEntryIter)->SetEventName(eventInfo->eventName);
635                         (*calendarEntryIter)->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
636                         
637                 }
638                         
639         }
640         
641         delete eventInfo;
642         eventInfo = nullptr;
643         
646 void XCCalendarDay::UpdateCalendarColour(wxCommandEvent &colourData){
647         
648         // Go thorugh each of the entries in the day and
649         // then update it.
650         
651         ColourUpdateProperties *colourInfo = (ColourUpdateProperties*)colourData.GetClientData();
652         
653         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
654                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
655                 
656                 if ((*calendarEntryIter)->GetCalendarID() == colourInfo->calendarID){
657                         
658                         (*calendarEntryIter)->SetColour(&colourInfo->newColour);
659                         
660                 }
661                         
662         }
663         
666 int XCCalendarDay::GetCalendarDay(){
667         
668         return calendarDay;
669         
672 int XCCalendarDay::GetCalendarMonth(){
673         
674         return calendarMonth;
675         
678 int XCCalendarDay::GetCalendarYear(){
679         
680         return calendarYear;
681         
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