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