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 ) );
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(){
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++){
{
int SelectedEntryID = DeselectEvent.GetInt();
-
+
wxCommandEvent DeselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
+ DeselectEntryEvent.SetId(ID_ENTRYDESELECT);
for (vector<XCCalendarDayEntry*>::iterator EntryIter = CalendarEntryList.begin();
EntryIter != CalendarEntryList.end(); EntryIter++){
}
-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<int> *hideAccounts, vector<int> *hideCalendars)
{
+ this->dataStorage = dataStorage;
+
// Set the day
NumberText->SetLabel(wxString::Format("%02i", SetupDay));
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<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);
+
+ // 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<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