Updates license
[apps/osp/Calendar.git] / src / ClEventEditorForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file        ClEventEditorForm.cpp
19  * @brief       This is the implementation file for the EventEditorForm class.
20  */
21
22 #include <FBase.h>
23 #include <FSystem.h>
24 #include "ClCalendarApp.h"
25 #include "ClCalendarSelectorPopup.h"
26 #include "ClEventEditorForm.h"
27 #include "ClEventPresentationModel.h"
28 #include "ClResourceManager.h"
29 #include "ClTypes.h"
30
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;
41
42 enum
43 {
44         GROUP_TITLE_CONTENT = 0,
45         GROUP_DATE_SELECTOR,
46         GROUP_INFORMATION_CONTENT,
47         GROUP_ADDITIONAL_CONTENT,
48         GROUP_SAVE_TO,
49         GROUP_COUNT,
50
51         TITLE_CONTENT_ITEM_TITLE = 0,
52         TITLE_CONTENT_ITEM_COUNT,
53
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,
59
60         INFORMATION_CONTENT_ITEM_DESCRIPTION = 0,
61         INFORMATION_CONTENT_ITEM_LOCATION,
62         INFORMATION_CONTENT_ITEM_COUNT,
63
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,
71
72         SAVE_TO_ITEM_SAVE_TO = 0,
73         SAVE_TO_ITEM_COUNT
74 };
75
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;
84
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;
108
109 static const int EXPANDABLE_EDIT_MAX_LINE = 10;
110 static const int EDITFIELD_LIMIT_LENGTH = 500;
111
112 EventEditorForm::EventEditorForm(void)
113         : __pPm(null)
114         , __style(EDIT_EVENT_FORM_STYLE_CREATE)
115         , __pTableView(null)
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)
130 {
131         memset(__pLabelReminder, 0, sizeof(Label*) * MAX_COUNT_OF_REMINDER);
132         memset(__pItemReminder, 0, sizeof(TableViewItem*) * MAX_COUNT_OF_REMINDER);
133 }
134
135 EventEditorForm::~EventEditorForm(void)
136 {
137 }
138
139 result
140 EventEditorForm::Initialize(void)
141 {
142         return Construct(L"IDL_EVENT_EDITOR_FORM");
143 }
144
145 result
146 EventEditorForm::OnInitializing(void)
147 {
148         __pPm = new (std::nothrow) EventPresentationModel();
149         __pPm->Construct();
150
151         Footer* pFooter = GetFooter();
152         pFooter->AddActionEventListener(*this);
153
154         SetFormBackEventListener(this);
155
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);
161
162         __pCalendarSelectorPopup = new (std::nothrow) CalendarSelectorPopup();
163         __pCalendarSelectorPopup->Initialize();
164
165         return E_SUCCESS;
166 }
167
168 result
169 EventEditorForm::OnTerminating(void)
170 {
171         delete __pPm;
172         if (__pCalendarSelectorPopup != null)
173         {
174                 __pCalendarSelectorPopup->Destroy();
175         }
176         return E_SUCCESS;
177 }
178
179 void
180 EventEditorForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
181 {
182         switch (requestId)
183         {
184         case IDA_CALENDAR_SELECTOR_POPUP_DONE:
185                 if (pArgs != null)
186                 {
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);
189                 }
190                 break;
191         }
192
193         if (pArgs != null)
194         {
195                 pArgs->RemoveAll(true);
196                 delete pArgs;
197         }
198 }
199
200 void
201 EventEditorForm::OnFormBackRequested(Form& source)
202 {
203         SetFocus();
204
205         CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
206         if (pApp != null)
207         {
208                 if (pApp->GetOperationType() != OPERATION_TYPE_MAIN)
209                 {
210                         result r = SendAppControlResult(APP_CTRL_RESULT_CANCELED);
211                         AppLogDebugIf(r != E_SUCCESS, "[%s] Unable to return result.", GetErrorMessage(r));
212
213                         pApp->Terminate();
214                         return;
215                 }
216         }
217
218         SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
219 }
220
221 void
222 EventEditorForm::OnExpandableEditAreaLineAdded(ExpandableEditArea& source, int newLineCount)
223 {
224         __pTableView->RefreshItem(GROUP_INFORMATION_CONTENT, INFORMATION_CONTENT_ITEM_DESCRIPTION, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
225 }
226
227 void
228 EventEditorForm::OnExpandableEditAreaLineRemoved(ExpandableEditArea& source, int newLineCount)
229 {
230         __pTableView->RefreshItem(GROUP_INFORMATION_CONTENT, INFORMATION_CONTENT_ITEM_DESCRIPTION, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
231 }
232
233 int
234 EventEditorForm::GetSectionCount(void)
235 {
236         return GROUP_COUNT;
237 }
238
239 int
240 EventEditorForm::GetItemCount(int sectionIndex)
241 {
242         switch (sectionIndex)
243         {
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;
252         case GROUP_SAVE_TO:
253                 return SAVE_TO_ITEM_COUNT;
254         }
255
256         return 0;
257 }
258
259 TableViewItem*
260 EventEditorForm::CreateItem(int sectionIndex, int itemIndex, int itemWidth)
261 {
262         TableViewItem* pItem = null;
263         switch (sectionIndex)
264         {
265         case GROUP_TITLE_CONTENT:
266                 switch (itemIndex)
267                 {
268                 case TITLE_CONTENT_ITEM_TITLE:
269                         pItem = CreateTitleItemN(itemWidth, __pPm->GetSubject());
270                         break;
271                 }
272                 break;
273         case GROUP_DATE_SELECTOR:
274                 switch (itemIndex)
275                 {
276                 case FROM_DATE_SELECTOR_ITEM_START:
277                         pItem = CreateStartTimeItemN(itemWidth, __pPm->GetStartTime(), __pPm->IsAllDayEvent());
278                         break;
279                 case TO_DATE_SELECTOR_ITEM_END:
280                         pItem = CreateEndTimeItemN(itemWidth, __pPm->GetEndTime(), __pPm->IsAllDayEvent());
281                         break;
282 //              case DATE_SELECTOR_ITEM_TIME_ZONE:
283 //                      pItem = CreateTimeZoneTimeN(itemWidth, __pPm->GetTimezone());
284 //                      break;
285                 case DATE_SELECTOR_ITEM_ALL_DAY_EVENT:
286                         pItem = CreateAllDayEventItemN(itemWidth);
287                         break;
288                 }
289                 break;
290         case GROUP_INFORMATION_CONTENT:
291                 switch (itemIndex)
292                 {
293                 case INFORMATION_CONTENT_ITEM_DESCRIPTION:
294                         pItem = CreateDescriptionItemN(itemWidth, __pPm->GetDescription());
295                         break;
296                 case INFORMATION_CONTENT_ITEM_LOCATION:
297                         pItem = CreateLocationItemN(itemWidth, __pPm->GetLocation());
298                         break;
299                 }
300                 break;
301         case GROUP_ADDITIONAL_CONTENT:
302                 switch (itemIndex)
303                 {
304                 case ADDITIONAL_CONTENT_ITEM_REMINDER:
305                         pItem = CreateReminderItemN(itemWidth, H_ITEM_2LINE, __pPm->GetReminderString(itemIndex), itemIndex, true, true);
306                         if (__pPm->GetCountReminder() <= 0)
307                         {
308                                 __pButtonAddReminer->SetShowState(false);
309                                 __pButtonDeleteReminder->SetShowState(false);
310                         }
311                         else if (__pPm->GetCountReminder() >= 5)
312                         {
313                                 __pButtonAddReminer->SetShowState(false);
314                         }
315                         break;
316                 case ADDITIONAL_CONTENT_ITEM_REMINDER2:
317                         // fall through
318                 case ADDITIONAL_CONTENT_ITEM_REMINDER3:
319                         // fall through
320                 case ADDITIONAL_CONTENT_ITEM_REMINDER4:
321                         // fall through
322                 case ADDITIONAL_CONTENT_ITEM_REMINDER5:
323                         if (itemIndex < __pPm->GetCountReminder())
324                         {
325                                 pItem = CreateReminderItemN(itemWidth, H_ITEM_2LINE, __pPm->GetReminderString(itemIndex), itemIndex);
326                         }
327                         else
328                         {
329                                 pItem = CreateReminderItemN(itemWidth, 0, __pPm->GetReminderString(itemIndex), itemIndex, false);
330                         }
331                         break;
332                 case ADDITIONAL_CONTENT_ITEM_REPEAT:
333                         pItem = CreateRepeatItemN(itemWidth, __pPm->GetRecurrenceString());
334                         break;
335                 }
336                 break;
337         case GROUP_SAVE_TO:
338                 if (itemIndex == SAVE_TO_ITEM_SAVE_TO)
339                 {
340                         const Bitmap* pIcon = __pPm->GetCalendarIconN();
341                         pItem = CreateSaveToItemN(itemWidth, __pPm->GetCalendarName(), pIcon);
342                         delete pIcon;
343                 }
344                 break;
345         }
346
347         return pItem;
348 }
349
350 bool
351 EventEditorForm::DeleteItem(int sectionIndex, int itemIndex, TableViewItem* pItem)
352 {
353         switch (sectionIndex)
354         {
355         case GROUP_TITLE_CONTENT:
356                 switch (itemIndex)
357                 {
358                 case TITLE_CONTENT_ITEM_TITLE:
359                         if (__pEditFieldTitle != null)
360                         {
361                                 __pPm->SetSubject(__pEditFieldTitle->GetText());
362                                 __pEditFieldTitle = null;
363                         }
364                         break;
365                 }
366                 break;
367         case GROUP_DATE_SELECTOR:
368                 switch (itemIndex)
369                 {
370                 case FROM_DATE_SELECTOR_ITEM_START:
371                         if (__pPm->IsAllDayEvent() == true)
372                         {
373                                 if (__pEditDateStartDate != null)
374                                 {
375                                         DateTime start;
376                                         start.SetValue(__pEditDateStartDate->GetYear(), __pEditDateStartDate->GetMonth(), __pEditDateStartDate->GetDay());
377                                         __pPm->SetStartTime(start);
378                                 }
379                         }
380                         else
381                         {
382                                 if (__pEditDateStartDate != null && __pEditTimeStartTime != null)
383                                 {
384                                         DateTime start;
385                                         start.SetValue(__pEditDateStartDate->GetYear(), __pEditDateStartDate->GetMonth(), __pEditDateStartDate->GetDay(),
386                                                                    __pEditTimeStartTime->GetHour(), __pEditTimeStartTime->GetMinute());
387                                         __pPm->SetStartTime(start);
388                                 }
389                         }
390                         __pEditDateStartDate = null;
391                         __pEditTimeStartTime = null;
392                         break;
393                 case TO_DATE_SELECTOR_ITEM_END:
394                         if (__pPm->IsAllDayEvent() == true)
395                         {
396                                 if (__pEditDateEndDate != null)
397                                 {
398                                         DateTime end;
399                                         end.SetValue(__pEditDateEndDate->GetYear(), __pEditDateEndDate->GetMonth(), __pEditDateEndDate->GetDay());
400                                         __pPm->SetEndTime(end);
401                                 }
402                         }
403                         else
404                         {
405                                 if (__pEditDateEndDate != null && __pEditTimeEndTime != null)
406                                 {
407                                         DateTime end;
408                                         end.SetValue(__pEditDateEndDate->GetYear(), __pEditDateEndDate->GetMonth(), __pEditDateEndDate->GetDay(),
409                                                                  __pEditTimeEndTime->GetHour(), __pEditTimeEndTime->GetMinute());
410                                         __pPm->SetEndTime(end);
411                                 }
412                         }
413                         __pEditDateEndDate = null;
414                         __pEditTimeEndTime = null;
415                         break;
416 //              case DATE_SELECTOR_ITEM_TIME_ZONE:
417 //                      __pLabelTimeZone = null;
418 //                      break;
419                 case DATE_SELECTOR_ITEM_ALL_DAY_EVENT:
420                         break;
421                 }
422                 break;
423         case GROUP_INFORMATION_CONTENT:
424                 switch (itemIndex)
425                 {
426                 case INFORMATION_CONTENT_ITEM_LOCATION:
427                         if (__pEditFieldLocation != null)
428                         {
429                                 __pPm->SetLocation(__pEditFieldLocation->GetText());
430                                 __pEditFieldLocation = null;
431                         }
432                         break;
433                 case INFORMATION_CONTENT_ITEM_DESCRIPTION:
434                         if (__pExpandableEditAreaNote != null)
435                         {
436                                 __pPm->SetDescription(__pExpandableEditAreaNote->GetText());
437                                 __pExpandableEditAreaNote = null;
438                         }
439                         break;
440                 }
441                 break;
442         case GROUP_ADDITIONAL_CONTENT:
443                 switch (itemIndex)
444                 {
445                 case ADDITIONAL_CONTENT_ITEM_REMINDER:
446                         __pButtonAddReminer = null;
447                         __pButtonDeleteReminder = null;
448                         // fall through
449                 case ADDITIONAL_CONTENT_ITEM_REMINDER2:
450                         // fall through
451                 case ADDITIONAL_CONTENT_ITEM_REMINDER3:
452                         // fall through
453                 case ADDITIONAL_CONTENT_ITEM_REMINDER4:
454                         // fall through
455                 case ADDITIONAL_CONTENT_ITEM_REMINDER5:
456                         __pLabelReminder[itemIndex] = null;
457                         __pItemReminder[itemIndex] = null;
458                         break;
459                 case ADDITIONAL_CONTENT_ITEM_REPEAT:
460                         __pLabelRepeat = null;
461                         break;
462                 }
463                 break;
464         case GROUP_SAVE_TO:
465                 __pLabelSaveTo = null;
466                 break;
467         default:
468                 break;
469         }
470         delete pItem;
471         return true;
472 }
473
474 void
475 EventEditorForm::UpdateItem(int sectionIndex, int itemIndex, TableViewItem* pItem)
476 {
477         switch (sectionIndex)
478         {
479         case GROUP_DATE_SELECTOR:
480                 if (itemIndex == FROM_DATE_SELECTOR_ITEM_START)
481                 {
482                         bool is24HourNotationEnabled = false;
483                         SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourNotationEnabled);
484                         __pEditTimeStartTime->Set24HourNotationEnabled(is24HourNotationEnabled);
485                         __pEditTimeStartTime->Invalidate(true);
486                 }
487                 else if (itemIndex == TO_DATE_SELECTOR_ITEM_END)
488                 {
489                         bool is24HourNotationEnabled = false;
490                         SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourNotationEnabled);
491                         __pEditTimeEndTime->Set24HourNotationEnabled(is24HourNotationEnabled);
492                         __pEditTimeEndTime->Invalidate(true);
493                 }
494                 break;
495         case GROUP_INFORMATION_CONTENT:
496                 if (itemIndex == INFORMATION_CONTENT_ITEM_DESCRIPTION)
497                 {
498                         if (__pExpandableEditAreaNote->GetHeight() >= H_ITEM)
499                         {
500                                 __pExpandableEditAreaNote->SetPosition(0, 0);
501                                 pItem->SetSize(pItem->GetWidth(), __pExpandableEditAreaNote->GetHeight());
502                         }
503                         else
504                         {
505                                 __pExpandableEditAreaNote->SetPosition(0, (H_ITEM - __pExpandableEditAreaNote->GetHeight()) / 2);
506                                 pItem->SetSize(pItem->GetWidth(), H_ITEM);
507                         }
508                         pItem->Invalidate(true);
509                 }
510                 break;
511         case GROUP_ADDITIONAL_CONTENT:
512                 switch (itemIndex)
513                 {
514                 case ADDITIONAL_CONTENT_ITEM_REMINDER:
515                         __pLabelReminder[itemIndex]->SetText(__pPm->GetReminderString(itemIndex));
516                         __pLabelReminder[itemIndex]->Invalidate(false);
517                         if (__pPm->GetCountReminder() <= 0)
518                         {
519                                 __pButtonAddReminer->SetShowState(false);
520                                 __pButtonDeleteReminder->SetShowState(false);
521                         }
522                         else if (__pPm->GetCountReminder() >= 5)
523                         {
524                                 __pButtonAddReminer->SetShowState(false);
525                                 __pButtonDeleteReminder->SetShowState(true);
526                         }
527                         else
528                         {
529                                 __pButtonAddReminer->SetShowState(true);
530                                 __pButtonDeleteReminder->SetShowState(true);
531                         }
532                         break;
533                 case ADDITIONAL_CONTENT_ITEM_REMINDER2:
534                         // fall through
535                 case ADDITIONAL_CONTENT_ITEM_REMINDER3:
536                         // fall through
537                 case ADDITIONAL_CONTENT_ITEM_REMINDER4:
538                         // fall through
539                 case ADDITIONAL_CONTENT_ITEM_REMINDER5:
540                         __pLabelReminder[itemIndex]->SetText(__pPm->GetReminderString(itemIndex));
541                         __pLabelReminder[itemIndex]->Invalidate(false);
542                         if (itemIndex < __pPm->GetCountReminder())
543                         {
544                                 pItem->SetSize(pItem->GetWidth(), H_ITEM_2LINE);
545                                 pItem->SetShowState(true);
546                         }
547                         else
548                         {
549                                 pItem->SetSize(pItem->GetWidth(), 0);
550                                 pItem->SetShowState(false);
551                         }
552
553                         // Reminder Max_Count is 5
554                         if (__pPm->GetCountReminder() > 4)
555                         {
556                                 __pButtonAddReminer->SetShowState(false);
557                         }
558                         else
559                         {
560                                 __pButtonAddReminer->SetShowState(true);
561                         }
562                         break;
563                 case ADDITIONAL_CONTENT_ITEM_REPEAT:
564                         __pLabelRepeat->SetText(__pPm->GetRecurrenceString());
565                         pItem->SetEnabled(__pPm->IsAllEventEditing() == true);
566                         pItem->Invalidate(true);
567                         break;
568                 }
569                 break;
570         case GROUP_SAVE_TO:
571                 if (itemIndex == SAVE_TO_ITEM_SAVE_TO)
572                 {
573                         __pLabelSaveTo->SetText(__pPm->GetCalendarName());
574                         pItem->SetEnabled(__pPm->IsAllEventEditing() == true);
575                         pItem->Invalidate(true);
576                 }
577                 break;
578         }
579 }
580
581 String
582 EventEditorForm::GetSectionHeader(int sectionIndex)
583 {
584         return L"";
585 }
586
587 bool
588 EventEditorForm::HasSectionHeader(int sectionIndex)
589 {
590         if (sectionIndex == 0)
591         {
592                 return false;
593         }
594         return true;
595 }
596
597 String
598 EventEditorForm::GetSectionFooter(int sectionIndex)
599 {
600         return L"";
601 }
602
603 bool
604 EventEditorForm::HasSectionFooter(int sectionIndex)
605 {
606         return false;
607 }
608
609 int
610 EventEditorForm::GetDefaultItemHeight(void)
611 {
612         return 0;
613 }
614
615 void
616 EventEditorForm::OnSectionTableViewItemStateChanged(SectionTableView& tableView, int sectionIndex, int itemIndex,
617                                                                                                                  TableViewItem* pItem, TableViewItemStatus status)
618 {
619         SetFocus();
620         LinkedList* pList = null;
621         switch (sectionIndex)
622         {
623         case GROUP_TITLE_CONTENT:
624                 if (itemIndex == TITLE_CONTENT_ITEM_TITLE)
625                 {
626                         __pEditFieldTitle->SetFocus();
627                 }
628                 break;
629         case GROUP_DATE_SELECTOR:
630 //              if (itemIndex == DATE_SELECTOR_ITEM_TIME_ZONE)
631 //              {
632 //                      // Call Settings application.
633 //                      UpdatePm();
634 //              }
635                 if (itemIndex == DATE_SELECTOR_ITEM_ALL_DAY_EVENT)
636                 {
637                         if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
638                         {
639                                 __pPm->SetAllDayEvent(true);
640
641                                 if (__pEditTimeStartTime != null)
642                                 {
643                                         __pEditTimeStartTime->SetShowState(false);
644                                 }
645
646                                 if (__pEditTimeEndTime != null)
647                                 {
648                                         __pEditTimeEndTime->SetShowState(false);
649                                 }
650                         }
651                         else if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED)
652                         {
653                                 __pPm->SetAllDayEvent(false);
654
655                                 if (__pEditDateStartDate != null && __pEditTimeStartTime != null
656                                         && __pEditDateEndDate != null && __pEditTimeEndTime != null)
657                                 {
658                                         DateTime startTime;
659                                         startTime.SetValue(__pEditDateStartDate->GetYear(), __pEditDateStartDate->GetMonth(), __pEditDateStartDate->GetDay(),
660                                                                                 __pEditTimeStartTime->GetHour(), __pEditTimeStartTime->GetMinute());
661                                         DateTime endTime;
662                                         endTime.SetValue(__pEditDateEndDate->GetYear(), __pEditDateEndDate->GetMonth(), __pEditDateEndDate->GetDay(),
663                                                                         __pEditTimeEndTime->GetHour(), __pEditTimeEndTime->GetMinute());
664                                         if (startTime >= endTime)
665                                         {
666                                                 endTime.AddHours(1);
667                                         }
668                                         __pPm->SetStartEndTime(startTime, endTime);
669
670                                         __pEditTimeStartTime->SetTime(__pPm->GetStartTime());
671                                         __pEditTimeStartTime->SetShowState(true);
672                                         __pEditTimeStartTime->Invalidate(false);
673
674                                         __pEditTimeEndTime->SetTime(__pPm->GetEndTime());
675                                         __pEditTimeEndTime->SetShowState(true);
676                                         __pEditTimeEndTime->Invalidate(false);
677                                 }
678                         }
679                 }
680                 break;
681         case GROUP_INFORMATION_CONTENT:
682                 switch (itemIndex)
683                 {
684                 case INFORMATION_CONTENT_ITEM_DESCRIPTION:
685                         __pExpandableEditAreaNote->SetFocus();
686                         break;
687                 case INFORMATION_CONTENT_ITEM_LOCATION:
688                         __pEditFieldLocation->SetFocus();
689                         break;
690                 }
691                 break;
692         case GROUP_ADDITIONAL_CONTENT:
693                 // Call ReminderForm
694                 switch (itemIndex)
695                 {
696                 case ADDITIONAL_CONTENT_ITEM_REMINDER:
697                         // fall through
698                 case ADDITIONAL_CONTENT_ITEM_REMINDER2:
699                         // fall through
700                 case ADDITIONAL_CONTENT_ITEM_REMINDER3:
701                         // fall through
702                 case ADDITIONAL_CONTENT_ITEM_REMINDER4:
703                         // fall through
704                 case ADDITIONAL_CONTENT_ITEM_REMINDER5:
705                         if (__pPm->GetReminder(itemIndex) != null)
706                         {
707                                 UpdatePm();
708                                 pList = new (std::nothrow) LinkedList();
709                                 pList->Add(new (std::nothrow) Reminder(*__pPm->GetReminder(itemIndex)));
710                                 pList->Add(new (std::nothrow) Integer(itemIndex));
711                         }
712                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_REMINDER,
713                                                                                                   SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
714                 break;
715                 }
716
717                 if (itemIndex == ADDITIONAL_CONTENT_ITEM_REPEAT)
718                 {
719                         // Call RepeatForm
720                         UpdatePm();
721                         pList = new (std::nothrow) LinkedList();
722                         pList->Add(new (std::nothrow) DateTime(__pPm->GetStartTime()));
723                         if (__pPm->GetRecurrence() != null)
724                         {
725                                 pList->Add(new (std::nothrow) Recurrence(*__pPm->GetRecurrence()));
726                         }
727
728                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_REPEAT,
729                                                                                                                                                   SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
730                 }
731                 break;
732         case GROUP_SAVE_TO:
733                 if (itemIndex == SAVE_TO_ITEM_SAVE_TO)
734                 {
735                         __pCalendarSelectorPopup->RequestCalendar(CALENDAR_SELECTOR_POPUP_STYLE_EVENT, this);
736                 }
737                 break;
738         }
739 }
740
741 void
742 EventEditorForm::OnSectionTableViewContextItemActivationStateChanged(SectionTableView& tableView, int sectionIndex, int itemIndex,
743                                                                                                                                                    TableViewContextItem* pContextItem, bool activated)
744 {
745 }
746
747 void
748 EventEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
749 {
750         AppLogDebug("Enter.");
751         if (previousSceneId == IDSCN_REMINDER)
752         {
753                 int index = 0;
754                 if (pArgs != null)
755                 {
756                         Integer* pIndex = dynamic_cast<Integer*>(pArgs->GetAt(0));
757                         if (pIndex != null)
758                         {
759                                 index = pIndex->ToInt();
760                         }
761                         Reminder* pReminder = dynamic_cast<Reminder*>(pArgs->GetAt(1));
762                         if (pReminder != null)
763                         {
764                                 if (index < __pPm->GetCountReminder())
765                                 {
766                                         __pPm->SetReminderAt(*pReminder, index);
767                                 }
768                                 else
769                                 {
770                                         __pPm->AddReminder(*pReminder);
771                                 }
772                                 __pTableView->RefreshItem(GROUP_ADDITIONAL_CONTENT, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
773                         }
774                         else
775                         {
776                                 __pPm->RemoveReminderAt(index);
777                                 __pTableView->UpdateTableView();
778                         }
779                 }
780         }
781         else if (previousSceneId == IDSCN_REPEAT)
782         {
783                 Recurrence* pRecurrence = null;
784                 if (pArgs != null)
785                 {
786                         pRecurrence = dynamic_cast<Recurrence*>(pArgs->GetAt(0));
787                 }
788
789                 result r = E_FAILURE;
790                 if (pRecurrence == null)
791                 {
792                         r = __pPm->SetRecurrence(null);
793                 }
794                 else if (pRecurrence->GetCounts() > 0)
795                 {
796                         r = __pPm->SetRecurrence(pRecurrence);
797                 }
798                 else if (pRecurrence->GetUntil() != null)
799                 {
800                         DateTime untilDateChecker = __pPm->GetStartTime();
801                         switch (pRecurrence->GetFrequency())
802                         {
803                         case FREQ_DAILY:
804                                 untilDateChecker.AddDays(pRecurrence->GetInterval());
805                                 break;
806                         case FREQ_WEEKLY:
807                                 untilDateChecker.AddDays(7 * pRecurrence->GetInterval());
808                                 break;
809                         case FREQ_MONTHLY:
810                                 untilDateChecker.AddMonths(pRecurrence->GetInterval());
811                                 break;
812                         case FREQ_YEARLY:
813                                 untilDateChecker.AddYears(pRecurrence->GetInterval());
814                                 break;
815                         }
816
817                         if (*pRecurrence->GetUntil() >= untilDateChecker)
818                         {
819                                 r = __pPm->SetRecurrence(pRecurrence);
820                         }
821                 }
822
823                 if (r == E_SUCCESS)
824                 {
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);
828                 }
829                 else
830                 {
831                         MessageBox msgBox;
832                         msgBox.Construct(L"", ResourceManager::GetString(IDS_CLD_BODY_REPEAT_WARNING), MSGBOX_STYLE_OK);
833                         int modalResult;
834                         msgBox.ShowAndWait(modalResult);
835                 }
836         }
837         else
838         {
839                 CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
840                 if (pApp->GetOperationType() == OPERATION_TYPE_MAIN)
841                 {
842                         if (pArgs != null)
843                         {
844                                 CalEventInstance* pEvent = dynamic_cast<CalEventInstance*>(pArgs->GetAt(0));
845                                 DateTime* pStartTime = null;
846
847                                 if (pEvent != null)
848                                 {
849                                         bool allEventEditing = true;
850                                         Boolean* pAllEventEditing = dynamic_cast<Boolean*>(pArgs->GetAt(1));
851                                         if (pAllEventEditing != null)
852                                         {
853                                                 allEventEditing = pAllEventEditing->value;
854                                         }
855                                         __pPm->SetAllEventEditing(allEventEditing);
856
857                                         result r = __pPm->SetEventInstance(*pEvent);
858                                         if (r != E_SUCCESS)
859                                         {
860                                                 AppLogDebug("[%s] Unable to get event.", GetErrorMessage(r));
861                                                 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
862                                                 AppLogDebug("Enter.");
863                                                 return;
864                                         }
865
866                                         SetStyle(EDIT_EVENT_FORM_STYLE_EDIT);
867                                 }
868
869                                 pStartTime = dynamic_cast<DateTime*>(pArgs->GetAt(0));
870                                 if (pStartTime != null)
871                                 {
872                                         pStartTime->AddHours(1);
873                                         pStartTime->AddMinutes(-pStartTime->GetMinute());
874                                         pStartTime->AddSeconds(-pStartTime->GetSecond());
875                                         DateTime end = *pStartTime;
876                                         end.AddHours(1);
877                                         __pPm->SetStartEndTime(*pStartTime, end);
878
879                                         SetStyle(EDIT_EVENT_FORM_STYLE_CREATE);
880
881                                         if (__pEditFieldTitle != null)
882                                         {
883                                                 __pEditFieldTitle->SetFocus();
884                                         }
885                                 }
886                         }
887                 }
888                 else
889                 {
890                         //AppControl
891                         CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
892                         if (pApp->GetOperationType() == OPERATION_TYPE_EDIT)
893                         {
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)
897                                 {
898                                         RecordId eventId = INVALID_RECORD_ID;
899                                         Integer::Parse(*pEventId, eventId);
900                                         result r = __pPm->SetEventId(eventId);
901                                         if (r == E_SUCCESS)
902                                         {
903                                                 SetStyle(EDIT_EVENT_FORM_STYLE_EDIT);
904                                         }
905                                         else
906                                         {
907                                                 r = SendAppControlResult(APP_CTRL_RESULT_FAILED);
908                                                 AppLogDebugIf(r != E_SUCCESS, "[%s] Unable to return result.", GetErrorMessage(r));
909
910                                                 pApp->Terminate();
911                                         }
912                                 }
913                         }
914                 }
915         }
916
917         __pTableView->SetItemChecked(GROUP_DATE_SELECTOR, DATE_SELECTOR_ITEM_ALL_DAY_EVENT, __pPm->IsAllDayEvent());
918
919         if (pArgs != null)
920         {
921                 pArgs->RemoveAll(true);
922                 delete pArgs;
923         }
924
925         AppLogDebug("Exit.");
926 }
927
928 void
929 EventEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
930 {
931         AppLogDebug("Enter.");
932         AppLogDebug("Exit.");
933 }
934
935 void
936 EventEditorForm::OnActionPerformed(const Control& source, int actionId)
937 {
938         AppLogDebug("Enter.");
939         SetFocus();
940         switch (actionId)
941         {
942         case IDA_EVENT_EDITOR_FORM_SAVE:
943                 UpdatePm();
944                 if (__pPm->Update() == E_SUCCESS)
945                 {
946                         CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
947                         if (pApp != null && pApp->GetOperationType() != OPERATION_TYPE_MAIN)
948                         {
949                                 result r = SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED);
950                                 AppLogDebugIf(r != E_SUCCESS, "[%s] Unable to return result.", GetErrorMessage(r));
951
952                                 pApp->Terminate();
953                                 AppLogDebug("Exit.");
954                                 return;
955                         }
956
957                         CalEventInstance* pEventInstance = __pPm->GetEventInstance();
958                         if (pEventInstance != null)
959                         {
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);
963                                 if (r != E_SUCCESS)
964                                 {
965                                         pList->RemoveAll(true);
966                                         delete pList;
967
968                                         MessageBox msgBox;
969                                         msgBox.Construct(L"", ResourceManager::GetString(IDS_COM_POP_SAVING_FAILED), MSGBOX_STYLE_OK);
970                                         int modalResult;
971                                         msgBox.ShowAndWait(modalResult);
972                                 }
973                         }
974                         else
975                         {
976                                 if (SceneManager::GetInstance()->IsSceneAlive(IDSCN_EVENT_DETAILS) == true)
977                                 {
978                                         SceneId backSceneId = IDSCN_MONTH;
979                                         IListT<SceneId>* pHistory = SceneManager::GetInstance()->GetSceneHistoryN();
980                                         if (pHistory != null)
981                                         {
982                                                 int index = 0;
983                                                 if (pHistory->IndexOf(SceneId(IDSCN_EVENT_DETAILS), index) == E_SUCCESS)
984                                                 {
985                                                         pHistory->GetAt(index - 1, backSceneId);
986                                                 }
987                                         }
988                                         pHistory->RemoveAll();
989                                         delete pHistory;
990
991                                         result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(backSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
992                                         if (r == E_SUCCESS)
993                                         {
994                                                 SceneManager::GetInstance()->DestroyScene(IDSCN_EVENT_DETAILS);
995                                         }
996                                         else
997                                         {
998                                                 MessageBox msgBox;
999                                                 msgBox.Construct(L"", ResourceManager::GetString(IDS_COM_POP_SAVING_FAILED), MSGBOX_STYLE_OK);
1000                                                 int modalResult;
1001                                                 msgBox.ShowAndWait(modalResult);
1002                                         }
1003                                 }
1004                                 else
1005                                 {
1006                                         result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1007                                         if (r != E_SUCCESS)
1008                                         {
1009                                                 MessageBox msgBox;
1010                                                 msgBox.Construct(L"", ResourceManager::GetString(IDS_COM_POP_SAVING_FAILED), MSGBOX_STYLE_OK);
1011                                                 int modalResult;
1012                                                 msgBox.ShowAndWait(modalResult);
1013                                         }
1014                                 }
1015                         }
1016                 }
1017                 else
1018                 {
1019                         MessageBox msgBox;
1020                         msgBox.Construct(L"", ResourceManager::GetString(IDS_COM_POP_SAVING_FAILED), MSGBOX_STYLE_OK);
1021                         int modalResult;
1022                         msgBox.ShowAndWait(modalResult);
1023                 }
1024                 __pTableView->UpdateTableView();
1025                 break;
1026         case IDA_EVENT_EDITOR_FORM_CANCEL:
1027                 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1028                 break;
1029         case IDA_EVENT_EDITOR_FORM_ADD_REMINDER:
1030         {
1031                 Reminder reminder;
1032                 __pPm->AddReminder(reminder);
1033
1034                 __pTableView->RefreshItem(GROUP_ADDITIONAL_CONTENT, __pPm->GetCountReminder() - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1035                 break;
1036         }
1037         case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER:
1038                 // fall through
1039         case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER2:
1040                 // fall through
1041         case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER3:
1042                 // fall through
1043         case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER4:
1044                 // fall through
1045         case IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER5:
1046         {
1047                 int index = actionId - IDA_EVENT_EDITOR_FORM_REMOVE_REMINDER;
1048                 int count = __pPm->GetCountReminder();
1049                 __pPm->RemoveReminderAt(index);
1050
1051                 while (index < count)
1052                 {
1053                         __pTableView->RefreshItem(GROUP_ADDITIONAL_CONTENT, index++, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1054                 }
1055                 break;
1056         }
1057         }
1058         AppLogDebug("Exit.");
1059 }
1060
1061 void
1062 EventEditorForm::OnDateChanged(const Control& source, int year, int month, int day)
1063 {
1064         DateTime startTime = __pPm->GetStartTime();
1065         DateTime endTime = __pPm->GetEndTime();
1066         if (&source == __pEditDateStartDate)
1067         {
1068                 startTime.SetValue(year, month, day, startTime.GetHour(), startTime.GetMinute());
1069                 endTime.AddSeconds(-endTime.GetSecond());
1070                 if (__pPm->IsAllDayEvent() == true)
1071                 {
1072                         if (startTime > endTime)
1073                         {
1074                                 endTime = startTime;
1075                         }
1076                 }
1077                 else
1078                 {
1079                         if (startTime >= endTime)
1080                         {
1081                                 endTime = startTime;
1082                                 endTime.AddHours(1);
1083                         }
1084                 }
1085         }
1086         else if (&source == __pEditDateEndDate)
1087         {
1088                 endTime.SetValue(year, month, day, endTime.GetHour(), endTime.GetMinute());
1089                 if (__pPm->IsAllDayEvent() == true)
1090                 {
1091                         if (startTime > endTime)
1092                         {
1093                                 startTime = endTime;
1094                         }
1095                 }
1096                 else
1097                 {
1098                         if (startTime >= endTime)
1099                         {
1100                                 startTime = endTime;
1101                                 startTime.AddHours(-1);
1102                         }
1103                 }
1104         }
1105
1106         result r = __pPm->SetStartEndTime(startTime, endTime);
1107
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);
1116
1117         if (r != E_SUCCESS)
1118         {
1119                 MessageBox msgBox;
1120                 msgBox.Construct(L"", ResourceManager::GetString(IDS_CLD_POP_INVALID_TIME), MSGBOX_STYLE_NONE, MESSAGE_BOX_TIME_OUT);
1121                 int modalResult;
1122                 msgBox.ShowAndWait(modalResult);
1123         }
1124 }
1125
1126 void
1127 EventEditorForm::OnDateChangeCanceled(const Control& source)
1128 {
1129 }
1130
1131 void
1132 EventEditorForm::OnKeypadWillOpen(Control& source)
1133 {
1134 }
1135
1136 void
1137 EventEditorForm::OnKeypadOpened(Control& source)
1138 {
1139         Invalidate(true);
1140 }
1141
1142 void
1143 EventEditorForm::OnKeypadClosed(Control& source)
1144 {
1145         Invalidate(true);
1146 }
1147
1148 void
1149 EventEditorForm::OnKeypadActionPerformed(Control& source, KeypadAction keypadAction)
1150 {
1151 }
1152
1153 void
1154 EventEditorForm::OnTimeChanged(const Control& source, int hour, int minute)
1155 {
1156         DateTime startTime = __pPm->GetStartTime();
1157         DateTime endTime = __pPm->GetEndTime();
1158         if (&source == __pEditTimeStartTime)
1159         {
1160                 startTime.SetValue(startTime.GetYear(), startTime.GetMonth(), startTime.GetDay(), hour, minute);
1161                 endTime.AddSeconds(-endTime.GetSecond());
1162                 if (startTime >= endTime)
1163                 {
1164                         endTime = startTime;
1165                         endTime.AddHours(1);
1166                 }
1167         }
1168         else if (&source == __pEditTimeEndTime)
1169         {
1170                 endTime.SetValue(endTime.GetYear(), endTime.GetMonth(), endTime.GetDay(), hour, minute);
1171                 if (startTime >= endTime)
1172                 {
1173                         startTime = endTime;
1174                         startTime.AddHours(-1);
1175                 }
1176         }
1177
1178         result r = __pPm->SetStartEndTime(startTime, endTime);
1179
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);
1188
1189         if (r != E_SUCCESS)
1190         {
1191                 MessageBox msgBox;
1192                 msgBox.Construct(L"", ResourceManager::GetString(IDS_CLD_POP_INVALID_TIME), MSGBOX_STYLE_NONE, MESSAGE_BOX_TIME_OUT);
1193                 int modalResult;
1194                 msgBox.ShowAndWait(modalResult);
1195         }
1196 }
1197
1198 void
1199 EventEditorForm::OnTimeChangeCanceled(const Control& source)
1200 {
1201 }
1202
1203 TableViewItem*
1204 EventEditorForm::CreateTitleItemN(int itemWidth, const String& title)
1205 {
1206         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1207
1208         EditField* pTitle = null;
1209         pItem->Construct(Dimension(itemWidth, H_ITEM));
1210         pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1211
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);
1215
1216         pItem->AddControl(pTitle);
1217         pItem->SetIndividualSelectionEnabled(pTitle, true);
1218
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)
1223         {
1224                 String subString;
1225                 title.SubString(0, EDITFIELD_LIMIT_LENGTH, subString);
1226                 pTitle->SetText(subString);
1227         }
1228         else
1229         {
1230                 pTitle->SetText(title);
1231         }
1232         pTitle->SetGuideText(ResourceManager::GetString(IDS_CLD_BODY_TITLE));
1233         pTitle->AddActionEventListener(*this);
1234         pTitle->AddKeypadEventListener(*this);
1235
1236         __pEditFieldTitle = pTitle;
1237
1238         return pItem;
1239 }
1240
1241 TableViewItem*
1242 EventEditorForm::CreateStartTimeItemN(int itemWidth, const DateTime& start, bool isAllDayEvent)
1243 {
1244         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1245
1246         EditDate* pStartDate = null;
1247         EditTime* pStartTime = null;
1248
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);
1253
1254         pStartDate = new (std::nothrow) EditDate();
1255         pStartDate->Construct(Point(0, Y_DATE_SELECTOR), ResourceManager::GetString(IDS_EVENT_EDITOR_FROM));
1256
1257         pItem->AddControl(pStartDate);
1258
1259         pStartDate->SetYearRange(Calendarbook::GetMinDateTime().GetYear() + 1, Calendarbook::GetMaxDateTime().GetYear() - 1);
1260         pStartDate->SetDate(start);
1261         pStartDate->AddDateChangeEventListener(*this);
1262         pItem->SetIndividualSelectionEnabled(pStartDate, true);
1263
1264         __pEditDateStartDate = pStartDate;
1265
1266         pStartTime = new (std::nothrow) EditTime();
1267         pStartTime->Construct(Point(X_DATE_SELECTOR, Y_DATE_SELECTOR), L" ");
1268
1269         pItem->AddControl(pStartTime);
1270
1271         pStartTime->SetTime(start);
1272         pStartTime->AddTimeChangeEventListener(*this);
1273         pItem->SetIndividualSelectionEnabled(pStartTime, true);
1274
1275         bool is24HourNotationEnabled = false;
1276         SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourNotationEnabled);
1277         pStartTime->Set24HourNotationEnabled(is24HourNotationEnabled);
1278
1279         __pEditTimeStartTime = pStartTime;
1280
1281         if (isAllDayEvent == true)
1282         {
1283                 __pEditTimeStartTime->SetShowState(false);
1284         }
1285
1286         return pItem;
1287 }
1288
1289 TableViewItem*
1290 EventEditorForm::CreateEndTimeItemN(int itemWidth, const DateTime& end, bool isAllDayEvent)
1291 {
1292         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1293
1294         EditDate* pEndDate = null;
1295         EditTime* pEndTime = null;
1296
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);
1301
1302         pEndDate = new (std::nothrow) EditDate();
1303         pEndDate->Construct(Point(0, Y_DATE_SELECTOR), ResourceManager::GetString(IDS_EVENT_EDITOR_TO));
1304
1305         pItem->AddControl(pEndDate);
1306
1307         pEndDate->SetYearRange(Calendarbook::GetMinDateTime().GetYear() + 1, Calendarbook::GetMaxDateTime().GetYear() - 1);
1308         pEndDate->SetDate(end);
1309         pEndDate->AddDateChangeEventListener(*this);
1310         pItem->SetIndividualSelectionEnabled(pEndDate, true);
1311
1312         __pEditDateEndDate = pEndDate;
1313
1314         pEndTime = new (std::nothrow) EditTime();
1315         pEndTime->Construct(Point(X_DATE_SELECTOR, Y_DATE_SELECTOR), L" ");
1316
1317         pItem->AddControl(pEndTime);
1318
1319         pEndTime->SetTime(end);
1320         pEndTime->AddTimeChangeEventListener(*this);
1321         pItem->SetIndividualSelectionEnabled(pEndTime, true);
1322
1323         bool is24HourNotationEnabled = false;
1324         SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourNotationEnabled);
1325         pEndTime->Set24HourNotationEnabled(is24HourNotationEnabled);
1326
1327         __pEditTimeEndTime = pEndTime;
1328
1329         if (isAllDayEvent == true)
1330         {
1331                 __pEditTimeEndTime->SetShowState(false);
1332         }
1333
1334         return pItem;
1335 }
1336
1337 //TableViewItem*
1338 //EventEditorForm::CreateTimeZoneTimeN(int itemWidth, const String& timeZone)
1339 //{
1340 //      TableViewItem* pItem = new (std::nothrow) TableViewItem();
1341 //
1342 //      Label* pLabel = null;
1343 //      Label* pContentLabel = null;
1344 //
1345 //      pItem->Construct(Dimension(itemWidth, H_ITEM_2LINE));
1346 //      pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1347 //
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));
1351 //
1352 //      pItem->AddControl(pLabel);
1353 //
1354 //      pLabel->SetTextColor(Color(COLOR_DETAIL02));
1355 //      pLabel->SetTextConfig(FONT_SIZE_DETAIL02, LABEL_TEXT_STYLE_NORMAL);
1356 //      pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1357 //
1358 //      pContentLabel = new (std::nothrow) Label();
1359 //      pContentLabel->Construct(Rectangle(0, Y_ITEM_CONTENT02, itemWidth, H_ITEM_CONTENT02), timeZone);
1360 //
1361 //      pItem->AddControl(pContentLabel);
1362 //
1363 //      pContentLabel->SetTextColor(Color(COLOR_ADDITIONAL_CONTENT));
1364 //      pContentLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1365 //      pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1366 //
1367 //      __pLabelTimeZone = pContentLabel;
1368 //
1369 //      return pItem;
1370 //}
1371
1372 TableViewItem*
1373 EventEditorForm::CreateAllDayEventItemN(int itemWidth)
1374 {
1375         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1376
1377         Label* pLabel = null;
1378
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);
1381
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);
1387
1388         pItem->AddControl(pLabel);
1389
1390         return pItem;
1391 }
1392
1393 TableViewItem*
1394 EventEditorForm::CreateDescriptionItemN(int itemWidth, const String& description)
1395 {
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);
1399
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);
1416
1417         // Adjust text position
1418         if (__pExpandableEditAreaNote->GetHeight() >= H_ITEM && __pExpandableEditAreaNote->GetY() != 0)
1419         {
1420                 __pExpandableEditAreaNote->SetPosition(0, 0);
1421         }
1422
1423         return pItem;
1424 }
1425
1426 TableViewItem*
1427 EventEditorForm::CreateLocationItemN(int itemWidth, const String& location)
1428 {
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);
1432
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);
1436
1437         pItem->AddControl(pLocation);
1438         pItem->SetIndividualSelectionEnabled(pLocation, true);
1439
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)
1444         {
1445                 String subString;
1446                 location.SubString(0, EDITFIELD_LIMIT_LENGTH, subString);
1447                 pLocation->SetText(subString);
1448         }
1449         else
1450         {
1451                 pLocation->SetText(location);
1452         }
1453         pLocation->SetGuideText(ResourceManager::GetString(IDS_CLD_BODY_LOCATION));
1454         pLocation->AddActionEventListener(*this);
1455         pLocation->AddKeypadEventListener(*this);
1456
1457         __pEditFieldLocation = pLocation;
1458
1459         return pItem;
1460 }
1461
1462 TableViewItem*
1463 EventEditorForm::CreateReminderItemN(int itemWidth, int itemHeight, const String& reminder, int index, bool showItem, bool hasAddButton)
1464 {
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);
1468
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));
1472
1473         pItem->AddControl(pLabel);
1474
1475         pLabel->SetTextColor(Color(COLOR_DETAIL02));
1476         pLabel->SetTextConfig(FONT_SIZE_DETAIL02, LABEL_TEXT_STYLE_NORMAL);
1477         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1478
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);
1481
1482         pItem->AddControl(pContentLabel);
1483
1484         pContentLabel->SetTextColor(Color(COLOR_ADDITIONAL_CONTENT));
1485         pContentLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1486         pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1487
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"");
1492
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)
1498         {
1499                 __pButtonDeleteReminder = pButtonDeleteReminder;
1500         }
1501
1502         Bitmap* pBitmapBgDelete = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON_DELETE);
1503         if (pBitmapBgDelete != null)
1504         {
1505                 pButtonDeleteReminder->SetNormalBackgroundBitmap(*pBitmapBgDelete);
1506                 delete pBitmapBgDelete;
1507         }
1508         Bitmap* pBitmapBgDeletePressed = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON_DELETE_PRESS);
1509         if (pBitmapBgDeletePressed != null)
1510         {
1511                 pButtonDeleteReminder->SetPressedBackgroundBitmap(*pBitmapBgDeletePressed);
1512                 pButtonDeleteReminder->SetHighlightedBackgroundBitmap(*pBitmapBgDeletePressed);
1513                 delete pBitmapBgDeletePressed;
1514         }
1515         Bitmap* pBitmapMinus = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS);
1516         if (pBitmapMinus != null)
1517         {
1518                 pButtonDeleteReminder->SetNormalBitmap(Point(0, 0), *pBitmapMinus);
1519                 delete pBitmapMinus;
1520         }
1521         Bitmap* pBitmapMinusPressed = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS_PRESS);
1522         if (pBitmapMinusPressed != null)
1523         {
1524                 pButtonDeleteReminder->SetPressedBitmap(Point(0, 0), *pBitmapMinusPressed);
1525                 delete pBitmapMinusPressed;
1526         }
1527
1528         // Add add button
1529         if (hasAddButton == true)
1530         {
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"");
1534
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;
1540
1541                 Bitmap* pBitmapBgButton = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON);
1542                 if (pBitmapBgButton != null)
1543                 {
1544                         pButtonAddReminder->SetNormalBackgroundBitmap(*pBitmapBgButton);
1545                         delete pBitmapBgButton;
1546                 }
1547                 Bitmap* pBitmapBgButtonPressed = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON_PRESS);
1548                 if (pBitmapBgButtonPressed != null)
1549                 {
1550                         pButtonAddReminder->SetPressedBackgroundBitmap(*pBitmapBgButtonPressed);
1551                         pButtonAddReminder->SetHighlightedBackgroundBitmap(*pBitmapBgButtonPressed);
1552                         delete pBitmapBgButtonPressed;
1553                 }
1554                 Bitmap* pBitmapPlus = ResourceManager::GetBitmapN(IDB_BUTTON_PLUS);
1555                 if (pBitmapPlus != null)
1556                 {
1557                         pButtonAddReminder->SetNormalBitmap(Point(0, 0), *pBitmapPlus);
1558                         delete pBitmapPlus;
1559                 }
1560                 Bitmap* pBitmapPlusPressed = ResourceManager::GetBitmapN(IDB_BUTTON_PLUS_PRESS);
1561                 if (pBitmapPlusPressed != null)
1562                 {
1563                         pButtonAddReminder->SetPressedBitmap(Point(0, 0), *pBitmapPlusPressed);
1564                         delete pBitmapPlusPressed;
1565                 }
1566         }
1567
1568         pItem->SetShowState(showItem);
1569         __pLabelReminder[index] = pContentLabel;
1570         __pItemReminder[index] = pItem;
1571
1572         return pItem;
1573 }
1574
1575 TableViewItem*
1576 EventEditorForm::CreateRepeatItemN(int itemWidth, const String& repeat)
1577 {
1578         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1579
1580         Label* pLabel = null;
1581         Label* pContentLabel = null;
1582
1583         pItem->Construct(Dimension(itemWidth, H_ITEM_2LINE));
1584         pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1585
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));
1589
1590         pItem->AddControl(pLabel);
1591
1592         pLabel->SetTextColor(Color(COLOR_DETAIL02));
1593         pLabel->SetTextConfig(FONT_SIZE_DETAIL02, LABEL_TEXT_STYLE_NORMAL);
1594         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1595
1596         pContentLabel = new (std::nothrow) Label();
1597         pContentLabel->Construct(Rectangle(0, Y_ITEM_CONTENT02, itemWidth, H_ITEM_CONTENT02), repeat);
1598
1599         pItem->AddControl(pContentLabel);
1600
1601         pContentLabel->SetTextColor(Color(COLOR_ADDITIONAL_CONTENT));
1602         pContentLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1603         pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1604
1605         __pLabelRepeat = pContentLabel;
1606
1607         if (__pPm->IsAllEventEditing() == false)
1608         {
1609                 pItem->SetEnabled(false);
1610         }
1611
1612         return pItem;
1613 }
1614
1615 TableViewItem*
1616 EventEditorForm::CreateSaveToItemN(int itemWidth, const String& calendarName, const Bitmap* pCalendarIcon)
1617 {
1618         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1619
1620         Label* pLabel = null;
1621         Label* pContentLabel = null;
1622
1623         pItem->Construct(Dimension(itemWidth, H_ITEM_2LINE));
1624         pItem->SetBackgroundColor(Color(COLOR_ITEM_BACKGROUND), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1625
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));
1629
1630         pItem->AddControl(pLabel);
1631
1632         pLabel->SetTextColor(Color(COLOR_DETAIL02));
1633         pLabel->SetTextConfig(FONT_SIZE_DETAIL02, LABEL_TEXT_STYLE_NORMAL);
1634         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1635
1636         pContentLabel = new (std::nothrow) Label();
1637         pContentLabel->Construct(Rectangle(0, Y_ITEM_CONTENT02, itemWidth, H_ITEM_CONTENT02), calendarName);
1638
1639         pItem->AddControl(pContentLabel);
1640
1641         pContentLabel->SetTextColor(Color(COLOR_ADDITIONAL_CONTENT));
1642         pContentLabel->SetTextConfig(FONT_SIZE_DETAIL03, LABEL_TEXT_STYLE_NORMAL);
1643         pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1644
1645         __pLabelSaveTo = pContentLabel;
1646
1647         if (__pPm->IsAllEventEditing() == false)
1648         {
1649                 pItem->SetEnabled(false);
1650         }
1651
1652         return pItem;
1653 }
1654
1655 result
1656 EventEditorForm::SetStyle(EditEventFormStyle style)
1657 {
1658         Header* pHeader = GetHeader();
1659         if (style == EDIT_EVENT_FORM_STYLE_CREATE)
1660         {
1661                 pHeader->SetTitleText(ResourceManager::GetString(IDS_CLD_HEADER_CREATE_EVENT));
1662         }
1663         else
1664         {
1665                 pHeader->SetTitleText(ResourceManager::GetString(IDS_CLD_HEADER_EDIT_EVENT));
1666         }
1667         pHeader->Invalidate(false);
1668
1669         if (__pTableView != null)
1670         {
1671                 __pEditFieldTitle = null;
1672                 __pEditFieldLocation = null;
1673                 __pEditDateStartDate = null;
1674                 __pEditTimeStartTime = null;
1675                 __pEditDateEndDate = null;
1676                 __pEditTimeEndTime = null;
1677                 __pExpandableEditAreaNote = null;
1678                 __pTableView->UpdateTableView();
1679         }
1680
1681         __style = style;
1682
1683         if (__pPm->GetSubject().GetLength() > EDITFIELD_LIMIT_LENGTH
1684                 || __pPm->GetLocation().GetLength() > EDITFIELD_LIMIT_LENGTH)
1685         {
1686                 MessageBox msgBox;
1687                 msgBox.Construct(L"", ResourceManager::GetString(IDS_IMGE_POP_TEXT_TOO_LONG),
1688                                                 MSGBOX_STYLE_NONE, MESSAGE_BOX_TIME_OUT);
1689
1690                 int modalResult;
1691                 msgBox.ShowAndWait(modalResult);
1692         }
1693
1694         return E_SUCCESS;
1695 }
1696
1697 result
1698 EventEditorForm::SendAppControlResult(AppCtrlResult appControlResult)
1699 {
1700         CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
1701         TryReturn(pApp != null, E_FAILURE, "[E_FAILURE] Unable to get app instance.");
1702
1703         result r = AppControlProviderManager::GetInstance()->SendAppControlResult(pApp->GetRequestId(), appControlResult, null);
1704         AppLogDebugIf(r != E_SUCCESS, "[%s] Unable to return result.", GetErrorMessage(r));
1705
1706         return r;
1707 }
1708
1709 result
1710 EventEditorForm::UpdatePm(void)
1711 {
1712         if (__pEditFieldTitle != null)
1713         {
1714                 __pPm->SetSubject(__pEditFieldTitle->GetText());
1715         }
1716
1717         DateTime startTime = __pPm->GetStartTime();
1718         DateTime endTime = __pPm->GetEndTime();
1719         if (__pEditDateStartDate != null)
1720         {
1721                 startTime.SetValue(__pEditDateStartDate->GetYear(), __pEditDateStartDate->GetMonth(), __pEditDateStartDate->GetDay(),
1722                                                         startTime.GetHour(), startTime.GetMinute());
1723         }
1724         if (__pEditTimeStartTime != null)
1725         {
1726                 startTime.SetValue(startTime.GetYear(), startTime.GetMonth(), startTime.GetDay(),
1727                                                         __pEditTimeStartTime->GetHour(), __pEditTimeStartTime->GetMinute());
1728         }
1729         if (__pEditDateEndDate != null)
1730         {
1731                 endTime.SetValue(__pEditDateEndDate->GetYear(), __pEditDateEndDate->GetMonth(), __pEditDateEndDate->GetDay(),
1732                                                         endTime.GetHour(), endTime.GetMinute());
1733         }
1734         if (__pEditTimeEndTime != null)
1735         {
1736                 endTime.SetValue(endTime.GetYear(), endTime.GetMonth(), endTime.GetDay(),
1737                                                         __pEditTimeEndTime->GetHour(), __pEditTimeEndTime->GetMinute());
1738         }
1739         __pPm->SetStartEndTime(startTime, endTime);
1740
1741         if (__pExpandableEditAreaNote != null)
1742         {
1743                 __pPm->SetDescription(__pExpandableEditAreaNote->GetText());
1744         }
1745
1746         if (__pEditFieldLocation != null)
1747         {
1748                 __pPm->SetLocation(__pEditFieldLocation->GetText());
1749         }
1750
1751         return E_SUCCESS;
1752 }