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 );
pnlMain->SetBackgroundColour(wxColour(40,40,40));
this->SetSizer(szrMain);
szrMain->Add(pnlMain, 0, wxEXPAND, 0);
-
+
// Setup the navigation section.
szrNavigation = new wxBoxSizer( wxHORIZONTAL );
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;
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));
// 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 );
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;
}
}
+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.
// 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>
#include "events.h"
#include "XCCalendarMonthSelect.h"
+#include "XCCalendarList.h"
#include "../bitmaps.h"
+#include "../libraries/CalendarDataStorage/CalendarDataStorage.h"
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:
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