1 #ifndef __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_H__
2 #define __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/dali-vector.h>
24 #include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
26 #include "button-impl.h"
38 * CheckBoxButton implementation class.
40 * \sa Dali::Toolkit::CheckBoxButton
42 class CheckBoxButton : public Button
47 * Create a new CheckBoxButton.
48 * @return A smart-pointer to the newly allocated CheckBoxButton.
50 static Dali::Toolkit::CheckBoxButton New();
53 * @copydoc Dali::Toolkit::CheckBoxButton::SetChecked( bool checked )
55 void SetChecked( bool checked );
58 * @copydoc Dali::Toolkit::CheckBoxButton::IsChecked()
60 bool IsChecked() const;
63 * @copydoc Dali::Toolkit::CheckBoxButton::SetBackgroundImage( Image image )
65 void SetBackgroundImage( Image image );
68 * @copydoc Dali::Toolkit::CheckBoxButton::SetBackgroundImage( Actor image )
70 void SetBackgroundImage( Actor image );
73 * Used by the painter only.
74 * @return A reference to the background image.
76 Actor& GetBackgroundImage();
79 * @copydoc Dali::Toolkit::CheckBoxButton::GetBackgroundImage()
81 Actor GetBackgroundImage() const;
84 * @copydoc Dali::Toolkit::CheckBoxButton::SetCheckedImage( Image image )
86 void SetCheckedImage( Image image );
89 * @copydoc Dali::Toolkit::CheckBoxButton::SetCheckedImage( Actor image )
91 void SetCheckedImage( Actor image );
94 * Used by the painter only.
95 * @return A reference to the checked image.
97 Actor& GetCheckedImage();
100 * @copydoc Dali::Toolkit::CheckBoxButton::GetCheckedImage()
102 Actor GetCheckedImage() const;
105 * @copydoc Dali::Toolkit::CheckBoxButton::SetDimmedBackgroundImage( Image image )
107 void SetDimmedBackgroundImage( Image image );
110 * @copydoc Dali::Toolkit::CheckBoxButton::SetDimmedBackgroundImage( Actor image )
112 void SetDimmedBackgroundImage( Actor image );
115 * Used by the painter only.
116 * @return A reference to the dimmed background image.
118 Actor& GetDimmedBackgroundImage();
121 * @copydoc Dali::Toolkit::CheckBoxButton::GetDimmedBackgroundImage()
123 Actor GetDimmedBackgroundImage() const;
126 * @copydoc Dali::Toolkit::CheckBoxButton::SetDimmedCheckedImage( Image image )
128 void SetDimmedCheckedImage( Image image );
131 * @copydoc Dali::Toolkit::CheckBoxButton::SetDimmedCheckedImage( Actor image )
133 void SetDimmedCheckedImage( Actor image );
136 * Used by the painter only.
137 * @return A reference to the dimmed checked image.
139 Actor& GetDimmedCheckedImage();
142 * @copydoc Dali::Toolkit::CheckBoxButton::GetDimmedCheckedImage()
144 Actor GetDimmedCheckedImage() const;
147 * Used by the painter only.
148 * @return A reference to the background image that is fading out.
150 Actor& GetFadeOutBackgroundImage();
153 * Used by the painter only.
154 * @return A reference to the checked image that is fading out.
156 Actor& GetFadeOutCheckedImage();
158 protected: // From Control
161 * Respond the activate notification.
163 virtual void OnActivated();
168 * Perform the click action to click the button.
169 * @param[in] attributes The attributes to perfrom this action.
171 void DoClickAction(const PropertyValueContainer& attributes);
175 * Performs actions as requested using the action name.
176 * @param[in] object The object on which to perform the action.
177 * @param[in] actionName The action to perform.
178 * @param[in] attributes The attributes with which to perfrom this action.
179 * @return true if action has been accepted by this control
181 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
183 protected: // From Button
186 * Registers properties
188 virtual void OnButtonInitialize();
191 * Emits signals and notifies the painter accordingly with the set button
192 * properties when the button is released.
194 virtual void OnButtonUp();
197 * Sets the push button animation time.
198 * @param animationTime The animation time in seconds.
200 virtual void OnAnimationTimeSet( float animationTime );
203 * Retrieves the animation time.
204 * @return The animation time in seconds.
206 virtual float OnAnimationTimeRequested() const;
211 * Construct a new CheckBoxButton.
216 * A reference counted object may only be deleted by calling Unreference()
218 virtual ~CheckBoxButton();
223 CheckBoxButton( const CheckBoxButton& );
226 CheckBoxButton& operator=( const CheckBoxButton& );
230 bool mChecked; ///< Stores the check state.
232 Actor mBackgroundImage; ///< Stores the background image.
233 Actor mCheckedImage; ///< Stores the checked image.
234 Actor mDimmedCheckedImage; ///< Stores the dimmed checked image.
235 Actor mDimmedBackgroundImage; ///< Stores the dimmed background image.
236 Actor mFadeOutBackgroundImage; ///< Stores a background image, which is in a fade out animation, to be removed when the animation finishes.
237 Actor mFadeOutCheckedImage; ///< Stores a foreground image, which is in a fade out animation, to be removed when the animation finishes.
240 bool mClickActionPerforming;
243 Property::Index mUseFadeAnimationProperty;
244 Property::Index mUseCheckAnimationProperty;
247 } // namespace Internal
249 // Helpers for public-api forwarding methods
251 inline Toolkit::Internal::CheckBoxButton& GetImplementation( Toolkit::CheckBoxButton& button )
253 DALI_ASSERT_ALWAYS( button );
255 Dali::RefObject& handle = button.GetImplementation();
257 return static_cast<Toolkit::Internal::CheckBoxButton&>( handle );
260 inline const Toolkit::Internal::CheckBoxButton& GetImplementation( const Toolkit::CheckBoxButton& button )
262 DALI_ASSERT_ALWAYS( button );
264 const Dali::RefObject& handle = button.GetImplementation();
266 return static_cast<const Toolkit::Internal::CheckBoxButton&>( handle );
269 } // namespace Toolkit
273 #endif // __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_H__