Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial version of the XCCalendarDayEntry widget
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 18 Jun 2016 22:33:21 +0000 (23:33 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 18 Jun 2016 22:33:21 +0000 (23:33 +0100)
Basic version. Will be changed as progress is made on Xestia Calendar.

source/widgets/XCCalendarDayEntry.cpp [new file with mode: 0644]
source/widgets/XCCalendarDayEntry.h [new file with mode: 0644]

diff --git a/source/widgets/XCCalendarDayEntry.cpp b/source/widgets/XCCalendarDayEntry.cpp
new file mode 100644 (file)
index 0000000..f5f31b4
--- /dev/null
@@ -0,0 +1,232 @@
+// XCCalendarDayEntry.cpp - Xestia Calendar XCCalendarDayEntry 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 "XCCalendarDayEntry.h"
+
+BEGIN_EVENT_TABLE(XCCalendarDayEntry, wxPanel)
+EVT_PAINT(XCCalendarDayEntry::PaintFrameEvent)
+EVT_SIZE(XCCalendarDayEntry::ResizeFrameEvent)
+EVT_LEFT_DOWN(XCCalendarDayEntry::LeftClick)
+END_EVENT_TABLE()
+
+using namespace std;
+
+XCCalendarDayEntry::XCCalendarDayEntry(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size, const int id)
+        : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title)
+{
+
+       Connect(wxID_ANY, XCCALENDARDAYENTRY_DESELECT, wxCommandEventHandler(XCCalendarDayEntry::Deselect));
+       
+       DayPanel = parent->GetParent();
+       EntryID = id;
+       
+       this->SetMinSize(wxSize(65, 30));
+       
+       EventTextData = title.mb_str();
+       EventText = new wxStaticText(this, wxID_ANY, title, wxPoint(49, 8), wxDefaultSize, wxST_ELLIPSIZE_END);
+       
+       AlarmIconBitmap.LoadFile("AlertIcon.png", wxBITMAP_DEFAULT_TYPE);
+       PriorityIconBitmap.LoadFile("PriorityIcon.png", wxBITMAP_DEFAULT_TYPE);
+
+       AlarmIcon->SetBitmap(AlarmIconBitmap);
+       HighPriorityIcon->SetBitmap(PriorityIconBitmap);
+       
+       UpdateInformation();
+       
+}
+
+XCCalendarDayEntry::~XCCalendarDayEntry(){
+       
+       // Destory the controls from the widget.
+       
+}
+
+void XCCalendarDayEntry::Repaint(){
+       
+       wxPaintDC dc(this);
+
+       // Get the wxSizerItem for the top date and the entries part.
+
+       dc.SetBrush(wxBrush(wxColor(0,0,0), wxBRUSHSTYLE_TRANSPARENT));
+       
+       /*wxRect Test;
+       
+       Test.SetX(this->GetClientRect().GetX());
+       Test.SetY(this->GetClientRect().GetY());
+       Test.SetHeight(this->GetClientRect().GetHeight());
+       Test.SetWidth(this->GetClientRect().GetWidth());
+       
+       cout << Test.GetX() << "|" << Test.GetY() << "|" << Test.GetHeight() << "|" << Test.GetWidth() << "|" << endl;*/
+       
+       dc.DrawRectangle(this->GetClientRect());
+       
+       // Draw the calendar colour.
+       
+       dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
+       dc.SetBrush(wxBrush(wxColor(EntryColour.red,
+               EntryColour.green,
+               EntryColour.blue), wxBRUSHSTYLE_SOLID));
+       dc.DrawRectangle(wxRect(1,1,10,28));
+       
+}
+
+void XCCalendarDayEntry::UpdateInformation(){
+
+       PositionMode = 0;
+
+       // Check if the high priority icon needs to be displayed.
+       
+       if (HasHighPriority == true){
+               
+               HighPriorityIcon->SetPosition(wxPoint(FirstPosition,7));
+
+               HighPriorityIcon->Show(true);
+               
+               PositionMode++;
+               
+       } else {
+               
+               HighPriorityIcon->Show(false);
+               
+       }
+       
+       // Check if the alarm icon needs to be displayed.
+       
+       if (HasAlarm == true){
+               
+               switch(PositionMode){
+                       case 0:
+                               AlarmIcon->SetPosition(wxPoint(FirstPosition,7));
+                               break;
+                       case 1:
+                               AlarmIcon->SetPosition(wxPoint(SecondPosition,7));
+                               break;
+               }
+               
+               AlarmIcon->Show(true);
+               
+               PositionMode++;
+               
+       } else {
+               
+               AlarmIcon->Show(false);
+               
+       }
+       
+       // Now set the text.
+       
+       switch(PositionMode){
+               case 0:
+                       EventText->SetPosition(wxPoint(FirstPosition,8));
+                       break;
+               case 1:
+                       EventText->SetPosition(wxPoint(SecondPosition,8));
+                       break;
+               case 2:
+                       EventText->SetPosition(wxPoint(ThirdPosition,8));
+                       break;
+       }
+       
+}
+
+void XCCalendarDayEntry::PaintFrameEvent(wxPaintEvent &PaintEvent)
+{
+
+       Repaint();
+       
+}
+
+void XCCalendarDayEntry::ResizeFrameEvent(wxSizeEvent &SizeEvent)
+{
+       
+       // Adjust the Event text so it is displayed properly.
+       
+       switch(PositionMode){
+               case 0:
+                       EventText->SetSize(wxSize((this->GetClientRect().width - FirstPosition - 5),15));
+                       break;
+               case 1:
+                       EventText->SetSize(wxSize((this->GetClientRect().width - SecondPosition - 5),15));
+                       break;
+               case 2:
+                       EventText->SetSize(wxSize((this->GetClientRect().width - ThirdPosition - 5),15));
+                       break;
+       }
+       
+       // Refresh the window.
+       
+       this->Refresh();
+       
+}
+
+void XCCalendarDayEntry::LeftClick(wxMouseEvent &MouseEvent)
+{
+       
+       // Change the background of the widget to mark 
+       // the entry as selected.
+       
+       this->SetBackgroundColour(wxColor(255,215,0));
+       wxCommandEvent DeselectOthersEvent(XCCALENDARDAY_DESELECTOTHERENTRIES);
+       DeselectOthersEvent.SetInt(EntryID);
+       wxPostEvent(DayPanel, DeselectOthersEvent);
+       
+}
+
+void XCCalendarDayEntry::Deselect(wxCommandEvent &DeselectEvent){
+       
+       this->SetBackgroundColour(wxNullColour);
+       
+}
+
+void XCCalendarDayEntry::SetColour(Colour *ColourIn){
+       
+       EntryColour = *ColourIn;
+       
+}
+
+void XCCalendarDayEntry::SetDisplayAlarm(bool DisplayValue){
+       
+       HasAlarm = DisplayValue;
+       UpdateInformation();
+       
+}
+
+void XCCalendarDayEntry::SetDisplayHighPriority(bool DisplayValue){
+       
+       HasHighPriority = DisplayValue;
+       UpdateInformation();    
+       
+}
+
+bool XCCalendarDayEntry::GetDisplayAlarm(){
+       
+       return HasAlarm;
+       
+}
+
+bool XCCalendarDayEntry::GetDisplayHighPriority(){
+       
+       return HasHighPriority;
+       
+}
+
+int XCCalendarDayEntry::GetID(){
+       
+       return EntryID;
+       
+}
\ No newline at end of file
diff --git a/source/widgets/XCCalendarDayEntry.h b/source/widgets/XCCalendarDayEntry.h
new file mode 100644 (file)
index 0000000..de30c90
--- /dev/null
@@ -0,0 +1,78 @@
+// XCCalendarDayEntry.h - Xestia Calendar XCCalendarDayEntry 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/>
+
+#ifndef __WIDGETS_XCCALENDARDAYENTRY_H__
+#define __WIDGETS_XCCALENDARDAYENTRY_H__
+
+#include <wx/wx.h>
+#include "../common/colour.h"
+#include "../common/text.h"
+#include "../common/events.h"
+
+enum XCCalendarDayEntryMode {
+       XCCALENDARDAYENTRY_NORMAL,
+       XCCALENDARDAYENTRY_SMALL,
+};
+
+class XCCalendarDayEntry: public wxPanel
+{
+       
+       private:
+               wxWindow *DayPanel = nullptr;
+               string EventTextData = "";
+               wxStaticText *EventText = nullptr;
+               wxStaticBitmap *HighPriorityIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxPoint(14,7), wxDefaultSize, 0 );
+               wxStaticBitmap *AlarmIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxPoint(30,7), wxDefaultSize, 0 );
+               wxBitmap AlarmIconBitmap;
+               wxBitmap PriorityIconBitmap;
+       
+               Colour EntryColour;
+       
+               bool HasAlarm = false;
+               bool HasHighPriority = false;
+               int PositionMode = 0;
+               int EntryID = 0;
+               const int FirstPosition = 14;
+               const int SecondPosition = 30;
+               const int ThirdPosition = 49;
+       
+               void Repaint();
+               void RepaintSelected();
+       
+               void UpdateInformation();
+       
+       public:
+               XCCalendarDayEntry(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size, const int id);
+               ~XCCalendarDayEntry();
+       
+               void PaintFrameEvent(wxPaintEvent &PaintEvent);
+               void ResizeFrameEvent(wxSizeEvent &SizeEvent);
+               void LeftClick(wxMouseEvent &MouseEvent);
+               void Deselect(wxCommandEvent &DeselectEvent);
+       
+               void SetColour(Colour *ColourIn);
+               void SetDisplayAlarm(bool DisplayValue);
+               void SetDisplayHighPriority(bool DisplayValue);
+               int GetID();
+               bool GetDisplayAlarm();
+               bool GetDisplayHighPriority();
+       
+       DECLARE_EVENT_TABLE()
+};
+
+#endif
\ No newline at end of file
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