Implemented Deprecated GetSelectedImage and GetButtonImage
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / button.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/public-api/controls/buttons/button.h>
20
21 // EXTERNAL INCLUDES
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>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/internal/controls/buttons/button-impl.h>
28 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 Button::Button()
37 {}
38
39 Button::Button( const Button& button )
40 : Control( button )
41 {
42 }
43
44 Button& Button::operator=( const Button& button )
45 {
46   if( &button != this )
47   {
48     Control::operator=( button );
49   }
50   return *this;
51 }
52
53 Button::~Button()
54 {
55 }
56
57 Button Button::DownCast( BaseHandle handle )
58 {
59   return Control::DownCast<Button, Internal::Button>(handle);
60 }
61
62 void Button::SetDisabled( bool disabled )
63 {
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" );
65
66   Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
67 }
68
69 bool Button::IsDisabled() const
70 {
71   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsDisabled() is deprecated and will be removed from next release. Use GetProperty DISABLED instead.\n" );
72
73   return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
74 }
75
76 void Button::SetAutoRepeating( bool autoRepeating )
77 {
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" );
79
80   Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
81 }
82
83 bool Button::IsAutoRepeating() const
84 {
85   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsAutoRepeating() is deprecated and will be removed from next release. Use GetProperty AUTO_REPEATING instead.\n" );
86
87   return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
88 }
89
90 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
91 {
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" );
93
94   Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
95 }
96
97 float Button::GetInitialAutoRepeatingDelay() const
98 {
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" );
100
101   return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
102 }
103
104 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
105 {
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" );
107
108   Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
109 }
110
111 float Button::GetNextAutoRepeatingDelay() const
112 {
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" );
114
115   return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
116 }
117
118 void Button::SetTogglableButton( bool togglable )
119 {
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" );
121
122   Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
123 }
124
125 bool Button::IsTogglableButton() const
126 {
127   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsTogglableButton() is deprecated and will be removed from next release. Use GetProperty TOGGLABLE instead.\n" );
128
129   return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
130 }
131
132 void Button::SetSelected( bool selected )
133 {
134   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelected() is deprecated and will be removed from next release. Use SetProperty SELECTED instead.\n" );
135
136   Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
137 }
138
139 bool Button::IsSelected() const
140 {
141   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsSelected() is deprecated and will be removed from next release. Use GetProperty SELECTED instead.\n" );
142
143   return Dali::Toolkit::GetImplementation( *this ).IsSelected();
144 }
145
146 void Button::SetAnimationTime( float animationTime )
147 {
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" );
149
150   Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
151 }
152
153 float Button::GetAnimationTime() const
154 {
155   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetAnimationTime() is deprecated and will be removed from next release.\n" );
156
157   return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
158 }
159
160 void Button::SetLabelText( const std::string& label )
161 {
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" );
163
164   Dali::Toolkit::GetImplementation( *this ).SetLabelText( label );
165 }
166
167 std::string Button::GetLabelText() const
168 {
169   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetLabelText() is deprecated and will be removed from next release. Use GetProperty LABEL instead.\n" );
170
171   return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
172 }
173
174 void Button::SetUnselectedImage( const std::string& filename )
175 {
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" );
177
178   Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( filename );
179 }
180
181 void Button::SetBackgroundImage( const std::string& filename )
182 {
183   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetBackgroundImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
184
185   Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( filename );
186 }
187
188 void Button::SetSelectedImage( const std::string& filename )
189 {
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" );
191
192   Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( filename );
193 }
194
195 void Button::SetSelectedBackgroundImage( const std::string& filename )
196 {
197   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedBackgroundImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
198
199   Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( filename );
200 }
201
202 void Button::SetDisabledBackgroundImage( const std::string& filename )
203 {
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" );
205
206   Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( filename );
207 }
208
209 void Button::SetDisabledImage( const std::string& filename )
210 {
211   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
212
213   Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( filename );
214 }
215
216 void Button::SetDisabledSelectedImage( const std::string& filename )
217 {
218   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
219
220   Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( filename );
221 }
222
223 Button::ButtonSignalType& Button::PressedSignal()
224 {
225   return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
226 }
227
228 Button::ButtonSignalType& Button::ReleasedSignal()
229 {
230   return Dali::Toolkit::GetImplementation( *this ).ReleasedSignal();
231 }
232
233 Button::ButtonSignalType& Button::ClickedSignal()
234 {
235   return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
236 }
237
238 Button::ButtonSignalType& Button::StateChangedSignal()
239 {
240   return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
241 }
242
243 // Deprecated API
244
245 void Button::SetLabel( Actor label )
246 {
247   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetLabel() is deprecated and will be removed from next release. Use SetProperty LABEL instead.\n" );
248
249   Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
250 }
251
252 void Button::SetButtonImage( Image image )
253 {
254   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetButtonImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
255
256   Dali::Toolkit::GetImplementation( *this ).SetButtonImage( image );
257 }
258
259 void Button::SetSelectedImage( Image image )
260 {
261   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
262
263   Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
264 }
265
266 Actor Button::GetButtonImage() const
267 {
268   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetButtonImage() is deprecated and will be removed from next release.\n" );
269
270   return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
271 }
272
273 Actor Button::GetSelectedImage() const
274 {
275   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSelectedImage() is deprecated and will be removed from next release.\n" );
276
277   return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
278 }
279
280 Button::Button( Internal::Button& implementation )
281 : Control( implementation )
282 {
283 }
284
285 Button::Button( Dali::Internal::CustomActor* internal )
286 : Control( internal )
287 {
288   VerifyCustomActorPointer<Internal::Button>(internal);
289 }
290
291 } // namespace Toolkit
292
293 } // namespace Dali