Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / FGrpCoordinateSystem.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                FGrpCoordinateSystem.cpp
20  * @brief               This is the cpp file for CoordinateSystem class.
21  *
22  */
23
24 #include <FGrpCoordinateSystem.h>
25
26 #include <FBaseSysLog.h>
27
28 #include "FGrp_CoordinateSystem.h"
29 #include "FGrp_Screen.h"
30
31
32 namespace // unnamed
33 {
34
35 Tizen::Graphics::Dimension
36 ConvertToDimension(Tizen::Graphics::_LogicalResolution logicalResolution)
37 {
38         int width = 0;
39         int height = 0;
40
41         switch (logicalResolution)
42         {
43         case Tizen::Graphics::RESOLUTION_LOGICAL_240:
44                 width = 240;
45                 height = 400;
46                 break;
47         case Tizen::Graphics::RESOLUTION_LOGICAL_320:
48                 width = 320;
49                 height = 480;
50                 break;
51         case Tizen::Graphics::RESOLUTION_LOGICAL_480:
52                 width = 480;
53                 height = 800;
54                 break;
55         case Tizen::Graphics::RESOLUTION_LOGICAL_720:
56                 width = 720;
57                 height = 1280;
58                 break;
59         default:
60                 width = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetLogicalResolutionInt();
61                 height = Tizen::Graphics::CoordinateSystem::ConvertToLogicalY(Tizen::Graphics::_Screen::GetHeight());
62                 break;
63         }
64
65         return Tizen::Graphics::Dimension(width,height);
66 }
67
68 }
69
70
71 namespace Tizen { namespace Graphics
72 {
73
74 Dimension
75 CoordinateSystem::GetLogicalResolution(void)
76 {
77         _LogicalResolution logicalResolution = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetLogicalResolution();
78
79         return ConvertToDimension(logicalResolution);
80 }
81
82 Dimension
83 CoordinateSystem::GetPhysicalResolution(void)
84 {
85         return Dimension(_Screen::GetWidth(), _Screen::GetHeight());
86 }
87
88 int
89 CoordinateSystem::ConvertToLogicalX(int physicalX)
90 {
91         _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
92
93         return (pTransformer) ? pTransformer->TransformHorizontal(physicalX) : physicalX;
94 }
95
96 int
97 CoordinateSystem::ConvertToLogicalY(int physicalY)
98 {
99         _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
100
101         return (pTransformer) ? pTransformer->TransformVertical(physicalY) : physicalY;
102 }
103
104 int
105 CoordinateSystem::ConvertToPhysicalX(int logicalX)
106 {
107         _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
108
109         return (pTransformer) ? pTransformer->TransformHorizontal(logicalX) : logicalX;
110 }
111
112 int
113 CoordinateSystem::ConvertToPhysicalY(int logicalY)
114 {
115         _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer();
116
117         return (pTransformer) ? pTransformer->TransformVertical(logicalY) : logicalY;
118 }
119
120 }} // Tizen::Graphics