2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 * @file FUiCtrl_Button.h
19 * @brief This is the header file for the _Button class.
21 * This header file contains the declarations of the %_Button class.
23 #ifndef _FUI_CTRL_INTERNAL_BUTTON_H_
24 #define _FUI_CTRL_INTERNAL_BUTTON_H_
26 #include <FUiCtrlButton.h>
27 #include "FUi_Control.h"
28 #include "FUiCtrl_IActionEventListener.h"
29 #include "FUiCtrl_ActionEvent.h"
31 namespace Tizen { namespace Ui
33 class _AccessibilityElement;
36 namespace Tizen { namespace Ui { namespace Controls
38 class _ButtonPresenter;
51 _BUTTON_STATUS_NORMAL = 0, /**< The normal status */
52 _BUTTON_STATUS_DISABLED, /**< The disabled status */
53 _BUTTON_STATUS_PRESSED, /**< The pressed status */
54 _BUTTON_STATUS_HIGHLIGHTED, /**< The highlighted status */
55 _BUTTON_STATUS_SELECTED /**< The slecteded status */
64 class _OSP_EXPORT_ _Button
65 : public Tizen::Ui::_Control
66 , public _IPropertyChangeEventListener
67 , virtual public Tizen::Base::Runtime::IEventListener
68 , virtual public Tizen::Ui::_IUiEventListener
69 , virtual public Tizen::Ui::_IUiEventPreviewer
71 DECLARE_CLASS_BEGIN(_Button, _Control);
72 DECLARE_PROPERTY("normalColor", GetPropertyNormalColor, SetPropertyNormalColor);
73 DECLARE_PROPERTY("disabledColor", GetPropertyDisabledColor, SetPropertyDisabledColor);
74 DECLARE_PROPERTY("pressedColor", GetPropertyPressedColor, SetPropertyPressedColor);
75 DECLARE_PROPERTY("highlightedColor", GetPropertyHighlightedColor, SetPropertyHighlightedColor);
76 DECLARE_PROPERTY("selectedColor", GetPropertySelectedColor, SetPropertySelectedColor);
77 DECLARE_PROPERTY("normalTextColor", GetPropertyNormalTextColor, SetPropertyNormalTextColor);
78 DECLARE_PROPERTY("disabledTextColor", GetPropertyDisabledTextColor, SetPropertyDisabledTextColor);
79 DECLARE_PROPERTY("pressedTextColor", GetPropertyPressedTextColor, SetPropertyPressedTextColor);
80 DECLARE_PROPERTY("highlightedTextColor", GetPropertyHighlightedTextColor, SetPropertyHighlightedTextColor);
81 DECLARE_PROPERTY("selectedTextColor", GetPropertySelectedTextColor, SetPropertySelectedTextColor);
82 DECLARE_PROPERTY("text", GetPropertyText, SetPropertyText);
83 DECLARE_PROPERTY("textSize", GetPropertyTextSize, SetPropertyTextSize);
84 DECLARE_PROPERTY("actionId", GetPropertyActionId, SetPropertyActionId);
87 result SetPropertyNormalColor(const Variant& color);
88 Variant GetPropertyNormalColor(void) const;
89 result SetPropertyDisabledColor(const Variant& color);
90 Variant GetPropertyDisabledColor(void) const;
91 result SetPropertyPressedColor(const Variant& color);
92 Variant GetPropertyPressedColor(void) const;
93 result SetPropertyHighlightedColor(const Variant& color);
94 Variant GetPropertyHighlightedColor(void) const;
95 result SetPropertySelectedColor(const Variant& color);
96 Variant GetPropertySelectedColor(void) const;
98 result SetPropertyNormalTextColor(const Variant& color);
99 Variant GetPropertyNormalTextColor(void) const;
100 result SetPropertyDisabledTextColor(const Variant& color);
101 Variant GetPropertyDisabledTextColor(void) const;
102 result SetPropertyPressedTextColor(const Variant& color);
103 Variant GetPropertyPressedTextColor(void) const;
104 result SetPropertyHighlightedTextColor(const Variant& color);
105 Variant GetPropertyHighlightedTextColor(void) const;
106 result SetPropertySelectedTextColor(const Variant& color);
107 Variant GetPropertySelectedTextColor(void) const;
109 result SetPropertyText(const Variant& text);
110 Variant GetPropertyText(void) const;
112 result SetPropertyTextSize(const Variant& textSize);
113 Variant GetPropertyTextSize(void) const;
114 result SetPropertyActionId(const Variant& actionId);
115 Variant GetPropertyActionId(void) const;
117 virtual void OnPropertyChanging(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty);
118 virtual void OnPropertyChanged(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty);
121 virtual ~_Button(void);
124 static _Button* CreateButtonN(void);
126 virtual void OnDraw(void);
127 virtual result OnAttachedToMainTree(void);
128 virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
129 virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
130 virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
131 virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
132 virtual void OnTouchMoveHandled(const _Control& control);
133 virtual void OnBoundsChanged(void);
134 virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
135 virtual void OnFontInfoRequested(unsigned long& style, int& size);
136 virtual Tizen::Graphics::Dimension GetContentSize(void) const;
139 result SetText(const Tizen::Base::String& text);
140 Tizen::Base::String GetText(void) const;
142 result SetColor(_ButtonStatus status, const Tizen::Graphics::Color& color);
143 Tizen::Graphics::Color GetColor(_ButtonStatus status) const;
145 result AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener);
146 result RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener);
148 result SetActionId(int actionId);
149 int GetActionId(void) const;
151 result SetTextHorizontalAlignment(HorizontalAlignment alignment);
152 HorizontalAlignment GetTextHorizontalAlignment(void) const;
153 result SetTextVerticalAlignment(VerticalAlignment alignment);
154 VerticalAlignment GetTextVerticalAlignment(void) const;
156 result SetTextColor(_ButtonStatus status, const Tizen::Graphics::Color& color);
157 Tizen::Graphics::Color GetTextColor(_ButtonStatus status) const;
159 result SetBitmap(_ButtonStatus status, const Tizen::Graphics::Point& position, const Tizen::Graphics::Bitmap& bitmap);
160 Tizen::Graphics::Bitmap* GetBitmap(_ButtonStatus status) const;
161 Tizen::Graphics::Point GetBitmapPosition(_ButtonStatus status) const;
163 result SetToolbarItemBackgroundBitmap(_ButtonStatus status, const Tizen::Graphics::Bitmap& bitmap);
164 Tizen::Graphics::Bitmap* GetToolbarItemBackgroundBitmap(_ButtonStatus status) const;
166 result SetToolbarSelectedBitmap(const Tizen::Graphics::Bitmap& bitmap, bool drawInner);
167 Tizen::Graphics::Bitmap* GetToolbarSelectedBitmap(void) const;
169 result SetBackgroundBitmap(_ButtonStatus status, const Tizen::Graphics::Bitmap& bitmap);
170 Tizen::Graphics::Bitmap* GetBackgroundBitmap(_ButtonStatus status) const;
172 result SetBackgroundEffectBitmap(_ButtonStatus status, const Tizen::Graphics::Bitmap& bitmap);
173 Tizen::Graphics::Bitmap* GetBackgroundEffectBitmap(_ButtonStatus status) const;
175 result SetTextSize(int size, unsigned long fontStyle = Tizen::Graphics::FONT_STYLE_PLAIN);
176 int GetTextSize(void) const;
178 result SetButtonStyle(_ButtonStyle buttonStyle);
179 _ButtonStyle GetButtonStyle(void) const;
181 result SetButtonStatus(_ButtonStatus buttonStatus, bool fire = true);
182 _ButtonStatus GetButtonStatus(void) const;
184 result SetTextMaxLine(int textMaxLine);
185 int GetTextMaxLine(void) const;
187 result UnloadBackgroundBitmap(_ButtonStatus status);
188 result UnloadBackgroundEffectBitmap(_ButtonStatus status);
189 bool IsUserBackgroundBitmap(_ButtonStatus status) const;
190 bool IsUserBackgroundEffectBitmap(_ButtonStatus status) const;
193 result FireActionEvent(void);
195 result SetUserDefinedTextArea(const Tizen::Graphics::Rectangle& bounds);
196 Tizen::Graphics::Rectangle GetUserDefinedTextArea(void) const;
198 bool UserDefinedText(void) const;
199 bool IsDrawInner(void) const;
201 result SetMargin(int topMargin, int leftMargin);
202 int GetTopMargin(void) const;
203 int GetLeftMargin(void) const;
205 Tizen::Graphics::Dimension GetContentSizeInternal(void) const;
206 int GetTextExtentSize(void) const;
209 result SetPresenter(const _ButtonPresenter& buttonPresenter);
212 bool IsTouchAreaChanged(bool currentButtonArea);
213 void InitializeAccessibilityElement(void);
216 _Button(const _Button& rhs);
217 _Button& operator =(const _Button& rhs);
222 NUMBER_OF_BUTTON_STATUS = 5
226 _ButtonPresenter* __pButtonPresenter;
227 _ActionEvent* __pActionEvent;
231 Tizen::Base::String __text;
233 Tizen::Graphics::Color __textColor[NUMBER_OF_BUTTON_STATUS];
234 Tizen::Graphics::Color __color[NUMBER_OF_BUTTON_STATUS];
236 Tizen::Graphics::Bitmap* __pBitmap[NUMBER_OF_BUTTON_STATUS];
237 Tizen::Graphics::Point __bitmapPosition[NUMBER_OF_BUTTON_STATUS];
239 Tizen::Graphics::Bitmap* __pToolbarItemBackgroundBitmap[NUMBER_OF_BUTTON_STATUS];
240 Tizen::Graphics::Bitmap* __pBackgroundBitmap[NUMBER_OF_BUTTON_STATUS];
241 Tizen::Graphics::Bitmap* __pBackgroundEffectBitmap[NUMBER_OF_BUTTON_STATUS];
242 Tizen::Graphics::Bitmap* __pToolbarSelectedBitmap;
244 HorizontalAlignment __horizontalAlignment;
245 VerticalAlignment __verticalAlignment;
247 _ButtonStatus __buttonStatus;
248 _ButtonStyle __buttonStyle;
253 int __parentMoveDistance;
255 bool __isUserBackgroundBitmap[NUMBER_OF_BUTTON_STATUS];
256 bool __isUserBackgroundEffectBitmap[NUMBER_OF_BUTTON_STATUS];
258 bool __previousTouchArea;
260 bool __userDefinedText;
267 Tizen::Graphics::Rectangle __userDefinedTextArea;
269 Tizen::Ui::_AccessibilityElement* __pTextElement;
272 }}} // Tizen::Ui::Controls
274 #endif // _FUI_CTRL_INTERNAL_BUTTON_H_