Tizen 2.0 Release
[apps/osp/Internet.git] / src / IntReaderFontSizeForm.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 //!Internet IntFontSize class
19 /*@file:        IntFontSize.cpp
20  *@brief:       This class defines IntFontSize used to change the font size
21  *
22  */
23
24 #include <FAppUiApp.h>
25 #include <FUi.h>
26
27 #include "IntCommonLib.h"
28 #include "IntReaderFontSizeForm.h"
29 #include "IntSceneRegister.h"
30 #include "IntSettingPresentationModel.h"
31
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
39
40
41 ReaderFontSizeForm::ReaderFontSizeForm(void)
42 {
43         __pFontSlider = null;
44         __pFontValue = null;
45 }
46
47 ReaderFontSizeForm::~ReaderFontSizeForm(void)
48 {
49
50 }
51
52 bool
53 ReaderFontSizeForm::Initialize(void)
54 {
55         Form::Construct(L"IDL_FONT_SIZE");
56
57         return true;
58 }
59
60 result
61 ReaderFontSizeForm::OnInitializing(void)
62 {
63         result r = E_SUCCESS;
64
65         SceneManager* pSceneManager = SceneManager::GetInstance();
66         if (pSceneManager != null)
67         {
68                 r = pSceneManager->AddSceneEventListener(IDSCN_FONT_SIZE, *this);
69                 TryCatch(!IsFailed(r),,"AddSceneEventListener failed with error %s",GetErrorMessage(r));
70         }
71
72         SetFormBackEventListener(this);
73
74         r = GetHeader()->SetTitleText(CommonUtil::GetString(L"IDS_BR_BODY_FONT_SIZE"));
75         TryCatch(!IsFailed(r),,"OnInitialized failed with %s",GetErrorMessage(r));
76
77         __pFontSlider = static_cast< Slider* >(GetControl(
78                         L"IDC_FONT_SLIDER", true));
79         if (__pFontSlider == null)
80         {
81                 return E_FAILURE;
82         }
83         __pFontSlider->AddSliderEventListener(*this);
84
85         r = __pFontSlider->SetBounds(Rectangle(0, 10, GetClientAreaBounds().width, 120));
86         TryCatch(!IsFailed(r),,"OnInitialized failed with %s",GetErrorMessage(r));
87
88         r = __pFontSlider->SetRange(10, 30);
89         TryCatch(!IsFailed(r),,"OnInitialized failed with %s",GetErrorMessage(r));
90
91         GetFooter()->AddActionEventListener(*this);
92
93         CATCH:
94         return r;
95 }
96
97 void
98 ReaderFontSizeForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
99 {
100         __pFontValue = dynamic_cast<Integer*>(pArgs->GetAt(0));
101
102         if (__pFontValue == null)
103         {
104                 return;
105         }
106
107         if (__pFontSlider != null && __pFontValue != null)
108         {
109                 __pFontSlider->SetValue(__pFontValue->ToInt());
110         }
111         return;
112 }
113
114 void
115 ReaderFontSizeForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
116 {
117         return;
118 }
119
120 void
121 ReaderFontSizeForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
122 {
123         *__pFontValue = value;
124         return;
125 }
126
127 void
128 ReaderFontSizeForm::OnFormBackRequested(Form& source)
129 {
130         result r = E_FAILURE;
131         SceneManager* pSceneManager = SceneManager::GetInstance();
132         ArrayList *pArgList = new(std::nothrow) ArrayList();
133
134         if (pArgList != null)
135         {
136                 r = pArgList->Construct();
137                 TryCatch(!IsFailed(r),,"OnFormBackRequested failed with %s",GetErrorMessage(r));
138
139                 SettingPresentationModel::GetInstance()->SetReaderFontSize(__pFontValue->ToInt());
140                 TryCatch(!IsFailed(r),,"OnFormBackRequested failed with %s",GetErrorMessage(r));
141
142                 if (pSceneManager != null)
143                 {
144                         r = pSceneManager->GoBackward(BackwardSceneTransition());
145                         TryCatch(!IsFailed(r), "ReaderFontSizeForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
146                 }
147         }
148
149         CATCH:
150
151         if( pArgList != NULL)
152         {
153                 delete pArgList;
154         }
155
156         return;
157 }
158
159 void
160 ReaderFontSizeForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
161 {
162
163 }