2 /// \file CalendarEditDlg.cc
3 /// Dialog class to handle the editing of the Calendar 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 "CalendarEditDlg.h"
23 #include "windowids.h"
24 #include <wx/valgen.h>
28 using namespace Barry
;
30 // begin wxGlade: ::extracode
34 //////////////////////////////////////////////////////////////////////////////
35 // CalendarEditDlg class
37 CalendarEditDlg::CalendarEditDlg(wxWindow
* parent
,
40 const Barry::TimeZones
*device_zones
)
41 : wxDialog(parent
, Dialog_CalendarEdit
, _T("Calendar Record"))
42 , m_zones(device_zones
? device_zones
: &m_static_zones
)
45 , m_duration_minutes(0)
47 , m_reminder_minutes(0)
49 , m_relative_date(false)
51 // set all weekday 'bits' to false
52 for( int i
= 0; i
< 7; i
++ )
53 m_weekdays
[i
] = false;
56 bottom_buttons
= CreateButtonSizer(wxOK
| wxCANCEL
);
59 bottom_buttons
= CreateButtonSizer(wxCANCEL
);
62 // begin wxGlade: CalendarEditDlg::CalendarEditDlg
63 label_1
= new wxStaticText(this, wxID_ANY
, wxT("Subject:"));
64 m_Subject
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
65 label_2
= new wxStaticText(this, wxID_ANY
, wxT("Location:"));
66 m_Location
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
67 static_line_1
= new wxStaticLine(this, wxID_ANY
);
68 label_4
= new wxStaticText(this, wxID_ANY
, wxT("All Day Event:"));
69 m_AllDayCheck
= new wxCheckBox(this, Dialog_CalendarEdit_AllDayCheck
, wxEmptyString
);
70 label_5
= new wxStaticText(this, wxID_ANY
, wxT("Start:"));
71 m_StartDateCtrl
= new wxDatePickerCtrl(this, Dialog_CalendarEdit_StartDateCtrl
, wxDefaultDateTime
, wxDefaultPosition
, wxDefaultSize
, wxDP_DROPDOWN
|wxDP_SHOWCENTURY
);
72 m_StartHoursSpinner
= new wxSpinCtrl(this, Dialog_CalendarEdit_StartHoursSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_WRAP
|wxTE_NOHIDESEL
, 0, 23);
73 label_11
= new wxStaticText(this, wxID_ANY
, wxT(":"));
74 m_StartMinutesSpinner
= new wxSpinCtrl(this, Dialog_CalendarEdit_StartMinutesSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_WRAP
|wxTE_NOHIDESEL
, 0, 59);
75 label_6
= new wxStaticText(this, wxID_ANY
, wxT("End:"));
76 m_EndDateCtrl
= new wxDatePickerCtrl(this, Dialog_CalendarEdit_EndDateCtrl
, wxDefaultDateTime
, wxDefaultPosition
, wxDefaultSize
, wxDP_DROPDOWN
|wxDP_SHOWCENTURY
);
77 m_EndHoursSpinner
= new wxSpinCtrl(this, Dialog_CalendarEdit_EndHoursSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_WRAP
|wxTE_NOHIDESEL
, 0, 23);
78 label_12
= new wxStaticText(this, wxID_ANY
, wxT(":"));
79 m_EndMinutesSpinner
= new wxSpinCtrl(this, Dialog_CalendarEdit_EndMinutesSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_WRAP
|wxTE_NOHIDESEL
, 0, 59);
80 label_7
= new wxStaticText(this, wxID_ANY
, wxT("Duration:"));
81 m_DurationHoursSpinner
= new wxSpinCtrl(this, Dialog_CalendarEdit_DurationHoursSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 0, 999);
82 label_13
= new wxStaticText(this, wxID_ANY
, wxT("hours and"));
83 m_DurationMinutesSpinner
= new wxSpinCtrl(this, Dialog_CalendarEdit_DurationMinutesSpinner
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 0, 59);
84 label_17
= new wxStaticText(this, wxID_ANY
, wxT("minutes."));
85 label_8
= new wxStaticText(this, wxID_ANY
, wxT("Time Zone:"));
86 const wxString m_TimezoneChoice_choices
[] = {
87 wxT("System Time Zone")
89 m_TimezoneChoice
= new wxChoice(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, 1, m_TimezoneChoice_choices
, 0);
90 label_9
= new wxStaticText(this, wxID_ANY
, wxT("Show As:"));
91 const wxString m_ShowAsChoice_choices
[] = {
97 m_ShowAsChoice
= new wxChoice(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, 4, m_ShowAsChoice_choices
, 0);
98 label_10
= new wxStaticText(this, wxID_ANY
, wxT("Reminder:"));
99 m_ReminderHoursSpinner
= new wxSpinCtrl(this, wxID_ANY
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 0, 999);
100 label_13_copy
= new wxStaticText(this, wxID_ANY
, wxT("hours and"));
101 m_ReminderMinutesSpinner
= new wxSpinCtrl(this, wxID_ANY
, wxT(""), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 0, 59);
102 label_17_copy
= new wxStaticText(this, wxID_ANY
, wxT("minutes."));
103 static_line_2
= new wxStaticLine(this, wxID_ANY
);
104 label_18
= new wxStaticText(this, wxID_ANY
, wxT("Recurrence:"));
105 const wxString m_RecurrenceChoice_choices
[] = {
112 m_RecurrenceChoice
= new wxChoice(this, Dialog_CalendarEdit_RecurrenceChoice
, wxDefaultPosition
, wxDefaultSize
, 5, m_RecurrenceChoice_choices
, 0);
113 label_19
= new wxStaticText(this, wxID_ANY
, wxT("Interval:"));
114 label_23
= new wxStaticText(this, wxID_ANY
, wxT("Every"));
115 m_IntervalSpinner
= new wxSpinCtrl(this, wxID_ANY
, wxT("1"), wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 1, 999);
116 m_IntervalUnitLabel
= new wxStaticText(this, wxID_ANY
, wxT("days? weeks? months?"), wxDefaultPosition
, wxDefaultSize
, wxST_NO_AUTORESIZE
);
117 label_20
= new wxStaticText(this, wxID_ANY
, wxT("Days:"));
118 m_SunCheck
= new wxCheckBox(this, wxID_ANY
, wxT("S"));
119 m_MonCheck
= new wxCheckBox(this, wxID_ANY
, wxT("M"));
120 m_TueCheck
= new wxCheckBox(this, wxID_ANY
, wxT("T"));
121 m_WedCheck
= new wxCheckBox(this, wxID_ANY
, wxT("W"));
122 m_ThuCheck
= new wxCheckBox(this, wxID_ANY
, wxT("T"));
123 m_FriCheck
= new wxCheckBox(this, wxID_ANY
, wxT("F"));
124 m_SatCheck
= new wxCheckBox(this, wxID_ANY
, wxT("S"));
125 label_21
= new wxStaticText(this, wxID_ANY
, wxT("Relative Date:"));
126 m_RelativeDateCheck
= new wxCheckBox(this, wxID_ANY
, wxEmptyString
);
127 label_22
= new wxStaticText(this, wxID_ANY
, wxT("End Date:"));
128 m_NeverEndsCheck
= new wxCheckBox(this, Dialog_CalendarEdit_NeverEndsCheck
, wxT("Never ends"));
129 m_RecurEndDateCtrl
= new wxDatePickerCtrl(this, wxID_ANY
, wxDefaultDateTime
, wxDefaultPosition
, wxDefaultSize
, wxDP_DROPDOWN
|wxDP_SHOWCENTURY
);
130 static_line_3
= new wxStaticLine(this, wxID_ANY
);
131 label_14
= new wxStaticText(this, wxID_ANY
, wxT("Organizer:"));
132 m_OrganizerText
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
133 label_15
= new wxStaticText(this, wxID_ANY
, wxT("Invited:"));
134 m_InvitedText
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
135 label_16
= new wxStaticText(this, wxID_ANY
, wxT("Accepted By:"));
136 m_AcceptedByText
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
);
137 static_line_4
= new wxStaticLine(this, wxID_ANY
);
138 const wxString m_ClassRadioBox_choices
[] = {
143 m_ClassRadioBox
= new wxRadioBox(this, wxID_ANY
, wxT("Class"), wxDefaultPosition
, wxDefaultSize
, 3, m_ClassRadioBox_choices
, 3, wxRA_SPECIFY_COLS
);
144 static_line_5
= new wxStaticLine(this, wxID_ANY
);
145 label_3
= new wxStaticText(this, wxID_ANY
, wxT("Notes:"));
146 m_NotesText
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
152 m_top_sizer
->Add(bottom_buttons
, 0, wxLEFT
|wxRIGHT
|wxBOTTOM
|wxEXPAND
, 5);
154 // fill the time zone control with real time zones
155 m_TimezoneChoice
->Clear();
156 m_TimezoneChoice
->Append(wxT("Assume Local Timezone"), (void*)0);
157 Barry::TimeZones::const_iterator b
, e
;
158 for( b
= m_zones
->begin(), e
= m_zones
->end(); b
!= e
; ++b
) {
159 m_TimezoneChoice
->Append(
160 wxString(b
->GetDescription().c_str(), wxConvUTF8
),
163 m_TimezoneChoice
->SetSelection(0);
165 // layout again, in case sizes are different
169 void CalendarEditDlg::RedoLayout()
171 m_top_sizer
->Fit(this);
175 BEGIN_EVENT_TABLE(CalendarEditDlg
, wxDialog
)
176 // begin wxGlade: CalendarEditDlg::event_table
177 EVT_CHECKBOX(Dialog_CalendarEdit_AllDayCheck
, CalendarEditDlg::OnAllDayEvent
)
178 EVT_DATE_CHANGED(Dialog_CalendarEdit_StartDateCtrl
, CalendarEditDlg::OnStartDateChanged
)
179 EVT_SPINCTRL(Dialog_CalendarEdit_StartHoursSpinner
, CalendarEditDlg::OnStartHoursSpin
)
180 EVT_SPINCTRL(Dialog_CalendarEdit_StartMinutesSpinner
, CalendarEditDlg::OnStartMinutesSpin
)
181 EVT_DATE_CHANGED(Dialog_CalendarEdit_EndDateCtrl
, CalendarEditDlg::OnEndDateChanged
)
182 EVT_SPINCTRL(Dialog_CalendarEdit_EndHoursSpinner
, CalendarEditDlg::OnEndHoursSpin
)
183 EVT_SPINCTRL(Dialog_CalendarEdit_EndMinutesSpinner
, CalendarEditDlg::OnEndMinutesSpin
)
184 EVT_SPINCTRL(Dialog_CalendarEdit_DurationHoursSpinner
, CalendarEditDlg::OnDurationHoursSpin
)
185 EVT_SPINCTRL(Dialog_CalendarEdit_DurationMinutesSpinner
, CalendarEditDlg::OnDurationMinutesSpin
)
186 EVT_CHOICE(Dialog_CalendarEdit_RecurrenceChoice
, CalendarEditDlg::OnRecurrenceChoice
)
187 EVT_CHECKBOX(Dialog_CalendarEdit_NeverEndsCheck
, CalendarEditDlg::OnEndDateCheckbox
)
192 void CalendarEditDlg::OnAllDayEvent(wxCommandEvent
&event
)
195 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnAllDayEvent) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
199 void CalendarEditDlg::OnStartDateChanged(wxDateEvent
&event
)
202 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnStartDateChanged) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
205 void CalendarEditDlg::OnStartHoursSpin(wxSpinEvent
&event
)
208 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnStartHoursSpin) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
211 void CalendarEditDlg::OnStartMinutesSpin(wxSpinEvent
&event
)
214 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnStartMinutesSpin) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
217 void CalendarEditDlg::OnEndDateChanged(wxDateEvent
&event
)
220 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnEndDateChanged) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
223 void CalendarEditDlg::OnEndHoursSpin(wxSpinEvent
&event
)
226 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnEndHoursSpin) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
229 void CalendarEditDlg::OnEndMinutesSpin(wxSpinEvent
&event
)
232 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnEndMinutesSpin) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
235 void CalendarEditDlg::OnDurationHoursSpin(wxSpinEvent
&event
)
238 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnDurationHoursSpin) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
241 void CalendarEditDlg::OnDurationMinutesSpin(wxSpinEvent
&event
)
244 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnDurationMinutesSpin) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
247 void CalendarEditDlg::OnRecurrenceChoice(wxCommandEvent
&event
)
250 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnRecurrenceChoice) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
254 void CalendarEditDlg::OnEndDateCheckbox(wxCommandEvent
&event
)
257 wxLogDebug(wxT("Event handler (CalendarEditDlg::OnEndDateCheckbox) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
261 // wxGlade: add CalendarEditDlg event handlers
264 void CalendarEditDlg::set_properties()
266 // begin wxGlade: CalendarEditDlg::set_properties
267 SetTitle(wxT("dialog_1"));
268 m_Subject
->SetFocus();
269 m_Subject
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_rec
.Subject
)));
270 m_Location
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_rec
.Location
)));
271 m_AllDayCheck
->SetValidator(wxGenericValidator(&m_rec
.AllDayEvent
));
272 m_StartDateCtrl
->SetMinSize(wxSize(110, -1));
273 m_StartDateCtrl
->SetValidator(DateTimeValidator(&m_StartDateObj
.m_date
));
274 m_StartHoursSpinner
->SetMinSize(wxSize(45, -1));
275 m_StartHoursSpinner
->SetValidator(wxGenericValidator(&m_StartDateObj
.m_hour
));
276 m_StartMinutesSpinner
->SetMinSize(wxSize(45, -1));
277 m_StartMinutesSpinner
->SetValidator(wxGenericValidator(&m_StartDateObj
.m_min
));
278 m_EndDateCtrl
->SetMinSize(wxSize(110, -1));
279 m_EndDateCtrl
->SetValidator(DateTimeValidator(&m_EndDateObj
.m_date
));
280 m_EndHoursSpinner
->SetMinSize(wxSize(45, -1));
281 m_EndHoursSpinner
->SetValidator(wxGenericValidator(&m_EndDateObj
.m_hour
));
282 m_EndMinutesSpinner
->SetMinSize(wxSize(45, -1));
283 m_EndMinutesSpinner
->SetValidator(wxGenericValidator(&m_EndDateObj
.m_min
));
284 m_DurationHoursSpinner
->SetMinSize(wxSize(45, -1));
285 m_DurationHoursSpinner
->SetValidator(wxGenericValidator(&m_duration_hours
));
286 m_DurationMinutesSpinner
->SetMinSize(wxSize(45, -1));
287 m_DurationMinutesSpinner
->SetValidator(wxGenericValidator(&m_duration_minutes
));
288 m_TimezoneChoice
->SetSelection(0);
289 m_ShowAsChoice
->SetSelection(2);
290 m_ReminderHoursSpinner
->SetMinSize(wxSize(45, -1));
291 m_ReminderHoursSpinner
->SetToolTip(wxT("Set Reminder to 0 to disable"));
292 m_ReminderHoursSpinner
->SetValidator(wxGenericValidator(&m_reminder_hours
));
293 m_ReminderMinutesSpinner
->SetMinSize(wxSize(45, -1));
294 m_ReminderMinutesSpinner
->SetToolTip(wxT("Set Reminder to 0 to disable"));
295 m_ReminderMinutesSpinner
->SetValidator(wxGenericValidator(&m_reminder_minutes
));
296 m_RecurrenceChoice
->SetValidator(wxGenericValidator(&m_recur_choice
));
297 m_RecurrenceChoice
->SetSelection(0);
298 m_IntervalSpinner
->SetMinSize(wxSize(45, -1));
299 m_IntervalSpinner
->SetValidator(wxGenericValidator(&m_interval
));
300 m_SunCheck
->SetValidator(wxGenericValidator(&m_weekdays
[0]));
301 m_MonCheck
->SetValidator(wxGenericValidator(&m_weekdays
[1]));
302 m_TueCheck
->SetValidator(wxGenericValidator(&m_weekdays
[2]));
303 m_WedCheck
->SetValidator(wxGenericValidator(&m_weekdays
[3]));
304 m_ThuCheck
->SetValidator(wxGenericValidator(&m_weekdays
[4]));
305 m_FriCheck
->SetValidator(wxGenericValidator(&m_weekdays
[5]));
306 m_SatCheck
->SetValidator(wxGenericValidator(&m_weekdays
[6]));
307 label_21
->SetToolTip(wxT("Relative monthly or yearly dates take the weekday of the start date into account. (eg. every first Sunday of month)"));
308 m_RelativeDateCheck
->SetToolTip(wxT("Relative monthly or yearly dates take the weekday of the start date into account. (eg. every first Sunday of month)"));
309 m_RelativeDateCheck
->SetValidator(wxGenericValidator(&m_relative_date
));
310 m_NeverEndsCheck
->SetValidator(wxGenericValidator(&m_rec
.Perpetual
));
311 m_NeverEndsCheck
->SetValue(1);
312 m_RecurEndDateCtrl
->SetMinSize(wxSize(110, -1));
313 m_RecurEndDateCtrl
->Enable(false);
314 m_RecurEndDateCtrl
->SetValidator(DateTimeValidator(&m_RecurEndDateObj
.m_date
));
315 m_OrganizerText
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_organizer
)));
316 m_InvitedText
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_invited
)));
317 m_AcceptedByText
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_accepted_by
)));
318 m_ClassRadioBox
->SetValidator(MakeRadioBoxValidator(&m_rec
.ClassFlag
).Add(Barry::Calendar::Public
).Add(Barry::Calendar::Private
).Add(Barry::Calendar::Confidential
));
319 m_ClassRadioBox
->SetSelection(0);
320 m_NotesText
->SetMinSize(wxSize(-1, 61));
321 m_NotesText
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_rec
.Notes
)));
326 void CalendarEditDlg::do_layout()
328 // begin wxGlade: CalendarEditDlg::do_layout
329 wxBoxSizer
* sizer_surround
= new wxBoxSizer(wxVERTICAL
);
330 wxBoxSizer
* sizer_1
= new wxBoxSizer(wxVERTICAL
);
331 wxBoxSizer
* sizer_2
= new wxBoxSizer(wxHORIZONTAL
);
332 wxFlexGridSizer
* grid_sizer_3
= new wxFlexGridSizer(3, 2, 5, 5);
333 wxFlexGridSizer
* grid_sizer_4
= new wxFlexGridSizer(5, 2, 5, 5);
334 wxBoxSizer
* sizer_8
= new wxBoxSizer(wxHORIZONTAL
);
335 wxBoxSizer
* m_DaysCtrlsSizer
= new wxBoxSizer(wxHORIZONTAL
);
336 wxBoxSizer
* m_IntervalCtrlsSizer
= new wxBoxSizer(wxHORIZONTAL
);
337 wxFlexGridSizer
* grid_sizer_2
= new wxFlexGridSizer(7, 2, 5, 5);
338 wxBoxSizer
* sizer_5_copy
= new wxBoxSizer(wxHORIZONTAL
);
339 wxBoxSizer
* sizer_5
= new wxBoxSizer(wxHORIZONTAL
);
340 wxBoxSizer
* sizer_4
= new wxBoxSizer(wxHORIZONTAL
);
341 wxBoxSizer
* sizer_3
= new wxBoxSizer(wxHORIZONTAL
);
342 wxFlexGridSizer
* grid_sizer_1
= new wxFlexGridSizer(2, 2, 5, 5);
343 grid_sizer_1
->Add(label_1
, 0, 0, 0);
344 grid_sizer_1
->Add(m_Subject
, 0, wxEXPAND
, 0);
345 grid_sizer_1
->Add(label_2
, 0, 0, 0);
346 grid_sizer_1
->Add(m_Location
, 0, wxEXPAND
, 0);
347 grid_sizer_1
->AddGrowableCol(1);
348 sizer_1
->Add(grid_sizer_1
, 0, wxEXPAND
, 0);
349 sizer_1
->Add(static_line_1
, 0, wxALL
|wxEXPAND
, 5);
350 grid_sizer_2
->Add(label_4
, 0, 0, 0);
351 grid_sizer_2
->Add(m_AllDayCheck
, 0, 0, 0);
352 grid_sizer_2
->Add(label_5
, 0, wxALIGN_CENTER_VERTICAL
, 0);
353 sizer_3
->Add(m_StartDateCtrl
, 0, 0, 0);
354 sizer_3
->Add(20, 20, 0, 0, 0);
355 sizer_3
->Add(m_StartHoursSpinner
, 0, 0, 0);
356 sizer_3
->Add(label_11
, 0, wxLEFT
|wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 1);
357 sizer_3
->Add(m_StartMinutesSpinner
, 0, 0, 0);
358 grid_sizer_2
->Add(sizer_3
, 1, wxEXPAND
, 0);
359 grid_sizer_2
->Add(label_6
, 0, wxALIGN_CENTER_VERTICAL
, 0);
360 sizer_4
->Add(m_EndDateCtrl
, 0, 0, 0);
361 sizer_4
->Add(20, 20, 0, 0, 0);
362 sizer_4
->Add(m_EndHoursSpinner
, 0, 0, 0);
363 sizer_4
->Add(label_12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 1);
364 sizer_4
->Add(m_EndMinutesSpinner
, 0, 0, 0);
365 grid_sizer_2
->Add(sizer_4
, 1, wxEXPAND
, 0);
366 grid_sizer_2
->Add(label_7
, 0, wxALIGN_CENTER_VERTICAL
, 0);
367 sizer_5
->Add(m_DurationHoursSpinner
, 0, wxRIGHT
, 5);
368 sizer_5
->Add(label_13
, 0, wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 5);
369 sizer_5
->Add(m_DurationMinutesSpinner
, 0, wxRIGHT
, 5);
370 sizer_5
->Add(label_17
, 0, wxALIGN_CENTER_VERTICAL
, 0);
371 grid_sizer_2
->Add(sizer_5
, 1, wxEXPAND
, 0);
372 grid_sizer_2
->Add(label_8
, 0, wxALIGN_CENTER_VERTICAL
, 0);
373 grid_sizer_2
->Add(m_TimezoneChoice
, 0, 0, 0);
374 grid_sizer_2
->Add(label_9
, 0, wxALIGN_CENTER_VERTICAL
, 0);
375 grid_sizer_2
->Add(m_ShowAsChoice
, 0, 0, 0);
376 grid_sizer_2
->Add(label_10
, 0, wxALIGN_CENTER_VERTICAL
, 0);
377 sizer_5_copy
->Add(m_ReminderHoursSpinner
, 0, wxRIGHT
, 5);
378 sizer_5_copy
->Add(label_13_copy
, 0, wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 5);
379 sizer_5_copy
->Add(m_ReminderMinutesSpinner
, 0, wxRIGHT
, 5);
380 sizer_5_copy
->Add(label_17_copy
, 0, wxALIGN_CENTER_VERTICAL
, 0);
381 grid_sizer_2
->Add(sizer_5_copy
, 1, wxEXPAND
, 0);
382 grid_sizer_2
->AddGrowableCol(1);
383 sizer_1
->Add(grid_sizer_2
, 0, wxEXPAND
, 0);
384 sizer_1
->Add(static_line_2
, 0, wxALL
|wxEXPAND
, 5);
385 grid_sizer_4
->Add(label_18
, 0, wxALIGN_CENTER_VERTICAL
, 0);
386 grid_sizer_4
->Add(m_RecurrenceChoice
, 0, 0, 0);
387 grid_sizer_4
->Add(label_19
, 0, wxALIGN_CENTER_VERTICAL
, 0);
388 m_IntervalCtrlsSizer
->Add(label_23
, 0, wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 5);
389 m_IntervalCtrlsSizer
->Add(m_IntervalSpinner
, 0, wxRIGHT
, 5);
390 m_IntervalCtrlsSizer
->Add(m_IntervalUnitLabel
, 1, wxALIGN_CENTER_VERTICAL
, 0);
391 grid_sizer_4
->Add(m_IntervalCtrlsSizer
, 1, wxEXPAND
, 0);
392 grid_sizer_4
->Add(label_20
, 0, wxALIGN_CENTER_VERTICAL
, 0);
393 m_DaysCtrlsSizer
->Add(m_SunCheck
, 0, wxRIGHT
, 5);
394 m_DaysCtrlsSizer
->Add(m_MonCheck
, 0, wxRIGHT
, 5);
395 m_DaysCtrlsSizer
->Add(m_TueCheck
, 0, wxRIGHT
, 5);
396 m_DaysCtrlsSizer
->Add(m_WedCheck
, 0, wxRIGHT
, 5);
397 m_DaysCtrlsSizer
->Add(m_ThuCheck
, 0, wxRIGHT
, 5);
398 m_DaysCtrlsSizer
->Add(m_FriCheck
, 0, wxRIGHT
, 5);
399 m_DaysCtrlsSizer
->Add(m_SatCheck
, 0, wxRIGHT
, 5);
400 grid_sizer_4
->Add(m_DaysCtrlsSizer
, 1, wxEXPAND
, 0);
401 grid_sizer_4
->Add(label_21
, 0, wxALIGN_CENTER_VERTICAL
, 0);
402 grid_sizer_4
->Add(m_RelativeDateCheck
, 0, 0, 0);
403 grid_sizer_4
->Add(label_22
, 0, wxALIGN_CENTER_VERTICAL
, 0);
404 sizer_8
->Add(m_NeverEndsCheck
, 0, wxRIGHT
|wxALIGN_CENTER_VERTICAL
, 10);
405 sizer_8
->Add(m_RecurEndDateCtrl
, 0, wxALIGN_CENTER_VERTICAL
, 0);
406 grid_sizer_4
->Add(sizer_8
, 1, wxEXPAND
, 0);
407 grid_sizer_4
->AddGrowableCol(1);
408 sizer_1
->Add(grid_sizer_4
, 0, wxEXPAND
, 0);
409 sizer_1
->Add(static_line_3
, 0, wxALL
|wxEXPAND
, 5);
410 grid_sizer_3
->Add(label_14
, 0, wxALIGN_CENTER_VERTICAL
, 0);
411 grid_sizer_3
->Add(m_OrganizerText
, 0, wxEXPAND
, 0);
412 grid_sizer_3
->Add(label_15
, 0, wxALIGN_CENTER_VERTICAL
, 0);
413 grid_sizer_3
->Add(m_InvitedText
, 0, wxEXPAND
, 0);
414 grid_sizer_3
->Add(label_16
, 0, wxALIGN_CENTER_VERTICAL
, 0);
415 grid_sizer_3
->Add(m_AcceptedByText
, 0, wxEXPAND
, 0);
416 grid_sizer_3
->AddGrowableCol(1);
417 sizer_1
->Add(grid_sizer_3
, 0, wxEXPAND
, 0);
418 sizer_1
->Add(static_line_4
, 0, wxALL
|wxEXPAND
, 5);
419 sizer_1
->Add(m_ClassRadioBox
, 0, wxEXPAND
, 0);
420 sizer_1
->Add(static_line_5
, 0, wxALL
|wxEXPAND
, 5);
421 sizer_2
->Add(label_3
, 0, wxRIGHT
, 5);
422 sizer_2
->Add(m_NotesText
, 1, wxEXPAND
, 0);
423 sizer_1
->Add(sizer_2
, 1, wxEXPAND
, 0);
424 sizer_surround
->Add(sizer_1
, 1, wxALL
|wxEXPAND
, 10);
425 SetSizer(sizer_surround
);
426 sizer_surround
->Fit(this);
430 m_top_sizer
= sizer_surround
;
433 bool CalendarEditDlg::TransferDataToWindow()
435 // prepare temporary variables, from record
437 m_organizer
= m_rec
.Organizer
.ToCommaSeparated();
438 m_invited
= m_rec
.Invited
.ToCommaSeparated();
439 m_accepted_by
= m_rec
.AcceptedBy
.ToCommaSeparated();
441 m_StartDateObj
.Set(m_rec
.StartTime
.Time
);
442 m_EndDateObj
.Set(m_rec
.EndTime
.Time
);
444 int duration
= m_rec
.EndTime
.Time
- m_rec
.StartTime
.Time
;
445 duration
/= 60; // convert to minutes
446 if( m_rec
.EndTime
.Time
>= m_rec
.StartTime
.Time
) {
447 m_duration_hours
= duration
/ 60;
448 m_duration_minutes
= duration
% 60;
451 if( m_rec
.NotificationTime
.Time
) {
452 int span
= m_rec
.StartTime
.Time
- m_rec
.NotificationTime
.Time
;
453 span
/= 60; // convert to minutes
454 if( m_rec
.StartTime
.Time
> m_rec
.NotificationTime
.Time
) {
455 m_reminder_hours
= span
/ 60;
456 m_reminder_minutes
= span
% 60;
459 m_reminder_hours
= 0;
460 m_reminder_minutes
= 15;
464 // set the timezone choice only if the record's data is valid
465 m_TimezoneChoice
->SetSelection(0); // default to none
466 if( m_rec
.TimeZoneValid
) {
467 TimeZones::const_iterator i
= m_zones
->Find(m_rec
.TimeZoneCode
);
468 if( i
!= m_zones
->end() ) {
469 int array_index
= i
- m_zones
->begin();
470 // select item, skipping 0's "none" option
471 m_TimezoneChoice
->SetSelection(array_index
+ 1);
475 // Note that recur_choice values are (zero-based) in the following
477 // None, Daily, Weekly, Monthly, Yearly
484 if( m_rec
.Recurring
) {
485 switch( m_rec
.RecurringType
)
487 case Barry::Calendar::Day
:
488 m_recur_choice
= RC_DAILY
;
489 m_relative_date
= false;
492 case Barry::Calendar::MonthByDate
:
493 m_recur_choice
= RC_MONTHLY
;
494 m_relative_date
= false;
497 case Barry::Calendar::MonthByDay
:
498 m_recur_choice
= RC_MONTHLY
;
499 m_relative_date
= true;
502 case Barry::Calendar::YearByDate
:
503 m_recur_choice
= RC_YEARLY
;
504 m_relative_date
= false;
507 case Barry::Calendar::YearByDay
:
508 m_recur_choice
= RC_YEARLY
;
509 m_relative_date
= true;
512 case Barry::Calendar::Week
:
513 m_recur_choice
= RC_WEEKLY
;
514 m_relative_date
= false;
515 m_weekdays
[0] = m_rec
.WeekDays
& CAL_WD_SUN
;
516 m_weekdays
[1] = m_rec
.WeekDays
& CAL_WD_MON
;
517 m_weekdays
[2] = m_rec
.WeekDays
& CAL_WD_TUE
;
518 m_weekdays
[3] = m_rec
.WeekDays
& CAL_WD_WED
;
519 m_weekdays
[4] = m_rec
.WeekDays
& CAL_WD_THU
;
520 m_weekdays
[5] = m_rec
.WeekDays
& CAL_WD_FRI
;
521 m_weekdays
[6] = m_rec
.WeekDays
& CAL_WD_SAT
;
525 cerr
<< "Bad RecurringType in CalendarEditDlg" << endl
;
526 m_recur_choice
= RC_NONE
;
527 m_relative_date
= false;
531 m_recur_choice
= RC_NONE
;
532 m_relative_date
= false;
535 m_interval
= m_rec
.Interval
;
537 if( m_rec
.Perpetual
) {
538 m_RecurEndDateCtrl
->Enable(false);
541 m_RecurEndDateCtrl
->Enable();
542 m_RecurEndDateObj
.Set(m_rec
.RecurringEndTime
.Time
);
545 m_strings
.SyncToWx();
547 return wxDialog::TransferDataToWindow();
550 bool CalendarEditDlg::TransferDataFromWindow()
552 if( !wxDialog::TransferDataFromWindow() )
555 m_strings
.SyncToStd();
557 m_rec
.Organizer
.clear();
558 m_rec
.Organizer
.AddCommaSeparated(m_organizer
);
560 m_rec
.Invited
.clear();
561 m_rec
.Invited
.AddCommaSeparated(m_invited
);
563 m_rec
.AcceptedBy
.clear();
564 m_rec
.AcceptedBy
.AddCommaSeparated(m_accepted_by
);
566 m_rec
.StartTime
.Time
= m_StartDateObj
.Get();
567 m_rec
.EndTime
.Time
= m_EndDateObj
.Get();
568 if( m_rec
.EndTime
.Time
< m_rec
.StartTime
.Time
) {
569 wxMessageBox(_T("Start time must come before end time."),
570 _T("Validation Error"), wxOK
| wxICON_INFORMATION
);
574 int span
= ((m_reminder_hours
* 60) + m_reminder_minutes
) * 60;
575 m_rec
.NotificationTime
.Time
= m_rec
.StartTime
.Time
+ span
;
577 // set the timezone choice only if the record's data is valid
578 int sel
= m_TimezoneChoice
->GetSelection();
580 m_rec
.TimeZoneCode
= (*m_zones
)[sel
-1].Index
;
581 m_rec
.TimeZoneValid
= true;
584 // default was selected
585 m_rec
.TimeZoneValid
= false;
588 // Note that recur_choice values are (zero-based) in the following
590 // None, Daily, Weekly, Monthly, Yearly
591 switch( m_recur_choice
)
595 m_rec
.Recurring
= false;
599 m_rec
.Recurring
= true;
600 m_rec
.RecurringType
= Barry::Calendar::Day
;
604 m_rec
.Recurring
= true;
605 m_rec
.RecurringType
= Barry::Calendar::Week
;
607 if( m_weekdays
[0] ) m_rec
.WeekDays
|= CAL_WD_SUN
;
608 if( m_weekdays
[1] ) m_rec
.WeekDays
|= CAL_WD_MON
;
609 if( m_weekdays
[2] ) m_rec
.WeekDays
|= CAL_WD_TUE
;
610 if( m_weekdays
[3] ) m_rec
.WeekDays
|= CAL_WD_WED
;
611 if( m_weekdays
[4] ) m_rec
.WeekDays
|= CAL_WD_THU
;
612 if( m_weekdays
[5] ) m_rec
.WeekDays
|= CAL_WD_FRI
;
613 if( m_weekdays
[6] ) m_rec
.WeekDays
|= CAL_WD_SAT
;
617 m_rec
.Recurring
= true;
618 if( m_relative_date
)
619 m_rec
.RecurringType
= Barry::Calendar::MonthByDay
;
621 m_rec
.RecurringType
= Barry::Calendar::MonthByDate
;
625 m_rec
.Recurring
= true;
626 if( m_relative_date
)
627 m_rec
.RecurringType
= Barry::Calendar::YearByDay
;
629 m_rec
.RecurringType
= Barry::Calendar::YearByDate
;
634 m_rec
.Interval
= m_interval
;
636 if( !m_rec
.Perpetual
) {
637 m_rec
.RecurringEndTime
.Time
= m_RecurEndDateObj
.Get();