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