using namespace std;
+wxDEFINE_EVENT(XCCALENDARDAY_DESELECTOTHERENTRIES, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_DESELECTALLENTRIES, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_HIDEACCOUNTENTRIES, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_SHOWACCOUNTENTRIES, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_HIDECALENDARENTRIES, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_SHOWCALENDARENTRIES, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_DELETECALENDARENTRIES, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_DELETEENTRY, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_ADDENTRY, wxCommandEvent);
+wxDEFINE_EVENT(XCCALENDARDAY_UPDATEENTRY, wxCommandEvent);
+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->SetSizer(eventListFrameSizer);
eventListFrame->SetScrollRate(0,1);
- //EventListFrameSizer->FitInside(EventListFrame);
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();
- Connect(ID_DESELECTOTHERENTRIES, XCCALENDARDAY_DESELECTOTHERENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectOthersEvent));
- Connect(ID_DESELECTALLITEMS, XCCALENDARDAY_DESELECTALLENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectAllEvent));
- Connect(ID_HIDEENTRIES, XCCALENDARDAY_HIDEACCOUNTENTRIES, wxCommandEventHandler(XCCalendarDay::HideAccountEntries));
- Connect(ID_SHOWENTRIES, XCCALENDARDAY_SHOWACCOUNTENTRIES, wxCommandEventHandler(XCCalendarDay::ShowAccountEntries));
- Connect(ID_HIDECALENDARENTRIES, XCCALENDARDAY_HIDECALENDARENTRIES, wxCommandEventHandler(XCCalendarDay::HideCalendarEntries));
- Connect(ID_SHOWCALENDARENTRIES, XCCALENDARDAY_SHOWCALENDARENTRIES, wxCommandEventHandler(XCCalendarDay::ShowCalendarEntries));
- Connect(ID_DELETECALENDARENTRIES, XCCALENDARDAY_DELETECALENDARENTRIES, wxCommandEventHandler(XCCalendarDay::DeleteCalendarEntries));
- Connect(ID_DELETEENTRY, XCCALENDARDAY_DELETEENTRY, wxCommandEventHandler(XCCalendarDay::DeleteCalendarEntry));
- Connect(ID_ADDENTRY, XCCALENDARDAY_ADDENTRY, wxCommandEventHandler(XCCalendarDay::AddCalendarEntry));
- Connect(ID_UPDATEENTRY, XCCALENDARDAY_UPDATEENTRY, wxCommandEventHandler(XCCalendarDay::UpdateCalendarEntry));
- Connect(ID_UPDATECOLOUR, XCCALENDARDAY_UPDATECALENDARCOLOUR, wxCommandEventHandler(XCCalendarDay::UpdateCalendarColour));
-
+ // Bind events to the control.
+
+ Bind(XCCALENDARDAY_DESELECTOTHERENTRIES, &XCCalendarDay::DeselectOthersEvent, this, ID_DESELECTOTHERENTRIES);
+ Bind(XCCALENDARDAY_DESELECTALLENTRIES, &XCCalendarDay::DeselectAllEvent, this, ID_DESELECTALLITEMS);
+ Bind(XCCALENDARDAY_HIDEACCOUNTENTRIES, &XCCalendarDay::HideAccountEntries, this, ID_HIDEENTRIES);
+ Bind(XCCALENDARDAY_SHOWACCOUNTENTRIES, &XCCalendarDay::ShowAccountEntries, this, ID_SHOWENTRIES);
+ Bind(XCCALENDARDAY_HIDECALENDARENTRIES, &XCCalendarDay::HideCalendarEntries, this, ID_HIDECALENDARENTRIES);
+ Bind(XCCALENDARDAY_SHOWCALENDARENTRIES, &XCCalendarDay::ShowCalendarEntries, this, ID_SHOWCALENDARENTRIES);
+ Bind(XCCALENDARDAY_DELETECALENDARENTRIES, &XCCalendarDay::DeleteCalendarEntries, this, ID_DELETECALENDARENTRIES);
+ Bind(XCCALENDARDAY_DELETEENTRY, &XCCalendarDay::DeleteCalendarEntry, this, ID_DELETEENTRY);
+ Bind(XCCALENDARDAY_ADDENTRY, &XCCalendarDay::AddCalendarEntry, this, ID_ADDENTRY);
+ Bind(XCCALENDARDAY_UPDATEENTRY, &XCCalendarDay::UpdateCalendarEntry, this, ID_UPDATEENTRY);
+ Bind(XCCALENDARDAY_UPDATECALENDARCOLOUR, &XCCalendarDay::UpdateCalendarColour, this, ID_UPDATECOLOUR);
}
XCCalendarDay::~XCCalendarDay(){
// Destory the controls from the widget.
+ Unbind(XCCALENDARDAY_DESELECTOTHERENTRIES, &XCCalendarDay::DeselectOthersEvent, this, ID_DESELECTOTHERENTRIES);
+ Unbind(XCCALENDARDAY_DESELECTALLENTRIES, &XCCalendarDay::DeselectAllEvent, this, ID_DESELECTALLITEMS);
+ Unbind(XCCALENDARDAY_HIDEACCOUNTENTRIES, &XCCalendarDay::HideAccountEntries, this, ID_HIDEENTRIES);
+ Unbind(XCCALENDARDAY_SHOWACCOUNTENTRIES, &XCCalendarDay::ShowAccountEntries, this, ID_SHOWENTRIES);
+ Unbind(XCCALENDARDAY_HIDECALENDARENTRIES, &XCCalendarDay::HideCalendarEntries, this, ID_HIDECALENDARENTRIES);
+ Unbind(XCCALENDARDAY_SHOWCALENDARENTRIES, &XCCalendarDay::ShowCalendarEntries, this, ID_SHOWCALENDARENTRIES);
+ Unbind(XCCALENDARDAY_DELETECALENDARENTRIES, &XCCalendarDay::DeleteCalendarEntries, this, ID_DELETECALENDARENTRIES);
+ Unbind(XCCALENDARDAY_DELETEENTRY, &XCCalendarDay::DeleteCalendarEntry, this, ID_DELETEENTRY);
+ Unbind(XCCALENDARDAY_ADDENTRY, &XCCalendarDay::AddCalendarEntry, this, ID_ADDENTRY);
+ Unbind(XCCALENDARDAY_UPDATEENTRY, &XCCalendarDay::UpdateCalendarEntry, this, ID_UPDATEENTRY);
+ Unbind(XCCALENDARDAY_UPDATECALENDARCOLOUR, &XCCalendarDay::UpdateCalendarColour, this, ID_UPDATECOLOUR);
+
for (vector<XCCalendarDayEntry*>::iterator calendarEntryIter = calendarEntryList.begin();
calendarEntryIter != calendarEntryList.end(); calendarEntryIter++){
}
+ eventListFrameSizer->Clear();
+
+ eventListFrame->SetSizer(nullptr, true);
+
+ mainSectionSizer->Clear();
+ topSectionSizer->Clear();
+ windowSizer->Clear();
+
delete alertIcon;
alertIcon = nullptr;
delete eventListFrame;
eventListFrame = nullptr;
- calendarEntryList.clear();
-
-}
+ delete numberText;
+ numberText = nullptr;
-void XCCalendarDay::Repaint(){
-
- wxPaintDC dc(this);
- wxPaintDC eventListFrameDC(eventListFrame);
-
- // Get the wxSizerItem for the top date and the entries part.
+ delete topPanel;
+ topPanel = nullptr;
- wxSizerItem *topSectionSizerItem = windowSizer->GetItem((size_t)0);
- wxSizerItem *mainSectionSizerItem = windowSizer->GetItem((size_t)1);
- wxRect topSizer = wxRect(windowSizer->GetPosition(), windowSizer->GetSize());
+ delete mainPanel;
+ mainPanel = nullptr;
- if (isInMonth == true){
+ calendarEntryList.clear();
- 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());
-
- }
+ this->SetSizer(nullptr, true);
- // Draw the border.
-
- //dc.SetBrush(wxBrush(wxColor(0,0,0), wxBRUSHSTYLE_TRANSPARENT));
-
- this->Layout();
+ monthViewPointer = nullptr;
+ dataStorage = nullptr;
}
}
-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();
}
wxPostEvent((*entryIter), deselectEntryEvent);
}
-
+
}
// Send event notification to deselect the other calendar entries.
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();
-
- for (auto deleteIter : deleteEntriesList){
+ mainPanel->Layout();
+
+ for (auto deleteIter : deleteEntriesList) {
calendarEntryList.erase(deleteIter);
}
-
+
+ if (calendarEntryList.size() > 0)
+ {
+ eventListFrame->Layout();
+ eventListFrameSizer->Layout();
+ }
+
}
void XCCalendarDay::DeleteCalendarEntry(wxCommandEvent &eventData){
// 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();
}
EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
- XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(eventListFrame, eventInfo->eventName, wxDefaultPosition, wxDefaultSize, eventInfo->eventID);
+ // TODO: Fix conversion from string to wxString
+ XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(eventListFrame, wxString(eventInfo->eventName.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, eventInfo->eventID);
CDSGetCalendarInfo calendarInfo = dataStorage->GetCalendar(eventInfo->calendarID);
calendarEntryList.push_back(newEntry);
this->Refresh();
- Repaint();
+ mainPanel->Layout();
+ eventListFrame->Layout();
+ eventListFrameSizer->Layout();
}
(*calendarEntryIter)->SetEventName(eventInfo->eventName);
(*calendarEntryIter)->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
-
}
}