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.
19 #include <dali-toolkit/public-api/controls/buttons/button.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/property-map.h>
24 #include <dali/public-api/images/resource-image.h>
27 #include <dali-toolkit/internal/controls/buttons/button-impl.h>
28 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
39 Button::Button( const Button& button )
44 Button& Button::operator=( const Button& button )
48 Control::operator=( button );
57 Button Button::DownCast( BaseHandle handle )
59 return Control::DownCast<Button, Internal::Button>(handle);
62 void Button::SetDisabled( bool disabled )
64 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabled() is deprecated and will be removed from next release. Use SetProperty DISABLED or Styling file instead.\n" );
66 Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
69 bool Button::IsDisabled() const
71 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsDisabled() is deprecated and will be removed from next release. Use GetProperty DISABLED instead.\n" );
73 return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
76 void Button::SetAutoRepeating( bool autoRepeating )
78 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetAutoRepeating() is deprecated and will be removed from next release. Use SetProperty AUTO_REPEATING or Styling file instead.\n" );
80 Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
83 bool Button::IsAutoRepeating() const
85 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsAutoRepeating() is deprecated and will be removed from next release. Use GetProperty AUTO_REPEATING instead.\n" );
87 return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
90 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
92 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetInitialAutoRepeatingDelay() is deprecated and will be removed from next release. Use SetProperty INITIAL_AUTO_REPEATING_DELAY or Styling file instead.\n" );
94 Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
97 float Button::GetInitialAutoRepeatingDelay() const
99 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetPositionInheritanceMode() is deprecated and will be removed from next release. Use GetProperty INITIAL_AUTO_REPEATING_DELAY or Styling file instead.\n" );
101 return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
104 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
106 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetNextAutoRepeatingDelay() is deprecated and will be removed from next release. Use SetProperty NEXT_AUTO_REPEATING_DELAY or Styling file instead.\n" );
108 Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
111 float Button::GetNextAutoRepeatingDelay() const
113 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetNextAutoRepeatingDelay() is deprecated and will be removed from next release. Use GetProperty NEXT_AUTO_REPEATING_DELAY instead.\n" );
115 return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
118 void Button::SetTogglableButton( bool togglable )
120 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetTogglableButton() is deprecated and will be removed from next release. Use SetProperty TOGGLABLE or Styling file instead.\n" );
122 Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
125 bool Button::IsTogglableButton() const
127 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsTogglableButton() is deprecated and will be removed from next release. Use GetProperty TOGGLABLE instead.\n" );
129 return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
132 void Button::SetSelected( bool selected )
134 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelected() is deprecated and will be removed from next release. Use SetProperty SELECTED instead.\n" );
136 Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
139 bool Button::IsSelected() const
141 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsSelected() is deprecated and will be removed from next release. Use GetProperty SELECTED instead.\n" );
143 return Dali::Toolkit::GetImplementation( *this ).IsSelected();
146 void Button::SetAnimationTime( float animationTime )
148 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetAnimationTime() is deprecated and will be removed from next release. Use Styling file to set animation instead.\n" );
150 Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
153 float Button::GetAnimationTime() const
155 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetAnimationTime() is deprecated and will be removed from next release.\n" );
157 return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
160 void Button::SetLabelText( const std::string& label )
162 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetLabelText() is deprecated and will be removed from next release. Use SetProperty LABEL or Styling file instead.\n" );
164 Dali::Toolkit::GetImplementation( *this ).SetLabelText( label );
167 std::string Button::GetLabelText() const
169 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetLabelText() is deprecated and will be removed from next release. Use GetProperty LABEL instead.\n" );
171 return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
174 void Button::SetUnselectedImage( const std::string& filename )
176 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetUnselectedImage() is deprecated and will be removed from next release. Use SetProperty UNSELECTED_STATE_IMAGE or Styling file instead.\n" );
178 Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( filename );
181 void Button::SetBackgroundImage( const std::string& filename )
183 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetBackgroundImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
185 Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( filename );
188 void Button::SetSelectedImage( const std::string& filename )
190 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use SetProperty SELECTED_STATE_IMAGE or Styling file instead.\n" );
192 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( filename );
195 void Button::SetSelectedBackgroundImage( const std::string& filename )
197 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedBackgroundImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
199 Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( filename );
202 void Button::SetDisabledBackgroundImage( const std::string& filename )
204 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledBackgroundImage() is deprecated and will be removed from next release. Use SetProperty DISABLED_STATE_IMAGE or Styling file instead.\n" );
206 Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( filename );
209 void Button::SetDisabledImage( const std::string& filename )
211 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
213 Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( filename );
216 void Button::SetDisabledSelectedImage( const std::string& filename )
218 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
220 Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( filename );
223 Button::ButtonSignalType& Button::PressedSignal()
225 return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
228 Button::ButtonSignalType& Button::ReleasedSignal()
230 return Dali::Toolkit::GetImplementation( *this ).ReleasedSignal();
233 Button::ButtonSignalType& Button::ClickedSignal()
235 return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
238 Button::ButtonSignalType& Button::StateChangedSignal()
240 return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
245 void Button::SetLabel( Actor label )
247 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetLabel() is deprecated and will be removed from next release. Use SetProperty LABEL instead.\n" );
249 Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
252 void Button::SetButtonImage( Image image )
254 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetButtonImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
256 Dali::ResourceImage resourceImage = Dali::ResourceImage::DownCast( image );
258 std::string imageUrl;
262 imageUrl = resourceImage.GetUrl();
265 Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( imageUrl );
268 void Button::SetSelectedImage( Image image )
270 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
272 Dali::ResourceImage resourceImage = Dali::ResourceImage::DownCast( image );
274 std::string imageUrl;
278 imageUrl = resourceImage.GetUrl();
281 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageUrl );
284 Actor Button::GetButtonImage() const
286 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetButtonImage() is deprecated and will be removed from next release.\n" );
288 return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
291 Actor Button::GetSelectedImage() const
293 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSelectedImage() is deprecated and will be removed from next release.\n" );
295 return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
298 Button::Button( Internal::Button& implementation )
299 : Control( implementation )
303 Button::Button( Dali::Internal::CustomActor* internal )
304 : Control( internal )
306 VerifyCustomActorPointer<Internal::Button>(internal);
309 } // namespace Toolkit