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