Tizen 2.0 Release
[profile/ivi/libscl-ui.git] / scl / sclevents.cpp
1 /*
2  * Copyright 2012-2013 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
18 #include "sclevents.h"
19 #ifdef  __WIN32__
20 #include "sclevents-win32.h"
21 #elif defined(__EFL__)
22 #include "sclevents-efl.h"
23 #else
24 #include "sclevents-gtk.h"
25 #endif
26 #include "scldebug.h"
27 #include "sclwindows.h"
28
29 using namespace scl;
30
31 CSCLEvents* CSCLEvents::m_instance = NULL; /* For singleton */
32
33 CSCLEvents::CSCLEvents()
34 {
35     SCL_DEBUG();
36     m_impl = 0;
37     m_touch_event_offset.x = m_touch_event_offset.y = 0;
38 }
39
40 CSCLEvents::~CSCLEvents()
41 {
42     SCL_DEBUG();
43 }
44
45 CSCLEventsImpl* CSCLEvents::get_scl_events_impl()
46 {
47     SCL_DEBUG();
48     if (m_impl == 0) {
49 #ifdef  __WIN32__
50         m_impl = new CSCLEventsImplWin32;
51 #elif defined(__EFL__)
52         m_impl = new CSCLEventsImplEfl;
53 #else
54         m_impl = new CSCLEventsImplGtk;
55 #endif
56     }
57     return m_impl;
58 }
59
60 CSCLEvents* CSCLEvents::get_instance()
61 {
62     if (!m_instance) {
63         m_instance = new CSCLEvents();
64     }
65     return (CSCLEvents*)m_instance;
66 }
67
68 void
69 CSCLEvents::connect_window_events( sclwindow wnd, const sclint evt )
70 {
71     CSCLWindows *windows = CSCLWindows::get_instance();
72     //SclWindowContext *winctx = windows->get_window_context(wnd, FALSE);
73     SclWindowContext *winctx = windows->get_window_context(wnd);
74     if (winctx) {
75         if (!(winctx->is_virtual)) {
76             get_scl_events_impl()->connect_window_events(wnd, evt);
77         }
78     }
79 }
80
81 void
82 CSCLEvents::set_touch_event_offset(const SclPoint pos)
83 {
84     m_touch_event_offset = pos;
85 }
86
87 SclPoint*
88 CSCLEvents::get_touch_event_offset()
89 {
90     return &m_touch_event_offset;
91 }
92
93