6e20b592531541959eb910912e3e05138a33dc39
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_TabItem.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 /**
19  * @file                FUiCtrl_TabItem.cpp
20  * @brief               This is the header file for the _TabItem class.
21  *
22  */
23
24 #include <FGrp_BitmapImpl.h>
25 #include "FUi_Control.h"
26 #include "FUi_ResourceManager.h"
27 #include "FUiCtrl_TabItem.h"
28
29
30 using namespace Tizen::Graphics;
31
32 namespace Tizen { namespace Ui { namespace Controls {
33
34 _TabItem::_TabItem(void)
35         : __actionId(-1)
36         , __bUpdate(false)
37         , __style(_TABITEM_STYLE_TEXT)
38         , __text(L"")
39         , __pbmIcon(null)
40         , __pbmBadge(null)
41         , __status(_TABITEM_STATUS_NORMAL)
42 {
43         __bounds.x = 0.0f;
44         __bounds.y = 0.0f;
45         __bounds.width = 10.0f;
46         __bounds.height = 10.0f;
47 }
48
49
50 _TabItem::~_TabItem(void)
51 {
52         if (__pbmIcon)
53         {
54                 delete __pbmIcon;
55                 __pbmIcon = null;
56         }
57
58         if (__pbmBadge)
59         {
60                 delete __pbmBadge;
61                 __pbmBadge = null;
62         }
63 }
64
65
66 void
67 _TabItem::SetActionId(int actionId)
68 {
69         __actionId = actionId;
70 }
71
72
73 int
74 _TabItem::GetActionId(void) const
75 {
76         return __actionId;
77 }
78
79
80 void
81 _TabItem::SetUpdateState(bool bUpdate)
82 {
83         __bUpdate = bUpdate;
84 }
85
86
87 int
88 _TabItem::GetUpdateState(void) const
89 {
90         return __bUpdate;
91 }
92
93
94 void
95 _TabItem::SetText(const Tizen::Base::String& text)
96 {
97         __text = text;
98 }
99
100
101 Tizen::Base::String
102 _TabItem::GetText(void) const
103 {
104         return __text;
105 }
106
107
108 void
109 _TabItem::SetIcon(const Bitmap& icon)
110 {
111
112         Tizen::Graphics::Bitmap* __pBitmap = _BitmapImpl::CloneN(icon);
113         result r = GetLastResult();
114         SysTryReturnVoidResult(NID_UI_CTRL, (__pBitmap), r, "[%s] Propagating.", GetErrorMessage(r));
115
116         __pbmIcon = __pBitmap;
117
118         __pBitmap = null;
119 }
120
121
122 Bitmap*
123 _TabItem::GetIcon(void) const
124 {
125         return __pbmIcon;
126 }
127
128
129 void
130 _TabItem::SetBadgeIcon(const Bitmap& icon)
131 {
132         Tizen::Graphics::Bitmap* __pBitmap = _BitmapImpl::CloneN(icon);
133         result r = GetLastResult();
134         SysTryReturnVoidResult(NID_UI_CTRL, (__pBitmap), r, "[%s] Propagating.", GetErrorMessage(r));
135
136         __pbmBadge = __pBitmap;
137
138         __pBitmap = null;
139 }
140
141
142 Bitmap*
143 _TabItem::GetBadgeIcon(void) const
144 {
145         return __pbmBadge;
146 }
147
148
149 void
150 _TabItem::SetItemBounds(FloatRectangle bounds)
151 {
152         __bounds = bounds;
153 }
154
155
156 FloatRectangle
157 _TabItem::GetItemBounds(void) const
158 {
159         return __bounds;
160 }
161
162
163 void
164 _TabItem::SetStatus(_TabItemStatus status)
165 {
166         __status = status;
167 }
168
169
170 _TabItemStatus
171 _TabItem::GetStatus(void) const
172 {
173         return __status;
174 }
175
176
177 void
178 _TabItem::SetStyle(int style)
179 {
180         __style = style;
181 }
182
183
184 _TabItemStyle
185 _TabItem::GetStyle(void) const
186 {
187         return _TabItemStyle(__style);
188 }
189
190
191 }}} // Tizen::Ui::Controls