Update copyright year to 2015 for public api: toolkit
[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 /**
40  * @brief A PushButton changes its appearance when is pressed and returns to its original when is released.
41  *
42  * By default a PushButton emits a Button::PressedSignal() signal when the button is pressed, a Button::ClickedSignal() signal when it's clicked
43  * and a Button::ReleasedSignal() signal when it's released or having pressed it, the touch point leaves the boundary of the button.
44  *
45  * PushButton provides the following properties which modify signals emitted:
46  * <ul>
47  *   <li>\e autorepeating
48  *
49  *       When \e autorepeating is set to \e true, a Button::PressedSignal(), Button::ReleasedSignal() and Button::ClickedSignal() signals are emitted at regular
50  *       intervals while the button is touched.
51  *
52  *       The intervals could be modified with the PushButton::SetInitialAutoRepeatingDelay and PushButton::SetNextAutoRepeatingDelay methods.
53  *
54  *       A \e togglable button can't be \e autorepeating. If the \e autorepeating property is set to \e true, then the \e togglable property is set to
55  *       false but no signal is emitted.
56  *
57  *   <li>\e togglable
58  *
59  *       When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state, every time the button is touched instead
60  *       of emit Button::PressedSignal(), Button::ClickedSignal() and Button::ReleasedSignal() signals.
61  *
62  *       An \e autorepeating button can't be \e togglable. If the \e togglable property is set to \e true, then the \e autorepeating property is set to false.
63  * </ul>
64  *
65  * The button's appearance could be modified by setting images or actors with PushButton::SetButtonImage, PushButton::SetBackgroundImage,
66  * PushButton::SetSelectedImage, PushButton::SetDisabledBackgroundImage and  PushButton::SetDisabledImage or setting a text with
67  * PushButton::SetLabel.
68  *
69  * The \e background is always shown and doesn't change if the button is pressed or released. The \e button image is shown over the \e background image when the
70  * button is not pressed and is replaced by the \e selected image when the button is pressed. The text label is placed always on the top of all images.
71  *
72  * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images.
73  *
74  * The methods used to modify the button's appearance could receive Dali::Actor objects as a parameter, so more complex images could be defined.
75  *
76  * Is not mandatory set all images. A button could be defined only by setting its \e background image or by setting its \e background and \e selected images.
77  */
78 class DALI_IMPORT_API PushButton : public Button
79 {
80 public:
81
82   /**
83    * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
84    *
85    * Calling member functions with an uninitialized Dali::Object is not allowed.
86    */
87   PushButton();
88
89   /**
90    * @brief Copy constructor.
91    */
92   PushButton( const PushButton& pushButton );
93
94   /**
95    * @brief Assignment operator.
96    */
97   PushButton& operator=( const PushButton& pushButton );
98
99   /**
100    * @brief Destructor
101    *
102    * This is non-virtual since derived Handle types must not contain data or virtual methods.
103    */
104   ~PushButton();
105
106   /**
107    * @brief Create an initialized PushButton.
108    *
109    * @return A handle to a newly allocated Dali resource.
110    */
111   static PushButton New();
112
113   /**
114    * @brief Downcast an Object handle to PushButton.
115    *
116    * If handle points to a PushButton the downcast produces valid
117    * handle. If not the returned handle is left uninitialized.
118    *
119    * @param[in] handle Handle to an object
120    * @return handle to a PushButton or an uninitialized handle
121    */
122   static PushButton DownCast( BaseHandle handle );
123
124   /**
125    * @brief Sets the button image.
126    *
127    * @param[in] image The button image.
128    */
129   void SetButtonImage( Image image );
130
131   /**
132    * @brief SetButtonImage
133    *
134    * @param[in] image The Actor to be used as the button image.
135    *
136    * The natural size of the button would be the size of this Actor
137    * if it's larger than the background and label
138    */
139   void SetButtonImage( Actor image );
140
141   /**
142    * @brief Gets the button image.
143    *
144    * @return An actor with the button image.
145    */
146   Actor GetButtonImage() const;
147
148   /**
149    * @brief Sets the background image.
150    *
151    * @param[in] image The background image.
152    */
153   void SetBackgroundImage( Image image );
154
155   /**
156    * @brief SetBackgroundImage
157    *
158    * @param[in] image The Actor to be used as the background image.
159    *
160    * The natural size of the button would be the size of this Actor
161    * if it's larger than the button and label
162    */
163   void SetBackgroundImage( Actor image );
164
165   /**
166    * @brief Gets the background image.
167    *
168    * @return An actor with the background image.
169    */
170   Actor GetBackgroundImage() const;
171
172   /**
173    * @brief Sets the selected image.
174    *
175    * @param[in] image The selected image.
176    */
177   void SetSelectedImage( Image image );
178
179   /**
180    * @copydoc SetSelectedImage( Image image )
181    */
182   void SetSelectedImage( Actor image );
183
184   /**
185    * @brief Gets the selected image.
186    *
187    * @return An actor with the selected image.
188    */
189   Actor GetSelectedImage() const;
190
191   /**
192    * @brief Sets the selected background image.
193    *
194    * @param[in] image The selected background image.
195    */
196   void SetSelectedBackgroundImage( Image image );
197
198   /**
199    * @copydoc SetSelectedBackgroundImage( Image image )
200    */
201   void SetSelectedBackgroundImage( Actor image );
202
203   /**
204    * @brief Gets the selected background image.
205    *
206    * @return An actor with the selected background image.
207    */
208   Actor GetSelectedBackgroundImage() const;
209
210   /**
211    * @brief Sets the disabled background image.
212    *
213    * @param[in] image The disabled background image.
214    */
215   void SetDisabledBackgroundImage( Image image );
216
217   /**
218    * @copydoc SetDisabledBackgroundImage( Image image )
219    */
220   void SetDisabledBackgroundImage( Actor image );
221
222   /**
223    * @brief Gets the disabled background image.
224    *
225    * @return An actor with the disabled background image.
226    */
227   Actor GetDisabledBackgroundImage() const;
228
229   /**
230    * @brief Sets the disabled button image.
231    *
232    * @param[in] image The disabled button image.
233    */
234   void SetDisabledImage( Image image );
235
236   /**
237    * @copydoc SetDisabledImage( Image image )
238    */
239   void SetDisabledImage( Actor image );
240
241   /**
242    * @brief Gets the disabled image.
243    *
244    * @return An actor with the disabled image.
245    */
246   Actor GetDisabledImage() const;
247
248 public: // Not intended for application developers
249
250   /**
251    * @brief Creates a handle using the Toolkit::Internal implementation.
252    *
253    * @param[in]  implementation  The Control implementation.
254    */
255   DALI_INTERNAL PushButton( Internal::PushButton& implementation );
256
257   /**
258    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
259    *
260    * @param[in]  internal  A pointer to the internal CustomActor.
261    */
262   DALI_INTERNAL PushButton( Dali::Internal::CustomActor* internal );
263 };
264
265 } // namespace Toolkit
266
267 } // namespace Dali
268
269 #endif // __DALI_TOOLKIT_PUSH_BUTTON_H__