X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fwidgets%2FXCCalendarDayEntry.cpp;h=0aede5632f75b055a5b528df0aff9d367fd3ba7b;hb=ca1d24d80ec04ae64a7540cf8bca61c053f2a193;hp=4eb9bafddb5de2592aa61b9d5cd003732c528813;hpb=0b8511474e5fec3cbee0c4bd89f764d2a7458281;p=xestiacalendar%2F.git diff --git a/source/widgets/XCCalendarDayEntry.cpp b/source/widgets/XCCalendarDayEntry.cpp index 4eb9baf..0aede56 100644 --- a/source/widgets/XCCalendarDayEntry.cpp +++ b/source/widgets/XCCalendarDayEntry.cpp @@ -18,38 +18,61 @@ #include "XCCalendarDayEntry.h" +wxDEFINE_EVENT(XCCALENDARDAYENTRY_DESELECT, wxCommandEvent); + BEGIN_EVENT_TABLE(XCCalendarDayEntry, wxPanel) EVT_PAINT(XCCalendarDayEntry::PaintFrameEvent) EVT_SIZE(XCCalendarDayEntry::ResizeFrameEvent) -EVT_LEFT_DOWN(XCCalendarDayEntry::LeftClick) +EVT_LEFT_UP(XCCalendarDayEntry::LeftClick) +EVT_RIGHT_UP(XCCalendarDayEntry::RightClick) END_EVENT_TABLE() using namespace std; XCCalendarDayEntry::XCCalendarDayEntry(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size, const int id) : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){ - - DayPanel = parent->GetParent(); - EntryID = id; + dayPanel = parent->GetParent(); + eventID = id; this->SetMinSize(wxSize(65, 30)); - 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); + eventTextData = title.mb_str(); + eventText = new wxStaticText(this, wxID_ANY, title, wxPoint(49, 14), wxDefaultSize, wxST_ELLIPSIZE_END); + eventTime = new wxStaticText(this, wxID_ANY, wxT("Time"), wxPoint(49,3), wxDefaultSize, 0); + + wxFont eventTimeFont = eventTime->GetFont(); + eventTimeFont.MakeBold(); + eventTime->SetFont(eventTimeFont); - AlarmIcon->SetBitmap(AlarmIconBitmap); - HighPriorityIcon->SetBitmap(PriorityIconBitmap); + 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); + + alarmIcon->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); + highPriorityIcon->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); + eventText->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); + eventTime->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); + dayPanel->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); + + alarmIcon->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarDayEntry::RightClick), NULL, this); + highPriorityIcon->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarDayEntry::RightClick), NULL, this); + eventText->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarDayEntry::RightClick), NULL, this); + eventTime->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarDayEntry::RightClick), NULL, this); + dayPanel->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarDayEntry::RightClick), NULL, this); - Connect(wxID_ANY, XCCALENDARDAYENTRY_DESELECT, wxCommandEventHandler(XCCalendarDayEntry::Deselect)); - AlarmIcon->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); - HighPriorityIcon->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); - EventText->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); - UpdateInformation(); + // Bind events to the control. + + Bind(XCCALENDARDAYENTRY_DESELECT, &XCCalendarDayEntry::Deselect, this, ID_ENTRYDESELECT); } XCCalendarDayEntry::~XCCalendarDayEntry(){ @@ -80,91 +103,97 @@ void XCCalendarDayEntry::Repaint(){ // Draw the calendar colour. dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT)); - dc.SetBrush(wxBrush(wxColor(EntryColour.red, - EntryColour.green, - EntryColour.blue), wxBRUSHSTYLE_SOLID)); + dc.SetBrush(wxBrush(wxColor(entryColour.red, + entryColour.green, + entryColour.blue), wxBRUSHSTYLE_SOLID)); dc.DrawRectangle(wxRect(1,1,10,28)); } void XCCalendarDayEntry::UpdateInformation(){ - PositionMode = 0; + positionMode = 0; // Check if the high priority icon needs to be displayed. - if (HasHighPriority == true){ + if (hasHighPriority == true){ - HighPriorityIcon->SetPosition(wxPoint(FirstPosition,7)); + highPriorityIcon->SetPosition(wxPoint(firstPosition,7)); - HighPriorityIcon->Show(true); + highPriorityIcon->Show(true); - PositionMode++; + positionMode++; } else { - HighPriorityIcon->Show(false); + highPriorityIcon->Show(false); } // Check if the alarm icon needs to be displayed. - if (HasAlarm == true){ + if (hasAlarm == true){ - switch(PositionMode){ + switch(positionMode){ case 0: - AlarmIcon->SetPosition(wxPoint(FirstPosition,7)); + alarmIcon->SetPosition(wxPoint(firstPosition,7)); break; case 1: - AlarmIcon->SetPosition(wxPoint(SecondPosition,7)); + alarmIcon->SetPosition(wxPoint(secondPosition,7)); break; } - AlarmIcon->Show(true); + alarmIcon->Show(true); - PositionMode++; + positionMode++; } else { - AlarmIcon->Show(false); + alarmIcon->Show(false); } // Now set the text. - switch(PositionMode){ + switch(positionMode){ case 0: - EventText->SetPosition(wxPoint(FirstPosition,8)); + eventText->SetPosition(wxPoint(firstPosition,14)); + eventTime->SetPosition(wxPoint(firstPosition,3)); break; case 1: - EventText->SetPosition(wxPoint(SecondPosition,8)); + eventText->SetPosition(wxPoint(secondPosition,14)); + eventTime->SetPosition(wxPoint(firstPosition,3)); break; case 2: - EventText->SetPosition(wxPoint(ThirdPosition,8)); + eventText->SetPosition(wxPoint(thirdPosition,14)); + eventTime->SetPosition(wxPoint(firstPosition,3)); break; } } -void XCCalendarDayEntry::PaintFrameEvent(wxPaintEvent &PaintEvent){ +void XCCalendarDayEntry::PaintFrameEvent(wxPaintEvent &paintEvent){ Repaint(); } -void XCCalendarDayEntry::ResizeFrameEvent(wxSizeEvent &SizeEvent){ +void XCCalendarDayEntry::ResizeFrameEvent(wxSizeEvent &sizeEvent){ // Adjust the Event text so it is displayed properly. - switch(PositionMode){ + switch(positionMode){ case 0: - EventText->SetSize(wxSize((this->GetClientRect().width - FirstPosition - 5),15)); + eventText->SetSize(wxSize((this->GetClientRect().width - firstPosition - 5),15)); + eventTime->SetSize(wxSize((this->GetClientRect().width - firstPosition - 5),15)); break; case 1: - EventText->SetSize(wxSize((this->GetClientRect().width - SecondPosition - 5),15)); + eventText->SetSize(wxSize((this->GetClientRect().width - secondPosition - 5),15)); + eventTime->SetSize(wxSize((this->GetClientRect().width - secondPosition - 5),15)); break; case 2: - EventText->SetSize(wxSize((this->GetClientRect().width - ThirdPosition - 5),15)); + eventText->SetSize(wxSize((this->GetClientRect().width - thirdPosition - 5),14)); + eventTime->SetSize(wxSize((this->GetClientRect().width - thirdPosition - 5),15)); break; } @@ -174,15 +203,31 @@ void XCCalendarDayEntry::ResizeFrameEvent(wxSizeEvent &SizeEvent){ } -void XCCalendarDayEntry::LeftClick(wxMouseEvent &MouseEvent){ +void XCCalendarDayEntry::LeftClick(wxMouseEvent &mouseEvent){ // Change the background of the widget to mark // the entry as selected. this->SetBackgroundColour(wxColor(255,215,0)); - wxCommandEvent DeselectOthersEvent(XCCALENDARDAY_DESELECTOTHERENTRIES); - DeselectOthersEvent.SetInt(EntryID); - wxPostEvent(DayPanel, DeselectOthersEvent); + wxCommandEvent deselectOthersEvent(XCCALENDARDAY_DESELECTOTHERENTRIES); + deselectOthersEvent.SetInt(eventID); + deselectOthersEvent.SetId(ID_DESELECTOTHERENTRIES); + wxPostEvent(dayPanel, deselectOthersEvent); + +} + +void XCCalendarDayEntry::RightClick(wxMouseEvent &MouseEvent){ + + // Sent an event to the month view control. + + EventProperties *eventData = new EventProperties; + eventData->calendarID = calendarID; + eventData->eventID = eventID; + + wxCommandEvent eventMenu(XCCALENDARMONTH_DISPLAYEVENTMENU); + eventMenu.SetClientData(eventData); + eventMenu.SetId(ID_DISPLAYEVENTMENU); + wxPostEvent(this->GetParent()->GetParent(), eventMenu); } @@ -192,40 +237,156 @@ void XCCalendarDayEntry::Deselect(wxCommandEvent &DeselectEvent){ } -void XCCalendarDayEntry::SetColour(Colour *ColourIn){ +void XCCalendarDayEntry::SetTime(int timeHour, int timeMinute, int timeSecond){ + + this->timeHour = timeHour; + this->timeMinute = timeMinute; + this->timeSecond = timeSecond; + + string timeOutput = BuildEventTime(timeHour, timeMinute); + eventTime->SetLabel(timeOutput); + +} + +void XCCalendarDayEntry::SetColour(Colour *colourIn){ - EntryColour = *ColourIn; + entryColour = *colourIn; + Repaint(); } -void XCCalendarDayEntry::SetDisplayAlarm(bool DisplayValue){ +void XCCalendarDayEntry::SetDisplayAlarm(bool displayValue){ - HasAlarm = DisplayValue; + hasAlarm = displayValue; UpdateInformation(); } -void XCCalendarDayEntry::SetDisplayHighPriority(bool DisplayValue){ +void XCCalendarDayEntry::SetDisplayHighPriority(bool displayValue){ - HasHighPriority = DisplayValue; + hasHighPriority = displayValue; UpdateInformation(); } bool XCCalendarDayEntry::GetDisplayAlarm(){ - return HasAlarm; + return hasAlarm; } bool XCCalendarDayEntry::GetDisplayHighPriority(){ - return HasHighPriority; + return hasHighPriority; } int XCCalendarDayEntry::GetID(){ - return EntryID; + return eventID; + +} + +int XCCalendarDayEntry::GetCalendarID(){ + + return calendarID; + +} + +int XCCalendarDayEntry::GetEventID(){ + + return eventID; + +} + +int XCCalendarDayEntry::GetAccountID(){ + + return accountID; + +} + +string XCCalendarDayEntry::BuildEventTime(int timeHour, int timeMinute){ + + string timeOutput; + + if (timeHour > 12){ + + timeOutput += to_string(timeHour - 12); + + } else if (timeHour > 0){ + + timeOutput += to_string(timeHour); + + } else if (timeHour == 0){ + + timeOutput += to_string(12); + + } + + timeOutput += ":"; + + if (timeMinute < 10){ + timeOutput += "0"; + } + + timeOutput += to_string(timeMinute); + + if (timeHour < 12){ + timeOutput += "am"; + } else { + timeOutput += "pm"; + } + + return timeOutput; + +} + +void XCCalendarDayEntry::SetEntryIDs(int accountID, int calendarID, int eventID){ + + this->accountID = accountID; + this->calendarID = calendarID; + this->eventID = eventID; + +} + +void XCCalendarDayEntry::SetAfterSpacer(wxSizerItem *afterSpacer){ + + this->afterSpacer = afterSpacer; + +} + +void XCCalendarDayEntry::SetEventName(string eventName){ + + eventText->SetLabel((wxString)eventName); + +} + +wxSizerItem* XCCalendarDayEntry::GetAfterSpacer(){ + + return afterSpacer; + +} + +bool XCCalendarDayEntry::SetShowAccountStatus(bool statusInput){ + + showAccount = statusInput; + +} + +bool XCCalendarDayEntry::SetShowCalendarStatus(bool statusInput){ + + showCalendar = statusInput; + +} + +bool XCCalendarDayEntry::GetShowAccountStatus(){ + + return showAccount; + +} + +bool XCCalendarDayEntry::GetShowCalendarStatus(){ + + return showCalendar; } \ No newline at end of file