Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / push-button.cpp
1 /*
2  * Copyright (c) 2014 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/push-button.h>
21
22 // INTERNAL INCLUDES
23
24 #include <dali-toolkit/internal/controls/buttons/push-button-impl.h>
25 #include <dali/public-api/actors/image-actor.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 PushButton::PushButton()
34 : Button()
35 {
36 }
37
38 PushButton::PushButton( Internal::PushButton& implementation )
39 : Button( implementation )
40 {
41 }
42
43 PushButton::PushButton( const PushButton& pushButton )
44 : Button( pushButton )
45 {
46 }
47
48 PushButton& PushButton::operator=( const PushButton& pushButton )
49 {
50   if( &pushButton != this )
51   {
52     Button::operator=( pushButton );
53   }
54   return *this;
55 }
56
57 PushButton::PushButton( Dali::Internal::CustomActor* internal )
58 : Button( internal )
59 {
60   VerifyCustomActorPointer<Internal::PushButton>(internal);
61 }
62
63 PushButton::~PushButton()
64 {
65 }
66
67 PushButton PushButton::New()
68 {
69   return Internal::PushButton::New();
70 }
71
72 PushButton PushButton::DownCast( BaseHandle handle )
73 {
74   return Control::DownCast<PushButton, Internal::PushButton>(handle);
75 }
76
77 void PushButton::SetButtonImage( Image image )
78 {
79   Actor imageActor = ImageActor::New( image );
80   imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
81   Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
82 }
83
84 void PushButton::SetButtonImage( Actor image )
85 {
86   Dali::Toolkit::GetImplementation( *this ).SetButtonImage( image );
87 }
88
89 Actor PushButton::GetButtonImage() const
90 {
91   return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
92 }
93
94 void PushButton::SetBackgroundImage( Image image )
95 {
96   Actor imageActor = ImageActor::New( image );
97   imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
98   Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor );
99 }
100
101 void PushButton::SetBackgroundImage( Actor image )
102 {
103   Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( image );
104 }
105
106 Actor PushButton::GetBackgroundImage() const
107 {
108   return Dali::Toolkit::GetImplementation( *this ).GetBackgroundImage();
109 }
110
111 void PushButton::SetSelectedImage( Image image )
112 {
113   Actor imageActor = ImageActor::New( image );
114   imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
115   Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
116 }
117
118 void PushButton::SetSelectedImage( Actor image )
119 {
120   Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
121 }
122
123 Actor PushButton::GetSelectedImage() const
124 {
125   return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
126 }
127
128 void PushButton::SetSelectedBackgroundImage( Image image )
129 {
130   Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( ImageActor::New( image ) );
131 }
132
133 void PushButton::SetSelectedBackgroundImage( Actor image )
134 {
135   Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( image );
136 }
137
138 Actor PushButton::GetSelectedBackgroundImage() const
139 {
140   return Dali::Toolkit::GetImplementation( *this ).GetSelectedBackgroundImage();
141 }
142
143 void PushButton::SetDisabledBackgroundImage( Image image )
144 {
145   Actor imageActor = ImageActor::New( image );
146   imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
147   Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor );
148 }
149
150 void PushButton::SetDisabledBackgroundImage( Actor image )
151 {
152   Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( image );
153 }
154
155 Actor PushButton::GetDisabledBackgroundImage() const
156 {
157   return Dali::Toolkit::GetImplementation( *this ).GetDisabledBackgroundImage();
158 }
159
160 void PushButton::SetDisabledImage( Image image )
161 {
162   Actor imageActor = ImageActor::New( image );
163   imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
164   Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor );
165 }
166
167 void PushButton::SetDisabledImage( Actor image )
168 {
169   Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( image );
170 }
171
172 Actor PushButton::GetDisabledImage() const
173 {
174   return Dali::Toolkit::GetImplementation( *this ).GetDisabledImage();
175 }
176
177 } // namespace Toolkit
178
179 } // namespace Dali