Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmMain: Implemented code to hide/show calendar entries
[xestiacalendar/.git] / source / widgets / XCCalendarCtrl.cpp
index a7af38e..b4fe633 100644 (file)
 
 #include "XCCalendarCtrl.h"
 
+BEGIN_EVENT_TABLE(XCCalendarCtrl, wxPanel)
+END_EVENT_TABLE()
+
 using namespace std; 
 
-XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent)
+XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *dataStorage)
        : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize){
        
+       // Setup the pointers.
+               
+       calendarStorage = dataStorage;
+               
        // Setup the main sizer.
        
        szrMain = new wxFlexGridSizer(2, 1, 0, 0);
@@ -33,18 +40,33 @@ XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent)
        this->SetSizer(szrMain);
        
        // Setup the top menu.
-       
-       ManipulatorCtrl = new XCCalendarManipulator(this, "XCCalendarManipulator Test", wxDefaultPosition, wxDefaultSize);
+               
+       ManipulatorCtrl = new XCCalendarManipulator(this, "XCCalendarManipulator Test", wxDefaultPosition, wxDefaultSize, calendarStorage);
                
        // Setup the month view grid.
        
-       XCCalendarMonthViewGrid CurrentMonthGrid = GenerateMonthGrid(11, 2016);
+       wxDateTime DTNow = wxDateTime::Now();
+       int currentMonth = ((int)DTNow.GetMonth() + 1);
+       int currentYear = DTNow.GetYear();
+               
+       XCCalendarMonthViewGrid CurrentMonthGrid = GenerateMonthGrid(currentMonth, currentYear);
        szrMain->Add(ManipulatorCtrl, 1, wxEXPAND, 5);
                
-       MonthViewCtrl = new XCCalendarMonthView(this, "XCCalendarMonthView Test", wxDefaultPosition, wxDefaultSize, &CurrentMonthGrid);
+       // TODO: Get the list of hidden accounts and calendars.
+               
+       vector<int> hideAccountsList = ManipulatorCtrl->GetHiddenAccountsList();
+       vector<int> hideCalendarsList = ManipulatorCtrl->GetHiddenCalendarsList();
+               
+       MonthViewCtrl = new XCCalendarMonthView(this, "XCCalendarMonthView Test", wxDefaultPosition, wxDefaultSize, &CurrentMonthGrid, calendarStorage, &hideAccountsList, &hideCalendarsList);
        szrMain->Add(MonthViewCtrl, 1, wxEXPAND, 5);
        
-       Connect(wxID_ANY, XCCALENDARCTRL_CHANGEGRID, wxCommandEventHandler(XCCalendarCtrl::UpdateGrid));
+       // Connect events to the control.
+       
+       Connect(ID_CHANGEGRID, XCCALENDARCTRL_CHANGEGRID, wxCommandEventHandler(XCCalendarCtrl::UpdateGrid));
+       Connect(ID_HIDEENTRIES, XCCALENDARCTRL_HIDEACCOUNTENTRIES, wxCommandEventHandler(XCCalendarCtrl::HideAccountEntries));
+       Connect(ID_SHOWENTRIES, XCCALENDARCTRL_SHOWACCOUNTENTRIES, wxCommandEventHandler(XCCalendarCtrl::ShowAccountEntries));
+       Connect(ID_HIDECALENDARENTRIES, XCCALENDARCTRL_HIDECALENDARENTRIES, wxCommandEventHandler(XCCalendarCtrl::HideCalendarEntries));
+       Connect(ID_SHOWCALENDARENTRIES, XCCALENDARCTRL_SHOWCALENDARENTRIES, wxCommandEventHandler(XCCalendarCtrl::ShowCalendarEntries));
        
 }
 
@@ -62,10 +84,15 @@ void XCCalendarCtrl::UpdateGrid(wxCommandEvent &event){
 
        OldGrid = MonthViewCtrl;
        
+       // Get the list of hidden accounts and calendars.
+               
+       vector<int> hideAccountsList = ManipulatorCtrl->GetHiddenAccountsList();
+       vector<int> hideCalendarsList = ManipulatorCtrl->GetHiddenCalendarsList();
+       
        // Create a new grid.
        
        XCCalendarMonthViewGrid NewGrid = GenerateMonthGrid(ManipulatorCtrl->GetMonth(), ManipulatorCtrl->GetYear());
-       MonthViewCtrl = new XCCalendarMonthView(this, _(""), wxDefaultPosition, wxDefaultSize, &NewGrid);
+       MonthViewCtrl = new XCCalendarMonthView(this, _(""), wxDefaultPosition, wxDefaultSize, &NewGrid, calendarStorage, &hideAccountsList, &hideCalendarsList);
 
        // Detach the old grid and attach the new one.
        
@@ -79,4 +106,52 @@ void XCCalendarCtrl::UpdateGrid(wxCommandEvent &event){
        delete OldGrid;
        OldGrid = nullptr;
        
+}
+
+void XCCalendarCtrl::HideAccountEntries(wxCommandEvent &accountData){
+       
+       // Get the list of calendar IDs for the account and go through 
+       // the list of entries in each day control.
+       
+       wxCommandEvent event(XCCALENDARMONTH_HIDEACCOUNTENTRIES);
+       event.SetInt(accountData.GetInt());
+       event.SetId(ID_HIDEENTRIES);
+       wxPostEvent(MonthViewCtrl, event);
+       
+}
+
+void XCCalendarCtrl::ShowAccountEntries(wxCommandEvent &accountData){
+       
+       // Get the list of calendar IDs for the account and go through 
+       // the list of entries in each day control.
+       
+       wxCommandEvent event(XCCALENDARMONTH_SHOWACCOUNTENTRIES);
+       event.SetInt(accountData.GetInt());
+       event.SetId(ID_SHOWENTRIES);
+       wxPostEvent(MonthViewCtrl, event);
+       
+}
+
+void XCCalendarCtrl::HideCalendarEntries(wxCommandEvent &calendarData){
+       
+       // Get the list of calendar IDs for the account and go through 
+       // the list of entries in each day control.
+       
+       wxCommandEvent event(XCCALENDARMONTH_HIDECALENDARENTRIES);
+       event.SetInt(calendarData.GetInt());
+       event.SetId(ID_HIDECALENDARENTRIES);
+       wxPostEvent(MonthViewCtrl, event);
+       
+}
+
+void XCCalendarCtrl::ShowCalendarEntries(wxCommandEvent &calendarData){
+       
+       // Get the list of calendar IDs for the account and go through 
+       // the list of entries in each day control.
+       
+       wxCommandEvent event(XCCALENDARMONTH_SHOWCALENDARENTRIES);
+       event.SetInt(calendarData.GetInt());
+       event.SetId(ID_SHOWCALENDARENTRIES);
+       wxPostEvent(MonthViewCtrl, event);
+       
 }
\ 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