NABI issues N_SE-50115, N_SE-50067, N_SE-49946, N_SE-49897, N_SE-49884, N_SE-48837...
[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                 Label* pLabel = new (std::nothrow) Label();
119                 pLabel->Construct(helpTitleRect, itemTitle);
120                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
121                 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
122                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
123                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
124
125                 __pContentPanel->AddControl(pLabel);
126
127                 Label* pSecondLabel = new (std::nothrow) Label();
128                 pSecondLabel->Construct(HelpContentsRect, itemHelp);
129                 pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
130                 pSecondLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
131                 pSecondLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
132                 pSecondLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
133
134                 __pContentPanel->AddControl(pSecondLabel);
135
136                 helpTitleRect.y = (HelpContentsRect.y + HelpContentsRect.height);
137         }
138         AddControl(__pContentPanel);
139 }
140
141 void
142 LocationHelpForm::CreateHelpTextView(void)
143 {
144         Rectangle bounds = GetClientAreaBounds();
145         bounds.x = H_TEXT_GAP;
146         bounds.y = Y_HELP_TEXT_PAGE;
147
148         CreateHelpText(bounds);
149 }
150
151 result
152 LocationHelpForm::OnInitializing(void)
153 {
154         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_HELP"));
155         CreateHelpTextView();
156 //      SetOrientationAutoMode();
157
158         return E_SUCCESS;
159 }
160
161 result
162 LocationHelpForm::OnTerminating(void)
163 {
164         SetFormBackEventListener(null);
165         return E_SUCCESS;
166 }
167
168 void
169 LocationHelpForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
170 {
171 }
172
173 void
174 LocationHelpForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
175 {
176 }
177
178 void
179 LocationHelpForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
180 {
181         SceneManager* pSceneManager = SceneManager::GetInstance();
182         AppAssert(pSceneManager);
183
184         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
185 }
186
187 void
188 LocationHelpForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
189 {
190         RemoveControl(__pContentPanel);
191         __pContentPanel = null;
192         CreateHelpTextView();
193 }
194
195 void
196 LocationHelpForm::SetOrientationAutoMode(void)
197 {
198         SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
199         AddOrientationEventListener(*this);
200 }