Fixed jira issues : N_SE-56423, N_SE-56330, N_SE-56326
[apps/osp/MusicPlayer.git] / src / MpSettingForm.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                MpSettingForm.cpp
19  * @brief               This is the implementation file for SettingForm class.
20  */
21
22 #include <FApp.h>
23 #include <FBase.h>
24 #include <FUi.h>
25 #include <FUiScenes.h>
26 #include "MpAllListPresentationModel.h"
27 #include "MpNowPlayContentPanel.h"
28 #include "MpSceneRegister.h"
29 #include "MpSettingForm.h"
30 #include "MpSettingPresentationModel.h"
31 #include "MpTypes.h"
32
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
40
41 static const int SETTING_ITEM_HEIGHT = 115;
42
43 static const int ID_MAIN_DEFAULT_PLAYLIST_ITEM = 1;
44 static const int ID_SUB_MOST_PLAYED_ITEM = 0;
45 static const int ID_SUB_RECENTLY_PLAYED_ITEM = 1;
46 static const int ID_SUB_RECENTLY_ADD_ITEM = 2;
47
48 static const int ID_MAIN_AUTO_OFF_ITEM = 0;
49 static const int ID_SUB_ZERO_ITEM = 0;
50 static const int ID_SUB_FIFTEEN_ITEM = 1;
51 static const int ID_SUB_THIRTY_ITEM = 2;
52 static const int ID_SUB_ONE_HOUR_ITEM = 3;
53 static const int ID_SUB_ONE_HOUR_THIRTY_ITEM = 4;
54 static const int ID_SUB_TWO_HOURS_ITEM = 5;
55
56 static const int ID_MAIN_DEFAULT_PLAYLIST_ITEM_COUNT = 3;
57 static const int ID_MAIN_AUTO_OFF_ITEM_COUNT = 6;
58 static const unsigned int COLOR_SUB_TEXT_SETTINGS = Color32<42, 137, 194>::Value;
59
60 SettingForm::SettingForm(void)
61         : __pSettingPresentationModel(null)
62         , __pSettingTableView(null)
63 {
64         AppLogDebug("ENTER");
65         AppLogDebug("EXIT");
66 }
67
68 SettingForm::~SettingForm(void)
69 {
70         AppLogDebug("ENTER");
71         AppLogDebug("EXIT");
72 }
73
74 void
75 SettingForm::Initialize(void)
76 {
77         AppLogDebug("ENTER");
78         Construct(IDL_SETTING_FORM);
79         AppLogDebug("EXIT");
80 }
81
82 result
83 SettingForm::OnInitializing(void)
84 {
85         AppLogDebug("ENTER");
86         result r = E_SUCCESS;
87         SetFormBackEventListener(this);
88
89         __pSettingTableView = static_cast<GroupedTableView*>(GetControl(IDC_GROUPEDTABLEVIEW_CONTENT_LIST));
90         __pSettingTableView->SetItemProvider(this);
91         __pSettingTableView->AddGroupedTableViewItemEventListener(*this);
92
93         __pSettingPresentationModel = SettingPresentationModel::GetInstance();
94 //      __pSettingPresentationModel->InitializeSettingValue();
95         __pPresentationModel = AllListPresentationModel::GetInstance();
96         __pSettingTableView->UpdateTableView();
97         __pSettingTableView->CollapseAllGroup();
98 //      for (int itemIndex = 0; itemIndex < ID_MAIN_DEFAULT_PLAYLIST_ITEM_COUNT; itemIndex++)
99 //      {
100 //              __pSettingTableView->SetItemChecked(0, itemIndex, __pSettingPresentationModel->IsTabEnable(itemIndex));
101 //      }
102         __pSettingTableView->SetItemChecked(ID_MAIN_AUTO_OFF_ITEM, __pSettingPresentationModel->GetAutoOffTime(), true);
103
104         Invalidate(true);
105         AppLogDebug("EXIT");
106         return r;
107 }
108
109 result
110 SettingForm::OnTerminating(void)
111 {
112         AppLogDebug("ENTER");
113         result r = E_SUCCESS;
114
115         /*Frame* pFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
116         Form* pForm = static_cast<Form*>(pFrame->GetControl(CONTENT_FORM_REQUSEST_ID));
117         if (pForm != null)
118         {
119                 AppLogDebug("AForm");
120                 pForm->SendUserEvent(0, null);
121         }*/
122 //      __pSettingPresentationModel->DestroySettingPresentationModel();
123
124         AppLogDebug("EXIT");
125         return r;
126 }
127
128 int
129 SettingForm::GetGroupCount(void)
130 {
131         AppLogDebug("ENTER");
132         AppLogDebug("EXIT");
133         return 1;
134 }
135
136 int
137 SettingForm::GetItemCount(int groupIndex)
138 {
139         AppLogDebug("ENTER");
140         int itemCount = 0;
141
142         switch (groupIndex)
143         {
144         case ID_MAIN_DEFAULT_PLAYLIST_ITEM:
145                 {
146                         itemCount = ID_MAIN_DEFAULT_PLAYLIST_ITEM_COUNT;
147                 }
148                 break;
149
150         case ID_MAIN_AUTO_OFF_ITEM:
151                 {
152                         itemCount = ID_MAIN_AUTO_OFF_ITEM_COUNT;
153                 }
154                 break;
155
156         default:
157                 break;
158         }
159         AppLogDebug("EXIT");
160         return itemCount;
161 }
162
163 TableViewGroupItem*
164 SettingForm::CreateGroupItem(int groupIndex, int itemWidth)
165 {
166         AppLogDebug("ENTER %d", groupIndex);
167         RelativeLayout layout;
168         layout.Construct();
169
170         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
171         pItem->Construct(layout, Dimension(itemWidth, SETTING_ITEM_HEIGHT));
172         Panel* pGroupTableViewItem =  new (std::nothrow) Panel();
173         switch (groupIndex)
174         {
175         case ID_MAIN_DEFAULT_PLAYLIST_ITEM:
176                 {
177                         if (IsFailed(pGroupTableViewItem->Construct(IDL_SETTING_PLAYLIST_SET_ITEM_PANEL)))
178                         {
179                                 AppLogDebug("Construct(IDL_SETTING_PLAYLIST_SET_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
180                                 delete pGroupTableViewItem;
181                                 delete pItem;
182                                 return null;
183                         }
184                 }
185                 break;
186
187         case ID_MAIN_AUTO_OFF_ITEM:
188                 {
189                         Label* pSubTextLabel = null;
190                         Label* pMainTextLabel = null;
191
192                         if (IsFailed(pGroupTableViewItem->Construct(IDL_SETTING_OFF_SET_ITEM_PANEL)))
193                         {
194                                 AppLogDebug("Construct(IDL_SETTING_PLAYLIST_SET_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
195                                 delete pGroupTableViewItem;
196                                 delete pItem;
197                                 return null;
198                         }
199
200                         pSubTextLabel = static_cast<Label*>(pGroupTableViewItem->GetControl(IDC_LABEL_SUB_TEXT));
201                         pSubTextLabel->SetText(GetAutoOffString());
202                         pSubTextLabel->AddTouchEventListener(*this);
203                         pMainTextLabel = static_cast<Label*>(pGroupTableViewItem->GetControl(IDC_LABEL_MAIN_TEXT));
204                         pMainTextLabel->AddTouchEventListener(*this);
205                         static_cast<Label*>(pGroupTableViewItem->GetControl(IDC_LABEL_EX))->AddTouchEventListener(*this);
206                         pItem->AddKeyEventListener(*this);
207                         pItem->AddFocusEventListener(*this);
208                 }
209                 break;
210
211         default:
212                 break;
213         }
214
215         pItem->AddControl(pGroupTableViewItem);
216         pItem->SetIndividualSelectionEnabled(pGroupTableViewItem, true);
217         CommonUtil::SetLayoutFitToContainer(*pItem, *pGroupTableViewItem);
218
219         AppLogDebug("EXIT");
220         return pItem;
221 }
222
223 bool
224 SettingForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
225 {
226         AppLogDebug("ENTER");
227         AppLogDebug("EXIT");
228         return false;
229 }
230
231 TableViewItem*
232 SettingForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
233 {
234         AppLogDebug("ENTER");
235         RelativeLayout layout;
236         layout.Construct();
237
238         TableViewItem* pItem = new (std::nothrow) TableViewItem();
239         Panel* pGroupTableViewItem =  new (std::nothrow) Panel();
240
241         result r = pGroupTableViewItem->Construct(IDL_GROUPEDTABLEVIEW_ITEM_PANEL);
242         TryCatch(r == E_SUCCESS, delete pItem, "pGroupTableViewItem->Construct(%s)", GetErrorMessage(r));
243
244         if (groupIndex == ID_MAIN_DEFAULT_PLAYLIST_ITEM)
245         {
246                 r = pItem->Construct(layout, Dimension(W_CLIENT_AREA, SETTING_ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_MARK);
247                 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
248
249                 Label* pMainText = static_cast<Label*>(pGroupTableViewItem->GetControl(IDC_LABEL_MAIN_TEXT));
250
251                 switch (itemIndex)
252                 {
253                 case ID_SUB_MOST_PLAYED_ITEM:
254                         {
255                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_MOST_PLAYED"));
256                         }
257                         break;
258
259                 case ID_SUB_RECENTLY_PLAYED_ITEM:
260                         {
261                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_PLAYLIST_RECENTLY_PLAYED"));
262                         }
263                         break;
264
265                 case ID_SUB_RECENTLY_ADD_ITEM:
266                         {
267                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_RECENTLY_ADDED"));
268                         }
269                         break;
270
271                 default:
272                         break;
273                 }
274         }
275         else
276         {
277                 r = pItem->Construct(layout, Dimension(W_CLIENT_AREA, SETTING_ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_RADIO);
278                 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
279
280                 Label* pMainText = static_cast<Label*>(pGroupTableViewItem->GetControl(IDC_LABEL_MAIN_TEXT));
281
282                 switch (itemIndex)
283                 {
284                 case ID_SUB_ZERO_ITEM:
285                         {
286                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_NOT_USED"));
287                         }
288                         break;
289
290                 case ID_SUB_FIFTEEN_ITEM:
291                         {
292                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_OPT_AFTER_15_MIN_ABB"));
293                         }
294                         break;
295
296                 case ID_SUB_THIRTY_ITEM:
297                         {
298                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_AFTER_30_MIN"));
299                         }
300                         break;
301
302                 case ID_SUB_ONE_HOUR_ITEM:
303                         {
304                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_AFTER_1_HOUR"));
305                         }
306                         break;
307
308                 case ID_SUB_ONE_HOUR_THIRTY_ITEM:
309                         {
310                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_POP_AFTER_1_HOUR_30_MIN"));
311                         }
312                         break;
313
314                 case ID_SUB_TWO_HOURS_ITEM:
315                         {
316                                 pMainText->SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_AFTER_2_HOURS"));
317                         }
318                         break;
319
320                 default:
321                         break;
322                 }
323         }
324
325         pItem->AddControl(pGroupTableViewItem);
326         pItem->SetIndividualSelectionEnabled(pGroupTableViewItem, true);
327         CommonUtil::SetLayoutFitToContainer(*pItem, *pGroupTableViewItem);
328
329         AppLogDebug("EXIT");
330         return pItem;
331
332 CATCH:
333         AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
334         delete pGroupTableViewItem;
335         return null;
336 }
337
338 void
339 SettingForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem)
340 {
341         AppLogDebug("ENTER");
342         AppLogDebug("EXIT");
343 }
344
345 void
346 SettingForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem)
347 {
348         AppLogDebug("ENTER");
349         if (groupIndex == ID_MAIN_AUTO_OFF_ITEM)
350         {
351                 Label* pLabelSubtext = static_cast<Label*>(pItem->GetControl(IDC_LABEL_SUB_TEXT, true));
352                 pLabelSubtext->SetText(GetAutoOffString());
353                 pLabelSubtext->Invalidate(false);
354         }
355         __pSettingTableView->Invalidate(true);
356         AppLogDebug("EXIT");
357 }
358
359 int
360 SettingForm::GetDefaultItemHeight(void)
361 {
362         AppLogDebug("ENTER");
363         AppLogDebug("EXIT");
364         return SETTING_ITEM_HEIGHT;
365 }
366
367 int
368 SettingForm::GetDefaultGroupItemHeight(void)
369 {
370         AppLogDebug("ENTER");
371         AppLogDebug("EXIT");
372         return SETTING_ITEM_HEIGHT;
373 }
374
375 bool
376 SettingForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
377 {
378         AppLogDebug("ENTER");
379         AppLogDebug("EXIT");
380         return false;
381 }
382
383 void
384 SettingForm::OnGroupedTableViewGroupItemStateChanged(GroupedTableView& tableView, int groupIndex, TableViewGroupItem* pItem, TableViewItemStatus status)
385 {
386         AppLogDebug("ENTER");
387         if (tableView.IsGroupExpanded(groupIndex) == true)
388         {
389                 Label* pLabel = static_cast<Label*>(pItem->GetControl(IDC_LABEL_EX, true));
390                 Bitmap* pBitmap = ResourceManager::GetBitmapN(L"00_button_expand_closed.png");
391                 pLabel->SetBackgroundBitmap(*pBitmap);
392                 pLabel->Invalidate(false);
393                 delete pBitmap;
394
395                 if (groupIndex == ID_MAIN_AUTO_OFF_ITEM)
396                 {
397                         Label* pLabelSubtext = static_cast<Label*>(pItem->GetControl(IDC_LABEL_SUB_TEXT, true));
398                         pLabelSubtext->SetText(GetAutoOffString());
399                         pLabelSubtext->Invalidate(false);
400                 }
401
402                 AppLogDebug("CollapseGroup %d",groupIndex);
403                 tableView.CollapseGroup(groupIndex);
404         }
405         else
406         {
407                 Label* pLabel = static_cast<Label*>(pItem->GetControl(IDC_LABEL_EX, true));
408                 Bitmap* pBitmap = ResourceManager::GetBitmapN(L"00_button_expand_opened.png");
409                 pLabel->SetBackgroundBitmap(*pBitmap);
410                 pLabel->Invalidate(false);
411                 delete pBitmap;
412
413                 AppLogDebug("ExpandGroup %d",groupIndex);
414                 tableView.ExpandGroup(groupIndex);
415         }
416         AppLogDebug("EXIT");
417 }
418
419 void
420 SettingForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status)
421 {
422         AppLogDebug("ENTER");
423         bool isChecked = false;
424         switch (groupIndex)
425         {
426         case ID_MAIN_DEFAULT_PLAYLIST_ITEM:
427                 {
428                         if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
429                         {
430                                 isChecked = true;
431                         }
432                         __pSettingPresentationModel->SetTabEnable(itemIndex, isChecked);
433                         Frame* pFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
434                         Form* pForm = static_cast<Form*>(pFrame->GetControl(CONTENT_FORM_REQUSEST_ID));
435                         if (pForm != null)
436                         {
437                                 AppLogDebug("AForm");
438                                 pForm->SendUserEvent(0, null);
439                         }
440                 }
441                 break;
442
443         case ID_MAIN_AUTO_OFF_ITEM:
444                 {
445                         int timerInterval = 0;
446                         result r = E_SUCCESS;
447                         timerInterval = __pSettingPresentationModel->SetAutoOffTime(itemIndex);
448                         r = GetLastResult();
449                         for (int i = 0; i < __pSettingTableView->GetItemCountAt(ID_MAIN_AUTO_OFF_ITEM); i++)
450                         {
451                                 if (i == itemIndex)
452                                 {
453                                         AppLogDebug("true : %d", i);
454                                         __pSettingTableView->SetItemChecked(groupIndex, i, true);
455                                 }
456                                 else
457                                 {
458                                         AppLogDebug("false : %d", i);
459                                         __pSettingTableView->SetItemChecked(groupIndex, i, false);
460                                 }
461                         }
462
463                         if (r == E_STORAGE_FULL)
464                         {
465                                 int messageResult = 0;
466                                 MessageBox messageBox;
467                                 __pSettingTableView->SetItemChecked(groupIndex, itemIndex, false);
468                                 __pSettingTableView->SetItemChecked(groupIndex, __pSettingPresentationModel->GetAutoOffTime(), true);
469                                 messageBox.Construct(L"",IDS_STORAGE_FULL,MSGBOX_STYLE_NONE,COUNT_MESSAGE_BOX_TIMEOUT);
470                                 messageBox.ShowAndWait(messageResult);
471                                 App::GetInstance()->Terminate();
472                                 return;
473                         }
474
475                         if (timerInterval >= 0)
476                         {
477                                 __pPresentationModel->StartAutoOffTimer(timerInterval);
478                                 tableView.RefreshItem(groupIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
479                         }
480                         else
481                         {
482                                 //show message of IDS_UNABLE_TO_CHANGE_SETTINGS
483                                 __pSettingTableView->SetItemChecked(groupIndex, itemIndex, false);
484                                 __pSettingTableView->SetItemChecked(groupIndex, __pSettingPresentationModel->GetAutoOffTime(), true);
485                                 int messgeResult = 0;
486                                 MessageBox messageBox;
487 //                              messageBox.Construct(L"Error", ResourceManager::GetString(L"IDS_UNABLE_TO_CHANGE_SETTINGS"), MSGBOX_STYLE_NONE,3000);
488                                 messageBox.Construct(L"Error", L"Unable to change the setting.", MSGBOX_STYLE_NONE,3000);
489                                 messageBox.ShowAndWait(messgeResult);
490                         }
491                 }
492                 break;
493
494         default:
495                 break;
496         }
497         AppLogDebug("EXIT");
498 }
499
500 void
501 SettingForm::OnGroupedTableViewContextItemActivationStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewContextItem* pContextItem, bool activated)
502 {
503         AppLogDebug("ENTER");
504         AppLogDebug("EXIT");
505 }
506
507 void
508 SettingForm::OnFocusGained(const Control& source)
509 {
510         AppLogDebug("ENTER");
511         AppLogDebug("EXIT");
512 }
513
514 void
515 SettingForm::OnFocusLost(const Control& source)
516 {
517         AppLogDebug("ENTER");
518         const TableViewGroupItem* pSourcePanel = dynamic_cast<const TableViewGroupItem*>(&source);
519
520         if (pSourcePanel != null)
521         {
522                 Label* pLabel = static_cast<Label*>(pSourcePanel->GetControl(IDC_LABEL_SUB_TEXT,true));
523
524                 if (pLabel)
525                 {
526                         pLabel->SetTextColor(COLOR_SUB_TEXT_SETTINGS);
527                         pLabel->Invalidate(false);
528                 }
529         }
530
531         AppLogDebug("EXIT");
532 }
533
534 void
535 SettingForm::OnKeyLongPressed(const Control& source, KeyCode keyCode)
536 {
537         AppLogDebug("ENTER");
538         AppLogDebug("EXIT");
539 }
540
541 void
542 SettingForm::OnKeyPressed(const Control& source, KeyCode keyCode)
543 {
544         AppLogDebug("ENTER %ls", source.GetName().GetPointer());
545         if(keyCode == KEY_ENTER)
546         {
547                 const TableViewGroupItem* pSourcePanel = dynamic_cast<const TableViewGroupItem*>(&source);
548
549                 if (pSourcePanel != null)
550                 {
551                         Label* pLabel = static_cast<Label*>(pSourcePanel->GetControl(IDC_LABEL_SUB_TEXT,true));
552
553                         if (pLabel)
554                         {
555                                 pLabel->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
556                                 pLabel->Invalidate(false);
557                         }
558                 }
559         }
560         AppLogDebug("EXIT");
561 }
562
563 void
564 SettingForm::OnKeyReleased(const Control& source, KeyCode keyCode)
565 {
566         AppLogDebug("ENTER %ls", source.GetName().GetPointer());
567         if (keyCode == KEY_ENTER)
568         {
569                 const TableViewGroupItem* pSourcePanel = dynamic_cast<const TableViewGroupItem*>(&source);
570
571                 if (pSourcePanel != null)
572                 {
573                         Label* pLabel = static_cast<Label*>(pSourcePanel->GetControl(IDC_LABEL_SUB_TEXT,true));
574
575                         if (pLabel)
576                         {
577                                 pLabel->SetTextColor(COLOR_SUB_TEXT_SETTINGS);
578                                 pLabel->Invalidate(false);
579                         }
580                 }
581         }
582         AppLogDebug("EXIT");
583 }
584
585 void
586 SettingForm::OnTouchCanceled(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
587 {
588         AppLogDebug("ENTER %ls",source.GetName().GetPointer());
589         if (source.GetName().Equals(IDC_LABEL_SUB_TEXT,true)
590                         || source.GetName().Equals(IDC_LABEL_MAIN_TEXT,true)
591                         || source.GetName().Equals(IDC_LABEL_EX,true))
592         {
593                 Panel* pSourcePanel = dynamic_cast<Panel*>(source.GetParent());
594                 if (pSourcePanel)
595                 {
596                         Label* pLabel = static_cast<Label*>(pSourcePanel->GetControl(IDC_LABEL_SUB_TEXT,true));
597                         if (pLabel)
598                         {
599                                 pLabel->SetTextColor(COLOR_SUB_TEXT_SETTINGS);
600                         }
601                 }
602         }
603         AppLogDebug("EXIT");
604 }
605
606 void
607 SettingForm::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
608 {
609         AppLogDebug("ENTER %ls",source.GetName().GetPointer());
610         if (source.GetName().Equals(IDC_LABEL_SUB_TEXT,true)
611                         || source.GetName().Equals(IDC_LABEL_MAIN_TEXT,true)
612                         || source.GetName().Equals(IDC_LABEL_EX,true))
613         {
614                 Panel* pSourcePanel = dynamic_cast<Panel*>(source.GetParent());
615                 if (pSourcePanel)
616                 {
617                         Label* pLabel = static_cast<Label*>(pSourcePanel->GetControl(IDC_LABEL_SUB_TEXT,true));
618                         if (pLabel)
619                         {
620                                 pLabel->SetTextColor(COLOR_SUB_TEXT_SETTINGS);
621                         }
622                 }
623         }
624         AppLogDebug("EXIT");
625 }
626
627 void
628 SettingForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo & touchInfo)
629 {
630         AppLogDebug("ENTER %ls", source.GetName().GetPointer());
631         if (source.GetName().Equals(IDC_LABEL_SUB_TEXT,true)
632                         || source.GetName().Equals(IDC_LABEL_MAIN_TEXT,true)
633                         || source.GetName().Equals(IDC_LABEL_EX,true))
634         {
635                 Panel* pSourcePanel = dynamic_cast<Panel*>(source.GetParent());
636                 if (pSourcePanel)
637                 {
638                         Label* pLabel = static_cast<Label*>(pSourcePanel->GetControl(IDC_LABEL_SUB_TEXT,true));
639                         if (pLabel)
640                         {
641                                 pLabel->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
642 //                              pLabel->Invalidate(false);
643                         }
644                 }
645         }
646         AppLogDebug("EXIT");
647 }
648
649 void
650 SettingForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
651 {
652         AppLogDebug("ENTER %ls",source.GetName().GetPointer());
653         if (source.GetName().Equals(IDC_LABEL_SUB_TEXT,true)
654                         || source.GetName().Equals(IDC_LABEL_MAIN_TEXT,true)
655                         || source.GetName().Equals(IDC_LABEL_EX,true))
656         {
657                 Panel* pSourcePanel = dynamic_cast<Panel*>(source.GetParent());
658                 if (pSourcePanel)
659                 {
660                         Label* pLabel = static_cast<Label*>(pSourcePanel->GetControl(IDC_LABEL_SUB_TEXT,true));
661                         if (pLabel)
662                         {
663                                 pLabel->SetTextColor(COLOR_SUB_TEXT_SETTINGS);
664 //                              pLabel->Invalidate(false);
665                         }
666                 }
667         }
668         AppLogDebug("EXIT");
669 }
670
671 void
672 SettingForm::OnActionPerformed(const Control& source, int actionId)
673 {
674         AppLogDebug("ENTER");
675         AppLogDebug("EXIT");
676 }
677
678 void
679 SettingForm::OnFormBackRequested(Form& source)
680 {
681         AppLogDebug("ENTER");
682         SceneManager* pSceneManager = SceneManager::GetInstance();
683         AppAssert(pSceneManager);
684         result r = pSceneManager->GoBackward(BackwardSceneTransition());
685         if (r != E_SUCCESS)
686         {
687                 __pSettingPresentationModel->DestroySettingPresentationModel();
688                 UiApp* pApp = UiApp::GetInstance();
689                 pApp->Terminate();
690         }
691         AppLogDebug("EXIT");
692 }
693
694 void
695 SettingForm::OnSceneActivatedN(const SceneId& previousSceneId,
696                                                                 const SceneId& currentSceneId,
697                                                                 IList* pArgs)
698 {
699         AppLogDebug("ENTER");
700         SceneManager* pSceneManager = SceneManager::GetInstance();
701         AppAssert(pSceneManager);
702
703         CommonUtil::SetSimpleTitleStyle(*GetHeader(), ResourceManager::GetString(L"IDS_MUSIC_BODY_MUSIC_SETTINGS"));
704
705         if (pArgs != null)
706         {
707                 pArgs->RemoveAll(true);
708                 delete pArgs;
709         }
710         AppLogDebug("EXIT");
711 }
712
713 void
714 SettingForm::OnSceneDeactivated(const SceneId& currentSceneId,
715                                         const SceneId& nextSceneId)
716 {
717         AppLogDebug("ENTER");
718         AppLogDebug("EXIT");
719 }
720
721 String
722 SettingForm::GetAutoOffString(void)
723 {
724         AppLogDebug("ENTER");
725         switch (__pSettingPresentationModel->GetAutoOffTime())
726         {
727         case ID_SUB_ZERO_ITEM:
728                 {
729                         return ResourceManager::GetString(L"IDS_MUSIC_BODY_NOT_USED");
730                 }
731                 break;
732
733         case ID_SUB_FIFTEEN_ITEM:
734                 {
735                         return ResourceManager::GetString(L"IDS_MUSIC_OPT_AFTER_15_MIN_ABB");
736                 }
737                 break;
738
739         case ID_SUB_THIRTY_ITEM:
740                 {
741                         return ResourceManager::GetString(L"IDS_MUSIC_BODY_AFTER_30_MIN");
742                 }
743                 break;
744
745         case ID_SUB_ONE_HOUR_ITEM:
746                 {
747                         return ResourceManager::GetString(L"IDS_MUSIC_BODY_AFTER_1_HOUR");
748                 }
749                 break;
750
751         case ID_SUB_ONE_HOUR_THIRTY_ITEM:
752                 {
753                         return ResourceManager::GetString(L"IDS_MUSIC_POP_AFTER_1_HOUR_30_MIN");
754                 }
755                 break;
756
757         case ID_SUB_TWO_HOURS_ITEM:
758                 {
759                         return ResourceManager::GetString(L"IDS_MUSIC_BODY_AFTER_2_HOURS");
760                 }
761                 break;
762
763         default:
764                 break;
765         }
766
767         AppLogDebug("EXIT");
768         return ResourceManager::GetString(L"IDS_MUSIC_BODY_NOT_USED");
769 }