Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / ui / FUi_CoordinateSystemUtils.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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        FUi_CoordinateSystemUtils.cpp
20  * @brief       This file contains implementation of _CoordinateSystemUtils class
21  *
22  * This file contains implementation _CoordinateSystemUtils class.
23  */
24
25 #include <FBaseErrors.h>
26 #include <FOspConfig.h>
27 #include "FUi_CoordinateSystemUtils.h"
28
29 using namespace Tizen::Graphics;
30
31 namespace Tizen { namespace Ui {
32
33 _CoordinateSystem* _CoordinateSystemUtils::__pCoordinateSystemInstance = null;
34
35 _ICoordinateSystemTransformer*
36 _CoordinateSystemUtils::GetTransformer(void)
37 {
38         if (__pCoordinateSystemInstance == null)
39         {
40                 __pCoordinateSystemInstance = _CoordinateSystem::GetInstance();
41                 SysTryReturn(NID_UI, __pCoordinateSystemInstance, null, E_SYSTEM, "[E_SYSTEM] Coordinate system instance must not be null.");
42         }
43
44         _ICoordinateSystemTransformer* pTransform = __pCoordinateSystemInstance->GetTransformer();
45         SysTryReturn(NID_UI, pTransform, null, E_SYSTEM, "[E_SYSTEM] The valid coordinate transformer does not exist.");
46
47         return pTransform;
48 }
49
50 _ICoordinateSystemTransformer*
51 _CoordinateSystemUtils::GetInverseTransformer(void)
52 {
53         if (__pCoordinateSystemInstance == null)
54         {
55                 __pCoordinateSystemInstance = _CoordinateSystem::GetInstance();
56                 SysTryReturn(NID_UI, __pCoordinateSystemInstance, null, E_SYSTEM, "[E_SYSTEM] Coordinate system instance must not be null.");
57         }
58
59         _ICoordinateSystemTransformer* pInverseTransform= __pCoordinateSystemInstance->GetInverseTransformer();
60         SysTryReturn(NID_UI, pInverseTransform, null, E_SYSTEM, "[E_SYSTEM] The valid coordinate inverse transformer does not exist.");
61
62         return pInverseTransform;
63 }
64
65
66 // Transform Utilities
67 Rectangle
68 _CoordinateSystemUtils::Transform(const Rectangle& rect)
69 {
70         return GetTransformer()->Transform(rect);
71 }
72
73 Rectangle
74 _CoordinateSystemUtils::Transform(const Point& point, const Dimension& dim)
75 {
76         return GetTransformer()->Transform(Rectangle(point, dim));
77 }
78
79 Dimension
80 _CoordinateSystemUtils::Transform(const Dimension& dim)
81 {
82         return GetTransformer()->Transform(dim);
83 }
84
85 Point
86 _CoordinateSystemUtils::Transform(const Point& point)
87 {
88         return GetTransformer()->Transform(point);
89 }
90
91 int
92 _CoordinateSystemUtils::HorizontalTransform(int scalar)
93 {
94         return GetTransformer()->TransformHorizontal(scalar);
95 }
96
97 int
98 _CoordinateSystemUtils::VerticalTransform(int scalar)
99 {
100         return GetTransformer()->TransformVertical(scalar);
101 }
102
103
104 // InverseTransform Utilities
105 Rectangle
106 _CoordinateSystemUtils::InverseTransform(const Rectangle& rect)
107 {
108         return GetInverseTransformer()->Transform(rect);
109 }
110
111 Rectangle
112 _CoordinateSystemUtils::InverseTransform(const Point& point, const Dimension& dim)
113 {
114         return GetInverseTransformer()->Transform(Rectangle(point, dim));
115 }
116
117 Dimension
118 _CoordinateSystemUtils::InverseTransform(const Dimension& dim)
119 {
120         return GetInverseTransformer()->Transform(dim);
121 }
122
123 Point
124 _CoordinateSystemUtils::InverseTransform(const Point& point)
125 {
126         return GetInverseTransformer()->Transform(point);
127 }
128
129 int
130 _CoordinateSystemUtils::InverseHorizontalTransform(int scalar)
131 {
132         return GetInverseTransformer()->TransformHorizontal(scalar);
133 }
134
135 int
136 _CoordinateSystemUtils::InverseVerticalTransform(int scalar)
137 {
138         return GetInverseTransformer()->TransformVertical(scalar);
139 }
140
141 }} // Tizen::Ui