X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=blobdiff_plain;f=source%2Fwidgets%2FXCCalendarDayEntry.cpp;h=5bef6692b76593382b9c012f61876559f7d6da6e;hp=0aede5632f75b055a5b528df0aff9d367fd3ba7b;hb=d97b5c14c651aa7dad92072e7bf192704540018c;hpb=df6ed16ac514d7b0408f609b9ff1a35aaffdb0e5 diff --git a/source/widgets/XCCalendarDayEntry.cpp b/source/widgets/XCCalendarDayEntry.cpp index 0aede56..5bef669 100644 --- a/source/widgets/XCCalendarDayEntry.cpp +++ b/source/widgets/XCCalendarDayEntry.cpp @@ -21,7 +21,6 @@ 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) @@ -35,15 +34,29 @@ XCCalendarDayEntry::XCCalendarDayEntry(wxWindow* parent, const wxString& title, 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)); @@ -56,12 +69,16 @@ XCCalendarDayEntry::XCCalendarDayEntry(wxWindow* parent, const wxString& title, alarmIcon->SetBitmap(alarmIconBitmap); highPriorityIcon->SetBitmap(priorityIconBitmap); + // 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); @@ -73,40 +90,16 @@ XCCalendarDayEntry::XCCalendarDayEntry(wxWindow* parent, const wxString& title, // Bind events to the control. Bind(XCCALENDARDAYENTRY_DESELECT, &XCCalendarDayEntry::Deselect, this, ID_ENTRYDESELECT); -} - -XCCalendarDayEntry::~XCCalendarDayEntry(){ - // Destory the controls from the widget. + // Set the control's sizer. + this->SetSizer(mainSizer); + mainSizer->Add(mainPanel, 0, wxEXPAND, 1); } -void XCCalendarDayEntry::Repaint(){ - - wxPaintDC dc(this); - - // Get the wxSizerItem for the top date and the entries part. - - 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. } @@ -172,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. @@ -197,6 +184,10 @@ void XCCalendarDayEntry::ResizeFrameEvent(wxSizeEvent &sizeEvent){ break; } + // Resize the main panel. + + mainPanel->SetSize(this->GetSize()); + // Refresh the window. this->Refresh(); @@ -208,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); @@ -233,7 +224,7 @@ void XCCalendarDayEntry::RightClick(wxMouseEvent &MouseEvent){ void XCCalendarDayEntry::Deselect(wxCommandEvent &DeselectEvent){ - this->SetBackgroundColour(wxNullColour); + mainPanel->SetBackgroundColour(wxNullColour); } @@ -250,8 +241,7 @@ void XCCalendarDayEntry::SetTime(int timeHour, int timeMinute, int timeSecond){ void XCCalendarDayEntry::SetColour(Colour *colourIn){ - entryColour = *colourIn; - Repaint(); + calendarColour->SetBackgroundColour(wxColour(colourIn->red, colourIn->green, colourIn->blue, colourIn->alpha)); }