115b05b73c89cd360efd22d55cae8d06d23ecb9f
[apps/osp/Settings.git] / src / StLocationHelpForm.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                StLocationHelpForm.cpp
19  * @brief               This is the implementation file for LocationHelpForm class.
20  */
21
22 #include "StLocationHelpForm.h"
23 #include "StResourceManager.h"
24 #include "StTypes.h"
25
26 using namespace Tizen::Base;
27 using namespace Tizen::Graphics;
28 using namespace Tizen::Ui;
29 using namespace Tizen::Ui::Controls;
30 using namespace Tizen::Ui::Scenes;
31
32 static const int XYH_BASE_POINT = 0;
33
34 static const int ID_ITEM_COUNT = 2;
35 static const int ID_HELP_TEXT_GPS = 0;
36 static const int ID_HELP_TEXT_NETWORK_POSITION = 1;
37
38 static const int H_TEXT_GAP = 20;
39 static const int W_HUGE_SIZE_PORTRAIT_TEXT_GAP = 90;
40
41 LocationHelpForm::LocationHelpForm(void)
42 :__pContentPanel(null)
43 {
44 }
45
46 LocationHelpForm::~LocationHelpForm(void)
47 {
48 }
49
50 void
51 LocationHelpForm::CreateHeader(const Tizen::Base::String& textTitle)
52 {
53         Header* pHeader = GetHeader();
54
55         pHeader->SetStyle(HEADER_STYLE_TITLE);
56         pHeader->SetTitleText(textTitle);
57 }
58
59 void
60 LocationHelpForm::CreateFooter(void)
61 {
62         Footer* pFooter = GetFooter();
63         AppAssert(pFooter);
64
65         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
66         pFooter->AddActionEventListener(*this);
67
68         SetFormBackEventListener(this);
69 }
70
71 void
72 LocationHelpForm::CreateHelpText(const Rectangle& bounds)
73 {
74         Rectangle helpTitleRect;
75         Rectangle HelpContentsRect;
76         String itemTitle;
77         String itemHelp;
78
79         __pContentPanel = new ScrollPanel();
80         __pContentPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height));
81
82         int fontSize = GetFontSize();
83
84         helpTitleRect = bounds;
85
86         helpTitleRect.y = XYH_BASE_POINT;
87         helpTitleRect.height = XYH_BASE_POINT;
88
89         HelpContentsRect = helpTitleRect;
90         HelpContentsRect.y = XYH_BASE_POINT;
91         HelpContentsRect.height = XYH_BASE_POINT;
92
93         for (int count = 0; count < ID_ITEM_COUNT; count ++)
94         {
95                 switch (count)
96                 {
97                 case ID_HELP_TEXT_GPS:
98                         {
99                                 itemTitle = ResourceManager::GetString(L"IDS_CAM_OPT_GPS");
100                                 itemHelp = ResourceManager::GetString(L"IDS_LBS_POP_APPLICATIONS_WILL_BE_PERMITTED_TO_USE_YOUR_LOCATION");
101                         }
102                         break;
103
104                 case ID_HELP_TEXT_NETWORK_POSITION:
105                         {
106                                 itemTitle = ResourceManager::GetString(L"IDS_LBS_BODY_NETWORK_POSITION");
107                                 itemHelp = ResourceManager::GetString(L"IDS_LBS_BODY_ENABLING_NETWORK_POSITIONING_WILL_HELP_YOU_FIND_YOUR_LOCATION_EVEN_IF_YOU_ARE_INDOORS_MSG");
108                         }
109                         break;
110                 }
111
112                 helpTitleRect.x = H_TEXT_GAP;
113                 helpTitleRect.height =  GetHeightForStringArea(itemTitle, bounds.width + W_HUGE_SIZE_PORTRAIT_TEXT_GAP, fontSize) + H_TEXT_GAP;
114                 HelpContentsRect.x = H_TEXT_GAP;
115                 HelpContentsRect.y = (helpTitleRect.y + helpTitleRect.height);
116                 HelpContentsRect.height = GetHeightForStringArea(itemHelp, bounds.width , fontSize) + H_TEXT_GAP;
117
118                 if ((count == ID_HELP_TEXT_NETWORK_POSITION) && (fontSize > FONT_MAIN_TEXT_SIZE_LARGE))
119                 {
120                         HelpContentsRect.height = GetHeightForStringArea(itemHelp, bounds.width + W_HUGE_SIZE_PORTRAIT_TEXT_GAP , fontSize) + H_TEXT_GAP;
121                 }
122
123                 Label* pLabel = new (std::nothrow) Label();
124                 pLabel->Construct(helpTitleRect, itemTitle);
125                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
126                 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
127                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
128                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
129
130                 __pContentPanel->AddControl(pLabel);
131
132                 Label* pSecondLabel = new (std::nothrow) Label();
133                 pSecondLabel->Construct(HelpContentsRect, itemHelp);
134                 pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
135                 pSecondLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
136                 pSecondLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
137                 pSecondLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
138
139                 __pContentPanel->AddControl(pSecondLabel);
140
141                 helpTitleRect.y = (HelpContentsRect.y + HelpContentsRect.height);
142         }
143         AddControl(__pContentPanel);
144 }
145
146 void
147 LocationHelpForm::CreateHelpTextView(void)
148 {
149         Rectangle bounds = GetClientAreaBounds();
150         bounds.x = H_TEXT_GAP;
151         bounds.y = Y_HELP_TEXT_PAGE;
152
153         CreateHelpText(bounds);
154 }
155
156 result
157 LocationHelpForm::OnInitializing(void)
158 {
159         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_HELP"));
160         CreateHelpTextView();
161 //      SetOrientationAutoMode();
162
163         return E_SUCCESS;
164 }
165
166 result
167 LocationHelpForm::OnTerminating(void)
168 {
169         SetFormBackEventListener(null);
170         return E_SUCCESS;
171 }
172
173 void
174 LocationHelpForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
175 {
176 }
177
178 void
179 LocationHelpForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
180 {
181 }
182
183 void
184 LocationHelpForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
185 {
186         SceneManager* pSceneManager = SceneManager::GetInstance();
187         AppAssert(pSceneManager);
188
189         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
190 }
191
192 void
193 LocationHelpForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
194 {
195         RemoveControl(__pContentPanel);
196         __pContentPanel = null;
197         CreateHelpTextView();
198 }
199
200 void
201 LocationHelpForm::SetOrientationAutoMode(void)
202 {
203         SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
204         AddOrientationEventListener(*this);
205 }