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 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
11 // http://floralicense.org/license/
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.
21 #include <dali/public-api/common/dali-vector.h>
23 #include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
25 #include "button-impl.h"
37 * CheckBoxButton implementation class.
39 * \sa Dali::Toolkit::CheckBoxButton
41 class CheckBoxButton : public Button
46 * Create a new CheckBoxButton.
47 * @return A smart-pointer to the newly allocated CheckBoxButton.
49 static Dali::Toolkit::CheckBoxButton New();
52 * @copydoc Dali::Toolkit::CheckBoxButton::SetChecked( bool checked )
54 void SetChecked( bool checked );
57 * @copydoc Dali::Toolkit::CheckBoxButton::IsChecked()
59 bool IsChecked() const;
62 * @copydoc Dali::Toolkit::CheckBoxButton::SetBackgroundImage( Image image )
64 void SetBackgroundImage( Image image );
67 * @copydoc Dali::Toolkit::CheckBoxButton::SetBackgroundImage( Actor image )
69 void SetBackgroundImage( Actor image );
72 * Used by the painter only.
73 * @return A reference to the background image.
75 Actor& GetBackgroundImage();
78 * @copydoc Dali::Toolkit::CheckBoxButton::GetBackgroundImage()
80 Actor GetBackgroundImage() const;
83 * @copydoc Dali::Toolkit::CheckBoxButton::SetCheckedImage( Image image )
85 void SetCheckedImage( Image image );
88 * @copydoc Dali::Toolkit::CheckBoxButton::SetCheckedImage( Actor image )
90 void SetCheckedImage( Actor image );
93 * Used by the painter only.
94 * @return A reference to the checked image.
96 Actor& GetCheckedImage();
99 * @copydoc Dali::Toolkit::CheckBoxButton::GetCheckedImage()
101 Actor GetCheckedImage() const;
104 * @copydoc Dali::Toolkit::CheckBoxButton::SetDimmedBackgroundImage( Image image )
106 void SetDimmedBackgroundImage( Image image );
109 * @copydoc Dali::Toolkit::CheckBoxButton::SetDimmedBackgroundImage( Actor image )
111 void SetDimmedBackgroundImage( Actor image );
114 * Used by the painter only.
115 * @return A reference to the dimmed background image.
117 Actor& GetDimmedBackgroundImage();
120 * @copydoc Dali::Toolkit::CheckBoxButton::GetDimmedBackgroundImage()
122 Actor GetDimmedBackgroundImage() const;
125 * @copydoc Dali::Toolkit::CheckBoxButton::SetDimmedCheckedImage( Image image )
127 void SetDimmedCheckedImage( Image image );
130 * @copydoc Dali::Toolkit::CheckBoxButton::SetDimmedCheckedImage( Actor image )
132 void SetDimmedCheckedImage( Actor image );
135 * Used by the painter only.
136 * @return A reference to the dimmed checked image.
138 Actor& GetDimmedCheckedImage();
141 * @copydoc Dali::Toolkit::CheckBoxButton::GetDimmedCheckedImage()
143 Actor GetDimmedCheckedImage() const;
146 * Used by the painter only.
147 * @return A reference to the background image that is fading out.
149 Actor& GetFadeOutBackgroundImage();
152 * Used by the painter only.
153 * @return A reference to the checked image that is fading out.
155 Actor& GetFadeOutCheckedImage();
157 protected: // From ControlImpl
160 * Respond the activate notification.
162 virtual void OnActivated();
167 * Perform the click action to click the button.
168 * @param[in] attributes The attributes to perfrom this action.
170 void DoClickAction(const PropertyValueContainer& attributes);
174 * Performs actions as requested using the action name.
175 * @param[in] object The object on which to perform the action.
176 * @param[in] actionName The action to perform.
177 * @param[in] attributes The attributes with which to perfrom this action.
178 * @return true if action has been accepted by this control
180 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
182 protected: // From Button
185 * Registers properties
187 virtual void OnButtonInitialize();
190 * Emits signals and notifies the painter accordingly with the set button
191 * properties when the button is released.
193 virtual void OnButtonUp();
196 * Sets the push button animation time.
197 * @param animationTime The animation time in seconds.
199 virtual void OnAnimationTimeSet( float animationTime );
202 * Retrieves the animation time.
203 * @return The animation time in seconds.
205 virtual float OnAnimationTimeRequested() const;
210 * Construct a new CheckBoxButton.
215 * A reference counted object may only be deleted by calling Unreference()
217 virtual ~CheckBoxButton();
222 CheckBoxButton( const CheckBoxButton& );
225 CheckBoxButton& operator=( const CheckBoxButton& );
229 bool mChecked; ///< Stores the check state.
231 Actor mBackgroundImage; ///< Stores the background image.
232 Actor mCheckedImage; ///< Stores the checked image.
233 Actor mDimmedCheckedImage; ///< Stores the dimmed checked image.
234 Actor mDimmedBackgroundImage; ///< Stores the dimmed background image.
235 Actor mFadeOutBackgroundImage; ///< Stores a background image, which is in a fade out animation, to be removed when the animation finishes.
236 Actor mFadeOutCheckedImage; ///< Stores a foreground image, which is in a fade out animation, to be removed when the animation finishes.
239 bool mClickActionPerforming;
242 Property::Index mUseFadeAnimationProperty;
243 Property::Index mUseCheckAnimationProperty;
246 } // namespace Internal
248 // Helpers for public-api forwarding methods
250 inline Toolkit::Internal::CheckBoxButton& GetImplementation( Toolkit::CheckBoxButton& button )
252 DALI_ASSERT_ALWAYS( button );
254 Dali::RefObject& handle = button.GetImplementation();
256 return static_cast<Toolkit::Internal::CheckBoxButton&>( handle );
259 inline const Toolkit::Internal::CheckBoxButton& GetImplementation( const Toolkit::CheckBoxButton& button )
261 DALI_ASSERT_ALWAYS( button );
263 const Dali::RefObject& handle = button.GetImplementation();
265 return static_cast<const Toolkit::Internal::CheckBoxButton&>( handle );
268 } // namespace Toolkit
272 #endif // __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_H__