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.
22 using namespace Osp::Base;
23 using namespace Osp::Ui;
24 using namespace Osp::Ui::Controls;
25 using namespace Osp::App;
26 using namespace Osp::Graphics;
28 MainForm::MainForm(void)
32 MainForm::~MainForm(void)
37 MainForm::Initialize(void)
39 Form::Construct(FORM_STYLE_NORMAL|FORM_STYLE_HEADER|FORM_STYLE_INDICATOR);
43 Header* pHeader = this->GetHeader();
44 pHeader->SetTitleText(L"Metal Detector");
46 this->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK));
52 MainForm::OnInitializing(void)
57 Button *pBtnStart = new (std::nothrow) Button();
58 TryReturn(pBtnStart != null, E_FAILURE, "[Fail]Button Create");
60 Rectangle clientAreaBound = GetClientAreaBounds();
61 int buttonX = static_cast<int>(clientAreaBound.width * 0.33); // 1/3 Down
62 int buttonY = static_cast<int>(clientAreaBound.height * 0.75); // 3/4
63 int buttonWidth = static_cast<int>(clientAreaBound.width * 0.34); // 1/3 Up
64 int buttonHeight = static_cast<int>(clientAreaBound.height * 0.14); // 1/7
66 pBtnStart->Construct(Rectangle(buttonX, buttonY, buttonWidth, buttonHeight));
67 pBtnStart->SetText(L"Start");
68 pBtnStart->SetActionId(IDC_BTN_START);
69 pBtnStart->AddActionEventListener(*this);
70 AddControl(*pBtnStart);
76 MainForm::OnTerminating(void)
82 MainForm::OnActionPerformed(const Osp::Ui::Control& source, int actionId)
84 // Get the frame pointer
85 Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
91 FormMgr* pFormMgr = static_cast<FormMgr *>(pFrame->GetControl("FormMgr"));
95 pFormMgr->SendUserEvent(FormMgr::REQUEST_DETECTFORM, null);