400 |
308 |
401 CleanupStack::PopAndDestroy( pcData16 ); |
309 CleanupStack::PopAndDestroy( pcData16 ); |
402 } |
310 } |
403 } |
311 } |
404 CleanupStack::PopAndDestroy( &children ); |
312 CleanupStack::PopAndDestroy( &children ); |
|
313 |
|
314 iControl->SetCurrentTitle( ETrue ); |
|
315 |
405 } |
316 } |
406 |
317 |
407 // ----------------------------------------------------------------------------- |
318 // ----------------------------------------------------------------------------- |
408 // CXnNewstickerAdapter::CXnNewstickerAdapter |
319 // CXnNewstickerAdapter::CXnNewstickerAdapter |
409 // C++ default constructor |
320 // C++ default constructor |
410 // ----------------------------------------------------------------------------- |
321 // ----------------------------------------------------------------------------- |
411 // |
322 // |
412 CXnNewstickerAdapter::CXnNewstickerAdapter(CXnControlAdapter* /*aParent*/, |
323 CXnNewstickerAdapter::CXnNewstickerAdapter( CXnControlAdapter* /*aParent*/, |
413 CXnNodePluginIf& aNode) |
324 CXnNodePluginIf& aNode ) |
414 : iState(ENotStarted), iNode(aNode) |
325 : iNode( aNode ), |
|
326 iPowerSaveMode( ETrue ), |
|
327 iRestartAfterUpdate( EFalse ), |
|
328 iTextColor( KRgbBlack ), |
|
329 iTextAlignment( ELayoutAlignLeft ), |
|
330 iTextBaseline( 0 ), |
|
331 iUnderlining( EUnderlineOff ), |
|
332 iStrikethrough( EStrikethroughOff ), |
|
333 iScrollLooping( ETrue ), |
|
334 iRedraw( ETrue ) |
415 { |
335 { |
416 } |
336 } |
417 |
337 |
418 // ----------------------------------------------------------------------------- |
338 // ----------------------------------------------------------------------------- |
419 // CXnNewstickerAdapter::~CXnNewstickerAdapter |
339 // CXnNewstickerAdapter::~CXnNewstickerAdapter |
420 // C++ destructor |
340 // C++ destructor |
421 // ----------------------------------------------------------------------------- |
341 // ----------------------------------------------------------------------------- |
422 // |
342 // |
423 CXnNewstickerAdapter::~CXnNewstickerAdapter() |
343 CXnNewstickerAdapter::~CXnNewstickerAdapter() |
424 { |
344 { |
425 if( iPeriodicTimer ) |
345 if( iPeriodicTimer && iPeriodicTimer->IsActive() ) |
426 { |
346 { |
427 iPeriodicTimer->Cancel(); |
347 iPeriodicTimer->Cancel(); |
428 } |
348 } |
429 |
349 |
430 delete iPeriodicTimer; |
350 delete iPeriodicTimer; |
431 |
351 |
432 if( iFont && iReleaseFont ) |
352 if( iFont && ( iReleaseFont == 1 ) ) |
433 { |
353 { |
434 CWsScreenDevice* dev = iCoeEnv->ScreenDevice(); |
354 CWsScreenDevice* dev = iCoeEnv->ScreenDevice(); |
435 dev->ReleaseFont( iFont ); |
355 dev->ReleaseFont( iFont ); |
436 } |
356 } |
437 |
357 |
|
358 delete iMarqueeControl; |
438 delete iControl; |
359 delete iControl; |
439 |
360 |
440 if( iState == EAnimation ) |
|
441 { |
|
442 TRAP_IGNORE( iSvgControl->StopL() ); |
|
443 } |
|
444 |
|
445 delete iSvgControl; |
|
446 delete iBufferDevice; |
|
447 delete iDrawingBuffer; |
|
448 delete iBufferGc; |
|
449 delete iBackgroundBitmap; |
|
450 } |
361 } |
451 |
362 |
452 // ----------------------------------------------------------------------------- |
363 // ----------------------------------------------------------------------------- |
453 // CXnNewstickerAdapter::SetTextPropertiesL |
364 // CXnNewstickerAdapter::SetTextPropertiesL |
454 // Sets text properties, such as color, font, etc. |
365 // Sets text properties, such as color, font, etc. |
455 // ----------------------------------------------------------------------------- |
366 // ----------------------------------------------------------------------------- |
456 // |
367 // |
457 void CXnNewstickerAdapter::SetTextPropertiesL() |
368 void CXnNewstickerAdapter::SetTextPropertiesL() |
458 { |
369 { |
459 if (iFont && iReleaseFont) |
370 if (iFont && ( iReleaseFont == 1 ) ) |
460 { |
371 { |
461 CWsScreenDevice* dev = iCoeEnv->ScreenDevice(); |
372 CWsScreenDevice* dev = iCoeEnv->ScreenDevice(); |
462 dev->ReleaseFont(iFont); |
373 dev->ReleaseFont(iFont); |
463 iFont = NULL; |
374 iFont = NULL; |
464 } |
375 } |
|
376 |
465 CXnUtils::CreateFontL(iNode, iFont, iReleaseFont); |
377 CXnUtils::CreateFontL(iNode, iFont, iReleaseFont); |
466 iControl->SetFont(iFont); |
|
467 |
378 |
468 TBool colorSet(EFalse); |
379 TBool colorSet(EFalse); |
469 CXnProperty* colorProperty = iNode.GetPropertyL(XnPropertyNames::appearance::common::KColor); |
380 CXnProperty* colorProperty = iNode.GetPropertyL(XnPropertyNames::appearance::common::KColor); |
470 if (colorProperty != NULL) |
381 |
|
382 if( colorProperty ) |
471 { |
383 { |
472 CXnDomProperty* domProperty = colorProperty->Property(); |
384 CXnDomProperty* domProperty = colorProperty->Property(); |
473 if(domProperty) |
385 if(domProperty) |
474 { |
386 { |
475 TRgb textColor; |
|
476 TInt error( KErrNotSupported ); |
387 TInt error( KErrNotSupported ); |
477 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* > |
388 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* > |
478 ( domProperty->PropertyValueList().Item( 0 ) ); |
389 ( domProperty->PropertyValueList().Item( 0 ) ); |
|
390 |
479 if( value->IsAutoIdent() ) |
391 if( value->IsAutoIdent() ) |
480 { |
392 { |
481 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
393 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
482 error = AknsUtils::GetCachedColor(skinInstance, textColor, KAknsIIDQsnTextColors, |
394 error = AknsUtils::GetCachedColor( skinInstance, iTextColor, KAknsIIDQsnTextColors, |
483 EAknsCIQsnTextColorsCG6); |
395 EAknsCIQsnTextColorsCG6 ); |
484 } |
396 } |
485 else if( value->PrimitiveValueType() == CXnDomPropertyValue::ERgbColor ) |
397 else if( value->PrimitiveValueType() == CXnDomPropertyValue::ERgbColor ) |
486 { |
398 { |
487 textColor = value->RgbColorValueL(); |
399 iTextColor = value->RgbColorValueL(); |
488 error = KErrNone; |
400 error = KErrNone; |
489 } |
401 } |
490 else |
402 else |
491 { |
403 { |
492 HBufC* colorString = colorProperty->StringValueL(); |
404 HBufC* colorString = colorProperty->StringValueL(); |
495 CXnUtils::StripQuotes( colorString ); |
407 CXnUtils::StripQuotes( colorString ); |
496 |
408 |
497 TInt index = 0; |
409 TInt index = 0; |
498 TAknsItemID skinID; |
410 TAknsItemID skinID; |
499 |
411 |
500 TBool idResolved = CXnUtils::ResolveSkinItemIDL( colorString->Des(), skinID, index ); |
412 TBool idResolved = CXnUtils::ResolveSkinItemIDL( |
|
413 colorString->Des(), skinID, index ); |
501 |
414 |
502 if( idResolved ) |
415 if( idResolved ) |
503 { |
416 { |
504 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
417 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
505 error = AknsUtils::GetCachedColor( skinInstance, textColor, skinID, index ); |
418 error = AknsUtils::GetCachedColor( |
|
419 skinInstance, iTextColor, skinID, index ); |
506 } |
420 } |
507 else // use auto value if skin id is invalid. |
421 else // use auto value if skin id is invalid. |
508 { |
422 { |
509 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
423 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
510 error = AknsUtils::GetCachedColor(skinInstance, textColor, KAknsIIDQsnTextColors, |
424 error = AknsUtils::GetCachedColor(skinInstance, iTextColor, |
511 EAknsCIQsnTextColorsCG6); |
425 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); |
512 } |
426 } |
513 CleanupStack::PopAndDestroy( colorString ); |
427 CleanupStack::PopAndDestroy( colorString ); |
514 } |
428 } |
515 if (error == KErrNone) |
429 |
516 { |
430 if ( error == KErrNone ) |
517 iControl->SetTextColor(textColor); |
431 { |
518 colorSet = ETrue; |
432 colorSet = ETrue; |
519 } |
433 } |
520 } |
434 } |
521 } |
435 } |
522 |
436 |
523 if(!colorSet) // Use text skin color |
437 if( !colorSet ) // Use text skin color |
524 { |
438 { |
525 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
439 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
526 TRgb textColor; |
440 TRgb textColor; |
527 TInt error = AknsUtils::GetCachedColor( skinInstance, textColor, |
441 TInt error = AknsUtils::GetCachedColor( skinInstance, textColor, |
528 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); |
442 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); |
529 if (error == KErrNone) |
443 if (error == KErrNone) |
530 { |
444 { |
531 iControl->SetTextColor(textColor); |
445 iTextColor = textColor; |
532 } |
446 } |
533 } |
447 } |
534 |
448 |
535 CXnProperty* textDecorationProp = |
449 CXnProperty* textDecorationProp = |
536 iNode.GetPropertyL(XnPropertyNames::appearance::common::KTextDecoration); |
450 iNode.GetPropertyL(XnPropertyNames::appearance::common::KTextDecoration); |
537 if(textDecorationProp) |
451 |
|
452 if( textDecorationProp ) |
538 { |
453 { |
539 CXnDomList& propertyValueList = textDecorationProp->Property()->PropertyValueList(); |
454 CXnDomList& propertyValueList = textDecorationProp->Property()->PropertyValueList(); |
540 TInt valueCount = propertyValueList.Length(); |
455 TInt valueCount = propertyValueList.Length(); |
541 for (TInt i = 0; i < valueCount; ++i) |
456 |
|
457 for( TInt i = 0; i < valueCount; ++i ) |
542 { |
458 { |
543 CXnDomPropertyValue* value = |
459 CXnDomPropertyValue* value = |
544 static_cast<CXnDomPropertyValue*>(propertyValueList.Item(i)); |
460 static_cast<CXnDomPropertyValue*>(propertyValueList.Item(i)); |
545 if (value->StringValueL() == |
461 if (value->StringValueL() == |
546 XnPropertyNames::appearance::common::textdecoration::KUnderline) |
462 XnPropertyNames::appearance::common::textdecoration::KUnderline) |
547 { |
463 { |
548 iControl->SetTextUnderlineStyle(EUnderlineOn); |
464 iUnderlining = EUnderlineOn; |
549 } |
465 } |
550 if (value->StringValueL() == |
466 if (value->StringValueL() == |
551 XnPropertyNames::appearance::common::textdecoration::KLinethrough) |
467 XnPropertyNames::appearance::common::textdecoration::KLinethrough) |
552 { |
468 { |
553 iControl->SetTextStrikethroughStyle(EStrikethroughOn); |
469 iStrikethrough = EStrikethroughOn; |
554 } |
470 } |
555 } |
471 } |
556 } |
472 } |
557 |
473 |
558 TGulAlignmentValue alignment = CXnUtils::TextAlignment( iNode ); |
474 TGulAlignmentValue alignment = CXnUtils::TextAlignment( iNode ); |
559 |
475 |
560 TInt textAlignment( ELayoutAlignLeft ); // all are vertically top aligned by default (avkon) |
|
561 |
|
562 switch( alignment ) |
476 switch( alignment ) |
563 { |
477 { |
564 case EHCenterVCenter: |
478 case EHCenterVCenter: |
565 textAlignment = ELayoutAlignCenter; |
479 iTextAlignment = ELayoutAlignCenter; |
566 break; |
480 break; |
|
481 |
567 case EHRightVCenter: |
482 case EHRightVCenter: |
568 textAlignment = ELayoutAlignRight; |
483 iTextAlignment = ELayoutAlignRight; |
569 break; |
484 break; |
|
485 |
570 default: |
486 default: |
|
487 iTextAlignment = ELayoutAlignLeft; |
571 break; |
488 break; |
572 } |
489 } |
573 |
490 } |
574 iControl->SetTextAlignment(textAlignment); |
491 |
575 } |
492 // ----------------------------------------------------------------------------- |
576 |
|
577 // --------------------------------------------------------- |
|
578 // CXnNewstickerAdapter::AppendTitleL |
493 // CXnNewstickerAdapter::AppendTitleL |
579 // --------------------------------------------------------- |
494 // ----------------------------------------------------------------------------- |
580 // |
495 // |
581 void CXnNewstickerAdapter::AppendTitleL(const TDesC& aTitle) |
496 void CXnNewstickerAdapter::AppendTitleL( const TDesC& aTitle ) |
582 { |
497 { |
583 iControl->AppendTitleL(aTitle); |
498 iControl->AppendTitleL( aTitle ); |
584 iNode.SetDirtyL(); |
499 iNode.SetDirtyL(); |
585 } |
500 } |
586 |
501 |
587 // --------------------------------------------------------- |
502 // ----------------------------------------------------------------------------- |
588 // CXnNewstickerAdapter::InsertTitleL |
503 // CXnNewstickerAdapter::InsertTitleL |
589 // --------------------------------------------------------- |
504 // ----------------------------------------------------------------------------- |
590 // |
505 // |
591 void CXnNewstickerAdapter::InsertTitleL(const TDesC& aTitle, TInt aIndex) |
506 void CXnNewstickerAdapter::InsertTitleL( const TDesC& aTitle, TInt aIndex ) |
592 { |
507 { |
593 iControl->InsertTitleL(aTitle, aIndex); |
508 iControl->InsertTitleL( aTitle, aIndex ); |
594 iNode.SetDirtyL(); |
509 iNode.SetDirtyL(); |
595 } |
510 } |
596 |
511 |
597 // --------------------------------------------------------- |
512 // ----------------------------------------------------------------------------- |
598 // CXnNewstickerAdapter::UpdateTitleL |
513 // CXnNewstickerAdapter::UpdateTitleL |
599 // --------------------------------------------------------- |
514 // ----------------------------------------------------------------------------- |
600 // |
515 // |
601 void CXnNewstickerAdapter::UpdateTitleL(const TDesC& aTitle, TInt aIndex) |
516 void CXnNewstickerAdapter::UpdateTitleL( const TDesC& aTitle, TInt aIndex ) |
602 { |
517 { |
603 iControl->UpdateTitleL(aTitle, aIndex); |
518 iControl->UpdateTitleL( aTitle, aIndex ); |
604 iNode.SetDirtyL(); |
519 iNode.SetDirtyL(); |
|
520 |
605 if ( iRestartAfterUpdate ) |
521 if ( iRestartAfterUpdate ) |
606 { |
522 { |
607 RestartL(); |
523 Stop(); |
608 } |
524 Start(); |
609 } |
525 } |
610 |
526 } |
611 // --------------------------------------------------------- |
527 |
|
528 // ----------------------------------------------------------------------------- |
612 // CXnNewstickerAdapter::DeleteTitleL |
529 // CXnNewstickerAdapter::DeleteTitleL |
613 // --------------------------------------------------------- |
530 // ----------------------------------------------------------------------------- |
614 // |
531 // |
615 void CXnNewstickerAdapter::DeleteTitleL(TInt aIndex) |
532 void CXnNewstickerAdapter::DeleteTitleL( TInt aIndex ) |
616 { |
533 { |
617 if( iState == EAnimation && iControl->CurrentTitleIndex() == aIndex ) |
534 iControl->DeleteTitleL( aIndex ); |
618 { |
|
619 // About to delete the currently showing animation |
|
620 iSvgControl->StopL(); |
|
621 iControl->DeleteTitleL( aIndex ); |
|
622 |
|
623 RestartL(); |
|
624 } |
|
625 else |
|
626 { |
|
627 iControl->DeleteTitleL(aIndex); |
|
628 } |
|
629 |
|
630 iNode.SetDirtyL(); |
535 iNode.SetDirtyL(); |
631 } |
536 } |
632 |
537 |
633 // --------------------------------------------------------- |
538 // ----------------------------------------------------------------------------- |
634 // CXnNewstickerAdapter::CurrentTitleIndex |
539 // CXnNewstickerAdapter::CurrentTitleIndex |
635 // --------------------------------------------------------- |
540 // ----------------------------------------------------------------------------- |
636 // |
541 // |
637 TInt CXnNewstickerAdapter::CurrentTitleIndex() |
542 TInt CXnNewstickerAdapter::CurrentTitleIndex() |
638 { |
543 { |
639 return iControl->CurrentTitleIndex(); |
544 return iControl->CurrentTitleIndex(); |
640 } |
545 } |
641 |
546 |
642 // --------------------------------------------------------- |
547 // ----------------------------------------------------------------------------- |
643 // CXnNewstickerAdapter::Title |
548 // CXnNewstickerAdapter::Title |
644 // --------------------------------------------------------- |
549 // ----------------------------------------------------------------------------- |
645 // |
550 // |
646 const TDesC& CXnNewstickerAdapter::Title(TInt aIndex) |
551 const TDesC& CXnNewstickerAdapter::Title( TInt aIndex ) |
647 { |
552 { |
648 return iControl->Title(aIndex); |
553 return iControl->Title( aIndex ); |
649 } |
554 } |
650 |
555 |
651 // --------------------------------------------------------- |
556 // ----------------------------------------------------------------------------- |
652 // CXnNewstickerAdapter::SetSeparatorImageL |
|
653 // --------------------------------------------------------- |
|
654 // |
|
655 TInt CXnNewstickerAdapter::SetSeparatorImageL(CGulIcon* aIcon) |
|
656 { |
|
657 return iControl->SetSeparatorImageL(aIcon); |
|
658 } |
|
659 |
|
660 // --------------------------------------------------------- |
|
661 // CXnNewstickerAdapter::ClearTitles |
557 // CXnNewstickerAdapter::ClearTitles |
662 // --------------------------------------------------------- |
558 // ----------------------------------------------------------------------------- |
663 // |
559 // |
664 void CXnNewstickerAdapter::ClearTitles() |
560 void CXnNewstickerAdapter::ClearTitles() |
665 { |
561 { |
666 iControl->ClearTitles(); |
562 iControl->ClearTitles(); |
667 TRAP_IGNORE(iNode.SetDirtyL()); |
563 TRAP_IGNORE( iNode.SetDirtyL() ); |
668 } |
564 } |
669 |
565 |
670 // --------------------------------------------------------- |
566 // ----------------------------------------------------------------------------- |
671 // CXnNewstickerAdapter::AppendSvgTitleL |
|
672 // --------------------------------------------------------- |
|
673 // |
|
674 void CXnNewstickerAdapter::AppendSvgTitleL(const TDesC8& aByteData) |
|
675 { |
|
676 iControl->AppendSvgTitleL(aByteData); |
|
677 } |
|
678 |
|
679 // --------------------------------------------------------- |
|
680 // CXnNewstickerAdapter::InsertSvgTitleL |
|
681 // --------------------------------------------------------- |
|
682 // |
|
683 void CXnNewstickerAdapter::InsertSvgTitleL(const TDesC8& aByteData, TInt aIndex) |
|
684 { |
|
685 iControl->InsertSvgTitleL(aByteData, aIndex); |
|
686 } |
|
687 |
|
688 // --------------------------------------------------------- |
|
689 // CXnNewstickerAdapter::SetCallbackInterfaceL |
567 // CXnNewstickerAdapter::SetCallbackInterfaceL |
690 // --------------------------------------------------------- |
568 // ----------------------------------------------------------------------------- |
691 // |
569 // |
692 void CXnNewstickerAdapter::SetCallbackInterfaceL( |
570 void CXnNewstickerAdapter::SetCallbackInterfaceL( |
693 XnNewstickerInterface::MXnNewstickerCallbackInterface* aCallback) |
571 XnNewstickerInterface::MXnNewstickerCallbackInterface* aCallback ) |
694 { |
572 { |
695 iCallback = aCallback; |
573 iCallback = aCallback; |
696 } |
574 } |
697 |
575 |
698 // --------------------------------------------------------- |
576 // ----------------------------------------------------------------------------- |
699 // CXnNewstickerAdapter::TitleScrolled |
577 // CXnNewstickerAdapter::TitleScrolled |
700 // --------------------------------------------------------- |
578 // ----------------------------------------------------------------------------- |
701 // |
579 // |
702 void CXnNewstickerAdapter::TitleScrolled(TInt aTitleIndex) |
580 void CXnNewstickerAdapter::TitleScrolled( TInt aTitleIndex ) |
703 { |
581 { |
704 if (iCallback) |
582 if( iCallback ) |
705 { |
583 { |
706 iCallback->TitleScrolled(aTitleIndex); |
584 iCallback->TitleScrolled( aTitleIndex ); |
707 } |
585 } |
708 // if not looping, see if the last item was scrolled... |
586 } |
709 if( !iControl->ScrollLooping() && |
587 |
710 aTitleIndex == iControl->TitleCount() - 1 ) |
588 // ----------------------------------------------------------------------------- |
711 { |
|
712 iState = EScrollEnded; |
|
713 TRAP_IGNORE( StopL() ); |
|
714 DrawNow(); |
|
715 } |
|
716 } |
|
717 |
|
718 // ----------------------------------------------------------------------------- |
|
719 // CXnNewstickerAdapter::DrawBackground() |
|
720 // ----------------------------------------------------------------------------- |
|
721 // |
|
722 void CXnNewstickerAdapter::DrawBackgroundL(const TRect& aRect, CWindowGc& aGc) const |
|
723 { |
|
724 RPointerArray<CXnControlAdapter> adapters; |
|
725 |
|
726 for ( CXnNodePluginIf* node = &iNode; node; ) |
|
727 { |
|
728 CXnControlAdapter* adapter( node->Control() ); |
|
729 |
|
730 if ( adapter ) |
|
731 { |
|
732 adapters.Append( adapter ); |
|
733 } |
|
734 |
|
735 node = node->ParentL(); |
|
736 } |
|
737 |
|
738 for ( TInt i = adapters.Count() - 1; i >= 0; --i ) |
|
739 { |
|
740 adapters[i]->Draw( aRect, aGc ); |
|
741 } |
|
742 |
|
743 adapters.Reset(); |
|
744 } |
|
745 |
|
746 // ----------------------------------------------------------------------------- |
|
747 // CXnNewstickerAdapter::SetTimerToDisplaytime() |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 void CXnNewstickerAdapter::SetTimerToDisplaytime() |
|
751 { |
|
752 if( iCurrentInterval != iAlternateInterval ) |
|
753 { |
|
754 iPeriodicTimer->Cancel(); |
|
755 |
|
756 iPeriodicTimer->Start( |
|
757 TTimeIntervalMicroSeconds32( iAlternateInterval ), |
|
758 TTimeIntervalMicroSeconds32( iAlternateInterval ), |
|
759 TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) ); |
|
760 iCurrentInterval = iAlternateInterval; |
|
761 } |
|
762 } |
|
763 |
|
764 // ----------------------------------------------------------------------------- |
|
765 // CXnNewstickerAdapter::SetTimerToScrolltime() |
|
766 // ----------------------------------------------------------------------------- |
|
767 // |
|
768 void CXnNewstickerAdapter::SetTimerToScrolltime() |
|
769 { |
|
770 if( iCurrentInterval != iInterval ) |
|
771 { |
|
772 iPeriodicTimer->Cancel(); |
|
773 |
|
774 iPeriodicTimer->Start( |
|
775 TTimeIntervalMicroSeconds32( iInterval ), |
|
776 TTimeIntervalMicroSeconds32( iInterval ), |
|
777 TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) ); |
|
778 iCurrentInterval = iInterval; |
|
779 } |
|
780 } |
|
781 // --------------------------------------------------------- |
|
782 // CXnNewstickerAdapter::StartL |
589 // CXnNewstickerAdapter::StartL |
783 // --------------------------------------------------------- |
590 // ----------------------------------------------------------------------------- |
784 // |
591 // |
785 void CXnNewstickerAdapter::StartL() |
592 void CXnNewstickerAdapter::Start() |
786 { |
593 { |
787 if( iDisplay && !iPowerSaveMode ) |
594 if( IsVisible() && !iPowerSaveMode ) |
788 { |
595 { |
789 if( iControl->TitleCount() == 0 ) |
596 if( iControl->TitleCount() < 1 ) |
790 { |
597 { |
791 // Nothing to show |
598 // Nothing to show |
792 return; |
599 return; |
793 } |
600 } |
794 |
601 |
795 if( iPeriodicTimer && !iPeriodicTimer->IsActive() ) |
602 switch( iScrollBehaviour ) |
796 { |
603 { |
797 TInt startDelay( ( iState == ENotStarted ) ? iDelay : KNoDelay ); |
604 case EScroll: |
798 |
605 { |
799 // Start |
606 iMarqueeControl->EnableMarquee( ETrue ); |
800 if ( ScrollBehaviour() == CXnNewstickerAdapter::EScrollAlternate && |
607 iRedraw = ETrue; |
801 iControl->CalculateCurrentTextFitInNewstickerRect() ) |
608 } |
802 { |
609 break; |
803 iPeriodicTimer->Start( |
610 |
804 TTimeIntervalMicroSeconds32( startDelay ), |
611 case EAlternate: |
805 TTimeIntervalMicroSeconds32( iAlternateInterval ), |
612 { |
806 TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) ); |
613 iMarqueeControl->EnableMarquee( EFalse ); |
807 iCurrentInterval = iAlternateInterval; |
614 StartAlternateCounter(); |
808 } |
615 } |
809 else |
616 break; |
810 { |
617 |
811 iPeriodicTimer->Start( |
618 case EScrollAlternate: |
812 TTimeIntervalMicroSeconds32( startDelay ), |
619 { |
813 TTimeIntervalMicroSeconds32( iInterval ), |
620 iMarqueeControl->EnableMarquee( ETrue ); |
814 TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) ); |
621 StartAlternateCounter(); |
815 iCurrentInterval = iInterval; |
622 iRedraw = ETrue; |
816 } |
623 } |
817 |
624 break; |
818 iState = EText; |
625 |
819 } |
626 default: |
820 } |
627 break; |
821 } |
628 } |
822 |
629 } |
823 // --------------------------------------------------------- |
630 } |
824 // CXnNewstickerAdapter::StopL |
631 |
825 // --------------------------------------------------------- |
632 // ----------------------------------------------------------------------------- |
826 // |
633 // CXnNewstickerAdapter::Stop |
827 void CXnNewstickerAdapter::StopL() |
634 // ----------------------------------------------------------------------------- |
828 { |
635 // |
829 if( iState == EAnimation ) |
636 void CXnNewstickerAdapter::Stop() |
830 { |
637 { |
831 iSvgControl->StopL(); |
638 StopAlternateCounter(); |
832 } |
639 StopMarquee(); |
833 |
640 } |
834 // Have we already been started |
641 |
835 if( iPeriodicTimer->IsActive() ) |
642 // ----------------------------------------------------------------------------- |
836 { |
643 // CXnNewstickerAdapter::StopAlternateCounter |
837 // Yes, cancel and set the state |
644 // ----------------------------------------------------------------------------- |
838 iPeriodicTimer->Cancel(); |
645 // |
839 |
646 void CXnNewstickerAdapter::StopAlternateCounter() |
840 if ( iState == EScrollEnded ) |
647 { |
841 { |
648 if( iPeriodicTimer && iPeriodicTimer->IsActive() ) |
842 iControl->MoveToLastL(); |
649 { |
843 iControl->DrawStatic(); |
650 iPeriodicTimer->Cancel(); |
844 } |
651 } |
845 else if ( iState == EText || iState == EAnimation ) |
652 } |
846 { |
653 |
847 iState = EPaused; |
654 // ----------------------------------------------------------------------------- |
848 } |
655 // CXnNewstickerAdapter::StopMarquee |
849 } |
656 // ----------------------------------------------------------------------------- |
850 // Entering power save mode => Move to last item and draw it |
657 // |
851 if ( ( iScrollBehaviour == EAlternate || |
658 void CXnNewstickerAdapter::StopMarquee() |
852 iScrollBehaviour == EScrollAlternate ) |
659 { |
853 && iPowerSaveMode ) |
660 iMarqueeControl->Reset(); |
854 { |
661 iMarqueeControl->EnableMarquee( EFalse ); |
855 iState = EPaused; |
662 } |
856 iControl->MoveToLastL(); |
663 |
857 iControl->DrawStatic(); |
664 // ----------------------------------------------------------------------------- |
858 } |
665 // CXnNewstickerAdapter::StartCounter |
859 } |
666 // ----------------------------------------------------------------------------- |
860 |
667 // |
861 // --------------------------------------------------------- |
668 void CXnNewstickerAdapter::StartAlternateCounter() |
862 // CXnNewstickerAdapter::ShowSvgL |
669 { |
863 // --------------------------------------------------------- |
670 if( iPeriodicTimer && iPeriodicTimer->IsActive() ) |
864 // |
671 { |
865 void CXnNewstickerAdapter::ShowSvgL() |
672 iPeriodicTimer->Cancel(); |
866 { |
673 } |
867 // Get next animation from model and start it |
674 |
868 iSvgControl->StartL( iControl->CurrentSvgTitle() ); |
675 iPeriodicTimer->Start( |
869 |
676 TTimeIntervalMicroSeconds32( iAlternateDelay ), |
870 // Set the end timer |
677 TTimeIntervalMicroSeconds32( iAlternateInterval ), |
871 iState = EAnimation; |
678 TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) ); |
872 |
679 } |
873 iPeriodicTimer->Cancel(); |
680 |
874 |
681 // ----------------------------------------------------------------------------- |
875 iPeriodicTimer->Start( |
|
876 TTimeIntervalMicroSeconds32( iAnimationTime ), |
|
877 TTimeIntervalMicroSeconds32( iAnimationTime ), |
|
878 TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) ); |
|
879 iCurrentInterval = iAnimationTime; |
|
880 } |
|
881 |
|
882 // --------------------------------------------------------- |
|
883 // CXnNewstickerAdapter::PeriodicEventL |
682 // CXnNewstickerAdapter::PeriodicEventL |
884 // --------------------------------------------------------- |
683 // ----------------------------------------------------------------------------- |
885 // |
684 // |
886 TInt CXnNewstickerAdapter::PeriodicEventL( TAny* aPtr ) |
685 TInt CXnNewstickerAdapter::PeriodicEventL( TAny* aPtr ) |
887 { |
686 { |
888 CXnNewstickerAdapter* self = static_cast< CXnNewstickerAdapter* >( aPtr ); |
687 CXnNewstickerAdapter* self = static_cast< CXnNewstickerAdapter* >( aPtr ); |
889 |
688 self->DoScroll(); |
890 if( self->iState == EText ) |
689 |
891 { |
|
892 // Do the text scroll |
|
893 self->iControl->DoScrollL(); |
|
894 } |
|
895 else if( self->iState == EAnimation ) |
|
896 { |
|
897 self->iSvgControl->StopL(); |
|
898 self->TitleScrolled( self->iControl->CurrentTitleIndex() ); |
|
899 // Animation scroll has been ended, start the next scroll |
|
900 self->iState = ENotStarted; |
|
901 self->iPeriodicTimer->Cancel(); |
|
902 self->StartL(); |
|
903 // Do the first draw |
|
904 self->iControl->SetBeginningState(); |
|
905 self->iControl->DoScrollL(); |
|
906 } |
|
907 |
|
908 return KErrNone; |
690 return KErrNone; |
909 } |
691 } |
910 |
692 |
911 void CXnNewstickerAdapter::RestartL() |
693 // ----------------------------------------------------------------------------- |
912 { |
694 // CXnNewstickerAdapter::MakeVisible() |
913 if ( iPowerSaveMode ) |
695 // ----------------------------------------------------------------------------- |
914 { |
696 // |
915 return; |
697 void CXnNewstickerAdapter::MakeVisible( TBool aVisible ) |
916 } |
698 { |
917 // Restart |
699 if( aVisible ) |
918 iState = ENotStarted; |
700 { |
919 iPeriodicTimer->Cancel(); |
701 Start(); |
920 |
702 } |
921 iControl->MoveToFirstL(); |
703 else |
922 StartL(); |
704 { |
923 |
705 Stop(); |
924 // Do the first draw |
706 } |
925 iControl->SetBeginningState(); |
707 |
926 } |
708 CCoeControl::MakeVisible( aVisible ); |
927 // --------------------------------------------------------- |
709 } |
|
710 |
|
711 // ----------------------------------------------------------------------------- |
928 // CXnNewstickerAdapter::SizeChanged() |
712 // CXnNewstickerAdapter::SizeChanged() |
929 // --------------------------------------------------------- |
713 // ----------------------------------------------------------------------------- |
930 // |
714 // |
931 void CXnNewstickerAdapter::SizeChanged() |
715 void CXnNewstickerAdapter::SizeChanged() |
932 { |
716 { |
933 CXnControlAdapter::SizeChanged(); |
717 CXnControlAdapter::SizeChanged(); |
934 TRAP_IGNORE( SizeChangedL() ); |
718 iMarqueeControl->SetExtent( iNode.Rect().iTl, iNode.Rect().Size() ); |
935 } |
719 |
936 |
720 iTextBaseline = iNode.Rect().Height() / 2 + iFont->AscentInPixels() / 2; |
937 // --------------------------------------------------------- |
721 } |
938 // CXnNewstickerAdapter::SizeChangedL() |
722 |
939 // --------------------------------------------------------- |
723 // ----------------------------------------------------------------------------- |
940 // |
724 // CXnNewstickerAdapter::CountComponentControls() const |
941 void CXnNewstickerAdapter::SizeChangedL() |
725 // ----------------------------------------------------------------------------- |
942 { |
726 // |
943 UpdateDoubleBufferL(); |
727 TInt CXnNewstickerAdapter::CountComponentControls() const |
944 |
728 { |
945 TRect rect( Rect() ); |
729 return 1; // return nbr of controls inside this container |
|
730 } |
|
731 |
|
732 // ----------------------------------------------------------------------------- |
|
733 // CXnNewstickerAdapter::ComponentControl(TInt aIndex) const |
|
734 // ----------------------------------------------------------------------------- |
|
735 // |
|
736 CCoeControl* CXnNewstickerAdapter::ComponentControl( TInt aIndex ) const |
|
737 { |
|
738 switch ( aIndex ) |
|
739 { |
|
740 case 0: |
|
741 return iMarqueeControl; |
946 |
742 |
947 iControl->SetNewstickerRect( rect ); |
743 default: |
948 iSvgControl->SetSvgRectL( rect, *SystemGc().Device() ); |
744 return NULL; |
949 } |
745 } |
950 |
746 } |
951 // ----------------------------------------------------------------------------- |
747 |
952 // CXnNewstickerAdapter::HandlePointerEventL |
|
953 // ----------------------------------------------------------------------------- |
|
954 // |
|
955 void CXnNewstickerAdapter::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
956 { |
|
957 if ( AknLayoutUtils::PenEnabled() ) |
|
958 { |
|
959 CXnControlAdapter::HandlePointerEventL(aPointerEvent); |
|
960 } |
|
961 } |
|
962 // ----------------------------------------------------------------------------- |
748 // ----------------------------------------------------------------------------- |
963 // CXnNewstickerAdapter::DoHandlePropertyChangeL |
749 // CXnNewstickerAdapter::DoHandlePropertyChangeL |
964 // ----------------------------------------------------------------------------- |
750 // ----------------------------------------------------------------------------- |
965 // |
751 // |
966 void CXnNewstickerAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty ) |
752 void CXnNewstickerAdapter::DoHandlePropertyChangeL( CXnProperty* /*aProperty*/ ) |
967 { |
753 { |
968 SetTextPropertiesL(); |
754 SetTextPropertiesL(); |
969 SetNewstickerPropertiesL(); |
755 SetNewstickerPropertiesL(); |
970 //New code to check do we need Start or Stop Newsticker |
|
971 if( aProperty ) |
|
972 { |
|
973 const TDesC8& name( aProperty->Property()->Name() ); |
|
974 |
|
975 if( name == XnPropertyNames::style::common::KDisplay || |
|
976 name == XnPropertyNames::style::common::KVisibility ) |
|
977 { |
|
978 if( CheckDisplayL( iNode ) ) |
|
979 { |
|
980 StartL(); |
|
981 } |
|
982 else |
|
983 { |
|
984 StopL(); |
|
985 } |
|
986 } |
|
987 } |
|
988 } |
|
989 |
|
990 // ----------------------------------------------------------------------------- |
|
991 // CXnNewstickerAdapter::FocusChanged |
|
992 // ----------------------------------------------------------------------------- |
|
993 // |
|
994 void CXnNewstickerAdapter::FocusChanged(TDrawNow /*aDrawNow*/) |
|
995 { |
|
996 } |
756 } |
997 |
757 |
998 // ----------------------------------------------------------------------------- |
758 // ----------------------------------------------------------------------------- |
999 // CXnNewstickerAdapter::SkinChanged |
759 // CXnNewstickerAdapter::SkinChanged |
1000 // ----------------------------------------------------------------------------- |
760 // ----------------------------------------------------------------------------- |
1003 { |
763 { |
1004 CXnControlAdapter::SkinChanged(); |
764 CXnControlAdapter::SkinChanged(); |
1005 TRAP_IGNORE( SetTextPropertiesL() ); |
765 TRAP_IGNORE( SetTextPropertiesL() ); |
1006 } |
766 } |
1007 |
767 |
1008 void CXnNewstickerAdapter::ReportNewstickerEventL(const TDesC8& aEventName) |
768 // ----------------------------------------------------------------------------- |
|
769 // CXnNewstickerAdapter::ReportNewstickerEventL |
|
770 // ----------------------------------------------------------------------------- |
|
771 // |
|
772 void CXnNewstickerAdapter::ReportNewstickerEvent( const TDesC8& aEventName ) |
1009 { |
773 { |
1010 TBuf8<8>index(KNullDesC8); |
774 TBuf8<KByteLength>index( KNullDesC8 ); |
1011 index.Num(CurrentTitleIndex()); |
775 index.Num( CurrentTitleIndex() ); |
1012 |
776 |
1013 iNode.ReportTriggerEventL(aEventName, |
777 TRAP_IGNORE( iNode.ReportTriggerEventL( aEventName, |
1014 XnPropertyNames::action::trigger::name::KTitleIndex, index); |
778 XnPropertyNames::action::trigger::name::KTitleIndex, index ); ) |
1015 } |
|
1016 // ----------------------------------------------------------------------------- |
|
1017 // CXnNewstickerAdapter::OfferKeyEventL |
|
1018 // ----------------------------------------------------------------------------- |
|
1019 // |
|
1020 TKeyResponse CXnNewstickerAdapter::OfferKeyEventL( |
|
1021 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
1022 { |
|
1023 TKeyResponse resp = EKeyWasNotConsumed; |
|
1024 TBool restart = EFalse; |
|
1025 |
|
1026 CXnControlAdapter::OfferKeyEventL(aKeyEvent, aType); |
|
1027 |
|
1028 if(aType == EEventKey) |
|
1029 { |
|
1030 if (aKeyEvent.iScanCode == EStdKeyRightArrow) |
|
1031 { |
|
1032 restart = ETrue; |
|
1033 if(iControl->IsWestern()) |
|
1034 { |
|
1035 iControl->MoveToNextL(); |
|
1036 } |
|
1037 else |
|
1038 { |
|
1039 iControl->MoveToPrevL(); |
|
1040 } |
|
1041 StopL(); |
|
1042 } |
|
1043 else if (aKeyEvent.iScanCode == EStdKeyLeftArrow) |
|
1044 { |
|
1045 restart = ETrue; |
|
1046 if(iControl->IsWestern()) |
|
1047 { |
|
1048 iControl->MoveToPrevL(); |
|
1049 } |
|
1050 else |
|
1051 { |
|
1052 iControl->MoveToNextL(); |
|
1053 } |
|
1054 StopL(); |
|
1055 } |
|
1056 } |
|
1057 if(aType == EEventKeyUp) |
|
1058 { |
|
1059 if (aKeyEvent.iScanCode == EStdKeyDevice3) // rocker |
|
1060 { |
|
1061 restart = ETrue; |
|
1062 StopL(); |
|
1063 iControl->MoveToCurrent(); |
|
1064 } |
|
1065 } |
|
1066 |
|
1067 if( restart ) |
|
1068 { |
|
1069 // Restart and do the first draw |
|
1070 iState = ENotStarted; |
|
1071 StartL(); |
|
1072 iControl->DoScrollL(); |
|
1073 } |
|
1074 |
|
1075 return resp; |
|
1076 } |
779 } |
1077 |
780 |
1078 // ----------------------------------------------------------------------------- |
781 // ----------------------------------------------------------------------------- |
1079 // CXnNewstickerAdapter::Draw |
782 // CXnNewstickerAdapter::Draw |
1080 // Draws the text component |
783 // Draws the text component |
1081 // ----------------------------------------------------------------------------- |
784 // ----------------------------------------------------------------------------- |
1082 void CXnNewstickerAdapter::Draw(const TRect& aRect) const |
785 void CXnNewstickerAdapter::Draw( const TRect& aRect ) const |
1083 { |
786 { |
1084 CXnControlAdapter::Draw( aRect ); |
787 const_cast<CXnNewstickerAdapter*>(this)->DrawText( iControl->SelectTitle(), aRect ); |
1085 |
|
1086 TRAP_IGNORE( UpdateBackgroundL() ); |
|
1087 // In powersave-/editmode only draw the last title. |
|
1088 if ( iScrollBehaviour == EAlternate && iPowerSaveMode ) |
|
1089 { |
|
1090 iControl->DrawStatic(); |
|
1091 |
|
1092 // Blit double buffer |
|
1093 SystemGc().BitBlt( Rect().iTl, iDrawingBuffer ); |
|
1094 } |
|
1095 else if( iState == EText || iState == EPaused && |
|
1096 iControl->CurrentTitleIndex() >= 0 ) |
|
1097 { |
|
1098 iControl->Draw(); |
|
1099 |
|
1100 // Blit double buffer |
|
1101 SystemGc().BitBlt( Rect().iTl, iDrawingBuffer ); |
|
1102 } |
|
1103 else if( iState == EAnimation ) |
|
1104 { |
|
1105 iSvgControl->Draw(); |
|
1106 |
|
1107 // Blit double buffer |
|
1108 SystemGc().BitBlt( Rect().iTl, iDrawingBuffer ); |
|
1109 } |
|
1110 else if( iState == EScrollEnded ) |
|
1111 { |
|
1112 iControl->DrawStatic(); |
|
1113 SystemGc().BitBlt( Rect().iTl, iDrawingBuffer ); |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 // ----------------------------------------------------------------------------- |
|
1118 // CXnNewstickerAdapter::UpdateDoubleBufferL |
|
1119 // ----------------------------------------------------------------------------- |
|
1120 // |
|
1121 void CXnNewstickerAdapter::UpdateDoubleBufferL() |
|
1122 { |
|
1123 TDisplayMode displayMode( SystemGc().Device()->DisplayMode() ); |
|
1124 |
|
1125 // Create double buffer |
|
1126 if( iDrawingBuffer ) |
|
1127 { |
|
1128 delete iDrawingBuffer; |
|
1129 iDrawingBuffer = NULL; |
|
1130 delete iBufferDevice; |
|
1131 iBufferDevice = NULL; |
|
1132 delete iBufferGc; |
|
1133 iBufferGc = NULL; |
|
1134 } |
|
1135 |
|
1136 iDrawingBuffer = new ( ELeave ) CFbsBitmap(); |
|
1137 iDrawingBuffer->Create( iNode.Rect().Size(), displayMode ); |
|
1138 iBufferDevice = CFbsBitmapDevice::NewL( iDrawingBuffer ); |
|
1139 iBufferDevice->CreateBitmapContext( iBufferGc ); |
|
1140 iBufferGc->UseFont( iControl->Font() ); |
|
1141 iBufferGc->SetPenColor( iControl->TextColor() ); |
|
1142 iBufferGc->SetStrikethroughStyle( iControl->TextStrikethroughStyle() ); |
|
1143 iBufferGc->SetUnderlineStyle( iControl->TextUnderlineStyle() ); |
|
1144 } |
|
1145 |
|
1146 // ----------------------------------------------------------------------------- |
|
1147 // CXnNewstickerAdapter::UpdateBackgroundL |
|
1148 // ----------------------------------------------------------------------------- |
|
1149 // |
|
1150 void CXnNewstickerAdapter::UpdateBackgroundL() const |
|
1151 { |
|
1152 TDisplayMode displayMode( SystemGc().Device()->DisplayMode() ); |
|
1153 |
|
1154 // Create "screenshot" from the background appearance |
|
1155 if( iBackgroundBitmap ) |
|
1156 { |
|
1157 delete iBackgroundBitmap; |
|
1158 iBackgroundBitmap = NULL; |
|
1159 } |
|
1160 |
|
1161 iBackgroundBitmap = new ( ELeave ) CFbsBitmap(); |
|
1162 iBackgroundBitmap->Create( iNode.Rect().Size(), displayMode ); |
|
1163 |
|
1164 CFbsBitmap* tmpBitmap = new ( ELeave ) CFbsBitmap(); |
|
1165 CleanupStack::PushL( tmpBitmap ); |
|
1166 |
|
1167 CWsScreenDevice* scrDevice = static_cast< CWsScreenDevice* >( SystemGc().Device() ); |
|
1168 |
|
1169 TSize tmpSize( scrDevice->SizeInPixels() ); |
|
1170 |
|
1171 tmpBitmap->Create( tmpSize, displayMode ); |
|
1172 |
|
1173 CFbsBitmapDevice* tmpDevice = CFbsBitmapDevice::NewL( tmpBitmap ); |
|
1174 CleanupStack::PushL( tmpDevice ); |
|
1175 |
|
1176 CBitmapContext* bc( NULL ); |
|
1177 |
|
1178 tmpDevice->CreateBitmapContext( bc ); |
|
1179 CleanupStack::PushL( bc ); |
|
1180 |
|
1181 DrawBackgroundL( iNode.Rect(), reinterpret_cast< CWindowGc& >( *bc ) ); |
|
1182 |
|
1183 CopyBitmapData( *iBackgroundBitmap, *tmpBitmap, iNode.Rect().iTl ); |
|
1184 |
|
1185 CleanupStack::PopAndDestroy( 3 ); |
|
1186 } |
788 } |
1187 |
789 |
1188 // ----------------------------------------------------------------------------- |
790 // ----------------------------------------------------------------------------- |
1189 // CXnNewstickerAdapter::DoEnterPowerSaveModeL |
791 // CXnNewstickerAdapter::DoEnterPowerSaveModeL |
1190 // Enter power save mode |
792 // Enter power save mode |
1191 // ----------------------------------------------------------------------------- |
793 // ----------------------------------------------------------------------------- |
1192 void CXnNewstickerAdapter::DoEnterPowerSaveModeL(TModeEvent /*aEvent*/) |
794 void CXnNewstickerAdapter::DoEnterPowerSaveModeL( TModeEvent /*aEvent*/ ) |
1193 { |
795 { |
1194 iDisplay = EFalse; |
|
1195 iPowerSaveMode = ETrue; |
796 iPowerSaveMode = ETrue; |
1196 |
797 Stop(); |
1197 StopL(); |
|
1198 } |
798 } |
1199 |
799 |
1200 // ----------------------------------------------------------------------------- |
800 // ----------------------------------------------------------------------------- |
1201 // CXnNewstickerAdapter::DoExitPowerSaveModeL |
801 // CXnNewstickerAdapter::DoExitPowerSaveModeL |
1202 // Exit power save mode |
802 // Exit power save mode |
1203 // ----------------------------------------------------------------------------- |
803 // ----------------------------------------------------------------------------- |
1204 void CXnNewstickerAdapter::DoExitPowerSaveModeL(TModeEvent /*aEvent*/) |
804 void CXnNewstickerAdapter::DoExitPowerSaveModeL( TModeEvent /*aEvent*/ ) |
1205 { |
805 { |
1206 iPowerSaveMode = EFalse; |
806 iPowerSaveMode = EFalse; |
|
807 |
|
808 if( IsVisible() ) |
|
809 { |
|
810 Start(); |
|
811 } |
|
812 } |
|
813 |
|
814 // ----------------------------------------------------------------------------- |
|
815 // CXnNewstickerAdapter::DrawText |
|
816 // Text drawing function is selected by scrolling behaviour |
|
817 // ----------------------------------------------------------------------------- |
|
818 void CXnNewstickerAdapter::DrawText( const TDesC& aText, const TRect& aRect ) |
|
819 { |
|
820 CWindowGc& gc = SystemGc(); |
|
821 |
|
822 TRect rect = iNode.Rect(); |
|
823 |
|
824 CXnControlAdapter::Draw( aRect ); |
|
825 |
|
826 gc.SetPenColor( iTextColor ); |
|
827 gc.UseFont( iFont ); |
|
828 gc.SetUnderlineStyle( iUnderlining ); |
|
829 gc.SetStrikethroughStyle( iStrikethrough ); |
|
830 |
|
831 TInt textWidth = iFont->TextWidthInPixels( aText ); |
|
832 TInt rectWidth = rect.Width(); |
|
833 |
|
834 switch( iScrollBehaviour ) |
|
835 { |
|
836 case EScroll: |
|
837 case EScrollAlternate: |
|
838 { |
|
839 if( !iRedraw || textWidth < rectWidth ) |
|
840 { |
|
841 iMarqueeControl->Stop(); |
|
842 DrawStaticText( gc, aText ); |
|
843 } |
|
844 else |
|
845 { |
|
846 iMarqueeControl->Start(); |
|
847 TBool isLast = DrawMarqueeText( gc, aText ); |
|
848 |
|
849 if( isLast ) |
|
850 { |
|
851 if( !iScrollLooping ) |
|
852 { |
|
853 iRedraw = EFalse; |
|
854 } |
|
855 |
|
856 iMarqueeControl->Reset(); |
|
857 StartAlternateCounter(); |
|
858 } |
|
859 } |
|
860 } |
|
861 break; |
1207 |
862 |
1208 if( CheckDisplayL( iNode ) ) |
863 case EAlternate: |
1209 { |
864 { |
1210 RestartL(); |
865 DrawStaticText( gc, aText ); |
1211 |
866 } |
1212 if( iDrawingBuffer ) |
867 break; |
1213 { |
868 |
1214 DrawNow(); |
869 default: |
1215 } |
870 break; |
1216 } |
871 } |
1217 } |
872 } |
1218 |
873 |
1219 // ----------------------------------------------------------------------------- |
874 // ----------------------------------------------------------------------------- |
1220 // CXnNewstickerAdapter::DrawNow |
875 // CXnNewstickerAdapter::RedrawCallback |
1221 // Draw |
876 // Callback function for marquee control |
1222 // ----------------------------------------------------------------------------- |
877 // ----------------------------------------------------------------------------- |
1223 void CXnNewstickerAdapter::DrawNow() const |
878 // |
1224 { |
879 TInt CXnNewstickerAdapter::RedrawCallback( TAny* aPtr ) |
1225 TBool parentDrawn = EFalse; |
880 { |
1226 TRAP_IGNORE( parentDrawn = DrawFocusableParentL() ); |
881 CXnNewstickerAdapter* self = static_cast<CXnNewstickerAdapter*>( aPtr ); |
1227 if ( !parentDrawn ) |
882 self->DrawNow(); |
1228 { |
883 |
1229 CCoeControl::DrawNow(); |
884 return self->Redraw(); |
1230 } |
885 |
1231 } |
886 } |
1232 |
887 |
1233 // ----------------------------------------------------------------------------- |
888 // ----------------------------------------------------------------------------- |
1234 // CXnNewstickerAdapter::DrawFocusableParentL |
889 // CXnNewstickerAdapter::DoScroll |
1235 // Draws focusable parent |
890 // Scrolls alternative text. Function is called by periodic timer |
1236 // ----------------------------------------------------------------------------- |
891 // ----------------------------------------------------------------------------- |
1237 TBool CXnNewstickerAdapter::DrawFocusableParentL() const |
892 // |
1238 { |
893 void CXnNewstickerAdapter::DoScroll() |
1239 TBool parentDrawn = EFalse; |
894 { |
1240 |
895 ReportNewstickerEvent( XnPropertyNames::action::trigger::name::KTitleScrolled ); |
1241 if ( !iNode.IsFocusedState() ) |
896 |
1242 { |
897 if( iControl->SetCurrentTitle() ) |
1243 // node is not focusable, find focusable and focused parent |
898 { |
1244 CXnNodePluginIf* parent = iNode.ParentL(); |
899 // stop alternate scrolling if current index is last |
1245 while ( parent && !parent->IsFocusedState() ) |
900 StopAlternateCounter(); |
1246 { |
901 } |
1247 parent = parent->ParentL(); |
902 |
1248 } |
903 DrawNow(); |
1249 |
904 |
1250 if (parent) |
905 ReportNewstickerEvent( XnPropertyNames::action::trigger::name::KTitleToScroll ); |
1251 { |
906 } |
1252 // focusable parent found, draw it |
907 |
1253 parent->Control()->DrawNow(); |
908 // ----------------------------------------------------------------------------- |
1254 parentDrawn = ETrue; |
909 // CXnNewstickerAdapter::DrawStatic |
1255 } |
910 // Draws text directly to screen when scrolling is not needed |
1256 } |
911 // ----------------------------------------------------------------------------- |
1257 |
912 // |
1258 return parentDrawn; |
913 void CXnNewstickerAdapter::DrawStaticText( CWindowGc& aGc, const TDesC& aText ) const |
1259 } |
914 { |
|
915 HBufC* text = HBufC::New( aText.Length() + KAknBidiExtraSpacePerLine ); |
|
916 |
|
917 if( text ) |
|
918 { |
|
919 TRect rect = iNode.Rect(); |
|
920 TInt maxLength = rect.Width(); |
|
921 TPtr ptr = text->Des(); |
|
922 AknBidiTextUtils::ConvertToVisualAndClip( |
|
923 aText, ptr, *iFont, maxLength, maxLength ); |
|
924 |
|
925 aGc.DrawText( *text, rect, iTextBaseline, |
|
926 ( CGraphicsContext::TTextAlign )iTextAlignment ); |
|
927 |
|
928 delete text; |
|
929 } |
|
930 } |
|
931 |
|
932 // ----------------------------------------------------------------------------- |
|
933 // CXnNewstickerAdapter::DrawScrolling |
|
934 // Draws scrolling text to screen via marquee control |
|
935 // ----------------------------------------------------------------------------- |
|
936 // |
|
937 TBool CXnNewstickerAdapter::DrawMarqueeText( CWindowGc& aGc, const TDesC& aText ) const |
|
938 { |
|
939 TRect rect = iNode.Rect(); |
|
940 |
|
941 // returns true when all loops have been executed |
|
942 return iMarqueeControl->DrawText( aGc, rect, aText, iTextBaseline, |
|
943 ( CGraphicsContext::TTextAlign )iTextAlignment, *iFont ); |
|
944 } |
|
945 |
1260 |
946 |
1261 // End of file |
947 // End of file |