2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali-toolkit/public-api/controls/buttons/button.h>
24 #include <dali-toolkit/internal/controls/buttons/button-impl.h>
27 #include <dali/public-api/actors/image-actor.h>
38 Button::Button( const Button& button )
43 Button& Button::operator=( const Button& button )
47 Control::operator=( button );
56 Button Button::DownCast( BaseHandle handle )
58 return Control::DownCast<Button, Internal::Button>(handle);
61 void Button::SetDisabled( bool disabled )
63 Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
66 bool Button::IsDisabled() const
68 return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
71 void Button::SetAutoRepeating( bool autoRepeating )
73 Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
76 bool Button::IsAutoRepeating() const
78 return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
81 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
83 Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
86 float Button::GetInitialAutoRepeatingDelay() const
88 return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
91 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
93 Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
96 float Button::GetNextAutoRepeatingDelay() const
98 return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
101 void Button::SetTogglableButton( bool togglable )
103 Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
106 bool Button::IsTogglableButton() const
108 return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
111 void Button::SetSelected( bool selected )
113 Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
116 bool Button::IsSelected() const
118 return Dali::Toolkit::GetImplementation( *this ).IsSelected();
121 void Button::SetAnimationTime( float animationTime )
123 Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
126 float Button::GetAnimationTime() const
128 return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
131 void Button::SetLabelText( const std::string& label )
133 Dali::Toolkit::GetImplementation( *this ).SetLabelText( label );
136 std::string Button::GetLabelText() const
138 return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
141 void Button::SetUnselectedImage( const std::string& filename )
143 Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( filename );
146 void Button::SetBackgroundImage( const std::string& filename )
148 Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( filename );
151 void Button::SetSelectedImage( const std::string& filename )
153 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( filename );
156 void Button::SetSelectedBackgroundImage( const std::string& filename )
158 Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( filename );
161 void Button::SetDisabledBackgroundImage( const std::string& filename )
163 Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( filename );
166 void Button::SetDisabledImage( const std::string& filename )
168 Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( filename );
171 void Button::SetDisabledSelectedImage( const std::string& filename )
173 Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( filename );
176 Button::ButtonSignalType& Button::PressedSignal()
178 return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
181 Button::ButtonSignalType& Button::ReleasedSignal()
183 return Dali::Toolkit::GetImplementation( *this ).ReleasedSignal();
186 Button::ButtonSignalType& Button::ClickedSignal()
188 return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
191 Button::ButtonSignalType& Button::StateChangedSignal()
193 return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
198 void Button::SetLabel( Actor label )
200 Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
203 void Button::SetButtonImage( Image image )
205 Actor imageActor = ImageActor::New( image );
206 imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
207 Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
210 void Button::SetSelectedImage( Image image )
212 Actor imageActor = ImageActor::New( image );
213 imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
214 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
217 Actor Button::GetButtonImage() const
219 return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
222 Actor Button::GetSelectedImage() const
224 return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
228 Button::Button( Internal::Button& implementation )
229 : Control( implementation )
233 Button::Button( Dali::Internal::CustomActor* internal )
234 : Control( internal )
236 VerifyCustomActorPointer<Internal::Button>(internal);
239 } // namespace Toolkit