Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / FUi_AccessibilityGesture.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 #include <FAppUiApp.h>
19 #include <FAppIAppFrame.h>
20 #include <FBaseSysLog.h>
21 #include <FGrpCoordinateSystem.h>
22 #include <FGrpDimension.h>
23 #include <FUiCtrlFrame.h>
24 #include <FUiCtrlForm.h>
25 #include "FUi_AccessibilityGesture.h"
26 #include "FUi_AccessibilityManager.h"
27 #include "FUi_ControlManager.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Ui::Controls;
32
33 namespace
34 {
35         void ConvertTouchPosition(int &x, int&y)
36         {
37                 Frame* pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame();
38                 Form* pForm= pFrame->GetCurrentForm();
39                 Dimension screen = Tizen::Ui::_ControlManager::GetInstance()->GetScreenSize();
40                 int _x = x;
41                 int _y = y;
42                 switch(pForm->GetOrientationStatus())
43                 {
44                         case Tizen::Ui::ORIENTATION_STATUS_PORTRAIT:
45                                 break;
46                         case Tizen::Ui::ORIENTATION_STATUS_LANDSCAPE:
47                                 x = screen.height - _y;
48                                 y= _x;
49                                 break;
50                         case Tizen::Ui::ORIENTATION_STATUS_PORTRAIT_REVERSE:
51                                 y = screen.height - _y;
52                                 break;
53                         case Tizen::Ui::ORIENTATION_STATUS_LANDSCAPE_REVERSE:
54                                 x = _y;
55                                 y = screen.width - _x;
56                                 break;
57                         default:
58                                 break;
59                 }
60         }
61 }
62
63 namespace Tizen { namespace Ui {
64 _AccessibilityGesture::_AccessibilityGesture(_AccessibilityManager& manager)
65 : __pManager(&manager)
66 {
67 }
68
69 _AccessibilityGesture::~_AccessibilityGesture(void)
70 {
71 }
72
73 bool
74 _AccessibilityGesture::ProcessGesture(_AccessibilityGestureType type, int x, int y)
75 {
76         ConvertTouchPosition(x,y);
77         _AccessibilityManager::GetInstance()->ProcessGesture(type,Tizen::Graphics::Point(CoordinateSystem::ConvertToLogicalX(x),CoordinateSystem::ConvertToLogicalY(y)), null);
78         return true;
79 }
80 }} //Tizen::Ui
81