Upload initial version
[platform/core/uifw/libscl-ui-nui.git] / scl / sclgwes.cpp
1 /*
2  * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 "sclgwes.h"
19 #include "scldebug.h"
20
21 using namespace scl;
22
23 CSCLGwes::CSCLGwes()
24 {
25     SCL_DEBUG();
26
27     m_windows = NULL;
28     m_graphics = NULL;
29     m_events = NULL;
30 }
31
32 CSCLGwes::~CSCLGwes()
33 {
34     SCL_DEBUG();
35 }
36
37 void CSCLGwes::init(sclwindow parent, scl16 width, scl16 height)
38 {
39     SCL_DEBUG();
40
41     if (m_windows == NULL) m_windows = CSCLWindows::get_instance();
42     if (m_graphics == NULL) m_graphics = CSCLGraphics::get_instance();
43     if (m_events == NULL) m_events = CSCLEvents::get_instance();
44
45     if (m_windows) {
46         m_windows->init();
47     }
48
49     if (m_graphics) {
50         m_graphics->init();
51     }
52
53     if (m_events) {
54         m_events->init();
55     }
56
57     if (m_windows) {
58         sclwindow wnd = m_windows->create_base_window(parent, width, height);
59         if (m_events) {
60             m_events->connect_window_events(wnd, SCL_EVENT_MOUSE | SCL_EVENT_EXPOSE);
61         }
62     }
63 }
64
65 void CSCLGwes::fini()
66 {
67     SCL_DEBUG();
68
69     if (m_windows) {
70         m_windows->fini();
71         m_windows = NULL;
72     }
73     if (m_graphics) {
74         m_graphics->fini();
75         m_graphics = NULL;
76     }
77     if (m_events) {
78         m_events->fini();
79         m_events = NULL;
80     }
81 }
82
83 CSCLGwes* CSCLGwes::get_instance()
84 {
85     static CSCLGwes instance;
86     return &instance;
87 }
88