Merge "rollback : support evas engine type" into tizen_2.1
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_Tab.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_Tab.cpp
20  * @brief               This is the implementation file for the _Tab class.
21  */
22
23 #include <FBaseErrorDefine.h>
24 #include <FBaseSysLog.h>
25 #include <FGrp_BitmapImpl.h>
26 #include "FUi_ResourceManager.h"
27 #include "FUi_UiTouchEvent.h"
28 #include "FUi_AccessibilityContainer.h"
29 #include "FUi_AccessibilityElement.h"
30 #include "FUi_TouchLongPressGestureDetector.h"
31 #include "FUiCtrl_Tab.h"
32 #include "FUi_CoordinateSystemUtils.h"
33
34 using namespace Tizen::Base;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Base::Runtime;
37
38 namespace Tizen { namespace Ui { namespace Controls {
39
40 _Tab::_Tab(void)
41         : __pTabPresenter(null)
42         , __style(_TAB_STYLE_TEXT)
43         , __tabStatus(_TAB_STATUS_NORMAL)
44         , __pActionEvent(null)
45         , __pGestureLongPress(null)
46         , __pFlickGesture(null)
47         , __pBackgroundBitmap(null)
48         , __pDisabledBackgroundBitmap(null)
49         , __pPressedItemBackgroundBitmap(null)
50         , __pPressedItemBackgroundEffectBitmap(null)
51         , __pSelectedItemBackgroundBitmap(null)
52         , __pHighlightedItemBackgroundBitmap(null)
53 {
54         ClearLastResult();
55         result r = E_SUCCESS;
56
57         __tabItems.Construct();
58
59         GET_COLOR_CONFIG(TAB::ITEM_BG_NORMAL, __itemBgColor[_TAB_STATUS_NORMAL]);
60         GET_COLOR_CONFIG(TAB::ITEM_BG_PRESSED, __itemBgColor[_TAB_STATUS_PRESSED]);
61         GET_COLOR_CONFIG(TAB::ITEM_BG_SELECTED, __itemBgColor[_TAB_STATUS_SELECTED]);
62         GET_COLOR_CONFIG(TAB::ITEM_BG_HIGHLIGHTED, __itemBgColor[_TAB_STATUS_HIGHLIGHTED]);
63         GET_COLOR_CONFIG(TAB::ITEM_BG_DISABLED, __itemBgColor[_TAB_STATUS_DISABLED]);
64
65         GET_COLOR_CONFIG(TAB::ITEM_TEXT_NORMAL, __itemTextColor[_TAB_STATUS_NORMAL]);
66         GET_COLOR_CONFIG(TAB::ITEM_TEXT_PRESSED, __itemTextColor[_TAB_STATUS_PRESSED]);
67         GET_COLOR_CONFIG(TAB::ITEM_TEXT_SELECTED, __itemTextColor[_TAB_STATUS_SELECTED]);
68         GET_COLOR_CONFIG(TAB::ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_TAB_STATUS_HIGHLIGHTED]);
69         GET_COLOR_CONFIG(TAB::ITEM_TEXT_DISABLED, __itemTextColor[_TAB_STATUS_DISABLED]);
70
71         r = LoadBitmap();
72         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to load bitmap.");
73
74         _Control::SetResizable(false);
75         _Control::SetMovable(false);
76
77         _TabPresenter* pPresenter = new (std::nothrow) _TabPresenter;
78         SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
79
80         r = SetPresenter(*pPresenter);
81         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance could not be set.");
82
83         r = pPresenter->Construct(*this);
84         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance construct failed.");
85
86 }
87
88 _Tab::~_Tab(void)
89 {
90         delete __pTabPresenter;
91         __pTabPresenter = null;
92
93         if (__pActionEvent)
94         {
95                 delete __pActionEvent;
96                 __pActionEvent = null;
97         }
98
99         __tabItems.RemoveAll(true);
100
101         if (__pFlickGesture != null)
102         {
103                 __pFlickGesture->RemoveGestureListener(*this);
104                 RemoveGestureDetector(*__pFlickGesture);
105
106                 delete __pFlickGesture;
107                 __pFlickGesture = null;
108         }
109
110         if (__pGestureLongPress != null)
111         {
112                 __pGestureLongPress->RemoveGestureListener(*this);
113                 RemoveGestureDetector(*__pGestureLongPress);
114
115                 delete __pGestureLongPress;
116                 __pGestureLongPress = null;
117         }
118
119         if (__pBackgroundBitmap)
120         {
121                 delete __pBackgroundBitmap;
122                 __pBackgroundBitmap = null;
123         }
124
125         if (__pDisabledBackgroundBitmap)
126         {
127                 delete __pDisabledBackgroundBitmap;
128                 __pDisabledBackgroundBitmap = null;
129         }
130
131         if (__pPressedItemBackgroundBitmap)
132         {
133                 delete __pPressedItemBackgroundBitmap;
134                 __pPressedItemBackgroundBitmap = null;
135         }
136
137         if (__pPressedItemBackgroundEffectBitmap)
138         {
139                 delete __pPressedItemBackgroundEffectBitmap;
140                 __pPressedItemBackgroundEffectBitmap = null;
141         }
142
143         if (__pSelectedItemBackgroundBitmap)
144         {
145                 delete __pSelectedItemBackgroundBitmap;
146                 __pSelectedItemBackgroundBitmap = null;
147         }
148
149         if (__pHighlightedItemBackgroundBitmap)
150         {
151                 delete __pHighlightedItemBackgroundBitmap;
152                 __pHighlightedItemBackgroundBitmap = null;
153         }
154
155         RemoveAllAccessibilityElement();
156 }
157
158 _Tab*
159 _Tab::CreateTabN(void)
160 {
161         result r = E_SUCCESS;
162
163         _Tab* pTab = new (std::nothrow) _Tab;
164         SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
165
166         if (IsFailed(GetLastResult()))
167         {
168                 goto CATCH;
169         }
170
171         pTab->AcquireHandle();
172
173         pTab->__pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector;
174         SysTryCatch(NID_UI_CTRL, pTab->__pGestureLongPress, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
175
176         pTab->__pGestureLongPress->SetDuration(500);
177         pTab->AddGestureDetector(*(pTab->__pGestureLongPress));
178         r = pTab->__pGestureLongPress->AddGestureListener(*pTab);
179         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
180
181         pTab->__pFlickGesture = new (std::nothrow) _TouchFlickGestureDetector;
182         SysTryCatch(NID_UI_CTRL, pTab->__pFlickGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
183
184         r = pTab->AddGestureDetector(*(pTab->__pFlickGesture));
185         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
186
187         r = pTab->__pFlickGesture->AddGestureListener(*pTab);
188         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
189
190         return pTab;
191
192 CATCH:
193         if (pTab->__pGestureLongPress != null)
194         {
195                 pTab->__pGestureLongPress->RemoveGestureListener(*pTab);
196                 pTab->RemoveGestureDetector(*pTab->__pGestureLongPress);
197
198                 delete pTab->__pGestureLongPress;
199                 pTab->__pGestureLongPress = null;
200         }
201         if (pTab->__pFlickGesture != null)
202         {
203                 pTab->__pFlickGesture->RemoveGestureListener(*pTab);
204                 pTab->RemoveGestureDetector(*pTab->__pFlickGesture);
205
206                 delete pTab->__pFlickGesture;
207                 pTab->__pFlickGesture = null;
208         }
209
210         delete pTab;
211         return null;
212 }
213
214 result
215 _Tab::SetPresenter(const _TabPresenter& tabPresenter)
216 {
217         ClearLastResult();
218         __pTabPresenter = const_cast<_TabPresenter*>(&tabPresenter);
219
220         return E_SUCCESS;
221 }
222
223 result
224 _Tab::AddItem(const Bitmap& icon, const String& text, int actionId)
225 {
226         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
227         {
228                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
229                 return E_OUT_OF_RANGE;
230         }
231
232         if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
233         {
234                 return E_SYSTEM;
235         }
236
237         __style = _TAB_STYLE_ICON_TEXT;
238
239         bool isDuplicate = CheckDuplicatedActionId(actionId);
240         SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId);
241
242         int itemCount = __tabItems.GetCount();
243
244         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
245
246         _TabItem *pItem = new (std::nothrow) _TabItem;
247         SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
248
249         pItem->SetIcon(icon);
250         pItem->SetText(text);
251         pItem->SetActionId(actionId);
252         pItem->SetUpdateState(true);
253
254         if (itemCount > 0)
255         {
256                 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
257         }
258         else
259         {
260                 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
261         }
262
263         __pTabPresenter->SetRecalculateItemBounds(true);
264
265         return __tabItems.Add(*pItem);
266 }
267
268 result
269 _Tab::AddItem(const Bitmap& icon, int actionId)
270 {
271         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
272         {
273                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
274                 return E_OUT_OF_RANGE;
275         }
276
277         if (__style != _TAB_STYLE_ICON)
278         {
279                 return E_SYSTEM;
280         }
281
282         bool isDuplicate = CheckDuplicatedActionId(actionId);
283         SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId);
284
285         int itemCount = __tabItems.GetCount();
286
287         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
288
289         _TabItem *pItem = new (std::nothrow) _TabItem;
290         SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
291
292         pItem->SetIcon(icon);
293         pItem->SetActionId(actionId);
294         pItem->SetUpdateState(true);
295
296         if (itemCount > 0)
297         {
298                 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
299         }
300         else
301         {
302                 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
303         }
304
305         __pTabPresenter->SetRecalculateItemBounds(true);
306
307         return __tabItems.Add(*pItem);
308 }
309
310 result
311 _Tab::AddItem(const String& text, int actionId)
312 {
313         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
314         {
315                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
316                 return E_OUT_OF_RANGE;
317         }
318
319         if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
320         {
321                 return E_SYSTEM;
322         }
323
324         bool isDuplicate = CheckDuplicatedActionId(actionId);
325         SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId);
326
327         int itemCount = __tabItems.GetCount();
328
329         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
330
331         _TabItem *pItem = new (std::nothrow) _TabItem;
332         SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
333
334         pItem->SetText(text);
335         pItem->SetActionId(actionId);
336         pItem->SetUpdateState(true);
337
338         if (itemCount > 0)
339         {
340                 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
341         }
342         else
343         {
344                 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
345         }
346
347         __pTabPresenter->SetRecalculateItemBounds(true);
348
349
350         return __tabItems.Add(*pItem);
351 }
352
353 result
354 _Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int actionId)
355 {
356         result r = E_SUCCESS;
357         bool isSelected = false;
358
359         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
360         {
361                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
362                 return E_OUT_OF_RANGE;
363         }
364
365         if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
366         {
367                 return E_SYSTEM;
368         }
369
370         __style = _TAB_STYLE_ICON_TEXT;
371
372         bool isDuplicate = CheckDuplicatedActionId(actionId);
373         SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId);
374
375         int itemCount = __tabItems.GetCount();
376
377         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
378
379         _TabItem *pItem = new (std::nothrow) _TabItem;
380         SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
381
382         pItem->SetIcon(icon);
383         pItem->SetText(text);
384         pItem->SetActionId(actionId);
385         pItem->SetUpdateState(true);
386
387         int selectedIndex = GetSelectedItemIndex();
388
389         if (selectedIndex >= index)
390         {
391                 _TabItem *pSelectedItem = null;
392                 pSelectedItem = GetItemAt(selectedIndex);
393                 if (pSelectedItem != null)
394                 {
395                         isSelected = true;
396                         pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
397                 }
398         }
399         else
400         {
401                 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
402         }
403
404         __pTabPresenter->SetRecalculateItemBounds(true);
405
406         r = __tabItems.InsertAt(*pItem, index);
407
408         if (isSelected)
409         {
410                 SetSelectedItemIndex(selectedIndex);
411         }
412
413         return r;
414 }
415
416 result
417 _Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
418 {
419         result r = E_SUCCESS;
420         bool isSelected = false;
421
422         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
423         {
424                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
425                 return E_OUT_OF_RANGE;
426         }
427
428         if (__style != _TAB_STYLE_ICON)
429         {
430                 return E_SYSTEM;
431         }
432
433         bool isDuplicate = CheckDuplicatedActionId(actionId);
434         SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId);
435
436         int itemCount = __tabItems.GetCount();
437
438         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
439
440         _TabItem *pItem = new (std::nothrow) _TabItem;
441         SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
442
443         pItem->SetIcon(icon);
444         pItem->SetActionId(actionId);
445         pItem->SetUpdateState(true);
446         int selectedIndex = GetSelectedItemIndex();
447
448         if (selectedIndex >= index)
449         {
450                 _TabItem *pSelectedItem = null;
451                 pSelectedItem = GetItemAt(selectedIndex);
452                 if (pSelectedItem != null)
453                 {
454                         isSelected = true;
455                         pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
456                 }
457         }
458         else
459         {
460                 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
461         }
462
463         __pTabPresenter->SetRecalculateItemBounds(true);
464
465         r = __tabItems.InsertAt(*pItem, index);
466
467         if (isSelected)
468         {
469                 SetSelectedItemIndex(selectedIndex);
470         }
471
472         return r;
473 }
474
475 result
476 _Tab::InsertItemAt(int index, const String& text, int actionId)
477 {
478         result r = E_SUCCESS;
479         bool isSelected = false;
480
481         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
482         {
483                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
484                 return E_OUT_OF_RANGE;
485         }
486
487         bool isDuplicate = CheckDuplicatedActionId(actionId);
488         SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId);
489
490         if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
491         {
492                 return E_SYSTEM;
493         }
494
495         int itemCount = __tabItems.GetCount();
496
497         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
498
499         _TabItem *pItem = new (std::nothrow) _TabItem;
500         SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
501
502         pItem->SetText(text);
503         pItem->SetActionId(actionId);
504         pItem->SetUpdateState(true);
505         int selectedIndex = GetSelectedItemIndex();
506
507         if (selectedIndex >= index)
508         {
509                 _TabItem *pSelectedItem = null;
510                 pSelectedItem = GetItemAt(selectedIndex);
511                 if (pSelectedItem != null)
512                 {
513                         isSelected = true;
514                         pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
515                 }
516         }
517         else
518         {
519                 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
520         }
521
522         __pTabPresenter->SetRecalculateItemBounds(true);
523
524         r = __tabItems.InsertAt(*pItem, index);
525
526         if (isSelected)
527         {
528                 SetSelectedItemIndex(selectedIndex);
529         }
530
531         return r;
532 }
533
534 result
535 _Tab::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId)
536 {
537         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
538         {
539                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
540                 return E_OUT_OF_RANGE;
541         }
542
543         if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
544         {
545                 return E_SYSTEM;
546         }
547
548         __style = _TAB_STYLE_ICON_TEXT;
549
550         int itemCount = __tabItems.GetCount();
551
552         if ((index < 0) || (index >= itemCount))
553         {
554                 return E_OUT_OF_RANGE;
555         }
556
557         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
558
559         if (GetItemIndex(actionId) != index)
560         {
561                 return E_SYSTEM;
562         }
563
564         _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
565         result r = GetLastResult();
566         SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
567
568         pItem->SetIcon(icon);
569         pItem->SetText(text);
570         pItem->SetActionId(actionId);
571         pItem->SetUpdateState(true);
572
573         return E_SUCCESS;
574 }
575
576 result
577 _Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
578 {
579         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
580         {
581                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
582                 return E_OUT_OF_RANGE;
583         }
584
585         if (__style != _TAB_STYLE_ICON)
586         {
587                 return E_SYSTEM;
588         }
589
590         int itemCount = __tabItems.GetCount();
591
592         if ((index < 0) || (index >= itemCount))
593         {
594                 return E_OUT_OF_RANGE;
595         }
596
597         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
598
599         if (GetItemIndex(actionId) != index)
600         {
601                 return E_SYSTEM;
602         }
603
604         _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
605         result r = GetLastResult();
606         SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
607
608         pItem->SetIcon(icon);
609         pItem->SetActionId(actionId);
610         pItem->SetUpdateState(true);
611
612         return E_SUCCESS;
613 }
614
615 result
616 _Tab::SetItemAt(int index, const String& text, int actionId)
617 {
618         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
619         {
620                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
621                 return E_OUT_OF_RANGE;
622         }
623
624         if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
625         {
626                 return E_SYSTEM;
627         }
628
629         int itemCount = __tabItems.GetCount();
630
631         if ((index < 0) || (index >= itemCount))
632         {
633                 return E_OUT_OF_RANGE;
634         }
635
636         SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
637
638         if (GetItemIndex(actionId) != index)
639         {
640                 return E_SYSTEM;
641         }
642
643         _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
644         result r = GetLastResult();
645         SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
646
647         pItem->SetText(text);
648         pItem->SetActionId(actionId);
649         pItem->SetUpdateState(true);
650
651         return E_SUCCESS;
652 }
653
654 result
655 _Tab::RemoveItemAt(int index)
656 {
657         result r = E_SUCCESS;
658         int selectedIndex = GetSelectedItemIndex();
659
660         if (selectedIndex >= index)
661         {
662                 _TabItem *pSelectedItem = null;
663                 pSelectedItem = GetItemAt(selectedIndex);
664                 if (pSelectedItem != null)
665                 {
666                         pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
667                 }
668         }
669         __pTabPresenter->SetRecalculateItemBounds(true);
670
671         r = __tabItems.RemoveAt(index, true);
672
673         SetSelectedItemIndex(0);
674
675         return r;
676 }
677
678 result
679 _Tab::RemoveAllItems(void)
680 {
681         __pTabPresenter->SetRecalculateItemBounds(true);
682         SetSelectedItemIndex(0);
683         SetFirstDrawnItemIndex(-1);
684
685         __tabItems.RemoveAll(true);
686
687         return E_SUCCESS;
688 }
689
690 bool
691 _Tab::ChangeItemAt(const int srcIndex, const int destIndex)
692 {
693         _TabItem* pItem = null;
694         pItem = GetItemAt(srcIndex);
695
696         __tabItems.InsertAt(*pItem, destIndex);
697
698         if (srcIndex > destIndex)
699         {
700                 __tabItems.RemoveAt((srcIndex + 1), false);
701         }
702         else
703         {
704                 __tabItems.RemoveAt(srcIndex, false);
705         }
706
707         return true;
708 }
709
710 int
711 _Tab::GetItemIndex(int actionId)
712 {
713         int itemCount = __tabItems.GetCount();
714
715         _TabItem* pItem = null;
716
717         for (int i = 0; i < itemCount; i++)
718         {
719                 pItem = GetItemAt(i);
720
721                 if ((pItem != null) && (actionId == pItem->GetActionId()))
722                 {
723                         return i;
724                 }
725         }
726
727         return -1;
728 }
729
730 bool
731 _Tab::CheckDuplicatedActionId(int actionId)
732 {
733         int itemIndex = GetItemIndex(actionId);
734
735         if (itemIndex >= 0)
736         {
737                 return true;
738         }
739
740         return false;
741 }
742
743 result
744 _Tab::LoadBitmap(void)
745 {
746         result r = E_SUCCESS;
747         Bitmap* pPressedItemBackgroundBitmap = null;
748         Bitmap* pItemBackgroundBitmap = null;
749         Bitmap* pDisabledBackgroundBitmap = null;
750         Bitmap* pSelectedItemBackgroundBitmap = null;
751         Bitmap* pPressedItemBackgroundEffectBitmap = null;
752         Bitmap* pHighlightedItemBackgroundBitmap = null;
753         Color pressedEffectColor;
754         GET_COLOR_CONFIG(TAB::ITEM_BG_EFFECT_PRESSED, pressedEffectColor);
755
756         r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisabledBackgroundBitmap);
757         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate disabled item background bitmap.");
758
759         if (pDisabledBackgroundBitmap)
760         {
761                 __pDisabledBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDisabledBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetDisabledItemBackgroundColor());
762                 SysTryLog(NID_UI_CTRL, (__pDisabledBackgroundBitmap != null), "Failed to locate disabled item background bitmap.");
763
764                 delete pDisabledBackgroundBitmap;
765         }
766
767         r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pItemBackgroundBitmap);
768         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate item background bitmap.");
769
770         if (pItemBackgroundBitmap)
771         {
772                 __pBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetItemBackgroundColor());
773                 SysTryLog(NID_UI_CTRL, (__pBackgroundBitmap != null), "Failed to locate item background bitmap.");
774
775                 delete pItemBackgroundBitmap;
776         }
777
778         r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundBitmap);
779         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap.");
780
781         if (pPressedItemBackgroundBitmap)
782         {
783                 __pPressedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetPressedItemBackgroundColor());
784                 SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundBitmap != null), "Failed to locate pressed item background bitmap.");
785
786                 delete pPressedItemBackgroundBitmap;
787         }
788
789         r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pSelectedItemBackgroundBitmap);
790         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
791
792         if (pSelectedItemBackgroundBitmap)
793         {
794                 __pSelectedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSelectedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetSelectedItemBackgroundColor());
795                 SysTryLog(NID_UI_CTRL, (__pSelectedItemBackgroundBitmap != null), "Failed to locate selected item background bitmap.");
796
797                 delete pSelectedItemBackgroundBitmap;
798         }
799
800         r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundEffectBitmap);
801         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
802
803         if (pPressedItemBackgroundEffectBitmap)
804         {
805                 __pPressedItemBackgroundEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedEffectColor);
806                 SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundEffectBitmap != null), "Failed to locate selected item background bitmap.");
807
808                 delete pPressedItemBackgroundEffectBitmap;
809         }
810
811         r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pHighlightedItemBackgroundBitmap);
812         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap.");
813
814         if (pHighlightedItemBackgroundBitmap)
815         {
816                 __pHighlightedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pHighlightedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetHighlightedItemBackgroundColor());
817                 SysTryLog(NID_UI_CTRL, (__pHighlightedItemBackgroundBitmap != null), "Failed to locate highlighted item background bitmap.");
818
819                 delete pHighlightedItemBackgroundBitmap;
820         }
821         return r;
822 }
823
824 result
825 _Tab::SetBadgeIcon(int actionId, const Bitmap* pBadgeIcon)
826 {
827         result r = E_SUCCESS;
828
829         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
830         {
831                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
832                 return E_OUT_OF_RANGE;
833         }
834
835         int itemIndex = GetItemIndexFromActionId(actionId);
836
837         _TabItem *pItem = null;
838
839         if (itemIndex < 0)
840         {
841                 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument(s) is used. The specified actionId is not found.");
842                 return E_INVALID_ARG;
843         }
844
845         pItem = dynamic_cast<_TabItem*>(__tabItems.GetAt(itemIndex));
846
847         if (pItem != null)
848         {
849                 pItem->SetBadgeIcon(*pBadgeIcon);
850
851                 r = __tabItems.SetAt(*pItem, itemIndex, false);
852         }
853
854         return r;
855 }
856
857 int
858 _Tab::GetItemCount(void) const
859 {
860         return __tabItems.GetCount();
861 }
862
863 int
864 _Tab::GetItemIndexFromActionId(int actionId) const
865 {
866         if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
867         {
868                 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
869                 return -1;
870         }
871
872         int index = 0;
873         int itemCount = __tabItems.GetCount();
874
875         for (index = 0; index < itemCount; index++)
876         {
877                 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
878
879                 if (pItem != null)
880                 {
881                         if (pItem->GetActionId() == actionId)
882                         {
883                                 return index;
884                         }
885                 }
886         }
887
888         return -1;
889 }
890
891 int
892 _Tab::GetItemActionIdAt(int index) const
893 {
894         if (__tabItems.GetAt(index) == null )
895         {
896                 return -1;
897         }
898
899         const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
900         SysTryReturn(NID_UI_CTRL, pItem != null, E_SYSTEM, E_SYSTEM,"[E_SYSTEM] A system error has occurred. Failed to get an item at index (%d).", index);
901
902         return pItem->GetActionId();
903 }
904
905 _TabItem*
906 _Tab::GetItemAt(int index)
907 {
908         if (__tabItems.GetAt(index) == null )
909         {
910                 return null;
911         }
912
913         _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
914         result r = GetLastResult();
915         SysTryReturn(NID_UI_CTRL, pItem != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
916
917         return pItem;
918 }
919
920 void
921 _Tab::SetSelectedItemIndex(int index)
922 {
923         __pTabPresenter->SetSelectedItemIndex(index);
924         return;
925 }
926
927 int
928 _Tab::GetSelectedItemIndex(void) const
929 {
930         return __pTabPresenter->GetSelectedItemIndex();
931 }
932
933 void
934 _Tab::SetFirstDrawnItemIndex(int index)
935 {
936         __pTabPresenter->SetFirstDrawnItemIndex(index);
937         return;
938 }
939
940 int
941 _Tab::GetFirstDrawnItemIndex(void) const
942 {
943         return __pTabPresenter->GetFirstDrawnItemIndex();
944 }
945
946 void
947 _Tab::SetEditModeEnabled(bool isEnabled)
948 {
949         return __pTabPresenter->SetEditModeEnabled(isEnabled);
950 }
951
952 bool
953 _Tab::IsEditModeEnabled(void) const
954 {
955         return __pTabPresenter->IsEditModeEnabled();
956 }
957
958 result
959 _Tab::SetBackgroundBitmap(const Bitmap& bitmap)
960 {
961         ClearLastResult();
962
963         Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
964
965         SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
966
967         if (__pBackgroundBitmap)
968         {
969                 delete __pBackgroundBitmap;
970                 __pBackgroundBitmap = null;
971         }
972
973         __pBackgroundBitmap = pBitmap;
974
975         if (__pDisabledBackgroundBitmap)
976         {
977                 delete __pDisabledBackgroundBitmap;
978                 __pDisabledBackgroundBitmap = null;
979         }
980
981         return E_SUCCESS;
982 }
983
984 Bitmap*
985 _Tab::GetBackgroundBitmap(void) const
986 {
987         return __pBackgroundBitmap;
988 }
989
990 Bitmap*
991 _Tab::GetDisabledBackgroundBitmap(void) const
992 {
993         return __pDisabledBackgroundBitmap;
994 }
995
996 Bitmap*
997 _Tab::GetPressedItemBackgroundBitmap(void) const
998 {
999         return __pPressedItemBackgroundBitmap;
1000 }
1001
1002 Bitmap*
1003 _Tab::GetPressedItemBackgroundEffectBitmap(void) const
1004 {
1005         return __pPressedItemBackgroundEffectBitmap;
1006 }
1007
1008 result
1009 _Tab::SetSelectedItemBackgroundBitmap(const Bitmap& bitmap)
1010 {
1011         ClearLastResult();
1012
1013         Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1014
1015         SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1016
1017         if (__pSelectedItemBackgroundBitmap)
1018         {
1019                 delete __pSelectedItemBackgroundBitmap;
1020                 __pSelectedItemBackgroundBitmap = null;
1021         }
1022         __pSelectedItemBackgroundBitmap = pBitmap;
1023         __pTabPresenter->FreeHorizontalLineBitmap();
1024
1025         return E_SUCCESS;
1026 }
1027
1028
1029 Bitmap*
1030 _Tab::GetSelectedItemBackgroundBitmap(void) const
1031 {
1032         return __pSelectedItemBackgroundBitmap;
1033 }
1034
1035 result
1036 _Tab::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap)
1037 {
1038         ClearLastResult();
1039
1040         Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1041
1042         SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1043
1044         if (__pHighlightedItemBackgroundBitmap)
1045         {
1046                 delete __pHighlightedItemBackgroundBitmap;
1047                 __pHighlightedItemBackgroundBitmap = null;
1048         }
1049
1050         __pHighlightedItemBackgroundBitmap = pBitmap;
1051
1052         return E_SUCCESS;
1053 }
1054
1055 Bitmap*
1056 _Tab::GetHighlightedItemBackgroundBitmap(void) const
1057 {
1058         return __pHighlightedItemBackgroundBitmap;
1059 }
1060
1061 void
1062 _Tab::SetItemBackgroundColor(Color color)
1063 {
1064         __itemBgColor[_TAB_STATUS_NORMAL] = color;
1065         return;
1066 }
1067
1068 Color
1069 _Tab::GetItemBackgroundColor(void) const
1070 {
1071         return __itemBgColor[_TAB_STATUS_NORMAL];
1072 }
1073
1074 Color
1075 _Tab::GetPressedItemBackgroundColor(void) const
1076 {
1077         return __itemBgColor[_TAB_STATUS_PRESSED];
1078 }
1079
1080 void
1081 _Tab::SetSelectedItemBackgroundColor(Color color)
1082 {
1083         __itemBgColor[_TAB_STATUS_SELECTED] = color;
1084         return;
1085 }
1086
1087 Color
1088 _Tab::GetSelectedItemBackgroundColor(void) const
1089 {
1090         return __itemBgColor[_TAB_STATUS_SELECTED];
1091 }
1092
1093 void
1094 _Tab::SetHighlightedItemBackgroundColor(Color color)
1095 {
1096         __itemBgColor[_TAB_STATUS_HIGHLIGHTED] = color;
1097         return;
1098 }
1099
1100 Color
1101 _Tab::GetHighlightedItemBackgroundColor(void) const
1102 {
1103         return __itemBgColor[_TAB_STATUS_HIGHLIGHTED];
1104 }
1105
1106 Color
1107 _Tab::GetDisabledItemBackgroundColor(void) const
1108 {
1109         return __itemBgColor[_TAB_STATUS_DISABLED];
1110 }
1111
1112 void
1113 _Tab::SetTextColor(const Color& textColor)
1114 {
1115         __itemTextColor[_TAB_STATUS_NORMAL] = textColor;
1116         return;
1117 }
1118
1119 Color
1120 _Tab::GetTextColor(void) const
1121 {
1122         return  __itemTextColor[_TAB_STATUS_NORMAL];
1123 }
1124
1125 Color
1126 _Tab::GetDisabledTextColor(void) const
1127 {
1128         return  __itemTextColor[_TAB_STATUS_DISABLED];
1129 }
1130
1131 void
1132 _Tab::SetPressedTextColor(const Color& textColor)
1133 {
1134         __itemTextColor[_TAB_STATUS_PRESSED] = textColor;
1135         return;
1136 }
1137
1138 Color
1139 _Tab::GetPressedTextColor(void) const
1140 {
1141         return __itemTextColor[_TAB_STATUS_PRESSED];
1142 }
1143
1144 void
1145 _Tab::SetSelectedTextColor(const Color& textColor)
1146 {
1147         __itemTextColor[_TAB_STATUS_SELECTED] = textColor;
1148         return;
1149 }
1150
1151 Color
1152 _Tab::GetSelectedTextColor(void) const
1153 {
1154         return __itemTextColor[_TAB_STATUS_SELECTED];
1155 }
1156
1157 void
1158 _Tab::SetHighlightedTextColor(const Color& color)
1159 {
1160         __itemTextColor[_TAB_STATUS_HIGHLIGHTED] = color;
1161         return;
1162 }
1163
1164 Color
1165 _Tab::GetHighlightedTextColor(void) const
1166 {
1167         return __itemTextColor[_TAB_STATUS_HIGHLIGHTED];
1168 }
1169
1170 void
1171 _Tab::SetStyle(int style)
1172 {
1173         __style = style;
1174         return;
1175 }
1176
1177 _TabStyle
1178 _Tab::GetStyle(void) const
1179 {
1180         return _TabStyle(__style);
1181 }
1182
1183 void
1184 _Tab::AddActionEventListener(const _IActionEventListener& listener)
1185 {
1186         ClearLastResult();
1187
1188         if (__pActionEvent == null)
1189         {
1190                 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1191
1192                 if (__pActionEvent == null || IsFailed(GetLastResult()))
1193                 {
1194                         SetLastResult(E_SYSTEM);
1195                         delete __pActionEvent;
1196                         return;
1197                 }
1198         }
1199         __pActionEvent->AddListener(listener);
1200         return;
1201 }
1202
1203 void
1204 _Tab::RemoveActionEventListener(const _IActionEventListener& listener)
1205 {
1206         ClearLastResult();
1207
1208         __pActionEvent->RemoveListener(listener);
1209         return;
1210 }
1211
1212 bool
1213 _Tab::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1214 {
1215         if (this != &source)
1216         {
1217                 return true;
1218         }
1219
1220         return __pTabPresenter->OnTouchPressed(source, touchinfo);
1221 }
1222
1223 bool
1224 _Tab::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1225 {
1226         if (this != &source)
1227         {
1228                 return true;
1229         }
1230
1231         __pTabPresenter->OnTouchReleased(source, touchinfo);
1232
1233         int index = __pTabPresenter->GetItemIndexFromPosition(touchinfo.GetCurrentPosition());
1234
1235         _TabItem* pItem = __pTabPresenter->GetItemAt(index);
1236
1237         if (pItem == null)
1238         {
1239                 return true;
1240         }
1241
1242         if (__pActionEvent)
1243         {
1244                 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(pItem->GetActionId());
1245                 SysTryReturn(NID_UI_CTRL, pEventArg, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1246
1247                 __pActionEvent->Fire(*pEventArg);
1248         }
1249
1250         return true;
1251 }
1252
1253 bool
1254 _Tab::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1255 {
1256         if (this != &source)
1257         {
1258                 return true;
1259         }
1260
1261         return __pTabPresenter->OnTouchMoved(source, touchinfo);
1262 }
1263
1264 bool
1265 _Tab::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
1266 {
1267         return __pTabPresenter->OnLongPressGestureDetected();
1268 }
1269
1270 bool
1271 _Tab::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
1272 {
1273         return false;
1274 }
1275
1276 bool
1277 _Tab::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1278 {
1279
1280         return __pTabPresenter->OnFlickGestureDetected(gesture);
1281 }
1282
1283 bool
1284 _Tab::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
1285 {
1286         return false;
1287 }
1288
1289 void
1290 _Tab::OnDraw(void)
1291 {
1292         ClearLastResult();
1293         __pTabPresenter->Draw();
1294         return;
1295
1296 }
1297
1298 void
1299 _Tab::OnBoundsChanged(void)
1300 {
1301         __pTabPresenter->OnBoundsChanged();
1302 }
1303
1304 result
1305 _Tab::OnAttachedToMainTree(void)
1306 {
1307         _AccessibilityContainer* pContainer = null;
1308
1309         pContainer = GetAccessibilityContainer();
1310
1311         if (pContainer)
1312         {
1313                 pContainer->Activate(true);
1314                 pContainer->AddListener(*this);
1315         }
1316
1317         return E_SUCCESS;
1318 }
1319
1320 void
1321 _Tab::OnFontChanged(Font* pFont)
1322 {
1323     __pTabPresenter->OnFontChanged(pFont);
1324     return;
1325 }
1326
1327 void
1328 _Tab::OnFontInfoRequested(unsigned long& style, float& size)
1329 {
1330     __pTabPresenter->OnFontInfoRequested(style, size);
1331     return;
1332 }
1333
1334 void
1335 _Tab::AddAccessibilityElement(const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
1336 {
1337         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1338
1339         if (pContainer != null)
1340         {
1341                 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1342                 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1343
1344                 pAccessibilityElement->SetTrait(L"Tab");
1345                 pAccessibilityElement->SetHint(L"Double tap to move to contents");
1346                 pAccessibilityElement->SetBounds(itemBounds);
1347
1348                 if (GetStyle() != _TAB_STYLE_ICON)
1349                 {
1350                         pAccessibilityElement->SetLabel(itemText);
1351                 }
1352
1353                 if (status == _TABITEM_STATUS_SELECTED)
1354                 {
1355                         pAccessibilityElement->SetStatus("Selected");
1356                         pAccessibilityElement->SetHintDisabled(true);
1357                 }
1358                 else
1359                 {
1360                         pAccessibilityElement->SetStatus("");
1361                         pAccessibilityElement->SetHintDisabled(false);
1362                 }
1363
1364                 pContainer->AddElement(*pAccessibilityElement);
1365                 __accessibilityElements.Add(pAccessibilityElement);
1366         }
1367
1368         return;
1369 }
1370
1371 void
1372 _Tab::RemoveAllAccessibilityElement(void)
1373 {
1374         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1375
1376         if (pContainer == null)
1377         {
1378                 return;
1379         }
1380
1381         _AccessibilityElement* pAccessibilityElement = null;
1382
1383         while (__accessibilityElements.GetCount() > 0)
1384         {
1385                 if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS)
1386                 {
1387                         pContainer->RemoveElement(*pAccessibilityElement);
1388                         __accessibilityElements.RemoveAt(0);
1389                 }
1390                 else
1391                 {
1392                         __accessibilityElements.RemoveAt(0);
1393                 }
1394         }
1395
1396         return;
1397 }
1398
1399 void
1400 _Tab::OnChangeLayout(_ControlOrientation orientation)
1401 {
1402         __pTabPresenter->OnChangeLayout(orientation);
1403
1404         return;
1405 }
1406
1407 bool
1408 _Tab::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1409 {
1410         ClearLastResult();
1411
1412         return __pTabPresenter->OnAccessibilityFocusMovedNext(control, element);
1413 }
1414
1415 bool
1416 _Tab::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1417 {
1418         ClearLastResult();
1419
1420         return __pTabPresenter->OnAccessibilityFocusMovedPrevious(control, element);
1421 }
1422
1423 bool
1424 _Tab::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1425 {
1426         return false;
1427 }
1428 bool
1429 _Tab::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1430 {
1431         return false;
1432 }
1433
1434 bool
1435 _Tab::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1436 {
1437         return false;
1438 }
1439
1440 bool
1441 _Tab::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1442 {
1443         return false;
1444 }
1445
1446 bool
1447 _Tab::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1448 {
1449         return false;
1450 }
1451
1452 bool
1453 _Tab::OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&)
1454 {
1455         return false;
1456 }
1457
1458 bool
1459 _Tab::OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&)
1460 {
1461         return false;
1462 }
1463
1464 }}} // Tizen::Ui::Controls
1465