|
1 /* |
|
2 * Copyright (c) 2002-2004 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: View control adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 |
|
20 // User includes |
|
21 #include "xnappuiadapter.h" |
|
22 #include "xnuiengine.h" |
|
23 #include "xnnodepluginif.h" |
|
24 #include "xnnode.h" |
|
25 |
|
26 #include "xndomdocument.h" |
|
27 #include "xndomnode.h" |
|
28 #include "xnproperty.h" |
|
29 |
|
30 #include "xnviewcontroladapter.h" |
|
31 |
|
32 // Constants |
|
33 |
|
34 // ============================ LOCAL FUNCTIONS ================================ |
|
35 // ----------------------------------------------------------------------------- |
|
36 // ResetGrabbingL |
|
37 // Removes recursively grabbing controls |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 static void ResetGrabbingL( CXnControlAdapter* aControl, |
|
41 const TPointerEvent& aEvent ) |
|
42 { |
|
43 if ( aControl ) |
|
44 { |
|
45 CCoeControl* grabber( aControl->GrabbingComponent() ); |
|
46 |
|
47 if ( grabber ) |
|
48 { |
|
49 // cancel longtap detector before reset grabbing. |
|
50 CAknLongTapDetector* detector = aControl->LongTapDetector(); |
|
51 if ( detector && detector->IsActive() ) |
|
52 { |
|
53 detector->Cancel(); |
|
54 } |
|
55 grabber->IgnoreEventsUntilNextPointerUp(); |
|
56 |
|
57 aControl->CCoeControl::HandlePointerEventL( aEvent ); |
|
58 |
|
59 CXnControlAdapter* adapter = |
|
60 dynamic_cast< CXnControlAdapter* >( grabber ); |
|
61 |
|
62 ResetGrabbingL( adapter, aEvent ); |
|
63 } |
|
64 } |
|
65 } |
|
66 |
|
67 // ============================ MEMBER FUNCTIONS =============================== |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CXnViewControlAdapter::NewL |
|
71 // Symbian static 1st phase constructor |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CXnViewControlAdapter* CXnViewControlAdapter::NewL( CXnNodePluginIf& aNode ) |
|
75 { |
|
76 CXnViewControlAdapter* self = new( ELeave ) CXnViewControlAdapter( aNode ); |
|
77 |
|
78 CleanupStack::PushL( self ); |
|
79 self->ConstructL( aNode ); |
|
80 CleanupStack::Pop( self ); |
|
81 |
|
82 return self; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CXnViewControlAdapter::ConstructL |
|
87 // Symbian 2nd phase constructor can leave. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CXnViewControlAdapter::ConstructL( CXnNodePluginIf& aNode ) |
|
91 { |
|
92 CreateWindowL(); |
|
93 |
|
94 CXnControlAdapter::ConstructL( aNode ); |
|
95 |
|
96 if( Window().SetTransparencyAlphaChannel() == KErrNone ) |
|
97 { |
|
98 Window().SetBackgroundColor( ~0 ); |
|
99 } |
|
100 |
|
101 Window().SetPointerGrab( EFalse ); |
|
102 |
|
103 EnableDragEvents(); |
|
104 |
|
105 ActivateL(); |
|
106 |
|
107 SetComponentsToInheritVisibility( ETrue ); |
|
108 |
|
109 iAppUi.UiStateListener().AddObserver( *this ); |
|
110 |
|
111 // By default all views are invisible during construction phase |
|
112 CXnDomStringPool* sp( aNode.Node().DomNode()->StringPool() ); |
|
113 |
|
114 CXnProperty* prop = CXnProperty::NewL( |
|
115 XnPropertyNames::style::common::KDisplay, |
|
116 XnPropertyNames::style::common::display::KNone, |
|
117 CXnDomPropertyValue::EString, *sp ); |
|
118 CleanupStack::PushL( prop ); |
|
119 |
|
120 aNode.SetPropertyWithoutNotificationL( prop ); |
|
121 CleanupStack::Pop( prop ); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CXnViewControlAdapter::CXnViewControlAdapter |
|
126 // C++ default constructor |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 CXnViewControlAdapter::CXnViewControlAdapter( CXnNodePluginIf& aNode ) |
|
130 : iNode( aNode ), iAppUi( static_cast< CXnAppUiAdapter& >( *iAvkonAppUi ) ) |
|
131 { |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CXnViewControlAdapter::~CXnViewControlAdapter |
|
136 // C++ destructor |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 CXnViewControlAdapter::~CXnViewControlAdapter() |
|
140 { |
|
141 iAppUi.UiStateListener().RemoveObserver( *this ); |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CXnViewControlAdapter::MakeVisible |
|
146 // |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CXnViewControlAdapter::MakeVisible( TBool aVisible ) |
|
150 { |
|
151 if ( aVisible == IsVisible() ) |
|
152 { |
|
153 return; |
|
154 } |
|
155 |
|
156 if ( aVisible ) |
|
157 { |
|
158 if ( !iAppUi.UiEngine().IsEditMode() ) |
|
159 { |
|
160 Window().SetPointerGrab( ETrue ); |
|
161 } |
|
162 } |
|
163 else |
|
164 { |
|
165 Window().SetPointerGrab( EFalse ); |
|
166 |
|
167 ResetGrabbing(); |
|
168 } |
|
169 |
|
170 CCoeControl::MakeVisible( aVisible ); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CXnViewControlAdapter::Draw |
|
175 // |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CXnViewControlAdapter::Draw( const TRect& aRect ) const |
|
179 { |
|
180 SystemGc().Clear( aRect ); |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CXnViewControlAdapter::HandlePointerEventL |
|
185 // |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CXnViewControlAdapter::HandlePointerEventL( |
|
189 const TPointerEvent& aPointerEvent ) |
|
190 { |
|
191 if ( iForegroundStatus != EBackground ) |
|
192 { |
|
193 iAppUi.UiEngine().DisableRenderUiLC(); |
|
194 |
|
195 CXnControlAdapter::HandlePointerEventL( aPointerEvent ); |
|
196 |
|
197 iAppUi.UiEngine().RenderUIL(); |
|
198 |
|
199 CleanupStack::PopAndDestroy(); |
|
200 } |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CXnViewControlAdapter::ResetGrabbing() |
|
205 // |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CXnViewControlAdapter::ResetGrabbing() |
|
209 { |
|
210 TPointerEvent event; |
|
211 |
|
212 event.iModifiers = 0; |
|
213 event.iPosition = TPoint(); |
|
214 event.iParentPosition = TPoint(); |
|
215 event.iType = TPointerEvent::EButton1Up; |
|
216 |
|
217 TRAP_IGNORE( ResetGrabbingL( this, event ) ); |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CXnViewControlAdapter::NotifyForegroundChanged() |
|
222 // |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CXnViewControlAdapter::NotifyForegroundChanged( TForegroundStatus aStatus ) |
|
226 { |
|
227 iForegroundStatus = aStatus; |
|
228 if ( aStatus == EBackground || aStatus == EPartialForeground ) |
|
229 { |
|
230 ResetGrabbing(); |
|
231 } |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CXnViewControlAdapter::NotifyLightStatusChanged() |
|
236 // |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void CXnViewControlAdapter::NotifyLightStatusChanged( TBool /*aLightsOn*/ ) |
|
240 { |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CXnViewControlAdapter::NotifyInCallStateChaged() |
|
245 // |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 void CXnViewControlAdapter::NotifyInCallStateChaged( TBool /*aInCall*/ ) |
|
249 { |
|
250 } |
|
251 |
|
252 // End of file |