1 #include "frmCalendarEditor.h"
5 frmCalendarEditor::frmCalendarEditor( wxWindow* parent )
7 frmCalendarEditorADT( parent )
12 void frmCalendarEditor::SetMode(bool setMode){
16 if (editMode == true){
18 lblAccount->Show(false);
19 cmbAccount->Show(false);
20 btnCreate->SetLabel(_("Update"));
26 void frmCalendarEditor::CloseWindow( wxCommandEvent &event )
33 void frmCalendarEditor::SetupAccounts(XCALPreferences *preferencesData){
35 for (int accountSeek = 0; accountSeek < preferencesData->accounts.GetCount(); accountSeek++){
37 // Check if the account is a supported type before adding.
39 if (preferencesData->accounts.GetAccountType(accountSeek) != wxT("Local")){
41 // Go to the next account.
47 cmbAccount->Append(preferencesData->accounts.GetAccountName(accountSeek));
48 accountPrefencesIDList.push_back(accountSeek);
52 this->preferencesData = preferencesData;
56 void frmCalendarEditor::ProcessCalendar( wxCommandEvent &event ){
58 // Check that an account has been selected before continuing.
60 if (cmbAccount->GetCurrentSelection() == -1 && editMode == false){
61 wxMessageBox(_("No account was selected for this calendar."), _("Error"));
65 // Check that the calendar has a name before continuing.
67 if (txtName->IsEmpty()){
68 wxMessageBox(_("No name for the calendar has been entered."), _("Error"));
72 // Post an event to the main window to create or edit the calendar with the
75 CalendarProperties *calendarInfo = new CalendarProperties;
79 if (editMode == true){
81 calendarInfo->accountPreferencesID = accountPrefencesIDList[cmbAccount->GetCurrentSelection()];
82 calendarInfo->calendarID = calendarID;
86 // Go through the list of accounts and find the matching account name.
90 for (accountSeek = 0; accountSeek < preferencesData->accounts.GetCount(); accountSeek++){
92 if ((wxString)cmbAccount->GetStringSelection() == preferencesData->accounts.GetAccountName(accountSeek)){
98 calendarInfo->accountPreferencesID = accountPrefencesIDList[cmbAccount->GetCurrentSelection()];
102 calendarInfo->editMode = editMode;
103 calendarInfo->accountName = cmbAccount->GetStringSelection();
104 calendarInfo->calendarName = txtName->GetValue().ToStdString();
105 calendarInfo->calendarDescription = txtDescription->GetValue().ToStdString();
107 calendarInfo->calendarColour = (clpColour->GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString() + "FF");
109 wxCommandEvent processCalendarEvent(XCMAIN_PROCESSCALENDAR);
110 processCalendarEvent.SetId(ID_PROCESSCALENDAR);
111 processCalendarEvent.SetClientData((void*)calendarInfo);
112 wxPostEvent(this->GetParent(), processCalendarEvent);
118 void frmCalendarEditor::SetData(int calendarID, std::string accountName, std::string calendarName, std::string calendarDescription, Colour calendarColour){
120 txtName->SetValue(wxString(calendarName.c_str()));
121 txtDescription->SetValue(wxString(calendarDescription.c_str()));
122 clpColour->SetColour(wxColour(calendarColour.red, calendarColour.green, calendarColour.blue));
123 cmbAccount->SetStringSelection(wxString(accountName));
124 this->calendarID = calendarID;