Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
widgets: Cleanup objects in destructors and minor code cleanup
[xestiacalendar/.git] / source / widgets / XCCalendarMonthSelect.cpp
1 // XCCalendarMonthSelect.cpp - Xestia Calendar XCCalendarMonthSelect 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 "XCCalendarMonthSelect.h" 
21 XCCalendarMonthSelect::XCCalendarMonthSelect(wxWindow *parent)
22         : wxPopupTransientWindow (parent){
23         
24         // Setup the main sizer.
25                 
26         szrMain = new wxBoxSizer( wxHORIZONTAL );
27         this->SetSizer(szrMain);
28         this->SetSize(wxSize(255, 40));
29                 
30         // Setup the month selection control.
31         
32         cmbMonth = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
33                 
34         cmbMonth->Append(_("January"));
35         cmbMonth->Append(_("February"));
36         cmbMonth->Append(_("March"));
37         cmbMonth->Append(_("April"));
38         cmbMonth->Append(_("May"));
39         cmbMonth->Append(_("June"));
40         cmbMonth->Append(_("July"));
41         cmbMonth->Append(_("August"));
42         cmbMonth->Append(_("September"));
43         cmbMonth->Append(_("October"));
44         cmbMonth->Append(_("November"));
45         cmbMonth->Append(_("December"));
47         szrMain->Add(cmbMonth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
49         // Setup the year selection control.
50         
51         spcYear = new wxSpinCtrl(this, wxID_ANY, _(""), wxDefaultPosition, wxSize(50,-1), wxSP_ARROW_KEYS, 0, 9999, 2016);
52         szrMain->Add(spcYear, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
54         // Setup the Change button.
55         
56         btnChange = new wxButton(this, wxID_ANY, _("Change"), wxDefaultPosition, wxDefaultSize);
57         szrMain->Add(btnChange, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
58         
59         // Setup the events.
60         
61         btnChange->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarMonthSelect::UpdateMonthView), NULL, this);
63         this->Layout();
64 }
66 XCCalendarMonthSelect::~XCCalendarMonthSelect(){
67         
68         szrMain->Clear();
69         
70         delete cmbMonth;
71         cmbMonth = nullptr;
72         
73         delete spcYear;
74         spcYear = nullptr;
75         
76         btnChange->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarMonthSelect::UpdateMonthView), NULL, this);
77         delete btnChange;
78         btnChange = nullptr;
79         
80         this->SetSizer(nullptr, true);
81         
82 }
84 void XCCalendarMonthSelect::UpdateDate(int Month, int Year){
85         
86         cmbMonth->SetSelection((Month - 1));
87         spcYear->SetValue(Year);
88         
89 }
91 void XCCalendarMonthSelect::UpdateMonthView(wxCommandEvent &event){
92         
93         // Post an event back to the parent updating the calendar
94         // with the new month.
95         
96         this->Dismiss();
97         wxCommandEvent UpdateGrid(XCCALENDARMANIPULATOR_CHANGEGRID);
98         UpdateGrid.SetId(ID_CHANGEGRID);
99         wxPostEvent(this->GetParent(), UpdateGrid);
100         
103 int XCCalendarMonthSelect::GetMonth(){
104         
105         return (cmbMonth->GetSelection() + 1);
106         
109 int XCCalendarMonthSelect::GetYear(){
110         
111         return spcYear->GetValue();
112         
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