X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fwidgets%2FXCCalendarDayEntry.cpp;h=089110f6c0609c4e73aef119127115bfd192bdb4;hb=3b8fa1539bff637461965a88b217e92b3bac4cde;hp=136d5c64ea950f6451f112d9c7b525d128d05192;hpb=401fd2eee6047f72fdaf811bbcc3924409a4fb9d;p=xestiacalendar%2F.git diff --git a/source/widgets/XCCalendarDayEntry.cpp b/source/widgets/XCCalendarDayEntry.cpp index 136d5c6..089110f 100644 --- a/source/widgets/XCCalendarDayEntry.cpp +++ b/source/widgets/XCCalendarDayEntry.cpp @@ -18,8 +18,9 @@ #include "XCCalendarDayEntry.h" +wxDEFINE_EVENT(XCCALENDARDAYENTRY_DESELECT, wxCommandEvent); + BEGIN_EVENT_TABLE(XCCalendarDayEntry, wxPanel) -EVT_PAINT(XCCalendarDayEntry::PaintFrameEvent) EVT_SIZE(XCCalendarDayEntry::ResizeFrameEvent) EVT_LEFT_UP(XCCalendarDayEntry::LeftClick) EVT_RIGHT_UP(XCCalendarDayEntry::RightClick) @@ -29,20 +30,33 @@ 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(); eventID = id; this->SetMinSize(wxSize(65, 30)); + + // Setup the main panel and main sizer. + + mainPanel = new wxPanel(this, wxID_ANY, wxPoint(0,0), this->GetSize(), wxTAB_TRAVERSAL|wxSIMPLE_BORDER); + mainSizer = new wxBoxSizer( wxVERTICAL ); + + // Setup the calendar colour. + calendarColour = new wxPanel(mainPanel, wxID_ANY, wxPoint(0,0), wxSize(10, 30), wxTAB_TRAVERSAL|wxEXPAND, "Calendar Colour"); + calendarColour->SetBackgroundColour(wxColour(80, 40, 40, 100)); + + // Setup the event text. + 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); + eventText = new wxStaticText(mainPanel, wxID_ANY, title, wxPoint(49, 14), wxDefaultSize, wxST_ELLIPSIZE_END); + eventTime = new wxStaticText(mainPanel, wxID_ANY, wxT("Time"), wxPoint(49,3), wxDefaultSize, 0); wxFont eventTimeFont = eventTime->GetFont(); eventTimeFont.MakeBold(); eventTime->SetFont(eventTimeFont); + // Setup the images. + wxMemoryInputStream alerticon(icons_alert_png, sizeof(icons_alert_png)); wxMemoryInputStream priorityicon(icons_priority_png, sizeof(icons_priority_png)); @@ -54,15 +68,17 @@ XCCalendarDayEntry::XCCalendarDayEntry(wxWindow* parent, const wxString& title, alarmIcon->SetBitmap(alarmIconBitmap); highPriorityIcon->SetBitmap(priorityIconBitmap); - - Connect(ID_ENTRYDESELECT, XCCALENDARDAYENTRY_DESELECT, wxCommandEventHandler(XCCalendarDayEntry::Deselect)); + // Setup the connections for the control. + + calendarColour->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(XCCalendarDayEntry::LeftClick), NULL, this); 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); - + + calendarColour->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarDayEntry::RightClick), 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); @@ -71,40 +87,19 @@ XCCalendarDayEntry::XCCalendarDayEntry(wxWindow* parent, const wxString& title, UpdateInformation(); -} - -XCCalendarDayEntry::~XCCalendarDayEntry(){ + // Bind events to the control. - // Destory the controls from the widget. + Bind(XCCALENDARDAYENTRY_DESELECT, &XCCalendarDayEntry::Deselect, this, ID_ENTRYDESELECT); -} - -void XCCalendarDayEntry::Repaint(){ + // Set the control's sizer. - wxPaintDC dc(this); - - // Get the wxSizerItem for the top date and the entries part. + this->SetSizer(mainSizer); + mainSizer->Add(mainPanel, 0, wxEXPAND, 1); +} - dc.SetBrush(wxBrush(wxColor(0,0,0), wxBRUSHSTYLE_TRANSPARENT)); - - /*wxRect Test; - - Test.SetX(this->GetClientRect().GetX()); - Test.SetY(this->GetClientRect().GetY()); - Test.SetHeight(this->GetClientRect().GetHeight()); - Test.SetWidth(this->GetClientRect().GetWidth()); - - cout << Test.GetX() << "|" << Test.GetY() << "|" << Test.GetHeight() << "|" << Test.GetWidth() << "|" << endl;*/ - - dc.DrawRectangle(this->GetClientRect()); - - // Draw the calendar colour. +XCCalendarDayEntry::~XCCalendarDayEntry(){ - dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT)); - dc.SetBrush(wxBrush(wxColor(entryColour.red, - entryColour.green, - entryColour.blue), wxBRUSHSTYLE_SOLID)); - dc.DrawRectangle(wxRect(1,1,10,28)); + // Destory the controls from the widget. } @@ -170,12 +165,6 @@ void XCCalendarDayEntry::UpdateInformation(){ } -void XCCalendarDayEntry::PaintFrameEvent(wxPaintEvent &paintEvent){ - - Repaint(); - -} - void XCCalendarDayEntry::ResizeFrameEvent(wxSizeEvent &sizeEvent){ // Adjust the Event text so it is displayed properly. @@ -195,6 +184,10 @@ void XCCalendarDayEntry::ResizeFrameEvent(wxSizeEvent &sizeEvent){ break; } + // Resize the main panel. + + mainPanel->SetSize(this->GetSize()); + // Refresh the window. this->Refresh(); @@ -206,7 +199,7 @@ void XCCalendarDayEntry::LeftClick(wxMouseEvent &mouseEvent){ // Change the background of the widget to mark // the entry as selected. - this->SetBackgroundColour(wxColor(255,215,0)); + mainPanel->SetBackgroundColour(wxColor(255,215,0)); wxCommandEvent deselectOthersEvent(XCCALENDARDAY_DESELECTOTHERENTRIES); deselectOthersEvent.SetInt(eventID); deselectOthersEvent.SetId(ID_DESELECTOTHERENTRIES); @@ -231,7 +224,7 @@ void XCCalendarDayEntry::RightClick(wxMouseEvent &MouseEvent){ void XCCalendarDayEntry::Deselect(wxCommandEvent &DeselectEvent){ - this->SetBackgroundColour(wxNullColour); + mainPanel->SetBackgroundColour(wxNullColour); } @@ -246,21 +239,20 @@ void XCCalendarDayEntry::SetTime(int timeHour, int timeMinute, int timeSecond){ } -void XCCalendarDayEntry::SetColour(Colour *ColourIn){ +void XCCalendarDayEntry::SetColour(Colour *colourIn){ - entryColour = *colourIn; - Repaint(); + calendarColour->SetBackgroundColour(wxColour(colourIn->red, colourIn->green, colourIn->blue, colourIn->alpha)); } -void XCCalendarDayEntry::SetDisplayAlarm(bool DisplayValue){ +void XCCalendarDayEntry::SetDisplayAlarm(bool displayValue){ hasAlarm = displayValue; UpdateInformation(); } -void XCCalendarDayEntry::SetDisplayHighPriority(bool DisplayValue){ +void XCCalendarDayEntry::SetDisplayHighPriority(bool displayValue){ hasHighPriority = displayValue; UpdateInformation(); @@ -365,13 +357,13 @@ wxSizerItem* XCCalendarDayEntry::GetAfterSpacer(){ } -bool XCCalendarDayEntry::SetShowAccountStatus(bool statusInput){ +void XCCalendarDayEntry::SetShowAccountStatus(bool statusInput){ showAccount = statusInput; } -bool XCCalendarDayEntry::SetShowCalendarStatus(bool statusInput){ +void XCCalendarDayEntry::SetShowCalendarStatus(bool statusInput){ showCalendar = statusInput;