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 void MakeRecent(wxCheckBox
*check
, wxDatePickerCtrl
*picker
)
39 wxDateTime when
= picker
->GetValue();
40 if( check
->IsChecked() &&
42 when
< wxDateTime(1, wxDateTime::Jan
, 1975, 0, 0, 0)) )
44 when
= wxDateTime::Now();
45 picker
->SetValue(when
);
50 //////////////////////////////////////////////////////////////////////////////
53 TaskEditDlg::TaskEditDlg(wxWindow
* parent
,
56 const Barry::TimeZones
*device_zones
)
57 : wxDialog(parent
, Dialog_TaskEdit
, _T("Task Record"))
58 , m_zones(device_zones
? device_zones
: &m_static_zones
)
61 , m_reminder_minutes(0)
63 , m_relative_date(false)
65 // set all weekday 'bits' to false
66 for( int i
= 0; i
< 7; i
++ )
67 m_weekdays
[i
] = false;
70 bottom_buttons
= CreateButtonSizer(wxOK
| wxCANCEL
);
73 bottom_buttons
= CreateButtonSizer(wxCANCEL
);
76 // begin wxGlade: TaskEditDlg::TaskEditDlg
77 label_1
= new wxStaticText(this, wxID_ANY
, wxT("Task:"));
78 m_TaskSummary
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
79 static_line_1
= new wxStaticLine(this, wxID_ANY
);
80 label_2
= new wxStaticText(this, wxID_ANY
, wxT("Status:"));
81 const wxString m_StatusChoice_choices
[] = {
88 m_StatusChoice
= new wxChoice(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, 5, m_StatusChoice_choices
, 0);
89 label_9
= new wxStaticText(this, wxID_ANY
, wxT("Priority:"));
90 const wxString m_PriorityChoice_choices
[] = {
95 m_PriorityChoice
= new wxChoice(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, 3, m_PriorityChoice_choices
, 0);
96 label_5
= new wxStaticText(this, wxID_ANY
, wxT("Due:"));
97 m_DueCheck
= new wxCheckBox(this, Dialog_TaskEdit_DueCheck
, wxEmptyString
);
98 m_DueDateCtrl
= new wxDatePickerCtrl(this, Dialog_TaskEdit_DueDateCtrl
, wxDefaultDateTime
, wxDefaultPosition
, wxDefaultSize
, wxDP_DROPDOWN
|wxDP_SHOWCENTURY
);
99 m_DueHoursSpinner
= new wxSpinCtrl(this, Dialog_TaskEdit_DueHoursSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_WRAP
|wxTE_NOHIDESEL
, 0, 23);
100 label_11
= new wxStaticText(this, wxID_ANY
, wxT(":"));
101 m_DueMinutesSpinner
= new wxSpinCtrl(this, Dialog_TaskEdit_DueMinutesSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_WRAP
|wxTE_NOHIDESEL
, 0, 59);
102 label_8
= new wxStaticText(this, wxID_ANY
, wxT("Time Zone:"));
103 const wxString m_TimezoneChoice_choices
[] = {
104 wxT("System Time Zone")
106 m_TimezoneChoice
= new wxChoice(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, 1, m_TimezoneChoice_choices
, 0);
107 label_10
= new wxStaticText(this, wxID_ANY
, wxT("Reminder:"));
108 m_ReminderCheck
= new wxCheckBox(this, Dialog_TaskEdit_ReminderCheck
, wxEmptyString
);
109 m_ReminderDateCtrl
= new wxDatePickerCtrl(this, Dialog_TaskEdit_ReminderDateCtrl
);
110 m_ReminderHoursSpinner
= new wxSpinCtrl(this, Dialog_TaskEdit_ReminderHoursSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 0, 999);
111 label_6
= new wxStaticText(this, wxID_ANY
, wxT(":"));
112 m_ReminderMinutesSpinner
= new wxSpinCtrl(this, Dialog_TaskEdit_ReminderMinutesSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 0, 59);
113 static_line_2
= new wxStaticLine(this, wxID_ANY
);
114 label_18
= new wxStaticText(this, wxID_ANY
, wxT("Recurrence:"));
115 const wxString m_RecurrenceChoice_choices
[] = {
122 m_RecurrenceChoice
= new wxChoice(this, Dialog_TaskEdit_RecurrenceChoice
, wxDefaultPosition
, wxDefaultSize
, 5, m_RecurrenceChoice_choices
, 0);
123 RecurIntervalLabel
= new wxStaticText(this, wxID_ANY
, wxT("Interval:"));
124 RecurIntervalLabelB
= new wxStaticText(this, wxID_ANY
, wxT("Every"));
125 m_IntervalSpinner
= new wxSpinCtrl(this, wxID_ANY
, wxT("1"), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 1, 999);
126 m_IntervalUnitLabel
= new wxStaticText(this, wxID_ANY
, wxT("days? weeks? months?"), wxDefaultPosition
, wxDefaultSize
, wxST_NO_AUTORESIZE
);
127 RecurDaysLabel
= new wxStaticText(this, wxID_ANY
, wxT("Days:"));
128 m_SunCheck
= new wxCheckBox(this, wxID_ANY
, wxT("S"));
129 m_MonCheck
= new wxCheckBox(this, wxID_ANY
, wxT("M"));
130 m_TueCheck
= new wxCheckBox(this, wxID_ANY
, wxT("T"));
131 m_WedCheck
= new wxCheckBox(this, wxID_ANY
, wxT("W"));
132 m_ThuCheck
= new wxCheckBox(this, wxID_ANY
, wxT("T"));
133 m_FriCheck
= new wxCheckBox(this, wxID_ANY
, wxT("F"));
134 m_SatCheck
= new wxCheckBox(this, wxID_ANY
, wxT("S"));
135 RecurRelativeDateLabel
= new wxStaticText(this, wxID_ANY
, wxT("Relative Date:"));
136 m_RelativeDateCheck
= new wxCheckBox(this, wxID_ANY
, wxEmptyString
);
137 RecurEndDateLabel
= new wxStaticText(this, wxID_ANY
, wxT("End Date:"));
138 m_NeverEndsCheck
= new wxCheckBox(this, Dialog_TaskEdit_NeverEndsCheck
, wxT("Never ends"));
139 m_RecurEndDateCtrl
= new wxDatePickerCtrl(this, wxID_ANY
, wxDefaultDateTime
, wxDefaultPosition
, wxDefaultSize
, wxDP_DROPDOWN
|wxDP_SHOWCENTURY
);
140 static_line_3
= new wxStaticLine(this, wxID_ANY
);
141 label_4
= new wxStaticText(this, wxID_ANY
, wxT("Categories:"));
142 m_CategoriesText
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
143 label_3
= new wxStaticText(this, wxID_ANY
, wxT("Notes:"));
144 m_NotesText
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
150 m_top_sizer
->Add(bottom_buttons
, 0, wxLEFT
|wxRIGHT
|wxBOTTOM
|wxEXPAND
, 5);
152 // fill the time zone control with real time zones
153 m_TimezoneChoice
->Clear();
154 m_TimezoneChoice
->Append(wxT("Assume Local Timezone"), (void*)0);
155 Barry::TimeZones::const_iterator b
, e
;
156 for( b
= m_zones
->begin(), e
= m_zones
->end(); b
!= e
; ++b
) {
157 m_TimezoneChoice
->Append(
158 wxString(b
->GetDescription().c_str(), wxConvUTF8
),
161 m_TimezoneChoice
->SetSelection(0);
163 // layout again, in case sizes are different
167 void TaskEditDlg::RedoLayout()
169 m_top_sizer
->Fit(this);
174 BEGIN_EVENT_TABLE(TaskEditDlg
, wxDialog
)
175 // begin wxGlade: TaskEditDlg::event_table
176 EVT_CHECKBOX(Dialog_TaskEdit_DueCheck
, TaskEditDlg::OnDueCheck
)
177 EVT_CHECKBOX(Dialog_TaskEdit_ReminderCheck
, TaskEditDlg::OnReminderCheck
)
178 EVT_CHOICE(Dialog_TaskEdit_RecurrenceChoice
, TaskEditDlg::OnRecurrenceChoice
)
179 EVT_CHECKBOX(Dialog_TaskEdit_NeverEndsCheck
, TaskEditDlg::OnEndDateCheckbox
)
184 // wxGlade: add TaskEditDlg event handlers
186 void TaskEditDlg::OnDueCheck(wxCommandEvent
&event
)
188 EnableDueDate(m_DueCheck
->IsChecked());
190 // make sure the first date is in a recent range, if not previously
192 MakeRecent(m_DueCheck
, m_DueDateCtrl
);
195 void TaskEditDlg::OnRecurrenceChoice(wxCommandEvent
&event
)
197 TransferDataFromWindow();
198 EnableRecurMode(m_rec
.Recurring
);
201 void TaskEditDlg::OnEndDateCheckbox(wxCommandEvent
&event
)
203 m_RecurEndDateCtrl
->Enable( !m_NeverEndsCheck
->IsChecked() );
206 void TaskEditDlg::OnReminderCheck(wxCommandEvent
&event
)
208 EnableReminderDate(m_ReminderCheck
->IsChecked());
210 // make sure the first date is in a recent range, if not previously
212 MakeRecent(m_ReminderCheck
, m_ReminderDateCtrl
);
215 void TaskEditDlg::set_properties()
217 // begin wxGlade: TaskEditDlg::set_properties
218 SetTitle(wxT("Task Event"));
219 m_TaskSummary
->SetFocus();
220 m_TaskSummary
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_rec
.Summary
)));
221 m_StatusChoice
->SetSelection(0);
222 m_PriorityChoice
->SetSelection(1);
223 m_DueDateCtrl
->SetMinSize(wxSize(110, -1));
224 m_DueDateCtrl
->SetValidator(DateTimeValidator(&m_DueDateObj
.m_date
));
225 m_DueHoursSpinner
->SetMinSize(wxSize(45, -1));
226 m_DueHoursSpinner
->SetValidator(wxGenericValidator(&m_DueDateObj
.m_hour
));
227 m_DueMinutesSpinner
->SetMinSize(wxSize(45, -1));
228 m_DueMinutesSpinner
->SetValidator(wxGenericValidator(&m_DueDateObj
.m_min
));
229 m_TimezoneChoice
->SetSelection(0);
230 m_ReminderDateCtrl
->SetMinSize(wxSize(110, -1));
231 m_ReminderDateCtrl
->SetValidator(DateTimeValidator(&m_ReminderDateObj
.m_date
));
232 m_ReminderHoursSpinner
->SetMinSize(wxSize(45, -1));
233 m_ReminderHoursSpinner
->SetToolTip(wxT("Set Reminder to 0 to disable"));
234 m_ReminderHoursSpinner
->SetValidator(wxGenericValidator(&m_ReminderDateObj
.m_hour
));
235 m_ReminderMinutesSpinner
->SetMinSize(wxSize(45, -1));
236 m_ReminderMinutesSpinner
->SetToolTip(wxT("Set Reminder to 0 to disable"));
237 m_ReminderMinutesSpinner
->SetValidator(wxGenericValidator(&m_ReminderDateObj
.m_min
));
238 m_RecurrenceChoice
->SetValidator(wxGenericValidator(&m_recur_choice
));
239 m_RecurrenceChoice
->SetSelection(0);
240 m_IntervalSpinner
->SetMinSize(wxSize(45, -1));
241 m_IntervalSpinner
->SetValidator(wxGenericValidator(&m_interval
));
242 m_SunCheck
->SetValidator(wxGenericValidator(&m_weekdays
[0]));
243 m_MonCheck
->SetValidator(wxGenericValidator(&m_weekdays
[1]));
244 m_TueCheck
->SetValidator(wxGenericValidator(&m_weekdays
[2]));
245 m_WedCheck
->SetValidator(wxGenericValidator(&m_weekdays
[3]));
246 m_ThuCheck
->SetValidator(wxGenericValidator(&m_weekdays
[4]));
247 m_FriCheck
->SetValidator(wxGenericValidator(&m_weekdays
[5]));
248 m_SatCheck
->SetValidator(wxGenericValidator(&m_weekdays
[6]));
249 RecurRelativeDateLabel
->SetToolTip(wxT("Relative monthly or yearly dates take the weekday of the start date into account. (eg. every first Sunday of month)"));
250 m_RelativeDateCheck
->SetToolTip(wxT("Relative monthly or yearly dates take the weekday of the start date into account. (eg. every first Sunday of month)"));
251 m_RelativeDateCheck
->SetValidator(wxGenericValidator(&m_relative_date
));
252 m_NeverEndsCheck
->SetValidator(wxGenericValidator(&m_rec
.Perpetual
));
253 m_NeverEndsCheck
->SetValue(1);
254 m_RecurEndDateCtrl
->SetMinSize(wxSize(110, -1));
255 m_RecurEndDateCtrl
->Enable(false);
256 m_RecurEndDateCtrl
->SetValidator(DateTimeValidator(&m_RecurEndDateObj
.m_date
));
257 m_CategoriesText
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_categories
)));
258 m_NotesText
->SetMinSize(wxSize(-1, 71));
259 m_NotesText
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_rec
.Notes
)));
263 void TaskEditDlg::do_layout()
265 // begin wxGlade: TaskEditDlg::do_layout
266 wxBoxSizer
* sizer_surround
= new wxBoxSizer(wxVERTICAL
);
267 wxBoxSizer
* sizer_1
= new wxBoxSizer(wxVERTICAL
);
268 wxFlexGridSizer
* grid_sizer_3
= new wxFlexGridSizer(2, 2, 5, 5);
269 wxFlexGridSizer
* grid_sizer_4
= new wxFlexGridSizer(5, 2, 5, 5);
270 wxBoxSizer
* sizer_8
= new wxBoxSizer(wxHORIZONTAL
);
271 wxBoxSizer
* m_DaysCtrlsSizer
= new wxBoxSizer(wxHORIZONTAL
);
272 wxBoxSizer
* m_IntervalCtrlsSizer
= new wxBoxSizer(wxHORIZONTAL
);
273 wxFlexGridSizer
* grid_sizer_2
= new wxFlexGridSizer(10, 2, 5, 5);
274 wxBoxSizer
* sizer_5_copy
= new wxBoxSizer(wxHORIZONTAL
);
275 wxBoxSizer
* sizer_3
= new wxBoxSizer(wxHORIZONTAL
);
276 wxFlexGridSizer
* grid_sizer_1
= new wxFlexGridSizer(2, 2, 5, 5);
277 grid_sizer_1
->Add(label_1
, 0, wxALIGN_CENTER_VERTICAL
, 0);
278 grid_sizer_1
->Add(m_TaskSummary
, 0, wxEXPAND
, 0);
279 grid_sizer_1
->AddGrowableCol(1);
280 sizer_1
->Add(grid_sizer_1
, 0, wxEXPAND
, 0);
281 sizer_1
->Add(static_line_1
, 0, wxALL
|wxEXPAND
, 5);
282 grid_sizer_2
->Add(label_2
, 0, wxALIGN_CENTER_VERTICAL
, 0);
283 grid_sizer_2
->Add(m_StatusChoice
, 0, 0, 0);
284 grid_sizer_2
->Add(label_9
, 0, wxALIGN_CENTER_VERTICAL
, 0);
285 grid_sizer_2
->Add(m_PriorityChoice
, 0, 0, 0);
286 grid_sizer_2
->Add(label_5
, 0, wxALIGN_CENTER_VERTICAL
, 0);
287 sizer_3
->Add(m_DueCheck
, 0, 0, 0);
288 sizer_3
->Add(m_DueDateCtrl
, 0, 0, 0);
289 sizer_3
->Add(20, 20, 0, 0, 0);
290 sizer_3
->Add(m_DueHoursSpinner
, 0, 0, 0);
291 sizer_3
->Add(label_11
, 0, wxLEFT
|wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 1);
292 sizer_3
->Add(m_DueMinutesSpinner
, 0, 0, 0);
293 grid_sizer_2
->Add(sizer_3
, 1, wxEXPAND
, 0);
294 grid_sizer_2
->Add(label_8
, 0, wxALIGN_CENTER_VERTICAL
, 0);
295 grid_sizer_2
->Add(m_TimezoneChoice
, 0, 0, 0);
296 grid_sizer_2
->Add(label_10
, 0, wxALIGN_CENTER_VERTICAL
, 0);
297 sizer_5_copy
->Add(m_ReminderCheck
, 0, 0, 0);
298 sizer_5_copy
->Add(m_ReminderDateCtrl
, 0, 0, 0);
299 sizer_5_copy
->Add(20, 20, 0, 0, 0);
300 sizer_5_copy
->Add(m_ReminderHoursSpinner
, 0, 0, 5);
301 sizer_5_copy
->Add(label_6
, 0, wxLEFT
|wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 1);
302 sizer_5_copy
->Add(m_ReminderMinutesSpinner
, 0, wxRIGHT
, 5);
303 grid_sizer_2
->Add(sizer_5_copy
, 1, wxEXPAND
, 0);
304 grid_sizer_2
->AddGrowableCol(1);
305 sizer_1
->Add(grid_sizer_2
, 0, wxEXPAND
, 0);
306 sizer_1
->Add(static_line_2
, 0, wxALL
|wxEXPAND
, 5);
307 grid_sizer_4
->Add(label_18
, 0, wxALIGN_CENTER_VERTICAL
, 0);
308 grid_sizer_4
->Add(m_RecurrenceChoice
, 0, 0, 0);
309 grid_sizer_4
->Add(RecurIntervalLabel
, 0, wxALIGN_CENTER_VERTICAL
, 0);
310 m_IntervalCtrlsSizer
->Add(RecurIntervalLabelB
, 0, wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 5);
311 m_IntervalCtrlsSizer
->Add(m_IntervalSpinner
, 0, wxRIGHT
, 5);
312 m_IntervalCtrlsSizer
->Add(m_IntervalUnitLabel
, 1, wxALIGN_CENTER_VERTICAL
, 0);
313 grid_sizer_4
->Add(m_IntervalCtrlsSizer
, 1, wxEXPAND
, 0);
314 grid_sizer_4
->Add(RecurDaysLabel
, 0, wxALIGN_CENTER_VERTICAL
, 0);
315 m_DaysCtrlsSizer
->Add(m_SunCheck
, 0, wxRIGHT
, 5);
316 m_DaysCtrlsSizer
->Add(m_MonCheck
, 0, wxRIGHT
, 5);
317 m_DaysCtrlsSizer
->Add(m_TueCheck
, 0, wxRIGHT
, 5);
318 m_DaysCtrlsSizer
->Add(m_WedCheck
, 0, wxRIGHT
, 5);
319 m_DaysCtrlsSizer
->Add(m_ThuCheck
, 0, wxRIGHT
, 5);
320 m_DaysCtrlsSizer
->Add(m_FriCheck
, 0, wxRIGHT
, 5);
321 m_DaysCtrlsSizer
->Add(m_SatCheck
, 0, wxRIGHT
, 5);
322 grid_sizer_4
->Add(m_DaysCtrlsSizer
, 1, wxEXPAND
, 0);
323 grid_sizer_4
->Add(RecurRelativeDateLabel
, 0, wxALIGN_CENTER_VERTICAL
, 0);
324 grid_sizer_4
->Add(m_RelativeDateCheck
, 0, 0, 0);
325 grid_sizer_4
->Add(RecurEndDateLabel
, 0, wxALIGN_CENTER_VERTICAL
, 0);
326 sizer_8
->Add(m_NeverEndsCheck
, 0, wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 10);
327 sizer_8
->Add(m_RecurEndDateCtrl
, 0, wxALIGN_CENTER_VERTICAL
, 0);
328 grid_sizer_4
->Add(sizer_8
, 1, wxEXPAND
, 0);
329 grid_sizer_4
->AddGrowableCol(1);
330 sizer_1
->Add(grid_sizer_4
, 0, wxEXPAND
, 0);
331 sizer_1
->Add(static_line_3
, 0, wxALL
|wxEXPAND
, 5);
332 grid_sizer_3
->Add(label_4
, 0, wxALIGN_CENTER_VERTICAL
, 0);
333 grid_sizer_3
->Add(m_CategoriesText
, 0, wxEXPAND
, 0);
334 grid_sizer_3
->Add(label_3
, 0, wxRIGHT
, 5);
335 grid_sizer_3
->Add(m_NotesText
, 1, wxEXPAND
, 0);
336 grid_sizer_3
->AddGrowableCol(1);
337 sizer_1
->Add(grid_sizer_3
, 1, wxEXPAND
, 0);
338 sizer_surround
->Add(sizer_1
, 1, wxALL
|wxEXPAND
, 10);
339 SetSizer(sizer_surround
);
340 sizer_surround
->Fit(this);
344 m_top_sizer
= sizer_surround
;
347 bool TaskEditDlg::TransferDataToWindow()
349 // prepare temporary variables, from record
351 m_rec
.Categories
.CategoryList2Str(m_categories
);
354 m_DueCheck
->SetValue(m_rec
.DueTime
.IsValid());
355 EnableDueDate(m_rec
.DueTime
.IsValid());
356 m_DueDateObj
.Set(m_rec
.DueTime
.Time
);
358 // alarm / reminder time
359 m_ReminderCheck
->SetValue(m_rec
.AlarmTime
.IsValid());
360 EnableReminderDate(m_rec
.AlarmTime
.IsValid());
361 m_ReminderDateObj
.Set(m_rec
.AlarmTime
.Time
);
364 #define S_NOT_STARTED 0
365 #define S_IN_PROGRESS 1
366 #define S_COMPLETED 2
369 switch( m_rec
.StatusFlag
)
371 case Barry::Task::NotStarted
:
373 m_StatusChoice
->SetSelection(S_NOT_STARTED
);
376 case Barry::Task::InProgress
:
377 m_StatusChoice
->SetSelection(S_IN_PROGRESS
);
380 case Barry::Task::Completed
:
381 m_StatusChoice
->SetSelection(S_COMPLETED
);
384 case Barry::Task::Waiting
:
385 m_StatusChoice
->SetSelection(S_WAITING
);
388 case Barry::Task::Deferred
:
389 m_StatusChoice
->SetSelection(S_DEFERRED
);
397 switch( m_rec
.PriorityFlag
)
399 case Barry::Task::High
:
400 m_PriorityChoice
->SetSelection(P_HIGH
);
403 case Barry::Task::Normal
:
405 m_PriorityChoice
->SetSelection(P_NORMAL
);
408 case Barry::Task::Low
:
409 m_PriorityChoice
->SetSelection(P_LOW
);
413 // set the timezone choice only if the record's data is valid
414 m_TimezoneChoice
->SetSelection(0); // default to none
415 if( m_rec
.TimeZoneValid
) {
416 TimeZones::const_iterator i
= m_zones
->Find(m_rec
.TimeZoneCode
);
417 if( i
!= m_zones
->end() ) {
418 int array_index
= i
- m_zones
->begin();
419 // select item, skipping 0's "none" option
420 m_TimezoneChoice
->SetSelection(array_index
+ 1);
424 // Note that recur_choice values are (zero-based) in the following
426 // None, Daily, Weekly, Monthly, Yearly
433 if( m_rec
.Recurring
) {
434 switch( m_rec
.RecurringType
)
436 case Barry::RecurBase::Day
:
437 m_recur_choice
= RC_DAILY
;
438 m_relative_date
= false;
441 case Barry::RecurBase::MonthByDate
:
442 m_recur_choice
= RC_MONTHLY
;
443 m_relative_date
= false;
446 case Barry::RecurBase::MonthByDay
:
447 m_recur_choice
= RC_MONTHLY
;
448 m_relative_date
= true;
451 case Barry::RecurBase::YearByDate
:
452 m_recur_choice
= RC_YEARLY
;
453 m_relative_date
= false;
456 case Barry::RecurBase::YearByDay
:
457 m_recur_choice
= RC_YEARLY
;
458 m_relative_date
= true;
461 case Barry::RecurBase::Week
:
462 m_recur_choice
= RC_WEEKLY
;
463 m_relative_date
= false;
464 m_weekdays
[0] = m_rec
.WeekDays
& CAL_WD_SUN
;
465 m_weekdays
[1] = m_rec
.WeekDays
& CAL_WD_MON
;
466 m_weekdays
[2] = m_rec
.WeekDays
& CAL_WD_TUE
;
467 m_weekdays
[3] = m_rec
.WeekDays
& CAL_WD_WED
;
468 m_weekdays
[4] = m_rec
.WeekDays
& CAL_WD_THU
;
469 m_weekdays
[5] = m_rec
.WeekDays
& CAL_WD_FRI
;
470 m_weekdays
[6] = m_rec
.WeekDays
& CAL_WD_SAT
;
474 cerr
<< "Bad RecurringType in CalendarEditDlg" << endl
;
475 m_recur_choice
= RC_NONE
;
476 m_relative_date
= false;
480 m_recur_choice
= RC_NONE
;
481 m_relative_date
= false;
484 m_interval
= m_rec
.Interval
;
486 if( m_rec
.Perpetual
) {
487 m_RecurEndDateCtrl
->Enable(false);
490 m_RecurEndDateCtrl
->Enable();
491 m_RecurEndDateObj
.Set(m_rec
.RecurringEndTime
.Time
);
494 EnableRecurMode(m_rec
.Recurring
);
498 return wxDialog::TransferDataToWindow();
501 bool TaskEditDlg::TransferDataFromWindow()
503 if( !wxDialog::TransferDataFromWindow() )
508 m_rec
.Categories
.CategoryStr2List(m_categories
);
511 if( m_DueCheck
->IsChecked() )
512 m_rec
.DueTime
.Time
= m_DueDateObj
.Get();
514 m_rec
.DueTime
.clear();
516 // alarm / reminder time
517 if( m_ReminderCheck
->IsChecked() )
518 m_rec
.AlarmTime
.Time
= m_ReminderDateObj
.Get();
520 m_rec
.AlarmTime
.clear();
523 switch( m_StatusChoice
->GetSelection() )
527 m_rec
.StatusFlag
= Barry::Task::NotStarted
;
531 m_rec
.StatusFlag
= Barry::Task::InProgress
;
535 m_rec
.StatusFlag
= Barry::Task::Completed
;
539 m_rec
.StatusFlag
= Barry::Task::Waiting
;
543 m_rec
.StatusFlag
= Barry::Task::Deferred
;
548 switch( m_PriorityChoice
->GetSelection() )
551 m_rec
.PriorityFlag
= Barry::Task::High
;
556 m_rec
.PriorityFlag
= Barry::Task::Normal
;
560 m_rec
.PriorityFlag
= Barry::Task::Low
;
564 // set the timezone choice only if the record's data is valid
565 int sel
= m_TimezoneChoice
->GetSelection();
567 m_rec
.TimeZoneCode
= (*m_zones
)[sel
-1].Index
;
568 m_rec
.TimeZoneValid
= true;
571 // default was selected
572 m_rec
.TimeZoneValid
= false;
575 // Note that recur_choice values are (zero-based) in the following
577 // None, Daily, Weekly, Monthly, Yearly
578 switch( m_recur_choice
)
582 m_rec
.Recurring
= false;
586 m_rec
.Recurring
= true;
587 m_rec
.RecurringType
= Barry::RecurBase::Day
;
591 m_rec
.Recurring
= true;
592 m_rec
.RecurringType
= Barry::RecurBase::Week
;
594 if( m_weekdays
[0] ) m_rec
.WeekDays
|= CAL_WD_SUN
;
595 if( m_weekdays
[1] ) m_rec
.WeekDays
|= CAL_WD_MON
;
596 if( m_weekdays
[2] ) m_rec
.WeekDays
|= CAL_WD_TUE
;
597 if( m_weekdays
[3] ) m_rec
.WeekDays
|= CAL_WD_WED
;
598 if( m_weekdays
[4] ) m_rec
.WeekDays
|= CAL_WD_THU
;
599 if( m_weekdays
[5] ) m_rec
.WeekDays
|= CAL_WD_FRI
;
600 if( m_weekdays
[6] ) m_rec
.WeekDays
|= CAL_WD_SAT
;
604 m_rec
.Recurring
= true;
605 if( m_relative_date
)
606 m_rec
.RecurringType
= Barry::RecurBase::MonthByDay
;
608 m_rec
.RecurringType
= Barry::RecurBase::MonthByDate
;
612 m_rec
.Recurring
= true;
613 if( m_relative_date
)
614 m_rec
.RecurringType
= Barry::RecurBase::YearByDay
;
616 m_rec
.RecurringType
= Barry::RecurBase::YearByDate
;
621 m_rec
.Interval
= m_interval
;
623 if( !m_rec
.Perpetual
) {
624 m_rec
.RecurringEndTime
.Time
= m_RecurEndDateObj
.Get();
630 void TaskEditDlg::EnableDueDate(bool enable
)
632 m_DueDateCtrl
->Enable(enable
);
633 m_DueHoursSpinner
->Enable(enable
);
634 m_DueMinutesSpinner
->Enable(enable
);
635 m_RecurrenceChoice
->Enable(enable
);
638 m_RecurrenceChoice
->SetSelection(0);
639 EnableRecurMode(false);
643 void TaskEditDlg::EnableReminderDate(bool enable
)
645 m_ReminderDateCtrl
->Enable(enable
);
646 m_ReminderHoursSpinner
->Enable(enable
);
647 m_ReminderMinutesSpinner
->Enable(enable
);
650 void TaskEditDlg::EnableRecurMode(bool recur
)
652 RecurIntervalLabel
->Show(recur
);
653 RecurIntervalLabelB
->Show(recur
);
654 m_IntervalSpinner
->Show(recur
);
655 m_IntervalUnitLabel
->Show(recur
);
656 RecurDaysLabel
->Show(recur
);
657 m_SunCheck
->Show(recur
);
658 m_MonCheck
->Show(recur
);
659 m_TueCheck
->Show(recur
);
660 m_WedCheck
->Show(recur
);
661 m_ThuCheck
->Show(recur
);
662 m_FriCheck
->Show(recur
);
663 m_SatCheck
->Show(recur
);
664 RecurRelativeDateLabel
->Show(recur
);
665 m_RelativeDateCheck
->Show(recur
);
666 RecurEndDateLabel
->Show(recur
);
667 m_NeverEndsCheck
->Show(recur
);
668 m_RecurEndDateCtrl
->Show(recur
);
671 switch( m_RecurrenceChoice
->GetSelection() )
675 m_IntervalUnitLabel
->SetLabel(_T(""));
679 m_IntervalUnitLabel
->SetLabel(_T("day(s)"));
683 m_IntervalUnitLabel
->SetLabel(_T("week(s)"));
687 m_IntervalUnitLabel
->SetLabel(_T("month(s)"));
691 m_IntervalUnitLabel
->SetLabel(_T("year(s)"));