From: Steve Brokenshire <sbrokenshire@xestia.co.uk>
Date: Sun, 25 Dec 2016 01:26:05 +0000 (+0000)
Subject: Updated widgets
X-Git-Tag: release-0.02~73
X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=fb61a8df39e632cce6dfd8b421f410f041a25760;p=xestiacalendar%2F.git

Updated widgets

Updated XCCalendarCtrl and XCCalendarManipulator
---

diff --git a/source/widgets/XCCalendarCtrl.cpp b/source/widgets/XCCalendarCtrl.cpp
index a7af38e..893f150 100644
--- a/source/widgets/XCCalendarCtrl.cpp
+++ b/source/widgets/XCCalendarCtrl.cpp
@@ -20,7 +20,7 @@
 
 using namespace std; 
 
-XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent)
+XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *dataStorage)
 	: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize){
 	
 	// Setup the main sizer.
@@ -33,8 +33,8 @@ XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent)
 	this->SetSizer(szrMain);
 	
 	// Setup the top menu.
-	
-	ManipulatorCtrl = new XCCalendarManipulator(this, "XCCalendarManipulator Test", wxDefaultPosition, wxDefaultSize);
+		
+	ManipulatorCtrl = new XCCalendarManipulator(this, "XCCalendarManipulator Test", wxDefaultPosition, wxDefaultSize, dataStorage);
 		
 	// Setup the month view grid.
 	
diff --git a/source/widgets/XCCalendarCtrl.h b/source/widgets/XCCalendarCtrl.h
index d3a9cca..b8ed1d4 100644
--- a/source/widgets/XCCalendarCtrl.h
+++ b/source/widgets/XCCalendarCtrl.h
@@ -19,8 +19,6 @@
 #ifndef __WIDGETS_XCCALENDARCTRL_H__
 #define __WIDGETS_XCCALENDARCTRL_H__
 
-#endif
-
 #include <wx/wx.h>
 
 #include "events.h"
@@ -29,6 +27,7 @@
 #include "XCCalendarManipulator.h"
 
 #include "../common/monthviewgen.h"
+#include "../libraries/CalendarDataStorage/CalendarDataStorage.h"
 
 class XCCalendarCtrl: public wxPanel
 {
@@ -36,15 +35,18 @@ class XCCalendarCtrl: public wxPanel
 	private:
 		XCCalendarMonthView *MonthViewCtrl = nullptr;
 		XCCalendarManipulator *ManipulatorCtrl = nullptr;
-		wxFlexGridSizer* szrMain = nullptr;
+		wxFlexGridSizer	*szrMain = nullptr;
+		CalendarDataStorage *calendarStorage = nullptr;
 	
 	protected:
 		void UpdateGrid(wxCommandEvent &event);
 	
 	public:
-		XCCalendarCtrl(wxWindow *parent);
+		XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *storage);
 		~XCCalendarCtrl();
 	
 	//DECLARE_EVENT_TABLE()
 	
-};
\ No newline at end of file
+};
+
+#endif
\ No newline at end of file
diff --git a/source/widgets/XCCalendarManipulator.cpp b/source/widgets/XCCalendarManipulator.cpp
index 9268d61..7337a71 100644
--- a/source/widgets/XCCalendarManipulator.cpp
+++ b/source/widgets/XCCalendarManipulator.cpp
@@ -23,7 +23,8 @@ END_EVENT_TABLE()
 
 using namespace std;
 
-XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size)
+XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& title, 
+	const wxPoint& pos, const wxSize& size, CalendarDataStorage *dataStorage)
         : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){
 	
 	szrMain = new wxBoxSizer( wxVERTICAL );
@@ -31,7 +32,7 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
 	pnlMain->SetBackgroundColour(wxColour(40,40,40));
 	this->SetSizer(szrMain);
 	szrMain->Add(pnlMain, 0, wxEXPAND, 0);
-		
+	
 	// Setup the navigation section.
 		
 	szrNavigation = new wxBoxSizer( wxHORIZONTAL );
@@ -41,22 +42,28 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
 		
 	PreviousButton = new wxButton(pnlMain, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(32,32), 0|wxNO_BORDER);
 	NextButton = new wxButton(pnlMain, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(32,32), 0|wxNO_BORDER);
+	CalendarsButton = new wxButton(pnlMain, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(32,32), 0|wxNO_BORDER);
 	
 	wxMemoryInputStream PreviousIcon(icons_previous_png, sizeof(icons_previous_png));
 	wxMemoryInputStream NextIcon(icons_next_png, sizeof(icons_next_png));
+	wxMemoryInputStream CalendarsIcon(icons_calendars_png, sizeof(icons_calendars_png));
 		
 	wxImage icons_previous_png(PreviousIcon, wxBITMAP_TYPE_PNG);
 	PreviousIconBitmap = wxBitmap(icons_previous_png, -1);
 
 	wxImage icons_next_png(NextIcon, wxBITMAP_TYPE_PNG);
 	NextIconBitmap = wxBitmap(icons_next_png, -1);
-		
+
+	wxImage icons_calendars_png(CalendarsIcon, wxBITMAP_TYPE_PNG);
+	CalendarsIconBitmap = wxBitmap(icons_calendars_png, -1);
+
 	PreviousButton->SetBitmap(PreviousIconBitmap);
 	NextButton->SetBitmap(NextIconBitmap);
+	CalendarsButton->SetBitmap(CalendarsIconBitmap);
 		
 	// Setup the static text.
 		
-	DateButton = new wxButton(pnlMain, wxID_ANY, _("November 2016"), wxDefaultPosition, wxDefaultSize, 0|wxNO_BORDER);
+	DateButton = new wxButton(pnlMain, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0|wxNO_BORDER);
 		
 	wxFont Test;
 	
@@ -70,6 +77,7 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
 
 	DateButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::DateTextClick), NULL, this);
 	NextButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::NextMonth), NULL, this);
+	CalendarsButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::ShowCalendarsList), NULL, this);
 	PreviousButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::PreviousMonth), NULL, this);
 	
 	Connect(wxID_ANY, XCCALENDARMANIPULATOR_CHANGEGRID, wxCommandEventHandler(XCCalendarManipulator::ChangeGrid));
@@ -77,6 +85,7 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
 	// Setup the manipulator control.
 
 	szrNavigation->Add(PreviousButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+	szrNavigation->Add(CalendarsButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
 	szrNavigation->Add( 0, 0, 1, wxEXPAND, 5 );
 	szrNavigation->Add(DateButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
 	szrNavigation->Add( 0, 0, 1, wxEXPAND, 5 );
@@ -91,6 +100,15 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
 	Month = ((int)DTNow.GetMonth() + 1);
 	Year = DTNow.GetYear();
 	Moo->UpdateDate(Month, Year);
+	UpdateDateButtonText();
+	
+	// Setup the calendars list.
+	
+	calendarList = new XCCalendarList(this);
+	
+	// Setup the calendar data storage pointer.
+	
+	this->dataStorage = dataStorage;
 		
 }
 
@@ -190,6 +208,16 @@ void XCCalendarManipulator::PreviousMonth(wxCommandEvent &event){
 	
 }
 
+void XCCalendarManipulator::ShowCalendarsList(wxCommandEvent &event){
+	
+	// Update the list of calendars before showing.
+	
+	calendarList->SetPosition(wxPoint(CalendarsButton->GetScreenRect().GetLeft(), CalendarsButton->GetScreenRect().GetBottom()));
+	calendarList->UpdateCalendarList(dataStorage);
+	calendarList->Popup();
+	
+}
+
 void XCCalendarManipulator::UpdateDateButtonText(){
 	
 	// Update the date text.
diff --git a/source/widgets/XCCalendarManipulator.h b/source/widgets/XCCalendarManipulator.h
index bce03cc..1a69bc1 100644
--- a/source/widgets/XCCalendarManipulator.h
+++ b/source/widgets/XCCalendarManipulator.h
@@ -16,6 +16,9 @@
 // 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_XCCALENDARMANIPULATOR_H__
+#define __WIDGETS_XCCALENDARMANIPULATOR_H__
+
 #include <string>
 
 #include <wx/wx.h>
@@ -24,7 +27,9 @@
 
 #include "events.h"
 #include "XCCalendarMonthSelect.h"
+#include "XCCalendarList.h"
 #include "../bitmaps.h"
+#include "../libraries/CalendarDataStorage/CalendarDataStorage.h"
 
 class XCCalendarManipulator: public wxPanel
 {
@@ -35,12 +40,16 @@ class XCCalendarManipulator: public wxPanel
 		wxPanel *pnlMain = nullptr;
 		wxButton *PreviousButton = nullptr;
 		wxButton *NextButton = nullptr;
+		wxButton *CalendarsButton = nullptr;
 		wxButton *DateButton = nullptr;
 		XCCalendarMonthSelect *Moo = nullptr;
+		XCCalendarList *calendarList = nullptr;
+		CalendarDataStorage *dataStorage = nullptr;
 		int Month = 0;
 		int Year = 2016;
 		wxBitmap NextIconBitmap;
 		wxBitmap PreviousIconBitmap;
+		wxBitmap CalendarsIconBitmap;
 	
 		void UpdateDateButtonText();
 	protected:
@@ -50,12 +59,15 @@ class XCCalendarManipulator: public wxPanel
 		void ChangeGrid(wxCommandEvent &event);
 		void NextMonth(wxCommandEvent &event);
 		void PreviousMonth(wxCommandEvent &event);
+		void ShowCalendarsList(wxCommandEvent &event);
 	public:
-		XCCalendarManipulator(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size);
+		XCCalendarManipulator(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size, CalendarDataStorage *dataStorage);
 		~XCCalendarManipulator();
 		int GetMonth();
 		int GetYear();
 	
 	DECLARE_EVENT_TABLE()
 	
-};
\ No newline at end of file
+};
+
+#endif
\ No newline at end of file