License conversion from Flora to Apache 2.0
[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    * Virtual destructor.
83    * Dali::Object derived classes typically do not contain member data.
84    */
85   virtual ~CheckBoxButton();
86
87   /**
88    * Create an initialized CheckBoxButton.
89    * @return A handle to a newly allocated Dali resource.
90    */
91   static CheckBoxButton New();
92
93   /**
94    * Downcast an Object handle to CheckBoxButton. If handle points to a CheckBoxButton the
95    * downcast produces valid handle. If not the returned handle is left uninitialized.
96    * @param[in] handle Handle to an object
97    * @return handle to a CheckBoxButton or an uninitialized handle
98    */
99   static CheckBoxButton DownCast( BaseHandle handle );
100
101   /**
102    * Sets the button as checked or unchecked.
103    *
104    * Emits a Button::ClickedSignal() signal if the checkbox is not dimmed and the new state,
105    * given in the \e checked param, is different than the previous one.
106    *
107    * @param[in] checked state.
108    */
109   void SetChecked( bool checked );
110
111   /**
112    * @return \e true if the button is checked.
113    */
114   bool IsChecked() const;
115
116   /**
117    * Sets the background image.
118    *
119    * @param[in] image The background image.
120    */
121   void SetBackgroundImage( Image image );
122
123   /**
124    * @copydoc SetBackgroundImage( Image image )
125    */
126   void SetBackgroundImage( Actor image );
127
128   /**
129    * Gets the background image.
130    * @return An actor with the background image.
131    */
132   Actor GetBackgroundImage() const;
133
134   /**
135    * Sets the checked image.
136    *
137    * @param[in] image The checked image.
138    */
139   void SetCheckedImage( Image image );
140
141   /**
142    * @copydoc SetCheckedImage( Image image )
143    */
144   void SetCheckedImage( Actor image );
145
146   /**
147    * Gets the checked image.
148    * @return An actor with the checked image.
149    */
150   Actor GetCheckedImage() const;
151
152   /**
153    * Sets the dimmed background image.
154    *
155    * @param[in] image The dimmed background image.
156    */
157   void SetDimmedBackgroundImage( Image image );
158
159   /**
160    * @copydoc SetDimmedBackgroundImage( Image image )
161    */
162   void SetDimmedBackgroundImage( Actor image );
163
164   /**
165    * Gets the dimmed background image.
166    * @return An actor with the dimmed background image.
167    */
168   Actor GetDimmedBackgroundImage() const;
169
170   /**
171    * Sets the dimmed checked image.
172    *
173    * @param[in] image The dimmed checked image.
174    */
175   void SetDimmedCheckedImage( Image image );
176
177   /**
178    * @copydoc SetDimmedCheckedImage( Image image )
179    */
180   void SetDimmedCheckedImage( Actor image );
181
182   /**
183    * Gets the dimmed checked image.
184    * @return An actor with the dimmed checked image.
185    */
186   Actor GetDimmedCheckedImage() const;
187
188 public: // Not intended for application developers
189
190   /**
191    * Creates a handle using the Toolkit::Internal implementation.
192    * @param[in]  implementation  The Control implementation.
193    */
194   CheckBoxButton( Internal::CheckBoxButton& implementation );
195
196   /**
197    * Allows the creation of this Control from an Internal::CustomActor pointer.
198    * @param[in]  internal  A pointer to the internal CustomActor.
199    */
200   CheckBoxButton( Dali::Internal::CustomActor* internal );
201 };
202
203 } // namespace Toolkit
204
205 } // namespace Dali
206
207 #endif // __DALI_TOOLKIT_CHECK_BOX_BUTTON_H__