|
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: Xuikon control adapter source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System includes |
|
20 #include <AknUtils.h> |
|
21 |
|
22 // User includes |
|
23 #include "xncontroladapter.h" |
|
24 #include "xncontroladapterimpl.h" |
|
25 #include "xnproperty.h" |
|
26 #include "xnnodepluginif.h" |
|
27 #include "xnnode.h" |
|
28 #include "xnuiengine.h" |
|
29 #include "xncomponent.h" |
|
30 #include "xncomponentnodeimpl.h" |
|
31 #include "xntype.h" |
|
32 |
|
33 #include "xnviewnodeimpl.h" |
|
34 #include "xneditmode.h" |
|
35 |
|
36 // Constants |
|
37 const TInt KLongTapStartDelay( 500000 ); // 0.5s |
|
38 const TInt KLongTapTimeDelay( 1500000 ); // 1.5s |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CreateLongTapDetectorL |
|
42 // Checks wheter longtap detector is needed for this node |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 static TBool CreateLongTapDetectorL( CXnNode& aNode ) |
|
46 { |
|
47 if ( AknLayoutUtils::PenEnabled() ) |
|
48 { |
|
49 if ( aNode.Type()->Type() == KMenuBarNode ) |
|
50 { |
|
51 RPointerArray< CXnNode >& children( aNode.Children() ); |
|
52 |
|
53 for ( TInt i = 0; i < children.Count(); i++ ) |
|
54 { |
|
55 CXnProperty* prop( children[i]->GetPropertyL( |
|
56 XnPropertyNames::common::KLongTap ) ); |
|
57 |
|
58 if ( prop && prop->StringValue() == XnPropertyNames::KTrue ) |
|
59 { |
|
60 return ETrue; |
|
61 } |
|
62 } |
|
63 } |
|
64 else |
|
65 { |
|
66 CXnProperty* prop( aNode.GetPropertyL( |
|
67 XnPropertyNames::common::KLongTap ) ); |
|
68 |
|
69 if ( prop && prop->StringValue() == XnPropertyNames::KTrue ) |
|
70 { |
|
71 return ETrue; |
|
72 } |
|
73 } |
|
74 } |
|
75 |
|
76 return EFalse; |
|
77 } |
|
78 |
|
79 // ============================ MEMBER FUNCTIONS =============================== |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CXnControlAdapter::NewL |
|
83 // Two-phased constructor. Can leave. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 EXPORT_C CXnControlAdapter* CXnControlAdapter::NewL( CXnNodePluginIf& aNode ) |
|
87 { |
|
88 CXnControlAdapter* self = new ( ELeave ) CXnControlAdapter; |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL( aNode ); |
|
91 CleanupStack::Pop(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CXnControlAdapter::~CXnControlAdapter |
|
97 // Destructor. |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C CXnControlAdapter::~CXnControlAdapter() |
|
101 { |
|
102 delete iImpl; |
|
103 delete iLongTapDetector; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CXnControlAdapter::CXnControlAdapter |
|
108 // C++ default constructor. Must not leave. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C CXnControlAdapter::CXnControlAdapter() |
|
112 { |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CXnControlAdapter::ConstructL |
|
117 // 2nd phase constructor. Can leave. |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C void CXnControlAdapter::ConstructL( CXnNodePluginIf& aNode ) |
|
121 { |
|
122 iImpl = CXnControlAdapterImpl::NewL( aNode, *this, SystemGc() ); |
|
123 |
|
124 if ( CreateLongTapDetectorL( aNode.Node() ) ) |
|
125 { |
|
126 iLongTapDetector = CAknLongTapDetector::NewL( this ); |
|
127 |
|
128 iLongTapDetector->SetTimeDelayBeforeAnimation( KLongTapStartDelay ); |
|
129 iLongTapDetector->SetLongTapDelay( KLongTapTimeDelay ); |
|
130 } |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CXnControlAdapter::SetComponent |
|
135 // Sets component object to adapter. |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C void CXnControlAdapter::SetComponent( CXnComponent* aComponent ) |
|
139 { |
|
140 iImpl->SetComponent( aComponent ); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CXnControlAdapter::Component |
|
145 // Returns component attached to this adapter |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 CXnComponent* CXnControlAdapter::Component() const |
|
149 { |
|
150 return const_cast< CXnComponent* >( iImpl->Component() ); |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CXnControlAdapter::Component |
|
155 // Gets component object from adapter. |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 EXPORT_C CXnComponent* CXnControlAdapter::Component() |
|
159 { |
|
160 return iImpl->Component(); |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CXnControlAdapter::OfferKeyEventL |
|
165 // Handles key events. |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 EXPORT_C TKeyResponse CXnControlAdapter::OfferKeyEventL( |
|
169 const TKeyEvent& aKeyEvent, |
|
170 TEventCode aType ) |
|
171 { |
|
172 return iImpl->OfferKeyEventL( aKeyEvent, aType ); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CXnControlAdapter::HandleControlEventL |
|
177 // Handles control events. |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C void CXnControlAdapter::HandleControlEventL( |
|
181 CCoeControl* /*aControl*/, |
|
182 TCoeEvent /*aEventType*/ ) |
|
183 { |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CXnControlAdapter::HandleLongTapEventL |
|
188 // Handles the long tap events. |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 EXPORT_C void CXnControlAdapter::HandleLongTapEventL( |
|
192 const TPoint& aPenEventLocation, |
|
193 const TPoint& aPenEventScreenLocation ) |
|
194 { |
|
195 CXnNode* node( &Component()->Node()->Node() ); |
|
196 |
|
197 CXnUiEngine* engine( node->UiEngine() ); |
|
198 |
|
199 engine->DisableRenderUiLC(); |
|
200 |
|
201 iImpl->HandleLongTapEventL( aPenEventLocation, aPenEventScreenLocation ); |
|
202 |
|
203 CleanupStack::PopAndDestroy(); // DisableRenderUiLC; |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CXnControlAdapter::EnableLongTapAnimation |
|
208 // Handles the long tap events. |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 EXPORT_C void CXnControlAdapter::EnableLongTapAnimation( const TBool aAnimation ) |
|
212 { |
|
213 if ( iLongTapDetector ) |
|
214 { |
|
215 iLongTapDetector->EnableLongTapAnimation( aAnimation ); |
|
216 } |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CXnControlAdapter::HandlePointerEventL |
|
221 // Handle pointer events |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 EXPORT_C void CXnControlAdapter::HandlePointerEventL( |
|
225 const TPointerEvent& aPointerEvent ) |
|
226 { |
|
227 TBool consumed( EFalse ); |
|
228 |
|
229 switch( aPointerEvent.iType ) |
|
230 { |
|
231 case TPointerEvent::EButton1Down: |
|
232 case TPointerEvent::EButton1Up: |
|
233 case TPointerEvent::EDrag: |
|
234 consumed = iImpl->HandlePointerEventL( aPointerEvent ); |
|
235 break; |
|
236 default: |
|
237 break; |
|
238 } |
|
239 |
|
240 if ( !consumed ) |
|
241 { |
|
242 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
243 } |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CXnControlAdapter::Draw |
|
248 // Draws the control |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 EXPORT_C void CXnControlAdapter::Draw( const TRect& aRect ) const |
|
252 { |
|
253 iImpl->Draw( aRect ); |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CXnControlAdapter::Draw |
|
258 // Draws the control |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 EXPORT_C void CXnControlAdapter::Draw( const TRect& aRect, CWindowGc& aGc ) const |
|
262 { |
|
263 iImpl->Draw( aRect, aGc ); |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CXnControlAdapter::ComponentControl |
|
268 // Return a child control by index |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 EXPORT_C CCoeControl* CXnControlAdapter::ComponentControl( TInt aIndex ) const |
|
272 { |
|
273 return iImpl->ComponentControl( aIndex ); |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CXnControlAdapter::CountComponentControls |
|
278 // Return count of children |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 EXPORT_C TInt CXnControlAdapter::CountComponentControls() const |
|
282 { |
|
283 return iImpl->CountComponentControls(); |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CXnControlAdapter::SetVisible |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 EXPORT_C void CXnControlAdapter::SetVisible( TBool aVisible ) |
|
291 { |
|
292 MakeVisible( aVisible ); |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // CXnControlAdapter::AppendChildL |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 void CXnControlAdapter::AppendChildL(CXnControlAdapter& aChild, CXnNode& aNode) |
|
300 { |
|
301 iImpl->AppendChildL(aChild, aNode); |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CXnControlAdapter::IsDrawingAllowed |
|
306 // Checks whether drawing is allowed |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 EXPORT_C TBool CXnControlAdapter::IsDrawingAllowed() const |
|
310 { |
|
311 return iImpl->IsDrawingAllowed(); |
|
312 } |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CXnControlAdapter::ContentBitmaps |
|
316 // Gets content bitmaps |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 EXPORT_C void CXnControlAdapter::ContentBitmaps( |
|
320 CFbsBitmap*& aBitmap, |
|
321 CFbsBitmap*& aMask ) |
|
322 { |
|
323 iImpl->ContentBitmaps( aBitmap, aMask ); |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CXnControlAdapter::SetContentBitmaps |
|
328 // Sets content bitmaps |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 EXPORT_C void CXnControlAdapter::SetContentBitmaps( |
|
332 CFbsBitmap* aBitmap, |
|
333 CFbsBitmap* aMask ) |
|
334 { |
|
335 iImpl->SetContentBitmaps( aBitmap, aMask ); |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // CXnControlAdapter::SetContentBitmaps |
|
340 // Sets content bitmaps |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 EXPORT_C void CXnControlAdapter::SetContentBitmaps( |
|
344 const TDesC& aBitmapUrl, |
|
345 const TDesC& aMaskUrl ) |
|
346 { |
|
347 TRAP_IGNORE( iImpl->SetContentBitmapsL( aBitmapUrl, aMaskUrl ) ); |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CXnControlAdapter::DrawContentImage |
|
352 // Draws content image |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 EXPORT_C void CXnControlAdapter::DrawContentImage() const |
|
356 { |
|
357 iImpl->DrawContentImage(); |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CXnControlAdapter::SizeChanged |
|
362 // Control size change notification |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 EXPORT_C void CXnControlAdapter::SizeChanged() |
|
366 { |
|
367 iImpl->SizeChanged(); |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CXnControlAdapter::SkinChanged |
|
372 // Skin change notification |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 EXPORT_C void CXnControlAdapter::SkinChanged() |
|
376 { |
|
377 TRAP_IGNORE( Component()->Node()->SetDirtyL() ); |
|
378 |
|
379 iImpl->SkinChanged(); |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CXnControlAdapter::FocusChanged |
|
384 // Focus change notification |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 EXPORT_C void CXnControlAdapter::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
388 { |
|
389 TRAP_IGNORE( iImpl->FocusChangedL( IsFocused() ) ); |
|
390 } |
|
391 |
|
392 // ----------------------------------------------------------------------------- |
|
393 // CXnControlAdapter::LoadBitmap |
|
394 // Load a bitmap from the server. Ownership is transferred. |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 EXPORT_C CFbsBitmap* CXnControlAdapter::LoadBitmap( const TDesC& aBitmapUrl ) |
|
398 { |
|
399 return iImpl->LoadBitmap( aBitmapUrl ); |
|
400 } |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // CXnControlAdapter::GetBitmapAndMask |
|
404 // Load a bitmap and mask from the server. Ownership is transferred. |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 EXPORT_C void CXnControlAdapter::GetBitmapAndMask( |
|
408 const TDesC& aBitmapUrl, |
|
409 const TDesC& aMaskUrl, |
|
410 CFbsBitmap*& aBitmap, |
|
411 CFbsBitmap*& aMask ) |
|
412 { |
|
413 iImpl->GetBitmapAndMask( aBitmapUrl, aMaskUrl, aBitmap, aMask ); |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CXnControlAdapter::EnterPowerSaveModeL |
|
418 // Enter power save mode |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 EXPORT_C void CXnControlAdapter::EnterPowerSaveModeL( TModeEvent aEvent ) |
|
422 { |
|
423 iImpl->StopHighlightAnimation(); |
|
424 DoEnterPowerSaveModeL( aEvent ); |
|
425 } |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // CXnControlAdapter::DoEnterPowerSaveModeL |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 EXPORT_C void CXnControlAdapter::DoEnterPowerSaveModeL( TModeEvent /* aEvent */ ) |
|
432 { |
|
433 } |
|
434 |
|
435 // ----------------------------------------------------------------------------- |
|
436 // CXnControlAdapter::ExitPowerSaveModeL |
|
437 // Exit power save mode |
|
438 // ----------------------------------------------------------------------------- |
|
439 // |
|
440 EXPORT_C void CXnControlAdapter::ExitPowerSaveModeL( TModeEvent aEvent ) |
|
441 { |
|
442 iImpl->StartHighlightAnimation(); |
|
443 DoExitPowerSaveModeL( aEvent ); |
|
444 } |
|
445 |
|
446 // ----------------------------------------------------------------------------- |
|
447 // CXnControlAdapter::DoExitPowerSaveModeL |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 EXPORT_C void CXnControlAdapter::DoExitPowerSaveModeL( TModeEvent /*aEvent*/ ) |
|
451 { |
|
452 } |
|
453 |
|
454 // ----------------------------------------------------------------------------- |
|
455 // CXnControlAdapter::SetLocalUiZoomL |
|
456 // Set local UI zoom level |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 EXPORT_C void CXnControlAdapter::SetLocalUiZoomL( TAknUiZoom /*aZoom*/ ) |
|
460 { |
|
461 } |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // CXnControlAdapter::HandleScreenDeviceChangedL |
|
465 // ----------------------------------------------------------------------------- |
|
466 // |
|
467 EXPORT_C void CXnControlAdapter::HandleScreenDeviceChangedL() |
|
468 { |
|
469 CXnNode& node( Component()->Node()->Node() ); |
|
470 |
|
471 if ( CreateLongTapDetectorL( node ) ) |
|
472 { |
|
473 if ( !iLongTapDetector ) |
|
474 { |
|
475 iLongTapDetector = CAknLongTapDetector::NewL( this ); |
|
476 } |
|
477 } |
|
478 else |
|
479 { |
|
480 delete iLongTapDetector; |
|
481 iLongTapDetector = NULL; |
|
482 } |
|
483 |
|
484 Component()->Node()->SetDirtyL(); |
|
485 |
|
486 iImpl->HandleScreenDeviceChangedL(); |
|
487 } |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // CXnControlAdapter::HandlePropertyChangeL |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 EXPORT_C void CXnControlAdapter::HandlePropertyChangeL( CXnProperty* aProperty ) |
|
494 { |
|
495 // Check component focus. |
|
496 CXnComponent* component( iImpl->Component() ); |
|
497 |
|
498 if ( component ) |
|
499 { |
|
500 CXnNodePluginIf* node( component->Node() ); |
|
501 |
|
502 if ( node ) |
|
503 { |
|
504 if ( node->IsFocusedState() ) |
|
505 { |
|
506 iImpl->StartHighlightAnimation(); |
|
507 } |
|
508 else |
|
509 { |
|
510 iImpl->StopHighlightAnimation(); |
|
511 } |
|
512 } |
|
513 } |
|
514 |
|
515 if ( iImpl->UpdateBackgroundImageL( aProperty) == |
|
516 CXnControlAdapterImpl::EPropertyChangeNotConsumed ) |
|
517 { |
|
518 DoHandlePropertyChangeL( aProperty ); |
|
519 } |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // CXnControlAdapter::DoHandlePropertyChangeL |
|
524 // ----------------------------------------------------------------------------- |
|
525 // |
|
526 EXPORT_C void CXnControlAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty ) |
|
527 { |
|
528 iImpl->DoHandlePropertyChangeL( aProperty ); |
|
529 } |
|
530 |
|
531 // ----------------------------------------------------------------------------- |
|
532 // CXnControlAdapter::MeasureAdaptiveContentL |
|
533 // Measures the content dimensions |
|
534 // ----------------------------------------------------------------------------- |
|
535 // |
|
536 EXPORT_C TSize CXnControlAdapter::MeasureAdaptiveContentL( |
|
537 const TSize& aAvailableSize ) |
|
538 { |
|
539 return iImpl->MeasureAdaptiveContentL( aAvailableSize ); |
|
540 } |
|
541 |
|
542 // ----------------------------------------------------------------------------- |
|
543 // CXnControlAdapter::ResetStylusCounter |
|
544 // ----------------------------------------------------------------------------- |
|
545 // |
|
546 EXPORT_C void CXnControlAdapter::ResetStylusCounter() |
|
547 { |
|
548 } |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // CXnControlAdapter::SetBlank |
|
552 // |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 EXPORT_C void CXnControlAdapter::SetBlank( TBool aBlank ) |
|
556 { |
|
557 iImpl->SetBlank( aBlank ); |
|
558 } |
|
559 |
|
560 // ----------------------------------------------------------------------------- |
|
561 // CXnControlAdapter::LongTapDetector |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 EXPORT_C CAknLongTapDetector* CXnControlAdapter::LongTapDetector() const |
|
565 { |
|
566 return iLongTapDetector; |
|
567 } |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // CXnControlAdapter::RemoveChildAdapters |
|
571 // ----------------------------------------------------------------------------- |
|
572 // |
|
573 void CXnControlAdapter::RemoveChildAdapters() |
|
574 { |
|
575 iImpl->RemoveChildAdapters(); |
|
576 } |
|
577 |
|
578 // ----------------------------------------------------------------------------- |
|
579 // ----------------------------------------------------------------------------- |
|
580 // |
|
581 RPointerArray<CXnControlAdapter>& CXnControlAdapter::ChildAdapters() |
|
582 { |
|
583 return iImpl->ChildAdapters(); |
|
584 } |