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