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