Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
893f150de8d9cc9526e8ed8e12e1519b9c249779
[xestiacalendar/.git] / source / widgets / XCCalendarCtrl.cpp
1 // XCCalendarCtrl.cpp - Xestia Calendar XCCalendarCtrl widget class.
2 //
3 // (c) 2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "XCCalendarCtrl.h"
21 using namespace std; 
23 XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *dataStorage)
24         : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize){
25         
26         // Setup the main sizer.
27         
28         szrMain = new wxFlexGridSizer(2, 1, 0, 0);
29         szrMain->AddGrowableCol(0);
30         szrMain->AddGrowableRow(1);
31         szrMain->SetFlexibleDirection(wxBOTH);
32         szrMain->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
33         this->SetSizer(szrMain);
34         
35         // Setup the top menu.
36                 
37         ManipulatorCtrl = new XCCalendarManipulator(this, "XCCalendarManipulator Test", wxDefaultPosition, wxDefaultSize, dataStorage);
38                 
39         // Setup the month view grid.
40         
41         XCCalendarMonthViewGrid CurrentMonthGrid = GenerateMonthGrid(11, 2016);
42         szrMain->Add(ManipulatorCtrl, 1, wxEXPAND, 5);
43                 
44         MonthViewCtrl = new XCCalendarMonthView(this, "XCCalendarMonthView Test", wxDefaultPosition, wxDefaultSize, &CurrentMonthGrid);
45         szrMain->Add(MonthViewCtrl, 1, wxEXPAND, 5);
46         
47         Connect(wxID_ANY, XCCALENDARCTRL_CHANGEGRID, wxCommandEventHandler(XCCalendarCtrl::UpdateGrid));
48         
49 }
51 XCCalendarCtrl::~XCCalendarCtrl(){
52         
53         // Destory the controls in the XCCalendarCtrl class.
54         
55 }
57 void XCCalendarCtrl::UpdateGrid(wxCommandEvent &event){
59         XCCalendarMonthView *OldGrid = nullptr;
60         
61         // Park the old grid.
63         OldGrid = MonthViewCtrl;
64         
65         // Create a new grid.
66         
67         XCCalendarMonthViewGrid NewGrid = GenerateMonthGrid(ManipulatorCtrl->GetMonth(), ManipulatorCtrl->GetYear());
68         MonthViewCtrl = new XCCalendarMonthView(this, _(""), wxDefaultPosition, wxDefaultSize, &NewGrid);
70         // Detach the old grid and attach the new one.
71         
72         szrMain->Detach(1);
73         OldGrid->Show(false);
74         szrMain->Add(MonthViewCtrl, 1, wxEXPAND, 5);
75         szrMain->Layout();
76         
77         // Delete the old grid.
78         
79         delete OldGrid;
80         OldGrid = nullptr;
81         
82 }
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