From: Steve Brokenshire Date: Sun, 26 Jun 2016 10:40:47 +0000 (+0100) Subject: Added the XCCalendarMonthView class X-Git-Tag: release-0.02~113 X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=commitdiff_plain;h=22376cba960ea152be96f7507a49159907394590 Added the XCCalendarMonthView class --- diff --git a/source/widgets/XCCalendarMonthView.cpp b/source/widgets/XCCalendarMonthView.cpp new file mode 100644 index 0000000..9c23929 --- /dev/null +++ b/source/widgets/XCCalendarMonthView.cpp @@ -0,0 +1,132 @@ +// XCCalendarMonthView.cpp - Xestia Calendar XCCalendarMonthView widget class. +// +// (c) 2016 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 "XCCalendarMonthView.h" + +using namespace std; + +BEGIN_EVENT_TABLE(XCCalendarMonthView, wxFrame) +EVT_PAINT(XCCalendarMonthView::PaintFrameEvent) +END_EVENT_TABLE() + +XCCalendarMonthView::XCCalendarMonthView(const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid) + : wxFrame(NULL, wxID_ANY, title, pos, size){ + + MondayText = new XCCalendarMonthViewDayTitle(this, _("Monday"), wxDefaultPosition, wxDefaultSize); + TuesdayText = new XCCalendarMonthViewDayTitle(this, _("Tuesday"), wxDefaultPosition, wxDefaultSize); + WednesdayText = new XCCalendarMonthViewDayTitle(this, _("Wednesday"), wxDefaultPosition, wxDefaultSize); + ThursdayText = new XCCalendarMonthViewDayTitle(this, _("Thursday"), wxDefaultPosition, wxDefaultSize); + FridayText = new XCCalendarMonthViewDayTitle(this, _("Friday"), wxDefaultPosition, wxDefaultSize); + SaturdayText = new XCCalendarMonthViewDayTitle(this, _("Saturday"), wxDefaultPosition, wxDefaultSize); + SundayText = new XCCalendarMonthViewDayTitle(this, _("Sunday"), wxDefaultPosition, wxDefaultSize); + + WindowSizer->Add(MondayText, 1, wxEXPAND|wxALL, 0); + WindowSizer->Add(TuesdayText, 1, wxEXPAND|wxALL, 0); + WindowSizer->Add(WednesdayText, 1, wxEXPAND|wxALL, 0); + WindowSizer->Add(ThursdayText, 1, wxEXPAND|wxALL, 0); + WindowSizer->Add(FridayText, 1, wxEXPAND|wxALL, 0); + WindowSizer->Add(SaturdayText, 1, wxEXPAND|wxALL, 0); + WindowSizer->Add(SundayText, 1, wxEXPAND|wxALL, 0); + + ProcessGrid(grid); + + // Setup the days. + + // Setup the growable rows and columns. + + WindowSizer->AddGrowableCol(0); + WindowSizer->AddGrowableCol(1); + WindowSizer->AddGrowableCol(2); + WindowSizer->AddGrowableCol(3); + WindowSizer->AddGrowableCol(4); + WindowSizer->AddGrowableCol(5); + WindowSizer->AddGrowableCol(6); + WindowSizer->AddGrowableRow(1); + WindowSizer->AddGrowableRow(2); + WindowSizer->AddGrowableRow(3); + WindowSizer->AddGrowableRow(4); + WindowSizer->AddGrowableRow(5); + WindowSizer->SetFlexibleDirection( wxBOTH ); + WindowSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + this->SetSizer(WindowSizer); + WindowSizer->Fit(this); + this->Layout(); + this->SetBackgroundColour(wxColour(0,0,0)); + +} + +XCCalendarMonthView::~XCCalendarMonthView(){ + + + +} + +void XCCalendarMonthView::ProcessGrid(XCCalendarMonthViewGrid *grid){ + + // TODO: Delete the old calendar entries. + + // Add the new calendar entries. + + for (vector::iterator WeekIter = grid->WeekList.begin(); + WeekIter != grid->WeekList.end(); WeekIter++){ + + for (vector::iterator DayIter = (*WeekIter).DayList.begin(); + DayIter != (*WeekIter).DayList.end(); DayIter++){ + + // TODO: Add CalendarEntries. + + XCCalendarDay *CalendarDayItem = new XCCalendarDay(this, "XCCalendarMonthView Test", wxPoint(50, 50), wxSize(200, 200)); + + // Setup the control. + + CalendarDayItem->SetupControl((*DayIter).Day, (*DayIter).Month, (*DayIter).Year, (*DayIter).IsInMonth); + + CalendarDayList.push_back(CalendarDayItem); + WindowSizer->Add(CalendarDayItem, 1, wxEXPAND, 5); + + } + + } + +} + +void XCCalendarMonthView::Repaint(){ + + // Draw the border. + + this->Layout(); + +} + +void XCCalendarMonthView::PaintFrameEvent(wxPaintEvent &PaintEvent){ + + Repaint(); + +} + +void XCCalendarMonthView::ResizeFrameEvent(wxSizeEvent &SizeEvent){ + + // TODO: Check if window size is less than 120 pixels and if it is, + // switch to the small block mode. + + // Refresh the window. + + this->Refresh(); + +} \ No newline at end of file diff --git a/source/widgets/XCCalendarMonthView.h b/source/widgets/XCCalendarMonthView.h new file mode 100644 index 0000000..f81fa17 --- /dev/null +++ b/source/widgets/XCCalendarMonthView.h @@ -0,0 +1,63 @@ +// XCCalendarDayEntry.cpp - Xestia Calendar XCCalendarMonthView widget class. +// +// (c) 2016 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 + +#ifndef __WIDGETS_XCCALENDARMONTHVIEW_H__ +#define __WIDGETS_XCCALENDARMONTHVIEW_H__ + +#include +#include + +#include "../common/colour.h" +#include "../common/text.h" +#include "../common/events.h" +#include "../common/monthviewgen.h" + +#include "XCCalendarMonthView.h" +#include "XCCalendarMonthViewDayTitle.h" +#include "XCCalendarDay.h" + +class XCCalendarMonthView: public wxFrame +{ + + private: + wxFlexGridSizer *WindowSizer = new wxFlexGridSizer(0, 7, 1, 1); + vector CalendarDayList; + wxStaticText *NumberText = nullptr; + XCCalendarMonthViewDayTitle *MondayText = nullptr; + XCCalendarMonthViewDayTitle *TuesdayText = nullptr; + XCCalendarMonthViewDayTitle *WednesdayText = nullptr; + XCCalendarMonthViewDayTitle *ThursdayText = nullptr; + XCCalendarMonthViewDayTitle *FridayText = nullptr; + XCCalendarMonthViewDayTitle *SaturdayText = nullptr; + XCCalendarMonthViewDayTitle *SundayText = nullptr; + void ProcessGrid(XCCalendarMonthViewGrid *grid); + + void Repaint(); + + public: + XCCalendarMonthView(const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid); + ~XCCalendarMonthView(); + + void PaintFrameEvent(wxPaintEvent &PaintEvent); + void ResizeFrameEvent(wxSizeEvent &SizeEvent); + + DECLARE_EVENT_TABLE() + +}; + +#endif \ No newline at end of file