3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.tizenopensource.org/license
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include "StartForm.h"
19 #include "PedometerForm.h"
21 using namespace Osp::Graphics;
22 using namespace Osp::Ui::Controls;
24 StartForm::StartForm(void)
26 , __pLabelDescription(null)
27 , __pFormPedometer(null)
31 StartForm::~StartForm(void)
36 StartForm::Initialize(void)
38 // Construct an XML form
39 Construct(L"IDF_STARTFORM");
45 StartForm::OnInitializing(void)
47 SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK));
49 // Get a button via resource ID
50 __pButtonGo = static_cast<Button*>(GetControl(L"IDC_BUTTON_GO"));
51 TryReturn(__pButtonGo != null, E_FAILURE, "GoButton creation failed.");
53 __pLabelDescription = static_cast<Label*>(GetControl(L"IDC_LABEL_DESCRIPTION"));
54 TryReturn(__pLabelDescription != null, E_FAILURE, "DescriptionLabel creation failed.");
56 __pButtonGo->SetActionId(ID_BUTTON_GO);
57 __pButtonGo->AddActionEventListener(*this);
59 Rectangle clientAreaBound = GetClientAreaBounds();
60 int fontSize = clientAreaBound.width * 0.06;
61 __pLabelDescription->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
62 __pLabelDescription->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
64 __pFormPedometer = null;
70 StartForm::OnTerminating(void)
76 StartForm::OnActionPerformed(const Osp::Ui::Control& source, int actionId)
82 __pFormPedometer = new (std::nothrow) PedometerForm();
83 TryReturnVoid(__pFormPedometer != null, "PedometerForm creation failed");
84 static_cast<PedometerForm*>(__pFormPedometer)->Initialize();
86 // Add the form to the frame
87 Frame* pFrame = Osp::App::Application::GetInstance()->GetAppFrame()->GetFrame();
90 AppLogException("Frame getting failed");
91 delete __pFormPedometer;
92 __pFormPedometer = null;
95 pFrame->AddControl(*__pFormPedometer);
97 // Set the current form
98 pFrame->SetCurrentForm(*__pFormPedometer);
99 __pFormPedometer->Draw();
105 this->RequestRedraw(true);