X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fwidgets%2FXCCalendarManipulator.cpp;h=bc00983a4096885b3b04f3109ba5b7418e86316c;hb=baa27c175ee6111fd4b88a3c53614a9b6be3541e;hp=9268d61b472c5e9e640c2426dede1962dcb8ac2c;hpb=f1ecf412b80a5c25421595fde8f1e86131414f4c;p=xestiacalendar%2F.git diff --git a/source/widgets/XCCalendarManipulator.cpp b/source/widgets/XCCalendarManipulator.cpp index 9268d61..bc00983 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,13 +77,15 @@ 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)); + Connect(ID_CHANGEGRID, 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 ); @@ -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; } @@ -122,6 +140,7 @@ void XCCalendarManipulator::ChangeGrid(wxCommandEvent &event){ // Post an event to the parent control to update the grid. wxCommandEvent ChangeGrid(XCCALENDARCTRL_CHANGEGRID); + ChangeGrid.SetId(ID_CHANGEGRID); wxPostEvent(this->GetParent(), ChangeGrid); UpdateDateButtonText(); @@ -153,6 +172,7 @@ void XCCalendarManipulator::NextMonth(wxCommandEvent &event){ // Post an event to the parent control to update the grid. wxCommandEvent ChangeGrid(XCCALENDARCTRL_CHANGEGRID); + ChangeGrid.SetId(ID_CHANGEGRID); wxPostEvent(this->GetParent(), ChangeGrid); UpdateDateButtonText(); @@ -184,12 +204,23 @@ void XCCalendarManipulator::PreviousMonth(wxCommandEvent &event){ // Post an event to the parent control to update the grid. wxCommandEvent ChangeGrid(XCCALENDARCTRL_CHANGEGRID); + ChangeGrid.SetId(ID_CHANGEGRID); wxPostEvent(this->GetParent(), ChangeGrid); UpdateDateButtonText(); } +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. @@ -254,4 +285,16 @@ int XCCalendarManipulator::GetYear(){ return Year; +} + +vector XCCalendarManipulator::GetHiddenAccountsList(){ + + return calendarList->GetHiddenAccountsList(); + +} + +vector XCCalendarManipulator::GetHiddenCalendarsList(){ + + return calendarList->GetHiddenCalendarsList(); + } \ No newline at end of file