[dali_1.1.29] Merge branch 'devel/master'
[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
20 #include <dali-toolkit/public-api/controls/buttons/button.h>
21
22 // INTERNAL INCLUDES
23
24 #include <dali-toolkit/internal/controls/buttons/button-impl.h>
25 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 Button::Button()
34 {}
35
36 Button::Button( const Button& button )
37 : Control( button )
38 {
39 }
40
41 Button& Button::operator=( const Button& button )
42 {
43   if( &button != this )
44   {
45     Control::operator=( button );
46   }
47   return *this;
48 }
49
50 Button::~Button()
51 {
52 }
53
54 Button Button::DownCast( BaseHandle handle )
55 {
56   return Control::DownCast<Button, Internal::Button>(handle);
57 }
58
59 void Button::SetDisabled( bool disabled )
60 {
61   Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
62 }
63
64 bool Button::IsDisabled() const
65 {
66   return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
67 }
68
69 void Button::SetAutoRepeating( bool autoRepeating )
70 {
71   Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
72 }
73
74 bool Button::IsAutoRepeating() const
75 {
76   return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
77 }
78
79 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
80 {
81   Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
82 }
83
84 float Button::GetInitialAutoRepeatingDelay() const
85 {
86   return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
87 }
88
89 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
90 {
91   Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
92 }
93
94 float Button::GetNextAutoRepeatingDelay() const
95 {
96   return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
97 }
98
99 void Button::SetTogglableButton( bool togglable )
100 {
101   Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
102 }
103
104 bool Button::IsTogglableButton() const
105 {
106   return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
107 }
108
109 void Button::SetSelected( bool selected )
110 {
111   Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
112 }
113
114 bool Button::IsSelected() const
115 {
116   return Dali::Toolkit::GetImplementation( *this ).IsSelected();
117 }
118
119 void Button::SetAnimationTime( float animationTime )
120 {
121   Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
122 }
123
124 float Button::GetAnimationTime() const
125 {
126   return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
127 }
128
129 void Button::SetLabelText( const std::string& label )
130 {
131   Dali::Toolkit::GetImplementation( *this ).SetLabelText( label );
132 }
133
134 std::string Button::GetLabelText() const
135 {
136   return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
137 }
138
139 void Button::SetUnselectedImage( const std::string& filename )
140 {
141   Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( filename );
142 }
143
144 void Button::SetBackgroundImage( const std::string& filename )
145 {
146   Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( filename );
147 }
148
149 void Button::SetSelectedImage( const std::string& filename )
150 {
151   Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( filename );
152 }
153
154 void Button::SetSelectedBackgroundImage( const std::string& filename )
155 {
156   Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( filename );
157 }
158
159 void Button::SetDisabledBackgroundImage( const std::string& filename )
160 {
161   Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( filename );
162 }
163
164 void Button::SetDisabledImage( const std::string& filename )
165 {
166   Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( filename );
167 }
168
169 void Button::SetDisabledSelectedImage( const std::string& filename )
170 {
171   Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( filename );
172 }
173
174 Button::ButtonSignalType& Button::PressedSignal()
175 {
176   return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
177 }
178
179 Button::ButtonSignalType& Button::ReleasedSignal()
180 {
181   return Dali::Toolkit::GetImplementation( *this ).ReleasedSignal();
182 }
183
184 Button::ButtonSignalType& Button::ClickedSignal()
185 {
186   return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
187 }
188
189 Button::ButtonSignalType& Button::StateChangedSignal()
190 {
191   return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
192 }
193
194 // Deprecated API
195
196 void Button::SetLabel( Actor label )
197 {
198   Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
199 }
200
201 void Button::SetButtonImage( Image image )
202 {
203   Actor imageActor = Toolkit::ImageView::New( image );
204   imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
205   Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
206 }
207
208 void Button::SetSelectedImage( Image image )
209 {
210   Actor imageActor = Toolkit::ImageView::New( image );
211   imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
212   Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
213 }
214
215 Actor Button::GetButtonImage() const
216 {
217   return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
218 }
219
220 Actor Button::GetSelectedImage() const
221 {
222   return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
223 }
224
225
226 Button::Button( Internal::Button& implementation )
227 : Control( implementation )
228 {
229 }
230
231 Button::Button( Dali::Internal::CustomActor* internal )
232 : Control( internal )
233 {
234   VerifyCustomActorPointer<Internal::Button>(internal);
235 }
236
237 } // namespace Toolkit
238
239 } // namespace Dali