Applied latest source code
[apps/native/preloaded/Settings.git] / src / StDisplayForm.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                StDisplayForm.cpp
19  * @brief               This is the implementation file for DisplayForm class.
20  */
21
22 #include <FSystem.h>
23 #include "StDisplayForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
26 #include "StTypes.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::System;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Controls;
33 using namespace Tizen::Ui::Scenes;
34
35 static const int W_RESIZE_LABEL_GAP = 110;
36 static const int RELATIVE_LAYOUT_ITEM_RIGHT_MARGIN = 140;
37
38 static const int BACKLIGHT_TIME_15_SECONDS = 15;
39 static const int BACKLIGHT_TIME_30_SECONDS = 30;
40 static const int BACKLIGHT_TIME_1_MINUTE = 60;
41 static const int BACKLIGHT_TIME_2_MINUTES = 120;
42 static const int BACKLIGHT_TIME_5_MINUTES = 300;
43 static const int BACKLIGHT_TIME_10_MINUTES = 600;
44
45 static const int ID_GROUP_AUTO_ROTATE_SCREEN = 0;
46 static const int ID_ITEM_AUTO_ROTATE_SCREEN = 0;
47
48 static const int ID_GROUP_BACKLIGHT_TIME = 1;
49
50 static const int ID_GROUP_BACKLIGHT_TIME_LIST = 2;
51 static const int ID_GROUP_BACKLIGHT_TIME_LIST_ITEM_COUNT = 6;
52 static const int ID_ITEM_BACKLIGHT_TIME_15_SECONDS = 0;
53 static const int ID_ITEM_BACKLIGHT_TIME_30_SECONDS = 1;
54 static const int ID_ITEM_BACKLIGHT_TIME_1_MINUTE = 2;
55 static const int ID_ITEM_BACKLIGHT_TIME_2_MINUTES = 3;
56 static const int ID_ITEM_BACKLIGHT_TIME_5_MINUTES = 4;
57 static const int ID_ITEM_BACKLIGHT_TIME_10_MINUTES = 5;
58
59 static const int ID_GROUP_FONT = 3;
60
61 static const int ID_GROUP_BATTERY_PERCENTAGE = 4;
62 static const int ID_ITEM_BATTERY_PERCENTAGE = 0;
63
64 static const int ID_GROUP_BATTERY_PERCENTAGE_HELP = 5;
65
66 static const int ID_GROUP_DEFAULT_ITEM_COUNT = 1;
67
68 static const int ID_GROUP_COUNT = 6;
69
70 DisplayForm::DisplayForm(void)
71         : __pLabel(null)
72 {
73 }
74
75 DisplayForm::~DisplayForm(void)
76 {
77 }
78
79 void
80 DisplayForm::CreateFooter(void)
81 {
82         Footer* pFooter = GetFooter();
83         AppAssert(pFooter);
84
85         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
86         pFooter->AddActionEventListener(*this);
87
88         SetFormBackEventListener(this);
89 }
90
91 result
92 DisplayForm::OnInitializing(void)
93 {
94         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_DISPLAY"));
95         CreateTableView();
96
97         AppLogDebug("ENTER");
98
99         return E_SUCCESS;
100 }
101
102 result
103 DisplayForm::OnTerminating(void)
104 {
105         __pTableView = null;
106
107         SetFormBackEventListener(null);
108         return E_SUCCESS;
109 }
110
111 void
112 DisplayForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
113 {
114         __pTableView->UpdateTableView();
115
116         bool autoRotation = false;
117         if (SettingInfo::GetValue(SETTING_INFO_KEY_SCREEN_ROTAION_AUTO, autoRotation) == E_SUCCESS)
118         {
119                 __pTableView->SetItemChecked(ID_GROUP_AUTO_ROTATE_SCREEN, ID_ITEM_AUTO_ROTATE_SCREEN, autoRotation);
120         }
121
122         bool batteryPercentage = false;
123         if (SettingInfo::GetValue(SETTING_INFO_KEY_BATTERY_PERCENTAGE, batteryPercentage) == E_SUCCESS)
124         {
125                 __pTableView->SetItemChecked(ID_GROUP_BATTERY_PERCENTAGE, ID_ITEM_BATTERY_PERCENTAGE, batteryPercentage);
126         }
127
128         __pTableView->SetItemChecked(ID_GROUP_BACKLIGHT_TIME_LIST, GetBackLightTimeIndex(), true);
129         __pTableView->CollapseGroup(ID_GROUP_BACKLIGHT_TIME_LIST);
130 }
131
132 void
133 DisplayForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
134 {
135 }
136
137 void
138 DisplayForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
139 {
140         SceneManager* pSceneManager = SceneManager::GetInstance();
141         AppAssert(pSceneManager);
142
143         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
144 }
145
146 int
147 DisplayForm::GetGroupCount(void)
148 {
149         AppLogDebug("ENTER");
150         return ID_GROUP_COUNT;
151 }
152
153 int
154 DisplayForm::GetItemCount(int groupIndex)
155 {
156         int itemCount = ID_GROUP_DEFAULT_ITEM_COUNT;
157
158         if (groupIndex == ID_GROUP_BACKLIGHT_TIME_LIST)
159         {
160                 itemCount = ID_GROUP_BACKLIGHT_TIME_LIST_ITEM_COUNT;
161         }
162         else if (groupIndex == ID_GROUP_BATTERY_PERCENTAGE_HELP)
163         {
164                 itemCount = 0;
165         }
166         AppLogDebug("GetItemCount %d", itemCount);
167
168         return itemCount;
169 }
170
171 TableViewGroupItem*
172 DisplayForm::CreateGroupItem(int groupIndex, int itemWidth)
173 {
174         AppLogDebug("ENTER");
175
176         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
177         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
178         int fontSize = GetFontSize();
179         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
180         Rectangle itemMainRectangle;
181         String groupText;
182         Label* pLabel = null;
183
184         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
185
186         if (groupIndex == ID_GROUP_BATTERY_PERCENTAGE_HELP)
187         {
188                 style = LABEL_TEXT_STYLE_NORMAL;
189                 yItemOffset = 0;
190                 itemHeight = H_GROUP_INDEX_DEFAULT;
191                 groupText = ResourceManager::GetString(L"IDS_ST_BODY_SHOWS_BATTERY_PERCENTAGE_ON_INDICATOR");
192                 itemHeight = GetHeightForStringArea(groupText, itemWidth, fontSize);
193         }
194         else
195         {
196                 yItemOffset = 0;
197                 itemHeight = 0;
198         }
199
200         itemMainRectangle.x = X_GROUP_INDEX_DEFAULT_LABEL;
201         itemMainRectangle.y = yItemOffset;
202         itemMainRectangle.width = itemWidth;
203         itemMainRectangle.height = itemHeight;
204
205         RelativeLayout relativeLayout;
206         relativeLayout.Construct();
207
208         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
209         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
210
211         pLabel = new (std::nothrow) Label();
212         pLabel->Construct(itemMainRectangle, groupText);
213         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
214         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
215         pLabel->SetTextConfig(fontSize, style);
216         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
217
218         pItem->AddControl(pLabel);
219         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
220         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
221         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
222         pItem->SetEnabled(false);
223
224         return pItem;
225 }
226
227 TableViewItem*
228 DisplayForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
229 {
230         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
231
232         Rectangle itemMainRectangle;
233         Rectangle itemSubRectangle;
234         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
235         String itemMainText;
236         String subText;
237         Label* pLabel = null;
238         int fontSize = GetFontSize();
239         int leftMargin = 0;
240         int rightMargin = 0;
241         Rectangle detailArrow;
242         Bitmap* pBitmap = null;
243         int itemHeight = 0;
244         TableViewItem* pItem = new (std::nothrow) TableViewItem();
245
246         ItemTypeOneLine(itemMainRectangle);
247         itemHeight = itemMainRectangle.height;
248
249         switch (groupIndex)
250         {
251         case ID_GROUP_AUTO_ROTATE_SCREEN:
252                 {
253                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
254                         itemMainRectangle.width -= W_RESIZE_LABEL_GAP;
255                         itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_AUTO_ROTATE_SCREEN_ABB");
256                 }
257                 break;
258
259         case ID_GROUP_BACKLIGHT_TIME:
260                 {
261                         ItemTypeTwoLine(itemMainRectangle, itemSubRectangle,fontSize);
262                         itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
263
264                         pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_CLOSED);
265
266                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_BACKLIGHT_TIME");
267                         int index = GetBackLightTimeIndex();
268                         subText = GetBackLightTimeIndexString(index);
269                 }
270                 break;
271
272         case ID_GROUP_BACKLIGHT_TIME_LIST:
273                 {
274                         style = TABLE_VIEW_ANNEX_STYLE_RADIO;
275                         itemMainText = GetBackLightTimeIndexString(itemIndex);
276                 }
277                 break;
278
279         case ID_GROUP_FONT:
280                 {
281                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_FONT");
282                 }
283                 break;
284
285         case ID_GROUP_BATTERY_PERCENTAGE:
286                 {
287                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
288                         itemMainRectangle.width -= W_RESIZE_LABEL_GAP;
289                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_BATTERY_PERCENTAGE_ABB");
290                 }
291                 break;
292
293         default:
294                 break;
295         }
296
297         RelativeLayout relativeLayout;
298         relativeLayout.Construct();
299
300         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
301         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
302
303         pLabel = new (std::nothrow) Label();
304         pLabel->Construct(itemMainRectangle, itemMainText);
305         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
306         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
307         pLabel->SetTextColor(COLOR_MAIN_TEXT);
308         if (groupIndex == ID_GROUP_BACKLIGHT_TIME)
309         {
310                 pLabel->AddTouchEventListener(*this);
311         }
312
313         pItem->AddControl(pLabel);
314
315         switch (style)
316         {
317         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
318                 {
319                         rightMargin = RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING;
320                 }
321                 break;
322
323         case TABLE_VIEW_ANNEX_STYLE_RADIO:
324                 {
325                         leftMargin = RELATIVE_LAYOUT_LEFT_MARGIN;
326                         rightMargin = RELATIVE_LAYOUT_ITEM_RIGHT_MARGIN;
327                 }
328                 break;
329
330         default:
331                 {
332                         rightMargin = RELATIVE_LAYOUT_ITEM_RIGHT_MARGIN;
333                 }
334                 break;
335         }
336         relativeLayout.SetMargin(*pLabel, leftMargin, rightMargin, 0, 0);
337         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
338         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
339
340         if (pBitmap)
341         {
342                 detailArrow = itemMainRectangle;
343                 detailArrow.y = itemMainRectangle.y + ((itemHeight - W_DETAIL_ARROW_BUTTON) / DIVIDE_BY_TWO);
344                 detailArrow.height = W_DETAIL_ARROW_BUTTON;
345                 detailArrow.width = W_DETAIL_ARROW_BUTTON;
346
347                 pLabel = new (std::nothrow) Label();
348                 pLabel->Construct(detailArrow, L"");
349                 pLabel->AddTouchEventListener(*this);
350                 pLabel->SetBackgroundBitmap(*pBitmap);
351
352                 pItem->AddControl(pLabel);
353                 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_DETAIL_ARROW_BUTTON, 0, 0);
354                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
355
356                 __pLabel = new (std::nothrow) Label();
357                 __pLabel->Construct(itemSubRectangle, subText);
358                 __pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
359                 __pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
360                 __pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
361                 __pLabel->SetTextColor(COLOR_SUB_TEXT);
362                 __pLabel->AddTouchEventListener(*this);
363
364                 pItem->AddControl(__pLabel);
365                 relativeLayout.SetMargin(*__pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
366                 relativeLayout.SetRelation(*__pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
367                 relativeLayout.SetRelation(*__pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
368                 pItem->AddKeyEventListener(*this);
369                 pItem->AddFocusEventListener(*this);
370         }
371
372         return pItem;
373 }
374
375 bool
376 DisplayForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
377 {
378         AppLogDebug("ENTER");
379
380         delete pItem;
381         pItem = null;
382
383         return true;
384 }
385
386 bool
387 DisplayForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
388 {
389         AppLogDebug("ENTER");
390
391         delete pItem;
392         pItem = null;
393
394         return true;
395 }
396
397 void
398 DisplayForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
399 {
400         AppLogDebug("ENTER");
401         AppLogDebug("RequestFrom[%d]", requestId);
402         if (requestId == REFRESH_REQUEST_EVENT)
403         {
404                 int itemCount = __pTableView->GetItemCountAt(ID_GROUP_BACKLIGHT_TIME_LIST);
405                 bool autoRotation = false;
406                 if (SettingInfo::GetValue(SETTING_INFO_KEY_SCREEN_ROTAION_AUTO, autoRotation) == E_SUCCESS)
407                 {
408                         __pTableView->SetItemChecked(ID_GROUP_AUTO_ROTATE_SCREEN, ID_ITEM_AUTO_ROTATE_SCREEN, autoRotation);
409                 }
410
411                 bool batteryPercentage = false;
412                 if (SettingInfo::GetValue(SETTING_INFO_KEY_BATTERY_PERCENTAGE, batteryPercentage) == E_SUCCESS)
413                 {
414                         __pTableView->SetItemChecked(ID_GROUP_BATTERY_PERCENTAGE, ID_ITEM_BATTERY_PERCENTAGE, batteryPercentage);
415                 }
416
417                 for (int index = 0; index < itemCount; index++)
418                 {
419                         if (index == GetBackLightTimeIndex())
420                         {
421                                 __pTableView->SetItemChecked(ID_GROUP_BACKLIGHT_TIME_LIST, index, true);
422                         }
423                         else
424                         {
425                                 __pTableView->SetItemChecked(ID_GROUP_BACKLIGHT_TIME_LIST, index, false);
426                         }
427                 }
428                 __pTableView->RefreshItem(ID_GROUP_BACKLIGHT_TIME, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
429                 __pTableView->RefreshItem(ID_GROUP_BACKLIGHT_TIME, 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
430         }
431 }
432
433 void
434 DisplayForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
435 {
436         SceneManager* pSceneManager = SceneManager::GetInstance();
437         AppAssert(pSceneManager);
438
439         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
440
441         switch (groupIndex)
442         {
443         case ID_GROUP_AUTO_ROTATE_SCREEN:
444                 {
445                         bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
446
447                         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
448                         {
449                                 itemSelectStatus = !itemSelectStatus;
450                         }
451
452                         if (SettingInfo::SetValue(SETTING_INFO_KEY_SCREEN_ROTAION_AUTO, itemSelectStatus) == E_SUCCESS)
453                         {
454                                 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
455                         }
456                 }
457                 break;
458
459         case ID_GROUP_BACKLIGHT_TIME:
460                 {
461                         if (tableView.IsGroupExpanded(ID_GROUP_BACKLIGHT_TIME_LIST) == true)
462                         {
463                                 tableView.CollapseGroup(ID_GROUP_BACKLIGHT_TIME_LIST);
464                         }
465                         else
466                         {
467                                 tableView.ExpandGroup(ID_GROUP_BACKLIGHT_TIME_LIST);
468                         }
469                         tableView.RefreshItem(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
470                 }
471                 break;
472
473         case ID_GROUP_BACKLIGHT_TIME_LIST:
474                 {
475                         SetBackLightTime(itemIndex);
476
477                         int itemCount = tableView.GetItemCountAt(groupIndex);
478
479                         for (int index = 0; index < itemCount; index++)
480                         {
481                                 if (index == itemIndex)
482                                 {
483                                         tableView.SetItemChecked(groupIndex, index, true);
484                                 }
485                                 else
486                                 {
487                                         tableView.SetItemChecked(groupIndex, index, false);
488                                 }
489                         }
490                         tableView.RefreshItem(ID_GROUP_BACKLIGHT_TIME, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
491                 }
492                 break;
493
494         case ID_GROUP_FONT:
495                 {
496                         SceneManager* pSceneManager = SceneManager::GetInstance();
497                         AppAssert(pSceneManager);
498
499                         __pTableView->CollapseGroup(ID_GROUP_BACKLIGHT_TIME_LIST);
500                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FONT, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
501                 }
502                 break;
503
504         case ID_GROUP_BATTERY_PERCENTAGE:
505                 {
506                         bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
507
508                         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
509                         {
510                                 itemSelectStatus = !itemSelectStatus;
511                         }
512
513                         if (SettingInfo::SetValue(SETTING_INFO_KEY_BATTERY_PERCENTAGE, itemSelectStatus) == E_SUCCESS)
514                         {
515                                 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
516                         }
517                 }
518                 break;
519
520         default:
521                 break;
522         }
523 }
524
525 int
526 DisplayForm::GetDefaultGroupItemHeight(void)
527 {
528         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
529 }
530
531 int
532 DisplayForm::GetDefaultItemHeight(void)
533 {
534         return H_GROUP_ITEM_DEFAULT;
535 }
536
537 void
538 DisplayForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
539 {
540         AppLog("ENTER");
541         BaseForm::OnOrientationChanged(source, orientationStatus);
542         __pTableView->UpdateTableView();
543 }
544
545 void
546 DisplayForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
547 {
548 }
549
550 void
551 DisplayForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
552 {
553         int index = 0;
554         String itemMainText;
555         String itemSubText;
556         Label* pSubLabel = null;
557
558         switch (groupIndex)
559         {
560         case ID_GROUP_FONT:
561                 //fall through
562         case ID_GROUP_AUTO_ROTATE_SCREEN:
563                 //fall through
564         case ID_GROUP_BATTERY_PERCENTAGE:
565                 //fall through
566         case ID_GROUP_BACKLIGHT_TIME_LIST:
567                 {
568                         int fontSize = GetFontSize();
569                         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
570
571                         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
572                         pLabel->Invalidate(false);
573                 }
574                 break;
575
576         case ID_GROUP_BACKLIGHT_TIME:
577                 {
578                         Bitmap* pBitmap = null;
579                         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
580                         Label* pLabelBitmap = static_cast<Label*>(pItem->GetControl(1));
581                         pSubLabel = static_cast<Label*>(pItem->GetControl(2));
582
583                         int fontSize = GetFontSize();
584                         Rectangle mainRectangle;
585                         Rectangle subRectangle;
586                         Rectangle pItemRectangle;
587                         Rectangle detailArrow;
588
589                         pItemRectangle = pItem->GetBounds();
590                         ItemTypeTwoLine(mainRectangle, subRectangle, fontSize);
591
592                         pLabel->SetBounds(mainRectangle);
593                         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
594
595                         pItemRectangle.height = (mainRectangle.height + subRectangle.height);
596                         pItem->SetBounds(pItemRectangle);
597
598                         if (__pTableView->IsGroupExpanded(ID_GROUP_BACKLIGHT_TIME_LIST))
599                         {
600                                 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_OPENED);
601                         }
602                         else
603                         {
604                                 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_CLOSED);
605                         }
606                         pLabelBitmap->SetBackgroundBitmap(*pBitmap);
607
608                         detailArrow = mainRectangle;
609                         detailArrow.y = mainRectangle.y + ((pItemRectangle.height - W_DETAIL_ARROW_BUTTON) / DIVIDE_BY_TWO);
610                         detailArrow.height = W_DETAIL_ARROW_BUTTON;
611                         detailArrow.width = W_DETAIL_ARROW_BUTTON;
612                         pLabelBitmap->SetBounds(detailArrow);
613
614                         index = GetBackLightTimeIndex();
615                         itemSubText = GetBackLightTimeIndexString(index);
616                         pSubLabel->SetBounds(subRectangle);
617                         pSubLabel->SetText(itemSubText);
618                         pSubLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
619
620                         pLabel->Invalidate(false);
621                         pLabelBitmap->Invalidate(false);
622                         pSubLabel->Invalidate(false);
623                         pItem->Invalidate(false);
624                 }
625                 break;
626         }
627
628         Invalidate(true);
629 }
630
631 void
632 DisplayForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
633 {
634 }
635
636 void
637 DisplayForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
638 {
639 }
640
641 int
642 DisplayForm::GetBackLightTime(void)
643 {
644         int backlightTime = 0;
645
646         result r = SettingInfo::GetValue(SETTING_INFO_KEY_BACKLIGHT_TIME, backlightTime);
647         if (IsFailed(r))
648         {
649                 AppLogDebug("GetValue Backlight Time fail [%s]", GetErrorMessage(r));
650         }
651         return backlightTime;
652 }
653
654 void
655 DisplayForm::SetBackLightTime(int itemIndex)
656 {
657         int backlightTime = 0;
658         switch (itemIndex)
659         {
660         case ID_ITEM_BACKLIGHT_TIME_15_SECONDS:
661                 {
662                         backlightTime = BACKLIGHT_TIME_15_SECONDS;
663                 }
664                 break;
665
666         case ID_ITEM_BACKLIGHT_TIME_30_SECONDS:
667                 {
668                         backlightTime = BACKLIGHT_TIME_30_SECONDS;
669                 }
670                 break;
671
672         case ID_ITEM_BACKLIGHT_TIME_1_MINUTE:
673                 {
674                         backlightTime = BACKLIGHT_TIME_1_MINUTE;
675                 }
676                 break;
677
678         case ID_ITEM_BACKLIGHT_TIME_2_MINUTES:
679                 {
680                         backlightTime = BACKLIGHT_TIME_2_MINUTES;
681                 }
682                 break;
683
684         case ID_ITEM_BACKLIGHT_TIME_5_MINUTES:
685                 {
686                         backlightTime = BACKLIGHT_TIME_5_MINUTES;
687                 }
688                 break;
689
690         case ID_ITEM_BACKLIGHT_TIME_10_MINUTES:
691                 {
692                         backlightTime = BACKLIGHT_TIME_10_MINUTES;
693                 }
694                 break;
695         }
696
697         result r = SettingInfo::SetValue(SETTING_INFO_KEY_BACKLIGHT_TIME, backlightTime);
698         if (IsFailed(r))
699         {
700                 AppLogDebug("SetValue Backlight Time fail [%s]", GetErrorMessage(r));
701         }
702 }
703
704 int
705 DisplayForm::GetBackLightTimeIndex(void)
706 {
707         int itemIndex = 0;
708         int backlightTime = GetBackLightTime();
709
710         switch (backlightTime)
711         {
712         case BACKLIGHT_TIME_15_SECONDS:
713                 {
714                         itemIndex = ID_ITEM_BACKLIGHT_TIME_15_SECONDS;
715                 }
716                 break;
717
718         case BACKLIGHT_TIME_30_SECONDS:
719                 {
720                         itemIndex = ID_ITEM_BACKLIGHT_TIME_30_SECONDS;
721                 }
722                 break;
723
724         case BACKLIGHT_TIME_1_MINUTE:
725                 {
726                         itemIndex = ID_ITEM_BACKLIGHT_TIME_1_MINUTE;
727                 }
728                 break;
729
730         case BACKLIGHT_TIME_2_MINUTES:
731                 {
732                         itemIndex = ID_ITEM_BACKLIGHT_TIME_2_MINUTES;
733                 }
734                 break;
735
736         case BACKLIGHT_TIME_5_MINUTES:
737                 {
738                         itemIndex = ID_ITEM_BACKLIGHT_TIME_5_MINUTES;
739                 }
740                 break;
741
742         case BACKLIGHT_TIME_10_MINUTES:
743                 {
744                         itemIndex = ID_ITEM_BACKLIGHT_TIME_10_MINUTES;
745                 }
746                 break;
747         }
748
749         return itemIndex;
750 }
751
752 Tizen::Base::String
753 DisplayForm::GetBackLightTimeIndexString(int itemIndex)
754 {
755         String itemText;
756
757         switch (itemIndex)
758         {
759         case ID_ITEM_BACKLIGHT_TIME_15_SECONDS:
760                 {
761                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_15_SECONDS");
762                 }
763                 break;
764
765         case ID_ITEM_BACKLIGHT_TIME_30_SECONDS:
766                 {
767                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_30_SECONDS");
768                 }
769                 break;
770
771         case ID_ITEM_BACKLIGHT_TIME_1_MINUTE:
772                 {
773                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_1_MINUTE");
774                 }
775                 break;
776
777         case ID_ITEM_BACKLIGHT_TIME_2_MINUTES:
778                 {
779                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_2_MINUTES");
780                 }
781                 break;
782
783         case ID_ITEM_BACKLIGHT_TIME_5_MINUTES:
784                 {
785                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_5_MINUTES");
786                 }
787                 break;
788
789         case ID_ITEM_BACKLIGHT_TIME_10_MINUTES:
790                 {
791                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_10_MINUTES");
792                 }
793                 break;
794         }
795
796         return itemText;
797 }
798
799 void
800 DisplayForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
801 {
802         __pLabel->SetTextColor(COLOR_SUB_TEXT);
803         __pLabel->Invalidate(false);
804 }
805
806 void
807 DisplayForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
808 {
809         __pLabel->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
810         __pLabel->Invalidate(false);
811 }
812
813 void
814 DisplayForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
815 {
816         __pLabel->SetTextColor(COLOR_SUB_TEXT);
817         __pLabel->Invalidate(false);
818 }
819
820 void
821 DisplayForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
822 {
823         __pLabel->SetTextColor(COLOR_SUB_TEXT);
824         __pLabel->Invalidate(false);
825 }
826
827 void
828 DisplayForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
829 {
830         AppLog("Enter");
831         if(keyCode == KEY_ENTER)
832         {
833                 AppLog("Enter");
834                 __pLabel->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
835                 __pLabel->Invalidate(false);
836         }
837 }
838
839 void
840 DisplayForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
841 {
842         AppLog("Enter");
843         if(keyCode == KEY_ENTER)
844         {
845                 AppLog("Enter");
846                 __pLabel->SetTextColor(COLOR_SUB_TEXT);
847                 __pLabel->Invalidate(false);
848         }
849 }
850
851 void
852 DisplayForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
853 {
854 }
855
856 void
857 DisplayForm::OnFocusLost(const Tizen::Ui::Control& source)
858 {
859         AppLog("Enter");
860         __pLabel->SetTextColor(COLOR_SUB_TEXT);
861         __pLabel->Invalidate(false);
862 }
863
864 void
865 DisplayForm::OnFocusGained(const Tizen::Ui::Control& source)
866 {
867         AppLog("Enter");
868 }