Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_TabBarPresenter.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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://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  * @file                FUiCtrl_TabBarPresenter.h
19  * @brief       This is the header file for the _TabBarPresenter class.
20  *
21  * This header file contains the declarations of the %_TabBarPresenter class.
22  */
23 #ifndef _FUI_CTRL_INTERNAL_TABBAR_PRESENTER_H_
24 #define _FUI_CTRL_INTERNAL_TABBAR_PRESENTER_H_
25
26
27 #include <FBaseObject.h>
28 #include <FGrp_TextTextObject.h>
29 #include "FUi_Control.h"
30 #include "FUiCtrl_TabBar.h"
31 #include "FUiCtrl_TabBarItem.h"
32 #include "FUiCtrl_TabBarModel.h"
33
34
35 namespace Tizen { namespace Ui { namespace Controls
36 {
37 class _TabBar;
38
39 /**
40  * @class _TabBarPresenter
41  * @brief
42  * @since 2.0
43  *
44  *
45  *
46  *
47  */
48 class _TabBarPresenter
49         : public Tizen::Base::Object
50 {
51 // Lifecycle
52 public:
53         _TabBarPresenter(_TabBar& pTabBar);
54         virtual ~_TabBarPresenter(void);
55
56 // Operations
57 public:
58         result Construct(void);
59         result InitializeFont(void);
60
61         result AddItem(const Tizen::Base::String& text, int actionId);
62         result InsertItemAt(int index, const Tizen::Base::String& text, int actionId);
63         result SetItemAt(int index, const Tizen::Base::String& text, int actionId);
64         _TabBarItem* GetItemAt(int index) const;
65         result RemoveItemAt(int index);
66         result RemoveAllItems(void);
67
68         result SetItemSelected(int index);
69         int GetSelectedItemIndex(void) const;
70
71         int GetItemCount(void) const;
72         int GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const;
73         _TabBarItem* GetItemFromPosition(const Tizen::Graphics::Point& position) const;
74         result SetTopDrawnItemIndex(int index);
75
76         result SetReplacementColor(const Tizen::Graphics::Color& color);
77         result SetItemReplacementColor(_TabBarItemStatus itemStatus, const Tizen::Graphics::Color& color);
78
79         void Draw(void);
80         void InitItemPositionX(void);
81
82         virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
83         virtual void OnFontInfoRequested(unsigned long& style, int& size);
84
85         bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
86         bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
87         bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
88         void OnBoundsChanged(void);
89
90         void SetAllAccessibilityElement(void);
91
92 private:
93         result LoadBitmap(void);
94         result AdjustItemPositionX(int distance);
95         _TabBarItemStatus GetItemStatus(int index) const;
96         result SetItemStatus(int index, _TabBarItemStatus status);
97         void DrawBackground(Tizen::Graphics::Canvas* pCanvas);
98         void DrawItem(Tizen::Graphics::Canvas* pCanvas);
99         void DrawArrow(Tizen::Graphics::Canvas* pCanvas);
100         result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap);
101
102 private:
103         _TabBarPresenter(const _TabBarPresenter& rhs);
104         _TabBarPresenter& operator =(const _TabBarPresenter& rhs);
105
106 private:
107         _TabBar& __tabBar;
108         _TabBarModel* __pTabBarModel;
109
110         Tizen::Graphics::Font* __pFont;
111         Tizen::Graphics::_Text::TextObject* __pTextObject;
112         Tizen::Graphics::Point __startPosition;
113         int __highlightedItemIndex;
114         bool __touchMoved;
115         bool __touchBubblingBlocked;
116         Tizen::Graphics::Bitmap* __pBgBitmapCached;
117
118         Tizen::Graphics::Bitmap* __pItemBgBitmapCached[ITEM_STATUS_MAX];
119
120         Tizen::Graphics::Bitmap* __pLeftArrowBgBitmapCached;
121         Tizen::Graphics::Bitmap* __pRightArrowBgBitmapCached;
122         Tizen::Graphics::Bitmap* __pLeftArrowBitmapCached;
123         Tizen::Graphics::Bitmap* __pRightArrowBitmapCached;
124 }; // _TabBarPresenter
125
126 }}} // Tizen::Ui::Controls
127
128 #endif // _FUI_CTRL_INTERNAL_TABBAR_PRESENTER_H_