(TextInput) Ensure scroll position is reset when text is deleted
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / control.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 #include <dali-toolkit/public-api/controls/control.h>
19 #include <dali-toolkit/public-api/controls/control-impl.h>
20
21 namespace Dali
22 {
23
24 namespace Toolkit
25 {
26
27 const char* const Control::ACTION_CONTROL_ACTIVATED = "control-activated";
28
29 const char* const Control::SIGNAL_KEY_EVENT = "key-event";
30 const char* const Control::SIGNAL_TAPPED = "tapped";
31 const char* const Control::SIGNAL_PANNED = "panned";
32 const char* const Control::SIGNAL_PINCHED = "pinched";
33 const char* const Control::SIGNAL_LONG_PRESSED = "long-pressed";
34
35 Control Control::New()
36 {
37   return Internal::Control::New();
38 }
39
40 Control::Control()
41 {
42 }
43
44 Control::Control(const Control& uiControl)
45 : CustomActor( uiControl ? static_cast< const Internal::Control& >( uiControl.GetImplementation() ).GetOwner() : NULL)
46 {
47 }
48
49 Control::~Control()
50 {
51 }
52
53 Control& Control::operator=( const Control& handle )
54 {
55   if( &handle != this )
56   {
57     CustomActor::operator=( handle );
58   }
59   return *this;
60 }
61
62 Control Control::DownCast( BaseHandle handle )
63 {
64   return DownCast< Control, Internal::Control >(handle);
65 }
66
67 Internal::Control& Control::GetImplementation()
68 {
69   return static_cast<Internal::Control&>(CustomActor::GetImplementation());
70 }
71
72 const Internal::Control& Control::GetImplementation() const
73 {
74   return static_cast<const Internal::Control&>(CustomActor::GetImplementation());
75 }
76
77 void Control::SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy )
78 {
79   GetImplementation().SetSizePolicy( widthPolicy, heightPolicy );
80 }
81
82 void Control::GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const
83 {
84   GetImplementation().GetSizePolicy( widthPolicy, heightPolicy );
85 }
86
87 void Control::SetMinimumSize( const Vector3& size )
88 {
89   GetImplementation().SetMinimumSize( size );
90 }
91
92 const Vector3& Control::GetMinimumSize() const
93 {
94   return GetImplementation().GetMinimumSize();
95 }
96
97 void Control::SetMaximumSize( const Vector3& size )
98 {
99   GetImplementation().SetMaximumSize( size );
100 }
101
102 const Vector3& Control::GetMaximumSize() const
103 {
104   return GetImplementation().GetMaximumSize();
105 }
106
107 Vector3 Control::GetNaturalSize()
108 {
109   return GetImplementation().GetNaturalSize();
110 }
111
112 float Control::GetHeightForWidth( float width )
113 {
114   return GetImplementation().GetHeightForWidth( width );
115 }
116
117 float Control::GetWidthForHeight( float height )
118 {
119   return GetImplementation().GetWidthForHeight( height );
120 }
121
122 void Control::SetKeyInputFocus()
123 {
124   GetImplementation().SetKeyInputFocus();
125 }
126
127 bool Control::HasKeyInputFocus()
128 {
129   return GetImplementation().HasKeyInputFocus();
130 }
131
132 void Control::ClearKeyInputFocus()
133 {
134   GetImplementation().ClearKeyInputFocus();
135 }
136
137 PinchGestureDetector Control::GetPinchGestureDetector() const
138 {
139   return GetImplementation().GetPinchGestureDetector();
140 }
141
142 PanGestureDetector Control::GetPanGestureDetector() const
143 {
144   return GetImplementation().GetPanGestureDetector();
145 }
146
147 TapGestureDetector Control::GetTapGestureDetector() const
148 {
149   return GetImplementation().GetTapGestureDetector();
150 }
151
152 LongPressGestureDetector Control::GetLongPressGestureDetector() const
153 {
154   return GetImplementation().GetLongPressGestureDetector();
155 }
156
157 void Control::SetBackgroundColor( const Vector4& color )
158 {
159   GetImplementation().SetBackgroundColor( color );
160 }
161
162 Vector4 Control::GetBackgroundColor() const
163 {
164   return GetImplementation().GetBackgroundColor();
165 }
166
167 void Control::SetBackground( Image image )
168 {
169   GetImplementation().SetBackground( image );
170 }
171
172 void Control::ClearBackground()
173 {
174   GetImplementation().ClearBackground();
175 }
176
177 Actor Control::GetBackgroundActor() const
178 {
179   return GetImplementation().GetBackgroundActor();
180 }
181
182 Control::KeyEventSignalV2& Control::KeyEventSignal()
183 {
184   return GetImplementation().KeyEventSignal();
185 }
186
187 Control::Control(Internal::Control& implementation)
188 : CustomActor(implementation)
189 {
190 }
191
192 Control::Control(Dali::Internal::CustomActor* internal)
193 : CustomActor(internal)
194 {
195   VerifyCustomActorPointer<Internal::Control>(internal);
196 }
197
198 } // namespace Toolkit
199
200 } // namespace Dali