--- /dev/null
+// XCCalendarDay.cpp - Xestia Calendar XCCalendarDay 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 <http://www.gnu.org/licenses/>
+
+#include "XCCalendarDay.h"
+
+using namespace std;
+
+BEGIN_EVENT_TABLE(XCCalendarDay, wxFrame)
+EVT_PAINT(XCCalendarDay::PaintFrameEvent)
+EVT_SIZE(XCCalendarDay::ResizeFrameEvent)
+//EVT_COMMAND(wxID_ANY, XCCALENDARDAY_DESELECTOTHERENTRIES, XCCalendarDay::DeselectOthersEvent)
+END_EVENT_TABLE()
+
+XCCalendarDay::XCCalendarDay(const wxString& title, const wxPoint& pos, const wxSize& size)
+ : wxFrame(NULL, wxID_ANY, title, pos, size)
+{
+
+ Connect(wxID_ANY, XCCALENDARDAY_DESELECTOTHERENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectOthersEvent));
+
+ this->SetMinSize( wxSize( 100,100 ) );
+
+ AlertIconBitmap.LoadFile("AlertIcon-32.png", wxBITMAP_DEFAULT_TYPE);
+ PriorityIconBitmap.LoadFile("PriorityIcon-32.png", wxBITMAP_DEFAULT_TYPE);
+
+ AlertIcon->SetBitmap(AlertIconBitmap);
+ HighPriorityIcon->SetBitmap(PriorityIconBitmap);
+
+ WindowSizer->AddGrowableCol(0);
+ WindowSizer->AddGrowableRow(1);
+ WindowSizer->SetFlexibleDirection( wxBOTH );
+ WindowSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
+
+ NumberText = new wxStaticText(this, wxID_ANY, wxT("09"), wxDefaultPosition, wxDefaultSize, 0);
+ NumberText->SetFont(wxFont(24, 70, 90, 92, false, wxEmptyString));
+
+ TopSectionSizer->Add(HighPriorityIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
+ TopSectionSizer->Add(AlertIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
+ TopSectionSizer->Add(0, 0, 1, wxEXPAND, 5);
+ TopSectionSizer->Add(NumberText, 0, wxALL|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5);
+
+ // Setup the scrollable section.
+
+ Colour EventColour;
+ EventColour.red = 40; EventColour.green = 80; EventColour.blue = 80;
+
+ EventListFrame->SetSizer(EventListFrameSizer);
+ CalendarEntry1->SetColour(&EventColour);
+ CalendarEntry1->SetDisplayAlarm(false);
+ CalendarEntry1->SetDisplayHighPriority(false);
+ EventListFrameSizer->Add(CalendarEntry1, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+
+ EventColour.red = 255; EventColour.green = 0; EventColour.blue = 0;
+ CalendarEntry2->SetColour(&EventColour);
+ CalendarEntry2->SetDisplayAlarm(true);
+ CalendarEntry2->SetDisplayHighPriority(false);
+ EventListFrameSizer->Add(CalendarEntry2, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+
+ EventColour.red = 0; EventColour.green = 255; EventColour.blue = 0;
+ CalendarEntry3->SetColour(&EventColour);
+ CalendarEntry3->SetDisplayAlarm(false);
+ CalendarEntry3->SetDisplayHighPriority(false);
+ EventListFrameSizer->Add(CalendarEntry3, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+
+ EventColour.red = 0; EventColour.green = 0; EventColour.blue = 255;
+ CalendarEntry4->SetColour(&EventColour);
+ CalendarEntry4->SetDisplayAlarm(false);
+ CalendarEntry4->SetDisplayHighPriority(false);
+ EventListFrameSizer->Add(CalendarEntry4, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+
+ EventListFrameSizer->Add(CalendarEntry5, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+ EventListFrameSizer->Add(CalendarEntry6, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+ EventListFrameSizer->Add(CalendarEntry7, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+ EventListFrameSizer->Add(CalendarEntry8, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+ EventListFrameSizer->Add(CalendarEntry9, 0, wxEXPAND, 5);
+ EventListFrameSizer->Add(0, 5, 0, 0, 5);
+ EventListFrameSizer->Add(CalendarEntry10, 0, wxEXPAND, 5);
+
+ EventListFrame->SetScrollRate(0,1);
+ //EventListFrameSizer->FitInside(EventListFrame);
+ EventListFrameSizer->Fit(EventListFrame);
+ EventListFrameSizer->Layout();
+ WindowSizer->Fit(this);
+
+ // Setup the scroll window.
+
+ WindowSizer->Add(TopSectionSizer, 1, wxEXPAND, 5);
+ WindowSizer->Add(MainSectionSizer, 1, wxEXPAND, 5);
+ MainSectionSizer->Add(EventListFrame, 1, wxGROW | wxALL, 10);
+
+ this->SetSizer(WindowSizer);
+ this->SetSize(size);
+ this->Layout();
+ this->SetBackgroundStyle(wxBG_STYLE_PAINT);
+ this->Centre(wxBOTH);
+
+ CalendarEntryList.push_back(CalendarEntry1);
+ CalendarEntryList.push_back(CalendarEntry2);
+ CalendarEntryList.push_back(CalendarEntry3);
+ CalendarEntryList.push_back(CalendarEntry4);
+ CalendarEntryList.push_back(CalendarEntry5);
+ CalendarEntryList.push_back(CalendarEntry6);
+ CalendarEntryList.push_back(CalendarEntry7);
+ CalendarEntryList.push_back(CalendarEntry8);
+ CalendarEntryList.push_back(CalendarEntry9);
+ CalendarEntryList.push_back(CalendarEntry10);
+
+ UpdateTopIcons();
+
+}
+
+XCCalendarDay::~XCCalendarDay(){
+
+ // Destory the controls from the widget.
+
+}
+
+void XCCalendarDay::Repaint(){
+
+ wxPaintDC dc(this);
+
+ // Get the wxSizerItem for the top date and the entries part.
+
+ wxSizerItem *TopSectionSizerItem = WindowSizer->GetItem((size_t)0);
+ wxSizerItem *MainSectionSizerItem = WindowSizer->GetItem((size_t)1);
+ wxRect TopSizer = wxRect(WindowSizer->GetPosition(), WindowSizer->GetSize());
+
+ dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
+ dc.DrawRectangle(TopSectionSizerItem->GetRect());
+ dc.SetBrush(wxBrush(wxColor(225,225,225)));
+ dc.DrawRectangle(MainSectionSizerItem->GetRect());
+
+ // Draw the border.
+
+ this->Layout();
+
+ dc.SetBrush(wxBrush(wxColor(0,0,0), wxBRUSHSTYLE_TRANSPARENT));
+
+ wxPaintDC EventListFrameDC(EventListFrame);
+ EventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
+ EventListFrameDC.SetBrush(wxBrush(wxColor(225,225,225)));
+ EventListFrameDC.DrawRectangle(EventListFrame->GetClientRect());
+
+}
+
+void XCCalendarDay::UpdateTopIcons(){
+
+ bool AlarmFound = false;
+ bool HighPriorityFound = false;
+
+ for (vector<XCCalendarDayEntry*>::iterator EntryIter = CalendarEntryList.begin();
+ EntryIter != CalendarEntryList.end(); EntryIter++){
+
+ if ((*EntryIter)->GetDisplayAlarm() == true){
+
+ AlarmFound = true;
+
+ }
+
+ if ((*EntryIter)->GetDisplayHighPriority() == true){
+
+ HighPriorityFound = true;
+
+ }
+
+ if (AlarmFound == true && HighPriorityFound == true){
+
+ break;
+
+ }
+
+ }
+
+ AlertIcon->Show(AlarmFound);
+ HighPriorityIcon->Show(HighPriorityFound);
+
+}
+
+void XCCalendarDay::PaintFrameEvent(wxPaintEvent &PaintEvent)
+{
+
+ Repaint();
+
+}
+
+void XCCalendarDay::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();
+
+}
+
+void XCCalendarDay::DeselectOthersEvent(wxCommandEvent &DeselectEvent)
+{
+
+ int SelectedEntryID = DeselectEvent.GetInt();
+
+ wxCommandEvent DeselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
+
+ for (vector<XCCalendarDayEntry*>::iterator EntryIter = CalendarEntryList.begin();
+ EntryIter != CalendarEntryList.end(); EntryIter++){
+
+ if ((*EntryIter)->GetID() != SelectedEntryID){
+
+ wxPostEvent((*EntryIter), DeselectEntryEvent);
+
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+// XCCalendarDay.h - Xestia Calendar XCCalendarDay widget class header file.
+//
+// (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 <http://www.gnu.org/licenses/>
+
+#ifndef __WIDGETS_XCCALENDARDAY_H__
+#define __WIDGETS_XCCALENDARDAY_H__
+
+#include <wx/wx.h>
+#include <wx/dcbuffer.h>
+#include <vector>
+
+#include "XCCalendarDayEntry.h"
+#include "../common/events.h"
+
+class XCCalendarDay: public wxFrame
+{
+ private:
+ wxFlexGridSizer *WindowSizer = new wxFlexGridSizer(2, 1, 0, 0);
+ wxBoxSizer *TopSectionSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *MainSectionSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *EventListFrameSizer = new wxBoxSizer(wxVERTICAL);
+ wxStaticBitmap *HighPriorityIcon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(32,32), 0);
+ wxStaticBitmap *AlertIcon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(32,32), 0);
+ wxBitmap AlertIconBitmap;
+ wxBitmap PriorityIconBitmap;
+ wxStaticText *NumberText = nullptr;
+ wxScrolledWindow *EventListFrame = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
+ int CalendarEntrySeekNumber = 0;
+
+ vector<XCCalendarDayEntry*> CalendarEntryList;
+ XCCalendarDayEntry *CalendarEntry1 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 1", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry2 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 2", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry3 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 3", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry4 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 4", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry5 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 5", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry6 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 6", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry7 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 7", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry8 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 8", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry9 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 9", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+ XCCalendarDayEntry *CalendarEntry10 = new XCCalendarDayEntry(EventListFrame, "Calendar Entry 10", wxDefaultPosition, wxDefaultSize, CalendarEntrySeekNumber++);
+
+ void Repaint();
+
+ public:
+ XCCalendarDay(const wxString& title, const wxPoint& pos, const wxSize& size);
+ ~XCCalendarDay();
+ void PaintFrameEvent(wxPaintEvent &PaintEvent);
+ void ResizeFrameEvent(wxSizeEvent &SizeEvent);
+ void DeselectOthersEvent(wxCommandEvent &DeselectEvent);
+ void UpdateTopIcons();
+
+ DECLARE_EVENT_TABLE()
+};
+
+#endif
\ No newline at end of file