uifw/AvKon/src/AknCharMap.cpp
branchRCL_3
changeset 5 aabf2c525e0f
parent 3 8ca85d2f0db7
child 6 9f56a4e1b8ab
equal deleted inserted replaced
3:8ca85d2f0db7 5:aabf2c525e0f
   100 const TInt KAreaIdMain   = 1;
   100 const TInt KAreaIdMain   = 1;
   101 const TInt KAreaIdTail   = 2;
   101 const TInt KAreaIdTail   = 2;
   102 
   102 
   103 
   103 
   104 // ----------------------------------------------------------------------------
   104 // ----------------------------------------------------------------------------
   105 // TEmotionUtils definition
       
   106 // ----------------------------------------------------------------------------
       
   107 //
       
   108 
       
   109 const TUint KEmotionCharBase = 0xf880;
       
   110 
       
   111 class TEmotionUtils
       
   112     {
       
   113 public:
       
   114     static TBool IsEmotionChar(TChar aChar);
       
   115     static TChar EmotionChar(TInt aId);
       
   116     static TInt EmotionId(TChar aChar);
       
   117     static TChar EmotionSwitchToSmileyChar();
       
   118     static TChar EmotionSwitchToSctChar();
       
   119     };
       
   120 
       
   121 TBool TEmotionUtils::IsEmotionChar(TChar aChar)
       
   122     {
       
   123     return (aChar >= KEmotionCharBase);
       
   124     }
       
   125 
       
   126 TChar TEmotionUtils::EmotionChar(TInt aId)
       
   127     {
       
   128     return (KEmotionCharBase + aId);
       
   129     }
       
   130 
       
   131 TInt TEmotionUtils::EmotionId(TChar aChar)
       
   132     {
       
   133     return (TInt)(aChar - KEmotionCharBase);
       
   134     }
       
   135 
       
   136 TChar TEmotionUtils::EmotionSwitchToSmileyChar()
       
   137     {
       
   138     return KEmotionCharBase + CSmileyModel::EIconSwitchToSmiley;
       
   139     }
       
   140 
       
   141 TChar TEmotionUtils::EmotionSwitchToSctChar()
       
   142     {
       
   143     return KEmotionCharBase + CSmileyModel::EIconSwitchToSct;
       
   144     }
       
   145 
       
   146 
       
   147 // ----------------------------------------------------------------------------
       
   148 // CAknCharMapHistory definition
   105 // CAknCharMapHistory definition
   149 // ----------------------------------------------------------------------------
   106 // ----------------------------------------------------------------------------
   150 //
   107 //
   151 /**
   108 /**
   152  *  Recent data management when a Special characters or a Pictograph characters 
   109  *  Recent data management when a Special characters or a Pictograph characters 
   217         * Insert a character which select on SCT/Picto.
   174         * Insert a character which select on SCT/Picto.
   218         * @since 2.8
   175         * @since 2.8
   219         * @param aHistoryType The kind of charctor map, refer to THistoryType
   176         * @param aHistoryType The kind of charctor map, refer to THistoryType
   220         * @param aChar    Insert a character
   177         * @param aChar    Insert a character
   221         */
   178         */
   222         void InsertChar(THistoryType aHistoryType, const TChar aChar);
   179         void InsertChar(THistoryType aHistoryType, const TChar aChar, TBool aIsEmotion);
   223 
   180 
   224     private:
   181     private:
   225         /**
   182         /**
   226         * C++ default constructor.
   183         * C++ default constructor.
   227         * @since 2.8
   184         * @since 2.8
   475 //
   432 //
   476 NONSHARABLE_CLASS(CAknCharMapExtension) : 
   433 NONSHARABLE_CLASS(CAknCharMapExtension) : 
   477     public CBase,
   434     public CBase,
   478     public MObjectProvider,
   435     public MObjectProvider,
   479     public MAknSctFocusHandler,
   436     public MAknSctFocusHandler,
   480     public MSmileyIconObserver
   437     public MAknSmileyObserver
   481     {
   438     {
   482     public:
   439     public:
   483         CAknCharMapExtension();
   440         CAknCharMapExtension();
   484         ~CAknCharMapExtension();
   441         ~CAknCharMapExtension();
   485 
   442 
   497     protected:
   454     protected:
   498         TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
   455         TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
   499         MObjectProvider* MopNext();
   456         MObjectProvider* MopNext();
   500         
   457         
   501     private: // from MSmileyIconObserver
   458     private: // from MSmileyIconObserver
   502         virtual void ThumbnailLoaded(CSmileyIcon* aSmileyIcon);
   459         virtual void SmileyStillImageLoaded(CAknSmileyIcon* aSmileyIcon);
   503         virtual void AnimationChanged(CSmileyIcon* aSmileyIcon);
   460         virtual void SmileyAnimationChanged(CAknSmileyIcon* aSmileyIcon);
   504         
   461         
   505     public:
   462     public:
   506         TBool IsEmotionEnabled() const;
   463         TBool IsEmotionEnabled() const;
   507         TBool IsShowingEmotion() const;
   464         TBool IsShowingEmotion() const;
       
   465         void SwitchEmotionVisibilityL();
   508         TBool NeedEmotionSwitchIcon() const;
   466         TBool NeedEmotionSwitchIcon() const;
   509         HBufC* ReadEmotionHBufCL();
   467         HBufC* ReadEmotionHBufCL();
   510         void LoadEmotionTumbnails(const TDesC& aSctChars);
   468         void LoadEmotionTumbnails(const TDesC& aChars);
   511         void SetEmotionSize(const TSize& aSize);
   469         void SetEmotionSize(const TSize& aSize);
   512 
   470         TBool IsEmotionChar(TChar aChar);
   513         CSmileyIcon* EmotionIcon(TChar aEmotionChar);
   471         TChar SwitchToSctChar();
   514         TBool DrawEmotion(CWindowGc& aGc, const TRect& aRect, TChar aEmotionChar);
   472         TChar SwitchToEmotionChar();
       
   473         CAknSmileyIcon* EmotionIcon(TChar aChar);
       
   474         const TDesC& EmotionText(TChar aChar);
       
   475         TBool DrawEmotion(CWindowGc& aGc, const TRect& aRect, CAknSmileyIcon* aSmileyIcon);
   515         void HandleFocusStatusChanged(TChar aChar, TBool aIsFocused);
   476         void HandleFocusStatusChanged(TChar aChar, TBool aIsFocused);
   516 
   477 
   517     public: // data
   478     public: // data
   518         MCoeControlObserver *iObserver;
   479         MCoeControlObserver *iObserver;
   519         HBufC* iCharsQwerty;
   480         HBufC* iCharsQwerty;
   550         // Indicates whether menu sct is highlighted or not.
   511         // Indicates whether menu sct is highlighted or not.
   551         TBool iMenuSctHighlighted;
   512         TBool iMenuSctHighlighted;
   552         
   513         
   553     public: // for Emotion
   514     public: // for Emotion
   554         HBufC* iCharsSmiley;
   515         HBufC* iCharsSmiley;
   555         CSmileyModel iSmileyModel;
   516         CSmileyModel* iSmileyModel;
   556         TChar iLastFocusedSmileyChar;
   517         TChar iLastFocusedSmileyChar;
   557         TBool iIsShowingEmotion;
   518         TBool iIsShowingEmotion;
   558         TBool iIsEnableEmotion;
   519         TBool iIsEnableEmotion;
   559 
   520 
   560     public: // Single click        
   521     public: // Single click        
   565 
   526 
   566        /**
   527        /**
   567         * Is highlight visible
   528         * Is highlight visible
   568         */
   529         */
   569         TBool iHighlightVisible;         
   530         TBool iHighlightVisible;         
       
   531 
       
   532         /**
       
   533         * Is keyboard event
       
   534         */
       
   535         TBool iKeyBrdEvent;
   570     };
   536     };
   571 
   537 
   572 // ----------------------------------------------------------------------------
   538 // ----------------------------------------------------------------------------
   573 // Navi button class implementation
   539 // Navi button class implementation
   574 // ----------------------------------------------------------------------------
   540 // ----------------------------------------------------------------------------
   776 
   742 
   777 void CAknSctTableNavi::TableExitL()
   743 void CAknSctTableNavi::TableExitL()
   778     {
   744     {
   779     delete iIdle;
   745     delete iIdle;
   780     iIdle = 0;
   746     iIdle = 0;
   781     iIdle = CIdle::NewL(CActive::EPriorityIdle);
   747     iIdle = CIdle::NewL(CActive::EPriorityStandard);
   782     iIdle->Start(TCallBack(DoTableExit, this));
   748     iIdle->Start(TCallBack(DoTableExit, this));
   783     }
   749     }
   784 
   750 
   785 TInt CAknSctTableNavi::DoTableExit(TAny* aThis)
   751 TInt CAknSctTableNavi::DoTableExit(TAny* aThis)
   786     {
   752     {
  2454 
  2420 
  2455 // ----------------------------------------------------------------------------
  2421 // ----------------------------------------------------------------------------
  2456 // Extension class implementation
  2422 // Extension class implementation
  2457 // ----------------------------------------------------------------------------
  2423 // ----------------------------------------------------------------------------
  2458 //
  2424 //
  2459 CAknCharMapExtension::CAknCharMapExtension() : iSmileyModel(this)
  2425 CAknCharMapExtension::CAknCharMapExtension() : iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() )
  2460 ,iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() )
       
  2461     {
  2426     {
  2462     iObserver = NULL;
  2427     iObserver = NULL;
  2463     iPictographsBuffer = FeatureManager::FeatureSupported(KFeatureIdJapanesePicto);
  2428     iPictographsBuffer = FeatureManager::FeatureSupported(KFeatureIdJapanesePicto);
  2464     iPictographsBufferGrouping = FeatureManager::FeatureSupported(KFeatureIdJapanesePictographsGrouping);
  2429     iPictographsBufferGrouping = FeatureManager::FeatureSupported(KFeatureIdJapanesePictographsGrouping);
  2465     iKineticScrolling = CAknPhysics::FeatureEnabled();
  2430     iKineticScrolling = CAknPhysics::FeatureEnabled();
  2466 
  2431 
  2467     TRAP_IGNORE(iSmileyModel.LoadResourceL());
  2432     TRAP_IGNORE(iSmileyModel = new (ELeave) CSmileyModel(this));
       
  2433     TRAP_IGNORE(iSmileyModel->LoadResourceL());
  2468     }
  2434     }
  2469 
  2435 
  2470 TTypeUid::Ptr CAknCharMapExtension::MopSupplyObject(TTypeUid aId)
  2436 TTypeUid::Ptr CAknCharMapExtension::MopSupplyObject(TTypeUid aId)
  2471     {
  2437     {
  2472     return MAknsControlContext::SupplyMopObject(aId, iBgContext );
  2438     return MAknsControlContext::SupplyMopObject(aId, iBgContext );
  2477     return iCharMap;
  2443     return iCharMap;
  2478     }
  2444     }
  2479 
  2445 
  2480 CAknCharMapExtension::~CAknCharMapExtension()
  2446 CAknCharMapExtension::~CAknCharMapExtension()
  2481     {
  2447     {
       
  2448     delete iSmileyModel;
       
  2449     
  2482     delete iCharsSmiley;
  2450     delete iCharsSmiley;
  2483     delete iCharsQwerty;
  2451     delete iCharsQwerty;
  2484     delete iBgContext;
  2452     delete iBgContext;
  2485 
  2453 
  2486     delete iRadioButton;
  2454     delete iRadioButton;
  2511 TBool CAknCharMapExtension::EnterControl(TInt aX, TInt aY)
  2479 TBool CAknCharMapExtension::EnterControl(TInt aX, TInt aY)
  2512     {
  2480     {
  2513     if(iCharMapProxy->EnterControl(aX, aY))
  2481     if(iCharMapProxy->EnterControl(aX, aY))
  2514         {
  2482         {
  2515         iFocusHandler = this;
  2483         iFocusHandler = this;
  2516         iCharMapProxy->HandleFocusStatusChanged();
       
  2517         return ETrue;
  2484         return ETrue;
  2518         }
  2485         }
  2519     else
  2486     else
  2520         {
  2487         {
  2521         return EFalse;
  2488         return EFalse;
  2536 TBool CAknCharMapExtension::ExitWithKey(TInt /*aKeycode*/)
  2503 TBool CAknCharMapExtension::ExitWithKey(TInt /*aKeycode*/)
  2537     {
  2504     {
  2538     return ETrue;
  2505     return ETrue;
  2539     }
  2506     }
  2540 
  2507 
  2541 void CAknCharMapExtension::ThumbnailLoaded(CSmileyIcon* /*aSmileyIcon*/)
  2508 void CAknCharMapExtension::SmileyStillImageLoaded(CAknSmileyIcon* aSmileyIcon)
  2542     {
  2509     {
  2543     iCharMapProxy->DrawDeferred();
  2510     iCharMapProxy->SmileyStillImageLoaded(iSmileyModel->SmileyCode(aSmileyIcon));
  2544     }
  2511     }
  2545 
  2512 
  2546 void CAknCharMapExtension::AnimationChanged(CSmileyIcon* /*aSmileyIcon*/)
  2513 void CAknCharMapExtension::SmileyAnimationChanged(CAknSmileyIcon* aSmileyIcon)
  2547     {
  2514     {
  2548     iCharMapProxy->DrawCursor();
  2515     iCharMapProxy->SmileyAnimationChanged(iSmileyModel->SmileyCode(aSmileyIcon));
       
  2516     
       
  2517     User::After(30); // for slow down the AO of this animation
  2549     }
  2518     }
  2550 
  2519 
  2551 TBool CAknCharMapExtension::IsEmotionEnabled() const
  2520 TBool CAknCharMapExtension::IsEmotionEnabled() const
  2552     {
  2521     {
  2553     return iIsEnableEmotion;
  2522     return iIsEnableEmotion;
  2554     }
  2523     }
  2555 
  2524 
  2556 TBool CAknCharMapExtension::IsShowingEmotion() const
  2525 TBool CAknCharMapExtension::IsShowingEmotion() const
  2557     {
  2526     {
  2558     return iIsShowingEmotion;
  2527     return iIsShowingEmotion;
       
  2528     }
       
  2529 
       
  2530 void CAknCharMapExtension::SwitchEmotionVisibilityL()
       
  2531     {
       
  2532     iIsShowingEmotion = !iIsShowingEmotion;
  2559     }
  2533     }
  2560 
  2534 
  2561 TBool CAknCharMapExtension::NeedEmotionSwitchIcon() const
  2535 TBool CAknCharMapExtension::NeedEmotionSwitchIcon() const
  2562     {
  2536     {
  2563     // Emotion switch char
  2537     // Emotion switch char
  2565     return needEmotionSwitchIcon;
  2539     return needEmotionSwitchIcon;
  2566     }
  2540     }
  2567 
  2541 
  2568 HBufC* CAknCharMapExtension::ReadEmotionHBufCL()
  2542 HBufC* CAknCharMapExtension::ReadEmotionHBufCL()
  2569     {
  2543     {
  2570     TInt smileyCount = iSmileyModel.Count();
  2544     TInt smileyCount = iSmileyModel->Count();
  2571     HBufC* charsSmiley = HBufC::NewL(smileyCount);
  2545     HBufC* charsSmiley = HBufC::NewL(smileyCount);
  2572     TPtr charsSmileyPtr(charsSmiley->Des());
  2546     TPtr charsSmileyPtr(charsSmiley->Des());
  2573     for(TInt id(CSmileyModel::EIconSmiley); id<smileyCount; id++)
  2547     for(TInt index(0); index<smileyCount; index++)
  2574         {
  2548         {
  2575         charsSmileyPtr.Append(TEmotionUtils::EmotionChar(id));
  2549         charsSmileyPtr.Append(iSmileyModel->SmileyCode(index));
  2576         }
  2550         }
  2577     
  2551     
  2578     return charsSmiley;
  2552     return charsSmiley;
  2579     }
  2553     }
  2580 
  2554 
  2581 void CAknCharMapExtension::LoadEmotionTumbnails(const TDesC& aSctChars)
  2555 void CAknCharMapExtension::LoadEmotionTumbnails(const TDesC& aChars)
  2582     {
  2556     {
  2583     for(TInt i(0); i<aSctChars.Length(); i++)
  2557     iSmileyModel->LoadStillImagesL(aChars);
  2584         {
       
  2585         iSmileyModel.LoadThumbnailAsyn(TEmotionUtils::EmotionId(aSctChars[i]));
       
  2586         }
       
  2587     }
  2558     }
  2588 
  2559 
  2589 void CAknCharMapExtension::SetEmotionSize(const TSize& aSize)
  2560 void CAknCharMapExtension::SetEmotionSize(const TSize& aSize)
  2590     {
  2561     {
  2591     TInt unit = Min(aSize.iWidth, aSize.iHeight);
  2562     TInt unit = Min(aSize.iWidth, aSize.iHeight);
  2592     iSmileyModel.SetSize(TSize(unit,unit));
  2563     iSmileyModel->SetSize(TSize(unit,unit));
  2593     }
  2564     }
  2594 
  2565 
  2595 CSmileyIcon* CAknCharMapExtension::EmotionIcon(TChar aEmotionChar)
  2566 TBool CAknCharMapExtension::IsEmotionChar(TChar aChar)
  2596     {
  2567     {
  2597     if(TEmotionUtils::IsEmotionChar(aEmotionChar))
  2568     return iSmileyModel->IsSmiley(aChar);
  2598         {
  2569     }
  2599         return iSmileyModel[TEmotionUtils::EmotionId(aEmotionChar)];
  2570 
  2600         }
  2571 TChar CAknCharMapExtension::SwitchToSctChar()
  2601     else
  2572     {
  2602         {
  2573     return iSmileyModel->SwitchToSctCode();
  2603         return NULL;
  2574     }
  2604         }
  2575 
  2605     }
  2576 TChar CAknCharMapExtension::SwitchToEmotionChar()
  2606 
  2577     {
  2607 TBool CAknCharMapExtension::DrawEmotion(CWindowGc& aGc, const TRect& aRect, TChar aEmotionChar)
  2578     return iSmileyModel->SwitchToSmileyCode();
  2608     {
  2579     }
  2609     CSmileyIcon* icon = EmotionIcon(aEmotionChar);
  2580 
  2610     if(icon && icon->ReadyToDraw())
  2581 CAknSmileyIcon* CAknCharMapExtension::EmotionIcon(TChar aChar)
  2611         {
  2582     {
  2612         TRect iconRect(TPoint(),icon->Size());
  2583     return iSmileyModel->Smiley(aChar);
       
  2584     }
       
  2585 
       
  2586 const TDesC& CAknCharMapExtension::EmotionText(TChar aChar)
       
  2587     {
       
  2588     return iSmileyModel->Text(aChar);
       
  2589     }
       
  2590 
       
  2591 TBool CAknCharMapExtension::DrawEmotion(CWindowGc& aGc, const TRect& aRect, CAknSmileyIcon* aSmileyIcon)
       
  2592     {
       
  2593     if(aSmileyIcon && aSmileyIcon->ReadyToDraw())
       
  2594         {
       
  2595         TRect iconRect(TPoint(),aSmileyIcon->Size());
  2613         TInt xoffset = (aRect.Width() - iconRect.Width()) / 2;
  2596         TInt xoffset = (aRect.Width() - iconRect.Width()) / 2;
  2614         TInt yoffset = (aRect.Height() - iconRect.Height()) / 2;
  2597         TInt yoffset = (aRect.Height() - iconRect.Height()) / 2;
  2615 
  2598 
  2616         aGc.BitBltMasked(aRect.iTl+TPoint(xoffset,yoffset), icon->Image(), iconRect, icon->Mask(), FALSE);
  2599         aGc.BitBltMasked(aRect.iTl+TPoint(xoffset,yoffset), aSmileyIcon->Image(), iconRect, aSmileyIcon->Mask(), FALSE);
  2617         return ETrue;
  2600         return ETrue;
  2618         }
  2601         }
  2619     else
  2602     else
  2620         {
  2603         {
  2621         return EFalse;
  2604         return EFalse;
  2625 const TInt KEmotionAnimationRepeatCount = 30; // 30 times
  2608 const TInt KEmotionAnimationRepeatCount = 30; // 30 times
  2626 const TInt KEmotionAnimationDelay = 150*1000; // 0.15s
  2609 const TInt KEmotionAnimationDelay = 150*1000; // 0.15s
  2627 
  2610 
  2628 void CAknCharMapExtension::HandleFocusStatusChanged(TChar aChar, TBool aIsFocused)
  2611 void CAknCharMapExtension::HandleFocusStatusChanged(TChar aChar, TBool aIsFocused)
  2629     {
  2612     {
  2630     CSmileyIcon* lastIcon = EmotionIcon(iLastFocusedSmileyChar);
  2613     CAknSmileyIcon* lastIcon = EmotionIcon(iLastFocusedSmileyChar);
  2631     if(lastIcon)
  2614     if(lastIcon)
  2632         {
  2615         {
  2633         lastIcon->StopAnimation();
  2616         lastIcon->StopAnimation();
  2634         }
  2617         }
  2635     
  2618     
  2636     CSmileyIcon* focusedIcon = EmotionIcon(aChar);
  2619     CAknSmileyIcon* focusedIcon = EmotionIcon(aChar);
  2637     if(focusedIcon)
  2620     if(focusedIcon)
  2638         {
  2621         {
  2639         if(aIsFocused)
  2622         if(aIsFocused)
  2640             {
  2623             {
  2641             if(iHighlightVisible)
  2624             if(iHighlightVisible)
  2828 // -----------------------------------------------------------------------------
  2811 // -----------------------------------------------------------------------------
  2829 // CAknCharMapHistory::InsertChar()
  2812 // CAknCharMapHistory::InsertChar()
  2830 // Insert a character which select on SCT/Picto.
  2813 // Insert a character which select on SCT/Picto.
  2831 // -----------------------------------------------------------------------------
  2814 // -----------------------------------------------------------------------------
  2832 //
  2815 //
  2833 void CAknCharMapHistory::InsertChar(THistoryType aHistoryType, const TChar aChar)
  2816 void CAknCharMapHistory::InsertChar(THistoryType aHistoryType, const TChar aChar, TBool aIsEmotion)
  2834     {
  2817     {
  2835     __ASSERT_ALWAYS((EHistoryTypeFull<=aHistoryType && aHistoryType<EHistoryTypeMax), Panic(EAknPanicInvalidValue));
  2818     __ASSERT_ALWAYS((EHistoryTypeFull<=aHistoryType && aHistoryType<EHistoryTypeMax), Panic(EAknPanicInvalidValue));
  2836 
  2819 
  2837     InsertCharToHistoryBuf(iMixedHistoryArray[aHistoryType], aChar);
  2820     InsertCharToHistoryBuf(iMixedHistoryArray[aHistoryType], aChar);
  2838 
  2821 
  2839     if(TEmotionUtils::IsEmotionChar(aChar))
  2822     if(aIsEmotion)
  2840         {
  2823         {
  2841         InsertCharToHistoryBuf(iEmotionHistory, aChar);
  2824         InsertCharToHistoryBuf(iEmotionHistory, aChar);
  2842         }
  2825         }
  2843     else
  2826     else
  2844         {
  2827         {
  3007     CountMaxColumnsAndCellSizes();
  2990     CountMaxColumnsAndCellSizes();
  3008     SizeChanged();
  2991     SizeChanged();
  3009 
  2992 
  3010     // load Emotion icon resource, but not load images
  2993     // load Emotion icon resource, but not load images
  3011     TSize iconSize(iGridItemWidth,iGridItemHeight);
  2994     TSize iconSize(iGridItemWidth,iGridItemHeight);
  3012     iconSize.iWidth = iconSize.iWidth * 2 / 3;
  2995     iconSize.iWidth = iconSize.iWidth * 3 / 4;
  3013     iconSize.iHeight = iconSize.iHeight * 2 / 3;
  2996     iconSize.iHeight = iconSize.iHeight * 3 / 4;
  3014     Extension()->SetEmotionSize(iconSize);
  2997     Extension()->SetEmotionSize(iconSize);
  3015     }
  2998     }
  3016 
  2999 
  3017 
  3000 
  3018 EXPORT_C void CAknCharMap::ConstructFromResourceL(TResourceReader& aReader)
  3001 EXPORT_C void CAknCharMap::ConstructFromResourceL(TResourceReader& aReader)
  3184         {
  3167         {
  3185         iShowCasesRef = &iSpecialCharCases;
  3168         iShowCasesRef = &iSpecialCharCases;
  3186         iShowPagesRef = &iSpecialCharPages;
  3169         iShowPagesRef = &iSpecialCharPages;
  3187         
  3170         
  3188         // default
  3171         // default
       
  3172         iSpecialCharCase = EAknSCTLowerCase;
  3189         iChars = iCharsBufferLower;
  3173         iChars = iCharsBufferLower;
  3190         
  3174         
  3191         if(iExtension->iCharsSmiley && iExtension->IsShowingEmotion())
  3175         if(iExtension->iCharsSmiley && iExtension->IsShowingEmotion())
  3192             {
  3176             {
  3193             iChars = iExtension->iCharsSmiley;
  3177             iChars = iExtension->iCharsSmiley;
  3267     if(pageNavi)
  3251     if(pageNavi)
  3268         {
  3252         {
  3269         pageNavi->MakeVisible(PageCount()>1);
  3253         pageNavi->MakeVisible(PageCount()>1);
  3270         }
  3254         }
  3271     
  3255     
  3272     HandleFocusStatusChanged();
  3256     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  3273     
  3257     
  3274     }
  3258     }
  3275 
  3259 
  3276 EXPORT_C void CAknCharMap::SetBuffer(TDes& aSpecialChars)
  3260 EXPORT_C void CAknCharMap::SetBuffer(TDes& aSpecialChars)
  3277     {
  3261     {
  3454         {
  3438         {
  3455         if ( code == EKeyUpArrow || code == EKeyDownArrow || 
  3439         if ( code == EKeyUpArrow || code == EKeyDownArrow || 
  3456              code == EKeyLeftArrow || code == EKeyRightArrow || 
  3440              code == EKeyLeftArrow || code == EKeyRightArrow || 
  3457              code == EKeyEnter )
  3441              code == EKeyEnter )
  3458             {
  3442             {
       
  3443             iExtension->iKeyBrdEvent = ETrue;
  3459             iExtension->iHighlightVisible = ETrue;
  3444             iExtension->iHighlightVisible = ETrue;
  3460             iCursorPos = TPoint( 0, 0 );
  3445             iCursorPos = TPoint( 0, 0 );
  3461             DrawCursor();
  3446             DrawCursor();
  3462             HandleFocusStatusChanged();
       
  3463             return EKeyWasConsumed;
  3447             return EKeyWasConsumed;
  3464             }
  3448             }
  3465         }
  3449         }
  3466     
  3450     
  3467     switch (code)
  3451     switch (code)
  4002         // Append right amount of recent characters due to different layout.
  3986         // Append right amount of recent characters due to different layout.
  4003         if (recentWasSetBeforeSwitch) AppendRecentCharL();
  3987         if (recentWasSetBeforeSwitch) AppendRecentCharL();
  4004 
  3988 
  4005         // Sets the character case because the buffer content may have changed.
  3989         // Sets the character case because the buffer content may have changed.
  4006         SetCharacterCaseL(iSpecialCharCase);
  3990         SetCharacterCaseL(iSpecialCharCase);
  4007 
       
  4008         // status after layout switch.
       
  4009         TInt recentLengthAfterSwitch = iMaxColumns; // recentLength has changed after switch
       
  4010         TInt cursorIndexAfterSwitch;
  3991         TInt cursorIndexAfterSwitch;
  4011         if(cursorIndexBeforeSwitch < recentLengthBeforeSwitch)
  3992         if ( !iExtension->iKeyBrdEvent )
  4012             {
  3993             {
  4013             cursorIndexAfterSwitch = cursorIndexBeforeSwitch;
  3994             cursorIndexAfterSwitch = cursorIndexBeforeSwitch;
  4014             }
  3995             }
  4015         else
  3996         else
  4016             {
  3997             {
  4017             cursorIndexAfterSwitch = cursorIndexBeforeSwitch - recentLengthBeforeSwitch + recentLengthAfterSwitch;
  3998             // status after layout switch.
  4018             }
  3999             TInt recentLengthAfterSwitch = iMaxColumns; // recentLength has
  4019 
  4000                                                         // changed after switch
       
  4001             if ( cursorIndexBeforeSwitch < recentLengthBeforeSwitch )
       
  4002                 {
       
  4003                 cursorIndexAfterSwitch = cursorIndexBeforeSwitch;
       
  4004                 }
       
  4005             else
       
  4006                 {
       
  4007                 cursorIndexAfterSwitch = cursorIndexBeforeSwitch -
       
  4008                             recentLengthBeforeSwitch + recentLengthAfterSwitch;
       
  4009                 }
       
  4010             }
  4020         // the new first row is the top row on the page where the new focus is.
  4011         // the new first row is the top row on the page where the new focus is.
  4021         TInt pageVolume = iMaxColumns * iExtension->iMaxVisibleRows;
  4012         TInt pageVolume = iMaxColumns * iExtension->iMaxVisibleRows;
  4022         iFirstVisibleRow = (cursorIndexAfterSwitch / pageVolume * pageVolume) / iMaxColumns;
  4013         iFirstVisibleRow = (cursorIndexAfterSwitch / pageVolume * pageVolume) / iMaxColumns;
  4023 
  4014 
  4024         // the cursor positions are relative to current page
  4015         // the cursor positions are relative to current page
  4103         // !resize an option but the cost only differs with the creation of the graphic objects!
  4094         // !resize an option but the cost only differs with the creation of the graphic objects!
  4104         CreateOffscreenBackgroundL();
  4095         CreateOffscreenBackgroundL();
  4105         iOffscreenBgDrawn = EFalse;
  4096         iOffscreenBgDrawn = EFalse;
  4106         }
  4097         }
  4107 
  4098 
  4108     else if ( aType == KAknsMessageSkinChange )
  4099     else if( aType == KAknsMessageSkinChange )
  4109         {
  4100         {
  4110         iOffscreenBgDrawn = EFalse;
  4101         iOffscreenBgDrawn = EFalse;
  4111         }
  4102         }
  4112     else if ( aType == KAknMessageFocusLost && iExtension->iHighlightVisible )
  4103 
  4113         {
  4104     else if(aType == KEikMessageFadeAllWindows) // focus gained // KEikMessageWindowsFadeChange
  4114         iExtension->iHighlightVisible = EFalse;
  4105         {
  4115         DrawCursor();
  4106         SetSmileyAnimationActivityInCurrentPageL(ETrue);
  4116         }
  4107         }
       
  4108     
       
  4109     else if(aType == KAknMessageFocusLost) // focus lost
       
  4110         {
       
  4111         SetSmileyAnimationActivityInCurrentPageL(EFalse);
       
  4112 		
       
  4113     	if ( iExtension->iHighlightVisible )
       
  4114         	{
       
  4115         	iExtension->iHighlightVisible = EFalse;
       
  4116         	DrawCursor();
       
  4117         	}
       
  4118     	}
  4117     }
  4119     }
  4118 
  4120 
  4119 void CAknCharMap::EnableNavigationButtonsL()
  4121 void CAknCharMap::EnableNavigationButtonsL()
  4120     {
  4122     {
  4121     if ( iExtension )
  4123     if ( iExtension )
  4689         {
  4691         {
  4690         AknsUtils::GetCachedColor( skin, color,
  4692         AknsUtils::GetCachedColor( skin, color,
  4691             KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 );
  4693             KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 );
  4692         }
  4694         }
  4693     
  4695     
  4694     if(TEmotionUtils::IsEmotionChar(symbol[0]))
  4696     CAknSmileyIcon* icon = iExtension->EmotionIcon(symbol[0]);
  4695         {
  4697     if(icon) 
  4696         iExtension->DrawEmotion(aGc, textLayout.TextRect(), symbol[0]);
  4698         {
       
  4699         iExtension->DrawEmotion( aGc, textLayout.TextRect(), icon );
  4697         }
  4700         }
  4698     else
  4701     else
  4699         {
  4702         {
  4700         textLayout.DrawText( aGc, symbol, EFalse, color );
  4703         textLayout.DrawText( aGc, symbol, EFalse, color );
  4701         }
  4704         }
  4843     MTouchFeedback* feedback = MTouchFeedback::Instance();
  4846     MTouchFeedback* feedback = MTouchFeedback::Instance();
  4844     CFeedbackSpec* spec = CFeedbackSpec::New();
  4847     CFeedbackSpec* spec = CFeedbackSpec::New();
  4845 
  4848 
  4846     if ( feedback && spec )
  4849     if ( feedback && spec )
  4847         {
  4850         {
  4848         TInt orphans = NumberOfVisibleChars() % iMaxColumns;
  4851         TInt orphans = numberOfCells % iMaxColumns;
  4849         TInt rows = NumberOfVisibleChars() / iMaxColumns;
  4852         TInt rows = numberOfCells / iMaxColumns;
  4850         CAknCharMap* mutableThis = MUTABLE_CAST( CAknCharMap* ,this );
  4853         CAknCharMap* mutableThis = MUTABLE_CAST( CAknCharMap* ,this );
  4851         TInt recentChars = mutableThis->LengthOfRecentChar();    
  4854         TInt recentChars = mutableThis->LengthOfRecentChar();    
  4852         TRect rectMain;
  4855         TRect rectMain;
  4853         TPoint nextTopLeft = iGridTopLeft;    
  4856         TPoint nextTopLeft = iGridTopLeft;    
  4854 
  4857 
  5337             else
  5340             else
  5338                 {
  5341                 {
  5339                 pt.iX = index;
  5342                 pt.iX = index;
  5340                 }
  5343                 }
  5341             }
  5344             }
  5342         
       
  5343         HandleFocusStatusChanged();
       
  5344 
  5345 
  5345         iCursorPos = pt;
  5346         iCursorPos = pt;
  5346         UpdateScrollIndicatorL();
  5347         UpdateScrollIndicatorL();
  5347         DrawNow();
  5348         DrawNow();
  5348         }
  5349         }
  5375         if ((iRows > iExtension->iMaxVisibleRows) &&
  5376         if ((iRows > iExtension->iMaxVisibleRows) &&
  5376             (iOldCursorPos.iY + oldFirstVisibleRow != iCursorPos.iY + iFirstVisibleRow))
  5377             (iOldCursorPos.iY + oldFirstVisibleRow != iCursorPos.iY + iFirstVisibleRow))
  5377             {
  5378             {
  5378             UpdateScrollIndicatorL();
  5379             UpdateScrollIndicatorL();
  5379             }
  5380             }
  5380         
       
  5381         HandleFocusStatusChanged();
       
  5382 
  5381 
  5383         if (oldFirstVisibleRow == iFirstVisibleRow)
  5382         if (oldFirstVisibleRow == iFirstVisibleRow)
  5384             {
  5383             {
  5385                 // Draw only cursor if the view to the content was not scrolled.
  5384                 // Draw only cursor if the view to the content was not scrolled.
  5386             DrawCursor();
  5385             DrawCursor();
  5717 	
  5716 	
  5718     }
  5717     }
  5719 
  5718 
  5720 TInt CAknCharMap::NextPageL()
  5719 TInt CAknCharMap::NextPageL()
  5721     {
  5720     {
  5722     HandleFocusStatusChanged(EFalse);
  5721     SetSmileyAnimationActivityInCurrentPageL(EFalse);
  5723     
  5722     
  5724     TInt page(0);
  5723     TInt page(0);
  5725     iFirstVisibleRow =
  5724     iFirstVisibleRow =
  5726         (((iCursorPos.iY + iFirstVisibleRow) / iExtension->iMaxVisibleRows) + 1)
  5725         (((iCursorPos.iY + iFirstVisibleRow) / iExtension->iMaxVisibleRows) + 1)
  5727                                                     * iExtension->iMaxVisibleRows;
  5726                                                     * iExtension->iMaxVisibleRows;
  5756             }
  5755             }
  5757 
  5756 
  5758         }
  5757         }
  5759     UpdateHeadingPane( ETrue );
  5758     UpdateHeadingPane( ETrue );
  5760     UpdateScrollIndicatorL();
  5759     UpdateScrollIndicatorL();
  5761     HandleFocusStatusChanged();
  5760     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  5762     DrawNow();
  5761     DrawNow();
  5763 
  5762 
  5764     return page;
  5763     return page;
  5765     }
  5764     }
  5766 
  5765 
  5767 TInt CAknCharMap::PrevPageL()
  5766 TInt CAknCharMap::PrevPageL()
  5768     {
  5767     {
  5769     HandleFocusStatusChanged(EFalse);
  5768     SetSmileyAnimationActivityInCurrentPageL(EFalse);
  5770     
  5769     
  5771     TInt page(0);
  5770     TInt page(0);
  5772     TInt firstVisibleRow =
  5771     TInt firstVisibleRow =
  5773         (((iCursorPos.iY + iFirstVisibleRow) / iExtension->iMaxVisibleRows) - 1) *
  5772         (((iCursorPos.iY + iFirstVisibleRow) / iExtension->iMaxVisibleRows) - 1) *
  5774             iExtension->iMaxVisibleRows;
  5773             iExtension->iMaxVisibleRows;
  5801             iCursorPos = TPoint(0, 0);
  5800             iCursorPos = TPoint(0, 0);
  5802             }
  5801             }
  5803         }
  5802         }
  5804     UpdateHeadingPane( ETrue );
  5803     UpdateHeadingPane( ETrue );
  5805     UpdateScrollIndicatorL();
  5804     UpdateScrollIndicatorL();
  5806     HandleFocusStatusChanged();
  5805     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  5807     DrawNow();
  5806     DrawNow();
  5808 
  5807 
  5809     return page;
  5808     return page;
  5810     }
  5809     }
  5811 
  5810 
  6445 // to the array in which all the special characters are placed by the normal
  6444 // to the array in which all the special characters are placed by the normal
  6446 // (rocker) method.
  6445 // (rocker) method.
  6447 //--------------------------------------------------------------------------
  6446 //--------------------------------------------------------------------------
  6448 EXPORT_C void CAknCharMap::HandlePointerEventL(const TPointerEvent& aPointerEvent)
  6447 EXPORT_C void CAknCharMap::HandlePointerEventL(const TPointerEvent& aPointerEvent)
  6449     {
  6448     {
       
  6449     iExtension->iKeyBrdEvent = EFalse;
       
  6450 
  6450     if ( AknLayoutUtils::PenEnabled() && Rect().Contains(aPointerEvent.iPosition))
  6451     if ( AknLayoutUtils::PenEnabled() && Rect().Contains(aPointerEvent.iPosition))
  6451         {
  6452         {
  6452         if (iExtension->iFocusHandler->FocusedControl() != this)// Tapping will move focus to grid.
  6453         if (iExtension->iFocusHandler->FocusedControl() != this)// Tapping will move focus to grid.
  6453             {
  6454             {
  6454             iExtension->iFocusHandler->LeaveControl();
  6455             iExtension->iFocusHandler->LeaveControl();
  6564                             {
  6565                             {
  6565                             if( iExtension->iSingleClickEnabled )
  6566                             if( iExtension->iSingleClickEnabled )
  6566                                 {
  6567                                 {
  6567                                 iExtension->iHighlightVisible = ETrue;
  6568                                 iExtension->iHighlightVisible = ETrue;
  6568                                 }
  6569                                 }
  6569                         
       
  6570                             HandleFocusStatusChanged();
       
  6571                             }
  6570                             }
  6572                         
  6571                         
  6573                         DrawCursor();
  6572                         DrawCursor();
  6574                         }
  6573                         }
  6575                     else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
  6574                     else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
  6813         {
  6812         {
  6814         if (iExtension->iObserver)
  6813         if (iExtension->iObserver)
  6815             {
  6814             {
  6816             iExtension->iObserver->HandleControlEventL(this, MCoeControlObserver::EEventRequestFocus);
  6815             iExtension->iObserver->HandleControlEventL(this, MCoeControlObserver::EEventRequestFocus);
  6817             }
  6816             }
  6818         
  6817 
  6819         HandleFocusStatusChanged();
       
  6820         DrawDeferred();
  6818         DrawDeferred();
  6821         }
  6819         }
  6822     }
  6820     }
  6823 
  6821 
  6824 // -----------------------------------------------------------------------------
  6822 // -----------------------------------------------------------------------------
  6878             }
  6876             }
  6879         
  6877         
  6880         TPtrC textHistory = iCharMapHistory->RecentString(historyType, CAknCharMapHistory::EHistoryFilterTextOnly);
  6878         TPtrC textHistory = iCharMapHistory->RecentString(historyType, CAknCharMapHistory::EHistoryFilterTextOnly);
  6881         
  6879         
  6882         *charsBuf = InsertSwitchCharAndHistoryToCharsBufL(*charsBuf, 
  6880         *charsBuf = InsertSwitchCharAndHistoryToCharsBufL(*charsBuf, 
  6883                                                           TEmotionUtils::EmotionSwitchToSmileyChar(), 
  6881                                                           iExtension->SwitchToEmotionChar(), 
  6884                                                           textHistory);
  6882                                                           textHistory);
  6885         }
  6883         }
  6886     
  6884     
  6887     // Emotion history
  6885     // Emotion history
  6888     TPtrC emotionHistory = iCharMapHistory->RecentString(CAknCharMapHistory::EHistoryTypeFull, CAknCharMapHistory::EHistoryFilterEmotionOnly);
  6886     TPtrC emotionHistory = iCharMapHistory->RecentString(CAknCharMapHistory::EHistoryTypeFull, CAknCharMapHistory::EHistoryFilterEmotionOnly);
  6889     iExtension->iCharsSmiley = InsertSwitchCharAndHistoryToCharsBufL(iExtension->iCharsSmiley, 
  6887     iExtension->iCharsSmiley = InsertSwitchCharAndHistoryToCharsBufL(iExtension->iCharsSmiley, 
  6890                                                                      TEmotionUtils::EmotionSwitchToSctChar(), 
  6888                                                                      iExtension->SwitchToSctChar(), 
  6891                                                                      emotionHistory);
  6889                                                                      emotionHistory);
  6892 
  6890 
  6893     // ETrue are set to each variable when setting the recent used characters.
  6891     // ETrue are set to each variable when setting the recent used characters.
  6894     iSetRecentSct = ETrue;
  6892     iSetRecentSct = ETrue;
  6895     iSetRecentPic = ETrue;
  6893     iSetRecentPic = ETrue;
  6902         // Check whether recent charcters are included in base charcters.
  6900         // Check whether recent charcters are included in base charcters.
  6903         TBuf<CAknCharMapHistory::KHistoryBufferSize+5> insertBuffer;
  6901         TBuf<CAknCharMapHistory::KHistoryBufferSize+5> insertBuffer;
  6904         for (TInt index=0; index<aHistory.Length(); index++)
  6902         for (TInt index=0; index<aHistory.Length(); index++)
  6905             {
  6903             {
  6906             TChar txt = aHistory[index];
  6904             TChar txt = aHistory[index];
  6907             if(aCharsBuf->Locate(txt)!=KErrNotFound || TEmotionUtils::IsEmotionChar(txt) || txt==KHistoryEmptyChar)
  6905             if(aCharsBuf->Locate(txt)!=KErrNotFound || Extension()->IsEmotionChar(txt) || txt==KHistoryEmptyChar)
  6908                 {
  6906                 {
  6909                 insertBuffer.Append(txt);
  6907                 insertBuffer.Append(txt);
  6910                 }
  6908                 }
  6911             }
  6909             }
  6912 
  6910 
  7017             break;
  7015             break;
  7018         }
  7016         }
  7019     
  7017     
  7020     if (historyType > CAknCharMapHistory::EHistoryTypeNull)
  7018     if (historyType > CAknCharMapHistory::EHistoryTypeNull)
  7021         {
  7019         {
  7022         iCharMapHistory->InsertChar(historyType, aChar);
  7020         TBool isEmotion = Extension()->IsEmotionChar(aChar);
       
  7021         iCharMapHistory->InsertChar(historyType, aChar, isEmotion);
  7023         }
  7022         }
  7024 
  7023 
  7025     // Save recent data
  7024     // Save recent data
  7026     iCharMapHistory->SaveL();
  7025     iCharMapHistory->SaveL();
  7027     }
  7026     }
  7150     // If the row is empty, nothing to do
  7149     // If the row is empty, nothing to do
  7151     if (LengthOfRecentChar() == 0)
  7150     if (LengthOfRecentChar() == 0)
  7152         {
  7151         {
  7153         return;
  7152         return;
  7154         }
  7153         }
  7155     
  7154 
  7156     HandleFocusStatusChanged(aHighlight);
  7155     SetSmileyAnimationActivityInCurrentPageL(aHighlight);
  7157     
  7156     
  7158     CWindowGc& gc = SystemGc();
  7157     CWindowGc& gc = SystemGc();
  7159     if( !CAknEnv::Static()->TransparencyEnabled() )
  7158     if( !CAknEnv::Static()->TransparencyEnabled() )
  7160         {
  7159         {
  7161         ActivateGc();
  7160         ActivateGc();
  7307         ptrrecent.Copy(recentChars);
  7306         ptrrecent.Copy(recentChars);
  7308         for (TInt index=0; index < ptrrecent.Length(); index++)
  7307         for (TInt index=0; index < ptrrecent.Length(); index++)
  7309             {
  7308             {
  7310             if (ptrrecent[index] != KHistoryEmptyChar)
  7309             if (ptrrecent[index] != KHistoryEmptyChar)
  7311                 {
  7310                 {
  7312                 if(TEmotionUtils::IsEmotionChar(ptrrecent[index]))
  7311                 if(Extension()->IsEmotionChar(ptrrecent[index]))
  7313                     {
  7312                     {
  7314                     continue;
  7313                     continue;
  7315                     }
  7314                     }
  7316                 else
  7315                 else
  7317                     {
  7316                     {
  7319                     if (err == KErrNotFound)
  7318                     if (err == KErrNotFound)
  7320                         {
  7319                         {
  7321                         ptrrecent.Delete(index,1);
  7320                         ptrrecent.Delete(index,1);
  7322                         ptrrecent.Append(KHistoryEmptyChar);
  7321                         ptrrecent.Append(KHistoryEmptyChar);
  7323                         index--;
  7322                         index--;
  7324                         }                       
  7323                         }
  7325                     }
  7324                     }
  7326                 }
  7325                 }
  7327             }
  7326             }
  7328         if (iExtension->iFlags & EAknCharMapCharsAllocated) // iChars already contains HBufC
  7327         if (iExtension->iFlags & EAknCharMapCharsAllocated) // iChars already contains HBufC
  7329             {                                               // so delete old instance
  7328             {                                               // so delete old instance
  7344         iExtension->iFlags |= EAknCharMapCharsAllocated; // mark that iChars points to HBufC
  7343         iExtension->iFlags |= EAknCharMapCharsAllocated; // mark that iChars points to HBufC
  7345         }
  7344         }
  7346     
  7345     
  7347     iExtension->LoadEmotionTumbnails(*iChars);
  7346     iExtension->LoadEmotionTumbnails(*iChars);
  7348 
  7347 
  7349     HandleFocusStatusChanged();
  7348     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  7350     }
  7349     }
  7351 
  7350 
  7352 // -----------------------------------------------------------------------------
  7351 // -----------------------------------------------------------------------------
  7353 // CAknCharMap::CharacterCase()
  7352 // CAknCharMap::CharacterCase()
  7354 // Get current character case.
  7353 // Get current character case.
  7811     TRAP_IGNORE(MoveCursorL(aX,aY));
  7810     TRAP_IGNORE(MoveCursorL(aX,aY));
  7812     }
  7811     }
  7813 
  7812 
  7814 TBool CAknCharMap::LeaveControl()
  7813 TBool CAknCharMap::LeaveControl()
  7815     {
  7814     {
  7816     HandleFocusStatusChanged(EFalse);
       
  7817     
       
  7818     CWindowGc& gc = SystemGc();
  7815     CWindowGc& gc = SystemGc();
  7819     if( !CAknEnv::Static()->TransparencyEnabled() )
  7816     if( !CAknEnv::Static()->TransparencyEnabled() )
  7820         {
  7817         {
  7821         ActivateGc();
  7818         ActivateGc();
  7822         gc.UseFont(iFont);
  7819         gc.UseFont(iFont);
  8028     }
  8025     }
  8029 
  8026 
  8030 
  8027 
  8031 // for emotion added
  8028 // for emotion added
  8032 
  8029 
  8033 void CAknCharMap::HandleFocusStatusChanged(TBool aIsFocused)
       
  8034     {
       
  8035     TInt focusPos = iCursorPos.iX + (iFirstVisibleRow + iCursorPos.iY) * iMaxColumns;
       
  8036     if(focusPos>=0 && focusPos<iChars->Length())
       
  8037         {
       
  8038         aIsFocused &= (iExtension->iFocusHandler->FocusedControl()==this);
       
  8039         iExtension->HandleFocusStatusChanged((*iChars)[focusPos], aIsFocused);
       
  8040         }
       
  8041     }
       
  8042 
  8030 
  8043 TBool CAknCharMap::EmotionsAreAllReadyToDraw(TInt aIndex, TInt aCount) const
  8031 TBool CAknCharMap::EmotionsAreAllReadyToDraw(TInt aIndex, TInt aCount) const
  8044     {
  8032     {
  8045     for(TInt i(0); i<aCount; i++)
  8033     for(TInt i(0); i<aCount; i++)
  8046         {
  8034         {
  8047         if(aIndex < iChars->Length())
  8035         if(aIndex < iChars->Length())
  8048             {
  8036             {
  8049             TChar name = (*iChars)[aIndex++];
  8037             TChar code = (*iChars)[aIndex++];
  8050             CSmileyIcon* icon = iExtension->EmotionIcon(name);
  8038             CAknSmileyIcon* icon = Extension()->EmotionIcon(code);
  8051             if(icon && !icon->ReadyToDraw())
  8039             if(icon && !icon->ReadyToDraw())
  8052                 {
  8040                 {
  8053                 return EFalse;
  8041                 return EFalse;
  8054                 }
  8042                 }
  8055             }
  8043             }
  8060         }
  8048         }
  8061     
  8049     
  8062     return ETrue;
  8050     return ETrue;
  8063     }
  8051     }
  8064 
  8052 
       
  8053 void CAknCharMap::SmileyStillImageLoaded(TChar aChar)
       
  8054     {
       
  8055     const CAknSmileyIcon* loadedIcon = Extension()->EmotionIcon(aChar);
       
  8056     
       
  8057     for(TInt i(0); i<iChars->Length(); i++)
       
  8058         {
       
  8059         TChar code = (*iChars)[i];
       
  8060         CAknSmileyIcon* icon = Extension()->EmotionIcon(code);
       
  8061         if(icon == loadedIcon)
       
  8062             {
       
  8063             if((i%iMaxColumns == 0) || (i == iChars->Length()-1))
       
  8064                 {
       
  8065                 DrawDeferred(); // a new line is finished
       
  8066                 }
       
  8067             }
       
  8068         }
       
  8069     }
       
  8070 
       
  8071 void CAknCharMap::SmileyAnimationChanged(TChar aChar)
       
  8072     {
       
  8073     const CAknSmileyIcon* loadedIcon = Extension()->EmotionIcon(aChar);
       
  8074     TInt pageVolume = iExtension->iMaxVisibleRows * iMaxColumns;
       
  8075     
       
  8076     for(TInt i(0); i<iChars->Length(); i++)
       
  8077         {
       
  8078         TChar code = (*iChars)[i];
       
  8079         CAknSmileyIcon* icon = iExtension->EmotionIcon(code);
       
  8080         if(icon == loadedIcon)
       
  8081             {
       
  8082             TInt index = i % pageVolume;
       
  8083             TPoint pos(index%iMaxColumns, index/iMaxColumns);
       
  8084             
       
  8085             // grid is focused and cursor pos is same with the current index.
       
  8086             TBool highlighted = EFalse;
       
  8087             if(iExtension->iFocusHandler->FocusedControl()==this && iCursorPos==pos)
       
  8088                 {
       
  8089                 highlighted = (!iExtension->iMenuSct || iExtension->iMenuSctHighlighted);
       
  8090                 }
       
  8091 
       
  8092             DrawCell(index, highlighted);
       
  8093             }
       
  8094         }
       
  8095     }
       
  8096 
       
  8097 const TInt KAnimationRepeat = 30;
       
  8098 const TInt KAnimationDelay = 1000*1000;
       
  8099 
       
  8100 void CAknCharMap::SetSmileyAnimationActivityInCurrentPageL(TBool aIsActive)
       
  8101     {
       
  8102     TInt begin = iFirstVisibleRow * iMaxColumns;
       
  8103     TInt end = iExtension->iMaxVisibleRows * iMaxColumns + begin;
       
  8104     if(end > iChars->Length()) end = iChars->Length();
       
  8105 
       
  8106     for(TInt i(begin); i<end; i++)
       
  8107         {
       
  8108         TChar code = (*iChars)[i];
       
  8109         CAknSmileyIcon* icon = iExtension->EmotionIcon(code);
       
  8110         if(!icon) continue;
       
  8111 
       
  8112         if((aIsActive) && 
       
  8113            (Extension()->IsShowingEmotion()||Extension()->iMenuSctHighlighted)
       
  8114            )
       
  8115             {
       
  8116             icon->PlayAnimationL(KAnimationRepeat, KAnimationDelay);
       
  8117             }
       
  8118         else
       
  8119             {
       
  8120             icon->StopAnimation();
       
  8121             }
       
  8122         }
       
  8123     }
       
  8124 
  8065 void CAknCharMap::GetFocusSctName(TChar& aChar, TDes& aName) const
  8125 void CAknCharMap::GetFocusSctName(TChar& aChar, TDes& aName) const
  8066     {
  8126     {
  8067     TInt pos = iMaxColumns * (iFirstVisibleRow + iCursorPos.iY) + iCursorPos.iX;
  8127     TInt pos = iMaxColumns * (iFirstVisibleRow + iCursorPos.iY) + iCursorPos.iX;
  8068     
  8128 
  8069     aChar = (*iChars)[pos];
  8129     aChar = (*iChars)[pos];
  8070     
  8130 
  8071     aName.Zero();
  8131     aName.Zero();
  8072     
  8132 
  8073     if(TEmotionUtils::IsEmotionChar(aChar))
  8133     if(Extension()->IsEmotionChar(aChar))
  8074         {
  8134         {
  8075         CSmileyIcon* icon = iExtension->EmotionIcon(aChar);
  8135         aName.Append(Extension()->EmotionText(aChar));
  8076         if ( icon )
       
  8077             {
       
  8078             aName.Append(icon->Name());
       
  8079             }
       
  8080         }
  8136         }
  8081     else
  8137     else
  8082         {
  8138         {
  8083         aName.Append(aChar);
  8139         aName.Append(aChar);
  8084         }
  8140         }
  8100     TChar sctChar;
  8156     TChar sctChar;
  8101     TBuf<10> sctName;
  8157     TBuf<10> sctName;
  8102     GetFocusSctName(sctChar, sctName);
  8158     GetFocusSctName(sctChar, sctName);
  8103 
  8159 
  8104     if(Extension()->NeedEmotionSwitchIcon() && 
  8160     if(Extension()->NeedEmotionSwitchIcon() && 
  8105        (sctChar==TEmotionUtils::EmotionSwitchToSctChar() || sctChar==TEmotionUtils::EmotionSwitchToSmileyChar()))
  8161        (sctChar==Extension()->SwitchToSctChar() || sctChar==Extension()->SwitchToEmotionChar()))
  8106         {
  8162         {
  8107         SwitchSctAndEmotionL();
  8163         SwitchSctAndEmotionL();
  8108         }
  8164         }
  8109     else if(iFetcherCharsBuffer->Length() + sctName.Length() < iFetcherCharsBuffer->MaxLength())
  8165     else if(iFetcherCharsBuffer->Length() + sctName.Length() < iFetcherCharsBuffer->MaxLength())
  8110         {
  8166         {
  8139 
  8195 
  8140 TBool CAknCharMap::SwitchSctAndEmotionL()
  8196 TBool CAknCharMap::SwitchSctAndEmotionL()
  8141     {
  8197     {
  8142     if(Extension()->IsEmotionEnabled())
  8198     if(Extension()->IsEmotionEnabled())
  8143         {
  8199         {
  8144         Extension()->iIsShowingEmotion = !Extension()->IsShowingEmotion();
  8200         Extension()->SwitchEmotionVisibilityL();
       
  8201         
       
  8202         SetSmileyAnimationActivityInCurrentPageL(EFalse);
  8145         
  8203         
  8146         SetCharacterCaseL(iSpecialCharCase);
  8204         SetCharacterCaseL(iSpecialCharCase);
  8147         
  8205         
       
  8206         SetSmileyAnimationActivityInCurrentPageL(ETrue);
       
  8207         
  8148         CAknSctTableNavi* tableNavi = Extension()->iTableNavi;
  8208         CAknSctTableNavi* tableNavi = Extension()->iTableNavi;
  8149         if(tableNavi)
  8209         if(tableNavi)
  8150             {
  8210             {
  8151             tableNavi->UpdateNextTableButtonL();
  8211             tableNavi->UpdateNextTableButtonL();
  8152             }
  8212             }