From: Steve Brokenshire Date: Thu, 29 Dec 2016 19:50:12 +0000 (+0000) Subject: XCCalendarCtrl: Generate current month grid if no data is given X-Git-Tag: release-0.02~51 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=23796a09fe99206988ad5ad3b52bd18e37f57d6a;p=xestiacalendar%2F.git XCCalendarCtrl: Generate current month grid if no data is given --- diff --git a/source/widgets/XCCalendarCtrl.cpp b/source/widgets/XCCalendarCtrl.cpp index 893f150..2619242 100644 --- a/source/widgets/XCCalendarCtrl.cpp +++ b/source/widgets/XCCalendarCtrl.cpp @@ -18,11 +18,18 @@ #include "XCCalendarCtrl.h" +BEGIN_EVENT_TABLE(XCCalendarCtrl, wxPanel) +END_EVENT_TABLE() + using namespace std; 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); @@ -34,14 +41,18 @@ XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *dataStorag // Setup the top menu. - ManipulatorCtrl = new XCCalendarManipulator(this, "XCCalendarManipulator Test", wxDefaultPosition, wxDefaultSize, dataStorage); + 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); + MonthViewCtrl = new XCCalendarMonthView(this, "XCCalendarMonthView Test", wxDefaultPosition, wxDefaultSize, &CurrentMonthGrid, calendarStorage); szrMain->Add(MonthViewCtrl, 1, wxEXPAND, 5); Connect(wxID_ANY, XCCALENDARCTRL_CHANGEGRID, wxCommandEventHandler(XCCalendarCtrl::UpdateGrid)); @@ -65,7 +76,7 @@ void XCCalendarCtrl::UpdateGrid(wxCommandEvent &event){ // 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); // Detach the old grid and attach the new one. diff --git a/source/widgets/XCCalendarCtrl.h b/source/widgets/XCCalendarCtrl.h index b8ed1d4..9626a53 100644 --- a/source/widgets/XCCalendarCtrl.h +++ b/source/widgets/XCCalendarCtrl.h @@ -45,7 +45,7 @@ class XCCalendarCtrl: public wxPanel XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *storage); ~XCCalendarCtrl(); - //DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() };