Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlOverlayRegion.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUiCtrlOverlayRegion.cpp
20  * @brief               This is the implementation file for OverlayRegion class.
21  */
22
23 #include <FUiCtrlOverlayRegion.h>
24 #include <FSys_SystemInfoImpl.h>
25 #include "FUi_Control.h"
26 #include "FUiCtrl_OverlayAgent.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUi_CoordinateSystemUtils.h"
29 #include "FUiCtrl_OverlayRegionImpl.h"
30
31
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37
38 namespace Tizen { namespace Ui { namespace Controls
39 {
40
41 OverlayRegion::OverlayRegion(void)
42         : __pOverlayRegionImpl(null)
43 {
44 }
45
46 OverlayRegion::~OverlayRegion(void)
47 {
48         delete __pOverlayRegionImpl;
49         __pOverlayRegionImpl = null;
50 }
51
52 Rectangle
53 OverlayRegion::GetBounds(void) const
54 {
55         SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use.");
56
57         return _CoordinateSystemUtils::ConvertToInteger(__pOverlayRegionImpl->GetBounds());
58 }
59
60 FloatRectangle
61 OverlayRegion::GetBoundsF(void) const
62 {
63         SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use.");
64
65         return __pOverlayRegionImpl->GetBounds();
66 }
67
68 void
69 OverlayRegion::GetBounds(int& x, int& y, int& width, int& height) const
70 {
71         SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use.");
72         Rectangle rect = _CoordinateSystemUtils::ConvertToInteger(__pOverlayRegionImpl->GetBounds());
73
74         x = rect.x;
75         y = rect.y;
76         width = rect.width;
77         height = rect.height;
78 }
79
80 void
81 OverlayRegion::GetBounds(float& x, float& y, float& width, float& height) const
82 {
83         SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use.");
84
85         __pOverlayRegionImpl->GetBounds(x, y, width, height);
86
87         return;
88 }
89
90 result
91 OverlayRegion::SetInputBuffer(const ByteBuffer& srcBuffer, const Dimension& sourceDim, OverlayRegionBufferPixelFormat srcFormat)
92 {
93         SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use.");
94
95         result r  = __pOverlayRegionImpl->SetInputBuffer(srcBuffer, sourceDim, srcFormat);
96         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
97
98         return E_SUCCESS;
99 }
100
101 result
102 OverlayRegion::GetBackgroundBufferInfo(BufferInfo& info) const
103 {
104         SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use.");
105
106         result r  = __pOverlayRegionImpl->GetBackgroundBufferInfo(info);
107         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
108
109         return E_SUCCESS;
110 }
111
112 result
113 OverlayRegion::Show(void)
114 {
115         SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use.");
116
117         return E_SUCCESS;
118 }
119
120 bool
121 OverlayRegion::EvaluateBounds(OverlayRegionEvaluationOption option, Rectangle& rect, bool& modified)
122 {
123         FloatRectangle convertedRect = _CoordinateSystemUtils::ConvertToFloat(rect);
124         bool ret = EvaluateBounds(option, convertedRect, modified);
125
126         if(ret && modified)
127         {
128                 rect = _CoordinateSystemUtils::ConvertToInteger(convertedRect);
129         }
130
131         return ret;
132 }
133
134 bool
135 OverlayRegion::EvaluateBounds(OverlayRegionEvaluationOption option, FloatRectangle& rect, bool& modified)
136 {
137         result r = E_SUCCESS;
138
139         switch (option)
140         {
141         case OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN:
142         {
143                 r = _OverlayAgent::EvaluateBounds(OVERLAY_AGENT_EVALUATION_OPTION_GREATER_THAN, rect, modified);
144                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
145                 return true;
146         }
147         case OVERLAY_REGION_EVALUATION_OPTION_LESS_THAN:
148         {
149                 r = _OverlayAgent::EvaluateBounds(OVERLAY_AGENT_EVALUATION_OPTION_LESS_THAN, rect, modified);
150                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
151                 return true;
152         }
153         default:
154                 break;
155         }
156
157         SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The input OverlayRegionEvaluationOption is invalid.");
158         return false;
159 }
160
161 int
162 OverlayRegion::GetWidthUnit(void)
163 {
164         int widthUnit = _OverlayAgent::GetWidthUnit();
165         SysTryReturn(NID_UI_CTRL, widthUnit != -1, -1, E_SYSTEM, "[E_SYSTEM] Failed to get width unit of OverlayRegion.");
166
167         return widthUnit;
168 }
169
170 int
171 OverlayRegion::GetHeightUnit(void)
172 {
173         int heightUnit = _OverlayAgent::GetHeightUnit();
174         SysTryReturn(NID_UI_CTRL, heightUnit != -1, -1, E_SYSTEM, "[E_SYSTEM] Failed to get height unit of OverlayRegion.");
175
176         return heightUnit;
177 }
178
179 int
180 OverlayRegion::GetMaxCount(void)
181 {
182         int maxCount = _OverlayAgent::GetMaxCount();
183         SysTryReturn(NID_UI_CTRL, maxCount != -1, -1, E_SYSTEM, "[E_SYSTEM]Failed to get maximum count of OverlayRegion.");
184
185         return maxCount;
186 }
187
188 IListT<OverlayRegionBufferPixelFormat>*
189 OverlayRegion::GetSupportedBufferPixelFormatListN(void)
190 {
191         return _OverlayRegionImpl::GetSupportedBufferPixelFormatListN();
192 }
193
194 } } } // Tizen::Ui::Controls