Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
macOS: Implemented macOS specific paths and variable name fixes
[xestiacalendar/.git] / source / widgets / XCCalendarManipulator.cpp
index e3f35ec..4ca64bc 100644 (file)
 
 #include "XCCalendarManipulator.h"
 
-BEGIN_EVENT_TABLE(XCCalendarManipulator, wxPanel)
-END_EVENT_TABLE()
+wxDEFINE_EVENT(XCCALENDARMANIPULATOR_CHANGEGRID, wxCommandEvent);
 
 using namespace std;
 
 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 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(500, 50), wxTAB_TRAVERSAL);
+#if defined(__APPLE__)
+       pnlMain->SetBackgroundColour(wxColour(120,120,120));
+#else
        pnlMain->SetBackgroundColour(wxColour(40,40,40));
+#endif
        this->SetSizer(szrMain);
        szrMain->Add(pnlMain, 0, wxEXPAND, 0);
        
@@ -60,6 +62,9 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
        previousButton->SetBitmap(previousIconBitmap);
        nextButton->SetBitmap(nextIconBitmap);
        calendarsButton->SetBitmap(calendarsIconBitmap);
+       previousButton->SetBackgroundColour(pnlMain->GetBackgroundColour());
+       nextButton->SetBackgroundColour(pnlMain->GetBackgroundColour());
+       calendarsButton->SetBackgroundColour(pnlMain->GetBackgroundColour());
                
        // Setup the static text.
                
@@ -70,17 +75,9 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
        test.SetWeight(wxFONTWEIGHT_BOLD);
        test.SetPointSize(18);
                
-       dateButton->SetFont(Test);
+       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);
-       calendarsButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::ShowCalendarsList), NULL, this);
-       previousButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::PreviousMonth), NULL, this);
-       
-       Connect(ID_CHANGEGRID, XCCALENDARMANIPULATOR_CHANGEGRID, wxCommandEventHandler(XCCalendarManipulator::ChangeGrid));
+       dateButton->SetBackgroundColour(pnlMain->GetBackgroundColour());
        
        // Setup the manipulator control.
 
@@ -95,8 +92,12 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
        // Setup the month selection control.
        
        wxDateTime dtNow = wxDateTime::Now();
-       
+
+#if defined(WIN32) || defined(__APPLE__)
+       moo = new frmCalendarSelectMonth(this);
+#else
        moo = new XCCalendarMonthSelect(this);
+#endif
        month = ((int)dtNow.GetMonth() + 1);
        year = dtNow.GetYear();
        moo->UpdateDate(month, year);
@@ -110,6 +111,27 @@ XCCalendarManipulator::XCCalendarManipulator(wxWindow* parent, const wxString& t
        
        this->dataStorage = dataStorage;
                
+       // 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);
+       calendarsButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::ShowCalendarsList), NULL, this);
+       previousButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(XCCalendarManipulator::PreviousMonth), NULL, this);
+       
+#if defined(WIN32)
+       dateButton->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(XCCalendarManipulator::ButtonMouseover), NULL, this);
+       dateButton->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(XCCalendarManipulator::ButtonMouseout), NULL, this);
+       nextButton->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(XCCalendarManipulator::ButtonMouseover), NULL, this);
+       nextButton->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(XCCalendarManipulator::ButtonMouseout), NULL, this);
+       calendarsButton->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(XCCalendarManipulator::ButtonMouseover), NULL, this);
+       calendarsButton->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(XCCalendarManipulator::ButtonMouseout), NULL, this);
+       previousButton->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(XCCalendarManipulator::ButtonMouseover), NULL, this);
+       previousButton->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(XCCalendarManipulator::ButtonMouseout), NULL, this);
+#endif
+
+       Bind(XCCALENDARMANIPULATOR_CHANGEGRID, &XCCalendarManipulator::ChangeGrid, this, ID_CHANGEGRID);
+
+       this->Refresh();
 }
 
 XCCalendarManipulator::~XCCalendarManipulator(){
@@ -122,10 +144,16 @@ void XCCalendarManipulator::DateTextClick(wxCommandEvent &event){
        
        // Bring up a popup control to select the month and year.
        
+       // Do something different for Win32 and macOS.
+
        moo->SetPosition(wxPoint(dateButton->GetScreenRect().GetLeft(), dateButton->GetScreenRect().GetBottom()));
        moo->UpdateDate(month, year);
+#if defined(WIN32) || defined(__APPLE__)
+       moo->ShowModal();
+#else
        moo->Popup();
-       
+#endif
+
 }
 
 void XCCalendarManipulator::ChangeGrid(wxCommandEvent &event){
@@ -217,8 +245,22 @@ void XCCalendarManipulator::ShowCalendarsList(wxCommandEvent &event){
        
        calendarList->SetPosition(wxPoint(calendarsButton->GetScreenRect().GetLeft(), calendarsButton->GetScreenRect().GetBottom()));
        calendarList->UpdateCalendarList(dataStorage);
+#if defined(__APPLE__)
+
+    if (calendarListShow == false)
+    {
+        calendarList->Show();
+        calendarListShow = true;
+    }
+    else
+    {
+        calendarList->Hide();
+        calendarListShow = false;
+    }
+#else
        calendarList->Popup();
-       
+#endif
+    
 }
 
 void XCCalendarManipulator::UpdateDateButtonText(){
@@ -297,4 +339,16 @@ vector<int> XCCalendarManipulator::GetHiddenCalendarsList(){
        
        return calendarList->GetHiddenCalendarsList();
        
+}
+
+void XCCalendarManipulator::ButtonMouseover(wxMouseEvent &event)
+{
+       wxWindow *eventObject = (wxWindow*)event.GetEventObject();
+       eventObject->SetWindowStyle(0 | wxSIMPLE_BORDER);
+}
+
+void XCCalendarManipulator::ButtonMouseout(wxMouseEvent &event)
+{
+       wxWindow *eventObject = (wxWindow*)event.GetEventObject();
+       eventObject->SetWindowStyle(0 | wxNO_BORDER);
 }
\ 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