[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-toolkit.git] / capi / dali-toolkit / public-api / controls / buttons / button.h
1 #ifndef __DALI_TOOLKIT_BUTTON_H__
2 #define __DALI_TOOLKIT_BUTTON_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 /**
21  * @addtogroup CAPI_DALI_FRAMEWORK
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/control.h>
27
28 namespace Dali DALI_IMPORT_API
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33 class CustomActor;
34 }
35
36 namespace Toolkit
37 {
38
39 namespace Internal DALI_INTERNAL
40 {
41 class Button;
42 }
43
44 /**
45  * Button is a base class for different kind of buttons.
46  * This class provides the dimmed property and the clicked signal.
47  *
48  * A ClickedSignal() is emitted when the button is touched and the touch
49  * point doesn't leave the boundary of the button.
50  *
51  * When the \e dimmed property is set to \e true, no signal is emitted.
52  */
53 class Button : public Control
54 {
55 public:
56   //Signal Names
57   static const char* const SIGNAL_CLICKED;
58
59   /**
60    * The names of custom properties installed by this control.
61    */
62   // Property Names
63   static const char* const PROPERTY_DIMMED;      ///< name "dimmed", type bool.
64
65 public:
66
67   /**
68    * Create an uninitialized Button. Only derived versions can be instantiated.
69    * Calling member functions with an uninitialized Dali::Object is not allowed.
70    */
71   Button();
72
73   /**
74    * Copy constructor.
75    */
76   Button( const Button& button );
77
78   /**
79    * Assignment operator.
80    */
81   Button& operator=( const Button& button );
82
83   /**
84    * Downcast an Object handle to Button. If handle points to a Button the
85    * downcast produces valid handle. If not the returned handle is left uninitialized.
86    * @param[in] handle Handle to an object
87    * @return handle to a Button or an uninitialized handle
88    */
89   static Button DownCast( BaseHandle handle );
90
91   /**
92    * Virtual destructor.
93    * Dali::Object derived classes typically do not contain member data.
94    */
95   virtual ~Button();
96
97   /**
98    * Sets the button as \e dimmed.
99    *
100    * No signals are emitted when the \e dimmed property is set.
101    *
102    * @param[in] dimmed property.
103    */
104   void SetDimmed( bool dimmed );
105
106   /**
107    * @return \e true if the button is \e dimmed.
108    */
109   bool IsDimmed() const;
110
111   /**
112    * Sets the animation time.
113    * @param [in] animationTime The animation time in seconds.
114    */
115   void SetAnimationTime( float animationTime );
116
117   /**
118    * Retrieves button's animation time.
119    * @return The animation time in seconds.
120    */
121   float GetAnimationTime() const;
122
123 public: //Signals
124
125   // Button Clicked
126
127   typedef SignalV2< bool ( Button ) > ClickedSignalV2;
128
129   /**
130    * Signal emitted when the button is touched and the touch point doesn't leave the boundary of the button.
131    */
132   ClickedSignalV2& ClickedSignal();
133
134 public: // Not intended for application developers
135
136   /**
137    * Creates a handle using the Toolkit::Internal implementation.
138    * @param[in]  implementation  The Control implementation.
139    */
140   Button( Internal::Button& implementation );
141
142   /**
143    * Allows the creation of this Control from an Internal::CustomActor pointer.
144    * @param[in]  internal  A pointer to the internal CustomActor.
145    */
146   Button( Dali::Internal::CustomActor* internal );
147 };
148
149 } // namespace Toolkit
150
151 } // namespace Dali
152
153 /**
154  * @}
155  */
156 #endif // __DALI_TOOLKIT_BUTTON_H__