143a66daeed21c9120fce8fb914d0b4af09be826
[framework/web/wrt-plugins-common.git] / src / modules / tizen / DEPRACATED / Display / Screen.h
1 /*
2  * Copyright (c) 2011 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  * @author       Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
18  */
19
20 #ifndef WRTDEVICEAPIS_DISPLAY_SCREEN_H_
21 #define WRTDEVICEAPIS_DISPLAY_SCREEN_H_
22
23 #include <cstddef>
24 #include <pcrecpp.h>
25 #include <appcore-common.h>
26 #include <platform/commons/Emitters.h>
27 #include <API/Display/IScreen.h>
28 #include <VConf/Key.h>
29
30 namespace WrtPlugins {
31 namespace Platform {
32 namespace Display {
33 class Manager;
34
35 class Screen : public Api::Display::IScreen
36 {
37     friend class Manager;
38
39   public:
40     /**
41      * @see WrtPlugins::Api::Display::IScreen::getColorDepth()
42      */
43     unsigned short getColorDepth() const;
44
45     /**
46      * @see WrtPlugins::Api::Display::IScreen::getSize()
47      */
48     Dimension getSize() const;
49
50     /**
51      * @see WrtPlugins::Api::Display::IScreen::getActualSize()
52      */
53     Dimension getActualSize() const;
54
55     /**
56      * @see WrtPlugins::Api::Display::IScreen::getOrientation()
57      */
58     Api::Display::Orientation getOrientation() const;
59
60     /**
61      * @see WrtPlugins::Api::Display::IScreen::getState()
62      */
63     Api::Display::State getState() const;
64
65     /**
66      * @see WrtPlugins::Api::Display::IScreen::addOnChangeOrientation()
67      */
68     void addOnChangeOrientation(
69             const Api::Display::EventChangeOrientationEmitterPtr& emitter);
70
71     /**
72      * @see WrtPlugins::Api::Display::IScreen::removeOnChangeOrientation()
73      */
74     void removeOnChangeOrientation(
75             Api::Display::EventChangeOrientationEmitter::IdType id);
76
77     /**
78      * @see WrtPlugins::Api::Display::IScreen::addOnChangeState()
79      */
80     void addOnChangeState(
81             const Api::Display::EventChangeStateEmitterPtr& emitter);
82
83     /**
84      * @see WrtPlugins::Api::Display::IScreen::removeOnChangeState()
85      */
86     void removeOnChangeState(Api::Display::EventChangeStateEmitter::IdType id);
87
88   protected:
89     typedef Emitters<Api::Display::EventChangeOrientationEmitter>
90     ChangeOrientationEmitters;
91     typedef Emitters<Api::Display::EventChangeStateEmitter> ChangeStateEmitters;
92
93   protected:
94     /**
95      * Gets data matching specified pattern from output of xdpyinfo program.
96      * @param pattern Pattern to search for.
97      * @return Zero or positive value on success, -1 on failure.
98      */
99     static bool getXDpyProperty(const char* pattern,
100             const pcrecpp::Arg& arg1 = pcrecpp::RE::no_arg,
101             const pcrecpp::Arg& arg2 = pcrecpp::RE::no_arg);
102
103     /**
104      * Callback run when device's power state changes.
105      * @param node Node object (unused).
106      * @param data User data.
107      */
108     static void onChangeState(const VConf::Node* node,
109             void* data);
110
111     /**
112      * Callback run when device's orientation changes.
113      * @param rot Rotation mode.
114      * @param data User data.
115      * @return Error code (?) - not specified in documentation.
116      */
117     static int onChangeOrientation(appcore_rm rot,
118             void* data);
119
120   protected:
121     explicit Screen(std::size_t index);
122
123   protected:
124     std::size_t m_index; ///< Index of the screen.
125     ChangeOrientationEmitters m_onChangeOrientation; ///< Change orientation emitters.
126     ChangeStateEmitters m_onChangeState; ///< Change state emitters.
127     VConf::Key m_powerState; ///< Key for power manager state.
128 };
129 } // Display
130 } // Platform
131 } // WrtPlugins
132
133 #endif // WRTDEVICEAPIS_DISPLAY_SCREEN_H_