From 961583be6526b42c434c30b540b90fc06d988a0d Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Wed, 19 Jul 2017 23:23:45 +0100 Subject: [PATCH] frmCalendarSelectMonth: Implemented only for Win32 --- .../frmCalendarSelectMonth.cpp | 107 ++++++++++++++++++ .../frmCalendarSelectMonth.h | 45 ++++++++ 2 files changed, 152 insertions(+) create mode 100644 source/forms/calendarselectmonth/frmCalendarSelectMonth.cpp create mode 100644 source/forms/calendarselectmonth/frmCalendarSelectMonth.h diff --git a/source/forms/calendarselectmonth/frmCalendarSelectMonth.cpp b/source/forms/calendarselectmonth/frmCalendarSelectMonth.cpp new file mode 100644 index 0000000..8d68227 --- /dev/null +++ b/source/forms/calendarselectmonth/frmCalendarSelectMonth.cpp @@ -0,0 +1,107 @@ +// frmCalendarSelectMonth.cpp - Xestia Calendar frmCalendarSelectMonth form +// +// (c) 2016-2017 Xestia Software Development. +// +// This file is part of Xestia Calendar. +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Calendar. If not, see + +#include "frmCalendarSelectMonth.h" + +frmCalendarSelectMonth::frmCalendarSelectMonth(wxWindow *parent) + : wxDialog(parent, wxID_ANY, _("Select Month"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL, "") /* wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, "") */ { + + // Setup the main sizer. + + szrMain = new wxBoxSizer(wxHORIZONTAL); + this->SetSizer(szrMain); +#if defined(WIN32) + this->SetMinSize(wxSize(255, 80)); + this->SetSize(wxSize(255, 80)); +#else + this->SetMinSize(wxSize(255, 40)); + this->SetSize(wxSize(255, 40)); +#endif + + // Setup the month selection control. + + cmbMonth = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); + + cmbMonth->Append(_("January")); + cmbMonth->Append(_("February")); + cmbMonth->Append(_("March")); + cmbMonth->Append(_("April")); + cmbMonth->Append(_("May")); + cmbMonth->Append(_("June")); + cmbMonth->Append(_("July")); + cmbMonth->Append(_("August")); + cmbMonth->Append(_("September")); + cmbMonth->Append(_("October")); + cmbMonth->Append(_("November")); + cmbMonth->Append(_("December")); + + szrMain->Add(cmbMonth, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // Setup the year selection control. + + spcYear = new wxSpinCtrl(this, wxID_ANY, _(""), wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 0, 9999, 2016); + szrMain->Add(spcYear, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // Setup the Change button. + + btnChange = new wxButton(this, wxID_ANY, _("Change"), wxDefaultPosition, wxDefaultSize); + szrMain->Add(btnChange, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + // Setup the events. + + btnChange->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(frmCalendarSelectMonth::UpdateMonthView), NULL, this); + + this->Layout(); +} + +frmCalendarSelectMonth::~frmCalendarSelectMonth() { + + + +} + +void frmCalendarSelectMonth::UpdateDate(int Month, int Year) { + + cmbMonth->SetSelection((Month - 1)); + spcYear->SetValue(Year); + +} + +void frmCalendarSelectMonth::UpdateMonthView(wxCommandEvent &event) { + + // Post an event back to the parent updating the calendar + // with the new month. + + this->Close(); + wxCommandEvent UpdateGrid(XCCALENDARMANIPULATOR_CHANGEGRID); + UpdateGrid.SetId(ID_CHANGEGRID); + wxPostEvent(this->GetParent(), UpdateGrid); + +} + +int frmCalendarSelectMonth::GetMonth() { + + return (cmbMonth->GetSelection() + 1); + +} + +int frmCalendarSelectMonth::GetYear() { + + return spcYear->GetValue(); + +} \ No newline at end of file diff --git a/source/forms/calendarselectmonth/frmCalendarSelectMonth.h b/source/forms/calendarselectmonth/frmCalendarSelectMonth.h new file mode 100644 index 0000000..3641705 --- /dev/null +++ b/source/forms/calendarselectmonth/frmCalendarSelectMonth.h @@ -0,0 +1,45 @@ +// frmCalendarSelectMonth.h - Xestia Calendar frmCalendarSelectMonth form header +// +// (c) 2016-2017 Xestia Software Development. +// +// This file is part of Xestia Calendar. +// +// Xestia Calendar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Calendar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Calendar. If not, see + +#ifndef __FORMS_FRMCALENDARSELECTMONTH_H__ +#define __FORMS_FRMCALENDARSELECTMONTH_H__ + +#include +#include + +#include "events.h" + +class frmCalendarSelectMonth : public wxDialog +{ +private: + wxBoxSizer *szrMain = nullptr; + wxChoice *cmbMonth = nullptr; + wxSpinCtrl *spcYear = nullptr; + wxButton *btnChange = nullptr; +protected: + void UpdateMonthView(wxCommandEvent &event); +public: + frmCalendarSelectMonth(wxWindow *parent); + ~frmCalendarSelectMonth(); + void UpdateDate(int Month, int Year); + int GetMonth(); + int GetYear(); + +}; + +#endif \ No newline at end of file -- 2.39.2