[dali_2.3.19] Merge branch 'devel/master'
[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) 2020 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
25 {
26 namespace Toolkit
27 {
28 // Forward declarations
29
30 namespace Internal DALI_INTERNAL
31 {
32 class CheckBoxButton;
33 }
34 /**
35  * @addtogroup dali_toolkit_controls_buttons
36  * @{
37  */
38
39 /**
40  * @brief CheckBoxButton provides a check box button which user can check or uncheck.
41  *
42  * By default, a CheckBoxButton emits a Button::ClickedSignal() signal when the button changes its state to selected or unselected.
43  *
44  * The button's appearance could be modified by Button::SetUnselectedImage, Button::SetBackgroundImage,
45  * Button::SetSelectedImage, Button::SetSelectedBackgroundImage, Button::SetDisabledBackgroundImage,
46  * Button::SetDisabledImage, and Button::SetDisabledSelectedImage.
47  *
48  * When the button is not disabled, if it's not selected it only shows the \e background image. The \e selected image is shown over the
49  * \e background image when the box is selected (\e background image is not replaced by \e selected image).
50  *
51  * When the button is disabled, \e background image and \e selected image are replaced by \e disabled images.
52  *
53  * Usage example: -
54  *
55  * @code
56  * // in Creating a DALi Application
57  * void HelloWorldExample::Create( Application& application )
58  * {
59  *   CheckBoxButton button = CheckBoxButton::New();
60  *   button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
61  *   button.SetProperty( Button::Property::LABEL, "Check" );
62  *   button.SetProperty( Actor::Property::SIZE, Vector2( 200, 40 );
63  *   button.SetBackgroundColor( Color::WHITE );
64  *   Stage::GetCurrent().Add( button );
65  *
66  *   // Connect to a button signal emitted by the button
67  *   button.StateChangedSignal().Connect( this, &HelloWorldExample::OnButtonStateChanged );
68  * }
69  *
70  * bool HelloWorldExample::OnButtonStateChanged( Button button )
71  * {
72  *   // Do something when the button state is changed
73  *   // You can get the state using button.IsSelected() call
74  *   return true;
75  * }
76  * @endcode
77  * @SINCE_1_0.0
78  */
79 class DALI_TOOLKIT_API CheckBoxButton : public Button
80 {
81 public:
82   /**
83    * @brief Creates an uninitialized CheckBoxButton; this can be initialized with CheckBoxButton::New().
84    * Calling member functions with an uninitialized Dali::Object is not allowed.
85    * @SINCE_1_0.0
86    */
87   CheckBoxButton();
88
89   /**
90    * @brief Copy constructor.
91    * @SINCE_1_0.0
92    * @param[in] checkBox Handle to an object
93    */
94   CheckBoxButton(const CheckBoxButton& checkBox);
95
96   /**
97    * @brief Move constructor
98    * @SINCE_1_9.23
99    *
100    * @param[in] rhs A reference to the moved handle
101    */
102   CheckBoxButton(CheckBoxButton&& rhs);
103
104   /**
105    * @brief Assignment operator.
106    * @SINCE_1_0.0
107    * @param[in] checkBox Handle to an object
108    * @return A reference to this
109    */
110   CheckBoxButton& operator=(const CheckBoxButton& checkBox);
111
112   /**
113    * @brief Move assignment
114    * @SINCE_1_9.23
115    *
116    * @param[in] rhs A reference to the moved handle
117    * @return A reference to this
118    */
119   CheckBoxButton& operator=(CheckBoxButton&& rhs);
120
121   /**
122    * @brief Destructor.
123    *
124    * This is non-virtual since derived Handle types must not contain data or virtual methods.
125    * @SINCE_1_0.0
126    */
127   ~CheckBoxButton();
128
129   /**
130    * @brief Creates an initialized CheckBoxButton.
131    * @SINCE_1_0.0
132    * @return A handle to a newly allocated Dali resource
133    */
134   static CheckBoxButton New();
135
136   /**
137    * @brief Downcasts a handle to CheckBoxButton handle.
138    *
139    * If handle points to a CheckBoxButton, the downcast produces valid handle.
140    * If not, the returned handle is left uninitialized.
141    * @SINCE_1_0.0
142    * @param[in] handle Handle to an object
143    * @return Handle to a CheckBoxButton or an uninitialized handle
144    */
145   static CheckBoxButton DownCast(BaseHandle handle);
146
147 public: // Not intended for application developers
148   /// @cond internal
149   /**
150    * @brief Creates a handle using the Toolkit::Internal implementation.
151    * @SINCE_1_0.0
152    * @param[in] implementation The Control implementation
153    */
154   DALI_INTERNAL CheckBoxButton(Internal::CheckBoxButton& implementation);
155
156   /**
157    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
158    * @SINCE_1_0.0
159    * @param[in] internal A pointer to the internal CustomActor
160    */
161   DALI_INTERNAL CheckBoxButton(Dali::Internal::CustomActor* internal);
162   /// @endcond
163 };
164
165 /**
166  * @}
167  */
168 } // namespace Toolkit
169
170 } // namespace Dali
171
172 #endif // DALI_TOOLKIT_CHECK_BOX_BUTTON_H