X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fwidgets%2FXCCalendarDay.cpp;h=14657b98cc307b0260f995129b143015a3de6d01;hb=c5716d0f27f0f917282df9121aa97eab7a1bf6b8;hp=13b01d44ccbd40bf5d7912e440568260115f1d78;hpb=ed4644cc1c246d7c7ccc20f09cc7d587f6654668;p=xestiacalendar%2F.git diff --git a/source/widgets/XCCalendarDay.cpp b/source/widgets/XCCalendarDay.cpp index 13b01d4..14657b9 100644 --- a/source/widgets/XCCalendarDay.cpp +++ b/source/widgets/XCCalendarDay.cpp @@ -27,9 +27,6 @@ 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)); - Connect(ID_DESELECTALLITEMS, XCCALENDARDAY_DESELECTALLENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectAllEvent)); this->SetMinSize( wxSize( 100,100 ) ); @@ -88,12 +85,35 @@ XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPo 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::iterator CalendarEntryIter = CalendarEntryList.begin(); + CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){ + + delete((*CalendarEntryIter)); + + } + + CalendarEntryList.clear(); + + this->Refresh(); + } void XCCalendarDay::Repaint(){ @@ -193,10 +213,11 @@ void XCCalendarDay::ResizeFrameEvent(wxSizeEvent &SizeEvent) void XCCalendarDay::DeselectOthersEvent(wxCommandEvent &DeselectEvent) { - + int SelectedEntryID = DeselectEvent.GetInt(); wxCommandEvent DeselectEntryEvent(XCCALENDARDAYENTRY_DESELECT); + DeselectEntryEvent.SetId(ID_ENTRYDESELECT); for (vector::iterator EntryIter = CalendarEntryList.begin(); EntryIter != CalendarEntryList.end(); EntryIter++){ @@ -226,8 +247,9 @@ void XCCalendarDay::DeselectAllEvent(wxCommandEvent &DeselectEvent) { int SelectedEntryID = DeselectEvent.GetInt(); - + wxCommandEvent DeselectEntryEvent(XCCALENDARDAYENTRY_DESELECT); + DeselectEntryEvent.SetId(ID_ENTRYDESELECT); for (vector::iterator EntryIter = CalendarEntryList.begin(); EntryIter != CalendarEntryList.end(); EntryIter++){ @@ -238,9 +260,11 @@ void XCCalendarDay::DeselectAllEvent(wxCommandEvent &DeselectEvent) } -void XCCalendarDay::SetupControl(int SetupDay, int SetupMonth, int SetupYear, bool SetupIsInMonth, XCCalendarMonthView *MonthViewPointer, CalendarDataStorage *dataStorage) +void XCCalendarDay::SetupControl(int SetupDay, int SetupMonth, int SetupYear, bool SetupIsInMonth, XCCalendarMonthView *MonthViewPointer, CalendarDataStorage *dataStorage, vector *hideAccounts, vector *hideCalendars) { + this->dataStorage = dataStorage; + // Set the day NumberText->SetLabel(wxString::Format("%02i", SetupDay)); @@ -279,14 +303,360 @@ void XCCalendarDay::SetupControl(int SetupDay, int SetupMonth, int SetupYear, bo newEntry->SetColour(&newEntryCalendarInfo.calendarColour); newEntry->SetTime(newEntryInfo.entryStartHour, newEntryInfo.entryStartMinute, newEntryInfo.entryStartSecond); - newEntry->SetEntryIDs(newEntryCalendarInfo.accountID, newEntryInfo.calendarID, newEntryInfo.calendarEntryID); + 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::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::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::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::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::iterator CalendarEntryIter = CalendarEntryList.begin(); + CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){ + + if ((*CalendarEntryIter)->GetCalendarID() == calendarData.GetInt()){ + + (*CalendarEntryIter)->SetShowCalendarStatus(false); + + 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::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::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::iterator> DeleteEntriesList; + + for (vector::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::iterator> DeleteEntriesList; + + for (vector::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::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::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::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::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