2 /// \file TaskEditDlg.cc
3 /// Dialog class to handle the editing of the Task record
7 Copyright (C) 2012, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "TaskEditDlg.h"
23 #include "windowids.h"
24 #include <wx/valgen.h>
28 using namespace Barry
;
30 // begin wxGlade: ::extracode
34 //////////////////////////////////////////////////////////////////////////////
37 TaskEditDlg::TaskEditDlg(wxWindow
* parent
,
40 const Barry::TimeZones
*device_zones
)
41 : wxDialog(parent
, Dialog_TaskEdit
, _T("Task Record"))
42 , m_zones(device_zones
? device_zones
: &m_static_zones
)
45 , m_reminder_minutes(0)
47 , m_relative_date(false)
49 // set all weekday 'bits' to false
50 for( int i
= 0; i
< 7; i
++ )
51 m_weekdays
[i
] = false;
54 bottom_buttons
= CreateButtonSizer(wxOK
| wxCANCEL
);
57 bottom_buttons
= CreateButtonSizer(wxCANCEL
);
60 // begin wxGlade: TaskEditDlg::TaskEditDlg
61 label_1
= new wxStaticText(this, wxID_ANY
, wxT("Task:"));
62 m_TaskSummary
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
63 static_line_1
= new wxStaticLine(this, wxID_ANY
);
64 label_2
= new wxStaticText(this, wxID_ANY
, wxT("Status:"));
65 const wxString m_StatusChoice_choices
[] = {
72 m_StatusChoice
= new wxChoice(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, 5, m_StatusChoice_choices
, 0);
73 label_9
= new wxStaticText(this, wxID_ANY
, wxT("Priority:"));
74 const wxString m_PriorityChoice_choices
[] = {
79 m_PriorityChoice
= new wxChoice(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, 3, m_PriorityChoice_choices
, 0);
80 label_5
= new wxStaticText(this, wxID_ANY
, wxT("Due:"));
81 m_DueCheck
= new wxCheckBox(this, Dialog_TaskEdit_DueCheck
, wxEmptyString
);
82 m_DueDateCtrl
= new wxDatePickerCtrl(this, Dialog_TaskEdit_DueDateCtrl
, wxDefaultDateTime
, wxDefaultPosition
, wxDefaultSize
, wxDP_DROPDOWN
|wxDP_SHOWCENTURY
);
83 m_DueHoursSpinner
= new wxSpinCtrl(this, Dialog_TaskEdit_DueHoursSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_WRAP
|wxTE_NOHIDESEL
, 0, 23);
84 label_11
= new wxStaticText(this, wxID_ANY
, wxT(":"));
85 m_DueMinutesSpinner
= new wxSpinCtrl(this, Dialog_TaskEdit_DueMinutesSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_WRAP
|wxTE_NOHIDESEL
, 0, 59);
86 label_8
= new wxStaticText(this, wxID_ANY
, wxT("Time Zone:"));
87 const wxString m_TimezoneChoice_choices
[] = {
88 wxT("System Time Zone")
90 m_TimezoneChoice
= new wxChoice(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, 1, m_TimezoneChoice_choices
, 0);
91 label_10
= new wxStaticText(this, wxID_ANY
, wxT("Reminder:"));
92 m_ReminderCheck
= new wxCheckBox(this, Dialog_TaskEdit_ReminderCheck
, wxEmptyString
);
93 m_ReminderDateCtrl
= new wxDatePickerCtrl(this, Dialog_TaskEdit_ReminderDateCtrl
);
94 m_ReminderHoursSpinner
= new wxSpinCtrl(this, Dialog_TaskEdit_ReminderHoursSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 0, 999);
95 label_6
= new wxStaticText(this, wxID_ANY
, wxT(":"));
96 m_ReminderMinutesSpinner
= new wxSpinCtrl(this, Dialog_TaskEdit_ReminderMinutesSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 0, 59);
97 static_line_2
= new wxStaticLine(this, wxID_ANY
);
98 label_18
= new wxStaticText(this, wxID_ANY
, wxT("Recurrence:"));
99 const wxString m_RecurrenceChoice_choices
[] = {
106 m_RecurrenceChoice
= new wxChoice(this, Dialog_TaskEdit_RecurrenceChoice
, wxDefaultPosition
, wxDefaultSize
, 5, m_RecurrenceChoice_choices
, 0);
107 RecurIntervalLabel
= new wxStaticText(this, wxID_ANY
, wxT("Interval:"));
108 RecurIntervalLabelB
= new wxStaticText(this, wxID_ANY
, wxT("Every"));
109 m_IntervalSpinner
= new wxSpinCtrl(this, wxID_ANY
, wxT("1"), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 1, 999);
110 m_IntervalUnitLabel
= new wxStaticText(this, wxID_ANY
, wxT("days? weeks? months?"), wxDefaultPosition
, wxDefaultSize
, wxST_NO_AUTORESIZE
);
111 RecurDaysLabel
= new wxStaticText(this, wxID_ANY
, wxT("Days:"));
112 m_SunCheck
= new wxCheckBox(this, wxID_ANY
, wxT("S"));
113 m_MonCheck
= new wxCheckBox(this, wxID_ANY
, wxT("M"));
114 m_TueCheck
= new wxCheckBox(this, wxID_ANY
, wxT("T"));
115 m_WedCheck
= new wxCheckBox(this, wxID_ANY
, wxT("W"));
116 m_ThuCheck
= new wxCheckBox(this, wxID_ANY
, wxT("T"));
117 m_FriCheck
= new wxCheckBox(this, wxID_ANY
, wxT("F"));
118 m_SatCheck
= new wxCheckBox(this, wxID_ANY
, wxT("S"));
119 RecurRelativeDateLabel
= new wxStaticText(this, wxID_ANY
, wxT("Relative Date:"));
120 m_RelativeDateCheck
= new wxCheckBox(this, wxID_ANY
, wxEmptyString
);
121 RecurEndDateLabel
= new wxStaticText(this, wxID_ANY
, wxT("End Date:"));
122 m_NeverEndsCheck
= new wxCheckBox(this, Dialog_TaskEdit_NeverEndsCheck
, wxT("Never ends"));
123 m_RecurEndDateCtrl
= new wxDatePickerCtrl(this, wxID_ANY
, wxDefaultDateTime
, wxDefaultPosition
, wxDefaultSize
, wxDP_DROPDOWN
|wxDP_SHOWCENTURY
);
124 static_line_3
= new wxStaticLine(this, wxID_ANY
);
125 label_4
= new wxStaticText(this, wxID_ANY
, wxT("Categories:"));
126 m_CategoriesText
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
127 label_3
= new wxStaticText(this, wxID_ANY
, wxT("Notes:"));
128 m_NotesText
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
134 m_top_sizer
->Add(bottom_buttons
, 0, wxLEFT
|wxRIGHT
|wxBOTTOM
|wxEXPAND
, 5);
136 // fill the time zone control with real time zones
137 m_TimezoneChoice
->Clear();
138 m_TimezoneChoice
->Append(wxT("Assume Local Timezone"), (void*)0);
139 Barry::TimeZones::const_iterator b
, e
;
140 for( b
= m_zones
->begin(), e
= m_zones
->end(); b
!= e
; ++b
) {
141 m_TimezoneChoice
->Append(
142 wxString(b
->GetDescription().c_str(), wxConvUTF8
),
145 m_TimezoneChoice
->SetSelection(0);
147 // layout again, in case sizes are different
151 void TaskEditDlg::RedoLayout()
153 m_top_sizer
->Fit(this);
158 BEGIN_EVENT_TABLE(TaskEditDlg
, wxDialog
)
159 // begin wxGlade: TaskEditDlg::event_table
160 EVT_CHECKBOX(Dialog_TaskEdit_DueCheck
, TaskEditDlg::OnDueCheck
)
161 EVT_CHECKBOX(Dialog_TaskEdit_ReminderCheck
, TaskEditDlg::OnReminderCheck
)
162 EVT_CHOICE(Dialog_TaskEdit_RecurrenceChoice
, TaskEditDlg::OnRecurrenceChoice
)
163 EVT_CHECKBOX(Dialog_TaskEdit_NeverEndsCheck
, TaskEditDlg::OnEndDateCheckbox
)
168 // wxGlade: add TaskEditDlg event handlers
170 void TaskEditDlg::OnDueCheck(wxCommandEvent
&event
)
172 EnableDueDate(m_DueCheck
->IsChecked());
175 void TaskEditDlg::OnRecurrenceChoice(wxCommandEvent
&event
)
177 TransferDataFromWindow();
178 EnableRecurMode(m_rec
.Recurring
);
181 void TaskEditDlg::OnEndDateCheckbox(wxCommandEvent
&event
)
183 m_RecurEndDateCtrl
->Enable( !m_NeverEndsCheck
->IsChecked() );
186 void TaskEditDlg::OnReminderCheck(wxCommandEvent
&event
)
188 EnableReminderDate(m_ReminderCheck
->IsChecked());
191 void TaskEditDlg::set_properties()
193 // begin wxGlade: TaskEditDlg::set_properties
194 SetTitle(wxT("Task Event"));
195 m_TaskSummary
->SetFocus();
196 m_TaskSummary
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_rec
.Summary
)));
197 m_StatusChoice
->SetSelection(0);
198 m_PriorityChoice
->SetSelection(1);
199 m_DueDateCtrl
->SetMinSize(wxSize(110, -1));
200 m_DueDateCtrl
->SetValidator(DateTimeValidator(&m_DueDateObj
.m_date
));
201 m_DueHoursSpinner
->SetMinSize(wxSize(45, -1));
202 m_DueHoursSpinner
->SetValidator(wxGenericValidator(&m_DueDateObj
.m_hour
));
203 m_DueMinutesSpinner
->SetMinSize(wxSize(45, -1));
204 m_DueMinutesSpinner
->SetValidator(wxGenericValidator(&m_DueDateObj
.m_min
));
205 m_TimezoneChoice
->SetSelection(0);
206 m_ReminderDateCtrl
->SetMinSize(wxSize(110, -1));
207 m_ReminderDateCtrl
->SetValidator(DateTimeValidator(&m_ReminderDateObj
.m_date
));
208 m_ReminderHoursSpinner
->SetMinSize(wxSize(45, -1));
209 m_ReminderHoursSpinner
->SetToolTip(wxT("Set Reminder to 0 to disable"));
210 m_ReminderHoursSpinner
->SetValidator(wxGenericValidator(&m_ReminderDateObj
.m_hour
));
211 m_ReminderMinutesSpinner
->SetMinSize(wxSize(45, -1));
212 m_ReminderMinutesSpinner
->SetToolTip(wxT("Set Reminder to 0 to disable"));
213 m_ReminderMinutesSpinner
->SetValidator(wxGenericValidator(&m_ReminderDateObj
.m_min
));
214 m_RecurrenceChoice
->SetValidator(wxGenericValidator(&m_recur_choice
));
215 m_RecurrenceChoice
->SetSelection(0);
216 m_IntervalSpinner
->SetMinSize(wxSize(45, -1));
217 m_IntervalSpinner
->SetValidator(wxGenericValidator(&m_interval
));
218 m_SunCheck
->SetValidator(wxGenericValidator(&m_weekdays
[0]));
219 m_MonCheck
->SetValidator(wxGenericValidator(&m_weekdays
[1]));
220 m_TueCheck
->SetValidator(wxGenericValidator(&m_weekdays
[2]));
221 m_WedCheck
->SetValidator(wxGenericValidator(&m_weekdays
[3]));
222 m_ThuCheck
->SetValidator(wxGenericValidator(&m_weekdays
[4]));
223 m_FriCheck
->SetValidator(wxGenericValidator(&m_weekdays
[5]));
224 m_SatCheck
->SetValidator(wxGenericValidator(&m_weekdays
[6]));
225 RecurRelativeDateLabel
->SetToolTip(wxT("Relative monthly or yearly dates take the weekday of the start date into account. (eg. every first Sunday of month)"));
226 m_RelativeDateCheck
->SetToolTip(wxT("Relative monthly or yearly dates take the weekday of the start date into account. (eg. every first Sunday of month)"));
227 m_RelativeDateCheck
->SetValidator(wxGenericValidator(&m_relative_date
));
228 m_NeverEndsCheck
->SetValidator(wxGenericValidator(&m_rec
.Perpetual
));
229 m_NeverEndsCheck
->SetValue(1);
230 m_RecurEndDateCtrl
->SetMinSize(wxSize(110, -1));
231 m_RecurEndDateCtrl
->Enable(false);
232 m_RecurEndDateCtrl
->SetValidator(DateTimeValidator(&m_RecurEndDateObj
.m_date
));
233 m_CategoriesText
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_categories
)));
234 m_NotesText
->SetMinSize(wxSize(-1, 71));
235 m_NotesText
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_rec
.Notes
)));
239 void TaskEditDlg::do_layout()
241 // begin wxGlade: TaskEditDlg::do_layout
242 wxBoxSizer
* sizer_surround
= new wxBoxSizer(wxVERTICAL
);
243 wxBoxSizer
* sizer_1
= new wxBoxSizer(wxVERTICAL
);
244 wxFlexGridSizer
* grid_sizer_3
= new wxFlexGridSizer(2, 2, 5, 5);
245 wxFlexGridSizer
* grid_sizer_4
= new wxFlexGridSizer(5, 2, 5, 5);
246 wxBoxSizer
* sizer_8
= new wxBoxSizer(wxHORIZONTAL
);
247 wxBoxSizer
* m_DaysCtrlsSizer
= new wxBoxSizer(wxHORIZONTAL
);
248 wxBoxSizer
* m_IntervalCtrlsSizer
= new wxBoxSizer(wxHORIZONTAL
);
249 wxFlexGridSizer
* grid_sizer_2
= new wxFlexGridSizer(10, 2, 5, 5);
250 wxBoxSizer
* sizer_5_copy
= new wxBoxSizer(wxHORIZONTAL
);
251 wxBoxSizer
* sizer_3
= new wxBoxSizer(wxHORIZONTAL
);
252 wxFlexGridSizer
* grid_sizer_1
= new wxFlexGridSizer(2, 2, 5, 5);
253 grid_sizer_1
->Add(label_1
, 0, wxALIGN_CENTER_VERTICAL
, 0);
254 grid_sizer_1
->Add(m_TaskSummary
, 0, wxEXPAND
, 0);
255 grid_sizer_1
->AddGrowableCol(1);
256 sizer_1
->Add(grid_sizer_1
, 0, wxEXPAND
, 0);
257 sizer_1
->Add(static_line_1
, 0, wxALL
|wxEXPAND
, 5);
258 grid_sizer_2
->Add(label_2
, 0, wxALIGN_CENTER_VERTICAL
, 0);
259 grid_sizer_2
->Add(m_StatusChoice
, 0, 0, 0);
260 grid_sizer_2
->Add(label_9
, 0, wxALIGN_CENTER_VERTICAL
, 0);
261 grid_sizer_2
->Add(m_PriorityChoice
, 0, 0, 0);
262 grid_sizer_2
->Add(label_5
, 0, wxALIGN_CENTER_VERTICAL
, 0);
263 sizer_3
->Add(m_DueCheck
, 0, 0, 0);
264 sizer_3
->Add(m_DueDateCtrl
, 0, 0, 0);
265 sizer_3
->Add(20, 20, 0, 0, 0);
266 sizer_3
->Add(m_DueHoursSpinner
, 0, 0, 0);
267 sizer_3
->Add(label_11
, 0, wxLEFT
|wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 1);
268 sizer_3
->Add(m_DueMinutesSpinner
, 0, 0, 0);
269 grid_sizer_2
->Add(sizer_3
, 1, wxEXPAND
, 0);
270 grid_sizer_2
->Add(label_8
, 0, wxALIGN_CENTER_VERTICAL
, 0);
271 grid_sizer_2
->Add(m_TimezoneChoice
, 0, 0, 0);
272 grid_sizer_2
->Add(label_10
, 0, wxALIGN_CENTER_VERTICAL
, 0);
273 sizer_5_copy
->Add(m_ReminderCheck
, 0, 0, 0);
274 sizer_5_copy
->Add(m_ReminderDateCtrl
, 0, 0, 0);
275 sizer_5_copy
->Add(20, 20, 0, 0, 0);
276 sizer_5_copy
->Add(m_ReminderHoursSpinner
, 0, 0, 5);
277 sizer_5_copy
->Add(label_6
, 0, wxLEFT
|wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 1);
278 sizer_5_copy
->Add(m_ReminderMinutesSpinner
, 0, wxRIGHT
, 5);
279 grid_sizer_2
->Add(sizer_5_copy
, 1, wxEXPAND
, 0);
280 grid_sizer_2
->AddGrowableCol(1);
281 sizer_1
->Add(grid_sizer_2
, 0, wxEXPAND
, 0);
282 sizer_1
->Add(static_line_2
, 0, wxALL
|wxEXPAND
, 5);
283 grid_sizer_4
->Add(label_18
, 0, wxALIGN_CENTER_VERTICAL
, 0);
284 grid_sizer_4
->Add(m_RecurrenceChoice
, 0, 0, 0);
285 grid_sizer_4
->Add(RecurIntervalLabel
, 0, wxALIGN_CENTER_VERTICAL
, 0);
286 m_IntervalCtrlsSizer
->Add(RecurIntervalLabelB
, 0, wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 5);
287 m_IntervalCtrlsSizer
->Add(m_IntervalSpinner
, 0, wxRIGHT
, 5);
288 m_IntervalCtrlsSizer
->Add(m_IntervalUnitLabel
, 1, wxALIGN_CENTER_VERTICAL
, 0);
289 grid_sizer_4
->Add(m_IntervalCtrlsSizer
, 1, wxEXPAND
, 0);
290 grid_sizer_4
->Add(RecurDaysLabel
, 0, wxALIGN_CENTER_VERTICAL
, 0);
291 m_DaysCtrlsSizer
->Add(m_SunCheck
, 0, wxRIGHT
, 5);
292 m_DaysCtrlsSizer
->Add(m_MonCheck
, 0, wxRIGHT
, 5);
293 m_DaysCtrlsSizer
->Add(m_TueCheck
, 0, wxRIGHT
, 5);
294 m_DaysCtrlsSizer
->Add(m_WedCheck
, 0, wxRIGHT
, 5);
295 m_DaysCtrlsSizer
->Add(m_ThuCheck
, 0, wxRIGHT
, 5);
296 m_DaysCtrlsSizer
->Add(m_FriCheck
, 0, wxRIGHT
, 5);
297 m_DaysCtrlsSizer
->Add(m_SatCheck
, 0, wxRIGHT
, 5);
298 grid_sizer_4
->Add(m_DaysCtrlsSizer
, 1, wxEXPAND
, 0);
299 grid_sizer_4
->Add(RecurRelativeDateLabel
, 0, wxALIGN_CENTER_VERTICAL
, 0);
300 grid_sizer_4
->Add(m_RelativeDateCheck
, 0, 0, 0);
301 grid_sizer_4
->Add(RecurEndDateLabel
, 0, wxALIGN_CENTER_VERTICAL
, 0);
302 sizer_8
->Add(m_NeverEndsCheck
, 0, wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 10);
303 sizer_8
->Add(m_RecurEndDateCtrl
, 0, wxALIGN_CENTER_VERTICAL
, 0);
304 grid_sizer_4
->Add(sizer_8
, 1, wxEXPAND
, 0);
305 grid_sizer_4
->AddGrowableCol(1);
306 sizer_1
->Add(grid_sizer_4
, 0, wxEXPAND
, 0);
307 sizer_1
->Add(static_line_3
, 0, wxALL
|wxEXPAND
, 5);
308 grid_sizer_3
->Add(label_4
, 0, wxALIGN_CENTER_VERTICAL
, 0);
309 grid_sizer_3
->Add(m_CategoriesText
, 0, wxEXPAND
, 0);
310 grid_sizer_3
->Add(label_3
, 0, wxRIGHT
, 5);
311 grid_sizer_3
->Add(m_NotesText
, 1, wxEXPAND
, 0);
312 grid_sizer_3
->AddGrowableCol(1);
313 sizer_1
->Add(grid_sizer_3
, 1, wxEXPAND
, 0);
314 sizer_surround
->Add(sizer_1
, 1, wxALL
|wxEXPAND
, 10);
315 SetSizer(sizer_surround
);
316 sizer_surround
->Fit(this);
320 m_top_sizer
= sizer_surround
;
323 bool TaskEditDlg::TransferDataToWindow()
325 // prepare temporary variables, from record
327 m_rec
.Categories
.CategoryList2Str(m_categories
);
330 m_DueCheck
->SetValue(m_rec
.DueTime
.IsValid());
331 EnableDueDate(m_rec
.DueTime
.IsValid());
332 m_DueDateObj
.Set(m_rec
.DueTime
.Time
);
334 // alarm / reminder time
335 m_ReminderCheck
->SetValue(m_rec
.AlarmTime
.IsValid());
336 EnableReminderDate(m_rec
.AlarmTime
.IsValid());
337 m_ReminderDateObj
.Set(m_rec
.AlarmTime
.Time
);
340 #define S_NOT_STARTED 0
341 #define S_IN_PROGRESS 1
342 #define S_COMPLETED 2
345 switch( m_rec
.StatusFlag
)
347 case Barry::Task::NotStarted
:
349 m_StatusChoice
->SetSelection(S_NOT_STARTED
);
352 case Barry::Task::InProgress
:
353 m_StatusChoice
->SetSelection(S_IN_PROGRESS
);
356 case Barry::Task::Completed
:
357 m_StatusChoice
->SetSelection(S_COMPLETED
);
360 case Barry::Task::Waiting
:
361 m_StatusChoice
->SetSelection(S_WAITING
);
364 case Barry::Task::Deferred
:
365 m_StatusChoice
->SetSelection(S_DEFERRED
);
373 switch( m_rec
.PriorityFlag
)
375 case Barry::Task::High
:
376 m_PriorityChoice
->SetSelection(P_HIGH
);
379 case Barry::Task::Normal
:
381 m_PriorityChoice
->SetSelection(P_NORMAL
);
384 case Barry::Task::Low
:
385 m_PriorityChoice
->SetSelection(P_LOW
);
389 // set the timezone choice only if the record's data is valid
390 m_TimezoneChoice
->SetSelection(0); // default to none
391 if( m_rec
.TimeZoneValid
) {
392 TimeZones::const_iterator i
= m_zones
->Find(m_rec
.TimeZoneCode
);
393 if( i
!= m_zones
->end() ) {
394 int array_index
= i
- m_zones
->begin();
395 // select item, skipping 0's "none" option
396 m_TimezoneChoice
->SetSelection(array_index
+ 1);
400 // Note that recur_choice values are (zero-based) in the following
402 // None, Daily, Weekly, Monthly, Yearly
409 if( m_rec
.Recurring
) {
410 switch( m_rec
.RecurringType
)
412 case Barry::RecurBase::Day
:
413 m_recur_choice
= RC_DAILY
;
414 m_relative_date
= false;
417 case Barry::RecurBase::MonthByDate
:
418 m_recur_choice
= RC_MONTHLY
;
419 m_relative_date
= false;
422 case Barry::RecurBase::MonthByDay
:
423 m_recur_choice
= RC_MONTHLY
;
424 m_relative_date
= true;
427 case Barry::RecurBase::YearByDate
:
428 m_recur_choice
= RC_YEARLY
;
429 m_relative_date
= false;
432 case Barry::RecurBase::YearByDay
:
433 m_recur_choice
= RC_YEARLY
;
434 m_relative_date
= true;
437 case Barry::RecurBase::Week
:
438 m_recur_choice
= RC_WEEKLY
;
439 m_relative_date
= false;
440 m_weekdays
[0] = m_rec
.WeekDays
& CAL_WD_SUN
;
441 m_weekdays
[1] = m_rec
.WeekDays
& CAL_WD_MON
;
442 m_weekdays
[2] = m_rec
.WeekDays
& CAL_WD_TUE
;
443 m_weekdays
[3] = m_rec
.WeekDays
& CAL_WD_WED
;
444 m_weekdays
[4] = m_rec
.WeekDays
& CAL_WD_THU
;
445 m_weekdays
[5] = m_rec
.WeekDays
& CAL_WD_FRI
;
446 m_weekdays
[6] = m_rec
.WeekDays
& CAL_WD_SAT
;
450 cerr
<< "Bad RecurringType in CalendarEditDlg" << endl
;
451 m_recur_choice
= RC_NONE
;
452 m_relative_date
= false;
456 m_recur_choice
= RC_NONE
;
457 m_relative_date
= false;
460 m_interval
= m_rec
.Interval
;
462 if( m_rec
.Perpetual
) {
463 m_RecurEndDateCtrl
->Enable(false);
466 m_RecurEndDateCtrl
->Enable();
467 m_RecurEndDateObj
.Set(m_rec
.RecurringEndTime
.Time
);
470 EnableRecurMode(m_rec
.Recurring
);
474 return wxDialog::TransferDataToWindow();
477 bool TaskEditDlg::TransferDataFromWindow()
479 if( !wxDialog::TransferDataFromWindow() )
484 m_rec
.Categories
.CategoryStr2List(m_categories
);
487 if( m_DueCheck
->IsChecked() )
488 m_rec
.DueTime
.Time
= m_DueDateObj
.Get();
490 m_rec
.DueTime
.clear();
492 // alarm / reminder time
493 if( m_ReminderCheck
->IsChecked() )
494 m_rec
.AlarmTime
.Time
= m_ReminderDateObj
.Get();
496 m_rec
.AlarmTime
.clear();
499 switch( m_StatusChoice
->GetSelection() )
503 m_rec
.StatusFlag
= Barry::Task::NotStarted
;
507 m_rec
.StatusFlag
= Barry::Task::InProgress
;
511 m_rec
.StatusFlag
= Barry::Task::Completed
;
515 m_rec
.StatusFlag
= Barry::Task::Waiting
;
519 m_rec
.StatusFlag
= Barry::Task::Deferred
;
524 switch( m_PriorityChoice
->GetSelection() )
527 m_rec
.PriorityFlag
= Barry::Task::High
;
532 m_rec
.PriorityFlag
= Barry::Task::Normal
;
536 m_rec
.PriorityFlag
= Barry::Task::Low
;
540 // set the timezone choice only if the record's data is valid
541 int sel
= m_TimezoneChoice
->GetSelection();
543 m_rec
.TimeZoneCode
= (*m_zones
)[sel
-1].Index
;
544 m_rec
.TimeZoneValid
= true;
547 // default was selected
548 m_rec
.TimeZoneValid
= false;
551 // Note that recur_choice values are (zero-based) in the following
553 // None, Daily, Weekly, Monthly, Yearly
554 switch( m_recur_choice
)
558 m_rec
.Recurring
= false;
562 m_rec
.Recurring
= true;
563 m_rec
.RecurringType
= Barry::RecurBase::Day
;
567 m_rec
.Recurring
= true;
568 m_rec
.RecurringType
= Barry::RecurBase::Week
;
570 if( m_weekdays
[0] ) m_rec
.WeekDays
|= CAL_WD_SUN
;
571 if( m_weekdays
[1] ) m_rec
.WeekDays
|= CAL_WD_MON
;
572 if( m_weekdays
[2] ) m_rec
.WeekDays
|= CAL_WD_TUE
;
573 if( m_weekdays
[3] ) m_rec
.WeekDays
|= CAL_WD_WED
;
574 if( m_weekdays
[4] ) m_rec
.WeekDays
|= CAL_WD_THU
;
575 if( m_weekdays
[5] ) m_rec
.WeekDays
|= CAL_WD_FRI
;
576 if( m_weekdays
[6] ) m_rec
.WeekDays
|= CAL_WD_SAT
;
580 m_rec
.Recurring
= true;
581 if( m_relative_date
)
582 m_rec
.RecurringType
= Barry::RecurBase::MonthByDay
;
584 m_rec
.RecurringType
= Barry::RecurBase::MonthByDate
;
588 m_rec
.Recurring
= true;
589 if( m_relative_date
)
590 m_rec
.RecurringType
= Barry::RecurBase::YearByDay
;
592 m_rec
.RecurringType
= Barry::RecurBase::YearByDate
;
597 m_rec
.Interval
= m_interval
;
599 if( !m_rec
.Perpetual
) {
600 m_rec
.RecurringEndTime
.Time
= m_RecurEndDateObj
.Get();
606 void TaskEditDlg::EnableDueDate(bool enable
)
608 m_DueDateCtrl
->Enable(enable
);
609 m_DueHoursSpinner
->Enable(enable
);
610 m_DueMinutesSpinner
->Enable(enable
);
611 m_RecurrenceChoice
->Enable(enable
);
614 m_RecurrenceChoice
->SetSelection(0);
615 EnableRecurMode(false);
619 void TaskEditDlg::EnableReminderDate(bool enable
)
621 m_ReminderDateCtrl
->Enable(enable
);
622 m_ReminderHoursSpinner
->Enable(enable
);
623 m_ReminderMinutesSpinner
->Enable(enable
);
626 void TaskEditDlg::EnableRecurMode(bool recur
)
628 RecurIntervalLabel
->Show(recur
);
629 RecurIntervalLabelB
->Show(recur
);
630 m_IntervalSpinner
->Show(recur
);
631 m_IntervalUnitLabel
->Show(recur
);
632 RecurDaysLabel
->Show(recur
);
633 m_SunCheck
->Show(recur
);
634 m_MonCheck
->Show(recur
);
635 m_TueCheck
->Show(recur
);
636 m_WedCheck
->Show(recur
);
637 m_ThuCheck
->Show(recur
);
638 m_FriCheck
->Show(recur
);
639 m_SatCheck
->Show(recur
);
640 RecurRelativeDateLabel
->Show(recur
);
641 m_RelativeDateCheck
->Show(recur
);
642 RecurEndDateLabel
->Show(recur
);
643 m_NeverEndsCheck
->Show(recur
);
644 m_RecurEndDateCtrl
->Show(recur
);
647 switch( m_RecurrenceChoice
->GetSelection() )
651 m_IntervalUnitLabel
->SetLabel(_T(""));
655 m_IntervalUnitLabel
->SetLabel(_T("day(s)"));
659 m_IntervalUnitLabel
->SetLabel(_T("week(s)"));
663 m_IntervalUnitLabel
->SetLabel(_T("month(s)"));
667 m_IntervalUnitLabel
->SetLabel(_T("year(s)"));