28e47d7ad9783633e1b6a7269e8f19817d8085d5
[apps/osp/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 static const int ID_ITEM_BACKLIGHT_TIME = 0;
50
51 static const int ID_GROUP_BACKLIGHT_TIME_LIST = 2;
52 static const int ID_GROUP_BACKLIGHT_TIME_LIST_ITEM_COUNT = 6;
53 static const int ID_ITEM_BACKLIGHT_TIME_15_SECONDS = 0;
54 static const int ID_ITEM_BACKLIGHT_TIME_30_SECONDS = 1;
55 static const int ID_ITEM_BACKLIGHT_TIME_1_MINUTE = 2;
56 static const int ID_ITEM_BACKLIGHT_TIME_2_MINUTES = 3;
57 static const int ID_ITEM_BACKLIGHT_TIME_5_MINUTES = 4;
58 static const int ID_ITEM_BACKLIGHT_TIME_10_MINUTES = 5;
59
60 static const int ID_GROUP_FONT = 3;
61 static const int ID_ITEM_FONT = 0;
62
63 static const int ID_GROUP_DISPLAY_MAX_COUNT = 6;
64 static const int ID_GROUP_DEFAULT_ITEM_COUNT = 1;
65
66 static const int ID_GROUP_COUNT = 4;
67 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_DISPLAY_MAX_COUNT;
68
69 DisplayForm::DisplayForm(void)
70 {
71 }
72
73 DisplayForm::~DisplayForm(void)
74 {
75 }
76
77 void
78 DisplayForm::CreateFooter(void)
79 {
80         Footer* pFooter = GetFooter();
81         AppAssert(pFooter);
82
83         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
84         pFooter->SetBackButton();
85         pFooter->AddActionEventListener(*this);
86
87         SetFormBackEventListener(this);
88 }
89
90 result
91 DisplayForm::OnInitializing(void)
92 {
93         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_DISPLAY"));
94         CreateFooter();
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         if (previousSceneId == IDSCN_FONT)
115         {
116                 __pTableView->RefreshAllItems();
117                 return;
118         }
119         __pTableView->UpdateTableView();
120
121         bool autoRotation = false;
122         if (SettingInfo::GetValue(SETTING_INFO_KEY_SCREEN_ROTAION_AUTO, autoRotation) == E_SUCCESS)
123         {
124                 __pTableView->SetItemChecked(ID_GROUP_AUTO_ROTATE_SCREEN, ID_ITEM_AUTO_ROTATE_SCREEN, autoRotation);
125         }
126         __pTableView->SetItemChecked(ID_GROUP_BACKLIGHT_TIME_LIST, GetBackLightTimeIndex(), true);
127         __pTableView->CollapseGroup(ID_GROUP_BACKLIGHT_TIME_LIST);
128 }
129
130 void
131 DisplayForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
132 {
133 }
134
135 void
136 DisplayForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
137 {
138         SceneManager* pSceneManager = SceneManager::GetInstance();
139         AppAssert(pSceneManager);
140
141         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
142 }
143
144 int
145 DisplayForm::GetGroupCount(void)
146 {
147         AppLogDebug("ENTER");
148         return ID_GROUP_COUNT;
149 }
150
151 int
152 DisplayForm::GetItemCount(int groupIndex)
153 {
154         int itemCount = ID_GROUP_DEFAULT_ITEM_COUNT;
155
156         if (groupIndex == ID_GROUP_BACKLIGHT_TIME_LIST)
157         {
158                 itemCount = ID_GROUP_BACKLIGHT_TIME_LIST_ITEM_COUNT;
159         }
160         AppLogDebug("GetItemCount %d", itemCount);
161
162         return itemCount;
163 }
164
165 TableViewGroupItem*
166 DisplayForm::CreateGroupItem(int groupIndex, int itemWidth)
167 {
168         AppLogDebug("ENTER");
169
170         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
171         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
172         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
173         Rectangle itemMainRectangle;
174         String groupText;
175         Label* pLabel = null;
176
177         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
178
179         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
180         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
181
182         if (groupIndex == ID_GROUP_BACKLIGHT_TIME_LIST)
183         {
184                 yItemOffset = 0;
185                 itemHeight = 0;
186         }
187
188         itemMainRectangle.x = X_GROUP_INDEX_DEFAULT_LABEL;
189         itemMainRectangle.y = yItemOffset;
190         itemMainRectangle.width = itemWidth;
191         itemMainRectangle.height = itemHeight;
192
193         RelativeLayout relativeLayout;
194         relativeLayout.Construct();
195
196         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
197         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
198
199         pLabel = new (std::nothrow) Label();
200         pLabel->Construct(itemMainRectangle, groupText);
201         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
202         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
203         pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
204         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
205
206         pItem->AddControl(pLabel);
207         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
208         relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
209         relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
210         pItem->SetEnabled(false);
211
212         return pItem;
213 }
214
215 TableViewItem*
216 DisplayForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
217 {
218         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
219
220         Rectangle itemMainRectangle;
221         Rectangle itemSubRectangle;
222         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
223         String itemMainText;
224         String subText;
225         Label* pLabel = null;
226         int fontSize = GetFontSize();
227         int leftMargin = 0;
228         int rightMargin = 0;
229         Rectangle detailArrow;
230         Bitmap* pBitmap = null;
231         int itemHeight = 0;
232         TableViewItem* pItem = new (std::nothrow) TableViewItem();
233
234         ItemTypeOneLine(itemMainRectangle);
235         itemHeight = itemMainRectangle.height;
236
237         switch (groupIndex)
238         {
239         case ID_GROUP_AUTO_ROTATE_SCREEN:
240                 {
241                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
242                         itemMainRectangle.width -= W_RESIZE_LABEL_GAP;
243                         itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_AUTO_ROTATE_SCREEN_ABB");
244                 }
245                 break;
246
247         case ID_GROUP_BACKLIGHT_TIME:
248                 {
249                         ItemTypeTwoLine(itemMainRectangle, itemSubRectangle,fontSize);
250                         itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
251
252                         if (__pTableView->IsGroupExpanded(ID_GROUP_BACKLIGHT_TIME_LIST) == false)
253                         {
254                                 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_OPENED);
255                         }
256                         else
257                         {
258                                 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_CLOSED);
259                         }
260
261                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_BACKLIGHT_TIME");
262                         int index = GetBackLightTimeIndex();
263                         subText = GetBackLightTimeIndexString(index);
264                 }
265                 break;
266
267         case ID_GROUP_BACKLIGHT_TIME_LIST:
268                 {
269                         style = TABLE_VIEW_ANNEX_STYLE_RADIO;
270                         itemMainText = GetBackLightTimeIndexString(itemIndex);
271                 }
272                 break;
273
274         case ID_GROUP_FONT:
275                 {
276                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_FONT");
277                 }
278                 break;
279
280         default:
281                 break;
282         }
283
284         RelativeLayout relativeLayout;
285         relativeLayout.Construct();
286
287         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
288         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
289
290         pLabel = new (std::nothrow) Label();
291         pLabel->Construct(itemMainRectangle, itemMainText);
292         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
293         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
294         pLabel->SetTextColor(COLOR_MAIN_TEXT);
295
296         pItem->AddControl(pLabel);
297
298         switch (style)
299         {
300         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
301                 {
302                         rightMargin = RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING;
303                 }
304                 break;
305
306         case TABLE_VIEW_ANNEX_STYLE_RADIO:
307                 {
308                         leftMargin = RELATIVE_LAYOUT_LEFT_MARGIN;
309                         rightMargin = RELATIVE_LAYOUT_ITEM_RIGHT_MARGIN;
310                 }
311                 break;
312
313         default:
314                 {
315                         rightMargin = RELATIVE_LAYOUT_ITEM_RIGHT_MARGIN;
316                 }
317                 break;
318         }
319         relativeLayout.SetMargin(*pLabel, leftMargin, rightMargin, 0, 0);
320         relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
321         relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
322
323         if (pBitmap)
324         {
325                 detailArrow = itemMainRectangle;
326                 detailArrow.y = itemMainRectangle.y + ((itemHeight - W_DETAIL_ARROW_BUTTON) / DIVIDE_BY_TWO);
327                 detailArrow.height = W_DETAIL_ARROW_BUTTON;
328                 detailArrow.width = W_DETAIL_ARROW_BUTTON;
329
330                 pLabel = new (std::nothrow) Label();
331                 pLabel->Construct(detailArrow, L"");
332
333                 pLabel->SetBackgroundBitmap(*pBitmap);
334
335                 pItem->AddControl(pLabel);
336                 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_DETAIL_ARROW_BUTTON, 0, 0);
337                 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
338
339                 pLabel = new (std::nothrow) Label();
340                 pLabel->Construct(itemSubRectangle, subText);
341                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
342                 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
343                 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
344                 pLabel->SetTextColor(COLOR_SUB_TEXT);
345
346                 pItem->AddControl(pLabel);
347                 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
348                 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
349                 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
350         }
351
352         return pItem;
353 }
354
355 bool
356 DisplayForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
357 {
358         AppLogDebug("ENTER");
359
360         delete pItem;
361         pItem = null;
362
363         return true;
364 }
365
366 bool
367 DisplayForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
368 {
369         AppLogDebug("ENTER");
370
371         delete pItem;
372         pItem = null;
373
374         return true;
375 }
376
377 void
378 DisplayForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
379 {
380         AppLogDebug("ENTER");
381         AppLogDebug("RequestFrom[%d]", requestId);
382         if (requestId == FRFRESH_REQUEST_EVENT)
383         {
384                 int itemCount = __pTableView->GetItemCountAt(ID_GROUP_BACKLIGHT_TIME_LIST);
385
386                 for (int index = 0; index < itemCount; index++)
387                 {
388                         if (index == GetBackLightTimeIndex())
389                         {
390                                 __pTableView->SetItemChecked(ID_GROUP_BACKLIGHT_TIME_LIST, index, true);
391                         }
392                         else
393                         {
394                                 __pTableView->SetItemChecked(ID_GROUP_BACKLIGHT_TIME_LIST, index, false);
395                         }
396                 }
397                 __pTableView->UpdateTableView();
398         }
399 }
400
401 void
402 DisplayForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
403 {
404         SceneManager* pSceneManager = SceneManager::GetInstance();
405         AppAssert(pSceneManager);
406
407         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
408
409         switch (groupIndex)
410         {
411         case ID_GROUP_AUTO_ROTATE_SCREEN:
412                 {
413                         bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
414
415                         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
416                         {
417                                 itemSelectStatus = !itemSelectStatus;
418                         }
419
420                         if (SettingInfo::SetValue(SETTING_INFO_KEY_SCREEN_ROTAION_AUTO, itemSelectStatus) == E_SUCCESS)
421                         {
422                                 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
423                         }
424                 }
425                 break;
426
427         case ID_GROUP_BACKLIGHT_TIME:
428                 {
429                         if (tableView.IsGroupExpanded(ID_GROUP_BACKLIGHT_TIME_LIST) == true)
430                         {
431                                 tableView.CollapseGroup(ID_GROUP_BACKLIGHT_TIME_LIST);
432                         }
433                         else
434                         {
435                                 tableView.ExpandGroup(ID_GROUP_BACKLIGHT_TIME_LIST);
436                         }
437                         tableView.RefreshItem(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
438                 }
439                 break;
440
441         case ID_GROUP_BACKLIGHT_TIME_LIST:
442                 {
443                         SetBackLightTime(itemIndex);
444
445                         int itemCount = tableView.GetItemCountAt(groupIndex);
446
447                         for (int index = 0; index < itemCount; index++)
448                         {
449                                 if (index == itemIndex)
450                                 {
451                                         tableView.SetItemChecked(groupIndex, index, true);
452                                 }
453                                 else
454                                 {
455                                         tableView.SetItemChecked(groupIndex, index, false);
456                                 }
457                         }
458                         tableView.RefreshItem(ID_GROUP_BACKLIGHT_TIME, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
459                 }
460                 break;
461
462         case ID_GROUP_FONT:
463                 {
464                         SceneManager* pSceneManager = SceneManager::GetInstance();
465                         AppAssert(pSceneManager);
466
467                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FONT, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
468                 }
469                 break;
470
471         default:
472                 break;
473         }
474 }
475
476 int
477 DisplayForm::GetDefaultGroupItemHeight(void)
478 {
479         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
480 }
481
482 int
483 DisplayForm::GetDefaultItemHeight(void)
484 {
485         return H_GROUP_ITEM_DEFAULT;
486 }
487
488 void
489 DisplayForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
490 {
491 }
492
493 void
494 DisplayForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
495 {
496         int index = 0;
497         String itemMainText;
498         String itemSubText;
499         Label* pSubLabel = null;
500
501         switch (groupIndex)
502         {
503         case ID_GROUP_FONT:
504                 //fall through
505         case ID_GROUP_AUTO_ROTATE_SCREEN:
506                 //fall through
507         case ID_GROUP_BACKLIGHT_TIME_LIST:
508                 {
509                         int fontSize = GetFontSize();
510                         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
511
512                         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
513                         pLabel->Invalidate(false);
514                 }
515                 break;
516
517         case ID_GROUP_BACKLIGHT_TIME:
518                 {
519                         Bitmap* pBitmap = null;
520                         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
521                         Label* pLabelBitmap = static_cast<Label*>(pItem->GetControl(1));
522                         pSubLabel = static_cast<Label*>(pItem->GetControl(2));
523
524                         int fontSize = GetFontSize();
525                         Rectangle mainRectangle;
526                         Rectangle subRectangle;
527                         Rectangle pItemRectangle;
528                         Rectangle detailArrow;
529
530                         pItemRectangle = pItem->GetBounds();
531                         ItemTypeTwoLine(mainRectangle, subRectangle, fontSize);
532
533                         pLabel->SetBounds(mainRectangle);
534                         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
535
536                         pItemRectangle.height = (mainRectangle.height + subRectangle.height);
537                         pItem->SetBounds(pItemRectangle);
538
539                         if (__pTableView->IsGroupExpanded(ID_GROUP_BACKLIGHT_TIME_LIST))
540                         {
541                                 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_OPENED);
542                         }
543                         else
544                         {
545                                 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_CLOSED);
546                         }
547                         pLabelBitmap->SetBackgroundBitmap(*pBitmap);
548
549                         detailArrow = mainRectangle;
550                         detailArrow.y = mainRectangle.y + ((pItemRectangle.height - W_DETAIL_ARROW_BUTTON) / DIVIDE_BY_TWO);
551                         detailArrow.height = W_DETAIL_ARROW_BUTTON;
552                         detailArrow.width = W_DETAIL_ARROW_BUTTON;
553                         pLabelBitmap->SetBounds(detailArrow);
554
555                         index = GetBackLightTimeIndex();
556                         itemSubText = GetBackLightTimeIndexString(index);
557                         pSubLabel->SetBounds(subRectangle);
558                         pSubLabel->SetText(itemSubText);
559                         pSubLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
560
561                         pLabel->Invalidate(false);
562                         pLabelBitmap->Invalidate(false);
563                         pSubLabel->Invalidate(false);
564                         pItem->Invalidate(false);
565                 }
566                 break;
567         }
568
569         Invalidate(true);
570 }
571
572 void
573 DisplayForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
574 {
575 }
576
577 void
578 DisplayForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
579 {
580 }
581
582 int
583 DisplayForm::GetBackLightTime(void)
584 {
585         int backlightTime = 0;
586
587         result r = SettingInfo::GetValue(SETTING_INFO_KEY_BACKLIGHT_TIME, backlightTime);
588         if (IsFailed(r))
589         {
590                 AppLogDebug("GetValue Backlight Time fail [%s]", GetErrorMessage(r));
591         }
592         return backlightTime;
593 }
594
595 void
596 DisplayForm::SetBackLightTime(int itemIndex)
597 {
598         int backlightTime = 0;
599         switch (itemIndex)
600         {
601         case ID_ITEM_BACKLIGHT_TIME_15_SECONDS:
602                 {
603                         backlightTime = BACKLIGHT_TIME_15_SECONDS;
604                 }
605                 break;
606
607         case ID_ITEM_BACKLIGHT_TIME_30_SECONDS:
608                 {
609                         backlightTime = BACKLIGHT_TIME_30_SECONDS;
610                 }
611                 break;
612
613         case ID_ITEM_BACKLIGHT_TIME_1_MINUTE:
614                 {
615                         backlightTime = BACKLIGHT_TIME_1_MINUTE;
616                 }
617                 break;
618
619         case ID_ITEM_BACKLIGHT_TIME_2_MINUTES:
620                 {
621                         backlightTime = BACKLIGHT_TIME_2_MINUTES;
622                 }
623                 break;
624
625         case ID_ITEM_BACKLIGHT_TIME_5_MINUTES:
626                 {
627                         backlightTime = BACKLIGHT_TIME_5_MINUTES;
628                 }
629                 break;
630
631         case ID_ITEM_BACKLIGHT_TIME_10_MINUTES:
632                 {
633                         backlightTime = BACKLIGHT_TIME_10_MINUTES;
634                 }
635                 break;
636         }
637
638         result r = SettingInfo::SetValue(SETTING_INFO_KEY_BACKLIGHT_TIME, backlightTime);
639         if (IsFailed(r))
640         {
641                 AppLogDebug("SetValue Backlight Time fail [%s]", GetErrorMessage(r));
642         }
643 }
644
645 int
646 DisplayForm::GetBackLightTimeIndex(void)
647 {
648         int itemIndex = 0;
649         int backlightTime = GetBackLightTime();
650
651         switch (backlightTime)
652         {
653         case BACKLIGHT_TIME_15_SECONDS:
654                 {
655                         itemIndex = ID_ITEM_BACKLIGHT_TIME_15_SECONDS;
656                 }
657                 break;
658
659         case BACKLIGHT_TIME_30_SECONDS:
660                 {
661                         itemIndex = ID_ITEM_BACKLIGHT_TIME_30_SECONDS;
662                 }
663                 break;
664
665         case BACKLIGHT_TIME_1_MINUTE:
666                 {
667                         itemIndex = ID_ITEM_BACKLIGHT_TIME_1_MINUTE;
668                 }
669                 break;
670
671         case BACKLIGHT_TIME_2_MINUTES:
672                 {
673                         itemIndex = ID_ITEM_BACKLIGHT_TIME_2_MINUTES;
674                 }
675                 break;
676
677         case BACKLIGHT_TIME_5_MINUTES:
678                 {
679                         itemIndex = ID_ITEM_BACKLIGHT_TIME_5_MINUTES;
680                 }
681                 break;
682
683         case BACKLIGHT_TIME_10_MINUTES:
684                 {
685                         itemIndex = ID_ITEM_BACKLIGHT_TIME_10_MINUTES;
686                 }
687                 break;
688         }
689
690         return itemIndex;
691 }
692
693 Tizen::Base::String
694 DisplayForm::GetBackLightTimeIndexString(int itemIndex)
695 {
696         String itemText;
697
698         switch (itemIndex)
699         {
700         case ID_ITEM_BACKLIGHT_TIME_15_SECONDS:
701                 {
702                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_15_SECONDS");
703                 }
704                 break;
705
706         case ID_ITEM_BACKLIGHT_TIME_30_SECONDS:
707                 {
708                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_30_SECONDS");
709                 }
710                 break;
711
712         case ID_ITEM_BACKLIGHT_TIME_1_MINUTE:
713                 {
714                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_1_MINUTE");
715                 }
716                 break;
717
718         case ID_ITEM_BACKLIGHT_TIME_2_MINUTES:
719                 {
720                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_2_MINUTES");
721                 }
722                 break;
723
724         case ID_ITEM_BACKLIGHT_TIME_5_MINUTES:
725                 {
726                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_5_MINUTES");
727                 }
728                 break;
729
730         case ID_ITEM_BACKLIGHT_TIME_10_MINUTES:
731                 {
732                         itemText = ResourceManager::GetString(L"IDS_ST_BODY_10_MINUTES");
733                 }
734                 break;
735         }
736
737         return itemText;
738 }