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>
25 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
36 Button::Button( const Button& button )
41 Button& Button::operator=( const Button& button )
45 Control::operator=( button );
54 Button Button::DownCast( BaseHandle handle )
56 return Control::DownCast<Button, Internal::Button>(handle);
59 void Button::SetDisabled( bool disabled )
61 Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
64 bool Button::IsDisabled() const
66 return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
69 void Button::SetAutoRepeating( bool autoRepeating )
71 Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
74 bool Button::IsAutoRepeating() const
76 return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
79 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
81 Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
84 float Button::GetInitialAutoRepeatingDelay() const
86 return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
89 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
91 Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
94 float Button::GetNextAutoRepeatingDelay() const
96 return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
99 void Button::SetTogglableButton( bool togglable )
101 Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
104 bool Button::IsTogglableButton() const
106 return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
109 void Button::SetSelected( bool selected )
111 Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
114 bool Button::IsSelected() const
116 return Dali::Toolkit::GetImplementation( *this ).IsSelected();
119 void Button::SetAnimationTime( float animationTime )
121 Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
124 float Button::GetAnimationTime() const
126 return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
129 void Button::SetLabelText( const std::string& label )
131 Dali::Toolkit::GetImplementation( *this ).SetLabelText( label );
134 std::string Button::GetLabelText() const
136 return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
139 void Button::SetUnselectedImage( const std::string& filename )
141 Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( filename );
144 void Button::SetBackgroundImage( const std::string& filename )
146 Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( filename );
149 void Button::SetSelectedImage( const std::string& filename )
151 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( filename );
154 void Button::SetSelectedBackgroundImage( const std::string& filename )
156 Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( filename );
159 void Button::SetDisabledBackgroundImage( const std::string& filename )
161 Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( filename );
164 void Button::SetDisabledImage( const std::string& filename )
166 Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( filename );
169 void Button::SetDisabledSelectedImage( const std::string& filename )
171 Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( filename );
174 Button::ButtonSignalType& Button::PressedSignal()
176 return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
179 Button::ButtonSignalType& Button::ReleasedSignal()
181 return Dali::Toolkit::GetImplementation( *this ).ReleasedSignal();
184 Button::ButtonSignalType& Button::ClickedSignal()
186 return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
189 Button::ButtonSignalType& Button::StateChangedSignal()
191 return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
196 void Button::SetLabel( Actor label )
198 Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
201 void Button::SetButtonImage( Image image )
203 Actor imageView = Toolkit::ImageView::New( image );
204 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
205 Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageView );
208 void Button::SetSelectedImage( Image image )
210 Actor imageView = Toolkit::ImageView::New( image );
211 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
212 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageView );
215 Actor Button::GetButtonImage() const
217 return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
220 Actor Button::GetSelectedImage() const
222 return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
226 Button::Button( Internal::Button& implementation )
227 : Control( implementation )
231 Button::Button( Dali::Internal::CustomActor* internal )
232 : Control( internal )
234 VerifyCustomActorPointer<Internal::Button>(internal);
237 } // namespace Toolkit