Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
widgets: Updated and added widgets
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 26 Nov 2016 23:29:59 +0000 (23:29 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 26 Nov 2016 23:29:59 +0000 (23:29 +0000)
12 files changed:
source/widgets/XCCalendarCtrl.cpp [new file with mode: 0644]
source/widgets/XCCalendarCtrl.h [new file with mode: 0644]
source/widgets/XCCalendarDay.cpp
source/widgets/XCCalendarDay.h
source/widgets/XCCalendarDayEntry.cpp
source/widgets/XCCalendarDayEntry.h
source/widgets/XCCalendarManipulator.cpp [new file with mode: 0644]
source/widgets/XCCalendarManipulator.h [new file with mode: 0644]
source/widgets/XCCalendarMonthSelect.cpp [new file with mode: 0644]
source/widgets/XCCalendarMonthSelect.h [new file with mode: 0644]
source/widgets/XCCalendarMonthView.cpp
source/widgets/XCCalendarMonthView.h

diff --git a/source/widgets/XCCalendarCtrl.cpp b/source/widgets/XCCalendarCtrl.cpp
new file mode 100644 (file)
index 0000000..a7af38e
--- /dev/null
@@ -0,0 +1,82 @@
+// XCCalendarCtrl.cpp - Xestia Calendar XCCalendarCtrl 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 "XCCalendarCtrl.h"
+
+using namespace std; 
+
+XCCalendarCtrl::XCCalendarCtrl(wxWindow *parent)
+       : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize){
+       
+       // Setup the main sizer.
+       
+       szrMain = new wxFlexGridSizer(2, 1, 0, 0);
+       szrMain->AddGrowableCol(0);
+       szrMain->AddGrowableRow(1);
+       szrMain->SetFlexibleDirection(wxBOTH);
+       szrMain->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
+       this->SetSizer(szrMain);
+       
+       // Setup the top menu.
+       
+       ManipulatorCtrl = new XCCalendarManipulator(this, "XCCalendarManipulator Test", wxDefaultPosition, wxDefaultSize);
+               
+       // Setup the month view grid.
+       
+       XCCalendarMonthViewGrid CurrentMonthGrid = GenerateMonthGrid(11, 2016);
+       szrMain->Add(ManipulatorCtrl, 1, wxEXPAND, 5);
+               
+       MonthViewCtrl = new XCCalendarMonthView(this, "XCCalendarMonthView Test", wxDefaultPosition, wxDefaultSize, &CurrentMonthGrid);
+       szrMain->Add(MonthViewCtrl, 1, wxEXPAND, 5);
+       
+       Connect(wxID_ANY, XCCALENDARCTRL_CHANGEGRID, wxCommandEventHandler(XCCalendarCtrl::UpdateGrid));
+       
+}
+
+XCCalendarCtrl::~XCCalendarCtrl(){
+       
+       // Destory the controls in the XCCalendarCtrl class.
+       
+}
+
+void XCCalendarCtrl::UpdateGrid(wxCommandEvent &event){
+
+       XCCalendarMonthView *OldGrid = nullptr;
+       
+       // Park the old grid.
+
+       OldGrid = MonthViewCtrl;
+       
+       // Create a new grid.
+       
+       XCCalendarMonthViewGrid NewGrid = GenerateMonthGrid(ManipulatorCtrl->GetMonth(), ManipulatorCtrl->GetYear());
+       MonthViewCtrl = new XCCalendarMonthView(this, _(""), wxDefaultPosition, wxDefaultSize, &NewGrid);
+
+       // Detach the old grid and attach the new one.
+       
+       szrMain->Detach(1);
+       OldGrid->Show(false);
+       szrMain->Add(MonthViewCtrl, 1, wxEXPAND, 5);
+       szrMain->Layout();
+       
+       // Delete the old grid.
+       
+       delete OldGrid;
+       OldGrid = nullptr;
+       
+}
\ No newline at end of file
diff --git a/source/widgets/XCCalendarCtrl.h b/source/widgets/XCCalendarCtrl.h
new file mode 100644 (file)
index 0000000..d3a9cca
--- /dev/null
@@ -0,0 +1,50 @@
+// XCCalendarCtrl.h - Xestia Calendar XCCalendarCtrl 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_XCCALENDARCTRL_H__
+#define __WIDGETS_XCCALENDARCTRL_H__
+
+#endif
+
+#include <wx/wx.h>
+
+#include "events.h"
+
+#include "XCCalendarMonthView.h"
+#include "XCCalendarManipulator.h"
+
+#include "../common/monthviewgen.h"
+
+class XCCalendarCtrl: public wxPanel
+{
+       
+       private:
+               XCCalendarMonthView *MonthViewCtrl = nullptr;
+               XCCalendarManipulator *ManipulatorCtrl = nullptr;
+               wxFlexGridSizer* szrMain = nullptr;
+       
+       protected:
+               void UpdateGrid(wxCommandEvent &event);
+       
+       public:
+               XCCalendarCtrl(wxWindow *parent);
+               ~XCCalendarCtrl();
+       
+       //DECLARE_EVENT_TABLE()
+       
+};
\ No newline at end of file
index 15c8c65..bc8dc46 100644 (file)
@@ -33,11 +33,19 @@ XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPo
 
        this->SetMinSize( wxSize( 100,100 ) );
        
-       AlertIconBitmap.LoadFile("AlertIcon-32.png", wxBITMAP_DEFAULT_TYPE);
-       PriorityIconBitmap.LoadFile("PriorityIcon-32.png", wxBITMAP_DEFAULT_TYPE);
+       // Setip the icons.
+               
+       wxMemoryInputStream alerticon(icons_alert32_png, sizeof(icons_alert32_png));
+       wxMemoryInputStream priorityicon(icons_priority32_png, sizeof(icons_priority32_png));
+       
+       wxImage icons_alert_png(alerticon, wxBITMAP_TYPE_PNG);
+       wxBitmap imgAlertIcon(icons_alert_png, -1);
+
+       wxImage icons_priority_png(priorityicon, wxBITMAP_TYPE_PNG);
+       wxBitmap imgPriorityIcon(icons_priority_png, -1);
        
-       AlertIcon->SetBitmap(AlertIconBitmap);
-       HighPriorityIcon->SetBitmap(PriorityIconBitmap);        
+       AlertIcon->SetBitmap(imgAlertIcon);
+       HighPriorityIcon->SetBitmap(imgPriorityIcon);
        
        WindowSizer->AddGrowableCol(0);
        WindowSizer->AddGrowableRow(1);
@@ -58,7 +66,7 @@ XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPo
        EventColour.red = 40; EventColour.green = 80; EventColour.blue = 80;
        
        EventListFrame->SetSizer(EventListFrameSizer);
-       CalendarEntry1->SetColour(&EventColour);
+       /*CalendarEntry1->SetColour(&EventColour);
        CalendarEntry1->SetDisplayAlarm(false);
        CalendarEntry1->SetDisplayHighPriority(false);
        EventListFrameSizer->Add(CalendarEntry1, 0, wxEXPAND, 5);
@@ -95,7 +103,7 @@ XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPo
        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);
+       EventListFrameSizer->Add(CalendarEntry10, 0, wxEXPAND, 5);*/
 
        EventListFrame->SetScrollRate(0,1);
        //EventListFrameSizer->FitInside(EventListFrame);
@@ -115,7 +123,7 @@ XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPo
        this->SetBackgroundStyle(wxBG_STYLE_PAINT);
        this->Centre(wxBOTH);
        
-       CalendarEntryList.push_back(CalendarEntry1);
+       /*CalendarEntryList.push_back(CalendarEntry1);
        CalendarEntryList.push_back(CalendarEntry2);
        CalendarEntryList.push_back(CalendarEntry3);
        CalendarEntryList.push_back(CalendarEntry4);
@@ -124,7 +132,7 @@ XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPo
        CalendarEntryList.push_back(CalendarEntry7);
        CalendarEntryList.push_back(CalendarEntry8);
        CalendarEntryList.push_back(CalendarEntry9);
-       CalendarEntryList.push_back(CalendarEntry10);
+       CalendarEntryList.push_back(CalendarEntry10);*/
        
        UpdateTopIcons();
        
index aed2bca..580c4cf 100644 (file)
 
 #include <wx/wx.h>
 #include <wx/dcbuffer.h>
+#include <wx/mstream.h>
 #include <vector>
 
 #include "XCCalendarDayEntry.h"
 #include "XCCalendarMonthView.h"
 #include "../common/events.h"
+#include "../bitmaps.h"
 
 class XCCalendarMonthView;
 
@@ -47,16 +49,6 @@ class XCCalendarDay: public wxPanel
                bool IsInMonth = false;
        
                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();
        
index 4eb9baf..047bc4a 100644 (file)
@@ -36,10 +36,16 @@ XCCalendarDayEntry::XCCalendarDayEntry(wxWindow* parent, const wxString& title,
        
        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);
 
+       wxMemoryInputStream alerticon(icons_alert_png, sizeof(icons_alert_png));
+       wxMemoryInputStream priorityicon(icons_priority_png, sizeof(icons_priority_png));
+               
+       wxImage icons_alert_png(alerticon, wxBITMAP_TYPE_PNG);
+       AlarmIconBitmap = wxBitmap(icons_alert_png, -1);
+
+       wxImage icons_priority_png(priorityicon, wxBITMAP_TYPE_PNG);
+       PriorityIconBitmap = wxBitmap(icons_priority_png, -1);
+               
        AlarmIcon->SetBitmap(AlarmIconBitmap);
        HighPriorityIcon->SetBitmap(PriorityIconBitmap);
 
index de30c90..33a18ca 100644 (file)
 #define __WIDGETS_XCCALENDARDAYENTRY_H__
 
 #include <wx/wx.h>
+#include <wx/mstream.h>
+
 #include "../common/colour.h"
 #include "../common/text.h"
 #include "../common/events.h"
+#include "../bitmaps.h"
 
 enum XCCalendarDayEntryMode {
        XCCALENDARDAYENTRY_NORMAL,
diff --git a/source/widgets/XCCalendarManipulator.cpp b/source/widgets/XCCalendarManipulator.cpp
new file mode 100644 (file)
index 0000000..9268d61
--- /dev/null
@@ -0,0 +1,257 @@
+// XCCalendarManipulator.cpp - Xestia Calendar XCCalendarManipulator 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 "XCCalendarManipulator.h"
+
+BEGIN_EVENT_TABLE(XCCalendarManipulator, wxPanel)
+END_EVENT_TABLE()
+
+using namespace std;
+
+XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size)
+        : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){
+       
+       szrMain = new wxBoxSizer( wxVERTICAL );
+       pnlMain = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(500, 50), wxTAB_TRAVERSAL);
+       pnlMain->SetBackgroundColour(wxColour(40,40,40));
+       this->SetSizer(szrMain);
+       szrMain->Add(pnlMain, 0, wxEXPAND, 0);
+               
+       // Setup the navigation section.
+               
+       szrNavigation = new wxBoxSizer( wxHORIZONTAL );
+       pnlMain->SetSizer(szrNavigation);
+               
+       // Add next month and previous month buttons.
+               
+       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);
+       
+       wxMemoryInputStream PreviousIcon(icons_previous_png, sizeof(icons_previous_png));
+       wxMemoryInputStream NextIcon(icons_next_png, sizeof(icons_next_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);
+               
+       PreviousButton->SetBitmap(PreviousIconBitmap);
+       NextButton->SetBitmap(NextIconBitmap);
+               
+       // Setup the static text.
+               
+       DateButton = new wxButton(pnlMain, wxID_ANY, _("November 2016"), wxDefaultPosition, wxDefaultSize, 0|wxNO_BORDER);
+               
+       wxFont Test;
+       
+       Test.SetWeight(wxFONTWEIGHT_BOLD);
+       Test.SetPointSize(18);
+               
+       DateButton->SetFont(Test);
+       DateButton->SetForegroundColour(wxColour(255,255,255));
+       
+       // Setup the event controls.
+
+       DateButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::DateTextClick), NULL, this);
+       NextButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::NextMonth), NULL, this);
+       PreviousButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::PreviousMonth), NULL, this);
+       
+       Connect(wxID_ANY, XCCALENDARMANIPULATOR_CHANGEGRID, wxCommandEventHandler(XCCalendarManipulator::ChangeGrid));
+       
+       // Setup the manipulator control.
+
+       szrNavigation->Add(PreviousButton, 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 );
+       szrNavigation->Add(NextButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+       szrNavigation->Layout();
+               
+       // Setup the month selection control.
+       
+       wxDateTime DTNow = wxDateTime::Now();
+       
+       Moo = new XCCalendarMonthSelect(this);
+       Month = ((int)DTNow.GetMonth() + 1);
+       Year = DTNow.GetYear();
+       Moo->UpdateDate(Month, Year);
+               
+}
+
+XCCalendarManipulator::~XCCalendarManipulator(){
+       
+       // Destory the controls from the widget.
+       
+}
+
+void XCCalendarManipulator::DateTextClick(wxCommandEvent &event){
+       
+       // Bring up a popup control to select the month and year.
+       
+       Moo->SetPosition(wxPoint(DateButton->GetScreenRect().GetLeft(), DateButton->GetScreenRect().GetBottom()));
+       Moo->UpdateDate(Month, Year);
+       Moo->Popup();
+       
+}
+
+void XCCalendarManipulator::ChangeGrid(wxCommandEvent &event){
+       
+       if (Month == Moo->GetMonth() && Year == Moo->GetYear()){
+               return;
+       }
+       
+       Month = Moo->GetMonth();
+       Year = Moo->GetYear();
+       
+       // Post an event to the parent control to update the grid.
+       
+       wxCommandEvent ChangeGrid(XCCALENDARCTRL_CHANGEGRID);
+       wxPostEvent(this->GetParent(), ChangeGrid);
+       
+       UpdateDateButtonText();
+       
+}
+
+void XCCalendarManipulator::NextMonth(wxCommandEvent &event){
+       
+       int NewMonth = 1;
+       int NewYear = 0;
+       
+       // Get the current month and year.
+       
+       NewMonth = Moo->GetMonth();
+       NewYear = Moo->GetYear();
+
+       if (NewMonth == 12){
+               NewMonth = 1;
+               NewYear++;
+       } else {
+               NewMonth++;
+       }
+       
+       Month = NewMonth;
+       Year = NewYear;
+
+       Moo->UpdateDate(Month, Year);
+       
+       // Post an event to the parent control to update the grid.
+       
+       wxCommandEvent ChangeGrid(XCCALENDARCTRL_CHANGEGRID);
+       wxPostEvent(this->GetParent(), ChangeGrid);
+
+       UpdateDateButtonText();
+       
+}
+
+void XCCalendarManipulator::PreviousMonth(wxCommandEvent &event){
+       
+       int NewMonth = 1;
+       int NewYear = 0;
+       
+       // Get the current month and year.
+       
+       NewMonth = Moo->GetMonth();
+       NewYear = Moo->GetYear();
+
+       if (NewMonth == 1){
+               NewMonth = 12;
+               NewYear--;
+       } else {
+               NewMonth--;
+       }
+
+       Month = NewMonth;
+       Year = NewYear;
+       
+       Moo->UpdateDate(Month, Year);
+       
+       // Post an event to the parent control to update the grid.
+       
+       wxCommandEvent ChangeGrid(XCCALENDARCTRL_CHANGEGRID);
+       wxPostEvent(this->GetParent(), ChangeGrid);
+       
+       UpdateDateButtonText();
+       
+}
+
+void XCCalendarManipulator::UpdateDateButtonText(){
+       
+       // Update the date text.
+       
+       string NewDateText = "";
+       
+       switch (Moo->GetMonth()){
+               case 1:
+                       NewDateText = _("January");
+                       break;
+               case 2:
+                       NewDateText = _("February");
+                       break;
+               case 3:
+                       NewDateText = _("March");
+                       break;
+               case 4:
+                       NewDateText = _("April");
+                       break;
+               case 5:
+                       NewDateText = _("May");
+                       break;
+               case 6:
+                       NewDateText = _("June");
+                       break;
+               case 7:
+                       NewDateText = _("July");
+                       break;
+               case 8:
+                       NewDateText = _("August");
+                       break;
+               case 9:
+                       NewDateText = _("September");
+                       break;
+               case 10:
+                       NewDateText = _("October");
+                       break;
+               case 11:
+                       NewDateText = _("November");
+                       break;
+               case 12:
+                       NewDateText = _("December");
+                       break;
+       }
+       
+       NewDateText += " ";
+       
+       NewDateText += to_string(Year);
+       
+       DateButton->SetLabel(NewDateText);
+       szrMain->Layout();
+       
+}
+
+int XCCalendarManipulator::GetMonth(){
+       
+       return Month;
+       
+}
+
+int XCCalendarManipulator::GetYear(){
+       
+       return Year;
+       
+}
\ No newline at end of file
diff --git a/source/widgets/XCCalendarManipulator.h b/source/widgets/XCCalendarManipulator.h
new file mode 100644 (file)
index 0000000..bce03cc
--- /dev/null
@@ -0,0 +1,61 @@
+// XCCalendarManipulator.h - Xestia Calendar XCCalendarManipulator 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/> 
+
+#include <string>
+
+#include <wx/wx.h>
+#include <wx/dcbuffer.h>
+#include <wx/mstream.h>
+
+#include "events.h"
+#include "XCCalendarMonthSelect.h"
+#include "../bitmaps.h"
+
+class XCCalendarManipulator: public wxPanel
+{
+
+       private:
+               wxBoxSizer *szrMain = nullptr;
+               wxBoxSizer *szrNavigation = nullptr;
+               wxPanel *pnlMain = nullptr;
+               wxButton *PreviousButton = nullptr;
+               wxButton *NextButton = nullptr;
+               wxButton *DateButton = nullptr;
+               XCCalendarMonthSelect *Moo = nullptr;
+               int Month = 0;
+               int Year = 2016;
+               wxBitmap NextIconBitmap;
+               wxBitmap PreviousIconBitmap;
+       
+               void UpdateDateButtonText();
+       protected:
+               void DateTextMouseover(wxMouseEvent &event);
+               void DateTextMouseout(wxMouseEvent &event);
+               void DateTextClick(wxCommandEvent &event);
+               void ChangeGrid(wxCommandEvent &event);
+               void NextMonth(wxCommandEvent &event);
+               void PreviousMonth(wxCommandEvent &event);
+       public:
+               XCCalendarManipulator(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size);
+               ~XCCalendarManipulator();
+               int GetMonth();
+               int GetYear();
+       
+       DECLARE_EVENT_TABLE()
+       
+};
\ No newline at end of file
diff --git a/source/widgets/XCCalendarMonthSelect.cpp b/source/widgets/XCCalendarMonthSelect.cpp
new file mode 100644 (file)
index 0000000..94e9421
--- /dev/null
@@ -0,0 +1,99 @@
+// XCCalendarMonthSelect.cpp - Xestia Calendar XCCalendarMonthSelect 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 "XCCalendarMonthSelect.h" 
+
+XCCalendarMonthSelect::XCCalendarMonthSelect(wxWindow *parent)
+       : wxPopupTransientWindow (parent){
+       
+       // Setup the main sizer.
+               
+       szrMain = new wxBoxSizer( wxHORIZONTAL );
+       this->SetSizer(szrMain);
+       this->SetSize(wxSize(255, 40));
+               
+       // Setup the month selection control.
+       
+       cmbMonth = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
+               
+       cmbMonth->Append(_("January"));
+       cmbMonth->Append(_("February"));
+       cmbMonth->Append(_("March"));
+       cmbMonth->Append(_("April"));
+       cmbMonth->Append(_("May"));
+       cmbMonth->Append(_("June"));
+       cmbMonth->Append(_("July"));
+       cmbMonth->Append(_("August"));
+       cmbMonth->Append(_("September"));
+       cmbMonth->Append(_("October"));
+       cmbMonth->Append(_("November"));
+       cmbMonth->Append(_("December"));
+
+       szrMain->Add(cmbMonth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+
+       // Setup the year selection control.
+       
+       spcYear = new wxSpinCtrl(this, wxID_ANY, _(""), wxDefaultPosition, wxSize(50,-1), wxSP_ARROW_KEYS, 0, 9999, 2016);
+       szrMain->Add(spcYear, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+
+       // Setup the Change button.
+       
+       btnChange = new wxButton(this, wxID_ANY, _("Change"), wxDefaultPosition, wxDefaultSize);
+       szrMain->Add(btnChange, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+       
+       // Setup the events.
+       
+       btnChange->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarMonthSelect::UpdateMonthView), NULL, this);
+
+}
+
+XCCalendarMonthSelect::~XCCalendarMonthSelect(){
+       
+       
+       
+}
+
+void XCCalendarMonthSelect::UpdateDate(int Month, int Year){
+       
+       cmbMonth->SetSelection((Month - 1));
+       spcYear->SetValue(Year);
+       
+}
+
+void XCCalendarMonthSelect::UpdateMonthView(wxCommandEvent &event){
+       
+       // Post an event back to the parent updating the calendar
+       // with the new month.
+       
+       this->Dismiss();
+       wxCommandEvent UpdateGrid(XCCALENDARMANIPULATOR_CHANGEGRID);
+       wxPostEvent(this->GetParent(), UpdateGrid);
+       
+}
+
+int XCCalendarMonthSelect::GetMonth(){
+       
+       return (cmbMonth->GetSelection() + 1);
+       
+}
+
+int XCCalendarMonthSelect::GetYear(){
+       
+       return spcYear->GetValue();
+       
+}
\ No newline at end of file
diff --git a/source/widgets/XCCalendarMonthSelect.h b/source/widgets/XCCalendarMonthSelect.h
new file mode 100644 (file)
index 0000000..5a40121
--- /dev/null
@@ -0,0 +1,47 @@
+// XCCalendarMonthSelect.h - Xestia Calendar XCCalendarMonthSelect 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_XCCALENDARMONTHSELECT_H__
+#define __WIDGETS_XCCALENDARMONTHSELECT_H__
+
+#include <wx/wx.h>
+#include <wx/popupwin.h>
+#include <wx/spinctrl.h>
+
+#include "events.h"
+
+class XCCalendarMonthSelect: public wxPopupTransientWindow
+{
+       private:
+               wxBoxSizer *szrMain = nullptr;
+               wxChoice *cmbMonth = nullptr;
+               wxSpinCtrl *spcYear = nullptr;
+               wxButton *btnChange = nullptr;
+       protected:
+               //void ActivateWindow(wxFocusEvent &event);
+               void UpdateMonthView(wxCommandEvent &event);
+       public:
+               XCCalendarMonthSelect(wxWindow *parent);
+               ~XCCalendarMonthSelect();
+               void UpdateDate(int Month, int Year);
+               int GetMonth();
+               int GetYear();
+               
+};
+
+#endif
index aa99d8b..64452d5 100644 (file)
 
 using namespace std;
 
-BEGIN_EVENT_TABLE(XCCalendarMonthView, wxFrame)
+BEGIN_EVENT_TABLE(XCCalendarMonthView, wxPanel)
 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){
+XCCalendarMonthView::XCCalendarMonthView(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid)
+        : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL){
+       
+       Connect(ID_MONTHVIEWCLEARSELECTION, XCCALENDARMONTH_DESELECTOTHERENTRIES, wxCommandEventHandler(XCCalendarMonthView::DeselectOthersEvent));
+               
+       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->SetFlexibleDirection( wxBOTH );
+       WindowSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
+       
+       this->SetSizer(WindowSizer);
+       WindowSizer->Fit(this);
+       this->Layout();
+       this->SetBackgroundColour(wxColour(0,0,0));
+       
+}
+
+XCCalendarMonthView::XCCalendarMonthView(XCCalendarMonthViewGrid *grid)
+        : wxPanel(NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL){
        
        Connect(ID_MONTHVIEWCLEARSELECTION, XCCALENDARMONTH_DESELECTOTHERENTRIES, wxCommandEventHandler(XCCalendarMonthView::DeselectOthersEvent));
                
@@ -58,11 +102,6 @@ XCCalendarMonthView::XCCalendarMonthView(const wxString& title, const wxPoint& p
        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 );
        
@@ -85,9 +124,13 @@ void XCCalendarMonthView::ProcessGrid(XCCalendarMonthViewGrid *grid){
        
        // Add the new calendar entries.
        
+       int Week = 0;
+       
        for (vector<XCCalendarMonthViewGridDayWeek>::iterator WeekIter = grid->WeekList.begin();
                WeekIter != grid->WeekList.end(); WeekIter++){
-               
+                       
+               Week++;
+                       
                for (vector<XCCalendarMonthViewGridDayData>::iterator DayIter = (*WeekIter).DayList.begin();
                        DayIter != (*WeekIter).DayList.end(); DayIter++){
                                
@@ -106,6 +149,14 @@ void XCCalendarMonthView::ProcessGrid(XCCalendarMonthViewGrid *grid){
                        
        }
        
+       // Add the Growable Rows.
+       
+       for (int WeekSeek = 0; WeekSeek < Week; WeekSeek++){
+               
+               WindowSizer->AddGrowableRow((WeekSeek + 1));
+               
+       }
+       
 }
 
 void XCCalendarMonthView::Repaint(){
index 9799ea8..62b986b 100644 (file)
@@ -33,7 +33,7 @@
 
 class XCCalendarDay;
 
-class XCCalendarMonthView: public wxFrame
+class XCCalendarMonthView: public wxPanel
 {
        
        private:
@@ -52,7 +52,8 @@ class XCCalendarMonthView: public wxFrame
                void Repaint();
        
        public:
-               XCCalendarMonthView(const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid);
+               XCCalendarMonthView(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid);
+               XCCalendarMonthView(XCCalendarMonthViewGrid *grid);
                ~XCCalendarMonthView();
        
                void PaintFrameEvent(wxPaintEvent &PaintEvent);
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