Merge "Add deprecated tag and missed doxygen" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / push-button.h
1 #ifndef __DALI_TOOLKIT_PUSH_BUTTON_H__
2 #define __DALI_TOOLKIT_PUSH_BUTTON_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 // INTERNAL INCLUDES
22 #include "button.h"
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 // Forward declarations
31
32 namespace Internal DALI_INTERNAL
33 {
34 // Forward declarations
35
36 class PushButton;
37 }
38 /**
39  * @addtogroup dali_toolkit_controls_buttons
40  * @{
41  */
42
43 /**
44  * @brief A PushButton changes its appearance when is pressed and returns to its original when is released.
45  *
46  * By default a PushButton emits a Button::PressedSignal() signal when the button is pressed, a Button::ClickedSignal() signal when it's clicked
47  * and a Button::ReleasedSignal() signal when it's released or having pressed it, the touch point leaves the boundary of the button.
48  *
49  * Usage example: -
50  *
51  * @code
52  * // in Creating a DALi Application
53  * void HelloWorldExample::Create( Application& application )
54  * {
55  *   PushButton button = PushButton::New();
56  *   button.SetParentOrigin( ParentOrigin::CENTER );
57  *   button.SetLabelText( "Press" );
58  *   Stage::GetCurrent().Add( button );
59  *
60  *   // Connect to button signals emitted by the button
61  *   button.ClickedSignal().Connect( this, &HelloWorldExample::OnButtonClicked );
62  *   button.PressedSignal().Connect( this, &HelloWorldExample::OnButtonPressed );
63  *   button.ReleasedSignal().Connect( this, &HelloWorldExample::OnButtonReleased );
64  * }
65  *
66  * bool HelloWorldExample::OnButtonClicked( Button button )
67  * {
68  *   // Do something when the button is clicked
69  *   return true;
70  * }
71  *
72  * bool HelloWorldExample::OnButtonPressed( Button button )
73  * {
74  *   // Do something when the button is pressed
75  *   return true;
76  * }
77  *
78  * bool HelloWorldExample::OnButtonReleased( Button button )
79  * {
80  *   // Do something when the button is released
81  *   return true;
82  * }
83  * @endcode
84  *
85  * See Button for more detail on signals and modifying appearance via properties.
86  * @SINCE_1_0.0
87  */
88 class DALI_IMPORT_API PushButton : public Button
89 {
90 public:
91
92   /**
93    * @brief The start and end property ranges for this control.
94    * @SINCE_1_0.0
95    */
96   enum PropertyRange
97   {
98     PROPERTY_START_INDEX = Button::PROPERTY_END_INDEX + 1,          ///< @SINCE_1_0.0
99     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserving 1000 property indices @SINCE_1_0.0
100   };
101
102   /**
103    * @brief An enumeration of properties belonging to the PushButton class.
104    * @SINCE_1_0.0
105    */
106   struct Property
107   {
108     /**
109      * @brief An enumeration of properties belonging to the PushButton class.
110      * @SINCE_1_0.0
111      */
112     enum
113     {
114       UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselectedIcon",  type std::string @SINCE_1_0.0
115       SELECTED_ICON,                          ///< Property, name "selectedIcon",    type std::string @SINCE_1_0.0
116       ICON_ALIGNMENT,                         ///< Property, name "iconAlignment",   type std::string @SINCE_1_0.0
117       LABEL_PADDING,                          ///< Property, name "labelPadding",    type Vector4 @SINCE_1_0.0
118       ICON_PADDING,                           ///< Property, name "iconPadding",     type Vector4 @SINCE_1_0.0
119     };
120   };
121
122 public:
123
124   /**
125    * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
126    *
127    * Calling member functions with an uninitialized Dali::Object is not allowed.
128    * @SINCE_1_0.0
129    */
130   PushButton();
131
132   /**
133    * @brief Copy constructor.
134    * @SINCE_1_0.0
135    * @param[in] pushButton Handle to an object
136    */
137   PushButton( const PushButton& pushButton );
138
139   /**
140    * @brief Assignment operator.
141    * @SINCE_1_0.0
142    * @param[in] pushButton Handle to an object
143    * @return A reference to this
144    */
145   PushButton& operator=( const PushButton& pushButton );
146
147   /**
148    * @brief Destructor
149    *
150    * This is non-virtual since derived Handle types must not contain data or virtual methods.
151    * @SINCE_1_0.0
152    */
153   ~PushButton();
154
155   /**
156    * @brief Create an initialized PushButton.
157    *
158    * @SINCE_1_0.0
159    * @return A handle to a newly allocated Dali resource.
160    */
161   static PushButton New();
162
163   /**
164    * @brief Downcast a handle to PushButton handle.
165    *
166    * If handle points to a PushButton the downcast produces valid
167    * handle. If not the returned handle is left uninitialized.
168    *
169    * @SINCE_1_0.0
170    * @param[in] handle Handle to an object
171    * @return handle to a PushButton or an uninitialized handle
172    */
173   static PushButton DownCast( BaseHandle handle );
174
175
176   // Deprecated API
177
178   using Button::SetButtonImage;
179
180   /**
181    * @DEPRECATED_1_0.50. Instead, use Button::SetUnselectedImage.
182    *
183    * @brief Sets the unselected image with an Actor.
184    *
185    * @SINCE_1_0.0
186    * @param[in] image The Actor to use.
187    */
188   void SetButtonImage( Actor image );
189
190   using Button::SetBackgroundImage;
191
192   /**
193    * @DEPRECATED_1_0.50. Instead, use Button::SetBackgroundImage.
194    *
195    * @brief Sets the background image with an Actor.
196    *
197    * @SINCE_1_0.0
198    * @param[in] image The Actor to use.
199    */
200   void SetBackgroundImage( Actor image );
201
202   using Button::SetSelectedImage;
203
204   /**
205    * @DEPRECATED_1_0.50. Instead, use Button::SetSelectedImage( const std::string& filename ).
206    *
207    * @brief Sets the selected image with an Actor.
208    *
209    * @SINCE_1_0.0
210    * @param[in] image The Actor to use.
211    */
212   void SetSelectedImage( Actor image );
213
214   using Button::SetSelectedBackgroundImage;
215
216   /**
217    * @DEPRECATED_1_0.50. Instead, use Button::SetSelectedBackgroundImage.
218    *
219    * @brief Sets the selected background image with an Actor.
220    *
221    * @SINCE_1_0.0
222    * @param[in] image The Actor to use.
223    */
224   void SetSelectedBackgroundImage( Actor image );
225
226   using Button::SetDisabledBackgroundImage;
227
228   /**
229    * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledBackgroundImage.
230    *
231    * @brief Sets the disabled background image with an Actor.
232    *
233    * @SINCE_1_0.0
234    * @param[in] image The Actor to use.
235    */
236   void SetDisabledBackgroundImage( Actor image );
237
238   using Button::SetDisabledImage;
239
240   /**
241    * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledImage.
242    *
243    * @brief Sets the disabled image with an Actor.
244    *
245    * @SINCE_1_0.0
246    * @param[in] image The Actor to use.
247    */
248   void SetDisabledImage( Actor image );
249
250   using Button::SetDisabledSelectedImage;
251
252   /**
253    * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledSelectedImage.
254    *
255    * @brief Sets the disabled selected image with an Actor.
256    *
257    * @SINCE_1_0.0
258    * @param[in] image The Actor to use.
259    */
260   void SetDisabledSelectedImage( Actor image );
261
262
263 public: // Not intended for application developers
264
265   /// @cond internal
266   /**
267    * @brief Creates a handle using the Toolkit::Internal implementation.
268    *
269    * @SINCE_1_0.0
270    * @param[in]  implementation  The Control implementation.
271    */
272   DALI_INTERNAL PushButton( Internal::PushButton& implementation );
273
274   /**
275    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
276    *
277    * @SINCE_1_0.0
278    * @param[in]  internal  A pointer to the internal CustomActor.
279    */
280   DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal );
281   /// @endcond
282 };
283
284 /**
285  * @}
286  */
287 } // namespace Toolkit
288
289 } // namespace Dali
290
291 #endif // __DALI_TOOLKIT_PUSH_BUTTON_H__