1 // XCCalendarMonthSelect.cpp - Xestia Calendar XCCalendarMonthSelect widget class.
3 // (c) 2016 Xestia Software Development.
5 // This file is part of Xestia Calendar.
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.
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.
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){
24 // Setup the main sizer.
26 szrMain = new wxBoxSizer( wxHORIZONTAL );
27 this->SetSizer(szrMain);
28 this->SetSize(wxSize(255, 40));
30 // Setup the month selection control.
32 cmbMonth = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
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.
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.
56 btnChange = new wxButton(this, wxID_ANY, _("Change"), wxDefaultPosition, wxDefaultSize);
57 szrMain->Add(btnChange, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
61 btnChange->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarMonthSelect::UpdateMonthView), NULL, this);
66 XCCalendarMonthSelect::~XCCalendarMonthSelect(){
76 btnChange->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarMonthSelect::UpdateMonthView), NULL, this);
80 this->SetSizer(nullptr, true);
84 void XCCalendarMonthSelect::UpdateDate(int Month, int Year){
86 cmbMonth->SetSelection((Month - 1));
87 spcYear->SetValue(Year);
91 void XCCalendarMonthSelect::UpdateMonthView(wxCommandEvent &event){
93 // Post an event back to the parent updating the calendar
94 // with the new month.
97 wxCommandEvent UpdateGrid(XCCALENDARMANIPULATOR_CHANGEGRID);
98 UpdateGrid.SetId(ID_CHANGEGRID);
99 wxPostEvent(this->GetParent(), UpdateGrid);
103 int XCCalendarMonthSelect::GetMonth(){
105 return (cmbMonth->GetSelection() + 1);
109 int XCCalendarMonthSelect::GetYear(){
111 return spcYear->GetValue();