Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_TabBarItem.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0/
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  * @file                FUiCtrl_TabBarItem.cpp
19  * @brief               This is the implementation file for the _TabBarItem class.
20  */
21
22
23 #include <FBaseErrorDefine.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_TabBarItem.h"
26 #include "FUi_ResourceManager.h"
27 #include "FUi_AccessibilityElement.h"
28
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Ui;
31
32 namespace Tizen { namespace Ui { namespace Controls
33 {
34
35 _TabBarItem::_TabBarItem(_ControlOrientation orientation)
36         : __actionId(-1)
37         , __text(L"")
38         , __status(ITEM_STATUS_MAX)
39         , __pElement(null)
40 {
41         __bounds.x = 0.0f;
42         GET_SHAPE_CONFIG(TABBAR::TOP_MARGIN,     orientation, __bounds.y);
43         GET_SHAPE_CONFIG(TABBAR::ITEM_MIN_WIDTH, orientation, __bounds.width);
44         GET_SHAPE_CONFIG(TABBAR::ITEM_HEIGHT,    orientation, __bounds.height);
45 }
46
47
48 _TabBarItem::~_TabBarItem(void)
49 {
50 }
51
52
53 void
54 _TabBarItem::SetActionId(int actionId)
55 {
56         __actionId = actionId;
57 }
58
59 int
60 _TabBarItem::GetActionId(void) const
61 {
62         return __actionId;
63 }
64
65 void
66 _TabBarItem::SetText(const Tizen::Base::String& text, _ControlOrientation orientation)
67 {
68         float fontSize = 0.0f;
69         GET_SHAPE_CONFIG(TABBAR::FONT_SIZE, orientation, fontSize);
70         FloatDimension bounds(0.0f, 0.0f);
71
72         float minWidth   = 0.0f;
73         float maxWidth   = 0.0f;
74         float fontMargin = 0.0f;
75         GET_SHAPE_CONFIG(TABBAR::ITEM_MIN_WIDTH, orientation, minWidth);
76         GET_SHAPE_CONFIG(TABBAR::ITEM_MAX_WIDTH, orientation, maxWidth);
77         GET_SHAPE_CONFIG(TABBAR::FONT_MARGIN,    orientation, fontMargin);
78
79         Font font;
80         font.Construct(FONT_STYLE_BOLD, fontSize);
81         font.GetTextExtent(text, text.GetLength(), bounds);
82
83         bounds.width += 2.0f * fontMargin;
84         __bounds.width = bounds.width;
85
86         if (bounds.width < minWidth)
87         {
88                 __bounds.width = minWidth;
89         }
90
91         if (bounds.width > maxWidth)
92         {
93                 __bounds.width = maxWidth;
94         }
95
96         __text = text;
97 }
98
99 Tizen::Base::String
100 _TabBarItem::GetText(void) const
101 {
102         return __text;
103 }
104
105 void
106 _TabBarItem::SetStatus(_TabBarItemStatus status)
107 {
108         __status = status;
109 }
110
111 _TabBarItemStatus
112 _TabBarItem::GetStatus(void) const
113 {
114         return __status;
115 }
116
117 void
118 _TabBarItem::SetBounds(const Tizen::Graphics::FloatRectangle& bounds)
119 {
120         __bounds = bounds;
121 }
122
123 Tizen::Graphics::FloatRectangle
124 _TabBarItem::GetBounds(void) const
125 {
126         return __bounds;
127 }
128
129 void
130 _TabBarItem::SetAccessibilityElement(_AccessibilityElement* pElement)
131 {
132         __pElement = pElement;
133 }
134
135 _AccessibilityElement*
136 _TabBarItem::GetAccessibilityElement(void)
137 {
138         return __pElement;
139 }
140
141 }}} // Tizen::Ui::Controls