Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_CheckButtonPresenter.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_CheckButtonPresenter.h
19  * @brief               This is the header file for the _CheckButtonPresenter class.
20  *
21  * This header file contains the declarations of the %_CheckButtonPresenter class.
22  */
23 #ifndef _FUI_CTRL_INTERNAL_CHECK_BUTTON_PRESENTER_H_
24 #define _FUI_CTRL_INTERNAL_CHECK_BUTTON_PRESENTER_H_
25
26 #include <FBaseObject.h>
27 #include <FGrp_TextTextObject.h>
28 #include "FUi_Control.h"
29
30 namespace Tizen { namespace Ui { namespace Animations
31 {
32 class _VisualElement;
33 }}}  // Tizen::Ui::Animations
34
35 namespace Tizen { namespace Ui { namespace Controls
36 {
37 class _CheckButton;
38 class _CheckButtonModel;
39
40 /**
41  * @class _CHeckButtonPresenter
42  * @brief
43  * @since       1.0
44  *
45  *
46  *
47  *
48  */
49 class _CheckButtonPresenter
50         : public Tizen::Base::Object
51         , public Tizen::Base::Runtime::ITimerEventListener
52 {
53 public:
54         _CheckButtonPresenter(void);
55         virtual ~_CheckButtonPresenter(void);
56
57 public:
58         virtual result Construct(const _CheckButton& checkButton);
59         virtual result Install(void);
60
61         virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
62         virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
63         virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
64         virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
65         virtual void OnTouchMoveHandled(const _Control& control);
66
67         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
68
69         void Draw(void);
70
71         void OnFontChanged(Tizen::Graphics::Font* pFont);
72         void OnFontInfoRequested(unsigned long& style, int& size);
73         void SetFontInfo(unsigned long style, int size);
74
75         Tizen::Graphics::Rectangle GetTitleTextBounds(void) const;
76         Tizen::Graphics::Rectangle GetTextBounds(void) const;
77         Tizen::Graphics::Rectangle GetDefaultButtonBounds(void) const;
78         Tizen::Graphics::Rectangle GetOnOffSlidingButtonBounds(void) const;
79         Tizen::Graphics::Rectangle GetDetailedButtonBounds(void) const;
80
81         result StartCheckAnimationTimer(void);
82         result ResetCheckAnimationTimer(void);
83
84 protected:
85         result SetModel(const _CheckButtonModel& checkButtonModel);
86
87 private:
88         _CheckButtonPresenter(const _CheckButtonPresenter& rhs);
89         _CheckButtonPresenter& operator =(const _CheckButtonPresenter& rhs);
90
91         void DrawBackground(void);
92         void DrawCheckBitmap(void);
93         void DrawText(void);
94
95         bool IsEnabledStateChanged(void);
96         result CalculateTitleTextBounds(void);
97         result CalculateTextBounds(void);
98         result CalculateButtonBounds(void);
99
100         void DrawMarkAnimation(void);
101
102 private:
103         _CheckButton* __pCheckButton;
104         _CheckButtonModel* __pCheckButtonModel;
105         bool __previousEnabledState;
106         bool __touchMoveHandled;
107
108         Tizen::Graphics::Font* __pTextFont;
109         Tizen::Graphics::Font* __pTitleTextFont;
110         Tizen::Graphics::_Text::TextObject* __pTextObject;
111         Tizen::Graphics::_Text::TextObject* __pTitleTextObject;
112
113         Tizen::Graphics::Rectangle __titleTextBounds;
114         Tizen::Graphics::Rectangle __textBounds;
115         Tizen::Graphics::Rectangle __defaultButtonBounds;
116         Tizen::Graphics::Rectangle __onOffSlidingButtonBounds;
117         Tizen::Graphics::Rectangle __detailedButtonBounds;
118
119         unsigned long __fontStyle;
120         int __fontSize;
121
122         static const int CHECK_ACTION_TIMER_PERIOD = 10;
123         static const int RATIO_MAX = 10;
124         Tizen::Base::Runtime::Timer* __pCheckAnimationTimer;
125         int __ratio;
126
127 }; // _CheckButtonPresenter
128
129 }}} // Tizen::Ui::Controls
130
131 #endif  // _FUI_CTRL_INTERNAL_CHECK_BUTTON_PRESENTER_H_