|
1 /* |
|
2 * Copyright (c) 2006 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: Control group sub session |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alfsrvcontrolgroupsubsession.h" |
|
21 #include "alf/alfconstants.h" |
|
22 #include "alf/alfappsrvsessionbase.h" |
|
23 #include "alfappsrvsession.h" |
|
24 #include "alfscreen.h" // EAlfSessionContainer |
|
25 #include "alfsrvtransformationsubsession.h" |
|
26 #include <uiacceltk/HuiEnv.h> |
|
27 #include <uiacceltk/HuiControl.h> |
|
28 #include <uiacceltk/HuiControlGroup.h> |
|
29 #include <uiacceltk/HuiDisplay.h> |
|
30 #include <uiacceltk/HuiDeckLayout.h> |
|
31 |
|
32 // host control |
|
33 |
|
34 NONSHARABLE_CLASS( CAlfSrvHostControl ) : public CHuiControl |
|
35 { |
|
36 public: |
|
37 CAlfSrvHostControl(CHuiEnv& aEnv) : CHuiControl(aEnv) {} |
|
38 CHuiLayout* ContainerLayout(const CHuiControl* aConnected) const; |
|
39 }; |
|
40 |
|
41 |
|
42 CHuiLayout* CAlfSrvHostControl::ContainerLayout(const CHuiControl* /*aConnected*/) const |
|
43 { |
|
44 if ( VisualCount() ) |
|
45 { |
|
46 return static_cast<CHuiLayout*>(&Visual(0)); |
|
47 } |
|
48 return NULL; |
|
49 } |
|
50 |
|
51 |
|
52 // ======== MEMBER FUNCTIONS ======== |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Constructor |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CAlfSrvControlGroupSubSession::CAlfSrvControlGroupSubSession( |
|
59 CAlfAppSrvSessionBase& aSession, |
|
60 TInt aId ) |
|
61 : CAlfSrvSubSessionBase( aSession ), iId( aId ) |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // 2nd phasse constructor |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void CAlfSrvControlGroupSubSession::ConstructL() |
|
71 { |
|
72 CAlfSrvSubSessionBase::ConstructL(); |
|
73 |
|
74 iControlGroup = &Session().SharedHuiEnv()->NewControlGroupL( |
|
75 reinterpret_cast<TInt>(this) ); |
|
76 |
|
77 iHostControl = new (ELeave) CAlfSrvHostControl( *Session().SharedHuiEnv() ); |
|
78 iHostControl->ConstructL(); |
|
79 iHostControl->SetRole(EAlfSessionContainer); |
|
80 |
|
81 CHuiLayout* sessionContainer = CHuiDeckLayout::AddNewL( *iHostControl, NULL ); |
|
82 sessionContainer->SetFlags( EHuiVisualFlagManualLayout ); |
|
83 sessionContainer->SetTagL( _L8("Session container") ); |
|
84 sessionContainer->SetSize( Session().ClientDrawingArea().Size() ); |
|
85 sessionContainer->SetPos( Session().ClientDrawingArea().iTl ); |
|
86 |
|
87 iControlGroup->AppendL( iHostControl ); |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // NewL |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CAlfSrvControlGroupSubSession* CAlfSrvControlGroupSubSession::NewL( |
|
96 CAlfAppSrvSessionBase& aSession, |
|
97 TInt aId ) |
|
98 { |
|
99 CAlfSrvControlGroupSubSession* self = |
|
100 CAlfSrvControlGroupSubSession::NewLC( aSession, aId ); |
|
101 CleanupStack::Pop( self ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // NewLC |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CAlfSrvControlGroupSubSession* CAlfSrvControlGroupSubSession::NewLC( |
|
111 CAlfAppSrvSessionBase& aSession, |
|
112 TInt aId ) |
|
113 { |
|
114 CAlfSrvControlGroupSubSession* self = |
|
115 new( ELeave ) CAlfSrvControlGroupSubSession( aSession, aId ); |
|
116 CleanupClosePushL( *self ); |
|
117 self->ConstructL(); |
|
118 return self; |
|
119 } |
|
120 |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // Destructor |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CAlfSrvControlGroupSubSession::~CAlfSrvControlGroupSubSession() |
|
127 { |
|
128 // Hide the control group from the display |
|
129 CHuiDisplay* display = Session().SharedHuiEnv()->DisplayCount() ? |
|
130 &Session().SharedHuiEnv()->PrimaryDisplay() : |
|
131 NULL ; |
|
132 if ( display ) |
|
133 { |
|
134 display->Roster().Hide( ControlGroup() ); |
|
135 } |
|
136 |
|
137 Session().SharedHuiEnv()->DeleteControlGroup( reinterpret_cast<TInt>(this) ); |
|
138 |
|
139 iControlGroup = NULL; |
|
140 iHostControl = NULL; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // Gets control group |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 CHuiControlGroup& CAlfSrvControlGroupSubSession::ControlGroup() |
|
148 { |
|
149 return *iControlGroup; |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // Is control group shown |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 TBool CAlfSrvControlGroupSubSession::IsShown() const |
|
157 { |
|
158 return iIsShown; |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // Set if the control group is shown |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 void CAlfSrvControlGroupSubSession::SetIsShown( TBool aShown ) |
|
166 { |
|
167 iIsShown = aShown; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // Append control |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CAlfSrvControlGroupSubSession::AppendL( |
|
175 const RMessage2& aMessage ) |
|
176 { |
|
177 // Parse parameters |
|
178 |
|
179 CHuiControl* control = static_cast<CHuiControl*> |
|
180 ( Session().GetInterfaceL(EHuiObjectTypeControl, aMessage.Int1()) ); |
|
181 |
|
182 // Set host |
|
183 control->SetHostId( iHostControl->Id() ); |
|
184 |
|
185 // Append control |
|
186 ControlGroup().AppendL(control); |
|
187 |
|
188 // Complete |
|
189 aMessage.Complete( KErrNone ); |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // Remove control |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CAlfSrvControlGroupSubSession::RemoveL( |
|
197 const RMessage2& aMessage ) |
|
198 { |
|
199 // Parse parameters |
|
200 |
|
201 CHuiControl* control = static_cast<CHuiControl*> |
|
202 ( Session().GetInterfaceL(EHuiObjectTypeControl, aMessage.Int1())); |
|
203 |
|
204 // Append control |
|
205 TInt err = ControlGroup().Remove(control); |
|
206 |
|
207 // Complete |
|
208 aMessage.Complete( err ); |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // Enables transformation |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 void CAlfSrvControlGroupSubSession::EnableTransformationL( |
|
216 const RMessage2& aMessage ) |
|
217 { |
|
218 // Parser parameters |
|
219 |
|
220 // 1: is transformed (in) |
|
221 const TBool isTransformed = aMessage.Int1(); |
|
222 |
|
223 // 2: transformation handle (in) |
|
224 const TInt transHandle = aMessage.Int2(); |
|
225 CAlfSrvSubSessionBase& subSession = Session().SubSession( transHandle ); |
|
226 CAlfSrvTransformationSubSession& transformationSubSession = |
|
227 static_cast<CAlfSrvTransformationSubSession&>(subSession); |
|
228 |
|
229 // Enable transformation |
|
230 ControlGroup().EnableTransformationL( isTransformed ); |
|
231 CHuiTransformation* transformation = NULL; |
|
232 if ( isTransformed ) |
|
233 { |
|
234 transformation = &ControlGroup().Transformation(); |
|
235 } |
|
236 transformationSubSession.SetTransformation( transformation ); |
|
237 |
|
238 // Complete |
|
239 aMessage.Complete( KErrNone ); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // From CAlfSrvSubSessionBase |
|
244 // Process the message. |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CAlfSrvControlGroupSubSession::DoProcessMessageL(const RMessage2& aMessage) |
|
248 { |
|
249 switch( aMessage.Int0() ) |
|
250 { |
|
251 case EAlfControlGroupAppend: |
|
252 { |
|
253 AppendL( aMessage ); |
|
254 break; |
|
255 } |
|
256 |
|
257 case EAlfControlGroupRemove: |
|
258 { |
|
259 RemoveL( aMessage ); |
|
260 break; |
|
261 } |
|
262 |
|
263 case EAlfControlGroupEnableTransformation: |
|
264 { |
|
265 EnableTransformationL( aMessage ); |
|
266 break; |
|
267 } |
|
268 case EAlfControlGroupSubSessionClose: // obsolete |
|
269 { |
|
270 Session().CloseSubSession( aMessage ); |
|
271 break; |
|
272 } |
|
273 default: |
|
274 CAlfSrvSubSessionBase::DoProcessMessageL( aMessage ); |
|
275 break; |
|
276 } |
|
277 } |
|
278 |
|
279 |
|
280 CHuiControlGroup* CAlfSrvControlGroupSubSession::AsHuiControlCroup() |
|
281 { |
|
282 return iControlGroup; |
|
283 } |
|
284 |
|
285 TInt& CAlfSrvControlGroupSubSession::PreferredPos() |
|
286 { |
|
287 return iPrefrerredPos; |
|
288 } |
|
289 |
|
290 |
|
291 |