wxDEFINE_EVENT(XCCALENDARDAY_UPDATECALENDARCOLOUR, wxCommandEvent);
BEGIN_EVENT_TABLE(XCCalendarDay, wxPanel)
-EVT_PAINT(XCCalendarDay::PaintFrameEvent)
-EVT_SIZE(XCCalendarDay::ResizeFrameEvent)
END_EVENT_TABLE()
XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size)
: wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){
this->SetMinSize( wxSize( 100,100 ) );
+ // Setup the top panel.
+
+ topPanel = new wxPanel(this, wxID_ANY, wxPoint(0,0), wxSize(50, 40), wxTAB_TRAVERSAL);
+ mainPanel = new wxPanel(this, wxID_ANY, wxPoint(0,0), wxSize(200, 200), wxTAB_TRAVERSAL);
+
// Setip the icons.
+ highPriorityIcon = new wxStaticBitmap(topPanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(32,32), 0);
+ alertIcon = new wxStaticBitmap(topPanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(32,32), 0);
+
wxMemoryInputStream alerticon(icons_alert32_png, sizeof(icons_alert32_png));
wxMemoryInputStream priorityicon(icons_priority32_png, sizeof(icons_priority32_png));
alertIcon->SetBitmap(imgAlertIcon);
highPriorityIcon->SetBitmap(imgPriorityIcon);
- windowSizer->AddGrowableCol(0);
- windowSizer->AddGrowableRow(1);
- windowSizer->SetFlexibleDirection( wxBOTH );
- windowSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
-
- numberText = new wxStaticText(this, wxID_ANY, wxT("09"), wxDefaultPosition, wxDefaultSize, 0);
+ numberText = new wxStaticText(topPanel, wxID_ANY, wxT("09"), wxDefaultPosition, wxDefaultSize, 0);
numberText->SetFont(wxFont(24, 70, 90, 92, false, wxEmptyString));
topSectionSizer->Add(highPriorityIcon, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0);
// Setup the scrollable section.
+ eventListFrame = new wxScrolledWindow(mainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
+
Colour eventColour;
eventColour.red = 40; eventColour.green = 80; eventColour.blue = 80;
eventListFrame->SetScrollRate(0,1);
eventListFrameSizer->Fit(eventListFrame);
eventListFrameSizer->Layout();
- windowSizer->Fit(this);
// Setup the scroll window.
- mainSectionSizer->Add(eventListFrame, 1, wxGROW | wxALL, 10);
+ mainSectionSizer->Add(eventListFrame, 1, wxGROW | wxALL, 5);
- windowSizer->Add(topSectionSizer, 1, wxEXPAND, 5);
- windowSizer->Add(mainSectionSizer, 1, wxEXPAND, 5);
+ topPanel->SetSizer(topSectionSizer);
+ mainPanel->SetSizer(mainSectionSizer);
+
+ windowSizer->Add(topPanel, 1, wxEXPAND, 0);
+ windowSizer->Add(mainPanel, 1, wxEXPAND, 0);
this->SetSizer(windowSizer);
this->SetSize(size);
this->Layout();
- this->SetBackgroundStyle(wxBG_STYLE_PAINT);
this->Centre(wxBOTH);
UpdateTopIcons();
}
-void XCCalendarDay::Repaint(){
-
- wxPaintDC dc(this);
- wxPaintDC eventListFrameDC(eventListFrame);
-
- // Get the wxSizerItem for the top date and the entries part.
-
- wxSizerItem *topSectionSizerItem = windowSizer->GetItem((size_t)0);
- wxSizerItem *mainSectionSizerItem = windowSizer->GetItem((size_t)1);
- wxRect topSizer = wxRect(windowSizer->GetPosition(), windowSizer->GetSize());
-
- if (isInMonth == true){
-
- dc.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
- dc.SetBrush(wxBrush(wxColor(255,255,255)));
- dc.DrawRectangle(topSectionSizerItem->GetRect());
- dc.SetBrush(wxBrush(wxColor(225,225,225)));
- dc.DrawRectangle(mainSectionSizerItem->GetRect());
- eventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
- eventListFrameDC.SetBrush(wxBrush(wxColor(225,225,225)));
- eventListFrameDC.DrawRectangle(eventListFrame->GetClientRect());
-
- } else {
-
- dc.SetPen(wxPen(wxColor(185,185,185), 0, wxPENSTYLE_TRANSPARENT));
- dc.SetBrush(wxBrush(wxColor(185,185,185)));
- dc.DrawRectangle(topSectionSizerItem->GetRect());
- dc.SetBrush(wxBrush(wxColor(155,155,155)));
- dc.DrawRectangle(mainSectionSizerItem->GetRect());
- eventListFrameDC.SetPen(wxPen(wxColor(255,255,255), 0, wxPENSTYLE_TRANSPARENT));
- eventListFrameDC.SetBrush(wxBrush(wxColor(155,155,155)));
- eventListFrameDC.DrawRectangle(eventListFrame->GetClientRect());
-
- }
-
- // Draw the border.
-
- //dc.SetBrush(wxBrush(wxColor(0,0,0), wxBRUSHSTYLE_TRANSPARENT));
-
- this->Layout();
-
-}
-
void XCCalendarDay::UpdateTopIcons(){
bool alarmFound = false;
}
-void XCCalendarDay::PaintFrameEvent(wxPaintEvent &paintEvent)
-{
-
- Repaint();
-
-}
-
void XCCalendarDay::ResizeFrameEvent(wxSizeEvent &sizeEvent)
{
// Refresh the window.
this->Refresh();
+ topPanel->Refresh();
+ mainPanel->Refresh();
+ topSectionSizer->Layout();
+ mainSectionSizer->Layout();
+ windowSizer->Layout();
}
if (this->monthViewPointer != nullptr){
- wxCommandEvent deselectEvent(XCCALENDARMONTH_DESELECTOTHERENTRIES);
- deselectEvent.SetClientData(this);
- deselectEvent.SetId(ID_MONTHVIEWCLEARSELECTION);
- wxPostEvent(this->monthViewPointer, deselectEvent);
+ wxCommandEvent deselectMonthEvent(XCCALENDARMONTH_DESELECTOTHERENTRIES);
+ deselectMonthEvent.SetClientData(this);
+ deselectMonthEvent.SetId(ID_MONTHVIEWCLEARSELECTION);
+ wxPostEvent(this->monthViewPointer, deselectMonthEvent);
}
// Setup the Is In Month value.
isInMonth = setupIsInMonth;
+ if (isInMonth)
+ {
+ topPanel->SetBackgroundColour(wxColor(255,255,255));
+ mainPanel->SetBackgroundColour(wxColor(225,225,225));
+ eventListFrame->SetBackgroundColour(wxColor(225,225,225));
+ }
+ else
+ {
+ topPanel->SetBackgroundColour(wxColor(185,185,185));
+ mainPanel->SetBackgroundColour(wxColor(155,155,155));
+ eventListFrame->SetBackgroundColour(wxColor(155,155,155));
+ }
// Setup the month view pointer.
}
this->Refresh();
- Repaint();
}
}
this->Refresh();
- Repaint();
}
}
this->Refresh();
- Repaint();
}
}
this->Refresh();
- Repaint();
}
// Get the spacing and hide it as well.
- /*wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
+ wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
afterSpacer->Show(false);
- afterSpacer->DetachSizer();
delete afterSpacer;
- afterSpacer = nullptr;*/
+ afterSpacer = nullptr;
delete (*calendarEntryIter);
deleteEntriesList.push_back(calendarEntryIter);
}
this->Refresh();
- Repaint();
+ mainPanel->Layout();
+ eventListFrame->Layout();
+ eventListFrameSizer->Layout();
for (auto deleteIter : deleteEntriesList){
calendarEntryList.erase(deleteIter);
// Get the spacing and hide it as well.
- /*wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
+ wxSizerItem *afterSpacer = (*calendarEntryIter)->GetAfterSpacer();
afterSpacer->Show(false);
- afterSpacer->DetachSizer();
-
- delete afterSpacer;
- afterSpacer = nullptr;*/
delete (*calendarEntryIter);
deleteEntriesList.push_back(calendarEntryIter);
}
this->Refresh();
- Repaint();
+ this->Layout();
+ eventListFrame->Layout();
+ eventListFrameSizer->Layout();
}
calendarEntryList.push_back(newEntry);
this->Refresh();
- Repaint();
+ mainPanel->Layout();
+ eventListFrame->Layout();
+ eventListFrameSizer->Layout();
}
{
private:
XCCalendarMonthView *monthViewPointer = nullptr;
- wxFlexGridSizer *windowSizer = new wxFlexGridSizer(2, 1, 0, 0);
+ wxPanel *topPanel = nullptr;
+ wxPanel *mainPanel = nullptr;
+ wxBoxSizer *windowSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *topSectionSizer = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *mainSectionSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *eventListFrameSizer = new wxBoxSizer(wxVERTICAL);
- wxStaticBitmap *highPriorityIcon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(32,32), 0);
- wxStaticBitmap *alertIcon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(32,32), 0);
+ wxStaticBitmap *highPriorityIcon = nullptr;
+ wxStaticBitmap *alertIcon = nullptr;
CalendarDataStorage *dataStorage = nullptr;
wxBitmap alertIconBitmap;
wxBitmap priorityIconBitmap;
wxStaticText *numberText = nullptr;
- wxScrolledWindow *eventListFrame = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
+ wxScrolledWindow *eventListFrame = nullptr;
int calendarEntrySeekNumber = 0;
int calendarDay = 0;
int calendarMonth = 0;
vector<XCCalendarDayEntry*> calendarEntryList;
- void Repaint();
-
protected:
void HideAccountEntries(wxCommandEvent &accountData);
void ShowAccountEntries(wxCommandEvent &accountData);
public:
XCCalendarDay(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size);
~XCCalendarDay();
- void PaintFrameEvent(wxPaintEvent &paintEvent);
void ResizeFrameEvent(wxSizeEvent &sizeEvent);
void DeselectOthersEvent(wxCommandEvent &deselectEvent);
void DeselectAllEvent(wxCommandEvent &deselectEvent);
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)
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);
+ // 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);
// 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.
}
}
-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));
}
private:
wxWindow *dayPanel = nullptr;
+ wxPanel *mainPanel = nullptr;
+ wxPanel *borderPanel = nullptr;
+ wxPanel *calendarColour = nullptr;
string eventTextData = "";
wxStaticText *eventTime = nullptr;
wxStaticText *eventText = nullptr;
wxStaticBitmap *highPriorityIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxPoint(14,7), wxDefaultSize, 0 );
wxStaticBitmap *alarmIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxPoint(30,7), wxDefaultSize, 0 );
+ wxBoxSizer *mainSizer = nullptr;
+ wxBoxSizer *borderSizer = nullptr;
wxSizerItem *afterSpacer = nullptr;
wxBitmap alarmIconBitmap;
wxBitmap priorityIconBitmap;
const int secondPosition = 30;
const int thirdPosition = 49;
- void Repaint();
- void RepaintSelected();
-
void UpdateInformation();
string BuildEventTime(int timeHour, int timeMinute);
XCCalendarDayEntry(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size, const int id);
~XCCalendarDayEntry();
- void PaintFrameEvent(wxPaintEvent &paintEvent);
void ResizeFrameEvent(wxSizeEvent &sizeEvent);
void Deselect(wxCommandEvent &deselectEvent);
wxDEFINE_EVENT(XCCALENDARMONTH_UPDATECALENDARCOLOUR, wxCommandEvent);
BEGIN_EVENT_TABLE(XCCalendarMonthView, wxPanel)
-EVT_PAINT(XCCalendarMonthView::PaintFrameEvent)
END_EVENT_TABLE()
XCCalendarMonthView::XCCalendarMonthView(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid, CalendarDataStorage *dataStorage, std::vector<int> *hideAccounts, std::vector<int> *hideCalendars)
// Add Calendar entries.
- XCCalendarDay *calendarDayItem = new XCCalendarDay(this, "XCCalendarMonthView Test", wxPoint(50, 50), wxSize(200, 200));
-
+ XCCalendarDay *calendarDayItem = new XCCalendarDay(this, "XCCalendarMonthView Test", wxPoint(50, 50), wxSize(100,100));
+
// Setup the control.
calendarDayItem->SetupControl((*dayIter).day, (*dayIter).month, (*dayIter).year, (*dayIter).isInMonth, this, calendarStorage, hideAccounts, hideCalendars);
}
-void XCCalendarMonthView::Repaint(){
-
- // Draw the border.
-
- this->Layout();
-
-}
-
-void XCCalendarMonthView::PaintFrameEvent(wxPaintEvent &PaintEvent){
-
- Repaint();
-
-}
-
void XCCalendarMonthView::ResizeFrameEvent(wxSizeEvent &SizeEvent){
// TODO: Check if window size is less than 120 pixels and if it is,
void ProcessGrid(XCCalendarMonthViewGrid *grid, std::vector<int> *hideAccounts, std::vector<int> *hideCalendars);
- void Repaint();
-
protected:
void HideAccountEntries(wxCommandEvent &accountData);
void ShowAccountEntries(wxCommandEvent &accountData);
XCCalendarMonthView(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid, CalendarDataStorage *dataStorage, std::vector<int> *hideAccounts, std::vector<int> *hideCalendars);
XCCalendarMonthView(XCCalendarMonthViewGrid *grid, CalendarDataStorage *dataStorage, std::vector<int> *hideAccounts, std::vector<int> *hideCalendars);
~XCCalendarMonthView();
-
- void PaintFrameEvent(wxPaintEvent &paintEvent);
+
void ResizeFrameEvent(wxSizeEvent &sizeEvent);
void DeselectOthersEvent(wxCommandEvent &deselectEvent);