#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)
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));
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);
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.
}
}
-void XCCalendarDayEntry::PaintFrameEvent(wxPaintEvent &paintEvent){
-
- Repaint();
-
-}
-
void XCCalendarDayEntry::ResizeFrameEvent(wxSizeEvent &sizeEvent){
// Adjust the Event text so it is displayed properly.
break;
}
+ // Resize the main panel.
+
+ mainPanel->SetSize(this->GetSize());
+
// Refresh the window.
this->Refresh();
// 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);
void XCCalendarDayEntry::Deselect(wxCommandEvent &DeselectEvent){
- this->SetBackgroundColour(wxNullColour);
+ mainPanel->SetBackgroundColour(wxNullColour);
}
void XCCalendarDayEntry::SetColour(Colour *colourIn){
- entryColour = *colourIn;
- Repaint();
+ calendarColour->SetBackgroundColour(wxColour(colourIn->red, colourIn->green, colourIn->blue, colourIn->alpha));
}