[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / control.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 #include <dali-toolkit/public-api/controls/control.h>
18 #include <dali-toolkit/public-api/controls/control-impl.h>
19
20 namespace Dali
21 {
22
23 namespace Toolkit
24 {
25
26 const char* const Control::ACTION_CONTROL_ACTIVATED = "control-activated";
27 const char* const Control::SIGNAL_KEY_EVENT = "key-event";
28
29 Control Control::New()
30 {
31   return ControlImpl::New();
32 }
33
34 Control::Control()
35 {
36 }
37
38 Control::Control(const Control& uiControl)
39 : CustomActor( uiControl ? static_cast<const ControlImpl&>( uiControl.GetImplementation() ).GetOwner() : NULL)
40 {
41 }
42
43 Control::~Control()
44 {
45 }
46
47 Control& Control::operator=( const Control& handle )
48 {
49   if( &handle != this )
50   {
51     CustomActor::operator=( handle );
52   }
53   return *this;
54 }
55
56 Control Control::DownCast( BaseHandle handle )
57 {
58   return DownCast<Control, ControlImpl>(handle);
59 }
60
61 ControlImpl& Control::GetImplementation()
62 {
63   return static_cast<ControlImpl&>(CustomActor::GetImplementation());
64 }
65
66 const ControlImpl& Control::GetImplementation() const
67 {
68   return static_cast<const ControlImpl&>(CustomActor::GetImplementation());
69 }
70
71 void Control::SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy )
72 {
73   GetImplementation().SetSizePolicy( widthPolicy, heightPolicy );
74 }
75
76 void Control::GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const
77 {
78   GetImplementation().GetSizePolicy( widthPolicy, heightPolicy );
79 }
80
81 void Control::SetMinimumSize( const Vector3& size )
82 {
83   GetImplementation().SetMinimumSize( size );
84 }
85
86 const Vector3& Control::GetMinimumSize() const
87 {
88   return GetImplementation().GetMinimumSize();
89 }
90
91 void Control::SetMaximumSize( const Vector3& size )
92 {
93   GetImplementation().SetMaximumSize( size );
94 }
95
96 const Vector3& Control::GetMaximumSize() const
97 {
98   return GetImplementation().GetMaximumSize();
99 }
100
101 Vector3 Control::GetNaturalSize()
102 {
103   return GetImplementation().GetNaturalSize();
104 }
105
106 float Control::GetHeightForWidth( float width )
107 {
108   return GetImplementation().GetHeightForWidth( width );
109 }
110
111 float Control::GetWidthForHeight( float height )
112 {
113   return GetImplementation().GetWidthForHeight( height );
114 }
115
116 void Control::SetKeyInputFocus()
117 {
118   GetImplementation().SetKeyInputFocus();
119 }
120
121 bool Control::HasKeyInputFocus()
122 {
123   return GetImplementation().HasKeyInputFocus();
124 }
125
126 void Control::ClearKeyInputFocus()
127 {
128   GetImplementation().ClearKeyInputFocus();
129 }
130
131 Control::KeyEventSignalV2& Control::KeyEventSignal()
132 {
133   return GetImplementation().KeyEventSignal();
134 }
135
136 /**
137  * @copydoc ConnectionTrackerInterface::SignalConnected
138  */
139 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
140 {
141   GetImplementation().SignalConnected(slotObserver, callback );
142 }
143
144 /**
145  * @copydoc ConnectionTrackerInterface::SignalDisconnected
146  */
147 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
148 {
149   GetImplementation().SignalDisconnected(slotObserver, callback );
150 }
151
152 /**
153  * @copydoc ConnectionTrackerInterface::GetConnectionCount
154  */
155 std::size_t Control::GetConnectionCount() const
156 {
157   return GetImplementation().GetConnectionCount( );
158 }
159
160
161 Control::Control(ControlImpl& implementation)
162 : CustomActor(implementation)
163 {
164 }
165
166 Control::Control(Dali::Internal::CustomActor* internal)
167 : CustomActor(internal)
168 {
169   VerifyCustomActorPointer<ControlImpl>(internal);
170 }
171
172 } // namespace Toolkit
173
174 } // namespace Dali