Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
XCCalendarCtrl: Generate current month grid if no data is given
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 29 Dec 2016 19:50:12 +0000 (19:50 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 29 Dec 2016 19:50:12 +0000 (19:50 +0000)
source/widgets/XCCalendarCtrl.cpp
source/widgets/XCCalendarCtrl.h

index 893f150..2619242 100644 (file)
 
 #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.
        
index b8ed1d4..9626a53 100644 (file)
@@ -45,7 +45,7 @@ class XCCalendarCtrl: public wxPanel
                XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *storage);
                ~XCCalendarCtrl();
        
-       //DECLARE_EVENT_TABLE()
+       DECLARE_EVENT_TABLE()
        
 };
 
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