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>
25 #include <dali-toolkit/internal/controls/buttons/button-impl.h>
26 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
37 Button::Button( const Button& button )
42 Button& Button::operator=( const Button& button )
46 Control::operator=( button );
55 Button Button::DownCast( BaseHandle handle )
57 return Control::DownCast<Button, Internal::Button>(handle);
60 void Button::SetDisabled( bool disabled )
62 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabled() is deprecated and will be removed from next release. Use SetProperty DISABLED or Styling file instead.\n" );
64 Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
67 bool Button::IsDisabled() const
69 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsDisabled() is deprecated and will be removed from next release. Use GetProperty DISABLED instead.\n" );
71 return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
74 void Button::SetAutoRepeating( bool autoRepeating )
76 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" );
78 Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
81 bool Button::IsAutoRepeating() const
83 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsAutoRepeating() is deprecated and will be removed from next release. Use GetProperty AUTO_REPEATING instead.\n" );
85 return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
88 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
90 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" );
92 Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
95 float Button::GetInitialAutoRepeatingDelay() const
97 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" );
99 return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
102 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
104 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" );
106 Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
109 float Button::GetNextAutoRepeatingDelay() const
111 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetNextAutoRepeatingDelay() is deprecated and will be removed from next release. Use GetProperty NEXT_AUTO_REPEATING_DELAY instead.\n" );
113 return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
116 void Button::SetTogglableButton( bool togglable )
118 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetTogglableButton() is deprecated and will be removed from next release. Use SetProperty TOGGLABLE or Styling file instead.\n" );
120 Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
123 bool Button::IsTogglableButton() const
125 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsTogglableButton() is deprecated and will be removed from next release. Use GetProperty TOGGLABLE instead.\n" );
127 return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
130 void Button::SetSelected( bool selected )
132 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelected() is deprecated and will be removed from next release. Use SetProperty SELECTED instead.\n" );
134 Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
137 bool Button::IsSelected() const
139 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsSelected() is deprecated and will be removed from next release. Use GetProperty SELECTED instead.\n" );
141 return Dali::Toolkit::GetImplementation( *this ).IsSelected();
144 void Button::SetAnimationTime( float animationTime )
146 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetAnimationTime() is deprecated and will be removed from next release. Use Styling file to set animation instead.\n" );
148 Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
151 float Button::GetAnimationTime() const
153 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetAnimationTime() is deprecated and will be removed from next release.\n" );
155 return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
158 void Button::SetLabelText( const std::string& label )
160 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetLabelText() is deprecated and will be removed from next release. Use SetProperty LABEL or Styling file instead.\n" );
162 Dali::Toolkit::GetImplementation( *this ).SetLabelText( label );
165 std::string Button::GetLabelText() const
167 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetLabelText() is deprecated and will be removed from next release. Use GetProperty LABEL instead.\n" );
169 return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
172 void Button::SetUnselectedImage( const std::string& filename )
174 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" );
176 Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( filename );
179 void Button::SetBackgroundImage( const std::string& filename )
181 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetBackgroundImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
183 Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( filename );
186 void Button::SetSelectedImage( const std::string& filename )
188 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" );
190 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( filename );
193 void Button::SetSelectedBackgroundImage( const std::string& filename )
195 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedBackgroundImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
197 Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( filename );
200 void Button::SetDisabledBackgroundImage( const std::string& filename )
202 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" );
204 Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( filename );
207 void Button::SetDisabledImage( const std::string& filename )
209 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
211 Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( filename );
214 void Button::SetDisabledSelectedImage( const std::string& filename )
216 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
218 Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( filename );
221 Button::ButtonSignalType& Button::PressedSignal()
223 return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
226 Button::ButtonSignalType& Button::ReleasedSignal()
228 return Dali::Toolkit::GetImplementation( *this ).ReleasedSignal();
231 Button::ButtonSignalType& Button::ClickedSignal()
233 return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
236 Button::ButtonSignalType& Button::StateChangedSignal()
238 return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
243 void Button::SetLabel( Actor label )
245 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetLabel() is deprecated and will be removed from next release. Use SetProperty LABEL instead.\n" );
247 Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
250 void Button::SetButtonImage( Image image )
252 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetButtonImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
254 Actor imageView = Toolkit::ImageView::New( image );
255 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
256 Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageView );
259 void Button::SetSelectedImage( Image image )
261 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
263 Actor imageView = Toolkit::ImageView::New( image );
264 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
265 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageView );
268 Actor Button::GetButtonImage() const
270 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetButtonImage() is deprecated and will be removed from next release.\n" );
272 return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
275 Actor Button::GetSelectedImage() const
277 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSelectedImage() is deprecated and will be removed from next release.\n" );
279 return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
283 Button::Button( Internal::Button& implementation )
284 : Control( implementation )
288 Button::Button( Dali::Internal::CustomActor* internal )
289 : Control( internal )
291 VerifyCustomActorPointer<Internal::Button>(internal);
294 } // namespace Toolkit