|
1 /* |
|
2 * Copyright (c) 2009-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CDisplayServiceUILayout class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef DISPLAYSERVICEUILAYOUT_H |
|
20 #define DISPLAYSERVICEUILAYOUT_H |
|
21 |
|
22 // SYSTEM INCLUDE FILES |
|
23 #include <w32std.h> |
|
24 |
|
25 // USER INCLUDE FILES |
|
26 #include "displayservicebase.h" |
|
27 #include "displaysourcecontextdef.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CApaWindowGroupName; |
|
31 |
|
32 // DATA TYPES |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Ws event observer. |
|
38 */ |
|
39 NONSHARABLE_CLASS( MWsEventObserver ) |
|
40 { |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Handles window server event. |
|
45 * |
|
46 * @since S60 5.0 |
|
47 * @param aEvent New window server event. |
|
48 * @return None. |
|
49 */ |
|
50 virtual void HandleWsEventL( const TWsEvent &aEvent ) = 0; |
|
51 |
|
52 /** |
|
53 * Handle error occured in window server event. |
|
54 * |
|
55 * @since S60 5.0 |
|
56 * @param aEvent New window server event. |
|
57 * @return None. |
|
58 */ |
|
59 virtual void HandleWsEventErrorL( TInt aError ) = 0; |
|
60 }; |
|
61 |
|
62 /** |
|
63 * Listens events from window server and forwards them to observer. |
|
64 */ |
|
65 NONSHARABLE_CLASS( CWsEventHandler ): public CActive |
|
66 { |
|
67 public: |
|
68 |
|
69 /** |
|
70 * Symbian two phased constructors. |
|
71 * |
|
72 * @since S60 5.0 |
|
73 * @param None. |
|
74 * @return CDisplayServiceUILayout |
|
75 */ |
|
76 static CWsEventHandler* NewL( MWsEventObserver& aObserver ); |
|
77 static CWsEventHandler* NewLC( MWsEventObserver& aObserver ); |
|
78 |
|
79 /** |
|
80 * C++ destructor. |
|
81 */ |
|
82 virtual ~CWsEventHandler(); |
|
83 |
|
84 public: |
|
85 |
|
86 /** |
|
87 * Start event listening. |
|
88 * |
|
89 * @since S60 5.0 |
|
90 * @param None. |
|
91 * @return None. |
|
92 */ |
|
93 void IssueRequest(); |
|
94 |
|
95 /** |
|
96 * Resolve current UI layout mode. |
|
97 * |
|
98 * @since S60 5.0 |
|
99 * @param aLayout Current UI layout mode. |
|
100 * @param aRotation Current UI rotation. |
|
101 * @return TDisplayUILayoutValues. |
|
102 */ |
|
103 void ResolveUILayout( TDisplayUILayoutValues& aLayout, |
|
104 CFbsBitGc::TGraphicsOrientation& aRotation ) const; |
|
105 |
|
106 protected: |
|
107 |
|
108 // @see CActive |
|
109 virtual void RunL(); |
|
110 |
|
111 // @see CActive |
|
112 virtual void DoCancel(); |
|
113 |
|
114 // @see CActive |
|
115 virtual TInt RunError( TInt aError ); |
|
116 |
|
117 private: |
|
118 |
|
119 CWsEventHandler( MWsEventObserver& aObserver ); |
|
120 void ConstructL(); |
|
121 |
|
122 private: // Data |
|
123 |
|
124 /** Observer */ |
|
125 MWsEventObserver& iObserver; |
|
126 |
|
127 /** Window server session */ |
|
128 RWsSession iWsSession; |
|
129 |
|
130 /** Window group for receiving window server events */ |
|
131 RWindowGroup* iWindowGroup; |
|
132 |
|
133 /** Window group name to hide it from the task manager */ |
|
134 CApaWindowGroupName* iWindowGroupName; |
|
135 |
|
136 /** Screen device */ |
|
137 CWsScreenDevice* iWsScreenDevice; |
|
138 }; |
|
139 |
|
140 /** |
|
141 * UI Layout service provides information about the current UI layout. |
|
142 * I.e. if the current UI layout for the application is portrait or landscape. |
|
143 * |
|
144 * @lib None. |
|
145 * @since S60 5.0 |
|
146 */ |
|
147 NONSHARABLE_CLASS( CDisplayServiceUILayout ): public CDisplayServiceBase, |
|
148 public MWsEventObserver |
|
149 { |
|
150 public: |
|
151 |
|
152 /** |
|
153 * Symbian two phased constructors. |
|
154 * |
|
155 * @since S60 5.0 |
|
156 * @param None. |
|
157 * @return CDisplayServiceUILayout |
|
158 */ |
|
159 static CDisplayServiceUILayout* NewL( MCFContextInterface& aCF ); |
|
160 static CDisplayServiceUILayout* NewLC( MCFContextInterface& aCF ); |
|
161 |
|
162 /** |
|
163 * C++ destructor. |
|
164 */ |
|
165 virtual ~CDisplayServiceUILayout(); |
|
166 |
|
167 public: // From base classes |
|
168 |
|
169 // @see CDisplayServiceBase |
|
170 virtual void StartL(); |
|
171 |
|
172 // @see CDisplayServiceBase |
|
173 virtual void Stop(); |
|
174 |
|
175 // @see MWsEventObserver |
|
176 virtual void HandleWsEventL( const TWsEvent &aEvent ); |
|
177 |
|
178 // @see MWsEventObserver |
|
179 virtual void HandleWsEventErrorL( TInt aError ); |
|
180 |
|
181 private: |
|
182 |
|
183 /** |
|
184 * Publish UI layout mode context. |
|
185 */ |
|
186 void PublishContextL( TDisplayUILayoutValues aLayout, |
|
187 TBool aForce = EFalse ); |
|
188 |
|
189 /** |
|
190 * Publish UI rotation context. |
|
191 */ |
|
192 void PublishContextL( CFbsBitGc::TGraphicsOrientation aRotation, |
|
193 TBool aForce = EFalse ); |
|
194 |
|
195 private: |
|
196 |
|
197 CDisplayServiceUILayout( MCFContextInterface& aCF ); |
|
198 void ConstructL(); |
|
199 |
|
200 private: // Data |
|
201 |
|
202 /** Window server event handler */ |
|
203 CWsEventHandler* iWsEventHandler; |
|
204 |
|
205 /** Current UI layout */ |
|
206 TDisplayUILayoutValues iCurrentLayout; |
|
207 |
|
208 /** Current UI rotation */ |
|
209 CFbsBitGc::TGraphicsOrientation iCurrentRotation; |
|
210 }; |
|
211 |
|
212 #endif // DISPLAYSERVICEUILAYOUT_H |