Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_ToolbarPresenter.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_ToolbarPresenter.h
19  * @brief               This is the header file for the _ToolbarPresenter class.
20  *
21  * This header file contains the declarations of the %_ToolbarPresenter class.
22  */
23
24 #ifndef _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_
25 #define _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_
26
27 #include <FBaseObject.h>
28 #include <FGrp_TextTextObject.h>
29 #include "FUiCtrl_Toolbar.h"
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 class _Toolbar;
35 class _ToolbarModel;
36 class _Label;
37
38 enum ToolbarSeparatorType
39 {
40         TOOLBAR_SEPARATOR_HEADER_BUTTON = 0,
41         TOOLBAR_SEPARATOR_HEADER_SEGMENT,
42         TOOLBAR_SEPARATOR_HEADER_SEGMENT_TITLE,
43         TOOLBAR_SEPARATOR_FOOTER_BUTTON,
44         TOOLBAR_SEPARATOR_FOOTER_SEGMENT,
45         TOOLBAR_SEPARATOR_FOOTER_TOOLBAR,
46         TOOLBAR_SEPARATOR_FOOTER_TAB
47 };
48
49 /**
50  * @class       _ToolbarPresenter
51  * @brief       The presenter class of _Toolbar class
52  * @since 2.0
53  */
54 class _ToolbarPresenter
55         : public Tizen::Base::Object
56         , public Tizen::Base::Runtime::ITimerEventListener
57         , virtual public Tizen::Base::Runtime::IEventListener
58 {
59 public:
60         _ToolbarPresenter(void);
61
62         virtual ~_ToolbarPresenter(void);
63
64         result Construct(const _Toolbar& toolbar);
65
66         result Install(void);
67
68         result Draw(void);
69
70         void DrawBackground(void);
71
72         void DrawDescriptionText(void);
73
74         void DrawEditItem(const Tizen::Graphics::Point& point);
75
76         void DrawSeparator(ToolbarSeparatorType type, const Tizen::Graphics::Point& point, Tizen::Graphics::Canvas* pCanvas);
77
78         void DrawItems(void);
79
80         result DrawTitleText(Tizen::Graphics::Canvas* pCanvas);
81
82         int GetSelectedItemIndex(void) const;
83
84         bool IsInitialDraw(void) const;
85
86         bool IsTabEditModeEnabled(void) const;
87
88         result SetDescriptionText(const Tizen::Base::String& description);
89
90         result SetItemSelected(int itemIndex);
91
92         result SetInitialDrawState(bool state);
93
94         result SetTabEditModeEnabled(bool enable);
95
96         result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment);
97
98         result SetUsableAreaBounds(const Tizen::Graphics::Rectangle& rect);
99
100         bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
101
102         bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
103
104         bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
105
106         bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
107
108         bool OnLongPressGestureDetected(void);
109
110         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
111
112         result TimerForTitleSlideInit(void);
113
114         result TimerForTitleSlideStart(void);
115
116         result TimerForTitleSlideTimeout(void);
117
118         Tizen::Graphics::Rectangle GetTitleTextBounds(void) const;
119
120         Tizen::Graphics::Rectangle GetDescriptionBounds(void) const;
121
122         void OnFontChanged(Tizen::Graphics::Font* pFont);
123         void OnFontInfoRequested(unsigned long& style, int& size);
124         void SetFontInfo(unsigned long style, int size);
125
126 protected:
127         result _SetModel(const _ToolbarModel& toolbarModel);
128
129 private:
130         result AdjustItemPositionX(int distance);
131
132 private:
133         _Toolbar* __pToolbar;
134
135         _ToolbarModel* __pToolbarModel;
136
137         bool __initialDraw;
138
139         bool __tabEditEnabled;
140
141         bool __beingEdited;
142
143         bool __touchInitiatedInToolbar;
144
145         int __editItemIndex;
146
147         int __initialPressedItemIndex;
148
149         _ButtonStatus __initialPressesItemStatus;
150
151         _Label* __pEditItem;
152
153         Tizen::Graphics::Bitmap* __pTitleBackgroundBitmap;
154
155         Tizen::Base::Runtime::Timer* __pTitleSlideTimer;
156
157         Tizen::Graphics::Rectangle __titleRect;
158
159         Tizen::Graphics::Rectangle __descriptionRect;
160
161         Tizen::Graphics::Rectangle __toolbarUsableArea;
162
163         Tizen::Graphics::Point __currentTouchPosition;
164
165         Tizen::Base::String __titleText;
166
167         Tizen::Graphics::Font* __pTitleTextFont;
168
169         Tizen::Graphics::Font* __pTextFont;
170
171         Tizen::Graphics::_Text::TextObject* __pDescriptionTextObject;
172
173         Tizen::Graphics::_Text::TextObject* __pTitleTextObject;
174
175         Tizen::Graphics::_Text::TextObjectActionType __titleSlidingAction;
176
177         unsigned long __fontStyle;
178         int __fontSize;
179
180         bool __touchMoveHandled;
181
182 private:
183         _ToolbarPresenter(const _ToolbarPresenter& value);
184
185         _ToolbarPresenter& operator =(const _ToolbarPresenter& value);
186
187 };
188
189 }}} // Tizen::Ui::Controls
190
191 #endif  // _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_