Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added the XCCalendarMonthView class
[xestiacalendar/.git] / source / widgets / XCCalendarMonthView.cpp
1 // XCCalendarMonthView.cpp - Xestia Calendar XCCalendarMonthView 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 "XCCalendarMonthView.h"
21 using namespace std;
23 BEGIN_EVENT_TABLE(XCCalendarMonthView, wxFrame)
24 EVT_PAINT(XCCalendarMonthView::PaintFrameEvent)
25 END_EVENT_TABLE()
27 XCCalendarMonthView::XCCalendarMonthView(const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid)
28         : wxFrame(NULL, wxID_ANY, title, pos, size){
29         
30         MondayText = new XCCalendarMonthViewDayTitle(this, _("Monday"), wxDefaultPosition, wxDefaultSize);
31         TuesdayText = new XCCalendarMonthViewDayTitle(this, _("Tuesday"), wxDefaultPosition, wxDefaultSize);
32         WednesdayText = new XCCalendarMonthViewDayTitle(this, _("Wednesday"), wxDefaultPosition, wxDefaultSize);
33         ThursdayText = new XCCalendarMonthViewDayTitle(this, _("Thursday"), wxDefaultPosition, wxDefaultSize);
34         FridayText = new XCCalendarMonthViewDayTitle(this, _("Friday"), wxDefaultPosition, wxDefaultSize);
35         SaturdayText = new XCCalendarMonthViewDayTitle(this, _("Saturday"), wxDefaultPosition, wxDefaultSize);
36         SundayText = new XCCalendarMonthViewDayTitle(this, _("Sunday"), wxDefaultPosition, wxDefaultSize);
37         
38         WindowSizer->Add(MondayText, 1, wxEXPAND|wxALL, 0);
39         WindowSizer->Add(TuesdayText, 1, wxEXPAND|wxALL, 0);
40         WindowSizer->Add(WednesdayText, 1, wxEXPAND|wxALL, 0);
41         WindowSizer->Add(ThursdayText, 1, wxEXPAND|wxALL, 0);
42         WindowSizer->Add(FridayText, 1, wxEXPAND|wxALL, 0);
43         WindowSizer->Add(SaturdayText, 1, wxEXPAND|wxALL, 0);   
44         WindowSizer->Add(SundayText, 1, wxEXPAND|wxALL, 0);
45         
46         ProcessGrid(grid);
47         
48         // Setup the days.
49         
50         // Setup the growable rows and columns.
51         
52         WindowSizer->AddGrowableCol(0);
53         WindowSizer->AddGrowableCol(1);
54         WindowSizer->AddGrowableCol(2);
55         WindowSizer->AddGrowableCol(3);
56         WindowSizer->AddGrowableCol(4);
57         WindowSizer->AddGrowableCol(5); 
58         WindowSizer->AddGrowableCol(6);
59         WindowSizer->AddGrowableRow(1);
60         WindowSizer->AddGrowableRow(2);
61         WindowSizer->AddGrowableRow(3);
62         WindowSizer->AddGrowableRow(4);
63         WindowSizer->AddGrowableRow(5);
64         WindowSizer->SetFlexibleDirection( wxBOTH );
65         WindowSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
66         
67         this->SetSizer(WindowSizer);
68         WindowSizer->Fit(this);
69         this->Layout();
70         this->SetBackgroundColour(wxColour(0,0,0));
71         
72 }
74 XCCalendarMonthView::~XCCalendarMonthView(){
75         
76         
77         
78 }
80 void XCCalendarMonthView::ProcessGrid(XCCalendarMonthViewGrid *grid){
81         
82         // TODO: Delete the old calendar entries.
83         
84         // Add the new calendar entries.
85         
86         for (vector<XCCalendarMonthViewGridDayWeek>::iterator WeekIter = grid->WeekList.begin();
87                 WeekIter != grid->WeekList.end(); WeekIter++){
88                 
89                 for (vector<XCCalendarMonthViewGridDayData>::iterator DayIter = (*WeekIter).DayList.begin();
90                         DayIter != (*WeekIter).DayList.end(); DayIter++){
91                                 
92                         // TODO: Add CalendarEntries.
93                                 
94                         XCCalendarDay *CalendarDayItem = new XCCalendarDay(this, "XCCalendarMonthView Test", wxPoint(50, 50), wxSize(200, 200));
95                                 
96                         // Setup the control.
97                                 
98                         CalendarDayItem->SetupControl((*DayIter).Day, (*DayIter).Month, (*DayIter).Year, (*DayIter).IsInMonth);
99                                 
100                         CalendarDayList.push_back(CalendarDayItem);
101                         WindowSizer->Add(CalendarDayItem, 1, wxEXPAND, 5);
102                                 
103                 }
104                         
105         }
106         
109 void XCCalendarMonthView::Repaint(){
110         
111         // Draw the border.
112         
113         this->Layout();
117 void XCCalendarMonthView::PaintFrameEvent(wxPaintEvent &PaintEvent){
119         Repaint();
120         
123 void XCCalendarMonthView::ResizeFrameEvent(wxSizeEvent &SizeEvent){
125         // TODO: Check if window size is less than 120 pixels and if it is,
126         // switch to the small block mode.
127         
128         // Refresh the window.
129         
130         this->Refresh();
131         
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