Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
camelCase: Converted code in widgets directory
[xestiacalendar/.git] / source / widgets / XCCalendarDay.cpp
index 6c0b29b..110d321 100644 (file)
@@ -23,151 +23,131 @@ using namespace std;
 BEGIN_EVENT_TABLE(XCCalendarDay, wxPanel)
 EVT_PAINT(XCCalendarDay::PaintFrameEvent)
 EVT_SIZE(XCCalendarDay::ResizeFrameEvent)
-//EVT_COMMAND(wxID_ANY, XCCALENDARDAY_DESELECTOTHERENTRIES, XCCalendarDay::DeselectOthersEvent)
 END_EVENT_TABLE()
 
 XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size)
         : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){
-       
-       Connect(wxID_ANY, XCCALENDARDAY_DESELECTOTHERENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectOthersEvent));
-       
+
        this->SetMinSize( wxSize( 100,100 ) );
        
-       AlertIconBitmap.LoadFile("AlertIcon-32.png", wxBITMAP_DEFAULT_TYPE);
-       PriorityIconBitmap.LoadFile("PriorityIcon-32.png", wxBITMAP_DEFAULT_TYPE);
+       // Setip the icons.
+               
+       wxMemoryInputStream alerticon(icons_alert32_png, sizeof(icons_alert32_png));
+       wxMemoryInputStream priorityicon(icons_priority32_png, sizeof(icons_priority32_png));
+       
+       wxImage icons_alert_png(alerticon, wxBITMAP_TYPE_PNG);
+       wxBitmap imgAlertIcon(icons_alert_png, -1);
+
+       wxImage icons_priority_png(priorityicon, wxBITMAP_TYPE_PNG);
+       wxBitmap imgPriorityIcon(icons_priority_png, -1);
        
-       AlertIcon->SetBitmap(AlertIconBitmap);
-       HighPriorityIcon->SetBitmap(PriorityIconBitmap);        
+       alertIcon->SetBitmap(imgAlertIcon);
+       highPriorityIcon->SetBitmap(imgPriorityIcon);
        
-       WindowSizer->AddGrowableCol(0);
-       WindowSizer->AddGrowableRow(1);
-       WindowSizer->SetFlexibleDirection( wxBOTH );
-       WindowSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
+       windowSizer->AddGrowableCol(0);
+       windowSizer->AddGrowableRow(1);
+       windowSizer->SetFlexibleDirection( wxBOTH );
+       windowSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
        
-       NumberText = new wxStaticText(this, wxID_ANY, wxT("09"), wxDefaultPosition, wxDefaultSize, 0);
-       NumberText->SetFont(wxFont(24, 70, 90, 92, false, wxEmptyString));
+       numberText = new wxStaticText(this, wxID_ANY, wxT("09"), wxDefaultPosition, wxDefaultSize, 0);
+       numberText->SetFont(wxFont(24, 70, 90, 92, false, wxEmptyString));
        
-       TopSectionSizer->Add(HighPriorityIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
-       TopSectionSizer->Add(AlertIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
-       TopSectionSizer->Add(0, 0, 1, wxEXPAND, 5);
-       TopSectionSizer->Add(NumberText, 0, wxALL|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5);
+       topSectionSizer->Add(highPriorityIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
+       topSectionSizer->Add(alertIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
+       topSectionSizer->Add(0, 0, 1, wxEXPAND, 5);
+       topSectionSizer->Add(numberText, 0, wxALL|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5);
 
        // Setup the scrollable section.
        
-       Colour EventColour;
-       EventColour.red = 40; EventColour.green = 80; EventColour.blue = 80;
-       
-       EventListFrame->SetSizer(EventListFrameSizer);
-       CalendarEntry1->SetColour(&EventColour);
-       CalendarEntry1->SetDisplayAlarm(false);
-       CalendarEntry1->SetDisplayHighPriority(false);
-       EventListFrameSizer->Add(CalendarEntry1, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-       
-       EventColour.red = 255; EventColour.green = 0; EventColour.blue = 0;
-       CalendarEntry2->SetColour(&EventColour);
-       CalendarEntry2->SetDisplayAlarm(true);
-       CalendarEntry2->SetDisplayHighPriority(false);
-       EventListFrameSizer->Add(CalendarEntry2, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-       
-       EventColour.red = 0; EventColour.green = 255; EventColour.blue = 0;
-       CalendarEntry3->SetColour(&EventColour);
-       CalendarEntry3->SetDisplayAlarm(false);
-       CalendarEntry3->SetDisplayHighPriority(false);
-       EventListFrameSizer->Add(CalendarEntry3, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-
-       EventColour.red = 0; EventColour.green = 0; EventColour.blue = 255;
-       CalendarEntry4->SetColour(&EventColour);
-       CalendarEntry4->SetDisplayAlarm(false);
-       CalendarEntry4->SetDisplayHighPriority(false);
-       EventListFrameSizer->Add(CalendarEntry4, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-       
-       EventListFrameSizer->Add(CalendarEntry5, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-       EventListFrameSizer->Add(CalendarEntry6, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-       EventListFrameSizer->Add(CalendarEntry7, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-       EventListFrameSizer->Add(CalendarEntry8, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-       EventListFrameSizer->Add(CalendarEntry9, 0, wxEXPAND, 5);
-       EventListFrameSizer->Add(0, 5, 0, 0, 5);
-       EventListFrameSizer->Add(CalendarEntry10, 0, wxEXPAND, 5);
-
-       EventListFrame->SetScrollRate(0,1);
+       Colour eventColour;
+       eventColour.red = 40; eventColour.green = 80; eventColour.blue = 80;
+       
+       eventListFrame->SetSizer(eventListFrameSizer);
+
+       eventListFrame->SetScrollRate(0,1);
        //EventListFrameSizer->FitInside(EventListFrame);
-       EventListFrameSizer->Fit(EventListFrame);
-       EventListFrameSizer->Layout();
-       WindowSizer->Fit(this);
+       eventListFrameSizer->Fit(EventListFrame);
+       eventListFrameSizer->Layout();
+       windowSizer->Fit(this);
 
        // Setup the scroll window.
        
-       WindowSizer->Add(TopSectionSizer, 1, wxEXPAND, 5);
-       WindowSizer->Add(MainSectionSizer, 1, wxEXPAND, 5);
-       MainSectionSizer->Add(EventListFrame, 1, wxGROW | wxALL, 10);
+       mainSectionSizer->Add(eventListFrame, 1, wxGROW | wxALL, 10);
+       
+       windowSizer->Add(topSectionSizer, 1, wxEXPAND, 5);
+       windowSizer->Add(mainSectionSizer, 1, wxEXPAND, 5);
 
-       this->SetSizer(WindowSizer);
+       this->SetSizer(windowSizer);
        this->SetSize(size);
        this->Layout();
        this->SetBackgroundStyle(wxBG_STYLE_PAINT);
        this->Centre(wxBOTH);
        
-       CalendarEntryList.push_back(CalendarEntry1);
-       CalendarEntryList.push_back(CalendarEntry2);
-       CalendarEntryList.push_back(CalendarEntry3);
-       CalendarEntryList.push_back(CalendarEntry4);
-       CalendarEntryList.push_back(CalendarEntry5);
-       CalendarEntryList.push_back(CalendarEntry6);
-       CalendarEntryList.push_back(CalendarEntry7);
-       CalendarEntryList.push_back(CalendarEntry8);
-       CalendarEntryList.push_back(CalendarEntry9);
-       CalendarEntryList.push_back(CalendarEntry10);
-       
        UpdateTopIcons();
        
+       Connect(ID_DESELECTOTHERENTRIES, XCCALENDARDAY_DESELECTOTHERENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectOthersEvent));
+       Connect(ID_DESELECTALLITEMS, XCCALENDARDAY_DESELECTALLENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectAllEvent));
+       Connect(ID_HIDEENTRIES, XCCALENDARDAY_HIDEACCOUNTENTRIES, wxCommandEventHandler(XCCalendarDay::HideAccountEntries));
+       Connect(ID_SHOWENTRIES, XCCALENDARDAY_SHOWACCOUNTENTRIES, wxCommandEventHandler(XCCalendarDay::ShowAccountEntries));
+       Connect(ID_HIDECALENDARENTRIES, XCCALENDARDAY_HIDECALENDARENTRIES, wxCommandEventHandler(XCCalendarDay::HideCalendarEntries));
+       Connect(ID_SHOWCALENDARENTRIES, XCCALENDARDAY_SHOWCALENDARENTRIES, wxCommandEventHandler(XCCalendarDay::ShowCalendarEntries));
+       Connect(ID_DELETECALENDARENTRIES, XCCALENDARDAY_DELETECALENDARENTRIES, wxCommandEventHandler(XCCalendarDay::DeleteCalendarEntries));
+       Connect(ID_DELETEENTRY, XCCALENDARDAY_DELETEENTRY, wxCommandEventHandler(XCCalendarDay::DeleteCalendarEntry));
+       Connect(ID_ADDENTRY, XCCALENDARDAY_ADDENTRY, wxCommandEventHandler(XCCalendarDay::AddCalendarEntry));
+       Connect(ID_UPDATEENTRY, XCCALENDARDAY_UPDATEENTRY, wxCommandEventHandler(XCCalendarDay::UpdateCalendarEntry));
+       Connect(ID_UPDATECOLOUR, XCCALENDARDAY_UPDATECALENDARCOLOUR, wxCommandEventHandler(XCCalendarDay::UpdateCalendarColour));
+
 }
 
 XCCalendarDay::~XCCalendarDay(){
        
        // Destory the controls from the widget.
        
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+       
+               delete((*calendarEntryIter));
+                       
+       }
+       
+       calendarEntryList.clear();
+       
+       this->Refresh();
+       
 }
 
 void XCCalendarDay::Repaint(){
        
        wxPaintDC dc(this);
-       wxPaintDC EventListFrameDC(EventListFrame);
+       wxPaintDC eventListFrameDC(eventListFrame);
        
        // Get the wxSizerItem for the top date and the entries part.
 
-       wxSizerItem *TopSectionSizerItem = WindowSizer->GetItem((size_t)0);
-       wxSizerItem *MainSectionSizerItem = WindowSizer->GetItem((size_t)1);
-       wxRect TopSizer = wxRect(WindowSizer->GetPosition(), WindowSizer->GetSize());
+       wxSizerItem *topSectionSizerItem = windowSizer->GetItem((size_t)0);
+       wxSizerItem *mainSectionSizerItem = windowSizer->GetItem((size_t)1);
+       wxRect topSizer = wxRect(windowSizer->GetPosition(), windowSizer->GetSize());
        
-       if (IsInMonth == true){
+       if (isInMonth == true){
        
                dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
                dc.SetBrush(wxBrush(wxColor(255,255,255)));
-               dc.DrawRectangle(TopSectionSizerItem->GetRect());
+               dc.DrawRectangle(topSectionSizerItem->GetRect());
                dc.SetBrush(wxBrush(wxColor(225,225,225)));
-               dc.DrawRectangle(MainSectionSizerItem->GetRect());
-               EventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
-               EventListFrameDC.SetBrush(wxBrush(wxColor(225,225,225)));
-               EventListFrameDC.DrawRectangle(EventListFrame->GetClientRect());
+               dc.DrawRectangle(mainSectionSizerItem->GetRect());
+               eventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
+               eventListFrameDC.SetBrush(wxBrush(wxColor(225,225,225)));
+               eventListFrameDC.DrawRectangle(eventListFrame->GetClientRect());
                
        } else {
 
                dc.SetPen(wxPen(wxColor(185,185,185), 0, wxPENSTYLE_TRANSPARENT));
                dc.SetBrush(wxBrush(wxColor(185,185,185)));
-               dc.DrawRectangle(TopSectionSizerItem->GetRect());
+               dc.DrawRectangle(topSectionSizerItem->GetRect());
                dc.SetBrush(wxBrush(wxColor(155,155,155)));
-               dc.DrawRectangle(MainSectionSizerItem->GetRect());
-               EventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
-               EventListFrameDC.SetBrush(wxBrush(wxColor(155,155,155)));
-               EventListFrameDC.DrawRectangle(EventListFrame->GetClientRect());
+               dc.DrawRectangle(mainSectionSizerItem->GetRect());
+               eventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
+               eventListFrameDC.SetBrush(wxBrush(wxColor(155,155,155)));
+               eventListFrameDC.DrawRectangle(eventListFrame->GetClientRect());
                
        }
        
@@ -181,25 +161,25 @@ void XCCalendarDay::Repaint(){
 
 void XCCalendarDay::UpdateTopIcons(){
        
-       bool AlarmFound = false;
-       bool HighPriorityFound = false;
+       bool alarmFound = false;
+       bool highPriorityFound = false;
        
-       for (vector<XCCalendarDayEntry*>::iterator EntryIter = CalendarEntryList.begin();
-               EntryIter != CalendarEntryList.end(); EntryIter++){
+       for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
+               entryIter != calendarEntryList.end(); entryIter++){
 
-               if ((*EntryIter)->GetDisplayAlarm() == true){
+               if ((*entryIter)->GetDisplayAlarm() == true){
                        
-                       AlarmFound = true;
+                       alarmFound = true;
                        
                }
 
-               if ((*EntryIter)->GetDisplayHighPriority() == true){
+               if ((*entryIter)->GetDisplayHighPriority() == true){
                        
-                       HighPriorityFound = true;
+                       highPriorityFound = true;
                        
                }
                
-               if (AlarmFound == true && HighPriorityFound == true){
+               if (alarmFound == true && highPriorityFound == true){
                        
                        break;
                        
@@ -207,19 +187,19 @@ void XCCalendarDay::UpdateTopIcons(){
                
        }
        
-       AlertIcon->Show(AlarmFound);
-       HighPriorityIcon->Show(HighPriorityFound);
+       alertIcon->Show(alarmFound);
+       highPriorityIcon->Show(highPriorityFound);
        
 }
 
-void XCCalendarDay::PaintFrameEvent(wxPaintEvent &PaintEvent)
+void XCCalendarDay::PaintFrameEvent(wxPaintEvent &paintEvent)
 {
 
        Repaint();
        
 }
 
-void XCCalendarDay::ResizeFrameEvent(wxSizeEvent &SizeEvent)
+void XCCalendarDay::ResizeFrameEvent(wxSizeEvent &sizeEvent)
 {
 
        // TODO: Check if window size is less than 120 pixels and if it is,
@@ -231,22 +211,452 @@ void XCCalendarDay::ResizeFrameEvent(wxSizeEvent &SizeEvent)
        
 }
 
-void XCCalendarDay::DeselectOthersEvent(wxCommandEvent &DeselectEvent)
+void XCCalendarDay::DeselectOthersEvent(wxCommandEvent &deselectEvent)
+{
+       
+       int selectedEntryID = deselectEvent.GetInt();
+
+       wxCommandEvent deselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
+       deselectEntryEvent.SetId(ID_ENTRYDESELECT);
+       
+       for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
+               entryIter != calendarEntryList.end(); entryIter++){
+                       
+               if ((*entryIter)->GetID() != selectedEntryID){
+                       
+                       wxPostEvent((*entryIter), deselectEntryEvent);
+                       
+               }
+                       
+       }
+       
+       // Send event notification to deselect the other calendar entries.
+       
+       if (this->monthViewPointer != nullptr){
+               
+               wxCommandEvent deselectEvent(XCCALENDARMONTH_DESELECTOTHERENTRIES);
+               deselectEvent.SetClientData(this);
+               deselectEvent.SetId(ID_MONTHVIEWCLEARSELECTION);
+               wxPostEvent(this->monthViewPointer, deselectEvent);
+               
+       }
+       
+}
+
+void XCCalendarDay::DeselectAllEvent(wxCommandEvent &DeselectEvent)
+{
+       
+       int selectedEntryID = deselectEvent.GetInt();
+       
+       wxCommandEvent deselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
+       deselectEntryEvent.SetId(ID_ENTRYDESELECT);
+       
+       for (vector<XCCalendarDayEntry*>::iterator entryIter = calendarEntryList.begin();
+               entryIter != calendarEntryList.end(); EntryIter++){
+
+               wxPostEvent((*entryIter), deselectEntryEvent);
+                       
+       }
+       
+}
+
+void XCCalendarDay::SetupControl(int setupDay, int setupMonth, int setupYear, bool setupIsInMonth, XCCalendarMonthView *monthViewPointer, CalendarDataStorage *dataStorage, vector<int> *hideAccounts, vector<int> *hideCalendars)
 {
+       
+       this->dataStorage = dataStorage;
+       
+       // Set the day
+       
+       numberText->SetLabel(wxString::Format("%02i", setupDay));
+       calendarDay = setupDay;
+       
+       // Set the month
 
-       int SelectedEntryID = DeselectEvent.GetInt();
+       calendarMonth = setupMonth;
+       
+       // Set the year.
 
-       wxCommandEvent DeselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
+       calendarYear = setupYear;
+       
+       // Setup the Is In Month value.
+       
+       isInMonth = setupIsInMonth;
        
-       for (vector<XCCalendarDayEntry*>::iterator EntryIter = CalendarEntryList.begin();
-               EntryIter != CalendarEntryList.end(); EntryIter++){
+       // Setup the month view pointer.
+       
+       this->monthViewPointer = monthViewPointer;
+       
+       // Setup the calendar items.
+       
+       CDSEntryList calendarItems = dataStorage->GetEventListByDate(setupYear, setupMonth, setupDay);
+       
+       for (int entrySeek = 0; entrySeek < calendarItems.entryList.size(); entrySeek++){
+               
+               // Get the information about the calendar entry.
+               
+               CDSGetCalendarEntryInfo newEntryInfo = dataStorage->GetEvent(calendarItems.entryList[entrySeek]);
+               CDSGetCalendarInfo newEntryCalendarInfo = dataStorage->GetCalendar(newEntryInfo.calendarID);
+               
+               // Setup the calendar entry.
+               
+               XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(eventListFrame, newEntryInfo.entryName, wxDefaultPosition, wxDefaultSize, calendarItems.entryList[entrySeek]);
+               
+               newEntry->SetColour(&newEntryCalendarInfo.calendarColour);
+               newEntry->SetTime(newEntryInfo.entryStartHour, newEntryInfo.entryStartMinute, newEntryInfo.entryStartSecond);
+               newEntry->SetEntryIDs(newEntryCalendarInfo.accountID, newEntryInfo.calendarID, newEntryInfo.calendarEntryID);           
+               
+               eventListFrameSizer->Add(newEntry, 0, wxEXPAND, 5);
+               wxSizerItem *afterSpacer = eventListFrameSizer->Add(0, 5, 0, 0, 5);
+               
+               newEntry->SetAfterSpacer(afterSpacer);
+               
+               // Go through the list of calendar entries to hide by account.
+               
+               for (vector<int>::iterator hideAccountsItem = hideAccounts->begin();
+                       hideAccountsItem != hideAccounts->end(); hideAccountsItem++){
+                               
+                       if (*hideAccountsItem == newEntryCalendarInfo.accountID){
+                               newEntry->Show(false);
+                               newEntry->GetAfterSpacer()->Show(false);
+                       }
+                               
+               }
+               
+               // Go through the list of calendar entries to hide by calendar.
+               
+               for (vector<int>::iterator hideCalendarsItem = hideCalendars->begin();
+                       hideCalendarsItem != hideCalendars->end(); hideCalendarsItem++){
+                               
+                       if (*hideCalendarsItem == newEntryInfo.calendarID){
+                               newEntry->Show(false);
+                               newEntry->GetAfterSpacer()->Show(false);
+                       }
+                               
+               }
+               
+               calendarEntryList.push_back(newEntry);
+       }
+       
+}
+
+void XCCalendarDay::HideAccountEntries(wxCommandEvent &accountData){
+       
+       // Go through each of the controls and hide the controls (and spacing) that
+       // have the matched account IDs.
+       
+       int sizerPosition = 0;
+       
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+               
+               (*calendarEntryIter)->SetShowAccountStatus(false);
+                       
+               if ((*calendarEntryIter)->GetAccountID() == accountData.GetInt()){
+                       
+                       wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
+                       (*calendarEntryIter)->Show(false);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(false);
+                       
+               }
+                       
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::ShowAccountEntries(wxCommandEvent &accountData){
+       
+       // Go through each of the controls and hide the controls (and spacing) that
+       // have the matched account IDs.
+       
+       int sizerPosition = 0;
+       
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+               
+               (*calendarEntryIter)->SetShowAccountStatus(true);
+                       
+               if ((*calendarEntryIter)->GetShowCalendarStatus() == false){
+                       continue;
+               }
+                       
+               if ((*calendarEntryIter)->GetAccountID() == accountData.GetInt()){
+                       
+                       wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
+                       (*calendarEntryIter)->Show(true);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(true);
+                       
+               }
+               
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::HideCalendarEntries(wxCommandEvent &calendarData){
+       
+       // Go through each of the controls and hide the controls (and spacing) that
+       // have the matched account IDs.
+       
+       int sizerPosition = 0;
+       
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+                       
+               if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
+                       
+                       (*calendarEntryIter)->SetShowCalendarStatus(false);
+                       
+                       wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
+                       (*calendarEntryIter)->Show(false);
                        
-               if ((*EntryIter)->GetID() != SelectedEntryID){
+                       // Get the spacing and hide it as well.
                        
-                       wxPostEvent((*EntryIter), DeselectEntryEvent);
+                       wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(false);
                        
                }
                        
        }
        
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::ShowCalendarEntries(wxCommandEvent &calendarData){
+       
+       // Go through each of the controls and hide the controls (and spacing) that
+       // have the matched account IDs.
+       
+       int sizerPosition = 0;
+       
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+                       
+               if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
+                       
+                       (*calendarEntryIter)->SetShowCalendarStatus(true);
+                       
+                       if ((*calendarEntryIter)->GetShowAccountStatus() == false){
+                               
+                               // Don't show the calendar entry because the account status
+                               // is set to hidden. Continue to the next one.
+                               
+                               continue;
+                               
+                       }
+                       
+                       wxSizerItem *calendarItem = EventListFrameSizer->GetItem((*calendarEntryIter));
+                       (*calendarEntryIter)->Show(true);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(true);
+                       
+               }
+                       
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::DeleteCalendarEntries(wxCommandEvent &calendarData){
+       
+       vector<vector<XCCalendarDayEntry*>::iterator> deleteEntriesList;
+       
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+       
+               if ((*calendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
+                       
+                       wxSizerItem *calendarItem = eventListFrameSizer->GetItem((*calendarEntryIter));
+                       (*calendarEntryIter)->Show(false);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(false);
+                       afterSpacer->DetachSizer();
+                       
+                       delete afterSpacer;
+                       afterSpacer = nullptr;
+       
+                       delete (*calendarEntryIter);
+                       deleteEntriesList.push_back(calendarEntryIter);
+                       
+               }               
+                       
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+       for (auto deleteIter : deleteEntriesList){
+               calendarEntryList.erase(deleteIter);
+       }
+       
+}
+
+void XCCalendarDay::DeleteCalendarEntry(wxCommandEvent &eventData){
+       
+       vector<vector<XCCalendarDayEntry*>::iterator> deleteEntriesList;
+       
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+       
+               if ((*calendarEntryIter)->GetEventID() == eventData.GetInt()){
+                       
+                       wxSizerItem *calendarItem = EventListFrameSizer->GetItem((*calendarEntryIter));
+                       (*calendarEntryIter)->Show(false);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(false);
+                       afterSpacer->DetachSizer();
+                       
+                       delete afterSpacer;
+                       afterSpacer = nullptr;
+                       
+                       delete (*calendarEntryIter);
+                       deleteEntriesList.push_back(calendarEntryIter);                 
+                       
+               }               
+                       
+       }
+       
+       for (auto deleteIter : deleteEntriesList){
+               calendarEntryList.erase(deleteIter);
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::AddCalendarEntry(wxCommandEvent &eventData){
+       
+       EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+       
+       XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(eventListFrame, eventInfo->eventName, wxDefaultPosition, wxDefaultSize, eventInfo->eventID);
+               
+       CDSGetCalendarInfo calendarInfo = dataStorage->GetCalendar(eventInfo->calendarID);
+       
+       newEntry->SetColour(&calendarInfo.calendarColour);
+       newEntry->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
+       newEntry->SetEntryIDs(calendarInfo.accountID, eventInfo->calendarID, eventInfo->eventID);               
+               
+       eventListFrameSizer->Add(newEntry, 0, wxEXPAND, 5);
+       wxSizerItem *afterSpacer = eventListFrameSizer->Add(0, 5, 0, 0, 5);
+               
+       newEntry->SetAfterSpacer(afterSpacer);
+       
+       // Go through the list of calendar entries to hide by account.
+               
+       for (vector<int>::iterator hideAccountsItem = eventInfo->hideAccountsList.begin();
+               hideAccountsItem != eventInfo->hideAccountsList.end(); hideAccountsItem++){
+                               
+               if (*hideAccountsItem = calendarInfo.accountID){
+                       newEntry->Show(false);
+                       newEntry->GetAfterSpacer()->Show(false);
+               }
+                               
+       }
+               
+       // Go through the list of calendar entries to hide by calendar.
+               
+       for (vector<int>::iterator hideCalendarsItem = eventInfo->hideCalendarsList.begin();
+               hideCalendarsItem != eventInfo->hideCalendarsList.end(); hideCalendarsItem++){
+                               
+               if (*hideCalendarsItem == eventInfo->calendarID){
+                       newEntry->Show(false);
+                       newEntry->GetAfterSpacer()->Show(false);
+               }                       
+                               
+       }
+               
+       calendarEntryList.push_back(newEntry);
+       
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::UpdateCalendarEntry(wxCommandEvent &eventData){
+       
+       // Go thorugh each of the entries in the day and
+       // then update it.
+       
+       EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+       
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+               
+               if ((*calendarEntryIter)->GetEventID() == eventInfo->eventID){
+                       
+                       (*calendarEntryIter)->SetEventName(eventInfo->eventName);
+                       (*calendarEntryIter)->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
+                       
+                       
+               }
+                       
+       }
+       
+       delete eventInfo;
+       eventInfo = nullptr;
+       
+}
+
+void XCCalendarDay::UpdateCalendarColour(wxCommandEvent &colourData){
+       
+       // Go thorugh each of the entries in the day and
+       // then update it.
+       
+       ColourUpdateProperties *colourInfo = (ColourUpdateProperties*)colourData.GetClientData();
+       
+       for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
+               calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
+               
+               if ((*calendarEntryIter)->GetCalendarID() == colourInfo->calendarID){
+                       
+                       (*calendarEntryIter)->SetColour(&colourInfo->newColour);
+                       
+               }
+                       
+       }
+       
+}
+
+int XCCalendarDay::GetCalendarDay(){
+       
+       return calendarDay;
+       
+}
+
+int XCCalendarDay::GetCalendarMonth(){
+       
+       return calendarMonth;
+       
+}
+
+int XCCalendarDay::GetCalendarYear(){
+       
+       return calendarYear;
+       
 }
\ 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