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