de653107c86bd0a00d23333a72740b525827e117
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / buttons / check-box-button.h
1 #ifndef __DALI_TOOLKIT_CHECK_BOX_BUTTON_H__
2 #define __DALI_TOOLKIT_CHECK_BOX_BUTTON_H__
3
4 /*
5  * Copyright (c) 2014 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 <dali-toolkit/public-api/controls/buttons/button.h>
23
24 namespace Dali DALI_IMPORT_API
25 {
26
27 namespace Toolkit
28 {
29
30 // Forward declarations
31
32 namespace Internal DALI_INTERNAL
33 {
34 class CheckBoxButton;
35 }
36
37 /**
38  * CheckBoxButton provides a check box button which user can check or uncheck.
39  *
40  * By default a CheckBoxButton emits a Button::ClickedSignal() signal when the button changes its state to checked or unchecked.
41  *
42  * The button's appearance could be modified by setting images or actors with CheckBoxButton::SetBackgroundImage,
43  * CheckBoxButton::SetCheckedImage, CheckBoxButton::SetDimmedBackgroundImage and CheckBoxButton::SetDimmedCheckedImage.
44  *
45  * When the button is not dimmed, if it's not checked it only shows the \e background image. The \e checked image is shown over the
46  * \e background image when the box is checked (\e background image is not replaced by \e checked image).
47  *
48  * When the button is dimmed, \e background image and \e checked image are replaced by \e dimmed images.
49  *
50  * CheckBoxButton doesn't have a text. However, a Dali::Toolkit::TableView with a Dali::TextActor or a Dali::Toolkit::TextView
51  * and a CheckBoxButton could be used instead.
52  */
53 class CheckBoxButton : public Button
54 {
55 public:
56   //Action Names
57   static const char* const ACTION_CHECK_BOX_BUTTON_CLICK;
58
59   // Properties
60   static const std::string USE_FADE_ANIMATION_PROPERTY_NAME;
61   static const std::string USE_CHECK_ANIMATION_PROPERTY_NAME;
62
63 public:
64
65   /**
66    * Create an uninitialized CheckBoxButton; this can be initialized with CheckBoxButton::New()
67    * Calling member functions with an uninitialized Dali::Object is not allowed.
68    */
69   CheckBoxButton();
70
71   /**
72    * Copy constructor.
73    */
74   CheckBoxButton( const CheckBoxButton& checkBox );
75
76   /**
77    * Assignment operator.
78    */
79   CheckBoxButton& operator=( const CheckBoxButton& checkBox );
80
81   /**
82    * @brief Destructor
83    *
84    * This is non-virtual since derived Handle types must not contain data or virtual methods.
85    */
86   ~CheckBoxButton();
87
88   /**
89    * Create an initialized CheckBoxButton.
90    * @return A handle to a newly allocated Dali resource.
91    */
92   static CheckBoxButton New();
93
94   /**
95    * Downcast an Object handle to CheckBoxButton. If handle points to a CheckBoxButton the
96    * downcast produces valid handle. If not the returned handle is left uninitialized.
97    * @param[in] handle Handle to an object
98    * @return handle to a CheckBoxButton or an uninitialized handle
99    */
100   static CheckBoxButton DownCast( BaseHandle handle );
101
102   /**
103    * Sets the button as checked or unchecked.
104    *
105    * Emits a Button::ClickedSignal() signal if the checkbox is not dimmed and the new state,
106    * given in the \e checked param, is different than the previous one.
107    *
108    * @param[in] checked state.
109    */
110   void SetChecked( bool checked );
111
112   /**
113    * @return \e true if the button is checked.
114    */
115   bool IsChecked() const;
116
117   /**
118    * Sets the background image.
119    *
120    * @param[in] image The background image.
121    */
122   void SetBackgroundImage( Image image );
123
124   /**
125    * @copydoc SetBackgroundImage( Image image )
126    */
127   void SetBackgroundImage( Actor image );
128
129   /**
130    * Gets the background image.
131    * @return An actor with the background image.
132    */
133   Actor GetBackgroundImage() const;
134
135   /**
136    * Sets the checked image.
137    *
138    * @param[in] image The checked image.
139    */
140   void SetCheckedImage( Image image );
141
142   /**
143    * @copydoc SetCheckedImage( Image image )
144    */
145   void SetCheckedImage( Actor image );
146
147   /**
148    * Gets the checked image.
149    * @return An actor with the checked image.
150    */
151   Actor GetCheckedImage() const;
152
153   /**
154    * Sets the dimmed background image.
155    *
156    * @param[in] image The dimmed background image.
157    */
158   void SetDimmedBackgroundImage( Image image );
159
160   /**
161    * @copydoc SetDimmedBackgroundImage( Image image )
162    */
163   void SetDimmedBackgroundImage( Actor image );
164
165   /**
166    * Gets the dimmed background image.
167    * @return An actor with the dimmed background image.
168    */
169   Actor GetDimmedBackgroundImage() const;
170
171   /**
172    * Sets the dimmed checked image.
173    *
174    * @param[in] image The dimmed checked image.
175    */
176   void SetDimmedCheckedImage( Image image );
177
178   /**
179    * @copydoc SetDimmedCheckedImage( Image image )
180    */
181   void SetDimmedCheckedImage( Actor image );
182
183   /**
184    * Gets the dimmed checked image.
185    * @return An actor with the dimmed checked image.
186    */
187   Actor GetDimmedCheckedImage() const;
188
189 public: // Not intended for application developers
190
191   /**
192    * Creates a handle using the Toolkit::Internal implementation.
193    * @param[in]  implementation  The Control implementation.
194    */
195   CheckBoxButton( Internal::CheckBoxButton& implementation );
196
197   /**
198    * Allows the creation of this Control from an Internal::CustomActor pointer.
199    * @param[in]  internal  A pointer to the internal CustomActor.
200    */
201   CheckBoxButton( Dali::Internal::CustomActor* internal );
202 };
203
204 } // namespace Toolkit
205
206 } // namespace Dali
207
208 #endif // __DALI_TOOLKIT_CHECK_BOX_BUTTON_H__