using namespace std;
-BEGIN_EVENT_TABLE(XCCalendarDay, wxFrame)
+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(const wxString& title, const wxPoint& pos, const wxSize& size)
- : wxFrame(NULL, wxID_ANY, title, pos, size)
-{
+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);
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);
//EventListFrameSizer->FitInside(EventListFrame);
// Setup the scroll window.
+ MainSectionSizer->Add(EventListFrame, 1, wxGROW | wxALL, 10);
+
WindowSizer->Add(TopSectionSizer, 1, wxEXPAND, 5);
WindowSizer->Add(MainSectionSizer, 1, wxEXPAND, 5);
- MainSectionSizer->Add(EventListFrame, 1, wxGROW | wxALL, 10);
this->SetSizer(WindowSizer);
this->SetSize(size);
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));
+
}
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);
+
// 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());
- dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
- dc.DrawRectangle(TopSectionSizerItem->GetRect());
- dc.SetBrush(wxBrush(wxColor(225,225,225)));
- dc.DrawRectangle(MainSectionSizerItem->GetRect());
+ if (IsInMonth == true){
- // Draw the border.
-
- this->Layout();
+ dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
+ dc.SetBrush(wxBrush(wxColor(255,255,255)));
+ 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());
+
+ } else {
- dc.SetBrush(wxBrush(wxColor(0,0,0), wxBRUSHSTYLE_TRANSPARENT));
+ dc.SetPen(wxPen(wxColor(185,185,185), 0, wxPENSTYLE_TRANSPARENT));
+ dc.SetBrush(wxBrush(wxColor(185,185,185)));
+ 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());
+
+ }
- wxPaintDC EventListFrameDC(EventListFrame);
- EventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
- EventListFrameDC.SetBrush(wxBrush(wxColor(225,225,225)));
- EventListFrameDC.DrawRectangle(EventListFrame->GetClientRect());
+ // Draw the border.
+ //dc.SetBrush(wxBrush(wxColor(0,0,0), wxBRUSHSTYLE_TRANSPARENT));
+
+ this->Layout();
+
}
void XCCalendarDay::UpdateTopIcons(){
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++){
}
+ // 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)
+{
+
+ // Set the day
+
+ NumberText->SetLabel(wxString::Format("%02i", SetupDay));
+ calendarDay = SetupDay;
+
+ // Set the month
+
+ calendarMonth = SetupMonth;
+
+ // Set the year.
+
+ calendarYear = SetupYear;
+
+ // Setup the Is In Month value.
+
+ IsInMonth = SetupIsInMonth;
+
+ // 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);
+
+ // 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();
+
}
\ No newline at end of file