Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
svrblist: Implemented server blacklist code for Xestia Address Book
[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 BEGIN_EVENT_TABLE(XCCalendarCtrl, wxPanel)
22 END_EVENT_TABLE()
24 using namespace std; 
26 XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *dataStorage)
27         : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize){
28         
29         // Setup the pointers.
30                 
31         calendarStorage = dataStorage;
32                 
33         // Setup the main sizer.
34         
35         szrMain = new wxFlexGridSizer(2, 1, 0, 0);
36         szrMain->AddGrowableCol(0);
37         szrMain->AddGrowableRow(1);
38         szrMain->SetFlexibleDirection(wxBOTH);
39         szrMain->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
40         this->SetSizer(szrMain);
41         
42         // Setup the top menu.
43                 
44         ManipulatorCtrl = new XCCalendarManipulator(this, "XCCalendarManipulator Test", wxDefaultPosition, wxDefaultSize, calendarStorage);
45                 
46         // Setup the month view grid.
47         
48         wxDateTime DTNow = wxDateTime::Now();
49         int currentMonth = ((int)DTNow.GetMonth() + 1);
50         int currentYear = DTNow.GetYear();
51                 
52         XCCalendarMonthViewGrid CurrentMonthGrid = GenerateMonthGrid(currentMonth, currentYear);
53         szrMain->Add(ManipulatorCtrl, 1, wxEXPAND, 5);
54                 
55         // TODO: Get the list of hidden accounts and calendars.
56                 
57         vector<int> hideAccountsList = ManipulatorCtrl->GetHiddenAccountsList();
58         vector<int> hideCalendarsList = ManipulatorCtrl->GetHiddenCalendarsList();
59                 
60         MonthViewCtrl = new XCCalendarMonthView(this, "XCCalendarMonthView Test", wxDefaultPosition, wxDefaultSize, &CurrentMonthGrid, calendarStorage, &hideAccountsList, &hideCalendarsList);
61         szrMain->Add(MonthViewCtrl, 1, wxEXPAND, 5);
62         
63         // Connect events to the control.
64         
65         Connect(ID_CHANGEGRID, XCCALENDARCTRL_CHANGEGRID, wxCommandEventHandler(XCCalendarCtrl::UpdateGrid));
66         Connect(ID_HIDEENTRIES, XCCALENDARCTRL_HIDEACCOUNTENTRIES, wxCommandEventHandler(XCCalendarCtrl::HideAccountEntries));
67         Connect(ID_SHOWENTRIES, XCCALENDARCTRL_SHOWACCOUNTENTRIES, wxCommandEventHandler(XCCalendarCtrl::ShowAccountEntries));
68         Connect(ID_HIDECALENDARENTRIES, XCCALENDARCTRL_HIDECALENDARENTRIES, wxCommandEventHandler(XCCalendarCtrl::HideCalendarEntries));
69         Connect(ID_SHOWCALENDARENTRIES, XCCALENDARCTRL_SHOWCALENDARENTRIES, wxCommandEventHandler(XCCalendarCtrl::ShowCalendarEntries));
70         
71 }
73 XCCalendarCtrl::~XCCalendarCtrl(){
74         
75         // Destory the controls in the XCCalendarCtrl class.
76         
77 }
79 void XCCalendarCtrl::UpdateGrid(wxCommandEvent &event){
81         XCCalendarMonthView *OldGrid = nullptr;
82         
83         // Park the old grid.
85         OldGrid = MonthViewCtrl;
86         
87         // Get the list of hidden accounts and calendars.
88                 
89         vector<int> hideAccountsList = ManipulatorCtrl->GetHiddenAccountsList();
90         vector<int> hideCalendarsList = ManipulatorCtrl->GetHiddenCalendarsList();
91         
92         // Create a new grid.
93         
94         XCCalendarMonthViewGrid NewGrid = GenerateMonthGrid(ManipulatorCtrl->GetMonth(), ManipulatorCtrl->GetYear());
95         MonthViewCtrl = new XCCalendarMonthView(this, _(""), wxDefaultPosition, wxDefaultSize, &NewGrid, calendarStorage, &hideAccountsList, &hideCalendarsList);
97         // Detach the old grid and attach the new one.
98         
99         szrMain->Detach(1);
100         OldGrid->Show(false);
101         szrMain->Add(MonthViewCtrl, 1, wxEXPAND, 5);
102         szrMain->Layout();
103         
104         // Delete the old grid.
105         
106         delete OldGrid;
107         OldGrid = nullptr;
108         
111 void XCCalendarCtrl::HideAccountEntries(wxCommandEvent &accountData){
112         
113         // Get the list of calendar IDs for the account and go through 
114         // the list of entries in each day control.
115         
116         wxCommandEvent event(XCCALENDARMONTH_HIDEACCOUNTENTRIES);
117         event.SetInt(accountData.GetInt());
118         event.SetId(ID_HIDEENTRIES);
119         wxPostEvent(MonthViewCtrl, event);
120         
123 void XCCalendarCtrl::ShowAccountEntries(wxCommandEvent &accountData){
124         
125         // Get the list of calendar IDs for the account and go through 
126         // the list of entries in each day control.
127         
128         wxCommandEvent event(XCCALENDARMONTH_SHOWACCOUNTENTRIES);
129         event.SetInt(accountData.GetInt());
130         event.SetId(ID_SHOWENTRIES);
131         wxPostEvent(MonthViewCtrl, event);
132         
135 void XCCalendarCtrl::HideCalendarEntries(wxCommandEvent &calendarData){
136         
137         // Get the list of calendar IDs for the account and go through 
138         // the list of entries in each day control.
139         
140         wxCommandEvent event(XCCALENDARMONTH_HIDECALENDARENTRIES);
141         event.SetInt(calendarData.GetInt());
142         event.SetId(ID_HIDECALENDARENTRIES);
143         wxPostEvent(MonthViewCtrl, event);
144         
147 void XCCalendarCtrl::ShowCalendarEntries(wxCommandEvent &calendarData){
148         
149         // Get the list of calendar IDs for the account and go through 
150         // the list of entries in each day control.
151         
152         wxCommandEvent event(XCCALENDARMONTH_SHOWCALENDARENTRIES);
153         event.SetInt(calendarData.GetInt());
154         event.SetId(ID_SHOWCALENDARENTRIES);
155         wxPostEvent(MonthViewCtrl, event);
156         
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