Applied latest source code
[apps/native/preloaded/Clock.git] / src / ClkToggleCustomItem.cpp
1 //
2 //  Tizen Native SDK
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.1 (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://floralicense.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
18 /**
19  * @file         ToggleCustomItem.cpp
20  * @brief        The ToggleCustomItem
21  *
22  */
23
24 #include <FBase.h>
25 #include <FGraphics.h>
26 #include <FUiControls.h>
27
28 #include "ClkToggleCustomItem.h"
29
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Ui::Controls;
34
35 static const int IDA_FORMAT_STRING = 101;
36
37 ToggleCustomItem::ToggleCustomItem(void)
38 :__height(0),
39  __text(""),
40  __width(0)
41 {
42
43 }
44
45 ToggleCustomItem::~ToggleCustomItem(void)
46 {
47
48 }
49
50 result
51 ToggleCustomItem::Construct(int width, int height)
52 {
53         result r = E_FAILURE;
54
55         __width = width;
56         __height = height;
57         const Dimension dim(width, height);
58         r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_ONOFF_SLIDING);
59
60         return r;
61 }
62
63 void
64 ToggleCustomItem::SetText(String& text)
65 {
66         __text = text;
67 }
68
69 String
70 ToggleCustomItem::GetText(void)
71 {
72         return __text;
73 }
74
75 result
76 ToggleCustomItem::Make(void)
77 {
78         EnrichedText* pMainEnText = null;
79         TextElement* pMainTextElement = null;
80         Font* pMainTextFont = null;
81         int mainTextFont = 32;
82         int textX = 80;
83         int textY = 40;
84         Color textColor = Color(128, 128, 128);
85         Color pressedTextColor = Color(249, 249, 249);
86         int X_Margin = 26;
87         int Y_Margin = 40;
88     int itemWidth = __width - 60 ;
89
90         pMainEnText = new (std::nothrow) EnrichedText();
91         pMainEnText->Construct(Dimension(__width - textX, textY));
92
93         pMainTextElement = new (std::nothrow) TextElement();
94         pMainTextElement->Construct(__text);
95
96         pMainTextFont = new (std::nothrow) Font();
97         pMainTextFont->Construct(FONT_STYLE_BOLD, mainTextFont);
98
99         pMainTextElement->SetFont(*pMainTextFont);
100         pMainTextElement->SetTextColor(textColor);
101         pMainEnText->Add(*pMainTextElement);
102
103
104         AddElement(Rectangle(X_Margin, Y_Margin, itemWidth , __height), IDA_FORMAT_STRING, *pMainEnText);
105         //SetElementSelectionEnabled(IDA_FORMAT_STRING, true);
106
107         delete pMainTextFont;
108         pMainEnText->RemoveAllTextElements(true);
109         delete pMainEnText;
110
111
112         return E_SUCCESS;
113 }