XCCalendarMonthViewGrid CurrentMonthGrid = GenerateMonthGrid(currentMonth, currentYear);
szrMain->Add(ManipulatorCtrl, 1, wxEXPAND, 5);
- // TODO: Get the list of hidden accounts and calendars.
+ // Get the list of hidden accounts and calendars.
vector<int> hideAccountsList = ManipulatorCtrl->GetHiddenAccountsList();
vector<int> hideCalendarsList = ManipulatorCtrl->GetHiddenCalendarsList();
Connect(ID_SHOWENTRIES, XCCALENDARCTRL_SHOWACCOUNTENTRIES, wxCommandEventHandler(XCCalendarCtrl::ShowAccountEntries));
Connect(ID_HIDECALENDARENTRIES, XCCALENDARCTRL_HIDECALENDARENTRIES, wxCommandEventHandler(XCCalendarCtrl::HideCalendarEntries));
Connect(ID_SHOWCALENDARENTRIES, XCCALENDARCTRL_SHOWCALENDARENTRIES, wxCommandEventHandler(XCCalendarCtrl::ShowCalendarEntries));
+ Connect(ID_DELETECALENDARENTRIES, XCCALENDARCTRL_DELETECALENDARENTRIES, wxCommandEventHandler(XCCalendarCtrl::DeleteCalendarEntries));
+ Connect(ID_DELETEENTRY, XCCALENDARCTRL_DELETEENTRY, wxCommandEventHandler(XCCalendarCtrl::DeleteCalendarEntry));
+ Connect(ID_ADDENTRY, XCCALENDARCTRL_ADDENTRY, wxCommandEventHandler(XCCalendarCtrl::AddCalendarEntry));
+ Connect(ID_UPDATEENTRY, XCCALENDARCTRL_UPDATEENTRY, wxCommandEventHandler(XCCalendarCtrl::UpdateCalendarEntry));
+ Connect(ID_UPDATECOLOUR, XCCALENDARCTRL_UPDATECALENDARCOLOUR, wxCommandEventHandler(XCCalendarCtrl::UpdateCalendarColour));
}
event.SetId(ID_SHOWCALENDARENTRIES);
wxPostEvent(MonthViewCtrl, event);
+}
+
+void XCCalendarCtrl::DeleteCalendarEntries(wxCommandEvent &calendarData){
+
+ wxCommandEvent event(XCCALENDARMONTH_DELETECALENDARENTRIES);
+ event.SetInt(calendarData.GetInt());
+ event.SetId(ID_DELETECALENDARENTRIES);
+ wxPostEvent(MonthViewCtrl, event);
+
+}
+
+void XCCalendarCtrl::DeleteCalendarEntry(wxCommandEvent &eventData){
+
+ wxCommandEvent event(XCCALENDARMONTH_DELETEENTRY);
+ event.SetInt(eventData.GetInt());
+ event.SetId(ID_DELETEENTRY);
+ wxPostEvent(MonthViewCtrl, event);
+
+}
+
+void XCCalendarCtrl::AddCalendarEntry(wxCommandEvent &eventData){
+
+ EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+
+ eventInfo->hideAccountsList = ManipulatorCtrl->GetHiddenAccountsList();
+ eventInfo->hideCalendarsList = ManipulatorCtrl->GetHiddenCalendarsList();
+
+ wxCommandEvent addEvent(XCCALENDARMONTH_ADDENTRY);
+ addEvent.SetId(ID_ADDENTRY);
+ addEvent.SetClientData(eventInfo);
+ wxPostEvent(MonthViewCtrl, addEvent);
+
+}
+
+void XCCalendarCtrl::UpdateCalendarEntry(wxCommandEvent &eventData){
+
+ EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+
+ wxCommandEvent addEvent(XCCALENDARMONTH_UPDATEENTRY);
+ addEvent.SetId(ID_UPDATEENTRY);
+ addEvent.SetClientData(eventInfo);
+ wxPostEvent(MonthViewCtrl, addEvent);
+
+}
+
+void XCCalendarCtrl::UpdateCalendarColour(wxCommandEvent &colourData){
+
+ ColourUpdateProperties *colourInfo = (ColourUpdateProperties*)colourData.GetClientData();
+
+ wxCommandEvent colourEvent(XCCALENDARMONTH_UPDATECALENDARCOLOUR);
+ colourEvent.SetId(ID_UPDATECOLOUR);
+ colourEvent.SetClientData(colourInfo);
+ wxPostEvent(MonthViewCtrl, colourEvent);
+
}
\ No newline at end of file
#define __WIDGETS_XCCALENDARCTRL_H__
#include <wx/wx.h>
+#include <vector>
+#include "structs.h"
#include "events.h"
#include "XCCalendarMonthView.h"
void ShowAccountEntries(wxCommandEvent &accountData);
void HideCalendarEntries(wxCommandEvent &calendarData);
void ShowCalendarEntries(wxCommandEvent &calendarData);
+ void DeleteCalendarEntries(wxCommandEvent &calendarData);
+ void DeleteCalendarEntry(wxCommandEvent &eventData);
+ void AddCalendarEntry(wxCommandEvent &eventData);
+ void UpdateCalendarEntry(wxCommandEvent &eventData);
+ void UpdateCalendarColour(wxCommandEvent &colourData);
public:
XCCalendarCtrl(wxWindow *parent, CalendarDataStorage *storage);
~XCCalendarCtrl();
+
DECLARE_EVENT_TABLE()
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));
+
}
XCCalendarDay::~XCCalendarDay(){
void XCCalendarDay::SetupControl(int SetupDay, int SetupMonth, int SetupYear, bool SetupIsInMonth, XCCalendarMonthView *MonthViewPointer, CalendarDataStorage *dataStorage, vector<int> *hideAccounts, vector<int> *hideCalendars)
{
+ this->dataStorage = dataStorage;
+
// Set the day
NumberText->SetLabel(wxString::Format("%02i", SetupDay));
for (vector<int>::iterator hideAccountsItem = hideAccounts->begin();
hideAccountsItem != hideAccounts->end(); hideAccountsItem++){
- if (*hideAccountsItem = newEntryCalendarInfo.accountID){
+ if (*hideAccountsItem == newEntryCalendarInfo.accountID){
newEntry->Show(false);
newEntry->GetAfterSpacer()->Show(false);
}
if (*hideCalendarsItem == newEntryInfo.calendarID){
newEntry->Show(false);
newEntry->GetAfterSpacer()->Show(false);
- }
+ }
}
this->Refresh();
Repaint();
+}
+
+void XCCalendarDay::DeleteCalendarEntries(wxCommandEvent &calendarData){
+
+ vector<vector<XCCalendarDayEntry*>::iterator> DeleteEntriesList;
+
+ for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+ CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+
+ if ((*CalendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
+
+ wxSizerItem *calendarItem = EventListFrameSizer->GetItem((*CalendarEntryIter));
+ (*CalendarEntryIter)->Show(false);
+
+ // Get the spacing and hide it as well.
+
+ wxSizerItem *afterSpacer = (*CalendarEntryIter)->GetAfterSpacer();
+ afterSpacer->Show(false);
+ afterSpacer->DetachSizer();
+
+ delete afterSpacer;
+ afterSpacer = nullptr;
+
+ delete (*CalendarEntryIter);
+ DeleteEntriesList.push_back(CalendarEntryIter);
+
+ }
+
+ }
+
+ this->Refresh();
+ Repaint();
+
+ for (auto DeleteIter : DeleteEntriesList){
+ CalendarEntryList.erase(DeleteIter);
+ }
+
+}
+
+void XCCalendarDay::DeleteCalendarEntry(wxCommandEvent &eventData){
+
+ vector<vector<XCCalendarDayEntry*>::iterator> DeleteEntriesList;
+
+ for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+ CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+
+ if ((*CalendarEntryIter)->GetEventID() == eventData.GetInt()){
+
+ wxSizerItem *calendarItem = EventListFrameSizer->GetItem((*CalendarEntryIter));
+ (*CalendarEntryIter)->Show(false);
+
+ // Get the spacing and hide it as well.
+
+ wxSizerItem *afterSpacer = (*CalendarEntryIter)->GetAfterSpacer();
+ afterSpacer->Show(false);
+ afterSpacer->DetachSizer();
+
+ delete afterSpacer;
+ afterSpacer = nullptr;
+
+ delete (*CalendarEntryIter);
+ DeleteEntriesList.push_back(CalendarEntryIter);
+
+ }
+
+ }
+
+ for (auto DeleteIter : DeleteEntriesList){
+ CalendarEntryList.erase(DeleteIter);
+ }
+
+ this->Refresh();
+ Repaint();
+
+}
+
+void XCCalendarDay::AddCalendarEntry(wxCommandEvent &eventData){
+
+ EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+
+ XCCalendarDayEntry *newEntry = new XCCalendarDayEntry(EventListFrame, eventInfo->eventName, wxDefaultPosition, wxDefaultSize, eventInfo->eventID);
+
+ CDSGetCalendarInfo calendarInfo = dataStorage->GetCalendar(eventInfo->calendarID);
+
+ newEntry->SetColour(&calendarInfo.calendarColour);
+ newEntry->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
+ newEntry->SetEntryIDs(calendarInfo.accountID, eventInfo->calendarID, eventInfo->eventID);
+
+ EventListFrameSizer->Add(newEntry, 0, wxEXPAND, 5);
+ wxSizerItem *afterSpacer = EventListFrameSizer->Add(0, 5, 0, 0, 5);
+
+ newEntry->SetAfterSpacer(afterSpacer);
+
+ // Go through the list of calendar entries to hide by account.
+
+ for (vector<int>::iterator hideAccountsItem = eventInfo->hideAccountsList.begin();
+ hideAccountsItem != eventInfo->hideAccountsList.end(); hideAccountsItem++){
+
+ if (*hideAccountsItem = calendarInfo.accountID){
+ newEntry->Show(false);
+ newEntry->GetAfterSpacer()->Show(false);
+ }
+
+ }
+
+ // Go through the list of calendar entries to hide by calendar.
+
+ for (vector<int>::iterator hideCalendarsItem = eventInfo->hideCalendarsList.begin();
+ hideCalendarsItem != eventInfo->hideCalendarsList.end(); hideCalendarsItem++){
+
+ if (*hideCalendarsItem == eventInfo->calendarID){
+ newEntry->Show(false);
+ newEntry->GetAfterSpacer()->Show(false);
+ }
+
+ }
+
+ CalendarEntryList.push_back(newEntry);
+
+ this->Refresh();
+ Repaint();
+
+}
+
+void XCCalendarDay::UpdateCalendarEntry(wxCommandEvent &eventData){
+
+ // Go thorugh each of the entries in the day and
+ // then update it.
+
+ EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+
+ for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+ CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+
+ if ((*CalendarEntryIter)->GetEventID() == eventInfo->eventID){
+
+ (*CalendarEntryIter)->SetEventName(eventInfo->eventName);
+ (*CalendarEntryIter)->SetTime(eventInfo->eventHour, eventInfo->eventMinute, eventInfo->eventSecond);
+
+
+ }
+
+ }
+
+ delete eventInfo;
+ eventInfo = nullptr;
+
+}
+
+void XCCalendarDay::UpdateCalendarColour(wxCommandEvent &colourData){
+
+ // Go thorugh each of the entries in the day and
+ // then update it.
+
+ ColourUpdateProperties *colourInfo = (ColourUpdateProperties*)colourData.GetClientData();
+
+ for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+ CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+
+ if ((*CalendarEntryIter)->GetCalendarID() == colourInfo->calendarID){
+
+ (*CalendarEntryIter)->SetColour(&colourInfo->newColour);
+
+ }
+
+ }
+
+}
+
+int XCCalendarDay::GetCalendarDay(){
+
+ return calendarDay;
+
+}
+
+int XCCalendarDay::GetCalendarMonth(){
+
+ return calendarMonth;
+
+}
+
+int XCCalendarDay::GetCalendarYear(){
+
+ return calendarYear;
+
}
\ No newline at end of file
#include <wx/dcbuffer.h>
#include <wx/mstream.h>
#include <vector>
+#include <memory>
#include "XCCalendarDayEntry.h"
#include "XCCalendarMonthView.h"
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);
+ CalendarDataStorage *dataStorage = nullptr;
wxBitmap AlertIconBitmap;
wxBitmap PriorityIconBitmap;
wxStaticText *NumberText = nullptr;
bool IsInMonth = false;
vector<XCCalendarDayEntry*> CalendarEntryList;
- vector<size_t> CalendarEntryListIndex;
void Repaint();
void ShowAccountEntries(wxCommandEvent &accountData);
void HideCalendarEntries(wxCommandEvent &calendarData);
void ShowCalendarEntries(wxCommandEvent &calendarData);
+ void DeleteCalendarEntries(wxCommandEvent &calendarData);
+ void DeleteCalendarEntry(wxCommandEvent &eventData);
+ void AddCalendarEntry(wxCommandEvent &eventData);
+ void UpdateCalendarEntry(wxCommandEvent &eventData);
+ void UpdateCalendarColour(wxCommandEvent &colourData);
public:
XCCalendarDay(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size);
void DeselectAllEvent(wxCommandEvent &DeselectEvent);
void UpdateTopIcons();
void SetupControl(int SetupDay, int SetupMonth, int SetupYear, bool SetupIsInMonth, XCCalendarMonthView *MonthViewPointer, CalendarDataStorage *dataStorage, std::vector<int> *hideAccounts, std::vector<int> *hideCalendars);
+ int GetCalendarDay();
+ int GetCalendarMonth();
+ int GetCalendarYear();
DECLARE_EVENT_TABLE()
BEGIN_EVENT_TABLE(XCCalendarDayEntry, wxPanel)
EVT_PAINT(XCCalendarDayEntry::PaintFrameEvent)
EVT_SIZE(XCCalendarDayEntry::ResizeFrameEvent)
-EVT_LEFT_DOWN(XCCalendarDayEntry::LeftClick)
+EVT_LEFT_UP(XCCalendarDayEntry::LeftClick)
+EVT_RIGHT_UP(XCCalendarDayEntry::RightClick)
END_EVENT_TABLE()
using namespace std;
: wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){
DayPanel = parent->GetParent();
- entryID = id;
+ eventID = id;
this->SetMinSize(wxSize(65, 30));
HighPriorityIcon->SetBitmap(PriorityIconBitmap);
Connect(ID_ENTRYDESELECT, XCCALENDARDAYENTRY_DESELECT, wxCommandEventHandler(XCCalendarDayEntry::Deselect));
+
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);
+ 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);
+ EventTime->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarDayEntry::RightClick), NULL, this);
+ DayPanel->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarDayEntry::RightClick), NULL, this);
+
UpdateInformation();
}
this->SetBackgroundColour(wxColor(255,215,0));
wxCommandEvent DeselectOthersEvent(XCCALENDARDAY_DESELECTOTHERENTRIES);
- DeselectOthersEvent.SetInt(entryID);
+ DeselectOthersEvent.SetInt(eventID);
DeselectOthersEvent.SetId(ID_DESELECTOTHERENTRIES);
wxPostEvent(DayPanel, DeselectOthersEvent);
}
+void XCCalendarDayEntry::RightClick(wxMouseEvent &MouseEvent){
+
+ // Sent an event to the month view control.
+
+ EventProperties *eventData = new EventProperties;
+ eventData->calendarID = calendarID;
+ eventData->eventID = eventID;
+
+ wxCommandEvent eventMenu(XCCALENDARMONTH_DISPLAYEVENTMENU);
+ eventMenu.SetClientData(eventData);
+ eventMenu.SetId(ID_DISPLAYEVENTMENU);
+ wxPostEvent(this->GetParent()->GetParent(), eventMenu);
+
+}
+
void XCCalendarDayEntry::Deselect(wxCommandEvent &DeselectEvent){
this->SetBackgroundColour(wxNullColour);
int XCCalendarDayEntry::GetID(){
- return entryID;
+ return eventID;
}
}
+int XCCalendarDayEntry::GetEventID(){
+
+ return eventID;
+
+}
+
int XCCalendarDayEntry::GetAccountID(){
return accountID;
}
-void XCCalendarDayEntry::SetEntryIDs(int accountID, int calendarID, int entryID){
+void XCCalendarDayEntry::SetEntryIDs(int accountID, int calendarID, int eventID){
this->accountID = accountID;
this->calendarID = calendarID;
- this->entryID = entryID;
+ this->eventID = eventID;
}
}
+void XCCalendarDayEntry::SetEventName(string eventName){
+
+ EventText->SetLabel((wxString)eventName);
+
+}
+
wxSizerItem* XCCalendarDayEntry::GetAfterSpacer(){
return afterSpacer;
#include "../common/events.h"
#include "../bitmaps.h"
+#include "structs.h"
+
enum XCCalendarDayEntryMode {
XCCALENDARDAYENTRY_NORMAL,
XCCALENDARDAYENTRY_SMALL,
bool HasHighPriority = false;
int PositionMode = 0;
- int entryID = 0;
+ int eventID = 0;
int accountID = 0;
int calendarID =0;
bool showAccount = true;
string BuildEventTime(int timeHour, int timeMinute);
protected:
+ void LeftClick(wxMouseEvent &MouseEvent);
+ void RightClick(wxMouseEvent &MouseEvent);
public:
XCCalendarDayEntry(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size, const int id);
void PaintFrameEvent(wxPaintEvent &PaintEvent);
void ResizeFrameEvent(wxSizeEvent &SizeEvent);
- void LeftClick(wxMouseEvent &MouseEvent);
void Deselect(wxCommandEvent &DeselectEvent);
void SetTime(int timeHour, int timeMinute, int timeSecond);
void SetColour(Colour *ColourIn);
void SetDisplayAlarm(bool DisplayValue);
void SetDisplayHighPriority(bool DisplayValue);
- void SetEntryIDs(int accountID, int calendarID, int entryID);
+ void SetEntryIDs(int accountID, int calendarID, int eventID);
void SetAfterSpacer(wxSizerItem *afterSpacer);
+ void SetEventName(std::string eventName);
int GetID();
int GetCalendarID();
+ int GetEventID();
int GetAccountID();
wxSizerItem* GetAfterSpacer();
bool GetDisplayAlarm();
}
- // TODO: Delete the old controls.
+ // Delete the old controls. Remember which setting the checkboxes were hidden so they
+ // can be restored later on.
+
+ vector<int> calendarHiddenAccountsList = GetHiddenAccountsList();
+ vector<int> calendarHiddenCalendarsList = GetHiddenCalendarsList();
for (vector<XCCalendarListAccountCtrl*>::iterator accountCtrlIter = accountControlList.begin();
accountCtrlIter != accountControlList.end(); accountCtrlIter++){
XCCalendarListAccountCtrl *newAccountCtrl = new XCCalendarListAccountCtrl(this, accountListData.accountList[AccountSeek].accountName);
newAccountCtrl->SetAccountID(accountListData.accountList[AccountSeek].accountID);
+ newAccountCtrl->SetAccountPreferencesID(accountListData.accountList[AccountSeek].accountPreferencesID);
szrMain->Add(newAccountCtrl, 0, wxEXPAND, 5);
+ if (find(calendarHiddenAccountsList.begin(), calendarHiddenAccountsList.end(), accountListData.accountList[AccountSeek].accountID) != calendarHiddenAccountsList.end()){
+
+ newAccountCtrl->SetCheckBoxValue(wxCHK_UNCHECKED);
+
+ }
+
accountControlList.push_back(newAccountCtrl);
// Get the list of calendars and create controls.
XCCalendarListCalendarCtrl *newCalendarCtrl = new XCCalendarListCalendarCtrl(this, calendarInfo.calendarName, calendarInfo.calendarColour);
newCalendarCtrl->SetCalendarID(accountCalendarList.calendarList[calendarSeek]);
+ newCalendarCtrl->SetAccountPreferencesID(accountListData.accountList[AccountSeek].accountPreferencesID);
+
+ if (find(calendarHiddenCalendarsList.begin(), calendarHiddenCalendarsList.end(), accountCalendarList.calendarList[calendarSeek]) != calendarHiddenCalendarsList.end()){
+
+ newCalendarCtrl->SetCheckBoxValue(wxCHK_UNCHECKED);
+
+ }
+
newAccountCtrl->AddCalendar(newCalendarCtrl);
szrMain->Add(newCalendarCtrl, 0, wxEXPAND, 5);
}
+void XCCalendarListAccountCtrl::SetAccountPreferencesID(int accountID){
+
+ this->accountPreferencesID = accountPreferencesID;
+
+}
+
vector<int> XCCalendarListAccountCtrl::GetHiddenCalendarList(){
vector<int> calendarList;
return calendarList;
+}
+
+void XCCalendarListAccountCtrl::SetCheckBoxValue(wxCheckBoxState newValue){
+
+ if (newValue == wxCHK_CHECKED){
+ showAccounts = true;
+ } else {
+ showAccounts = false;
+ }
+
+ chkShowAll->SetValue(newValue);
+
}
\ No newline at end of file
protected:
std::vector<XCCalendarListCalendarCtrl*> calendarControlList;
int accountID = 0;
+ int accountPreferencesID = 0;
AccountType accountType = ACCOUNTTYPE_UNKNOWN;
std::string accountName = "";
bool showAccounts = true;
wxCheckBoxState GetShowCheckboxState();
int GetAccountID();
void SetAccountID(int accountID);
+ void SetAccountPreferencesID(int accountID);
+ void SetCheckBoxValue(wxCheckBoxState newValue);
std::vector<int> GetHiddenCalendarList();
DECLARE_EVENT_TABLE();
// Setup the checkbox.
- //chkShowAll = new wxCheckBox();
-
chkShowCalendar = new wxCheckBox(this, wxID_ANY, "", wxPoint(0,0), wxDefaultSize, wxCHK_3STATE, wxDefaultValidator, "");
// Setup the label.
pnlColour = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(16,16), 0, "");
pnlColour->SetBackgroundColour(wxColour(calendarColour.red, calendarColour.green, calendarColour.blue, calendarColour.alpha));
+ // Setup the popup menu.
+
+ calendarMenu = new XCCalendarMenu();
+ calendarMenu->SetWindowPointer(this);
+ calendarMenu->SetPopupPointer((wxPopupTransientWindow*)this->GetParent());
+
// Connect them to the sizer.
szrMain->Add(15, 0, 0, 0, 5);
// Connect the events to the controls.
chkShowCalendar->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxMouseEventHandler(XCCalendarListCalendarCtrl::ShowAllCheckboxClick), NULL, this);
+ chkShowCalendar->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarListCalendarCtrl::PopupMenu), NULL, this);
+ lblCalendarName->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarListCalendarCtrl::PopupMenu), NULL, this);
+ pnlColour->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarListCalendarCtrl::PopupMenu), NULL, this);
+ Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarListCalendarCtrl::PopupMenu), NULL, this);
chkShowCalendar->SetValue(wxCHK_CHECKED);
}
void XCCalendarListCalendarCtrl::SetCalendarID(int calendarID){
this->calendarID = calendarID;
+ calendarMenu->SetCalendarID(this->calendarID);
+
+}
+
+void XCCalendarListCalendarCtrl::SetAccountPreferencesID(int accountPreferencesID){
+
+ this->accountPreferencesID = accountPreferencesID;
+ calendarMenu->SetAccountPreferencesID(this->accountPreferencesID);
}
}
+}
+
+void XCCalendarListCalendarCtrl::SetCheckBoxValue(wxCheckBoxState newValue){
+
+ if (newValue == wxCHK_CHECKED){
+ showCalendar = true;
+ } else {
+ showCalendar = false;
+ }
+
+ chkShowCalendar->SetValue(newValue);
+
+}
+
+void XCCalendarListCalendarCtrl::PopupMenu( wxMouseEvent &mouseEvent ){
+
+ this->GetParent()->GetParent()->GetParent()->GetParent()->PopupMenu(calendarMenu->MenuPointer(), wxDefaultPosition);
+
}
\ No newline at end of file
#include "types.h"
#include "colour.h"
#include "events.h"
+#include "XCCalendarMenu.h"
class XCCalendarListCalendarCtrl: public wxPanel{
wxCheckBox *chkShowCalendar = nullptr;
wxStaticText *lblCalendarName = nullptr;
wxStaticBitmap *imgCalendarIcon = nullptr;
+ XCCalendarMenu *calendarMenu = nullptr;
wxPanel *pnlColour = nullptr;
+ int accountPreferencesID = 0;
protected:
int calendarID = 0;
std::string calendarName = "";
bool showCalendar = true;
void ShowAllCheckboxClick( wxMouseEvent &mouseEvent );
+ void PopupMenu( wxMouseEvent &mouseEvent );
public:
XCCalendarListCalendarCtrl(wxWindow* parent, string calendarName, Colour calendarColour);
~XCCalendarListCalendarCtrl();
wxCheckBoxState GetShowCheckboxState();
int GetCalendarID();
void SetCalendarID(int calendarID);
+ void SetAccountPreferencesID(int accountID);
+ void SetCheckBoxValue(wxCheckBoxState newValue);
};
FridayText = new XCCalendarMonthViewDayTitle(this, _("Friday"), wxDefaultPosition, wxDefaultSize);
SaturdayText = new XCCalendarMonthViewDayTitle(this, _("Saturday"), wxDefaultPosition, wxDefaultSize);
SundayText = new XCCalendarMonthViewDayTitle(this, _("Sunday"), wxDefaultPosition, wxDefaultSize);
+
+ eventMenu = new XCEventMenu;
WindowSizer->Add(MondayText, 1, wxEXPAND|wxALL, 0);
WindowSizer->Add(TuesdayText, 1, wxEXPAND|wxALL, 0);
Connect(ID_SHOWENTRIES, XCCALENDARMONTH_SHOWACCOUNTENTRIES, wxCommandEventHandler(XCCalendarMonthView::ShowAccountEntries));
Connect(ID_HIDECALENDARENTRIES, XCCALENDARMONTH_HIDECALENDARENTRIES, wxCommandEventHandler(XCCalendarMonthView::HideCalendarEntries));
Connect(ID_SHOWCALENDARENTRIES, XCCALENDARMONTH_SHOWCALENDARENTRIES, wxCommandEventHandler(XCCalendarMonthView::ShowCalendarEntries));
-
+ Connect(ID_DELETECALENDARENTRIES, XCCALENDARMONTH_DELETECALENDARENTRIES, wxCommandEventHandler(XCCalendarMonthView::DeleteCalendarEntries));
+ Connect(ID_DISPLAYEVENTMENU, XCCALENDARMONTH_DISPLAYEVENTMENU, wxCommandEventHandler(XCCalendarMonthView::ShowEventMenu));
+ Connect(ID_DELETEENTRY, XCCALENDARMONTH_DELETEENTRY, wxCommandEventHandler(XCCalendarMonthView::DeleteCalendarEntry));
+ Connect(ID_ADDENTRY, XCCALENDARMONTH_ADDENTRY, wxCommandEventHandler(XCCalendarMonthView::AddCalendarEntry));
+ Connect(ID_UPDATEENTRY, XCCALENDARMONTH_UPDATEENTRY, wxCommandEventHandler(XCCalendarMonthView::UpdateCalendarEntry));
+ Connect(ID_UPDATECOLOUR, XCCALENDARMONTH_UPDATECALENDARCOLOUR, wxCommandEventHandler(XCCalendarMonthView::UpdateCalendarColour));
+
}
XCCalendarMonthView::XCCalendarMonthView(XCCalendarMonthViewGrid *grid, CalendarDataStorage *dataStorage, std::vector<int> *hideAccounts, std::vector<int> *hideCalendars)
}
+}
+
+void XCCalendarMonthView::DeleteCalendarEntries(wxCommandEvent &calendarData){
+
+ for (vector<XCCalendarDay*>::iterator DayIter = CalendarDayList.begin();
+ DayIter != CalendarDayList.end(); DayIter++){
+
+ wxCommandEvent deleteEvent(XCCALENDARDAY_DELETECALENDARENTRIES);
+ deleteEvent.SetInt(calendarData.GetInt());
+ deleteEvent.SetId(ID_DELETECALENDARENTRIES);
+ wxPostEvent((*DayIter), deleteEvent);
+
+ }
+
+}
+
+void XCCalendarMonthView::DeleteCalendarEntry(wxCommandEvent &eventData){
+
+ for (vector<XCCalendarDay*>::iterator DayIter = CalendarDayList.begin();
+ DayIter != CalendarDayList.end(); DayIter++){
+
+ wxCommandEvent deleteEvent(XCCALENDARDAY_DELETEENTRY);
+ deleteEvent.SetInt(eventData.GetInt());
+ deleteEvent.SetId(ID_DELETEENTRY);
+ wxPostEvent((*DayIter), deleteEvent);
+
+ }
+
+}
+
+void XCCalendarMonthView::AddCalendarEntry(wxCommandEvent &eventData){
+
+ EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+ bool foundDate = false;
+
+ for (vector<XCCalendarDay*>::iterator DayIter = CalendarDayList.begin();
+ DayIter != CalendarDayList.end(); DayIter++){
+
+ // Check if the date matches with the date in the day
+ // widget. If it does, add the widget.
+
+ if ((*DayIter)->GetCalendarYear() == eventInfo->eventYear &&
+ (*DayIter)->GetCalendarMonth() == (eventInfo->eventMonth + 1) &&
+ (*DayIter)->GetCalendarDay() == eventInfo->eventDay){
+
+ wxCommandEvent addEvent(XCCALENDARDAY_ADDENTRY);
+ addEvent.SetId(ID_ADDENTRY);
+ addEvent.SetClientData(eventInfo);
+ wxPostEvent((*DayIter), addEvent);
+ foundDate = true;
+ break;
+
+ }
+
+ }
+
+ if (foundDate == false){
+
+ delete eventInfo;
+ eventInfo = nullptr;
+
+ }
+
+}
+
+void XCCalendarMonthView::UpdateCalendarEntry(wxCommandEvent &eventData){
+
+ EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+ bool foundDate = false;
+
+ for (vector<XCCalendarDay*>::iterator DayIter = CalendarDayList.begin();
+ DayIter != CalendarDayList.end(); DayIter++){
+
+ // Check if the date matches with the date in the day
+ // widget. If it does, update the widget.
+
+ if ((*DayIter)->GetCalendarYear() == eventInfo->eventYear &&
+ (*DayIter)->GetCalendarMonth() == (eventInfo->eventMonth + 1) &&
+ (*DayIter)->GetCalendarDay() == eventInfo->eventDay){
+
+ wxCommandEvent addEvent(XCCALENDARDAY_UPDATEENTRY);
+ addEvent.SetId(ID_UPDATEENTRY);
+ addEvent.SetClientData(eventInfo);
+ wxPostEvent((*DayIter), addEvent);
+ foundDate = true;
+ break;
+
+ }
+
+ }
+
+ if (foundDate == false){
+
+ delete eventInfo;
+ eventInfo = nullptr;
+
+ }
+
+}
+
+void XCCalendarMonthView::UpdateCalendarColour(wxCommandEvent &colourData){
+
+ ColourUpdateProperties *colourDataInfo = (ColourUpdateProperties*)colourData.GetClientData();
+
+ for (vector<XCCalendarDay*>::iterator DayIter = CalendarDayList.begin();
+ DayIter != CalendarDayList.end(); DayIter++){
+
+ // Check if the date matches with the date in the day
+ // widget. If it does, update the widget.
+
+ ColourUpdateProperties *colourDataPassInfo = colourDataInfo;
+
+ wxCommandEvent updateColour(XCCALENDARDAY_UPDATECALENDARCOLOUR);
+ updateColour.SetId(ID_UPDATECOLOUR);
+ updateColour.SetClientData(colourDataPassInfo);
+ wxPostEvent((*DayIter), updateColour);
+
+ }
+
+}
+
+void XCCalendarMonthView::ShowEventMenu(wxCommandEvent &eventData){
+
+ EventProperties *eventInfo = (EventProperties*)eventData.GetClientData();
+
+ eventMenu->SetEventID(eventInfo->eventID);
+ eventMenu->SetCalendarID(eventInfo->calendarID);
+ eventMenu->SetWindowPointer(this->GetParent()->GetParent());
+
+ this->PopupMenu(eventMenu, wxDefaultPosition);
+
+ delete eventInfo;
+ eventInfo = nullptr;
+
}
\ No newline at end of file
#include <vector>
#include <wx/wx.h>
-#include "../common/colour.h"
-#include "../common/text.h"
-#include "../common/events.h"
-#include "../common/monthviewgen.h"
+#include "colour.h"
+#include "text.h"
+#include "events.h"
+#include "monthviewgen.h"
+#include "structs.h"
#include "../libraries/CalendarDataStorage/CalendarDataStorage.h"
#include "XCCalendarMonthView.h"
#include "XCCalendarMonthViewDayTitle.h"
#include "XCCalendarDay.h"
+#include "XCEventMenu.h"
class XCCalendarDay;
XCCalendarMonthViewDayTitle *FridayText = nullptr;
XCCalendarMonthViewDayTitle *SaturdayText = nullptr;
XCCalendarMonthViewDayTitle *SundayText = nullptr;
+ XCEventMenu *eventMenu = nullptr;
CalendarDataStorage *calendarStorage = nullptr;
+
void ProcessGrid(XCCalendarMonthViewGrid *grid, std::vector<int> *hideAccounts, std::vector<int> *hideCalendars);
void Repaint();
void ShowAccountEntries(wxCommandEvent &accountData);
void HideCalendarEntries(wxCommandEvent &calendarData);
void ShowCalendarEntries(wxCommandEvent &calendarData);
+ void DeleteCalendarEntries(wxCommandEvent &calendarData);
+ void DeleteCalendarEntry(wxCommandEvent &eventData);
+ void AddCalendarEntry(wxCommandEvent &eventData);
+ void UpdateCalendarEntry(wxCommandEvent &eventData);
+ void UpdateCalendarColour(wxCommandEvent &colourData);
+ void ShowEventMenu(wxCommandEvent &eventData);
public:
XCCalendarMonthView(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, XCCalendarMonthViewGrid *grid, CalendarDataStorage *dataStorage, std::vector<int> *hideAccounts, std::vector<int> *hideCalendars);