Merge "This patch is for refining dali application to support tizen c# application...
[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     enum
109     {
110       UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselectedIcon",  type std::string @SINCE_1_0.0
111       SELECTED_ICON,                          ///< Property, name "selectedIcon",    type std::string @SINCE_1_0.0
112       ICON_ALIGNMENT,                         ///< Property, name "iconAlignment",   type std::string @SINCE_1_0.0
113       LABEL_PADDING,                          ///< Property, name "labelPadding",    type Vector4 @SINCE_1_0.0
114       ICON_PADDING,                           ///< Property, name "iconPadding",     type Vector4 @SINCE_1_0.0
115     };
116   };
117
118 public:
119
120   /**
121    * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
122    *
123    * Calling member functions with an uninitialized Dali::Object is not allowed.
124    * @SINCE_1_0.0
125    */
126   PushButton();
127
128   /**
129    * @brief Copy constructor.
130    * @SINCE_1_0.0
131    * @param[in] pushButton Handle to an object
132    */
133   PushButton( const PushButton& pushButton );
134
135   /**
136    * @brief Assignment operator.
137    * @SINCE_1_0.0
138    * @param[in] pushButton Handle to an object
139    * @return A reference to this
140    */
141   PushButton& operator=( const PushButton& pushButton );
142
143   /**
144    * @brief Destructor
145    *
146    * This is non-virtual since derived Handle types must not contain data or virtual methods.
147    * @SINCE_1_0.0
148    */
149   ~PushButton();
150
151   /**
152    * @brief Create an initialized PushButton.
153    *
154    * @SINCE_1_0.0
155    * @return A handle to a newly allocated Dali resource.
156    */
157   static PushButton New();
158
159   /**
160    * @brief Downcast a handle to PushButton handle.
161    *
162    * If handle points to a PushButton the downcast produces valid
163    * handle. If not the returned handle is left uninitialized.
164    *
165    * @SINCE_1_0.0
166    * @param[in] handle Handle to an object
167    * @return handle to a PushButton or an uninitialized handle
168    */
169   static PushButton DownCast( BaseHandle handle );
170
171
172   // Deprecated API
173
174   using Button::SetButtonImage;
175
176   /**
177    * @DEPRECATED_1_0.50. Instead, use Button::SetUnselectedImage.
178    *
179    * @brief Sets the unselected image with an Actor.
180    *
181    * @SINCE_1_0.0
182    * @param[in] image The Actor to use.
183    */
184   void SetButtonImage( Actor image );
185
186   using Button::SetBackgroundImage;
187
188   /**
189    * @DEPRECATED_1_0.50. Instead, use Button::SetBackgroundImage.
190    *
191    * @brief Sets the background image with an Actor.
192    *
193    * @SINCE_1_0.0
194    * @param[in] image The Actor to use.
195    */
196   void SetBackgroundImage( Actor image );
197
198   using Button::SetSelectedImage;
199
200   /**
201    * @DEPRECATED_1_0.50. Instead, use Button::SetSelectedImage( const std::string& filename ).
202    *
203    * @brief Sets the selected image with an Actor.
204    *
205    * @SINCE_1_0.0
206    * @param[in] image The Actor to use.
207    */
208   void SetSelectedImage( Actor image );
209
210   using Button::SetSelectedBackgroundImage;
211
212   /**
213    * @DEPRECATED_1_0.50. Instead, use Button::SetSelectedBackgroundImage.
214    *
215    * @brief Sets the selected background image with an Actor.
216    *
217    * @SINCE_1_0.0
218    * @param[in] image The Actor to use.
219    */
220   void SetSelectedBackgroundImage( Actor image );
221
222   using Button::SetDisabledBackgroundImage;
223
224   /**
225    * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledBackgroundImage.
226    *
227    * @brief Sets the disabled background image with an Actor.
228    *
229    * @SINCE_1_0.0
230    * @param[in] image The Actor to use.
231    */
232   void SetDisabledBackgroundImage( Actor image );
233
234   using Button::SetDisabledImage;
235
236   /**
237    * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledImage.
238    *
239    * @brief Sets the disabled image with an Actor.
240    *
241    * @SINCE_1_0.0
242    * @param[in] image The Actor to use.
243    */
244   void SetDisabledImage( Actor image );
245
246   using Button::SetDisabledSelectedImage;
247
248   /**
249    * @DEPRECATED_1_0.50. Instead, use Button::SetDisabledSelectedImage.
250    *
251    * @brief Sets the disabled selected image with an Actor.
252    *
253    * @SINCE_1_0.0
254    * @param[in] image The Actor to use.
255    */
256   void SetDisabledSelectedImage( Actor image );
257
258
259 public: // Not intended for application developers
260
261   /// @cond internal
262   /**
263    * @brief Creates a handle using the Toolkit::Internal implementation.
264    *
265    * @SINCE_1_0.0
266    * @param[in]  implementation  The Control implementation.
267    */
268   DALI_INTERNAL PushButton( Internal::PushButton& implementation );
269
270   /**
271    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
272    *
273    * @SINCE_1_0.0
274    * @param[in]  internal  A pointer to the internal CustomActor.
275    */
276   DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal );
277   /// @endcond
278 };
279
280 /**
281  * @}
282  */
283 } // namespace Toolkit
284
285 } // namespace Dali
286
287 #endif // __DALI_TOOLKIT_PUSH_BUTTON_H__