2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
18 * @file StLocationHelpForm.cpp
19 * @brief This is the implementation file for LocationHelpForm class.
22 #include "StLocationHelpForm.h"
23 #include "StResourceManager.h"
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;
32 static const int XYH_BASE_POINT = 0;
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;
38 static const int H_TEXT_GAP = 20;
39 static const int W_HUGE_SIZE_PORTRAIT_TEXT_GAP = 90;
41 LocationHelpForm::LocationHelpForm(void)
42 :__pContentPanel(null)
46 LocationHelpForm::~LocationHelpForm(void)
51 LocationHelpForm::CreateHeader(const Tizen::Base::String& textTitle)
53 Header* pHeader = GetHeader();
55 pHeader->SetStyle(HEADER_STYLE_TITLE);
56 pHeader->SetTitleText(textTitle);
60 LocationHelpForm::CreateFooter(void)
62 Footer* pFooter = GetFooter();
65 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
66 pFooter->AddActionEventListener(*this);
68 SetFormBackEventListener(this);
72 LocationHelpForm::CreateHelpText(const Rectangle& bounds)
74 Rectangle helpTitleRect;
75 Rectangle HelpContentsRect;
79 __pContentPanel = new ScrollPanel();
80 __pContentPanel->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height));
82 int fontSize = GetFontSize();
84 helpTitleRect = bounds;
86 helpTitleRect.y = XYH_BASE_POINT;
87 helpTitleRect.height = XYH_BASE_POINT;
89 HelpContentsRect = helpTitleRect;
90 HelpContentsRect.y = XYH_BASE_POINT;
91 HelpContentsRect.height = XYH_BASE_POINT;
93 for (int count = 0; count < ID_ITEM_COUNT; count ++)
97 case ID_HELP_TEXT_GPS:
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");
104 case ID_HELP_TEXT_NETWORK_POSITION:
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");
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;
118 if ((count == ID_HELP_TEXT_NETWORK_POSITION) && (fontSize > FONT_MAIN_TEXT_SIZE_LARGE))
120 HelpContentsRect.height = GetHeightForStringArea(itemHelp, bounds.width + W_HUGE_SIZE_PORTRAIT_TEXT_GAP , fontSize) + H_TEXT_GAP;
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);
130 __pContentPanel->AddControl(pLabel);
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);
139 __pContentPanel->AddControl(pSecondLabel);
141 helpTitleRect.y = (HelpContentsRect.y + HelpContentsRect.height);
143 AddControl(__pContentPanel);
147 LocationHelpForm::CreateHelpTextView(void)
149 Rectangle bounds = GetClientAreaBounds();
150 bounds.x = H_TEXT_GAP;
151 bounds.y = Y_HELP_TEXT_PAGE;
153 CreateHelpText(bounds);
157 LocationHelpForm::OnInitializing(void)
159 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_HELP"));
160 CreateHelpTextView();
161 // SetOrientationAutoMode();
167 LocationHelpForm::OnTerminating(void)
169 SetFormBackEventListener(null);
174 LocationHelpForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
179 LocationHelpForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
184 LocationHelpForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
186 SceneManager* pSceneManager = SceneManager::GetInstance();
187 AppAssert(pSceneManager);
189 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
193 LocationHelpForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
195 RemoveControl(__pContentPanel);
196 __pContentPanel = null;
197 CreateHelpTextView();
201 LocationHelpForm::SetOrientationAutoMode(void)
203 SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
204 AddOrientationEventListener(*this);