X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=blobdiff_plain;f=source%2Fwidgets%2FXCCalendarDay.cpp;h=bde350409c26ea3a3e10a1f02dc22f80e9c9f7d3;hp=13b01d44ccbd40bf5d7912e440568260115f1d78;hb=baa27c175ee6111fd4b88a3c53614a9b6be3541e;hpb=e79afea4cd8930a1ebbdda0e3543dd0a89e45b34 diff --git a/source/widgets/XCCalendarDay.cpp b/source/widgets/XCCalendarDay.cpp index 13b01d4..bde3504 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,30 @@ 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)); + } 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 +208,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 +242,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,7 +255,7 @@ 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) { // Set the day @@ -279,14 +296,175 @@ 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(); + +} \ No newline at end of file