Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
64b58e7a3f887ab66095af56d8269b438e88231a
[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 EVT_PAINT(XCCalendarDay::PaintFrameEvent)
37 EVT_SIZE(XCCalendarDay::ResizeFrameEvent)
38 END_EVENT_TABLE()
40 XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size)
41         : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){
42         this->SetMinSize( wxSize( 100,100 ) );
43         
44         // Setip the icons.
45                 
46         wxMemoryInputStream alerticon(icons_alert32_png, sizeof(icons_alert32_png));
47         wxMemoryInputStream priorityicon(icons_priority32_png, sizeof(icons_priority32_png));
48         
49         wxImage icons_alert_png(alerticon, wxBITMAP_TYPE_PNG);
50         wxBitmap imgAlertIcon(icons_alert_png, -1);
52         wxImage icons_priority_png(priorityicon, wxBITMAP_TYPE_PNG);
53         wxBitmap imgPriorityIcon(icons_priority_png, -1);
54         
55         alertIcon->SetBitmap(imgAlertIcon);
56         highPriorityIcon->SetBitmap(imgPriorityIcon);
57         
58         windowSizer->AddGrowableCol(0);
59         windowSizer->AddGrowableRow(1);
60         windowSizer->SetFlexibleDirection( wxBOTH );
61         windowSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
62         
63         numberText = new wxStaticText(this, wxID_ANY, wxT("09"), wxDefaultPosition, wxDefaultSize, 0);
64         numberText->SetFont(wxFont(24, 70, 90, 92, false, wxEmptyString));
65         
66         topSectionSizer->Add(highPriorityIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
67         topSectionSizer->Add(alertIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
68         topSectionSizer->Add(0, 0, 1, wxEXPAND, 5);
69         topSectionSizer->Add(numberText, 0, wxALL|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5);
71         // Setup the scrollable section.
72         
73         Colour eventColour;
74         eventColour.red = 40; eventColour.green = 80; eventColour.blue = 80;
75         
76         eventListFrame->SetSizer(eventListFrameSizer);
78         eventListFrame->SetScrollRate(0,1);
79         eventListFrameSizer->Fit(eventListFrame);
80         eventListFrameSizer->Layout();
81         windowSizer->Fit(this);
83         // Setup the scroll window.
84         
85         mainSectionSizer->Add(eventListFrame, 1, wxGROW | wxALL, 10);
86         
87         windowSizer->Add(topSectionSizer, 1, wxEXPAND, 5);
88         windowSizer->Add(mainSectionSizer, 1, wxEXPAND, 5);
90         this->SetSizer(windowSizer);
91         this->SetSize(size);
92         this->Layout();
93         this->SetBackgroundStyle(wxBG_STYLE_PAINT);
94         this->Centre(wxBOTH);
95         
96         UpdateTopIcons();
97         
98         // Bind events to the control.
99         
100         Bind(XCCALENDARDAY_DESELECTOTHERENTRIES, &XCCalendarDay::DeselectOthersEvent, this, ID_DESELECTOTHERENTRIES);
101         Bind(XCCALENDARDAY_DESELECTALLENTRIES, &XCCalendarDay::DeselectAllEvent, this, ID_DESELECTALLITEMS);
102         Bind(XCCALENDARDAY_HIDEACCOUNTENTRIES, &XCCalendarDay::HideAccountEntries, this, ID_HIDEENTRIES);
103         Bind(XCCALENDARDAY_SHOWACCOUNTENTRIES, &XCCalendarDay::ShowAccountEntries, this, ID_SHOWENTRIES);
104         Bind(XCCALENDARDAY_HIDECALENDARENTRIES, &XCCalendarDay::HideCalendarEntries, this, ID_HIDECALENDARENTRIES);
105         Bind(XCCALENDARDAY_SHOWCALENDARENTRIES, &XCCalendarDay::ShowCalendarEntries, this, ID_SHOWCALENDARENTRIES);
106         Bind(XCCALENDARDAY_DELETECALENDARENTRIES, &XCCalendarDay::DeleteCalendarEntries, this, ID_DELETECALENDARENTRIES);
107         Bind(XCCALENDARDAY_DELETEENTRY, &XCCalendarDay::DeleteCalendarEntry, this, ID_DELETEENTRY);
108         Bind(XCCALENDARDAY_ADDENTRY, &XCCalendarDay::AddCalendarEntry, this, ID_ADDENTRY);
109         Bind(XCCALENDARDAY_UPDATEENTRY, &XCCalendarDay::UpdateCalendarEntry, this, ID_UPDATEENTRY);
110         Bind(XCCALENDARDAY_UPDATECALENDARCOLOUR, &XCCalendarDay::UpdateCalendarColour, this, ID_UPDATECOLOUR);
113 XCCalendarDay::~XCCalendarDay(){
114         
115         // Destory the controls from the widget.
116         
117         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
118                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
119                         
120                 delete((*calendarEntryIter));
121                         
122         }
124         delete alertIcon;
125         alertIcon = nullptr;
126         
127         delete highPriorityIcon;
128         highPriorityIcon = nullptr;
129         
130         delete eventListFrame;
131         eventListFrame = nullptr;
132         
133         calendarEntryList.clear();
134         
137 void XCCalendarDay::Repaint(){
138         
139         wxPaintDC dc(this);
140         wxPaintDC eventListFrameDC(eventListFrame);
141         
142         // Get the wxSizerItem for the top date and the entries part.
144         wxSizerItem *topSectionSizerItem = windowSizer->GetItem((size_t)0);
145         wxSizerItem *mainSectionSizerItem = windowSizer->GetItem((size_t)1);
146         wxRect topSizer = wxRect(windowSizer->GetPosition(), windowSizer->GetSize());
147         
148         if (isInMonth == true){
149         
150                 dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
151                 dc.SetBrush(wxBrush(wxColor(255,255,255)));
152                 dc.DrawRectangle(topSectionSizerItem->GetRect());
153                 dc.SetBrush(wxBrush(wxColor(225,225,225)));
154                 dc.DrawRectangle(mainSectionSizerItem->GetRect());
155                 eventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
156                 eventListFrameDC.SetBrush(wxBrush(wxColor(225,225,225)));
157                 eventListFrameDC.DrawRectangle(eventListFrame->GetClientRect());
158                 
159         } else {
161                 dc.SetPen(wxPen(wxColor(185,185,185), 0, wxPENSTYLE_TRANSPARENT));
162                 dc.SetBrush(wxBrush(wxColor(185,185,185)));
163                 dc.DrawRectangle(topSectionSizerItem->GetRect());
164                 dc.SetBrush(wxBrush(wxColor(155,155,155)));
165                 dc.DrawRectangle(mainSectionSizerItem->GetRect());
166                 eventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
167                 eventListFrameDC.SetBrush(wxBrush(wxColor(155,155,155)));
168                 eventListFrameDC.DrawRectangle(eventListFrame->GetClientRect());
169                 
170         }
171         
172         // Draw the border.
174         //dc.SetBrush(wxBrush(wxColor(0,0,0), wxBRUSHSTYLE_TRANSPARENT));
176         this->Layout();
177         
180 void XCCalendarDay::UpdateTopIcons(){
181         
182         bool alarmFound = false;
183         bool highPriorityFound = false;
184         
185         for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
186                 entryIter != calendarEntryList.end(); entryIter++){
188                 if ((*entryIter)->GetDisplayAlarm() == true){
189                         
190                         alarmFound = true;
191                         
192                 }
194                 if ((*entryIter)->GetDisplayHighPriority() == true){
195                         
196                         highPriorityFound = true;
197                         
198                 }
199                 
200                 if (alarmFound == true && highPriorityFound == true){
201                         
202                         break;
203                         
204                 }
205                 
206         }
207         
208         alertIcon->Show(alarmFound);
209         highPriorityIcon->Show(highPriorityFound);
210         
213 void XCCalendarDay::PaintFrameEvent(wxPaintEvent &paintEvent)
216         Repaint();
217         
220 void XCCalendarDay::ResizeFrameEvent(wxSizeEvent &sizeEvent)
223         // TODO: Check if window size is less than 120 pixels and if it is,
224         // switch to the small block mode.
225         
226         // Refresh the window.
227         
228         this->Refresh();
229         
232 void XCCalendarDay::DeselectOthersEvent(wxCommandEvent &deselectEvent)
234         
235         int selectedEntryID = deselectEvent.GetInt();
237         wxCommandEvent deselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
238         deselectEntryEvent.SetId(ID_ENTRYDESELECT);
239         
240         for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
241                 entryIter != calendarEntryList.end(); entryIter++){
242                         
243                 if ((*entryIter)->GetID() != selectedEntryID){
244                         
245                         wxPostEvent((*entryIter), deselectEntryEvent);
246                         
247                 }
248                 
249         }
250         
251         // Send event notification to deselect the other calendar entries.
252         
253         if (this->monthViewPointer != nullptr){
254                 
255                 wxCommandEvent deselectEvent(XCCALENDARMONTH_DESELECTOTHERENTRIES);
256                 deselectEvent.SetClientData(this);
257                 deselectEvent.SetId(ID_MONTHVIEWCLEARSELECTION);
258                 wxPostEvent(this->monthViewPointer, deselectEvent);
259                 
260         }
261         
264 void XCCalendarDay::DeselectAllEvent(wxCommandEvent &deselectEvent)
266         
267         int selectedEntryID = deselectEvent.GetInt();
268         
269         wxCommandEvent deselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
270         deselectEntryEvent.SetId(ID_ENTRYDESELECT);
271         
272         for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
273                 entryIter != calendarEntryList.end(); entryIter++){
275                 wxPostEvent((*entryIter), deselectEntryEvent);
276                         
277         }
278         
281 void XCCalendarDay::SetupControl(int setupDay, int setupMonth, int setupYear, bool setupIsInMonth, XCCalendarMonthView *monthViewPointer, CalendarDataStorage *dataStorage, vector<int> *hideAccounts, vector<int> *hideCalendars)
283         
284         this->dataStorage = dataStorage;
285         
286         // Set the day
287         
288         numberText->SetLabel(wxString::Format("%02i", setupDay));
289         calendarDay = setupDay;
290         
291         // Set the month
293         calendarMonth = setupMonth;
294         
295         // Set the year.
297         calendarYear = setupYear;
298         
299         // Setup the Is In Month value.
300         
301         isInMonth = setupIsInMonth;
302         
303         // Setup the month view pointer.
304         
305         this->monthViewPointer = monthViewPointer;
306         
307         // Setup the calendar items.
308         
309         CDSEntryList calendarItems = dataStorage->GetEventListByDate(setupYear, setupMonth, setupDay);
310         
311         for (int entrySeek = 0; entrySeek < calendarItems.entryList.size(); entrySeek++){
312                 
313                 // Get the information about the calendar entry.
314                 
315                 CDSGetCalendarEntryInfo newEntryInfo = dataStorage->GetEvent(calendarItems.entryList[entrySeek]);
316                 CDSGetCalendarInfo newEntryCalendarInfo = dataStorage->GetCalendar(newEntryInfo.calendarID);
317                 
318                 // Setup the calendar entry.
319                 
320                 XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(eventListFrame, newEntryInfo.entryName, wxDefaultPosition, wxDefaultSize, calendarItems.entryList[entrySeek]);
321                 
322                 newEntry->SetColour(&newEntryCalendarInfo.calendarColour);
323                 newEntry->SetTime(newEntryInfo.entryStartHour, newEntryInfo.entryStartMinute, newEntryInfo.entryStartSecond);
324                 newEntry->SetEntryIDs(newEntryCalendarInfo.accountID, newEntryInfo.calendarID, newEntryInfo.calendarEntryID);           
325                 
326                 eventListFrameSizer->Add(newEntry, 0, wxEXPAND, 5);
327                 wxSizerItem *afterSpacer = eventListFrameSizer->Add(0, 5, 0, 0, 5);
328                 
329                 newEntry->SetAfterSpacer(afterSpacer);
330                 
331                 // Go through the list of calendar entries to hide by account.
332                 
333                 for (vector<int>::iterator hideAccountsItem = hideAccounts->begin();
334                         hideAccountsItem != hideAccounts->end(); hideAccountsItem++){
335                                 
336                         if (*hideAccountsItem == newEntryCalendarInfo.accountID){
337                                 newEntry->Show(false);
338                                 newEntry->GetAfterSpacer()->Show(false);
339                         }
340                                 
341                 }
342                 
343                 // Go through the list of calendar entries to hide by calendar.
344                 
345                 for (vector<int>::iterator hideCalendarsItem = hideCalendars->begin();
346                         hideCalendarsItem != hideCalendars->end(); hideCalendarsItem++){
347                                 
348                         if (*hideCalendarsItem == newEntryInfo.calendarID){
349                                 newEntry->Show(false);
350                                 newEntry->GetAfterSpacer()->Show(false);
351                         }
352                                 
353                 }
354                 
355                 calendarEntryList.push_back(newEntry);
356         }
357         
360 void XCCalendarDay::HideAccountEntries(wxCommandEvent &accountData){
361         
362         // Go through each of the controls and hide the controls (and spacing) that
363         // have the matched account IDs.
364         
365         int sizerPosition = 0;
366         
367         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
368                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
369                 
370                 (*calendarEntryIter)->SetShowAccountStatus(false);
371                         
372                 if ((*calendarEntryIter)->GetAccountID() == accountData.GetInt()){
373                         
374                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
375                         (*calendarEntryIter)->Show(false);
376                         
377                         // Get the spacing and hide it as well.
378                         
379                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
380                         afterSpacer->Show(false);
381                         
382                 }
383                         
384         }
385         
386         this->Refresh();
387         Repaint();
388         
391 void XCCalendarDay::ShowAccountEntries(wxCommandEvent &accountData){
392         
393         // Go through each of the controls and hide the controls (and spacing) that
394         // have the matched account IDs.
395         
396         int sizerPosition = 0;
397         
398         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
399                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
400                 
401                 (*calendarEntryIter)->SetShowAccountStatus(true);
402                         
403                 if ((*calendarEntryIter)->GetShowCalendarStatus() == false){
404                         continue;
405                 }
406                         
407                 if ((*calendarEntryIter)->GetAccountID() == accountData.GetInt()){
408                         
409                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
410                         (*calendarEntryIter)->Show(true);
411                         
412                         // Get the spacing and hide it as well.
413                         
414                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
415                         afterSpacer->Show(true);
416                         
417                 }
418                 
419         }
420         
421         this->Refresh();
422         Repaint();
423         
426 void XCCalendarDay::HideCalendarEntries(wxCommandEvent &calendarData){
427         
428         // Go through each of the controls and hide the controls (and spacing) that
429         // have the matched account IDs.
430         
431         int sizerPosition = 0;
432         
433         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
434                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
435                         
436                 if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
437                         
438                         (*calendarEntryIter)->SetShowCalendarStatus(false);
439                         
440                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
441                         (*calendarEntryIter)->Show(false);
442                         
443                         // Get the spacing and hide it as well.
444                         
445                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
446                         afterSpacer->Show(false);
447                         
448                 }
449                         
450         }
451         
452         this->Refresh();
453         Repaint();
454         
457 void XCCalendarDay::ShowCalendarEntries(wxCommandEvent &calendarData){
458         
459         // Go through each of the controls and hide the controls (and spacing) that
460         // have the matched account IDs.
461         
462         int sizerPosition = 0;
463         
464         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
465                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
466                         
467                 if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
468                         
469                         (*calendarEntryIter)->SetShowCalendarStatus(true);
470                         
471                         if ((*calendarEntryIter)->GetShowAccountStatus() == false){
472                                 
473                                 // Don't show the calendar entry because the account status
474                                 // is set to hidden. Continue to the next one.
475                                 
476                                 continue;
477                                 
478                         }
479                         
480                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
481                         (*calendarEntryIter)->Show(true);
482                         
483                         // Get the spacing and hide it as well.
484                         
485                         wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
486                         afterSpacer->Show(true);
487                         
488                 }
489                         
490         }
491         
492         this->Refresh();
493         Repaint();
494         
497 void XCCalendarDay::DeleteCalendarEntries(wxCommandEvent &calendarData){
498         
499         vector<vector<XCCalendarDayEntry*>::iterator> deleteEntriesList;
500         
501         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
502                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
503         
504                 if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
505                         
506                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
507                         (*calendarEntryIter)->Show(false);
508                         
509                         // Get the spacing and hide it as well.
510                         
511                         /*wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
512                         afterSpacer->Show(false);
513                         afterSpacer->DetachSizer();
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         Repaint();
527         
528         for (auto deleteIter : deleteEntriesList){
529                 calendarEntryList.erase(deleteIter);
530         }
531         
534 void XCCalendarDay::DeleteCalendarEntry(wxCommandEvent &eventData){
535         
536         vector<vector<XCCalendarDayEntry*>::iterator> deleteEntriesList;
537         
538         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
539                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
540         
541                 if ((*calendarEntryIter)->GetEventID() == eventData.GetInt()){
542                         
543                         wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
544                         (*calendarEntryIter)->Show(false);
545                         
546                         // Get the spacing and hide it as well.
547                         
548                         /*wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
549                         afterSpacer->Show(false);
550                         afterSpacer->DetachSizer();
551                         
552                         delete afterSpacer;
553                         afterSpacer = nullptr;*/
554                         
555                         delete (*calendarEntryIter);
556                         deleteEntriesList.push_back(calendarEntryIter);                 
557                         
558                 }               
559                         
560         }
561         
562         for (auto deleteIter : deleteEntriesList){
563                 calendarEntryList.erase(deleteIter);
564         }
565         
566         this->Refresh();
567         Repaint();
568         
571 void XCCalendarDay::AddCalendarEntry(wxCommandEvent &eventData){
572         
573         EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
574         
575         XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(eventListFrame, eventInfo->eventName, wxDefaultPosition, wxDefaultSize, eventInfo->eventID);
576                 
577         CDSGetCalendarInfo calendarInfo = dataStorage->GetCalendar(eventInfo->calendarID);
578         
579         newEntry->SetColour(&calendarInfo.calendarColour);
580         newEntry->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
581         newEntry->SetEntryIDs(calendarInfo.accountID, eventInfo->calendarID, eventInfo->eventID);               
582                 
583         eventListFrameSizer->Add(newEntry, 0, wxEXPAND, 5);
584         wxSizerItem *afterSpacer = eventListFrameSizer->Add(0, 5, 0, 0, 5);
585                 
586         newEntry->SetAfterSpacer(afterSpacer);
587         
588         // Go through the list of calendar entries to hide by account.
589                 
590         for (vector<int>::iterator hideAccountsItem = eventInfo->hideAccountsList.begin();
591                 hideAccountsItem != eventInfo->hideAccountsList.end(); hideAccountsItem++){
592                                 
593                 if (*hideAccountsItem = calendarInfo.accountID){
594                         newEntry->Show(false);
595                         newEntry->GetAfterSpacer()->Show(false);
596                 }
597                                 
598         }
599                 
600         // Go through the list of calendar entries to hide by calendar.
601                 
602         for (vector<int>::iterator hideCalendarsItem = eventInfo->hideCalendarsList.begin();
603                 hideCalendarsItem != eventInfo->hideCalendarsList.end(); hideCalendarsItem++){
604                                 
605                 if (*hideCalendarsItem == eventInfo->calendarID){
606                         newEntry->Show(false);
607                         newEntry->GetAfterSpacer()->Show(false);
608                 }                       
609                                 
610         }
611                 
612         calendarEntryList.push_back(newEntry);
613         
614         this->Refresh();
615         Repaint();
616         
619 void XCCalendarDay::UpdateCalendarEntry(wxCommandEvent &eventData){
620         
621         // Go thorugh each of the entries in the day and
622         // then update it.
623         
624         EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
625         
626         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
627                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
628                 
629                 if ((*calendarEntryIter)->GetEventID() == eventInfo->eventID){
630                         
631                         (*calendarEntryIter)->SetEventName(eventInfo->eventName);
632                         (*calendarEntryIter)->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
633                         
634                         
635                 }
636                         
637         }
638         
639         delete eventInfo;
640         eventInfo = nullptr;
641         
644 void XCCalendarDay::UpdateCalendarColour(wxCommandEvent &colourData){
645         
646         // Go thorugh each of the entries in the day and
647         // then update it.
648         
649         ColourUpdateProperties *colourInfo = (ColourUpdateProperties*)colourData.GetClientData();
650         
651         for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
652                 calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
653                 
654                 if ((*calendarEntryIter)->GetCalendarID() == colourInfo->calendarID){
655                         
656                         (*calendarEntryIter)->SetColour(&colourInfo->newColour);
657                         
658                 }
659                         
660         }
661         
664 int XCCalendarDay::GetCalendarDay(){
665         
666         return calendarDay;
667         
670 int XCCalendarDay::GetCalendarMonth(){
671         
672         return calendarMonth;
673         
676 int XCCalendarDay::GetCalendarYear(){
677         
678         return calendarYear;
679         
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