Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / partner / cpp / Sample / Tizen C++ / UiControls / UiControls / project / src / ColorPickerForm.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.tizenopensource.org/license
10 //
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.
16 //
17 #include "ColorPickerForm.h"\r
18 \r
19 using namespace Osp::Ui;\r
20 using namespace Osp::Ui::Controls;\r
21 using namespace Osp::Graphics;\r
22 \r
23 ColorPickerForm::ColorPickerForm():\r
24 __pLabelLog(null),\r
25 __pLabelText(null)\r
26 {\r
27 }\r
28 \r
29 ColorPickerForm::~ColorPickerForm()\r
30 {\r
31 }\r
32 \r
33 bool\r
34 ColorPickerForm::Initialize(void)\r
35 {\r
36         Construct(FORM_STYLE_NORMAL| FORM_STYLE_INDICATOR| FORM_STYLE_HEADER| FORM_STYLE_FOOTER);\r
37         SetFooter();\r
38 \r
39         return true;\r
40 }\r
41 \r
42 result\r
43 ColorPickerForm::OnInitializing(void)\r
44 {\r
45         BaseForm::OnInitializing();\r
46         result r = E_SUCCESS;\r
47         Header* pHeader = GetHeader();\r
48         pHeader->SetTitleText(L"ColorPicker");\r
49 \r
50         ColorPicker* pColorPicker = new ColorPicker();\r
51         pColorPicker->Construct(Point(10,60));\r
52         pColorPicker->AddColorChangeEventListener(*this);\r
53 \r
54         AddControl(*pColorPicker);\r
55 \r
56         Rectangle rc;\r
57         rc = GetClientAreaBounds();\r
58 \r
59         __pLabelLog = new Label();\r
60         __pLabelLog->Construct(Rectangle(45, rc.height-120, 630, 90), L"");\r
61         __pLabelLog->SetTextHorizontalAlignment(ALIGNMENT_LEFT);\r
62         AddControl(*__pLabelLog);\r
63 \r
64         __pLabelText = new Label();\r
65         __pLabelText->Construct(Rectangle(45, rc.height-225, 630, 90), L"Selected Color is");\r
66         __pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);\r
67         AddControl(*__pLabelText);\r
68 \r
69         return r;\r
70 }\r
71 \r
72 void\r
73 ColorPickerForm::OnColorChanged(const Osp::Ui::Control& source, const Osp::Graphics::Color& color)\r
74 {\r
75         __pLabelLog->SetBackgroundColor(color);\r
76         __pLabelLog->Draw();\r
77 }\r