2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file ClEventEditorForm.cpp
19 * @brief This is the implementation file for the EventEditorForm class.
24 #include "ClCalendarApp.h"
25 #include "ClCalendarSelectorPopup.h"
26 #include "ClEventEditorForm.h"
27 #include "ClEventPresentationModel.h"
28 #include "ClResourceManager.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Social;
36 using namespace Tizen::System;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Animations;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Ui::Scenes;
44 GROUP_TITLE_CONTENT = 0,
46 GROUP_INFORMATION_CONTENT,
47 GROUP_ADDITIONAL_CONTENT,
51 TITLE_CONTENT_ITEM_TITLE = 0,
52 TITLE_CONTENT_ITEM_COUNT,
54 FROM_DATE_SELECTOR_ITEM_START = 0,
55 TO_DATE_SELECTOR_ITEM_END,
56 // DATE_SELECTOR_ITEM_TIME_ZONE = 0,
57 DATE_SELECTOR_ITEM_ALL_DAY_EVENT,
58 DATE_SELECTOR_ITEM_COUNT,
60 INFORMATION_CONTENT_ITEM_DESCRIPTION = 0,
61 INFORMATION_CONTENT_ITEM_LOCATION,
62 INFORMATION_CONTENT_ITEM_COUNT,
64 ADDITIONAL_CONTENT_ITEM_REMINDER = 0,
65 ADDITIONAL_CONTENT_ITEM_REMINDER2,
66 ADDITIONAL_CONTENT_ITEM_REMINDER3,
67 ADDITIONAL_CONTENT_ITEM_REMINDER4,
68 ADDITIONAL_CONTENT_ITEM_REMINDER5,
69 ADDITIONAL_CONTENT_ITEM_REPEAT,
70 ADDITIONAL_CONTENT_ITEM_COUNT,
72 SAVE_TO_ITEM_SAVE_TO = 0,
76 static const int IDA_EVENT_EDITOR_FORM_SAVE = 20001;
77 static const int IDA_EVENT_EDITOR_FORM_CANCEL = 20002;
78 static const int IDA_EVENT_EDITOR_FORM_ADD_REMINDER = 20100;
79 static const int IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER = 20101;
80 static const int IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER2 = 20102;
81 static const int IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER3 = 20103;
82 static const int IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER4 = 20104;
83 static const int IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER5 = 20105;
85 static const int H_ITEM = 112;
86 static const int H_ITEM_2LINE = 136;
87 static const unsigned int COLOR_ITEM_BACKGROUND = Color32<239, 237, 229>::Value;
88 static const unsigned int COLOR_BLANK_BACKGROUND = Color32<0, 0, 0, 0>::Value;
89 static const int Y_ITEM_CONTENT01 = 22;
90 static const int H_ITEM_CONTENT01 = 38;
91 static const int Y_ITEM_CONTENT02 = 60;
92 static const int H_ITEM_CONTENT02 = 54;
93 static const int X_DATE_SELECTOR = 340;
94 static const int Y_DATE_SELECTOR = 0;
95 static const int Y_DESCRIPTION = 16;
96 static const int H_DESCRIPTION = 80;
97 static const int W_REMINDER_ADD_BUTTON = 74;
98 static const int W_REMINDER_ADD_BUTTON_MARGIN = 94;
99 static const int H_REMINDER_ADD_BUTTON = 74;
100 static const int W_REMINDER_DELETE_BUTTON = 74;
101 static const int W_REMINDER_DELETE_BUTTON_MARGIN = 184;
102 static const int H_REMINDER_DELETE_BUTTON = 74;
103 static const int FONT_SIZE_DETAIL02 = 32;
104 static const unsigned int COLOR_DETAIL02 = Color32<128, 128, 128>::Value;
105 static const int FONT_SIZE_DETAIL03 = 44;
106 static const unsigned int COLOR_DETAIL03 = Color32<0, 0, 0>::Value;
107 static const unsigned int COLOR_ADDITIONAL_CONTENT = Color32<59, 115, 182>::Value;
109 static const int EXPANDABLE_EDIT_MAX_LINE = 10;
110 static const int EDITFIELD_LIMIT_LENGTH = 500;
112 EventEditorForm::EventEditorForm(void)
114 , __style(EDIT_EVENT_FORM_STYLE_CREATE)
116 , __pEditFieldTitle(null)
117 , __pEditFieldLocation(null)
118 , __pEditDateStartDate(null)
119 , __pEditTimeStartTime(null)
120 , __pEditDateEndDate(null)
121 , __pEditTimeEndTime(null)
122 // , __pLabelTimeZone(null)
123 , __pLabelRepeat(null)
124 , __pTableViewItemNote(null)
125 , __pExpandableEditAreaNote(null)
126 , __pLabelSaveTo(null)
127 , __pButtonAddReminer(null)
128 , __pButtonDeleteReminder(null)
129 , __pCalendarSelectorPopup(null)
131 memset(__pLabelReminder, 0, sizeof(Label*) * MAX_COUNT_OF_REMINDER);
132 memset(__pItemReminder, 0, sizeof(TableViewItem*) * MAX_COUNT_OF_REMINDER);
135 EventEditorForm::~EventEditorForm(void)
140 EventEditorForm::Initialize(void)
142 return Construct(L"IDL_EVENT_EDITOR_FORM");
146 EventEditorForm::OnInitializing(void)
148 __pPm = new (std::nothrow) EventPresentationModel();
151 Footer* pFooter = GetFooter();
152 pFooter->AddActionEventListener(*this);
154 SetFormBackEventListener(this);
156 __pTableView = dynamic_cast<SectionTableView*>(GetControl(L"IDC_SECTIONTABLEVIEW"));
157 TryReturn(__pTableView != null, E_FAILURE, "[E_FAILURE] Unable to get sectiontableview.");
158 __pTableView->SetItemProvider(this);
159 __pTableView->AddSectionTableViewItemEventListener(*this);
160 __pTableView->SetGroupedLookEnabled(true);
162 __pCalendarSelectorPopup = new (std::nothrow) CalendarSelectorPopup();
163 __pCalendarSelectorPopup->Initialize();
169 EventEditorForm::OnTerminating(void)
172 if (__pCalendarSelectorPopup != null)
174 __pCalendarSelectorPopup->Destroy();
180 EventEditorForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
184 case IDA_CALENDAR_SELECTOR_POPUP_DONE:
187 __pPm->SetCalendar(static_cast<Integer*>(pArgs->GetAt(0))->value);
188 __pTableView->RefreshItem(GROUP_SAVE_TO, SAVE_TO_ITEM_SAVE_TO, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
195 pArgs->RemoveAll(true);
201 EventEditorForm::OnFormBackRequested(Form& source)
205 CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
208 if (pApp->GetOperationType() != OPERATION_TYPE_MAIN)
210 result r = SendAppControlResult(APP_CTRL_RESULT_CANCELED);
211 AppLogDebugIf(r != E_SUCCESS, "[%s] Unable to return result.", GetErrorMessage(r));
218 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
222 EventEditorForm::OnExpandableEditAreaLineAdded(ExpandableEditArea& source, int newLineCount)
224 __pTableView->RefreshItem(GROUP_INFORMATION_CONTENT, INFORMATION_CONTENT_ITEM_DESCRIPTION, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
228 EventEditorForm::OnExpandableEditAreaLineRemoved(ExpandableEditArea& source, int newLineCount)
230 __pTableView->RefreshItem(GROUP_INFORMATION_CONTENT, INFORMATION_CONTENT_ITEM_DESCRIPTION, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
234 EventEditorForm::GetSectionCount(void)
240 EventEditorForm::GetItemCount(int sectionIndex)
242 switch (sectionIndex)
244 case GROUP_TITLE_CONTENT:
245 return TITLE_CONTENT_ITEM_COUNT;
246 case GROUP_DATE_SELECTOR:
247 return DATE_SELECTOR_ITEM_COUNT;
248 case GROUP_INFORMATION_CONTENT:
249 return INFORMATION_CONTENT_ITEM_COUNT;
250 case GROUP_ADDITIONAL_CONTENT:
251 return ADDITIONAL_CONTENT_ITEM_COUNT;
253 return SAVE_TO_ITEM_COUNT;
260 EventEditorForm::CreateItem(int sectionIndex, int itemIndex, int itemWidth)
262 TableViewItem* pItem = null;
263 switch (sectionIndex)
265 case GROUP_TITLE_CONTENT:
268 case TITLE_CONTENT_ITEM_TITLE:
269 pItem = CreateTitleItemN(itemWidth, __pPm->GetSubject());
273 case GROUP_DATE_SELECTOR:
276 case FROM_DATE_SELECTOR_ITEM_START:
277 pItem = CreateStartTimeItemN(itemWidth, __pPm->GetStartTime(), __pPm->IsAllDayEvent());
279 case TO_DATE_SELECTOR_ITEM_END:
280 pItem = CreateEndTimeItemN(itemWidth, __pPm->GetEndTime(), __pPm->IsAllDayEvent());
282 // case DATE_SELECTOR_ITEM_TIME_ZONE:
283 // pItem = CreateTimeZoneTimeN(itemWidth, __pPm->GetTimezone());
285 case DATE_SELECTOR_ITEM_ALL_DAY_EVENT:
286 pItem = CreateAllDayEventItemN(itemWidth);
290 case GROUP_INFORMATION_CONTENT:
293 case INFORMATION_CONTENT_ITEM_DESCRIPTION:
294 pItem = CreateDescriptionItemN(itemWidth, __pPm->GetDescription());
296 case INFORMATION_CONTENT_ITEM_LOCATION:
297 pItem = CreateLocationItemN(itemWidth, __pPm->GetLocation());
301 case GROUP_ADDITIONAL_CONTENT:
304 case ADDITIONAL_CONTENT_ITEM_REMINDER:
305 pItem = CreateReminderItemN(itemWidth, H_ITEM_2LINE, __pPm->GetReminderString(itemIndex), itemIndex, true, true);
306 if (__pPm->GetCountReminder() <= 0)
308 __pButtonAddReminer->SetShowState(false);
309 __pButtonDeleteReminder->SetShowState(false);
311 else if (__pPm->GetCountReminder() >= 5)
313 __pButtonAddReminer->SetShowState(false);
316 case ADDITIONAL_CONTENT_ITEM_REMINDER2:
318 case ADDITIONAL_CONTENT_ITEM_REMINDER3:
320 case ADDITIONAL_CONTENT_ITEM_REMINDER4:
322 case ADDITIONAL_CONTENT_ITEM_REMINDER5:
323 if (itemIndex < __pPm->GetCountReminder())
325 pItem = CreateReminderItemN(itemWidth, H_ITEM_2LINE, __pPm->GetReminderString(itemIndex), itemIndex);
329 pItem = CreateReminderItemN(itemWidth, 0, __pPm->GetReminderString(itemIndex), itemIndex, false);
332 case ADDITIONAL_CONTENT_ITEM_REPEAT:
333 pItem = CreateRepeatItemN(itemWidth, __pPm->GetRecurrenceString());
338 if (itemIndex == SAVE_TO_ITEM_SAVE_TO)
340 const Bitmap* pIcon = __pPm->GetCalendarIconN();
341 pItem = CreateSaveToItemN(itemWidth, __pPm->GetCalendarName(), pIcon);
351 EventEditorForm::DeleteItem(int sectionIndex, int itemIndex, TableViewItem* pItem)
353 switch (sectionIndex)
355 case GROUP_TITLE_CONTENT:
358 case TITLE_CONTENT_ITEM_TITLE:
359 if (__pEditFieldTitle != null)
361 __pPm->SetSubject(__pEditFieldTitle->GetText());
362 __pEditFieldTitle = null;
367 case GROUP_DATE_SELECTOR:
370 case FROM_DATE_SELECTOR_ITEM_START:
371 if (__pPm->IsAllDayEvent() == true)
373 if (__pEditDateStartDate != null)
376 start.SetValue(__pEditDateStartDate->GetYear(), __pEditDateStartDate->GetMonth(), __pEditDateStartDate->GetDay());
377 __pPm->SetStartTime(start);
382 if (__pEditDateStartDate != null && __pEditTimeStartTime != null)
385 start.SetValue(__pEditDateStartDate->GetYear(), __pEditDateStartDate->GetMonth(), __pEditDateStartDate->GetDay(),
386 __pEditTimeStartTime->GetHour(), __pEditTimeStartTime->GetMinute());
387 __pPm->SetStartTime(start);
390 __pEditDateStartDate = null;
391 __pEditTimeStartTime = null;
393 case TO_DATE_SELECTOR_ITEM_END:
394 if (__pPm->IsAllDayEvent() == true)
396 if (__pEditDateEndDate != null)
399 end.SetValue(__pEditDateEndDate->GetYear(), __pEditDateEndDate->GetMonth(), __pEditDateEndDate->GetDay());
400 __pPm->SetEndTime(end);
405 if (__pEditDateEndDate != null && __pEditTimeEndTime != null)
408 end.SetValue(__pEditDateEndDate->GetYear(), __pEditDateEndDate->GetMonth(), __pEditDateEndDate->GetDay(),
409 __pEditTimeEndTime->GetHour(), __pEditTimeEndTime->GetMinute());
410 __pPm->SetEndTime(end);
413 __pEditDateEndDate = null;
414 __pEditTimeEndTime = null;
416 // case DATE_SELECTOR_ITEM_TIME_ZONE:
417 // __pLabelTimeZone = null;
419 case DATE_SELECTOR_ITEM_ALL_DAY_EVENT:
423 case GROUP_INFORMATION_CONTENT:
426 case INFORMATION_CONTENT_ITEM_LOCATION:
427 if (__pEditFieldLocation != null)
429 __pPm->SetLocation(__pEditFieldLocation->GetText());
430 __pEditFieldLocation = null;
433 case INFORMATION_CONTENT_ITEM_DESCRIPTION:
434 if (__pExpandableEditAreaNote != null)
436 __pPm->SetDescription(__pExpandableEditAreaNote->GetText());
437 __pExpandableEditAreaNote = null;
442 case GROUP_ADDITIONAL_CONTENT:
445 case ADDITIONAL_CONTENT_ITEM_REMINDER:
446 __pButtonAddReminer = null;
447 __pButtonDeleteReminder = null;
449 case ADDITIONAL_CONTENT_ITEM_REMINDER2:
451 case ADDITIONAL_CONTENT_ITEM_REMINDER3:
453 case ADDITIONAL_CONTENT_ITEM_REMINDER4:
455 case ADDITIONAL_CONTENT_ITEM_REMINDER5:
456 __pLabelReminder[itemIndex] = null;
457 __pItemReminder[itemIndex] = null;
459 case ADDITIONAL_CONTENT_ITEM_REPEAT:
460 __pLabelRepeat = null;
465 __pLabelSaveTo = null;
475 EventEditorForm::UpdateItem(int sectionIndex, int itemIndex, TableViewItem* pItem)
477 switch (sectionIndex)
479 case GROUP_DATE_SELECTOR:
480 if (itemIndex == FROM_DATE_SELECTOR_ITEM_START)
482 bool is24HourNotationEnabled = false;
483 SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourNotationEnabled);
484 __pEditTimeStartTime->Set24HourNotationEnabled(is24HourNotationEnabled);
485 __pEditTimeStartTime->Invalidate(true);
487 else if (itemIndex == TO_DATE_SELECTOR_ITEM_END)
489 bool is24HourNotationEnabled = false;
490 SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourNotationEnabled);
491 __pEditTimeEndTime->Set24HourNotationEnabled(is24HourNotationEnabled);
492 __pEditTimeEndTime->Invalidate(true);
495 case GROUP_INFORMATION_CONTENT:
496 if (itemIndex == INFORMATION_CONTENT_ITEM_DESCRIPTION)
498 if (__pExpandableEditAreaNote->GetHeight() >= H_ITEM)
500 __pExpandableEditAreaNote->SetPosition(0, 0);
501 pItem->SetSize(pItem->GetWidth(), __pExpandableEditAreaNote->GetHeight());
505 __pExpandableEditAreaNote->SetPosition(0, (H_ITEM - __pExpandableEditAreaNote->GetHeight()) / 2);
506 pItem->SetSize(pItem->GetWidth(), H_ITEM);
508 pItem->Invalidate(true);
511 case GROUP_ADDITIONAL_CONTENT:
514 case ADDITIONAL_CONTENT_ITEM_REMINDER:
515 __pLabelReminder[itemIndex]->SetText(__pPm->GetReminderString(itemIndex));
516 __pLabelReminder[itemIndex]->Invalidate(false);
517 if (__pPm->GetCountReminder() <= 0)
519 __pButtonAddReminer->SetShowState(false);
520 __pButtonDeleteReminder->SetShowState(false);
522 else if (__pPm->GetCountReminder() >= 5)
524 __pButtonAddReminer->SetShowState(false);
525 __pButtonDeleteReminder->SetShowState(true);
529 __pButtonAddReminer->SetShowState(true);
530 __pButtonDeleteReminder->SetShowState(true);
533 case ADDITIONAL_CONTENT_ITEM_REMINDER2:
535 case ADDITIONAL_CONTENT_ITEM_REMINDER3:
537 case ADDITIONAL_CONTENT_ITEM_REMINDER4:
539 case ADDITIONAL_CONTENT_ITEM_REMINDER5:
540 __pLabelReminder[itemIndex]->SetText(__pPm->GetReminderString(itemIndex));
541 __pLabelReminder[itemIndex]->Invalidate(false);
542 if (itemIndex < __pPm->GetCountReminder())
544 pItem->SetSize(pItem->GetWidth(), H_ITEM_2LINE);
545 pItem->SetShowState(true);
549 pItem->SetSize(pItem->GetWidth(), 0);
550 pItem->SetShowState(false);
553 // Reminder Max_Count is 5
554 if (__pPm->GetCountReminder() > 4)
556 __pButtonAddReminer->SetShowState(false);
560 __pButtonAddReminer->SetShowState(true);
563 case ADDITIONAL_CONTENT_ITEM_REPEAT:
564 __pLabelRepeat->SetText(__pPm->GetRecurrenceString());
565 pItem->SetEnabled(__pPm->IsAllEventEditing() == true);
566 pItem->Invalidate(true);
571 if (itemIndex == SAVE_TO_ITEM_SAVE_TO)
573 __pLabelSaveTo->SetText(__pPm->GetCalendarName());
574 pItem->SetEnabled(__pPm->IsAllEventEditing() == true);
575 pItem->Invalidate(true);
582 EventEditorForm::GetSectionHeader(int sectionIndex)
588 EventEditorForm::HasSectionHeader(int sectionIndex)
590 if (sectionIndex == 0)
598 EventEditorForm::GetSectionFooter(int sectionIndex)
604 EventEditorForm::HasSectionFooter(int sectionIndex)
610 EventEditorForm::GetDefaultItemHeight(void)
616 EventEditorForm::OnSectionTableViewItemStateChanged(SectionTableView& tableView, int sectionIndex, int itemIndex,
617 TableViewItem* pItem, TableViewItemStatus status)
620 LinkedList* pList = null;
621 switch (sectionIndex)
623 case GROUP_TITLE_CONTENT:
624 if (itemIndex == TITLE_CONTENT_ITEM_TITLE)
626 __pEditFieldTitle->SetFocus();
629 case GROUP_DATE_SELECTOR:
630 // if (itemIndex == DATE_SELECTOR_ITEM_TIME_ZONE)
632 // // Call Settings application.
635 if (itemIndex == DATE_SELECTOR_ITEM_ALL_DAY_EVENT)
637 if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
639 __pPm->SetAllDayEvent(true);
641 if (__pEditTimeStartTime != null)
643 __pEditTimeStartTime->SetShowState(false);
646 if (__pEditTimeEndTime != null)
648 __pEditTimeEndTime->SetShowState(false);
651 else if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED)
653 __pPm->SetAllDayEvent(false);
655 if (__pEditDateStartDate != null && __pEditTimeStartTime != null
656 && __pEditDateEndDate != null && __pEditTimeEndTime != null)
659 startTime.SetValue(__pEditDateStartDate->GetYear(), __pEditDateStartDate->GetMonth(), __pEditDateStartDate->GetDay(),
660 __pEditTimeStartTime->GetHour(), __pEditTimeStartTime->GetMinute());
662 endTime.SetValue(__pEditDateEndDate->GetYear(), __pEditDateEndDate->GetMonth(), __pEditDateEndDate->GetDay(),
663 __pEditTimeEndTime->GetHour(), __pEditTimeEndTime->GetMinute());
664 if (startTime >= endTime)
668 __pPm->SetStartEndTime(startTime, endTime);
670 __pEditTimeStartTime->SetTime(__pPm->GetStartTime());
671 __pEditTimeStartTime->SetShowState(true);
672 __pEditTimeStartTime->Invalidate(false);
674 __pEditTimeEndTime->SetTime(__pPm->GetEndTime());
675 __pEditTimeEndTime->SetShowState(true);
676 __pEditTimeEndTime->Invalidate(false);
681 case GROUP_INFORMATION_CONTENT:
684 case INFORMATION_CONTENT_ITEM_DESCRIPTION:
685 __pExpandableEditAreaNote->SetFocus();
687 case INFORMATION_CONTENT_ITEM_LOCATION:
688 __pEditFieldLocation->SetFocus();
692 case GROUP_ADDITIONAL_CONTENT:
696 case ADDITIONAL_CONTENT_ITEM_REMINDER:
698 case ADDITIONAL_CONTENT_ITEM_REMINDER2:
700 case ADDITIONAL_CONTENT_ITEM_REMINDER3:
702 case ADDITIONAL_CONTENT_ITEM_REMINDER4:
704 case ADDITIONAL_CONTENT_ITEM_REMINDER5:
705 if (__pPm->GetReminder(itemIndex) != null)
708 pList = new (std::nothrow) LinkedList();
709 pList->Add(new (std::nothrow) Reminder(*__pPm->GetReminder(itemIndex)));
710 pList->Add(new (std::nothrow) Integer(itemIndex));
712 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_REMINDER,
713 SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
717 if (itemIndex == ADDITIONAL_CONTENT_ITEM_REPEAT)
721 pList = new (std::nothrow) LinkedList();
722 pList->Add(new (std::nothrow) DateTime(__pPm->GetStartTime()));
723 if (__pPm->GetRecurrence() != null)
725 pList->Add(new (std::nothrow) Recurrence(*__pPm->GetRecurrence()));
728 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_REPEAT,
729 SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
733 if (itemIndex == SAVE_TO_ITEM_SAVE_TO)
735 __pCalendarSelectorPopup->RequestCalendar(CALENDAR_SELECTOR_POPUP_STYLE_EVENT, this);
742 EventEditorForm::OnSectionTableViewContextItemActivationStateChanged(SectionTableView& tableView, int sectionIndex, int itemIndex,
743 TableViewContextItem* pContextItem, bool activated)
748 EventEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
750 AppLogDebug("Enter.");
751 if (previousSceneId == IDSCN_REMINDER)
756 Integer* pIndex = dynamic_cast<Integer*>(pArgs->GetAt(0));
759 index = pIndex->ToInt();
761 Reminder* pReminder = dynamic_cast<Reminder*>(pArgs->GetAt(1));
762 if (pReminder != null)
764 if (index < __pPm->GetCountReminder())
766 __pPm->SetReminderAt(*pReminder, index);
770 __pPm->AddReminder(*pReminder);
772 __pTableView->RefreshItem(GROUP_ADDITIONAL_CONTENT, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
776 __pPm->RemoveReminderAt(index);
777 __pTableView->UpdateTableView();
781 else if (previousSceneId == IDSCN_REPEAT)
783 Recurrence* pRecurrence = null;
786 pRecurrence = dynamic_cast<Recurrence*>(pArgs->GetAt(0));
789 result r = E_FAILURE;
790 if (pRecurrence == null)
792 r = __pPm->SetRecurrence(null);
794 else if (pRecurrence->GetCounts() > 0)
796 r = __pPm->SetRecurrence(pRecurrence);
798 else if (pRecurrence->GetUntil() != null)
800 DateTime untilDateChecker = __pPm->GetStartTime();
801 switch (pRecurrence->GetFrequency())
804 untilDateChecker.AddDays(pRecurrence->GetInterval());
807 untilDateChecker.AddDays(7 * pRecurrence->GetInterval());
810 untilDateChecker.AddMonths(pRecurrence->GetInterval());
813 untilDateChecker.AddYears(pRecurrence->GetInterval());
817 if (*pRecurrence->GetUntil() >= untilDateChecker)
819 r = __pPm->SetRecurrence(pRecurrence);
825 __pTableView->RefreshItem(GROUP_ADDITIONAL_CONTENT, ADDITIONAL_CONTENT_ITEM_REPEAT, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
826 __pTableView->RefreshItem(GROUP_DATE_SELECTOR, FROM_DATE_SELECTOR_ITEM_START, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
827 __pTableView->RefreshItem(GROUP_DATE_SELECTOR, TO_DATE_SELECTOR_ITEM_END, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
832 msgBox.Construct(L"", ResourceManager::GetString(IDS_CLD_BODY_REPEAT_WARNING), MSGBOX_STYLE_OK);
834 msgBox.ShowAndWait(modalResult);
839 CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
840 if (pApp->GetOperationType() == OPERATION_TYPE_MAIN)
844 CalEventInstance* pEvent = dynamic_cast<CalEventInstance*>(pArgs->GetAt(0));
845 DateTime* pStartTime = null;
849 bool allEventEditing = true;
850 Boolean* pAllEventEditing = dynamic_cast<Boolean*>(pArgs->GetAt(1));
851 if (pAllEventEditing != null)
853 allEventEditing = pAllEventEditing->value;
855 __pPm->SetAllEventEditing(allEventEditing);
857 result r = __pPm->SetEventInstance(*pEvent);
860 AppLogDebug("[%s] Unable to get event.", GetErrorMessage(r));
861 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
862 AppLogDebug("Enter.");
866 SetStyle(EDIT_EVENT_FORM_STYLE_EDIT);
869 pStartTime = dynamic_cast<DateTime*>(pArgs->GetAt(0));
870 if (pStartTime != null)
872 pStartTime->AddHours(1);
873 pStartTime->AddMinutes(-pStartTime->GetMinute());
874 pStartTime->AddSeconds(-pStartTime->GetSecond());
875 DateTime end = *pStartTime;
877 __pPm->SetStartEndTime(*pStartTime, end);
879 SetStyle(EDIT_EVENT_FORM_STYLE_CREATE);
881 if (__pEditFieldTitle != null)
883 __pEditFieldTitle->SetFocus();
891 CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
892 if (pApp->GetOperationType() == OPERATION_TYPE_EDIT)
894 const String* pItemType = pApp->GetArgument(KEY_SOCIAL_ITEM_TYPE);
895 const String* pEventId = pApp->GetArgument(KEY_SOCIAL_ITEM_ID);
896 if (pItemType != null && pItemType->Equals(VALUE_CALENDAR_EVENT_TYPE, false) == true && pEventId != null)
898 RecordId eventId = INVALID_RECORD_ID;
899 Integer::Parse(*pEventId, eventId);
900 result r = __pPm->SetEventId(eventId);
903 SetStyle(EDIT_EVENT_FORM_STYLE_EDIT);
907 r = SendAppControlResult(APP_CTRL_RESULT_FAILED);
908 AppLogDebugIf(r != E_SUCCESS, "[%s] Unable to return result.", GetErrorMessage(r));
917 __pTableView->SetItemChecked(GROUP_DATE_SELECTOR, DATE_SELECTOR_ITEM_ALL_DAY_EVENT, __pPm->IsAllDayEvent());
921 pArgs->RemoveAll(true);
925 AppLogDebug("Exit.");
929 EventEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
931 AppLogDebug("Enter.");
932 AppLogDebug("Exit.");
936 EventEditorForm::OnActionPerformed(const Control& source, int actionId)
938 AppLogDebug("Enter.");
942 case IDA_EVENT_EDITOR_FORM_SAVE:
944 if (__pPm->Update() == E_SUCCESS)
946 CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
947 if (pApp != null && pApp->GetOperationType() != OPERATION_TYPE_MAIN)
949 result r = SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED);
950 AppLogDebugIf(r != E_SUCCESS, "[%s] Unable to return result.", GetErrorMessage(r));
953 AppLogDebug("Exit.");
957 CalEventInstance* pEventInstance = __pPm->GetEventInstance();
958 if (pEventInstance != null)
960 LinkedList* pList = new (std::nothrow) LinkedList();
961 pList->Add(new (std::nothrow) CalEventInstance(*pEventInstance));
962 result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pList);
965 pList->RemoveAll(true);
969 msgBox.Construct(L"", ResourceManager::GetString(IDS_COM_POP_SAVING_FAILED), MSGBOX_STYLE_OK);
971 msgBox.ShowAndWait(modalResult);
976 if (SceneManager::GetInstance()->IsSceneAlive(IDSCN_EVENT_DETAILS) == true)
978 SceneId backSceneId = IDSCN_MONTH;
979 IListT<SceneId>* pHistory = SceneManager::GetInstance()->GetSceneHistoryN();
980 if (pHistory != null)
983 if (pHistory->IndexOf(SceneId(IDSCN_EVENT_DETAILS), index) == E_SUCCESS)
985 pHistory->GetAt(index - 1, backSceneId);
988 pHistory->RemoveAll();
991 result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(backSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
994 SceneManager::GetInstance()->DestroyScene(IDSCN_EVENT_DETAILS);
999 msgBox.Construct(L"", ResourceManager::GetString(IDS_COM_POP_SAVING_FAILED), MSGBOX_STYLE_OK);
1001 msgBox.ShowAndWait(modalResult);
1006 result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1010 msgBox.Construct(L"", ResourceManager::GetString(IDS_COM_POP_SAVING_FAILED), MSGBOX_STYLE_OK);
1012 msgBox.ShowAndWait(modalResult);
1020 msgBox.Construct(L"", ResourceManager::GetString(IDS_COM_POP_SAVING_FAILED), MSGBOX_STYLE_OK);
1022 msgBox.ShowAndWait(modalResult);
1024 __pTableView->UpdateTableView();
1026 case IDA_EVENT_EDITOR_FORM_CANCEL:
1027 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1029 case IDA_EVENT_EDITOR_FORM_ADD_REMINDER:
1032 __pPm->AddReminder(reminder);
1034 __pTableView->RefreshItem(GROUP_ADDITIONAL_CONTENT, __pPm->GetCountReminder() - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1037 case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER:
1039 case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER2:
1041 case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER3:
1043 case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER4:
1045 case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER5:
1047 int index = actionId - IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER;
1048 int count = __pPm->GetCountReminder();
1049 __pPm->RemoveReminderAt(index);
1051 while (index < count)
1053 __pTableView->RefreshItem(GROUP_ADDITIONAL_CONTENT, index++, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1058 AppLogDebug("Exit.");
1062 EventEditorForm::OnDateChanged(const Control& source, int year, int month, int day)
1064 DateTime startTime = __pPm->GetStartTime();
1065 DateTime endTime = __pPm->GetEndTime();
1066 if (&source == __pEditDateStartDate)
1068 startTime.SetValue(year, month, day, startTime.GetHour(), startTime.GetMinute());
1069 endTime.AddSeconds(-endTime.GetSecond());
1070 if (__pPm->IsAllDayEvent() == true)
1072 if (startTime > endTime)
1074 endTime = startTime;
1079 if (startTime >= endTime)
1081 endTime = startTime;
1082 endTime.AddHours(1);
1086 else if (&source == __pEditDateEndDate)
1088 endTime.SetValue(year, month, day, endTime.GetHour(), endTime.GetMinute());
1089 if (__pPm->IsAllDayEvent() == true)
1091 if (startTime > endTime)
1093 startTime = endTime;
1098 if (startTime >= endTime)
1100 startTime = endTime;
1101 startTime.AddHours(-1);
1106 result r = __pPm->SetStartEndTime(startTime, endTime);
1108 __pEditTimeStartTime->SetTime(__pPm->GetStartTime());
1109 __pEditDateStartDate->SetDate(__pPm->GetStartTime());
1110 __pEditTimeEndTime->SetTime(__pPm->GetEndTime());
1111 __pEditDateEndDate->SetDate(__pPm->GetEndTime());
1112 __pEditTimeStartTime->Invalidate(true);
1113 __pEditDateStartDate->Invalidate(true);
1114 __pEditTimeEndTime->Invalidate(true);
1115 __pEditDateEndDate->Invalidate(true);
1120 msgBox.Construct(L"", ResourceManager::GetString(IDS_CLD_POP_INVALID_TIME), MSGBOX_STYLE_NONE, MESSAGE_BOX_TIME_OUT);
1122 msgBox.ShowAndWait(modalResult);
1127 EventEditorForm::OnDateChangeCanceled(const Control& source)
1132 EventEditorForm::OnKeypadWillOpen(Control& source)
1137 EventEditorForm::OnKeypadOpened(Control& source)
1143 EventEditorForm::OnKeypadClosed(Control& source)
1149 EventEditorForm::OnKeypadActionPerformed(Control& source, KeypadAction keypadAction)
1154 EventEditorForm::OnTimeChanged(const Control& source, int hour, int minute)
1156 DateTime startTime = __pPm->GetStartTime();
1157 DateTime endTime = __pPm->GetEndTime();
1158 if (&source == __pEditTimeStartTime)
1160 startTime.SetValue(startTime.GetYear(), startTime.GetMonth(), startTime.GetDay(), hour, minute);
1161 endTime.AddSeconds(-endTime.GetSecond());
1162 if (startTime >= endTime)
1164 endTime = startTime;
1165 endTime.AddHours(1);
1168 else if (&source == __pEditTimeEndTime)
1170 endTime.SetValue(endTime.GetYear(), endTime.GetMonth(), endTime.GetDay(), hour, minute);
1171 if (startTime >= endTime)
1173 startTime = endTime;
1174 startTime.AddHours(-1);
1178 result r = __pPm->SetStartEndTime(startTime, endTime);
1180 __pEditTimeStartTime->SetTime(__pPm->GetStartTime());
1181 __pEditDateStartDate->SetDate(__pPm->GetStartTime());
1182 __pEditTimeEndTime->SetTime(__pPm->GetEndTime());
1183 __pEditDateEndDate->SetDate(__pPm->GetEndTime());
1184 __pEditTimeStartTime->Invalidate(true);
1185 __pEditDateStartDate->Invalidate(true);
1186 __pEditTimeEndTime->Invalidate(true);
1187 __pEditDateEndDate->Invalidate(true);
1192 msgBox.Construct(L"", ResourceManager::GetString(IDS_CLD_POP_INVALID_TIME), MSGBOX_STYLE_NONE, MESSAGE_BOX_TIME_OUT);
1194 msgBox.ShowAndWait(modalResult);
1199 EventEditorForm::OnTimeChangeCanceled(const Control& source)
1204 EventEditorForm::CreateTitleItemN(int itemWidth, const String& title)
1206 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1208 EditField* pTitle = null;
1209 pItem->Construct(Dimension(itemWidth, H_ITEM));
1210 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1212 pTitle = new (std::nothrow) EditField();
1213 pTitle->Construct(Rectangle(0, 0, itemWidth, H_ITEM), EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY,
1214 false, EDITFIELD_LIMIT_LENGTH);
1216 pItem->AddControl(pTitle);
1217 pItem->SetIndividualSelectionEnabled(pTitle, true);
1219 pTitle->SetColor(EDIT_STATUS_NORMAL, Color(COLOR_BLANK_BACKGROUND));
1220 pTitle->SetColor(EDIT_STATUS_PRESSED, Color(COLOR_BLANK_BACKGROUND));
1221 pTitle->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(COLOR_BLANK_BACKGROUND));
1222 if (title.GetLength() > EDITFIELD_LIMIT_LENGTH)
1225 title.SubString(0, EDITFIELD_LIMIT_LENGTH, subString);
1226 pTitle->SetText(subString);
1230 pTitle->SetText(title);
1232 pTitle->SetGuideText(ResourceManager::GetString(IDS_CLD_BODY_TITLE));
1233 pTitle->AddActionEventListener(*this);
1234 pTitle->AddKeypadEventListener(*this);
1236 __pEditFieldTitle = pTitle;
1242 EventEditorForm::CreateStartTimeItemN(int itemWidth, const DateTime& start, bool isAllDayEvent)
1244 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1246 EditDate* pStartDate = null;
1247 EditTime* pStartTime = null;
1249 pItem->Construct(Dimension(itemWidth, H_ITEM));
1250 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1251 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1252 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);
1254 pStartDate = new (std::nothrow) EditDate();
1255 pStartDate->Construct(Point(0, Y_DATE_SELECTOR), ResourceManager::GetString(IDS_EVENT_EDITOR_FROM));
1257 pItem->AddControl(pStartDate);
1259 pStartDate->SetYearRange(Calendarbook::GetMinDateTime().GetYear() + 1, Calendarbook::GetMaxDateTime().GetYear() - 1);
1260 pStartDate->SetDate(start);
1261 pStartDate->AddDateChangeEventListener(*this);
1262 pItem->SetIndividualSelectionEnabled(pStartDate, true);
1264 __pEditDateStartDate = pStartDate;
1266 pStartTime = new (std::nothrow) EditTime();
1267 pStartTime->Construct(Point(X_DATE_SELECTOR, Y_DATE_SELECTOR), L" ");
1269 pItem->AddControl(pStartTime);
1271 pStartTime->SetTime(start);
1272 pStartTime->AddTimeChangeEventListener(*this);
1273 pItem->SetIndividualSelectionEnabled(pStartTime, true);
1275 bool is24HourNotationEnabled = false;
1276 SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourNotationEnabled);
1277 pStartTime->Set24HourNotationEnabled(is24HourNotationEnabled);
1279 __pEditTimeStartTime = pStartTime;
1281 if (isAllDayEvent == true)
1283 __pEditTimeStartTime->SetShowState(false);
1290 EventEditorForm::CreateEndTimeItemN(int itemWidth, const DateTime& end, bool isAllDayEvent)
1292 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1294 EditDate* pEndDate = null;
1295 EditTime* pEndTime = null;
1297 pItem->Construct(Dimension(itemWidth, H_ITEM));
1298 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1299 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1300 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);
1302 pEndDate = new (std::nothrow) EditDate();
1303 pEndDate->Construct(Point(0, Y_DATE_SELECTOR), ResourceManager::GetString(IDS_EVENT_EDITOR_TO));
1305 pItem->AddControl(pEndDate);
1307 pEndDate->SetYearRange(Calendarbook::GetMinDateTime().GetYear() + 1, Calendarbook::GetMaxDateTime().GetYear() - 1);
1308 pEndDate->SetDate(end);
1309 pEndDate->AddDateChangeEventListener(*this);
1310 pItem->SetIndividualSelectionEnabled(pEndDate, true);
1312 __pEditDateEndDate = pEndDate;
1314 pEndTime = new (std::nothrow) EditTime();
1315 pEndTime->Construct(Point(X_DATE_SELECTOR, Y_DATE_SELECTOR), L" ");
1317 pItem->AddControl(pEndTime);
1319 pEndTime->SetTime(end);
1320 pEndTime->AddTimeChangeEventListener(*this);
1321 pItem->SetIndividualSelectionEnabled(pEndTime, true);
1323 bool is24HourNotationEnabled = false;
1324 SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourNotationEnabled);
1325 pEndTime->Set24HourNotationEnabled(is24HourNotationEnabled);
1327 __pEditTimeEndTime = pEndTime;
1329 if (isAllDayEvent == true)
1331 __pEditTimeEndTime->SetShowState(false);
1338 //EventEditorForm::CreateTimeZoneTimeN(int itemWidth, const String& timeZone)
1340 // TableViewItem* pItem = new (std::nothrow) TableViewItem();
1342 // Label* pLabel = null;
1343 // Label* pContentLabel = null;
1345 // pItem->Construct(Dimension(itemWidth, H_ITEM_2LINE));
1346 // pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1348 // pLabel = new (std::nothrow) Label();
1349 // pLabel->Construct(Rectangle(0, Y_ITEM_CONTENT01, itemWidth, H_ITEM_CONTENT01),
1350 // ResourceManager::GetString(IDS_EVENT_EDITOR_TIME_ZONE));
1352 // pItem->AddControl(pLabel);
1354 // pLabel->SetTextColor(Color(COLOR_DETAIL02));
1355 // pLabel->SetTextConfig(FONT_SIZE_DETAIL02, LABEL_TEXT_STYLE_NORMAL);
1356 // pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1358 // pContentLabel = new (std::nothrow) Label();
1359 // pContentLabel->Construct(Rectangle(0, Y_ITEM_CONTENT02, itemWidth, H_ITEM_CONTENT02), timeZone);
1361 // pItem->AddControl(pContentLabel);
1363 // pContentLabel->SetTextColor(Color(COLOR_ADDITIONAL_CONTENT));
1364 // pContentLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1365 // pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1367 // __pLabelTimeZone = pContentLabel;
1373 EventEditorForm::CreateAllDayEventItemN(int itemWidth)
1375 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1377 Label* pLabel = null;
1379 pItem->Construct(Dimension(itemWidth, H_ITEM), TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING);
1380 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1382 pLabel = new (std::nothrow) Label();
1383 pLabel->Construct(Rectangle(0, 0, itemWidth, H_ITEM), ResourceManager::GetString(IDS_EVENT_EDITOR_ALL_DAY_EVENT));
1384 pLabel->SetTextColor(Color(COLOR_DETAIL03));
1385 pLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1386 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1388 pItem->AddControl(pLabel);
1394 EventEditorForm::CreateDescriptionItemN(int itemWidth, const String& description)
1396 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1397 pItem->Construct(Dimension(itemWidth, H_ITEM));
1398 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1400 __pExpandableEditAreaNote = new (std::nothrow) ExpandableEditArea();
1401 __pExpandableEditAreaNote->Construct(Rectangle(0, Y_DESCRIPTION, itemWidth, H_DESCRIPTION),
1402 EXPANDABLE_EDIT_AREA_STYLE_NORMAL, EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE, EXPANDABLE_EDIT_MAX_LINE);
1403 __pExpandableEditAreaNote->SetBackgroundBitmap(EDIT_STATUS_NORMAL, *ResourceManager::GetBlankBitmap());
1404 __pExpandableEditAreaNote->SetBackgroundBitmap(EDIT_STATUS_DISABLED, *ResourceManager::GetBlankBitmap());
1405 __pExpandableEditAreaNote->SetBackgroundBitmap(EDIT_STATUS_HIGHLIGHTED, *ResourceManager::GetBlankBitmap());
1406 __pExpandableEditAreaNote->SetBackgroundBitmap(EDIT_STATUS_PRESSED, *ResourceManager::GetBlankBitmap());
1407 __pExpandableEditAreaNote->SetColor(EDIT_STATUS_NORMAL, Color(COLOR_BLANK_BACKGROUND));
1408 __pExpandableEditAreaNote->SetColor(EDIT_STATUS_PRESSED, Color(COLOR_BLANK_BACKGROUND));
1409 __pExpandableEditAreaNote->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(COLOR_BLANK_BACKGROUND));
1410 __pExpandableEditAreaNote->AddExpandableEditAreaEventListener(*this);
1411 __pExpandableEditAreaNote->AddKeypadEventListener(*this);
1412 __pExpandableEditAreaNote->SetText(description);
1413 __pExpandableEditAreaNote->SetGuideText(ResourceManager::GetString(IDS_CLD_BODY_CREATE_DESCRIPTION));
1414 pItem->AddControl(__pExpandableEditAreaNote);
1415 pItem->SetIndividualSelectionEnabled(__pExpandableEditAreaNote, true);
1417 // Adjust text position
1418 if (__pExpandableEditAreaNote->GetHeight() >= H_ITEM && __pExpandableEditAreaNote->GetY() != 0)
1420 __pExpandableEditAreaNote->SetPosition(0, 0);
1427 EventEditorForm::CreateLocationItemN(int itemWidth, const String& location)
1429 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1430 pItem->Construct(Dimension(itemWidth, H_ITEM));
1431 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1433 EditField* pLocation = new (std::nothrow) EditField();
1434 pLocation->Construct(Rectangle(0, 0, itemWidth, H_ITEM), EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY,
1435 false, EDITFIELD_LIMIT_LENGTH);
1437 pItem->AddControl(pLocation);
1438 pItem->SetIndividualSelectionEnabled(pLocation, true);
1440 pLocation->SetColor(EDIT_STATUS_NORMAL, Color(COLOR_BLANK_BACKGROUND));
1441 pLocation->SetColor(EDIT_STATUS_PRESSED, Color(COLOR_BLANK_BACKGROUND));
1442 pLocation->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(COLOR_BLANK_BACKGROUND));
1443 if (location.GetLength() > EDITFIELD_LIMIT_LENGTH)
1446 location.SubString(0, EDITFIELD_LIMIT_LENGTH, subString);
1447 pLocation->SetText(subString);
1451 pLocation->SetText(location);
1453 pLocation->SetGuideText(ResourceManager::GetString(IDS_CLD_BODY_LOCATION));
1454 pLocation->AddActionEventListener(*this);
1455 pLocation->AddKeypadEventListener(*this);
1457 __pEditFieldLocation = pLocation;
1463 EventEditorForm::CreateReminderItemN(int itemWidth, int itemHeight, const String& reminder, int index, bool showItem, bool hasAddButton)
1465 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1466 pItem->Construct(Dimension(itemWidth, itemHeight));
1467 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1469 Label* pLabel = new (std::nothrow) Label();
1470 pLabel->Construct(Rectangle(0, Y_ITEM_CONTENT01, itemWidth - W_REMINDER_DELETE_BUTTON_MARGIN, H_ITEM_CONTENT01),
1471 ResourceManager::GetString(IDS_CLD_BODY_REMINDER));
1473 pItem->AddControl(pLabel);
1475 pLabel->SetTextColor(Color(COLOR_DETAIL02));
1476 pLabel->SetTextConfig(FONT_SIZE_DETAIL02, LABEL_TEXT_STYLE_NORMAL);
1477 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1479 Label* pContentLabel = new (std::nothrow) Label();
1480 pContentLabel->Construct(Rectangle(0, Y_ITEM_CONTENT02, itemWidth - W_REMINDER_DELETE_BUTTON_MARGIN, H_ITEM_CONTENT02), reminder);
1482 pItem->AddControl(pContentLabel);
1484 pContentLabel->SetTextColor(Color(COLOR_ADDITIONAL_CONTENT));
1485 pContentLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1486 pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1488 // Add delete button
1489 Button* pButtonDeleteReminder = new (std::nothrow) Button();
1490 pButtonDeleteReminder->Construct(Rectangle(itemWidth - W_REMINDER_DELETE_BUTTON_MARGIN,
1491 (H_ITEM_2LINE - H_REMINDER_DELETE_BUTTON) / 2, W_REMINDER_DELETE_BUTTON, H_REMINDER_DELETE_BUTTON), L"");
1493 pItem->AddControl(pButtonDeleteReminder);
1494 pItem->SetIndividualSelectionEnabled(pButtonDeleteReminder, true);
1495 pButtonDeleteReminder->SetActionId(IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER + index);
1496 pButtonDeleteReminder->AddActionEventListener(*this);
1497 if (index == ADDITIONAL_CONTENT_ITEM_REMINDER)
1499 __pButtonDeleteReminder = pButtonDeleteReminder;
1502 Bitmap* pBitmapBgDelete = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON_DELETE);
1503 if (pBitmapBgDelete != null)
1505 pButtonDeleteReminder->SetNormalBackgroundBitmap(*pBitmapBgDelete);
1506 delete pBitmapBgDelete;
1508 Bitmap* pBitmapBgDeletePressed = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON_DELETE_PRESS);
1509 if (pBitmapBgDeletePressed != null)
1511 pButtonDeleteReminder->SetPressedBackgroundBitmap(*pBitmapBgDeletePressed);
1512 pButtonDeleteReminder->SetHighlightedBackgroundBitmap(*pBitmapBgDeletePressed);
1513 delete pBitmapBgDeletePressed;
1515 Bitmap* pBitmapMinus = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS);
1516 if (pBitmapMinus != null)
1518 pButtonDeleteReminder->SetNormalBitmap(Point(0, 0), *pBitmapMinus);
1519 delete pBitmapMinus;
1521 Bitmap* pBitmapMinusPressed = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS_PRESS);
1522 if (pBitmapMinusPressed != null)
1524 pButtonDeleteReminder->SetPressedBitmap(Point(0, 0), *pBitmapMinusPressed);
1525 delete pBitmapMinusPressed;
1529 if (hasAddButton == true)
1531 Button* pButtonAddReminder = new (std::nothrow) Button();
1532 pButtonAddReminder->Construct(Rectangle(itemWidth - W_REMINDER_ADD_BUTTON_MARGIN,
1533 (H_ITEM_2LINE - H_REMINDER_ADD_BUTTON) / 2, W_REMINDER_ADD_BUTTON, H_REMINDER_ADD_BUTTON), L"");
1535 pItem->AddControl(pButtonAddReminder);
1536 pItem->SetIndividualSelectionEnabled(pButtonAddReminder, true);
1537 pButtonAddReminder->SetActionId(IDA_EVENT_EDITOR_FORM_ADD_REMINDER);
1538 pButtonAddReminder->AddActionEventListener(*this);
1539 __pButtonAddReminer = pButtonAddReminder;
1541 Bitmap* pBitmapBgButton = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON);
1542 if (pBitmapBgButton != null)
1544 pButtonAddReminder->SetNormalBackgroundBitmap(*pBitmapBgButton);
1545 delete pBitmapBgButton;
1547 Bitmap* pBitmapBgButtonPressed = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON_PRESS);
1548 if (pBitmapBgButtonPressed != null)
1550 pButtonAddReminder->SetPressedBackgroundBitmap(*pBitmapBgButtonPressed);
1551 pButtonAddReminder->SetHighlightedBackgroundBitmap(*pBitmapBgButtonPressed);
1552 delete pBitmapBgButtonPressed;
1554 Bitmap* pBitmapPlus = ResourceManager::GetBitmapN(IDB_BUTTON_PLUS);
1555 if (pBitmapPlus != null)
1557 pButtonAddReminder->SetNormalBitmap(Point(0, 0), *pBitmapPlus);
1560 Bitmap* pBitmapPlusPressed = ResourceManager::GetBitmapN(IDB_BUTTON_PLUS_PRESS);
1561 if (pBitmapPlusPressed != null)
1563 pButtonAddReminder->SetPressedBitmap(Point(0, 0), *pBitmapPlusPressed);
1564 delete pBitmapPlusPressed;
1568 pItem->SetShowState(showItem);
1569 __pLabelReminder[index] = pContentLabel;
1570 __pItemReminder[index] = pItem;
1576 EventEditorForm::CreateRepeatItemN(int itemWidth, const String& repeat)
1578 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1580 Label* pLabel = null;
1581 Label* pContentLabel = null;
1583 pItem->Construct(Dimension(itemWidth, H_ITEM_2LINE));
1584 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1586 pLabel = new (std::nothrow) Label();
1587 pLabel->Construct(Rectangle(0, Y_ITEM_CONTENT01, itemWidth, H_ITEM_CONTENT01),
1588 ResourceManager::GetString(IDS_CLD_BODY_REPEAT));
1590 pItem->AddControl(pLabel);
1592 pLabel->SetTextColor(Color(COLOR_DETAIL02));
1593 pLabel->SetTextConfig(FONT_SIZE_DETAIL02, LABEL_TEXT_STYLE_NORMAL);
1594 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1596 pContentLabel = new (std::nothrow) Label();
1597 pContentLabel->Construct(Rectangle(0, Y_ITEM_CONTENT02, itemWidth, H_ITEM_CONTENT02), repeat);
1599 pItem->AddControl(pContentLabel);
1601 pContentLabel->SetTextColor(Color(COLOR_ADDITIONAL_CONTENT));
1602 pContentLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1603 pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1605 __pLabelRepeat = pContentLabel;
1607 if (__pPm->IsAllEventEditing() == false)
1609 pItem->SetEnabled(false);
1616 EventEditorForm::CreateSaveToItemN(int itemWidth, const String& calendarName, const Bitmap* pCalendarIcon)
1618 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1620 Label* pLabel = null;
1621 Label* pContentLabel = null;
1623 pItem->Construct(Dimension(itemWidth, H_ITEM_2LINE));
1624 pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1626 pLabel = new (std::nothrow) Label();
1627 pLabel->Construct(Rectangle(0, Y_ITEM_CONTENT01, itemWidth, H_ITEM_CONTENT01),
1628 ResourceManager::GetString(IDS_ST_BODY_SAVE_TO));
1630 pItem->AddControl(pLabel);
1632 pLabel->SetTextColor(Color(COLOR_DETAIL02));
1633 pLabel->SetTextConfig(FONT_SIZE_DETAIL02, LABEL_TEXT_STYLE_NORMAL);
1634 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1636 pContentLabel = new (std::nothrow) Label();
1637 pContentLabel->Construct(Rectangle(0, Y_ITEM_CONTENT02, itemWidth, H_ITEM_CONTENT02), calendarName);
1639 pItem->AddControl(pContentLabel);
1641 pContentLabel->SetTextColor(Color(COLOR_ADDITIONAL_CONTENT));
1642 pContentLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1643 pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1645 __pLabelSaveTo = pContentLabel;
1647 if (__pPm->IsAllEventEditing() == false)
1649 pItem->SetEnabled(false);
1656 EventEditorForm::SetStyle(EditEventFormStyle style)
1658 Header* pHeader = GetHeader();
1659 if (style == EDIT_EVENT_FORM_STYLE_CREATE)
1661 pHeader->SetTitleText(ResourceManager::GetString(IDS_CLD_HEADER_CREATE_EVENT));
1665 pHeader->SetTitleText(ResourceManager::GetString(IDS_CLD_HEADER_EDIT_EVENT));
1667 pHeader->Invalidate(false);
1669 if (__pTableView != null)
1671 __pEditFieldTitle = null;
1672 __pEditFieldLocation = null;
1673 __pEditDateStartDate = null;
1674 __pEditTimeStartTime = null;
1675 __pEditDateEndDate = null;
1676 __pEditTimeEndTime = null;
1677 __pExpandableEditAreaNote = null;
1678 __pTableView->UpdateTableView();
1683 if (__pPm->GetSubject().GetLength() > EDITFIELD_LIMIT_LENGTH
1684 || __pPm->GetLocation().GetLength() > EDITFIELD_LIMIT_LENGTH)
1687 msgBox.Construct(L"", ResourceManager::GetString(IDS_IMGE_POP_TEXT_TOO_LONG),
1688 MSGBOX_STYLE_NONE, MESSAGE_BOX_TIME_OUT);
1691 msgBox.ShowAndWait(modalResult);
1698 EventEditorForm::SendAppControlResult(AppCtrlResult appControlResult)
1700 CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
1701 TryReturn(pApp != null, E_FAILURE, "[E_FAILURE] Unable to get app instance.");
1703 result r = AppControlProviderManager::GetInstance()->SendAppControlResult(pApp->GetRequestId(), appControlResult, null);
1704 AppLogDebugIf(r != E_SUCCESS, "[%s] Unable to return result.", GetErrorMessage(r));
1710 EventEditorForm::UpdatePm(void)
1712 if (__pEditFieldTitle != null)
1714 __pPm->SetSubject(__pEditFieldTitle->GetText());
1717 DateTime startTime = __pPm->GetStartTime();
1718 DateTime endTime = __pPm->GetEndTime();
1719 if (__pEditDateStartDate != null)
1721 startTime.SetValue(__pEditDateStartDate->GetYear(), __pEditDateStartDate->GetMonth(), __pEditDateStartDate->GetDay(),
1722 startTime.GetHour(), startTime.GetMinute());
1724 if (__pEditTimeStartTime != null)
1726 startTime.SetValue(startTime.GetYear(), startTime.GetMonth(), startTime.GetDay(),
1727 __pEditTimeStartTime->GetHour(), __pEditTimeStartTime->GetMinute());
1729 if (__pEditDateEndDate != null)
1731 endTime.SetValue(__pEditDateEndDate->GetYear(), __pEditDateEndDate->GetMonth(), __pEditDateEndDate->GetDay(),
1732 endTime.GetHour(), endTime.GetMinute());
1734 if (__pEditTimeEndTime != null)
1736 endTime.SetValue(endTime.GetYear(), endTime.GetMonth(), endTime.GetDay(),
1737 __pEditTimeEndTime->GetHour(), __pEditTimeEndTime->GetMinute());
1739 __pPm->SetStartEndTime(startTime, endTime);
1741 if (__pExpandableEditAreaNote != null)
1743 __pPm->SetDescription(__pExpandableEditAreaNote->GetText());
1746 if (__pEditFieldLocation != null)
1748 __pPm->SetLocation(__pEditFieldLocation->GetText());