uifw/AvKon/src/AknCharMap.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 18 fcdfafb36fe7
child 20 d48ab3b357f1
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
    40 #include <PUAcodes.hrh>
    40 #include <PUAcodes.hrh>
    41 #include <s32file.h>
    41 #include <s32file.h>
    42 #include <AknPanic.h>
    42 #include <AknPanic.h>
    43 #include "aknSctDialog.h" // CAknCharmapDialog
    43 #include "aknSctDialog.h" // CAknCharmapDialog
    44 #include <aknPopupHeadingPane.h>
    44 #include <aknPopupHeadingPane.h>
    45 #include <aknfep.rsg>
    45 //#include <aknfep.rsg>
    46 #include <bautils.h>
    46 #include <bautils.h>
    47 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    47 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    48 #include <uikon/eikenvinterface.h>
    48 #include <uikon/eikenvinterface.h>
    49 #endif
    49 #endif
    50 
    50 
    66 #include <eikedwin.h>
    66 #include <eikedwin.h>
    67 #include <gulbordr.h>
    67 #include <gulbordr.h>
    68 #include <touchfeedback.h>
    68 #include <touchfeedback.h>
    69 #include <eiklabel.h>
    69 #include <eiklabel.h>
    70 #include <aknphysics.h>
    70 #include <aknphysics.h>
    71 #include <AknPriv.hrh>
       
    72 
    71 
    73 #include "PictograhGrouping.h"
    72 #include "PictograhGrouping.h"
    74 #include "AknSettingCache.h"
    73 #include "AknSettingCache.h"
    75 #include "aknsctfocushandler.h"
    74 #include "aknsctfocushandler.h"
    76 
    75 
    92 
    91 
    93 
    92 
    94 const TUint KHistoryEmptyChar = CEditableText::ETabCharacter;
    93 const TUint KHistoryEmptyChar = CEditableText::ETabCharacter;
    95 const TUint KHistoryEmptyCharForDisplay = CEditableText::ESpace;
    94 const TUint KHistoryEmptyCharForDisplay = CEditableText::ESpace;
    96 
    95 
       
    96 const TInt KAknSctRadioOn = 1;
       
    97 const TInt KAknSctRadioOff = 0;
    97 const TInt KAreaIdRecent = 0;
    98 const TInt KAreaIdRecent = 0;
    98 const TInt KAreaIdMain   = 1;
    99 const TInt KAreaIdMain   = 1;
    99 const TInt KAreaIdTail   = 2;
   100 const TInt KAreaIdTail   = 2;
       
   101 
       
   102 
       
   103 // ----------------------------------------------------------------------------
       
   104 // TEmotionUtils definition
       
   105 // ----------------------------------------------------------------------------
       
   106 //
       
   107 
       
   108 const TUint KEmotionCharBase = 0xf880;
       
   109 
       
   110 class TEmotionUtils
       
   111     {
       
   112 public:
       
   113     static TBool IsEmotionChar(TChar aChar);
       
   114     static TChar EmotionChar(TInt aId);
       
   115     static TInt EmotionId(TChar aChar);
       
   116     static TChar EmotionSwitchToSmileyChar();
       
   117     static TChar EmotionSwitchToSctChar();
       
   118     };
       
   119 
       
   120 TBool TEmotionUtils::IsEmotionChar(TChar aChar)
       
   121     {
       
   122     return (aChar >= KEmotionCharBase);
       
   123     }
       
   124 
       
   125 TChar TEmotionUtils::EmotionChar(TInt aId)
       
   126     {
       
   127     return (KEmotionCharBase + aId);
       
   128     }
       
   129 
       
   130 TInt TEmotionUtils::EmotionId(TChar aChar)
       
   131     {
       
   132     return (TInt)(aChar - KEmotionCharBase);
       
   133     }
       
   134 
       
   135 TChar TEmotionUtils::EmotionSwitchToSmileyChar()
       
   136     {
       
   137     return KEmotionCharBase + CSmileyModel::EIconSwitchToSmiley;
       
   138     }
       
   139 
       
   140 TChar TEmotionUtils::EmotionSwitchToSctChar()
       
   141     {
       
   142     return KEmotionCharBase + CSmileyModel::EIconSwitchToSct;
       
   143     }
   100 
   144 
   101 
   145 
   102 // ----------------------------------------------------------------------------
   146 // ----------------------------------------------------------------------------
   103 // CAknCharMapHistory definition
   147 // CAknCharMapHistory definition
   104 // ----------------------------------------------------------------------------
   148 // ----------------------------------------------------------------------------
   172         * Insert a character which select on SCT/Picto.
   216         * Insert a character which select on SCT/Picto.
   173         * @since 2.8
   217         * @since 2.8
   174         * @param aHistoryType The kind of charctor map, refer to THistoryType
   218         * @param aHistoryType The kind of charctor map, refer to THistoryType
   175         * @param aChar    Insert a character
   219         * @param aChar    Insert a character
   176         */
   220         */
   177         void InsertChar(THistoryType aHistoryType, const TChar aChar, TBool aIsEmotion);
   221         void InsertChar(THistoryType aHistoryType, const TChar aChar);
   178 
   222 
   179     private:
   223     private:
   180         /**
   224         /**
   181         * C++ default constructor.
   225         * C++ default constructor.
   182         * @since 2.8
   226         * @since 2.8
   212 
   256 
   213 // ----------------------------------------------------------------------------
   257 // ----------------------------------------------------------------------------
   214 // Navi button class definition
   258 // Navi button class definition
   215 // ----------------------------------------------------------------------------
   259 // ----------------------------------------------------------------------------
   216 //
   260 //
   217 NONSHARABLE_CLASS(CAknSctNaviButton) : public CBase, public MCoeControlObserver
   261 NONSHARABLE_CLASS(CAknSctNaviButton) : public CBase
   218     {
   262     {
   219     public:
   263     public:
   220         static CAknSctNaviButton* NewL(const CCoeControl& aParent, TInt aButtonId, TResourceReader& reader);
   264         static CAknSctNaviButton* NewL(
       
   265             const CCoeControl& aParent,
       
   266             TInt aButtonId,
       
   267             TResourceReader& reader);
   221         ~CAknSctNaviButton();
   268         ~CAknSctNaviButton();
   222 
   269 
   223     private:
   270     private:
   224         CAknSctNaviButton(TInt aButtonId);
   271         CAknSctNaviButton(TInt aButtonId);
   225         void ConstructL(const CCoeControl& aParent, TResourceReader& reader);
   272         void ConstructL(
   226         
   273             const CCoeControl& aParent,
   227     private: // from MCoeControlObserver
   274             TResourceReader& reader);
   228         virtual void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
       
   229 
   275 
   230     public:
   276     public:
   231         void SetObserver(MCoeControlObserver* aObserver);
       
   232         void SetFocused(TBool aState);
   277         void SetFocused(TBool aState);
   233         void SetEnabled(TBool aState);
   278         void SetEnabled(TBool aState);
   234         TBool IsFocused();
   279         TBool IsFocused();
   235         TBool IsEnabled();
   280         TBool IsEnabled();
   236 
   281 
   237     public:
   282     public:
   238         CAknButton* iButtonControl;
   283         CAknButton* iButtonControl;
   239         MCoeControlObserver* iObserver;
       
   240         TInt iButtonId;
   284         TInt iButtonId;
   241         TBool iPressed;
   285         TBool iPressed;
   242         TBool iRepeat;
   286         TBool iRepeat;
       
   287     };
       
   288 
       
   289 // ----------------------------------------------------------------------------
       
   290 // Table Navi class definition
       
   291 // ----------------------------------------------------------------------------
       
   292 //
       
   293 NONSHARABLE_CLASS(CAknSctTableNavi) : public CAknControl, public MAknSctFocusHandler
       
   294     {
       
   295     public:
       
   296         CAknSctTableNavi(CAknCharMap* aCharMap, CAknCharMapExtension* aExtension);
       
   297         ~CAknSctTableNavi();
       
   298 
       
   299     public:  // from CCoeControl
       
   300         TInt CountComponentControls() const;
       
   301         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   302         virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode);
       
   303         void ConstructFromResourceL(TResourceReader& aReader);
       
   304         virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   305         virtual TSize MinimumSize();
       
   306         virtual void SizeChanged();
       
   307 
       
   308     public: // from MAknSctFocusHandler
       
   309         virtual CCoeControl* FocusedControl();
       
   310         virtual TBool EnterControl(TInt aX, TInt aY);
       
   311         virtual void MoveFocus(TInt aX, TInt aY);
       
   312         virtual TBool ExitWithKey(TInt aKeycode);
       
   313         virtual TBool LeaveControl();
       
   314 
       
   315     public:
       
   316         TInt TableCount();
       
   317         void TableExitL();
       
   318         static TInt DoTableExit(TAny* aThis);
       
   319         void UpdateNextTableButtonL();
       
   320 
       
   321     private:
       
   322         TInt ButtonPosition(TInt aButtonIndex) const;
       
   323         TInt SetStatusChanged();
       
   324         void NextTableL();
       
   325 
       
   326     private:  // data
       
   327         TInt iButtonIndex;
       
   328         RPointerArray<CAknSctNaviButton> iButtonArray;
       
   329         CAknCharMap* iCharMap;
       
   330         CAknCharMapExtension* iExtension;
       
   331         CIdle *iIdle;
       
   332         
       
   333         TInt iPressedButtonIndex;
   243     };
   334     };
   244 
   335 
   245 // ----------------------------------------------------------------------------
   336 // ----------------------------------------------------------------------------
   246 // Navigator class definition
   337 // Navigator class definition
   247 // ----------------------------------------------------------------------------
   338 // ----------------------------------------------------------------------------
   273         virtual TBool EnterControl(TInt aX, TInt aY);
   364         virtual TBool EnterControl(TInt aX, TInt aY);
   274         virtual void MoveFocus(TInt aX, TInt aY);
   365         virtual void MoveFocus(TInt aX, TInt aY);
   275         virtual TBool ExitWithKey(TInt aKeycode);
   366         virtual TBool ExitWithKey(TInt aKeycode);
   276         virtual TBool LeaveControl();
   367         virtual TBool LeaveControl();
   277 
   368 
   278     public:
       
   279         void UpdateNextTableButtonL();
       
   280         TInt LastButton() const;
       
   281         
       
   282     private:
   369     private:
   283         void MoveFocus(TBool aInternalMove, TInt aX, TInt aY );
       
   284         TBool IsNextButton() const;
   370         TBool IsNextButton() const;
   285         TBool CalcNextStep( TUint aKey, TInt& aX, TInt& aY );
       
   286         void TableExitL();
       
   287         static TInt TableExitCallBackL(TAny* aThis);
       
   288         void DoTableExitL();
       
   289         
       
   290         void NextTableL();
       
   291         static TInt NextTableCallBackL(TAny* aThis);
       
   292         void DoNextTableL();
       
   293 
   371 
   294     private:  // data
   372     private:  // data
   295         TInt iButtonIndex;
   373         TInt iButtonIndex;
   296         RPointerArray<CAknSctNaviButton> iButtonArray;
   374         RPointerArray<CAknSctNaviButton> iButtonArray;
   297         CAknCharMap* iCharMap;
   375         CAknCharMap* iCharMap;
   298         CAknCharMapExtension* iExtension;
   376         CAknCharMapExtension* iExtension;
   299         CEikLabel* iTitle;
   377         CEikLabel* iTitle;
   300         CIdle *iIdle;
       
   301     };
   378     };
       
   379 
   302 // ----------------------------------------------------------------------------
   380 // ----------------------------------------------------------------------------
   303 // Category button class defintion
   381 // Category button class defintion
   304 // ----------------------------------------------------------------------------
   382 // ----------------------------------------------------------------------------
   305 //
   383 //
   306 class CAknSctCategoryButton : public CBase
   384 class CAknSctCategoryButton : public CBase
   332 
   410 
   333 // ----------------------------------------------------------------------------
   411 // ----------------------------------------------------------------------------
   334 // Radio button class defintion
   412 // Radio button class defintion
   335 // ----------------------------------------------------------------------------
   413 // ----------------------------------------------------------------------------
   336 //
   414 //
   337 // stay for BC
   415 class CAknSctRadioButton : public CAknControl, public MAknSctFocusHandler
   338 class CAknSctRadioButton : public CAknControl
   416     {
   339     {
   417     public:
       
   418         enum TAknSctRadioButtonFlags
       
   419             {
       
   420             EAknSctRadioButtonResize = 0x1,
       
   421             EAknSctRadioButtonEnd
       
   422             };
   340     public:
   423     public:
   341         CAknSctRadioButton();
   424         CAknSctRadioButton();
       
   425         CAknSctRadioButton(CAknCharMap* aCharMap,
       
   426                            CAknCharMapExtension* aExtension);
   342         ~CAknSctRadioButton();
   427         ~CAknSctRadioButton();
       
   428     public: // from MAknSctFocusHandler
       
   429         virtual CCoeControl* FocusedControl();
       
   430         virtual TBool EnterControl(TInt aX, TInt aY);
       
   431         virtual void MoveFocus(TInt aX, TInt aY);
       
   432         virtual TBool ExitWithKey(TInt aKeycode);
       
   433         virtual TBool LeaveControl();
       
   434 
       
   435     public:  // from CCoeControl
       
   436         TInt CountComponentControls() const;
       
   437         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   438         virtual TKeyResponse OfferKeyEventL(
       
   439             const TKeyEvent& aKeyEvent, TEventCode);
       
   440         void ConstructFromResourceL(TResourceReader& aReader);
       
   441 
       
   442         /**
       
   443          * This function handles pointer events directed at the charmapdialog.
       
   444          * @param aPointerEvent The pointer event directed at the charmapdialog.
       
   445          */
       
   446         virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   447 
       
   448         virtual TSize MinimumSize();
       
   449         virtual void SizeChanged();
       
   450         virtual void Draw(const TRect& aRect) const;
       
   451 
       
   452     public:  // New function
       
   453         // The number of Buttons
       
   454         inline TInt Count() const;
       
   455 
       
   456         void SetCurrentCategory(TInt aCategory);
       
   457         void SetValidSctCase(TInt aSctCase);
       
   458         void RemoveInvalidButton();
   343 
   459 
   344     private:  // data
   460     private:  // data
   345         RPointerArray<CAknSctCategoryButton> iButtonArray;
   461         RPointerArray<CAknSctCategoryButton> iButtonArray;
       
   462         MCoeControlObserver* iObserver;
       
   463         TInt iFlags;
       
   464         CAknCharMapExtension* iExtension;
       
   465         CAknCharMap* iCharMap;
       
   466         TInt iButtonIndex;
       
   467         TInt iEntryIndex;
   346     };
   468     };
   347 
       
   348 CAknSctRadioButton::CAknSctRadioButton()
       
   349     {
       
   350     }
       
   351 
       
   352 CAknSctRadioButton::~CAknSctRadioButton()
       
   353     {
       
   354     iButtonArray.ResetAndDestroy();
       
   355     iButtonArray.Close();
       
   356     }
       
   357 
       
   358 // end of CAknSctRadioButton class definition
   469 // end of CAknSctRadioButton class definition
   359 
   470 
   360 // ----------------------------------------------------------------------------
   471 // ----------------------------------------------------------------------------
   361 // Extension class defintion
   472 // Extension class defintion
   362 // ----------------------------------------------------------------------------
   473 // ----------------------------------------------------------------------------
   363 //
   474 //
   364 NONSHARABLE_CLASS(CAknCharMapExtension) : 
   475 NONSHARABLE_CLASS(CAknCharMapExtension) : 
   365     public CBase,
   476     public CBase,
   366     public MObjectProvider,
   477     public MObjectProvider,
   367     public MAknSctFocusHandler,
   478     public MAknSctFocusHandler,
   368     public MAknSmileyObserver
   479     public MSmileyIconObserver
   369     {
   480     {
   370     public:
   481     public:
   371         CAknCharMapExtension();
   482         CAknCharMapExtension();
   372         ~CAknCharMapExtension();
   483         ~CAknCharMapExtension();
   373 
   484 
   385     protected:
   496     protected:
   386         TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
   497         TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
   387         MObjectProvider* MopNext();
   498         MObjectProvider* MopNext();
   388         
   499         
   389     private: // from MSmileyIconObserver
   500     private: // from MSmileyIconObserver
   390         virtual void SmileyStillImageLoaded(CAknSmileyIcon* aSmileyIcon);
   501         virtual void ThumbnailLoaded(CSmileyIcon* aSmileyIcon);
   391         virtual void SmileyAnimationChanged(CAknSmileyIcon* aSmileyIcon);
   502         virtual void AnimationChanged(CSmileyIcon* aSmileyIcon);
   392         
   503         
   393     public:
   504     public:
   394         TBool IsEmotionEnabled() const;
   505         TBool IsEmotionEnabled() const;
   395         TBool IsShowingEmotion() const;
   506         TBool IsShowingEmotion() const;
   396         void SwitchEmotionVisibilityL();
       
   397         TBool NeedEmotionSwitchIcon() const;
   507         TBool NeedEmotionSwitchIcon() const;
   398         HBufC* ReadEmotionHBufCL();
   508         HBufC* ReadEmotionHBufCL();
   399         void LoadEmotionTumbnails(const TDesC& aText);
   509         void LoadEmotionTumbnails(const TDesC& aSctChars);
   400         void PlayAnimationL(const TDesC& aText);
       
   401         void StopAnimation(const TDesC& aText);
       
   402         void SetEmotionSize(const TSize& aSize);
   510         void SetEmotionSize(const TSize& aSize);
   403         TBool IsEmotionChar(TChar aChar);
   511 
   404         TChar SwitchToSctChar();
   512         CSmileyIcon* EmotionIcon(TChar aEmotionChar);
   405         TChar SwitchToEmotionChar();
   513         TBool DrawEmotion(CWindowGc& aGc, const TRect& aRect, TChar aEmotionChar);
   406         CAknSmileyIcon* EmotionIcon(TChar aChar);
       
   407         const TDesC& EmotionText(TChar aChar);
       
   408         TBool DrawEmotion(CWindowGc& aGc, const TRect& aRect, CAknSmileyIcon* aSmileyIcon);
       
   409         void HandleFocusStatusChanged(TChar aChar, TBool aIsFocused);
   514         void HandleFocusStatusChanged(TChar aChar, TBool aIsFocused);
   410 
   515 
   411     public: // data
   516     public: // data
   412         MCoeControlObserver *iObserver;
   517         MCoeControlObserver *iObserver;
   413         HBufC* iCharsQwerty;
   518         HBufC* iCharsQwerty;
   421         TBool iKeyOkEvent; // ETrue is set after pressing OK Key
   526         TBool iKeyOkEvent; // ETrue is set after pressing OK Key
   422 
   527 
   423         // FeatureManager
   528         // FeatureManager
   424         TBool iPictographsBuffer;         // ETrue means Picto is valid.
   529         TBool iPictographsBuffer;         // ETrue means Picto is valid.
   425         TBool iPictographsBufferGrouping; // ETrue means Picto grouping is valid.
   530         TBool iPictographsBufferGrouping; // ETrue means Picto grouping is valid.
       
   531         TBool iJapaneseSctUi;       // Title and Softkey for Japanese varinat
       
   532         TBool iHasCategoryButtonUi; // Has Category button UI
       
   533         CAknSctRadioButton* iRadioButton;
   426         TInt  iCurrentCategory;     // defined enum TAknSCTCategoryButton on avkon.hrh
   534         TInt  iCurrentCategory;     // defined enum TAknSCTCategoryButton on avkon.hrh
   427 
   535 
   428         // QHD layout.
   536         // QHD layout.
   429         CAknCharMap* iCharMapProxy;
   537         CAknCharMap* iCharMapProxy;
   430         MAknSctFocusHandler* iFocusHandler;
   538         MAknSctFocusHandler* iFocusHandler;
       
   539         CAknSctTableNavi* iTableNavi;
   431         CAknSctPageNavi* iPageNavi;
   540         CAknSctPageNavi* iPageNavi;
   432         HBufC* iEntryBuf;
   541         HBufC* iEntryBuf;
   433         CEikLabel* iCategoryTitle;
   542         CEikLabel* iCategoryTitle;
   434         CEikLabel* iCategoryEntry;
   543         CEikLabel* iCategoryEntry;
   435         TBool iSelectAllowed;
   544         TBool iSelectAllowed;
   438         // Focus scrolling is disabled if kinetic scrolling is used.
   547         // Focus scrolling is disabled if kinetic scrolling is used.
   439         TBool iKineticScrolling;
   548         TBool iKineticScrolling;
   440         // Indicates whether menu sct is highlighted or not.
   549         // Indicates whether menu sct is highlighted or not.
   441         TBool iMenuSctHighlighted;
   550         TBool iMenuSctHighlighted;
   442         
   551         
   443         // flag for focus status of char map dialog
       
   444         TBool iCharMapFocusGained;
       
   445         
       
   446     public: // for Emotion
   552     public: // for Emotion
   447         HBufC* iCharsSmiley;
   553         HBufC* iCharsSmiley;
   448         CSmileyModel* iSmileyModel;
   554         CSmileyModel iSmileyModel;
   449         TChar iLastFocusedSmileyChar;
   555         TChar iLastFocusedSmileyChar;
   450         TBool iIsShowingEmotion;
   556         TBool iIsShowingEmotion;
   451         TBool iIsEnableEmotion;
   557         TBool iIsEnableEmotion;
   452 
   558 
   453     public: // Single click        
   559     public: // Single click        
   458 
   564 
   459        /**
   565        /**
   460         * Is highlight visible
   566         * Is highlight visible
   461         */
   567         */
   462         TBool iHighlightVisible;         
   568         TBool iHighlightVisible;         
   463 
       
   464         /**
       
   465         * Is keyboard event
       
   466         */
       
   467         TBool iKeyBrdEvent;
       
   468         
       
   469     private:
       
   470         CAknSctRadioButton iForBCDoNotUse;
       
   471     };
   569     };
   472 
   570 
   473 // ----------------------------------------------------------------------------
   571 // ----------------------------------------------------------------------------
   474 // Navi button class implementation
   572 // Navi button class implementation
   475 // ----------------------------------------------------------------------------
   573 // ----------------------------------------------------------------------------
   489 
   587 
   490 void CAknSctNaviButton::ConstructL(const CCoeControl& aParent, TResourceReader& aReader)
   588 void CAknSctNaviButton::ConstructL(const CCoeControl& aParent, TResourceReader& aReader)
   491     {
   589     {
   492     iButtonControl = CAknButton::NewL(aReader);
   590     iButtonControl = CAknButton::NewL(aReader);
   493     iButtonControl->SetContainerWindowL(aParent);
   591     iButtonControl->SetContainerWindowL(aParent);
   494     iButtonControl->SetObserver(this);
       
   495     }
       
   496 
       
   497 void CAknSctNaviButton::SetObserver(MCoeControlObserver* aObserver)
       
   498     {
       
   499     iObserver = aObserver;
       
   500     }
       
   501 
       
   502 void CAknSctNaviButton::HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType)
       
   503     {
       
   504     if(iObserver) iObserver->HandleControlEventL(aControl, aEventType);
       
   505     }
   592     }
   506 
   593 
   507 CAknSctNaviButton::~CAknSctNaviButton()
   594 CAknSctNaviButton::~CAknSctNaviButton()
   508     {
   595     {
   509     delete iButtonControl;
   596     delete iButtonControl;
   510     }
   597     }
   511 
   598 
   512 void CAknSctNaviButton::SetFocused(TBool aState)
   599 void CAknSctNaviButton::SetFocused(TBool aState)
   513     {
   600     {
   514     iButtonControl->SetFocus(aState);
   601     iButtonControl->SetFocus(aState);
   515     iButtonControl->DrawDeferred();
   602     iButtonControl->DrawNow();
   516     }
   603     }
   517 
   604 
   518 void CAknSctNaviButton::SetEnabled(TBool aState)
   605 void CAknSctNaviButton::SetEnabled(TBool aState)
   519     {
   606     {
   520     iButtonControl->MakeVisible(aState);
   607     iButtonControl->MakeVisible(aState);
   526     }
   613     }
   527 
   614 
   528 TBool CAknSctNaviButton::IsEnabled()
   615 TBool CAknSctNaviButton::IsEnabled()
   529     {
   616     {
   530     return iButtonControl->IsVisible();
   617     return iButtonControl->IsVisible();
       
   618     }
       
   619 
       
   620 // ----------------------------------------------------------------------------
       
   621 // Table navi class implementation
       
   622 // ----------------------------------------------------------------------------
       
   623 //
       
   624 CAknSctTableNavi::CAknSctTableNavi(CAknCharMap* aCharMap, CAknCharMapExtension* aExtension) : 
       
   625 iCharMap(aCharMap), iExtension(aExtension)
       
   626     {
       
   627     }
       
   628 
       
   629 CAknSctTableNavi::~CAknSctTableNavi()
       
   630     {
       
   631     if (iButtonArray.Count())
       
   632         {
       
   633         iButtonArray.ResetAndDestroy();
       
   634         }
       
   635     iButtonArray.Close();
       
   636     delete iIdle;
       
   637     }
       
   638 
       
   639 TInt CAknSctTableNavi::CountComponentControls() const
       
   640     {
       
   641     return iButtonArray.Count();
       
   642     }
       
   643 
       
   644 CCoeControl* CAknSctTableNavi::ComponentControl( TInt aIndex ) const
       
   645     {
       
   646     CCoeControl* rtn;
       
   647     if (aIndex < iButtonArray.Count())
       
   648         {
       
   649         rtn = iButtonArray[aIndex]->iButtonControl;
       
   650         }
       
   651     else
       
   652         {
       
   653         rtn = NULL;
       
   654         }
       
   655     return rtn;
       
   656     }
       
   657 
       
   658 TKeyResponse CAknSctTableNavi::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aModifiers)
       
   659     {
       
   660     CAknSctNaviButton* buttonObj = iButtonArray[iButtonIndex];
       
   661     buttonObj->iButtonControl->OfferKeyEventL(aKeyEvent,aModifiers);
       
   662     TKeyResponse response = EKeyWasNotConsumed;
       
   663     TUint code=aKeyEvent.iCode;
       
   664     switch (code)
       
   665         {
       
   666         case EKeyEnter:
       
   667         case EKeyOK:
       
   668             {
       
   669             switch (buttonObj->iButtonId)
       
   670                 {
       
   671                 case EAknSctTableNaviExit:
       
   672                     {
       
   673                     iExtension->iKeyOkEvent = ETrue;
       
   674                     TableExitL();
       
   675                     response = EKeyWasConsumed;
       
   676                     }
       
   677                     break;
       
   678                 // add all supported table types here.
       
   679                 case EAknSctTableNaviSpecialChar:
       
   680                 case EAknSctTableNaviEmotion:
       
   681                     {
       
   682                     NextTableL();
       
   683                     response = EKeyWasConsumed;
       
   684                     }
       
   685                     break;
       
   686                 default:
       
   687                     break;
       
   688                 }
       
   689             }
       
   690             break;
       
   691         case EKeyLeftArrow:
       
   692         case '4':
       
   693             {
       
   694             MoveFocus(-1,0);
       
   695             response = EKeyWasConsumed;
       
   696             }
       
   697             break;
       
   698         case EKeyRightArrow:
       
   699         case '6':
       
   700             {
       
   701             MoveFocus(1,0);
       
   702             response = EKeyWasConsumed;
       
   703             }
       
   704             break;
       
   705         case EKeyUpArrow:
       
   706         case '2':
       
   707             {
       
   708             response = EKeyWasConsumed;
       
   709             if ((iButtonIndex==0) && !Layout_Meta_Data::IsLandscapeOrientation())
       
   710                 {
       
   711                 // Left page button.
       
   712                 if (iExtension->iPageNavi && iExtension->iPageNavi->EnterControl(0,0))
       
   713                     {
       
   714                     LeaveControl();
       
   715                     }
       
   716                 }
       
   717             else
       
   718                 {
       
   719                 // Last radio button.
       
   720                 if ((iButtonIndex==0) && iExtension->iRadioButton)
       
   721                     {
       
   722                     if (iExtension->iRadioButton->EnterControl(0,iExtension->iRadioButton->Count()-1))
       
   723                         {
       
   724                         LeaveControl();
       
   725                         }
       
   726                     break;
       
   727                     }
       
   728 
       
   729                 // Grid bottom row.
       
   730                 TInt xPos = ButtonPosition(iButtonIndex);
       
   731                 if (iCharMap->ColMax(0) > iCharMap->ColMax(xPos))
       
   732                     {
       
   733                     xPos = iCharMap->RowMax(iCharMap->ColMax(0));
       
   734                     }
       
   735 
       
   736                 if (iExtension->EnterControl(xPos,iCharMap->ColMax(xPos)))
       
   737                     {
       
   738                     LeaveControl();
       
   739                     break;
       
   740                     }
       
   741                 }
       
   742             }
       
   743             break;
       
   744             
       
   745         case EKeyDownArrow:
       
   746         case '8':
       
   747             {
       
   748             response = EKeyWasConsumed;
       
   749             
       
   750             // First radio button.
       
   751             if ((iButtonIndex==0) && iExtension->iRadioButton)
       
   752                 {
       
   753                 if (iExtension->iRadioButton->EnterControl(0,0))
       
   754                     {
       
   755                     LeaveControl();
       
   756                     }
       
   757                 break;
       
   758                 }
       
   759             
       
   760             // Grid top row.
       
   761             TInt xPos = ButtonPosition(iButtonIndex);
       
   762             if (iExtension->EnterControl(xPos,iCharMap->ColMin(xPos)))
       
   763                 {
       
   764                 LeaveControl();
       
   765                 break;
       
   766                 }
       
   767             }
       
   768             break;
       
   769             
       
   770         default:
       
   771             break;
       
   772         }
       
   773     return response;
       
   774     }
       
   775 
       
   776 void CAknSctTableNavi::TableExitL()
       
   777     {
       
   778     delete iIdle;
       
   779     iIdle = 0;
       
   780     iIdle = CIdle::NewL(CActive::EPriorityIdle);
       
   781     iIdle->Start(TCallBack(DoTableExit, this));
       
   782     }
       
   783 
       
   784 TInt CAknSctTableNavi::DoTableExit(TAny* aThis)
       
   785     {
       
   786     return ((CAknSctTableNavi*)aThis)->SetStatusChanged();
       
   787     }
       
   788 
       
   789 TInt CAknSctTableNavi::ButtonPosition(TInt aButtonIndex) const
       
   790     {
       
   791     // buttons behind the 1th are behavior as one button
       
   792     return (aButtonIndex==0) ? 0 : 1;
       
   793     }
       
   794 
       
   795 TInt CAknSctTableNavi::SetStatusChanged()
       
   796     {
       
   797     TRAPD(err, iCharMap->SetStatusChanged(EAknCharSelectedTableExitButton));
       
   798     return err;
       
   799     }
       
   800 
       
   801 void CAknSctTableNavi::NextTableL()
       
   802     {
       
   803     iCharMap->SetStatusChanged(EAknCharSelectedNextTableButton);
       
   804     }
       
   805 
       
   806 void CAknSctTableNavi::ConstructFromResourceL(TResourceReader& aReader)
       
   807     {
       
   808     // Table navi buttons.
       
   809     TInt counts = aReader.ReadInt16();
       
   810     for (TInt i = 0; i < counts; i++)
       
   811         {
       
   812         TInt buttonId = aReader.ReadInt16();
       
   813         TInt resId = aReader.ReadInt32();
       
   814         TResourceReader buttonReader;
       
   815         iCoeEnv->CreateResourceReaderLC(buttonReader, resId);
       
   816         CAknSctNaviButton* buttonObj = CAknSctNaviButton::NewL(*this, buttonId, buttonReader);
       
   817         iButtonArray.Append(buttonObj);
       
   818         CleanupStack::PopAndDestroy(); // buttonReader
       
   819         }
       
   820     }
       
   821 
       
   822 void CAknSctTableNavi::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   823     {
       
   824     if (AknLayoutUtils::PenEnabled() && Rect().Contains(aPointerEvent.iPosition))
       
   825         {
       
   826         if (aPointerEvent.iType == TPointerEvent::EButton1Down)
       
   827             {
       
   828             iPressedButtonIndex = -1;
       
   829             
       
   830             for (TInt index = 0; index < iButtonArray.Count(); index++)
       
   831                 {
       
   832                 CAknSctNaviButton* buttonObj = iButtonArray[index];
       
   833                 if(buttonObj->IsEnabled())
       
   834                     {
       
   835                     TRect buttonRect = buttonObj->iButtonControl->Rect();
       
   836                     if (buttonRect.Contains(aPointerEvent.iPosition))
       
   837                         {
       
   838                         iPressedButtonIndex = index;
       
   839                         }
       
   840                     }
       
   841                 }
       
   842             }
       
   843         else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
       
   844             {
       
   845             if(iPressedButtonIndex >= 0)
       
   846                 {
       
   847                 CAknSctNaviButton* buttonObj = iButtonArray[iPressedButtonIndex];
       
   848                 if(buttonObj->IsEnabled())
       
   849                     {
       
   850                     iButtonIndex = iPressedButtonIndex;
       
   851                     
       
   852                     TRect buttonRect = buttonObj->iButtonControl->Rect();
       
   853                     if (buttonRect.Contains(aPointerEvent.iPosition))
       
   854                         {
       
   855                         switch (buttonObj->iButtonId)
       
   856                             {
       
   857                             case EAknSctTableNaviExit:
       
   858                                 {
       
   859                                 iExtension->iKeyOkEvent = ETrue;
       
   860                                 TableExitL();
       
   861                                 }
       
   862                                 return;
       
   863                                 
       
   864                             case EAknSctTableNaviSpecialChar:
       
   865                             case EAknSctTableNaviEmotion:
       
   866                                 {
       
   867                                 NextTableL();
       
   868                                 }
       
   869                                 return;
       
   870                                 
       
   871                             default:
       
   872                                 break;
       
   873                             }
       
   874                         }
       
   875                     }
       
   876                 }
       
   877             }
       
   878         }
       
   879     
       
   880     CCoeControl::HandlePointerEventL(aPointerEvent);
       
   881     }
       
   882 
       
   883 TSize CAknSctTableNavi::MinimumSize()
       
   884     {
       
   885     return Rect().Size();
       
   886     }
       
   887 
       
   888 void CAknSctTableNavi::SizeChanged()
       
   889     {
       
   890     if (iButtonArray.Count()>0)
       
   891         {
       
   892 
       
   893         TInt ctrlVariety = 2;
       
   894         TInt cellVariety = 1;
       
   895         if(!iCharMap->IsJapaneseSctUi())
       
   896             {
       
   897             ctrlVariety = (iCharMap->TableCount()>1) ? 0 : 1;
       
   898             cellVariety = 0;
       
   899             }
       
   900         
       
   901         TAknLayoutRect cellLayRect, buttonLayRect;
       
   902         TRect buttonRect;
       
   903 
       
   904         // Table exit.
       
   905         cellLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(ctrlVariety,0));
       
   906         buttonLayRect.LayoutRect(cellLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(cellVariety));
       
   907         buttonRect = buttonLayRect.Rect();
       
   908 
       
   909         TAknLayoutRect iconLayRect;
       
   910         iconLayRect.LayoutRect(buttonRect, AknLayoutScalable_Avkon::cell_graphic2_control_pane_g1(cellVariety));
       
   911         TSize iconSize = iconLayRect.Rect().Size();
       
   912 
       
   913         CAknSctNaviButton* buttonObj = iButtonArray[0];
       
   914         buttonObj->iButtonControl->SetRect(buttonRect);
       
   915         buttonObj->iButtonControl->SetHighlightRect(buttonRect);
       
   916         buttonObj->iButtonControl->SetIconScaleMode(EAspectRatioPreserved);
       
   917         buttonObj->iButtonControl->SetIconSize(iconSize);
       
   918         buttonObj->SetEnabled(ETrue);
       
   919 
       
   920         // Table change.
       
   921         if (iCharMap->TableCount() > 1)
       
   922             {
       
   923             cellLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(ctrlVariety,1));
       
   924             buttonLayRect.LayoutRect(cellLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(cellVariety));
       
   925             buttonRect = buttonLayRect.Rect();
       
   926             
       
   927             for (TInt i(1); i<iButtonArray.Count(); i++)
       
   928                 {
       
   929                 CAknSctNaviButton* buttonObj = iButtonArray[i];
       
   930                 buttonObj->iButtonControl->SetRect(buttonRect);
       
   931                 buttonObj->iButtonControl->SetHighlightRect(buttonRect);
       
   932                 buttonObj->iButtonControl->SetIconScaleMode(EAspectRatioPreserved);
       
   933                 buttonObj->iButtonControl->SetIconSize(iconSize);
       
   934                 buttonObj->SetEnabled(ETrue);
       
   935                 }
       
   936             }
       
   937 
       
   938         TRAP_IGNORE(UpdateNextTableButtonL());
       
   939         }
       
   940     }
       
   941 
       
   942 
       
   943 void CAknSctTableNavi::UpdateNextTableButtonL()
       
   944     {
       
   945     
       
   946     TBool isFocused = EFalse;
       
   947     
       
   948     // table switch buttons stay in one place.
       
   949     for(TInt index(1); index<iButtonArray.Count(); index++)
       
   950         {
       
   951         CAknSctNaviButton* buttonObj = iButtonArray[index];
       
   952         if(buttonObj->IsEnabled())
       
   953             {
       
   954             isFocused = buttonObj->IsFocused();
       
   955             }
       
   956         }
       
   957     
       
   958     // fresh focused button
       
   959     for (TInt index(1); index<iButtonArray.Count(); index++)
       
   960         {
       
   961         CAknSctNaviButton* buttonObj = iButtonArray[index];
       
   962         if (iCharMap->TableCount() > 1)
       
   963             {
       
   964             switch (iCharMap->NextTableCase())
       
   965                 {
       
   966                 case EAknCharMapTableSpecialChar:
       
   967                     {
       
   968                     TBool isShown = EFalse;
       
   969                     if(iExtension->IsShowingEmotion())
       
   970                         {
       
   971                         isShown = (buttonObj->iButtonId==EAknSctTableNaviSpecialChar);
       
   972                         }
       
   973                     else
       
   974                         {
       
   975                         isShown = (buttonObj->iButtonId==EAknSctTableNaviEmotion);
       
   976                         }
       
   977                     buttonObj->SetEnabled(isShown);
       
   978                     buttonObj->SetFocused(isShown && isFocused);
       
   979                     if(isShown && isFocused)
       
   980                         {
       
   981                         iButtonIndex = index;
       
   982                         }
       
   983                     }
       
   984                     break;
       
   985 
       
   986                 default:
       
   987                     buttonObj->SetEnabled(EFalse);
       
   988                     break;
       
   989                 }
       
   990             }
       
   991         else
       
   992             {
       
   993             buttonObj->SetEnabled(EFalse);
       
   994             }
       
   995         }
       
   996     }
       
   997 
       
   998 CCoeControl* CAknSctTableNavi::FocusedControl()
       
   999     {
       
  1000     return this;
       
  1001     }
       
  1002 
       
  1003 TBool CAknSctTableNavi::EnterControl(TInt aX, TInt /*aY*/)
       
  1004     {
       
  1005     if (IsVisible())
       
  1006         {
       
  1007         if ((aX >= 0) && (aX < iButtonArray.Count()))
       
  1008             {
       
  1009             TInt index = aX;
       
  1010             if (AknLayoutUtils::LayoutMirrored()) // reverse.
       
  1011                 {
       
  1012                 index = (iButtonArray.Count() - 1) - aX;
       
  1013                 }
       
  1014 
       
  1015             index = ButtonPosition(index);
       
  1016 
       
  1017             for(; index<iButtonArray.Count(); index++)
       
  1018                 {
       
  1019                 CAknSctNaviButton* buttonObj = iButtonArray[index];
       
  1020                 if (buttonObj->IsEnabled())
       
  1021                     {
       
  1022                     iButtonIndex = index;
       
  1023                     iExtension->iFocusHandler = this;
       
  1024                     buttonObj->SetFocused(ETrue);
       
  1025                     return ETrue;
       
  1026                     }
       
  1027                 }
       
  1028             }
       
  1029         }
       
  1030     return EFalse;
       
  1031     }
       
  1032 
       
  1033 void CAknSctTableNavi::MoveFocus(TInt aX, TInt /*aY*/)
       
  1034     {
       
  1035     TInt delta = aX;
       
  1036     if (AknLayoutUtils::LayoutMirrored()) // reverse.
       
  1037         {
       
  1038         delta = -aX;
       
  1039         }
       
  1040 
       
  1041     TInt buttonIndex = iButtonIndex + delta;
       
  1042 
       
  1043     // loop until find next position
       
  1044     for (TInt i = 0; i < iButtonArray.Count(); i++)
       
  1045         {
       
  1046 
       
  1047         if (buttonIndex > iButtonArray.Count() - 1) // goto Next control
       
  1048             {
       
  1049             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1050                 {
       
  1051                 // First radio button.
       
  1052                 if (iExtension->iRadioButton)
       
  1053                     {
       
  1054                     if (iExtension->iRadioButton->EnterControl(0,0))
       
  1055                         {
       
  1056                         LeaveControl();
       
  1057                         }
       
  1058                     break;
       
  1059                     }
       
  1060                 // Grid start.
       
  1061                 if (iExtension->EnterControl(0,iCharMap->ColMin(0)))
       
  1062                     {
       
  1063                     LeaveControl();
       
  1064                     }
       
  1065                 }
       
  1066             else
       
  1067                 {
       
  1068                 // Left page button.
       
  1069                 if (iExtension->iPageNavi &&
       
  1070                     iExtension->iPageNavi->EnterControl(0,0))
       
  1071                     {
       
  1072                     LeaveControl();
       
  1073                     }
       
  1074                 }
       
  1075             break;
       
  1076             }
       
  1077 
       
  1078         else if (buttonIndex < 0) // goto Prev control
       
  1079             {
       
  1080             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1081                 {
       
  1082                 // Right page button.
       
  1083                 if (iExtension->iPageNavi &&
       
  1084                     iExtension->iPageNavi->EnterControl(1,0))
       
  1085                     {
       
  1086                     LeaveControl();
       
  1087                     }
       
  1088                 }
       
  1089             else
       
  1090                 {
       
  1091                 // Grid end.
       
  1092                 TInt posY = iCharMap->ColMax(0);
       
  1093                 if (iExtension->EnterControl(iCharMap->RowMax(posY),posY))
       
  1094                     {
       
  1095                     LeaveControl();
       
  1096                     }
       
  1097                 }
       
  1098             break;
       
  1099             }
       
  1100 
       
  1101         if (iButtonArray[buttonIndex]->IsEnabled()) // goto next button in This control
       
  1102             {
       
  1103             CAknSctNaviButton* buttonObj;
       
  1104             buttonObj = iButtonArray[iButtonIndex];
       
  1105             buttonObj->SetFocused(EFalse);
       
  1106             iButtonIndex = buttonIndex;
       
  1107             buttonObj = iButtonArray[iButtonIndex];
       
  1108             buttonObj->SetFocused(ETrue);
       
  1109             break;
       
  1110             }
       
  1111         
       
  1112         buttonIndex += (delta < 0) ? -1 : 1; // get next position
       
  1113         }
       
  1114     }
       
  1115 
       
  1116 TBool CAknSctTableNavi::LeaveControl()
       
  1117     {
       
  1118     for (TInt i = 0; i < iButtonArray.Count(); i++ )
       
  1119         {
       
  1120         iButtonArray[i]->SetFocused(EFalse);
       
  1121         }
       
  1122     return ETrue;
       
  1123     }
       
  1124 
       
  1125 TBool CAknSctTableNavi::ExitWithKey(TInt /*aKeycode*/)
       
  1126     {
       
  1127     if (iButtonArray[iButtonIndex]->iButtonId != EAknSctTableNaviExit)
       
  1128         {
       
  1129         return EFalse;
       
  1130         }
       
  1131     else
       
  1132         {
       
  1133         return ETrue;
       
  1134         }
   531     }
  1135     }
   532 
  1136 
   533 // ----------------------------------------------------------------------------
  1137 // ----------------------------------------------------------------------------
   534 // Page Navi class implementation
  1138 // Page Navi class implementation
   535 // ----------------------------------------------------------------------------
  1139 // ----------------------------------------------------------------------------
   548         {
  1152         {
   549         iButtonArray.ResetAndDestroy();
  1153         iButtonArray.ResetAndDestroy();
   550         }
  1154         }
   551     iButtonArray.Close();
  1155     iButtonArray.Close();
   552     delete iTitle;
  1156     delete iTitle;
   553     delete iIdle;
       
   554     }
  1157     }
   555 
  1158 
   556 TInt CAknSctPageNavi::CountComponentControls() const
  1159 TInt CAknSctPageNavi::CountComponentControls() const
   557     {
  1160     {
   558     TInt num= 0;
  1161     TInt num= 0;
   597         case EKeyEnter:
  1200         case EKeyEnter:
   598         case EKeyOK:
  1201         case EKeyOK:
   599             {
  1202             {
   600             switch (buttonObj->iButtonId)
  1203             switch (buttonObj->iButtonId)
   601                 {
  1204                 {
   602                 case EAknSctTableNaviExit:
       
   603                     {
       
   604                     iExtension->iKeyOkEvent = ETrue;
       
   605                     TableExitL();
       
   606                     }
       
   607                     break;
       
   608                 case EAknSctPageNaviPrevPage:
  1205                 case EAknSctPageNaviPrevPage:
   609                     {
  1206                     {
   610                     iCharMap->PrevPageL();
  1207                     iCharMap->PrevPageL();
   611                     }
  1208                     }
   612                     break;
  1209                     break;
   613                 case EAknSctPageNaviNextPage:
  1210                 case EAknSctPageNaviNextPage:
   614                     {
  1211                     {
   615                     iCharMap->NextPageL();
  1212                     iCharMap->NextPageL();
   616                     }
       
   617                     break;
       
   618                 // add all supported table types here.
       
   619                 case EAknSctTableNaviSpecialChar:
       
   620                 case EAknSctTableNaviEmotion:
       
   621                     {
       
   622                     NextTableL();
       
   623                     }
  1213                     }
   624                     break;
  1214                     break;
   625                 default:
  1215                 default:
   626                     return EKeyWasConsumed;
  1216                     return EKeyWasConsumed;
   627                 }
  1217                 }
   630             UpdatePageTitleL();
  1220             UpdatePageTitleL();
   631             }
  1221             }
   632             break;
  1222             break;
   633         case EKeyLeftArrow:
  1223         case EKeyLeftArrow:
   634         case '4':
  1224         case '4':
       
  1225             {
       
  1226             MoveFocus(-1,0);
       
  1227             response = EKeyWasConsumed;
       
  1228             }
       
  1229             break;
   635         case EKeyRightArrow:
  1230         case EKeyRightArrow:
   636         case '6':
  1231         case '6':
       
  1232             {
       
  1233             MoveFocus(1,0);
       
  1234             response = EKeyWasConsumed;
       
  1235             }
       
  1236             break;
   637         case EKeyUpArrow:
  1237         case EKeyUpArrow:
   638         case '2':
  1238         case '2':
       
  1239             {
       
  1240             response = EKeyWasConsumed;
       
  1241             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1242                 {
       
  1243                 if (iExtension->iRadioButton && !IsNextButton())
       
  1244                     {
       
  1245                     // Last radio button.
       
  1246                     if (iExtension->iRadioButton->EnterControl(
       
  1247                         0,iExtension->iRadioButton->Count()-1))
       
  1248                         {
       
  1249                         LeaveControl();
       
  1250                         }
       
  1251                     break;
       
  1252                     }
       
  1253                 }
       
  1254             TInt xPos;
       
  1255             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1256                 {
       
  1257                 xPos = IsNextButton() ? iCharMap->MaxCols() - 1 : 0;
       
  1258                 }
       
  1259             else
       
  1260                 {
       
  1261                 if (IsNextButton())
       
  1262                     {
       
  1263                     xPos = iCharMap->MaxCols() - 1;
       
  1264                     }
       
  1265                 else
       
  1266                     {
       
  1267                     xPos = !iExtension->iRadioButton ?
       
  1268                         iCharMap->TableCount() : iCharMap->MaxCols()-2;
       
  1269                     }
       
  1270                 }
       
  1271             if (iCharMap->ColMax(0) > iCharMap->ColMax(xPos))
       
  1272                 {
       
  1273                 xPos = iCharMap->RowMax(iCharMap->ColMax(0));
       
  1274                 }
       
  1275             // Grid bottom row.
       
  1276             if (iExtension->EnterControl(xPos,iCharMap->ColMax(xPos)))
       
  1277                 {
       
  1278                 LeaveControl();
       
  1279                 break;
       
  1280                 }
       
  1281             }
       
  1282             break;
   639         case EKeyDownArrow:
  1283         case EKeyDownArrow:
   640         case '8':
  1284         case '8':
   641             {
  1285             {
   642             TInt gridX;
       
   643             TInt gridY;
       
   644             TBool gridInvolved = CalcNextStep( code, gridX, gridY );
       
   645             MoveFocus( !gridInvolved, gridX, gridY );
       
   646             response = EKeyWasConsumed;
  1286             response = EKeyWasConsumed;
       
  1287             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1288                 {
       
  1289                 if (!IsNextButton())
       
  1290                     {
       
  1291                     // First table button.
       
  1292                     if (iExtension->iTableNavi &&
       
  1293                         iExtension->iTableNavi->EnterControl(0,0))
       
  1294                         {
       
  1295                         LeaveControl();
       
  1296                         break;
       
  1297                         }
       
  1298                     }
       
  1299                 else
       
  1300                     {
       
  1301                     // Grid top row.
       
  1302                     TInt xPos = iCharMap->MaxCols() - 1;
       
  1303                     if (iExtension->EnterControl(xPos,iCharMap->ColMin(xPos)))
       
  1304                         {
       
  1305                         LeaveControl();
       
  1306                         break;
       
  1307                         }
       
  1308                     }
       
  1309                 }
       
  1310             else
       
  1311                 {
       
  1312                 TInt xPos;
       
  1313                 if (IsNextButton())
       
  1314                     {
       
  1315                     xPos = iCharMap->MaxCols() - 1;
       
  1316                     }
       
  1317                 else
       
  1318                     {
       
  1319                     xPos = !iExtension->iRadioButton ?
       
  1320                         iCharMap->TableCount() : iCharMap->MaxCols() - 2;
       
  1321                     }
       
  1322                 // Grid top row.
       
  1323                 if (iExtension->EnterControl(xPos,iCharMap->ColMin(xPos)))
       
  1324                     {
       
  1325                     LeaveControl();
       
  1326                     break;
       
  1327                     }
       
  1328                 }
   647             }
  1329             }
   648             break;
  1330             break;
   649         default:
  1331         default:
   650             break;
  1332             break;
   651         }
  1333         }
   652     return response;
  1334     return response;
   653     }
       
   654 
       
   655 TBool CAknSctPageNavi::CalcNextStep( TUint aKey, TInt& aX, TInt& aY )
       
   656     {
       
   657     TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
   658     TBool mirrored = AknLayoutUtils::LayoutMirrored();
       
   659     TBool emotionEnabled = iExtension->IsEmotionEnabled();
       
   660     TInt scPages = iCharMap->PageCount();
       
   661     
       
   662     aX = 0;
       
   663     aY = 0;
       
   664     TInt xOffset = 0;
       
   665     TInt yOffset = 0;
       
   666     
       
   667     // Simplify key events to two variants
       
   668     switch ( aKey )
       
   669         {
       
   670         case EKeyLeftArrow:
       
   671         case '4':
       
   672             {
       
   673             xOffset = -1;
       
   674             }
       
   675             break;
       
   676         case EKeyRightArrow:
       
   677         case '6':
       
   678             {
       
   679             xOffset = 1;
       
   680             }
       
   681             break;
       
   682         case EKeyDownArrow:
       
   683         case '8':
       
   684             {
       
   685             yOffset = 1;
       
   686             }
       
   687             break;
       
   688         case EKeyUpArrow:
       
   689         case '2':
       
   690             {
       
   691             yOffset = -1;
       
   692             }
       
   693             break;
       
   694         default:
       
   695             break;
       
   696         }
       
   697 
       
   698     TInt runtimeIndex = iButtonIndex;
       
   699     if ( !emotionEnabled )
       
   700         {
       
   701         // SC/Emotion unabled, button regrouped!
       
   702         if ( ( mirrored && iButtonIndex == EAknSctPageNaviPrevPage && xOffset != 1 )
       
   703           || ( !mirrored && iButtonIndex == EAknSctPageNaviNextPage && xOffset != -1) )
       
   704             {
       
   705             runtimeIndex = iExtension->IsShowingEmotion()?EAknSctTableNaviSpecialChar:EAknSctTableNaviEmotion;
       
   706             }
       
   707         }
       
   708     // calculate when moving from PageNavi to grid, the column position
       
   709     switch ( runtimeIndex ) 
       
   710         {
       
   711         case EAknSctTableNaviExit:
       
   712             {
       
   713             aX = 0;
       
   714             if ( ( !mirrored && xOffset == -1 ) || ( mirrored && xOffset == 1 ) )
       
   715                 {
       
   716                 // Grid end
       
   717                 aY = iCharMap->ColMax(0);
       
   718                 aX = iCharMap->RowMax( aY );
       
   719                 return ETrue;
       
   720                 }
       
   721             else if ( mirrored && xOffset == -1 && scPages >= 2 )
       
   722                 {
       
   723                 xOffset = EAknSctPageNaviNextPage;
       
   724                 }
       
   725             else if ( scPages < 2 
       
   726                     && ( ( !mirrored && xOffset == 1 ) || ( mirrored && xOffset == -1 ) ) )
       
   727                 {
       
   728                 if ( !emotionEnabled )
       
   729                     {
       
   730                     // Grid start
       
   731                     aX = 0;
       
   732                     aY = iCharMap->ColMin( aX );
       
   733                     return ETrue;
       
   734                     }
       
   735                 else
       
   736                     {
       
   737                     xOffset = LastButton();
       
   738                     }
       
   739                 }
       
   740             else
       
   741                 {
       
   742                 xOffset = EAknSctTableNaviExit + xOffset;
       
   743                 }
       
   744             }
       
   745             break;
       
   746         case EAknSctPageNaviPrevPage:
       
   747             {
       
   748             aX = mirrored ? iCharMap->MaxCols()-2 : 1;
       
   749             if ( mirrored && xOffset == -1 )
       
   750                 {
       
   751                 xOffset = LastButton();
       
   752                 }
       
   753             else
       
   754                 {
       
   755                 xOffset = xOffset + EAknSctPageNaviPrevPage;
       
   756                 }
       
   757             }
       
   758             break;
       
   759         case EAknSctPageNaviNextPage:
       
   760             {
       
   761             aX = mirrored ? 1 : iCharMap->MaxCols()-2;
       
   762             if ( mirrored && xOffset == 1 )
       
   763                 {
       
   764                 xOffset = 0;
       
   765                 }
       
   766             else if ( !mirrored && xOffset == 1 )
       
   767                 {
       
   768                 xOffset = LastButton();
       
   769                 }
       
   770             else
       
   771                 {
       
   772                 xOffset = EAknSctPageNaviNextPage + xOffset;
       
   773                 }
       
   774             }
       
   775             break;
       
   776         case EAknSctTableNaviSpecialChar:
       
   777         case EAknSctTableNaviEmotion:
       
   778             {
       
   779             aX = iCharMap->MaxCols()-1;
       
   780             if ( ( !mirrored && xOffset == 1 ) || ( mirrored && xOffset == -1 ) )
       
   781                 {
       
   782                 // Grid start
       
   783                 aX = 0;
       
   784                 aY = iCharMap->ColMin( aX );
       
   785                 return ETrue;
       
   786                 }
       
   787             else if ( scPages < 2 
       
   788                     && ( ( !mirrored && xOffset == -1 ) || ( mirrored && xOffset == 1 ) ) )
       
   789                 {
       
   790                 xOffset = EAknSctTableNaviExit;
       
   791                 }
       
   792             else if ( mirrored && xOffset == 1 )
       
   793                 {
       
   794                 xOffset = EAknSctPageNaviPrevPage;
       
   795                 }
       
   796             else
       
   797                 {
       
   798                 xOffset = EAknSctPageNaviNextPage;
       
   799                 }
       
   800             }
       
   801             break;
       
   802         default:
       
   803             break;
       
   804         }
       
   805     
       
   806     if ( yOffset == 1 )
       
   807         {
       
   808         // DOWN
       
   809         aY = iCharMap->ColMin( aX );
       
   810         return ETrue;
       
   811         }
       
   812     else if ( yOffset == -1 )
       
   813         {
       
   814         // and UP
       
   815         aY = iCharMap->ColMax( aX );
       
   816         return ETrue;
       
   817         }
       
   818 
       
   819     // Return False means it's internal moving focus within Page Navi
       
   820     aX = xOffset;
       
   821     aY = 0;
       
   822     return EFalse;
       
   823     }
  1335     }
   824 
  1336 
   825 TBool CAknSctPageNavi::IsNextButton() const
  1337 TBool CAknSctPageNavi::IsNextButton() const
   826     {
  1338     {
   827     if (iButtonIndex < iButtonArray.Count() && iButtonArray[iButtonIndex])
  1339     if (iButtonIndex < iButtonArray.Count() && iButtonArray[iButtonIndex])
   841         TResourceReader oneButtonReader;
  1353         TResourceReader oneButtonReader;
   842         iCoeEnv->CreateResourceReaderLC(oneButtonReader, resId);
  1354         iCoeEnv->CreateResourceReaderLC(oneButtonReader, resId);
   843         CAknSctNaviButton* buttonObj =
  1355         CAknSctNaviButton* buttonObj =
   844             CAknSctNaviButton::NewL(*this, buttonId, oneButtonReader);
  1356             CAknSctNaviButton::NewL(*this, buttonId, oneButtonReader);
   845         buttonObj->iButtonControl->SetObserver(this); // for handling control events.
  1357         buttonObj->iButtonControl->SetObserver(this); // for handling control events.
   846         CleanupStack::PushL( buttonObj );
  1358         iButtonArray.Append(buttonObj);
   847         iButtonArray.AppendL(buttonObj);
       
   848         CleanupStack::Pop( buttonObj );
       
   849         CleanupStack::PopAndDestroy(); // oneButtonReader
  1359         CleanupStack::PopAndDestroy(); // oneButtonReader
   850         }
  1360         }
   851     iTitle = new (ELeave) CEikLabel;
  1361     iTitle = new (ELeave) CEikLabel;
   852     }
  1362     }
   853 
  1363 
   858     if (aEventType == EEventStateChanged && AknLayoutUtils::PenEnabled()) // action on key repeat
  1368     if (aEventType == EEventStateChanged && AknLayoutUtils::PenEnabled()) // action on key repeat
   859         {
  1369         {
   860         for (TInt index=0; index < iButtonArray.Count(); index++)
  1370         for (TInt index=0; index < iButtonArray.Count(); index++)
   861             {
  1371             {
   862             CAknSctNaviButton* buttonObj = iButtonArray[index];
  1372             CAknSctNaviButton* buttonObj = iButtonArray[index];
       
  1373             TRect buttonRect = buttonObj->iButtonControl->Rect();
   863             if (buttonObj->iButtonControl == aControl)
  1374             if (buttonObj->iButtonControl == aControl)
   864                 {
  1375                 {
   865                 if (buttonObj->IsEnabled() && buttonObj->iPressed)
  1376                 if (buttonObj->IsEnabled() && buttonObj->iPressed)
   866                     {
  1377                     {
   867                     iButtonIndex = index;
  1378                     iButtonIndex = index;
   871                             {
  1382                             {
   872                             buttonObj->iRepeat = ETrue; // Set button repeat.
  1383                             buttonObj->iRepeat = ETrue; // Set button repeat.
   873                             iCharMap->PrevPageL();
  1384                             iCharMap->PrevPageL();
   874                             UpdatePageTitleL();
  1385                             UpdatePageTitleL();
   875                             }
  1386                             }
   876                             return;
  1387                             break;
   877                         case EAknSctPageNaviNextPage:
  1388                         case EAknSctPageNaviNextPage:
   878                             {
  1389                             {
   879                             buttonObj->iRepeat = ETrue; // Set button repeat.
  1390                             buttonObj->iRepeat = ETrue; // Set button repeat.
   880                             iCharMap->NextPageL();
  1391                             iCharMap->NextPageL();
   881                             UpdatePageTitleL();
  1392                             UpdatePageTitleL();
   882                             }
  1393                             }
   883                             return;
  1394                             break;
   884                         default:
  1395                         default:
   885                             break;
  1396                             break;
   886                         }
  1397                         }
   887                     }
  1398                     }
   888                 }
  1399                 }
   899             for (TInt index=0; index < iButtonArray.Count(); index++)
  1410             for (TInt index=0; index < iButtonArray.Count(); index++)
   900                 {
  1411                 {
   901                 CAknSctNaviButton* buttonObj = iButtonArray[index];
  1412                 CAknSctNaviButton* buttonObj = iButtonArray[index];
   902                 buttonObj->iPressed = EFalse;
  1413                 buttonObj->iPressed = EFalse;
   903                 buttonObj->iRepeat = EFalse;
  1414                 buttonObj->iRepeat = EFalse;
   904                 TInt buttonIndex = buttonObj->iButtonId;
       
   905                 TRect buttonRect = buttonObj->iButtonControl->Rect();
  1415                 TRect buttonRect = buttonObj->iButtonControl->Rect();
   906                 if ( buttonRect.Contains(aPointerEvent.iPosition))
  1416                 if (buttonRect.Contains(aPointerEvent.iPosition))
   907                     {
  1417                     {
   908                     if (buttonObj->IsEnabled())
  1418                     if (buttonObj->IsEnabled())
   909                         {
  1419                         {
       
  1420                         buttonObj->iButtonControl->SetButtonFlags(KAknButtonKeyRepeat);
   910                         buttonObj->iPressed = ETrue; // Set button pressed.
  1421                         buttonObj->iPressed = ETrue; // Set button pressed.
   911                         if ( buttonIndex == EAknSctPageNaviPrevPage 
       
   912                           || buttonIndex == EAknSctPageNaviNextPage )
       
   913                             {
       
   914                             // Only Prev/Next button can repeat
       
   915                             buttonObj->iButtonControl->SetButtonFlags( KAknButtonKeyRepeat );
       
   916                             }
       
   917                         }
  1422                         }
   918                     }
  1423                     }
   919                 }
  1424                 }
   920             }
  1425             }
   921         else if (aPointerEvent.iType == TPointerEvent::EButton1Up) // action on button release.
  1426         else if (aPointerEvent.iType == TPointerEvent::EButton1Up) // action on button release.
   943                                     {
  1448                                     {
   944                                     iCharMap->NextPageL();
  1449                                     iCharMap->NextPageL();
   945                                     UpdatePageTitleL();
  1450                                     UpdatePageTitleL();
   946                                     }
  1451                                     }
   947                                     break;
  1452                                     break;
   948                                 case EAknSctTableNaviExit:
       
   949                                     {
       
   950                                     iExtension->iKeyOkEvent = ETrue;
       
   951                                     TableExitL();
       
   952                                     }
       
   953                                     break;
       
   954                                 case EAknSctTableNaviSpecialChar:
       
   955                                 case EAknSctTableNaviEmotion:
       
   956                                     {
       
   957                                     NextTableL();
       
   958                                     }
       
   959                                     break;
       
   960                                 default:
  1453                                 default:
   961                                     break;
  1454                                     break;
   962                                 }
  1455                                 }
   963                             }
  1456                             }
   964                         }
  1457                         }
   977     }
  1470     }
   978 
  1471 
   979 void CAknSctPageNavi::SizeChanged()
  1472 void CAknSctPageNavi::SizeChanged()
   980     {
  1473     {
   981 
  1474 
   982     TAknLayoutRect pageButtonLayRect, buttonLayRect;
  1475     TAknLayoutRect pageButtonLayRect;
   983     TInt cellVar = Layout_Meta_Data::IsLandscapeOrientation()? 3 : 2;
  1476     TInt pageVariate = !iCharMap->IsJapaneseSctUi() ? ((iCharMap->TableCount() > 1) ? 0 : 1) : 2;
   984     TInt bgVar = 2;
  1477                        
   985     TBool landScape = Layout_Meta_Data::IsLandscapeOrientation();       
       
   986     TBool emotionEnabled = ETrue;
       
   987     TBool mirrored = AknLayoutUtils::LayoutMirrored();
       
   988     CAknSctNaviButton* buttonObj;
  1478     CAknSctNaviButton* buttonObj;
   989     TRect rect;
  1479     TRect rect;
   990 
  1480 
   991     if ( iExtension )
  1481     buttonObj = iButtonArray[0];
   992         {
  1482     buttonObj->iButtonControl->SetButtonFlags(0);
   993         emotionEnabled = iExtension->IsEmotionEnabled();
  1483     if (!AknLayoutUtils::LayoutMirrored())
   994         }
  1484         {
   995     
  1485         buttonObj->iButtonId = EAknSctPageNaviPrevPage;
   996     // Prev button
  1486         pageButtonLayRect.LayoutRect(Rect(),AknLayoutScalable_Avkon::bg_button_pane_cp10(pageVariate));
       
  1487         }
       
  1488     else
       
  1489         {
       
  1490         buttonObj->iButtonId = EAknSctPageNaviNextPage;
       
  1491         pageButtonLayRect.LayoutRect(Rect(),AknLayoutScalable_Avkon::bg_button_pane_cp11(pageVariate));
       
  1492         }
       
  1493     rect = pageButtonLayRect.Rect();
       
  1494     buttonObj->iButtonControl->SetRect(rect);
       
  1495     buttonObj->iButtonControl->SetHighlightRect(rect);
       
  1496     TAknLayoutRect pageButtonIconLayRect;
       
  1497     pageButtonIconLayRect.LayoutRect(pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::graphic2_pages_pane_g1(pageVariate));
       
  1498     buttonObj->iButtonControl->SetIconScaleMode(EAspectRatioPreserved);
       
  1499     TSize iconSize = pageButtonIconLayRect.Rect().Size();
       
  1500     buttonObj->iButtonControl->SetIconSize(iconSize);
       
  1501 
   997     buttonObj = iButtonArray[1];
  1502     buttonObj = iButtonArray[1];
   998     buttonObj->iButtonControl->SetButtonFlags(0);
  1503     buttonObj->iButtonControl->SetButtonFlags(0);
   999     TInt col = 0;
  1504     if (!AknLayoutUtils::LayoutMirrored())
  1000     if ( !landScape )
  1505         {
  1001         {
  1506         buttonObj->iButtonId = EAknSctPageNaviNextPage;
  1002         col = mirrored ? ( !emotionEnabled?4:3 ) : 1;
  1507         pageButtonLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp11(pageVariate));
  1003         }
  1508         }
  1004     else
  1509     else
  1005         {
  1510         {
  1006         col = mirrored ? ( !emotionEnabled?6:5 ) : 1;
  1511         buttonObj->iButtonId = EAknSctPageNaviPrevPage;
  1007         }
  1512         pageButtonLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp10(pageVariate));
  1008     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
  1513         }
  1009     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
  1514     rect = pageButtonLayRect.Rect();
  1010     rect = buttonLayRect.Rect();
       
  1011     buttonObj->iButtonControl->SetRect(rect);
  1515     buttonObj->iButtonControl->SetRect(rect);
  1012     buttonObj->iButtonControl->SetHighlightRect(rect);
  1516     buttonObj->iButtonControl->SetHighlightRect(rect);
  1013     
  1517     buttonObj->iButtonControl->SetIconScaleMode(EAspectRatioPreserved);
  1014     // ...Prev button icon
       
  1015     TAknLayoutRect iconLayRect;
       
  1016     iconLayRect.LayoutRect(rect, AknLayoutScalable_Avkon::cell_graphic2_control_pane_g1(bgVar));
       
  1017     TSize iconSize = iconLayRect.Rect().Size();
       
  1018     buttonObj->iButtonControl->SetIconSize(iconSize);
  1518     buttonObj->iButtonControl->SetIconSize(iconSize);
  1019     
  1519 
  1020     // Next button
       
  1021     buttonObj = iButtonArray[2];
       
  1022     buttonObj->iButtonControl->SetButtonFlags(0);
       
  1023     if ( !landScape )
       
  1024         {
       
  1025         col = mirrored ? 1 : ( !emotionEnabled?4:3 );
       
  1026         }
       
  1027     else
       
  1028         {
       
  1029         col = mirrored ? 1 : ( !emotionEnabled?6:5 );
       
  1030         }
       
  1031     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
       
  1032     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
       
  1033     rect = buttonLayRect.Rect();
       
  1034     buttonObj->iButtonControl->SetRect(rect);
       
  1035     buttonObj->iButtonControl->SetHighlightRect(rect);
       
  1036     
       
  1037     // ...Next button icon
       
  1038     buttonObj->iButtonControl->SetIconSize(iconSize);
       
  1039     
       
  1040     // Exit button
       
  1041     buttonObj = iButtonArray[0];
       
  1042     buttonObj->iButtonControl->SetButtonFlags(0);
       
  1043     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,0) );
       
  1044     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
       
  1045     rect = buttonLayRect.Rect();
       
  1046     buttonObj->iButtonControl->SetRect(rect);
       
  1047     buttonObj->iButtonControl->SetHighlightRect(rect);
       
  1048     
       
  1049     // ...Exit button icon
       
  1050     buttonObj->iButtonControl->SetIconSize(iconSize);
       
  1051     
       
  1052     // Emotion/Special-char button
       
  1053     col = landScape? 6 : 4;
       
  1054     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
       
  1055     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
       
  1056     rect = buttonLayRect.Rect();
       
  1057     for ( TInt i = 3; i < iButtonArray.Count();i++ )
       
  1058         {
       
  1059         buttonObj = iButtonArray[i];
       
  1060         buttonObj->iButtonControl->SetButtonFlags(0);
       
  1061         buttonObj->iButtonControl->SetRect(rect);
       
  1062         buttonObj->iButtonControl->SetHighlightRect(rect);
       
  1063         
       
  1064         // ...its icon
       
  1065         buttonObj->iButtonControl->SetIconSize(iconSize);
       
  1066         }
       
  1067     TRAP_IGNORE(UpdateNextTableButtonL());
       
  1068     
       
  1069     // Page text.
  1520     // Page text.
  1070     col = landScape? 3 : 2;
  1521     TRect parentRect = Rect();
  1071     pageButtonLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col));
  1522     AknLayoutUtils::LayoutLabel(iTitle, parentRect, AknLayoutScalable_Avkon::graphic2_pages_pane_t1(pageVariate).LayoutLine());
  1072     TAknTextComponentLayout textlayout = AknLayoutScalable_Avkon::cell_graphic2_control_pane_t1();
       
  1073     TRect titleRect( pageButtonLayRect.Rect() );
       
  1074     if ( !emotionEnabled )
       
  1075         {
       
  1076         // start complex dynamic logic to locate title rect when emotion is unable
       
  1077         TInt orientation = mirrored ? -1 : 1;
       
  1078         TInt newLeft = titleRect.iTl.iX + orientation*rect.Width()/2;
       
  1079         TPoint titlePoint( newLeft, titleRect.iTl.iY );
       
  1080         titleRect.SetRect( titlePoint, titleRect.Size() );
       
  1081         }
       
  1082     AknLayoutUtils::LayoutLabel(iTitle, titleRect, textlayout.LayoutLine());
       
  1083 
  1523 
  1084     // Page text color
  1524     // Page text color
  1085     TAknLayoutText textLayout;
  1525     TAknLayoutText textLayout;
  1086     textLayout.LayoutText( titleRect, textlayout );
  1526     textLayout.LayoutText(parentRect, AknLayoutScalable_Avkon::graphic2_pages_pane_t1(pageVariate));
       
  1527     TRect textRect = textLayout.TextRect();
  1087     TRgb color = textLayout.Color();
  1528     TRgb color = textLayout.Color();
  1088     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  1529     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  1089     if (skin)
  1530     if (skin)
  1090         {
  1531         {
  1091         (void)AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
  1532         (void)AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
  1099     TRAP_IGNORE(UpdatePageTitleL());
  1540     TRAP_IGNORE(UpdatePageTitleL());
  1100     }
  1541     }
  1101 
  1542 
  1102 void CAknSctPageNavi::UpdatePageTitleL() const
  1543 void CAknSctPageNavi::UpdatePageTitleL() const
  1103     {
  1544     {
  1104     TInt pages = iCharMap->PageCount();
       
  1105     if ( pages < 2 )
       
  1106         {
       
  1107         iTitle->MakeVisible( EFalse );
       
  1108         return;
       
  1109         }
       
  1110     CArrayFix<TInt>* numbers = new(ELeave)CArrayFixFlat<TInt>(2);
  1545     CArrayFix<TInt>* numbers = new(ELeave)CArrayFixFlat<TInt>(2);
  1111     CleanupStack::PushL( numbers );
  1546     CleanupStack::PushL(numbers);
  1112     numbers->AppendL( iCharMap->CurrentPage() );
  1547     numbers->AppendL(iCharMap->CurrentPage());
  1113     numbers->AppendL( pages );
  1548     numbers->AppendL(iCharMap->PageCount());
  1114     HBufC* page =
  1549     HBufC* page =
  1115         StringLoader::LoadL(
  1550         StringLoader::LoadL(
  1116             R_AVKON_SPECIAL_CHARACTERS_PAGE_INDICATOR, *numbers, iEikonEnv);
  1551             R_AVKON_SPECIAL_CHARACTERS_PAGE_INDICATOR, *numbers, iEikonEnv);
  1117     CleanupStack::PopAndDestroy(); // numbers
  1552     CleanupStack::PopAndDestroy(); // numbers
  1118     iTitle->SetTextL(page->Des());
  1553     iTitle->SetTextL(page->Des());
  1125     return this;
  1560     return this;
  1126     }
  1561     }
  1127 
  1562 
  1128 TBool CAknSctPageNavi::EnterControl(TInt aX, TInt /*aY*/)
  1563 TBool CAknSctPageNavi::EnterControl(TInt aX, TInt /*aY*/)
  1129     {
  1564     {
  1130     // Note, the button index is fixed on spite of mirrored case
       
  1131     if (IsVisible())
  1565     if (IsVisible())
  1132         {
  1566         {
  1133         if ((aX >= 0) && (aX < iButtonArray.Count()))
  1567         if ((aX >= 0) && (aX < iButtonArray.Count()))
  1134             {
  1568             {
  1135             CAknSctNaviButton* buttonObj;
  1569             CAknSctNaviButton* buttonObj;
  1136             buttonObj = iButtonArray[iButtonIndex];
  1570             buttonObj = iButtonArray[iButtonIndex];
  1137             buttonObj->SetFocused(EFalse);
  1571             buttonObj->SetFocused(EFalse);
  1138             TInt index = aX;
  1572             TInt index = aX;
       
  1573             if (AknLayoutUtils::LayoutMirrored()) // reverse.
       
  1574                 {
       
  1575                 index = iButtonArray.Count() - 1 - aX;
       
  1576                 }
  1139             buttonObj = iButtonArray[index];
  1577             buttonObj = iButtonArray[index];
  1140             if (buttonObj->IsEnabled())
  1578             if (buttonObj->IsEnabled())
  1141                 {
  1579                 {
  1142                 iButtonIndex = index;
  1580                 iButtonIndex = index;
  1143                 iExtension->iFocusHandler = this;
  1581                 iExtension->iFocusHandler = this;
  1147             }
  1585             }
  1148         }
  1586         }
  1149     return EFalse;
  1587     return EFalse;
  1150     }
  1588     }
  1151 
  1589 
  1152 void CAknSctPageNavi::MoveFocus(TInt aX, TInt aY )
  1590 void CAknSctPageNavi::MoveFocus(TInt aX, TInt /*aY*/)
  1153     {
  1591     {
  1154     (void)aX;
  1592     TInt delta = aX;
  1155     (void)aY;
  1593     TInt buttonIndex = iButtonIndex + delta;
  1156     }
  1594     for (TInt i = 0; i < iButtonArray.Count(); i++)
  1157 
  1595         {
  1158 void CAknSctPageNavi::MoveFocus(TBool aInternalMove, TInt aX, TInt aY )
  1596         if (buttonIndex > iButtonArray.Count() - 1) // Next control.
  1159     {
  1597             {
  1160     if ( aInternalMove )
  1598             if (!AknLayoutUtils::LayoutMirrored())
  1161         {
  1599                 {
  1162         EnterControl( aX, 0 );
  1600                 if (!Layout_Meta_Data::IsLandscapeOrientation())
  1163         }
  1601                     {
  1164     else
  1602                     // First table button.
  1165         {
  1603                     if (iExtension->iTableNavi &&
  1166         if (iExtension->EnterControl( aX, aY ) )
  1604                         iExtension->iTableNavi->EnterControl(0,0))
  1167             {
  1605                         {
  1168             LeaveControl();
  1606                         LeaveControl();
  1169             }
  1607                         break;
       
  1608                         }
       
  1609                     }
       
  1610                 else
       
  1611                     {
       
  1612                     // First radio button.
       
  1613                     if (iExtension->iRadioButton &&
       
  1614                         iExtension->iRadioButton->EnterControl(0,0))
       
  1615                         {
       
  1616                         LeaveControl();
       
  1617                         break;
       
  1618                         }
       
  1619                     // Grid start.
       
  1620                     TInt yPos = iCharMap->ColMin(0);
       
  1621                     if (iExtension->EnterControl(iCharMap->RowMin(yPos),yPos))
       
  1622                         {
       
  1623                         LeaveControl();
       
  1624                         break;
       
  1625                         }
       
  1626                     }
       
  1627                 }
       
  1628             else
       
  1629                 {
       
  1630                 if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1631                     {
       
  1632                     // Grid end.
       
  1633                     TInt yPos = iCharMap->ColMax(0);
       
  1634                     if (iExtension->EnterControl(iCharMap->RowMax(yPos),yPos))
       
  1635                         {
       
  1636                         LeaveControl();
       
  1637                         break;
       
  1638                         }
       
  1639                     }
       
  1640                 else
       
  1641                     {
       
  1642                     // Last table button.
       
  1643                     TInt xPos = iCharMap->TableCount() - 1;
       
  1644                     if (iExtension->iTableNavi &&
       
  1645                         iExtension->iTableNavi->EnterControl(xPos,0))
       
  1646                         {
       
  1647                         LeaveControl();
       
  1648                         break;
       
  1649                         }
       
  1650                     }
       
  1651                 }
       
  1652             break;
       
  1653             }
       
  1654         else if (buttonIndex < 0) // Prev control
       
  1655             {
       
  1656             if (!AknLayoutUtils::LayoutMirrored())
       
  1657                 {
       
  1658                 if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1659                     {
       
  1660                     // Grid end.
       
  1661                     TInt yPos = iCharMap->ColMax(0);
       
  1662                     if (iExtension->EnterControl(iCharMap->RowMax(yPos),yPos))
       
  1663                         {
       
  1664                         LeaveControl();
       
  1665                         break;
       
  1666                         }
       
  1667                     }
       
  1668                 else
       
  1669                     {
       
  1670                     // Last table button.
       
  1671                     if (iExtension->iTableNavi && 
       
  1672                         iExtension->iTableNavi->EnterControl(iCharMap->TableCount()-1,0))
       
  1673                         {
       
  1674                         LeaveControl();
       
  1675                         break;
       
  1676                         }
       
  1677                     }
       
  1678                 }
       
  1679             else
       
  1680                 {
       
  1681                 if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1682                     {
       
  1683                     // First table button.
       
  1684                     if (iExtension->iTableNavi &&
       
  1685                         iExtension->iTableNavi->EnterControl(0,0))
       
  1686                         {
       
  1687                         LeaveControl();
       
  1688                         break;
       
  1689                         }
       
  1690                     }
       
  1691                 else
       
  1692                     {
       
  1693                     // Grid start.
       
  1694                     TInt yPos = iCharMap->ColMin(0);
       
  1695                     if (iExtension->EnterControl(iCharMap->RowMin(yPos),yPos))
       
  1696                         {
       
  1697                         LeaveControl();
       
  1698                         break;
       
  1699                         }
       
  1700                     }
       
  1701                 }
       
  1702             }
       
  1703 
       
  1704         if (iButtonArray[buttonIndex]->IsEnabled()) // This control
       
  1705             {
       
  1706             CAknSctNaviButton* buttonObj;
       
  1707             buttonObj = iButtonArray[iButtonIndex];
       
  1708             buttonObj->SetFocused(EFalse);
       
  1709             iButtonIndex = buttonIndex;
       
  1710             buttonObj = iButtonArray[iButtonIndex];
       
  1711             buttonObj->SetFocused(ETrue);
       
  1712             break;
       
  1713             }
       
  1714         buttonIndex += (delta < 0) ? -1 : 1;
  1170         }
  1715         }
  1171     }
  1716     }
  1172 
  1717 
  1173 TBool CAknSctPageNavi::LeaveControl()
  1718 TBool CAknSctPageNavi::LeaveControl()
  1174     {
  1719     {
  1179     return ETrue;
  1724     return ETrue;
  1180     }
  1725     }
  1181 
  1726 
  1182 TBool CAknSctPageNavi::ExitWithKey(TInt /*aKeycode*/)
  1727 TBool CAknSctPageNavi::ExitWithKey(TInt /*aKeycode*/)
  1183     {
  1728     {
  1184     if (iButtonArray[iButtonIndex]->iButtonId != EAknSctTableNaviExit)
  1729     return EFalse;
  1185         {
       
  1186         return EFalse;
       
  1187         }
       
  1188     else
       
  1189         {
       
  1190         return ETrue;
       
  1191         }
       
  1192     }
       
  1193 
       
  1194 
       
  1195 void CAknSctPageNavi::TableExitL()
       
  1196     {
       
  1197     if(!iIdle)
       
  1198         {
       
  1199         iIdle = CIdle::NewL(CActive::EPriorityStandard);
       
  1200         }
       
  1201 
       
  1202     iIdle->Cancel();
       
  1203     iIdle->Start(TCallBack(TableExitCallBackL, this));
       
  1204     }
       
  1205 
       
  1206 TInt CAknSctPageNavi::TableExitCallBackL(TAny* aThis)
       
  1207     {
       
  1208     ((CAknSctPageNavi*)aThis)->DoTableExitL();
       
  1209     return KErrNone;
       
  1210     }
       
  1211 
       
  1212 void CAknSctPageNavi::DoTableExitL()
       
  1213     {
       
  1214     iCharMap->SetStatusChanged(EAknCharSelectedTableExitButton);
       
  1215     }
       
  1216 
       
  1217 void CAknSctPageNavi::NextTableL()
       
  1218     {
       
  1219     if(!iIdle)
       
  1220         {
       
  1221         iIdle = CIdle::NewL(CActive::EPriorityStandard);
       
  1222         }
       
  1223 
       
  1224     iIdle->Cancel();
       
  1225     iIdle->Start(TCallBack(NextTableCallBackL, this));
       
  1226     }
       
  1227 
       
  1228 TInt CAknSctPageNavi::NextTableCallBackL(TAny* aThis)
       
  1229     {
       
  1230     ((CAknSctPageNavi*)aThis)->DoNextTableL();
       
  1231     return KErrNone;
       
  1232     }
       
  1233 
       
  1234 void CAknSctPageNavi::DoNextTableL()
       
  1235     {
       
  1236     iCharMap->SetStatusChanged(EAknCharSelectedNextTableButton);
       
  1237     }
       
  1238 
       
  1239 void CAknSctPageNavi::UpdateNextTableButtonL()
       
  1240     {
       
  1241     
       
  1242     TBool isFocused = EFalse;
       
  1243     
       
  1244     // table switch buttons stay in one place.
       
  1245     for(TInt index(3); index<iButtonArray.Count(); index++)
       
  1246         {
       
  1247         CAknSctNaviButton* buttonObj = iButtonArray[index];
       
  1248         if(buttonObj->IsEnabled())
       
  1249             {
       
  1250             isFocused = buttonObj->IsFocused();
       
  1251             }
       
  1252         }
       
  1253     
       
  1254     // fresh focused button
       
  1255     for (TInt index(1); index<iButtonArray.Count(); index++)
       
  1256         {
       
  1257         CAknSctNaviButton* buttonObj = iButtonArray[index];
       
  1258         if ( index == EAknSctPageNaviPrevPage 
       
  1259                || index == EAknSctPageNaviNextPage )
       
  1260             {
       
  1261             // No need to display Prev/Next
       
  1262             if ( iCharMap->PageCount() < 2 )
       
  1263                 {
       
  1264                 buttonObj->SetEnabled(EFalse);
       
  1265                 }
       
  1266             continue;
       
  1267             }
       
  1268         if (iCharMap->TableCount() > 1)
       
  1269             {
       
  1270             switch (iCharMap->NextTableCase())
       
  1271                 {
       
  1272                 case EAknCharMapTableSpecialChar:
       
  1273                     {
       
  1274                     TBool isShown = EFalse;
       
  1275                     if(iExtension->IsShowingEmotion())
       
  1276                         {
       
  1277                         isShown = (buttonObj->iButtonId==EAknSctTableNaviSpecialChar);
       
  1278                         }
       
  1279                     else
       
  1280                         {
       
  1281                         isShown = (buttonObj->iButtonId==EAknSctTableNaviEmotion);
       
  1282                         }
       
  1283                     buttonObj->SetEnabled(isShown);
       
  1284                     buttonObj->SetFocused(isShown && isFocused);
       
  1285                     if(isShown && isFocused)
       
  1286                         {
       
  1287                         iButtonIndex = index;
       
  1288                         }
       
  1289                     }
       
  1290                     break;
       
  1291 
       
  1292                 default:
       
  1293                     buttonObj->SetEnabled(EFalse);
       
  1294                     break;
       
  1295                 }
       
  1296             }
       
  1297         else
       
  1298             {
       
  1299             buttonObj->SetEnabled(EFalse);
       
  1300             }
       
  1301         }
       
  1302     }
       
  1303 
       
  1304 TInt CAknSctPageNavi::LastButton() const
       
  1305     {
       
  1306     TBool emotionEnable = iExtension->IsEmotionEnabled();
       
  1307     if ( emotionEnable )
       
  1308         {
       
  1309         return iExtension->IsShowingEmotion()?EAknSctTableNaviSpecialChar:EAknSctTableNaviEmotion;
       
  1310         }
       
  1311     else if ( iCharMap->PageCount() < 2 && !emotionEnable )
       
  1312         {
       
  1313         // Only one page, must have no SC/Emotion also, left Exit only.
       
  1314         return EAknSctTableNaviExit;
       
  1315         }
       
  1316     else
       
  1317         {
       
  1318         // emotion doesn't support, no SC/Emotion icon then
       
  1319         TBool mirrored = AknLayoutUtils::LayoutMirrored();
       
  1320         return mirrored ? EAknSctPageNaviPrevPage : EAknSctPageNaviNextPage;
       
  1321         }
       
  1322     }
  1730     }
  1323 
  1731 
  1324 // ----------------------------------------------------------------------------
  1732 // ----------------------------------------------------------------------------
  1325 // Category button class implementation
  1733 // Category button class implementation
  1326 // ----------------------------------------------------------------------------
  1734 // ----------------------------------------------------------------------------
  1363     }
  1771     }
  1364 
  1772 
  1365 void CAknSctCategoryButton::SetFocused(TBool aState)
  1773 void CAknSctCategoryButton::SetFocused(TBool aState)
  1366     {
  1774     {
  1367     iButtonControl->SetFocus(aState);
  1775     iButtonControl->SetFocus(aState);
  1368     iButtonControl->DrawDeferred();
  1776     iButtonControl->DrawNow();
  1369     }
  1777     }
  1370 
  1778 
       
  1779 
       
  1780 // ----------------------------------------------------------------------------
       
  1781 // Radio button class implementation
       
  1782 // ----------------------------------------------------------------------------
       
  1783 //
       
  1784 CAknSctRadioButton::CAknSctRadioButton()
       
  1785     {
       
  1786     }
       
  1787 
       
  1788 CAknSctRadioButton::CAknSctRadioButton(
       
  1789     CAknCharMap* aCharMap,
       
  1790     CAknCharMapExtension* aExtension)
       
  1791     :iExtension(aExtension),
       
  1792     iCharMap(aCharMap)
       
  1793     {
       
  1794     }
       
  1795 
       
  1796 CAknSctRadioButton::~CAknSctRadioButton()
       
  1797     {
       
  1798     iButtonArray.ResetAndDestroy();
       
  1799     iButtonArray.Close();
       
  1800     }
       
  1801 
       
  1802 TInt CAknSctRadioButton::CountComponentControls() const
       
  1803     {
       
  1804     return iButtonArray.Count();
       
  1805     }
       
  1806 
       
  1807 CCoeControl* CAknSctRadioButton::ComponentControl( TInt aIndex ) const
       
  1808     {
       
  1809     if (aIndex < iButtonArray.Count())
       
  1810         {
       
  1811         return iButtonArray[aIndex]->iButtonControl;
       
  1812         }
       
  1813     return NULL;
       
  1814     }
       
  1815 
       
  1816 TKeyResponse CAknSctRadioButton::OfferKeyEventL(
       
  1817     const TKeyEvent& aKeyEvent,
       
  1818     TEventCode /*aModifiers*/)
       
  1819     {
       
  1820     TKeyResponse responce = EKeyWasNotConsumed;
       
  1821     TUint code=aKeyEvent.iCode;
       
  1822     switch (code)
       
  1823         {
       
  1824         case EKeyEnter:
       
  1825         case EKeyOK:
       
  1826             {
       
  1827             if (AknLayoutUtils::PenEnabled())
       
  1828                 {
       
  1829                 // Grid.
       
  1830                 TInt yPos = iCharMap->ColMin(0);
       
  1831                 TInt xPos = iCharMap->RowMin(yPos);
       
  1832                 if (iExtension->EnterControl(xPos,yPos))
       
  1833                     {
       
  1834                     CAknButton* buttonCtrlObj;
       
  1835                     TInt currentIndex;
       
  1836                     TInt newIndex;
       
  1837                     for (TInt index=0; index < iButtonArray.Count(); index++)
       
  1838                         {
       
  1839                         buttonCtrlObj = iButtonArray[index]->iButtonControl;
       
  1840                         currentIndex = buttonCtrlObj->StateIndex();
       
  1841                         if (index == iButtonIndex)
       
  1842                             {
       
  1843                             newIndex = KAknSctRadioOn;
       
  1844                             }
       
  1845                         else
       
  1846                             {
       
  1847                             newIndex = KAknSctRadioOff;
       
  1848                             }
       
  1849                         if (currentIndex != newIndex)
       
  1850                             {
       
  1851                             buttonCtrlObj->SetCurrentState(newIndex, ETrue);
       
  1852                             if (newIndex == KAknSctRadioOn)
       
  1853                                 {
       
  1854                                 iExtension->iCurrentCategory =
       
  1855                                     iButtonArray[index]->iButtonId;
       
  1856                                 iCharMap->SetStatusChanged(EAknCharChangedCategory);
       
  1857                                 }
       
  1858                             }
       
  1859                         }
       
  1860                     LeaveControl();
       
  1861                     }
       
  1862                 }
       
  1863             responce = EKeyWasConsumed;
       
  1864             }
       
  1865             break;
       
  1866         case EKeyLeftArrow:
       
  1867         case '4':
       
  1868             {
       
  1869             responce = EKeyWasConsumed;
       
  1870             if (AknLayoutUtils::PenEnabled())
       
  1871                 {
       
  1872                 TInt yPos = iButtonIndex - 1;
       
  1873                 if (iCharMap->RowMax(yPos) < 0)
       
  1874                     {
       
  1875                     if (Layout_Meta_Data::IsLandscapeOrientation())
       
  1876                         {
       
  1877                         if (iExtension->iRadioButton)
       
  1878                             {
       
  1879                             // Right page button.
       
  1880                             if (iExtension->iPageNavi &&
       
  1881                                 iExtension->iPageNavi->EnterControl(1,0))
       
  1882                                 {
       
  1883                                 LeaveControl();
       
  1884                                 break;
       
  1885                                 }
       
  1886                             }
       
  1887                         }
       
  1888                     // Next button up.
       
  1889                     MoveFocus(0,-1);
       
  1890                     break;
       
  1891                     }
       
  1892                 else
       
  1893                     {
       
  1894                     //Previous row end.
       
  1895                     TInt xPos = iCharMap->RowMax(yPos);
       
  1896                     if (iExtension->EnterControl(xPos,yPos))
       
  1897                         {
       
  1898                         LeaveControl();
       
  1899                         break;
       
  1900                         }
       
  1901                     }
       
  1902                 break;
       
  1903                 }
       
  1904             // Move by grid.
       
  1905             iCharMap->TakeFocus();
       
  1906             TInt xPos = iCharMap->CursorPos().iX;
       
  1907             TInt yPos = iCharMap->CursorPos().iY;
       
  1908             if (xPos == 0)
       
  1909                 {
       
  1910                 iCharMap->MoveFocus(-1,0);
       
  1911                 }
       
  1912             iCharMap->ShowFocus();
       
  1913             }
       
  1914             break;
       
  1915         case EKeyRightArrow:
       
  1916         case '6':
       
  1917             {
       
  1918             responce = EKeyWasConsumed;
       
  1919             if (AknLayoutUtils::PenEnabled())
       
  1920                 {
       
  1921                 TInt yPos = iButtonIndex;
       
  1922                 if (iCharMap->RowMax(yPos) < 0)
       
  1923                     {
       
  1924                     // Next button down.
       
  1925                     MoveFocus(0,1);
       
  1926                     break;
       
  1927                     }
       
  1928                 else
       
  1929                     {
       
  1930                     // 1st cell in the row.
       
  1931                     if (iExtension->EnterControl(0,yPos))
       
  1932                         {
       
  1933                         LeaveControl();
       
  1934                         break;
       
  1935                         }
       
  1936                     }
       
  1937                 break;
       
  1938                 }
       
  1939             // Move by grid.
       
  1940             iCharMap->TakeFocus();
       
  1941             TInt xPos = iCharMap->CursorPos().iX;
       
  1942             TInt yPos = iCharMap->CursorPos().iY;
       
  1943             if (xPos == iCharMap->RowMax(yPos))
       
  1944                 {
       
  1945                 iCharMap->MoveFocus(1,0);
       
  1946                 }
       
  1947             iCharMap->ShowFocus();
       
  1948             }
       
  1949             break;
       
  1950         case EKeyDownArrow:
       
  1951         case '8':
       
  1952             {
       
  1953             MoveFocus(0, 1);
       
  1954             responce = EKeyWasConsumed;
       
  1955             }
       
  1956             break;
       
  1957         case EKeyUpArrow:
       
  1958         case '2':
       
  1959             {
       
  1960             MoveFocus(0,-1);
       
  1961             responce = EKeyWasConsumed;
       
  1962             }
       
  1963             break;
       
  1964         default:
       
  1965             break;
       
  1966         }
       
  1967     return responce;
       
  1968     }
       
  1969 
       
  1970 void CAknSctRadioButton::ConstructFromResourceL(TResourceReader& aReader)
       
  1971     {
       
  1972     TInt counts = aReader.ReadInt16();
       
  1973     TResourceReader reader;
       
  1974     TInt categorybutton_id;
       
  1975     TInt sctcase_id;
       
  1976     TInt resId;
       
  1977     CAknSctCategoryButton* buttonObj;
       
  1978     TBool allowCreation;
       
  1979 
       
  1980     for (TInt index=0; index < counts; index++)
       
  1981         {
       
  1982         allowCreation = EFalse;
       
  1983         // button id
       
  1984         categorybutton_id = aReader.ReadInt16();
       
  1985         sctcase_id = aReader.ReadInt16();
       
  1986         switch (categorybutton_id)
       
  1987             {
       
  1988             case EAknSCTCategoryButtonHalfCase:
       
  1989             case EAknSCTCategoryButtonFullCase:
       
  1990                 allowCreation = ETrue;
       
  1991                 break;
       
  1992             case EAknSCTCategoryButtonPicto:
       
  1993                 if (iExtension->iPictographsBuffer)
       
  1994                     {
       
  1995                     allowCreation = ETrue;
       
  1996                     }
       
  1997                 break;
       
  1998             case EAknSCTCategoryButtonPicto1:
       
  1999             case EAknSCTCategoryButtonPicto2:
       
  2000                 if (iExtension->iPictographsBuffer &&
       
  2001                     iExtension->iPictographsBufferGrouping)
       
  2002                     {
       
  2003                     allowCreation = ETrue;
       
  2004                     }
       
  2005                 break;
       
  2006             default:
       
  2007                 break;
       
  2008             }
       
  2009 
       
  2010         if (allowCreation)
       
  2011             {
       
  2012             // read the button resource
       
  2013             resId = aReader.ReadInt32();
       
  2014             iCoeEnv->CreateResourceReaderLC( reader, resId );
       
  2015             // create Category button object
       
  2016             buttonObj = CAknSctCategoryButton::NewL(
       
  2017                 *this, reader, categorybutton_id, sctcase_id);
       
  2018             // Append button
       
  2019             iButtonArray.Append(buttonObj);
       
  2020             CleanupStack::PopAndDestroy(); // reader
       
  2021             }
       
  2022         else
       
  2023             {
       
  2024             // Skip data
       
  2025             resId = aReader.ReadInt32();
       
  2026             }
       
  2027         }
       
  2028 
       
  2029     }
       
  2030 
       
  2031 void CAknSctRadioButton::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  2032     {
       
  2033     TRect rect(Rect());
       
  2034     if (AknLayoutUtils::PenEnabled() && rect.Contains(aPointerEvent.iPosition))
       
  2035         {
       
  2036         if (aPointerEvent.iType == TPointerEvent::EButton1Down)
       
  2037             {
       
  2038             CAknButton* buttonCtrlObj;
       
  2039             TRect rectButton;
       
  2040             TInt currentIndex;
       
  2041             TInt newIndex;
       
  2042             for (TInt index=0; index < iButtonArray.Count(); index++)
       
  2043                 {
       
  2044                 buttonCtrlObj = iButtonArray[index]->iButtonControl;
       
  2045                 rectButton = buttonCtrlObj->Rect();
       
  2046                 currentIndex = buttonCtrlObj->StateIndex();
       
  2047 
       
  2048                 if (rectButton.Contains(aPointerEvent.iPosition))
       
  2049                     {
       
  2050                     newIndex = KAknSctRadioOn;
       
  2051                     }
       
  2052                 else
       
  2053                     {
       
  2054                     newIndex = KAknSctRadioOff;
       
  2055                     }
       
  2056                 if (currentIndex != newIndex)
       
  2057                     {
       
  2058                     buttonCtrlObj->SetCurrentState(newIndex, ETrue);
       
  2059                     if (newIndex == KAknSctRadioOn)
       
  2060                         {
       
  2061                         if (AknLayoutUtils::PenEnabled())
       
  2062                             {
       
  2063                             iButtonIndex = index;
       
  2064                             }
       
  2065                         iExtension->iCurrentCategory =
       
  2066                             iButtonArray[index]->iButtonId;
       
  2067                         iCharMap->SetStatusChanged(EAknCharChangedCategory);
       
  2068                         }
       
  2069                     }
       
  2070                 }
       
  2071             }
       
  2072         else if (aPointerEvent.iType == TPointerEvent::EDrag)
       
  2073             {
       
  2074             }
       
  2075         else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
       
  2076             {
       
  2077             }
       
  2078         }
       
  2079     else
       
  2080         {
       
  2081         CCoeControl::HandlePointerEventL(aPointerEvent);
       
  2082         }
       
  2083     }
       
  2084 
       
  2085 TSize CAknSctRadioButton::MinimumSize()
       
  2086     {
       
  2087     TAknLayoutRect oneButtonLayRect;
       
  2088     if (!AknLayoutUtils::PenEnabled())
       
  2089         {
       
  2090         TAknLayoutScalableParameterLimits charMapDialogVariety =
       
  2091             AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
       
  2092 
       
  2093         // Main pane without softkeys
       
  2094         TRect mainPaneRect;
       
  2095         if(!AknLayoutUtils::LayoutMetricsRect(
       
  2096             AknLayoutUtils::EPopupParent, mainPaneRect))
       
  2097             {
       
  2098             mainPaneRect = iAvkonAppUi->ClientRect();
       
  2099             }
       
  2100 
       
  2101         // Calc the variety
       
  2102         TInt maxVariety = charMapDialogVariety.LastVariety();
       
  2103 
       
  2104         TAknLayoutRect popupGridLayRect;
       
  2105         popupGridLayRect.LayoutRect(mainPaneRect,
       
  2106             AknLayoutScalable_Avkon::popup_grid_graphic_window(maxVariety));
       
  2107 
       
  2108         // Calculate the size relatively
       
  2109         TRect relativeDialog(TPoint(0,0),popupGridLayRect.Rect().Size());
       
  2110 
       
  2111         // Get the layout of the actual character grid with scrollbar
       
  2112         TAknLayoutRect gridWithScrollLayRect;
       
  2113         gridWithScrollLayRect.LayoutRect(relativeDialog,
       
  2114             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
       
  2115 
       
  2116         TAknLayoutRect categoryButtonLayRect;
       
  2117         categoryButtonLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
       
  2118             AknLayoutScalable_Avkon::grid_sct_catagory_button_pane());
       
  2119 
       
  2120         oneButtonLayRect.LayoutRect(categoryButtonLayRect.Rect(),
       
  2121             AknLayoutScalable_Avkon::cell_sct_catagory_button_pane());
       
  2122         }
       
  2123     else
       
  2124         {
       
  2125         TAknLayoutRect popupGridLayRect;
       
  2126         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
  2127             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
       
  2128 
       
  2129         TAknLayoutRect oneButtonLayRect;
       
  2130         TAknLayoutRect categoryButtonLayRect;
       
  2131         if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  2132             {
       
  2133             oneButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2134                 AknLayoutScalable_Avkon::grid_graphic2_control_pane(4));
       
  2135 
       
  2136             categoryButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2137                 AknLayoutScalable_Avkon::grid_graphic2_catg_pane(0));
       
  2138             }
       
  2139         else
       
  2140             {
       
  2141             oneButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2142                 AknLayoutScalable_Avkon::grid_graphic2_control_pane(5));
       
  2143 
       
  2144             categoryButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2145                 AknLayoutScalable_Avkon::grid_graphic2_catg_pane(1));
       
  2146 
       
  2147             }
       
  2148         }
       
  2149 
       
  2150     TSize size(oneButtonLayRect.Rect().Width(),
       
  2151         oneButtonLayRect.Rect().Height() * iButtonArray.Count());
       
  2152     return size;
       
  2153     }
       
  2154 
       
  2155 void CAknSctRadioButton::SizeChanged()
       
  2156     {
       
  2157     TRect base;
       
  2158     if (!AknLayoutUtils::PenEnabled())
       
  2159         {
       
  2160         TAknLayoutScalableParameterLimits charMapDialogVariety =
       
  2161             AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
       
  2162 
       
  2163         // Main pane without softkeys
       
  2164         TRect mainPaneRect;
       
  2165         if(!AknLayoutUtils::LayoutMetricsRect(
       
  2166             AknLayoutUtils::EPopupParent, mainPaneRect))
       
  2167             {
       
  2168             mainPaneRect = iAvkonAppUi->ClientRect();
       
  2169             }
       
  2170 
       
  2171         // Calc the variety
       
  2172         TInt maxVariety = charMapDialogVariety.LastVariety();
       
  2173 
       
  2174         TAknLayoutRect popupGridLayRect;
       
  2175         popupGridLayRect.LayoutRect(mainPaneRect,
       
  2176             AknLayoutScalable_Avkon::popup_grid_graphic_window(maxVariety));
       
  2177 
       
  2178         // Calculate the size relatively
       
  2179         TRect relativeDialog(TPoint(0,0), popupGridLayRect.Rect().Size());
       
  2180 
       
  2181         // Get the layout of the actual character grid with scrollbar
       
  2182         TAknLayoutRect gridWithScrollLayRect;
       
  2183         gridWithScrollLayRect.LayoutRect(relativeDialog,
       
  2184             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
       
  2185 
       
  2186         TAknLayoutRect categoryButtonLayRect;
       
  2187         categoryButtonLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
       
  2188             AknLayoutScalable_Avkon::grid_sct_catagory_button_pane());
       
  2189 
       
  2190         TAknLayoutRect oneButtonLayRect;
       
  2191         oneButtonLayRect.LayoutRect(categoryButtonLayRect.Rect(),
       
  2192             AknLayoutScalable_Avkon::cell_sct_catagory_button_pane());
       
  2193 
       
  2194         base = oneButtonLayRect.Rect();
       
  2195         }
       
  2196     else
       
  2197         {
       
  2198         TAknLayoutRect popupGridLayRect;
       
  2199         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
  2200             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
       
  2201 
       
  2202         TAknLayoutRect oneButtonLayRect;
       
  2203         TAknLayoutRect categoryButtonLayRect;
       
  2204         if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  2205             {
       
  2206             oneButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2207                 AknLayoutScalable_Avkon::grid_graphic2_control_pane(4));
       
  2208 
       
  2209             categoryButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2210                 AknLayoutScalable_Avkon::grid_graphic2_catg_pane(0));
       
  2211             }
       
  2212         else
       
  2213             {
       
  2214             oneButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2215                 AknLayoutScalable_Avkon::grid_graphic2_control_pane(5));
       
  2216 
       
  2217             categoryButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2218                 AknLayoutScalable_Avkon::grid_graphic2_catg_pane(1));
       
  2219 
       
  2220             }
       
  2221         base.iTl = categoryButtonLayRect.Rect().iTl;
       
  2222         base.SetSize(oneButtonLayRect.Rect().Size());
       
  2223         }
       
  2224 
       
  2225     if (iButtonArray.Count() > 0)
       
  2226         {
       
  2227         CAknButton* buttonCtrlObj;
       
  2228 
       
  2229         TMargins8 margins;
       
  2230         margins.iTop = 1;
       
  2231         margins.iBottom = 0;
       
  2232         margins.iLeft = 0;
       
  2233         margins.iRight = 0;
       
  2234 
       
  2235         // Change the size of buttons
       
  2236         for (TInt index=0; index < iButtonArray.Count(); index++)
       
  2237             {
       
  2238             buttonCtrlObj = iButtonArray[index]->iButtonControl;
       
  2239             if (buttonCtrlObj)
       
  2240                 {
       
  2241                 if (AknLayoutUtils::PenEnabled())
       
  2242                     {
       
  2243                     buttonCtrlObj->SetHighlightRect(base);
       
  2244                     }
       
  2245                 buttonCtrlObj->SetRect( base );
       
  2246                 buttonCtrlObj->SetIconSize( base.Size() );
       
  2247                 buttonCtrlObj->SetMargins( margins );
       
  2248                 buttonCtrlObj->SetIconScaleMode(EAspectRatioPreserved);
       
  2249                 base.Move(TPoint(0, base.Size().iHeight));
       
  2250                 }
       
  2251             }
       
  2252         }
       
  2253     }
       
  2254 
       
  2255 void CAknSctRadioButton::Draw(const TRect& /*aRect*/) const
       
  2256     {
       
  2257     // no draw
       
  2258     }
       
  2259 
       
  2260 /**
       
  2261  * Returns ETrue if the aFlag bitfield in iFlags is set, EFalse if it
       
  2262  * is clear
       
  2263  */
       
  2264 inline TInt CAknSctRadioButton::Count() const
       
  2265     {
       
  2266     return iButtonArray.Count();
       
  2267     }
       
  2268 
       
  2269 void CAknSctRadioButton::SetCurrentCategory(TInt aCategory)
       
  2270     {
       
  2271     CAknSctCategoryButton* buttonObj;
       
  2272     TInt status;
       
  2273 
       
  2274     for (TInt index=0; index < iButtonArray.Count(); index++)
       
  2275         {
       
  2276         buttonObj = iButtonArray[index];
       
  2277         status = (buttonObj->iButtonId == aCategory)?
       
  2278                      KAknSctRadioOn : KAknSctRadioOff;
       
  2279         buttonObj->iButtonControl->SetCurrentState(status, ETrue);
       
  2280         }
       
  2281     }
       
  2282 
       
  2283 void CAknSctRadioButton::SetValidSctCase(TInt aSctCase)
       
  2284     {
       
  2285     CAknSctCategoryButton* buttonObj;
       
  2286 
       
  2287     for (TInt index=0; index < iButtonArray.Count(); index++)
       
  2288         {
       
  2289         buttonObj = iButtonArray[index];
       
  2290         if (buttonObj->iSctCaseId == aSctCase)
       
  2291             {
       
  2292             buttonObj->iValid = ETrue;
       
  2293             break;
       
  2294             }
       
  2295         // Here is the special case for Half-width/Lower/Upper
       
  2296         else if (buttonObj->iSctCaseId == EAknSCTHalfCase
       
  2297               && (aSctCase == EAknSCTLowerCase
       
  2298                  || aSctCase == EAknSCTUpperCase)
       
  2299                 )
       
  2300             {
       
  2301             buttonObj->iValid = ETrue;
       
  2302             break;
       
  2303             }
       
  2304         }
       
  2305     }
       
  2306 
       
  2307 void CAknSctRadioButton::RemoveInvalidButton()
       
  2308     {
       
  2309     CAknSctCategoryButton* buttonObj;
       
  2310 
       
  2311     for (TInt index=iButtonArray.Count()-1; index >= 0; index--)
       
  2312         {
       
  2313         buttonObj = iButtonArray[index];
       
  2314         if (!buttonObj->iValid)
       
  2315             {
       
  2316             if (buttonObj->iSctCaseId == EAknSCTHalfCase)
       
  2317                 {
       
  2318                 if (iButtonArray.Count() > 1)
       
  2319                     {
       
  2320                     delete buttonObj;
       
  2321                     iButtonArray.Remove(index);
       
  2322                     }
       
  2323                 }
       
  2324             else
       
  2325                 {
       
  2326                 delete buttonObj;
       
  2327                 iButtonArray.Remove(index);
       
  2328                 }
       
  2329             }
       
  2330         }
       
  2331     }
       
  2332 
       
  2333 CCoeControl* CAknSctRadioButton::FocusedControl()
       
  2334     {
       
  2335     return this;
       
  2336     }
       
  2337 
       
  2338 TBool CAknSctRadioButton::EnterControl(TInt /*aX*/, TInt aY)
       
  2339     {
       
  2340     if (IsVisible())
       
  2341         {
       
  2342         if ((aY >= 0) && (aY < Count()))
       
  2343             {
       
  2344             if (iExtension->iHasCategoryButtonUi)
       
  2345                 {
       
  2346                 iEntryIndex = aY;
       
  2347                 iExtension->iFocusHandler = this;
       
  2348                 if (AknLayoutUtils::PenEnabled())
       
  2349                     {
       
  2350                     iButtonIndex = aY;
       
  2351                     CAknSctCategoryButton* buttonObj =
       
  2352                         iButtonArray[iButtonIndex];
       
  2353                     buttonObj->SetFocused(ETrue);
       
  2354                     }
       
  2355                 return ETrue;
       
  2356                 }
       
  2357             }
       
  2358         }
       
  2359     return EFalse;
       
  2360     }
       
  2361 
       
  2362 void CAknSctRadioButton::MoveFocus(TInt /*aX*/, TInt aY)
       
  2363     {
       
  2364     CAknSctCategoryButton* buttonObj;
       
  2365     CAknButton* buttonCtrlObj;
       
  2366     TInt buttonIndex = iButtonIndex + aY;
       
  2367     if (buttonIndex > iButtonArray.Count() - 1)
       
  2368         {
       
  2369         if (!AknLayoutUtils::PenEnabled())
       
  2370             {
       
  2371              // First radio button.
       
  2372             buttonIndex = 0;
       
  2373             }
       
  2374         else
       
  2375             {
       
  2376             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  2377                 {
       
  2378                 // Left page button.
       
  2379                 if (iExtension->iPageNavi &&
       
  2380                     iExtension->iPageNavi->EnterControl(0,0))
       
  2381                     {
       
  2382                     LeaveControl();
       
  2383                     return;
       
  2384                     }
       
  2385                 }
       
  2386             else
       
  2387                 {
       
  2388                 // First table button.
       
  2389                 if (iExtension->iTableNavi &&
       
  2390                     iExtension->iTableNavi->EnterControl(0,0))
       
  2391                     {
       
  2392                     LeaveControl();
       
  2393                     return;
       
  2394                     }
       
  2395                 }
       
  2396             }
       
  2397         }
       
  2398     else if (buttonIndex < 0)
       
  2399         {
       
  2400          if (!AknLayoutUtils::PenEnabled())
       
  2401             {
       
  2402             // Last radio button.
       
  2403             buttonIndex = iButtonArray.Count() - 1;
       
  2404             }
       
  2405          else
       
  2406             {
       
  2407             // First table button.
       
  2408             if (iExtension->iTableNavi &&
       
  2409                 iExtension->iTableNavi->EnterControl(0,0))
       
  2410                 {
       
  2411                 LeaveControl();
       
  2412                 return;
       
  2413                 }
       
  2414             }
       
  2415         }
       
  2416 
       
  2417     if (!AknLayoutUtils::PenEnabled())
       
  2418         {
       
  2419         buttonObj = iButtonArray[iButtonIndex];
       
  2420         buttonCtrlObj = buttonObj->iButtonControl;
       
  2421         buttonCtrlObj->SetCurrentState(KAknSctRadioOff, ETrue);
       
  2422         iButtonIndex = buttonIndex;
       
  2423         buttonObj = iButtonArray[iButtonIndex];
       
  2424         buttonCtrlObj = buttonObj->iButtonControl;
       
  2425         buttonCtrlObj->SetCurrentState(KAknSctRadioOn, ETrue);
       
  2426         iExtension->iCurrentCategory =
       
  2427             iButtonArray[buttonIndex]->iButtonId;
       
  2428         iCharMap->SetStatusChanged(EAknCharChangedCategory);
       
  2429         }
       
  2430     else
       
  2431         {
       
  2432         buttonObj = iButtonArray[iButtonIndex];
       
  2433         buttonObj->SetFocused(EFalse);
       
  2434         iButtonIndex = buttonIndex;
       
  2435         buttonObj = iButtonArray[iButtonIndex];
       
  2436         buttonObj->SetFocused(ETrue);
       
  2437         }
       
  2438     }
       
  2439 
       
  2440 TBool CAknSctRadioButton::LeaveControl()
       
  2441     {
       
  2442     for (TInt i = 0; i < iButtonArray.Count(); i++ )
       
  2443         {
       
  2444         iButtonArray[i]->SetFocused(EFalse);
       
  2445         }
       
  2446     return ETrue;
       
  2447     }
       
  2448 
       
  2449 TBool CAknSctRadioButton::ExitWithKey(TInt /*aKeycode*/)
       
  2450     {
       
  2451     return EFalse;
       
  2452     }
  1371 
  2453 
  1372 // ----------------------------------------------------------------------------
  2454 // ----------------------------------------------------------------------------
  1373 // Extension class implementation
  2455 // Extension class implementation
  1374 // ----------------------------------------------------------------------------
  2456 // ----------------------------------------------------------------------------
  1375 //
  2457 //
  1376 CAknCharMapExtension::CAknCharMapExtension() : iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() )
  2458 CAknCharMapExtension::CAknCharMapExtension() : iSmileyModel(this)
       
  2459 ,iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() )
  1377     {
  2460     {
  1378     iObserver = NULL;
  2461     iObserver = NULL;
  1379     iPictographsBuffer = FeatureManager::FeatureSupported(KFeatureIdJapanesePicto);
  2462     iPictographsBuffer = FeatureManager::FeatureSupported(KFeatureIdJapanesePicto);
  1380     iPictographsBufferGrouping = FeatureManager::FeatureSupported(KFeatureIdJapanesePictographsGrouping);
  2463     iPictographsBufferGrouping = FeatureManager::FeatureSupported(KFeatureIdJapanesePictographsGrouping);
  1381     iKineticScrolling = CAknPhysics::FeatureEnabled();
  2464     iKineticScrolling = CAknPhysics::FeatureEnabled();
  1382 
  2465 
  1383     TRAP_IGNORE(iSmileyModel = new (ELeave) CSmileyModel(this));
  2466     TRAP_IGNORE(iSmileyModel.LoadResourceL());
  1384     TRAP_IGNORE(iSmileyModel->LoadResourceL());
       
  1385     }
  2467     }
  1386 
  2468 
  1387 TTypeUid::Ptr CAknCharMapExtension::MopSupplyObject(TTypeUid aId)
  2469 TTypeUid::Ptr CAknCharMapExtension::MopSupplyObject(TTypeUid aId)
  1388     {
  2470     {
  1389     return MAknsControlContext::SupplyMopObject(aId, iBgContext );
  2471     return MAknsControlContext::SupplyMopObject(aId, iBgContext );
  1394     return iCharMap;
  2476     return iCharMap;
  1395     }
  2477     }
  1396 
  2478 
  1397 CAknCharMapExtension::~CAknCharMapExtension()
  2479 CAknCharMapExtension::~CAknCharMapExtension()
  1398     {
  2480     {
  1399     delete iSmileyModel;
       
  1400     
       
  1401     delete iCharsSmiley;
  2481     delete iCharsSmiley;
  1402     delete iCharsQwerty;
  2482     delete iCharsQwerty;
  1403     delete iBgContext;
  2483     delete iBgContext;
  1404 
  2484 
       
  2485     delete iRadioButton;
  1405     delete iTitleBuf;
  2486     delete iTitleBuf;
  1406 
  2487 
  1407     delete iPageNavi;
  2488     delete iPageNavi;
       
  2489     delete iTableNavi;
  1408     delete iCategoryTitle;
  2490     delete iCategoryTitle;
  1409     delete iCategoryEntry;
  2491     delete iCategoryEntry;
  1410     delete iEntryBuf;
  2492     delete iEntryBuf;
  1411     }
  2493     }
  1412 
  2494 
  1428 TBool CAknCharMapExtension::EnterControl(TInt aX, TInt aY)
  2510 TBool CAknCharMapExtension::EnterControl(TInt aX, TInt aY)
  1429     {
  2511     {
  1430     if(iCharMapProxy->EnterControl(aX, aY))
  2512     if(iCharMapProxy->EnterControl(aX, aY))
  1431         {
  2513         {
  1432         iFocusHandler = this;
  2514         iFocusHandler = this;
       
  2515         iCharMapProxy->HandleFocusStatusChanged();
  1433         return ETrue;
  2516         return ETrue;
  1434         }
  2517         }
  1435     else
  2518     else
  1436         {
  2519         {
  1437         return EFalse;
  2520         return EFalse;
  1452 TBool CAknCharMapExtension::ExitWithKey(TInt /*aKeycode*/)
  2535 TBool CAknCharMapExtension::ExitWithKey(TInt /*aKeycode*/)
  1453     {
  2536     {
  1454     return ETrue;
  2537     return ETrue;
  1455     }
  2538     }
  1456 
  2539 
  1457 void CAknCharMapExtension::SmileyStillImageLoaded(CAknSmileyIcon* aSmileyIcon)
  2540 void CAknCharMapExtension::ThumbnailLoaded(CSmileyIcon* /*aSmileyIcon*/)
  1458     {
  2541     {
  1459     iCharMapProxy->SmileyStillImageLoaded(iSmileyModel->SmileyCode(aSmileyIcon));
  2542     iCharMapProxy->DrawDeferred();
  1460     }
  2543     }
  1461 
  2544 
  1462 void CAknCharMapExtension::SmileyAnimationChanged(CAknSmileyIcon* aSmileyIcon)
  2545 void CAknCharMapExtension::AnimationChanged(CSmileyIcon* /*aSmileyIcon*/)
  1463     {
  2546     {
  1464     iCharMapProxy->SmileyAnimationChanged(iSmileyModel->SmileyCode(aSmileyIcon));
  2547     iCharMapProxy->DrawCursor();
  1465     
       
  1466     User::After(30); // for slow down the AO of this animation
       
  1467     }
  2548     }
  1468 
  2549 
  1469 TBool CAknCharMapExtension::IsEmotionEnabled() const
  2550 TBool CAknCharMapExtension::IsEmotionEnabled() const
  1470     {
  2551     {
  1471     return iIsEnableEmotion;
  2552     return iIsEnableEmotion;
  1472     }
  2553     }
  1473 
  2554 
  1474 TBool CAknCharMapExtension::IsShowingEmotion() const
  2555 TBool CAknCharMapExtension::IsShowingEmotion() const
  1475     {
  2556     {
  1476     return iIsShowingEmotion;
  2557     return iIsShowingEmotion;
  1477     }
       
  1478 
       
  1479 void CAknCharMapExtension::SwitchEmotionVisibilityL()
       
  1480     {
       
  1481     iIsShowingEmotion = !iIsShowingEmotion;
       
  1482     }
  2558     }
  1483 
  2559 
  1484 TBool CAknCharMapExtension::NeedEmotionSwitchIcon() const
  2560 TBool CAknCharMapExtension::NeedEmotionSwitchIcon() const
  1485     {
  2561     {
  1486     // Emotion switch char
  2562     // Emotion switch char
  1488     return needEmotionSwitchIcon;
  2564     return needEmotionSwitchIcon;
  1489     }
  2565     }
  1490 
  2566 
  1491 HBufC* CAknCharMapExtension::ReadEmotionHBufCL()
  2567 HBufC* CAknCharMapExtension::ReadEmotionHBufCL()
  1492     {
  2568     {
  1493     TInt smileyCount = iSmileyModel->Count();
  2569     TInt smileyCount = iSmileyModel.Count();
  1494     HBufC* charsSmiley = HBufC::NewL(smileyCount);
  2570     HBufC* charsSmiley = HBufC::NewL(smileyCount);
  1495     TPtr charsSmileyPtr(charsSmiley->Des());
  2571     TPtr charsSmileyPtr(charsSmiley->Des());
  1496     for(TInt index(0); index<smileyCount; index++)
  2572     for(TInt id(CSmileyModel::EIconSmiley); id<smileyCount; id++)
  1497         {
  2573         {
  1498         charsSmileyPtr.Append(iSmileyModel->SmileyCode(index));
  2574         charsSmileyPtr.Append(TEmotionUtils::EmotionChar(id));
  1499         }
  2575         }
  1500     
  2576     
  1501     return charsSmiley;
  2577     return charsSmiley;
  1502     }
  2578     }
  1503 
  2579 
  1504 void CAknCharMapExtension::LoadEmotionTumbnails(const TDesC& aText)
  2580 void CAknCharMapExtension::LoadEmotionTumbnails(const TDesC& aSctChars)
  1505     {
  2581     {
  1506     //If emotion tumbbails can't be load, 
  2582     for(TInt i(0); i<aSctChars.Length(); i++)
  1507     // no emotion tumbnail will be dispalyed.
  2583         {
  1508     TRAP_IGNORE( iSmileyModel->LoadStillImagesL(aText) );
  2584         iSmileyModel.LoadThumbnailAsyn(TEmotionUtils::EmotionId(aSctChars[i]));
  1509     }
  2585         }
  1510 
       
  1511 const TInt KAnimationRepeat = 30;
       
  1512 const TInt KAnimationDelay = 150*1000;
       
  1513 
       
  1514 void CAknCharMapExtension::PlayAnimationL(const TDesC& aText)
       
  1515     {
       
  1516     iSmileyModel->PlayAnimationL(aText, KAnimationRepeat, KAnimationDelay);
       
  1517     }
       
  1518 
       
  1519 void CAknCharMapExtension::StopAnimation(const TDesC& aText)
       
  1520     {
       
  1521     iSmileyModel->StopAnimation(aText);
       
  1522     }
  2586     }
  1523 
  2587 
  1524 void CAknCharMapExtension::SetEmotionSize(const TSize& aSize)
  2588 void CAknCharMapExtension::SetEmotionSize(const TSize& aSize)
  1525     {
  2589     {
  1526     TInt unit = Min(aSize.iWidth, aSize.iHeight);
  2590     TInt unit = Min(aSize.iWidth, aSize.iHeight);
  1527     iSmileyModel->SetSize(TSize(unit,unit));
  2591     iSmileyModel.SetSize(TSize(unit,unit));
  1528     }
  2592     }
  1529 
  2593 
  1530 TBool CAknCharMapExtension::IsEmotionChar(TChar aChar)
  2594 CSmileyIcon* CAknCharMapExtension::EmotionIcon(TChar aEmotionChar)
  1531     {
  2595     {
  1532     return iSmileyModel->IsSmiley(aChar);
  2596     if(TEmotionUtils::IsEmotionChar(aEmotionChar))
  1533     }
  2597         {
  1534 
  2598         return iSmileyModel[TEmotionUtils::EmotionId(aEmotionChar)];
  1535 TChar CAknCharMapExtension::SwitchToSctChar()
  2599         }
  1536     {
  2600     else
  1537     return iSmileyModel->SwitchToSctCode();
  2601         {
  1538     }
  2602         return NULL;
  1539 
  2603         }
  1540 TChar CAknCharMapExtension::SwitchToEmotionChar()
  2604     }
  1541     {
  2605 
  1542     return iSmileyModel->SwitchToSmileyCode();
  2606 TBool CAknCharMapExtension::DrawEmotion(CWindowGc& aGc, const TRect& aRect, TChar aEmotionChar)
  1543     }
  2607     {
  1544 
  2608     CSmileyIcon* icon = EmotionIcon(aEmotionChar);
  1545 CAknSmileyIcon* CAknCharMapExtension::EmotionIcon(TChar aChar)
  2609     if(icon && icon->ReadyToDraw())
  1546     {
  2610         {
  1547     return iSmileyModel->Smiley(aChar);
  2611         TRect iconRect(TPoint(),icon->Size());
  1548     }
       
  1549 
       
  1550 const TDesC& CAknCharMapExtension::EmotionText(TChar aChar)
       
  1551     {
       
  1552     return iSmileyModel->Text(aChar);
       
  1553     }
       
  1554 
       
  1555 TBool CAknCharMapExtension::DrawEmotion(CWindowGc& aGc, const TRect& aRect, CAknSmileyIcon* aSmileyIcon)
       
  1556     {
       
  1557     if(aSmileyIcon && aSmileyIcon->ReadyToDraw())
       
  1558         {
       
  1559         TRect iconRect(TPoint(),aSmileyIcon->Size());
       
  1560         TInt xoffset = (aRect.Width() - iconRect.Width()) / 2;
  2612         TInt xoffset = (aRect.Width() - iconRect.Width()) / 2;
  1561         TInt yoffset = (aRect.Height() - iconRect.Height()) / 2;
  2613         TInt yoffset = (aRect.Height() - iconRect.Height()) / 2;
  1562 
  2614 
  1563         aGc.BitBltMasked(aRect.iTl+TPoint(xoffset,yoffset), aSmileyIcon->Image(), iconRect, aSmileyIcon->Mask(), FALSE);
  2615         aGc.BitBltMasked(aRect.iTl+TPoint(xoffset,yoffset), icon->Image(), iconRect, icon->Mask(), FALSE);
  1564         return ETrue;
  2616         return ETrue;
  1565         }
  2617         }
  1566     else
  2618     else
  1567         {
  2619         {
  1568         return EFalse;
  2620         return EFalse;
  1572 const TInt KEmotionAnimationRepeatCount = 30; // 30 times
  2624 const TInt KEmotionAnimationRepeatCount = 30; // 30 times
  1573 const TInt KEmotionAnimationDelay = 150*1000; // 0.15s
  2625 const TInt KEmotionAnimationDelay = 150*1000; // 0.15s
  1574 
  2626 
  1575 void CAknCharMapExtension::HandleFocusStatusChanged(TChar aChar, TBool aIsFocused)
  2627 void CAknCharMapExtension::HandleFocusStatusChanged(TChar aChar, TBool aIsFocused)
  1576     {
  2628     {
  1577     CAknSmileyIcon* lastIcon = EmotionIcon(iLastFocusedSmileyChar);
  2629     CSmileyIcon* lastIcon = EmotionIcon(iLastFocusedSmileyChar);
  1578     if(lastIcon)
  2630     if(lastIcon)
  1579         {
  2631         {
  1580         lastIcon->StopAnimation();
  2632         lastIcon->StopAnimation();
  1581         }
  2633         }
  1582     
  2634     
  1583     CAknSmileyIcon* focusedIcon = EmotionIcon(aChar);
  2635     CSmileyIcon* focusedIcon = EmotionIcon(aChar);
  1584     if(focusedIcon)
  2636     if(focusedIcon)
  1585         {
  2637         {
  1586         if(aIsFocused)
  2638         if(aIsFocused)
  1587             {
  2639             {
  1588             if(iHighlightVisible)
  2640             if(iHighlightVisible)
  1775 // -----------------------------------------------------------------------------
  2827 // -----------------------------------------------------------------------------
  1776 // CAknCharMapHistory::InsertChar()
  2828 // CAknCharMapHistory::InsertChar()
  1777 // Insert a character which select on SCT/Picto.
  2829 // Insert a character which select on SCT/Picto.
  1778 // -----------------------------------------------------------------------------
  2830 // -----------------------------------------------------------------------------
  1779 //
  2831 //
  1780 void CAknCharMapHistory::InsertChar(THistoryType aHistoryType, const TChar aChar, TBool aIsEmotion)
  2832 void CAknCharMapHistory::InsertChar(THistoryType aHistoryType, const TChar aChar)
  1781     {
  2833     {
  1782     __ASSERT_ALWAYS((EHistoryTypeFull<=aHistoryType && aHistoryType<EHistoryTypeMax), Panic(EAknPanicInvalidValue));
  2834     __ASSERT_ALWAYS((EHistoryTypeFull<=aHistoryType && aHistoryType<EHistoryTypeMax), Panic(EAknPanicInvalidValue));
  1783 
  2835 
  1784     InsertCharToHistoryBuf(iMixedHistoryArray[aHistoryType], aChar);
  2836     InsertCharToHistoryBuf(iMixedHistoryArray[aHistoryType], aChar);
  1785 
  2837 
  1786     if(aIsEmotion)
  2838     if(TEmotionUtils::IsEmotionChar(aChar))
  1787         {
  2839         {
  1788         InsertCharToHistoryBuf(iEmotionHistory, aChar);
  2840         InsertCharToHistoryBuf(iEmotionHistory, aChar);
  1789         }
  2841         }
  1790     else
  2842     else
  1791         {
  2843         {
  1850 
  2902 
  1851     if(err)
  2903     if(err)
  1852         return;
  2904         return;
  1853 
  2905 
  1854     iExtension->iFlags = 0x00;
  2906     iExtension->iFlags = 0x00;
       
  2907 
       
  2908     // if feature language is Japanese
       
  2909     CAknEnv* env = CAknEnv::Static();
       
  2910     if (env)
       
  2911         {
       
  2912         if (env->IsFeatureLanguage(KFeatureIdJapanese))
       
  2913             {
       
  2914             iExtension->iJapaneseSctUi = ETrue;
       
  2915             iExtension->iHasCategoryButtonUi = ETrue;
       
  2916             }
       
  2917         }
  1855     iExtension->iFocusHandler = iExtension;
  2918     iExtension->iFocusHandler = iExtension;
  1856     iExtension->SetCharMapControl(this);
  2919     iExtension->SetCharMapControl(this);
  1857     
  2920 	
  1858     if ( iExtension->iSingleClickEnabled )
  2921     if ( iExtension->iSingleClickEnabled )
  1859         {
  2922         {
  1860         iExtension->iHighlightVisible = EFalse;
  2923         iExtension->iHighlightVisible = EFalse;
  1861         }
  2924         }
  1862     
  2925     
  1878     delete iPictographsBuffer2;
  2941     delete iPictographsBuffer2;
  1879     
  2942     
  1880     delete iSBFrame;
  2943     delete iSBFrame;
  1881     delete iPictoInterface;
  2944     delete iPictoInterface;
  1882 
  2945 
       
  2946     delete iOffscreenBg;
       
  2947     delete iBitmapDevice;
       
  2948     delete iBitmapGc;
  1883 
  2949 
  1884     delete iTitleDefault;
  2950     delete iTitleDefault;
  1885     delete iTitleFull;
  2951     delete iTitleFull;
  1886     delete iTitleHalf;
  2952     delete iTitleHalf;
  1887     delete iTitlePicto;
  2953     delete iTitlePicto;
  1900     iSpecialCharCases.Close();
  2966     iSpecialCharCases.Close();
  1901     iSpecialCharPages.Close();
  2967     iSpecialCharPages.Close();
  1902     iPictographCases.Close();
  2968     iPictographCases.Close();
  1903     iPictographPages.Close();
  2969     iPictographPages.Close();
  1904     MTouchFeedback* feedback = MTouchFeedback::Instance();
  2970     MTouchFeedback* feedback = MTouchFeedback::Instance();
  1905     
  2971     feedback->RemoveFeedbackForControl( this );
  1906     if ( feedback != NULL )
       
  1907         {
       
  1908         feedback->RemoveFeedbackForControl( this );
       
  1909         }
       
  1910    }
  2972    }
  1911 
  2973 
  1912 void CAknCharMap::DoLayout()
  2974 void CAknCharMap::DoLayout()
  1913     {
  2975     {
  1914     TAknTextLineLayout specialCharItemLayout;
  2976     TAknTextLineLayout specialCharItemLayout;
  1916         {
  2978         {
  1917         if ( Layout_Meta_Data::IsLandscapeOrientation() )
  2979         if ( Layout_Meta_Data::IsLandscapeOrientation() )
  1918             {
  2980             {
  1919             specialCharItemLayout =
  2981             specialCharItemLayout =
  1920                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(1);
  2982                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(1);
       
  2983             }
       
  2984         else if (IsJapaneseSctUi())
       
  2985             {
       
  2986             specialCharItemLayout =
       
  2987                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(2);
  1921             }
  2988             }
  1922         else
  2989         else
  1923             {
  2990             {
  1924             specialCharItemLayout =
  2991             specialCharItemLayout =
  1925                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(0);
  2992                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(0);
  1940     iIsMirrored = AknLayoutUtils::LayoutMirrored();
  3007     iIsMirrored = AknLayoutUtils::LayoutMirrored();
  1941     iDrawnBefore = EFalse;
  3008     iDrawnBefore = EFalse;
  1942     CountMaxColumnsAndCellSizes();
  3009     CountMaxColumnsAndCellSizes();
  1943     SizeChanged();
  3010     SizeChanged();
  1944 
  3011 
  1945     // set smiley size
  3012     // load Emotion icon resource, but not load images
  1946     TAknWindowComponentLayout cellGraphicsLayout;
  3013     TSize iconSize(iGridItemWidth,iGridItemHeight);
  1947     if ( Layout_Meta_Data::IsLandscapeOrientation() )
  3014     iconSize.iWidth = iconSize.iWidth * 2 / 3;
  1948         {
  3015     iconSize.iHeight = iconSize.iHeight * 2 / 3;
  1949         cellGraphicsLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_g5(1);
  3016     Extension()->SetEmotionSize(iconSize);
  1950         }
       
  1951     else
       
  1952         {
       
  1953         cellGraphicsLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_g5(0);
       
  1954         }
       
  1955 
       
  1956     TAknLayoutRect cellGraphicsRect;
       
  1957     cellGraphicsRect.LayoutRect(TRect(TSize(iGridItemWidth,iGridItemHeight)), cellGraphicsLayout);
       
  1958     
       
  1959     Extension()->SetEmotionSize(cellGraphicsRect.Rect().Size());
       
  1960     }
  3017     }
  1961 
  3018 
  1962 
  3019 
  1963 EXPORT_C void CAknCharMap::ConstructFromResourceL(TResourceReader& aReader)
  3020 EXPORT_C void CAknCharMap::ConstructFromResourceL(TResourceReader& aReader)
  1964     {
  3021     {
  2018         }
  3075         }
  2019 
  3076 
  2020     // Alternate components.
  3077     // Alternate components.
  2021     if (AknLayoutUtils::PenEnabled())
  3078     if (AknLayoutUtils::PenEnabled())
  2022         {
  3079         {
       
  3080         if (iExtension->iHasCategoryButtonUi)
       
  3081             {
       
  3082             EnableCategoryInputFieldL();
       
  3083             EnableCategoryButtonsL();
       
  3084             }
  2023         EnableNavigationButtonsL();
  3085         EnableNavigationButtonsL();
       
  3086         }
       
  3087     else
       
  3088         {
       
  3089         if (iExtension->iHasCategoryButtonUi)
       
  3090             {
       
  3091             EnableCategoryButtonsL();
       
  3092             }
  2024         }
  3093         }
  2025 
  3094 
  2026     // Offscreen background.
  3095     // Offscreen background.
  2027     if (offscreen)
  3096     if (offscreen)
  2028         {
  3097         {
  2116     else
  3185     else
  2117         {
  3186         {
  2118         iShowCasesRef = &iSpecialCharCases;
  3187         iShowCasesRef = &iSpecialCharCases;
  2119         iShowPagesRef = &iSpecialCharPages;
  3188         iShowPagesRef = &iSpecialCharPages;
  2120         
  3189         
       
  3190         // default
       
  3191         iSpecialCharCase = EAknSCTLowerCase;
       
  3192         iChars = iCharsBufferLower;
       
  3193         
  2121         if(iExtension->iCharsSmiley && iExtension->IsShowingEmotion())
  3194         if(iExtension->iCharsSmiley && iExtension->IsShowingEmotion())
  2122             {
  3195             {
  2123             iChars = iExtension->iCharsSmiley;
  3196             iChars = iExtension->iCharsSmiley;
  2124             }
  3197             }
  2125         else if (iCharsBufferUpper && iSpecialCharCase==EAknSCTUpperCase)
  3198         else if (iCharsBufferUpper && iSpecialCharCase==EAknSCTUpperCase)
  2139             iChars = iCharsBufferHalf;
  3212             iChars = iCharsBufferHalf;
  2140             }
  3213             }
  2141         else if (iExtension->iCharsQwerty && iSpecialCharCase==EAknSCTQwerty)
  3214         else if (iExtension->iCharsQwerty && iSpecialCharCase==EAknSCTQwerty)
  2142             {
  3215             {
  2143             iChars = iExtension->iCharsQwerty;
  3216             iChars = iExtension->iCharsQwerty;
  2144             }
       
  2145         else
       
  2146             {
       
  2147             iSpecialCharCase = EAknSCTLowerCase;
       
  2148             iChars = iCharsBufferLower;
       
  2149             }
  3217             }
  2150         }
  3218         }
  2151 
  3219 
  2152     // calculate page count for all pages
  3220     // calculate page count for all pages
  2153     iSpecialCharPages.Reset(); // reset the current page count for different charsets
  3221     iSpecialCharPages.Reset(); // reset the current page count for different charsets
  2176         {
  3244         {
  2177         iCursorPos = TPoint(0, 1);
  3245         iCursorPos = TPoint(0, 1);
  2178         }
  3246         }
  2179 
  3247 
  2180     iExtension->iCurrentCategory = Category();
  3248     iExtension->iCurrentCategory = Category();
       
  3249     if (iExtension->iRadioButton)
       
  3250         {
       
  3251         iExtension->iRadioButton->SetCurrentCategory(iExtension->iCurrentCategory);
       
  3252         }
  2181 
  3253 
  2182     // Create and set the scb visible even though there is nothing to scroll
  3254     // Create and set the scb visible even though there is nothing to scroll
  2183     delete iSBFrame;
  3255     delete iSBFrame;
  2184     iSBFrame=NULL;
  3256     iSBFrame=NULL;
  2185 
  3257 
  2190         iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
  3262         iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
  2191         iSBFrame->VerticalScrollBar()->SetMopParent(iExtension);
  3263         iSBFrame->VerticalScrollBar()->SetMopParent(iExtension);
  2192         UpdateScrollIndicatorL();
  3264         UpdateScrollIndicatorL();
  2193         }
  3265         }
  2194     
  3266     
  2195     Extension()->LoadEmotionTumbnails(*iChars);
  3267     iExtension->LoadEmotionTumbnails(*iChars);
       
  3268 
       
  3269     CAknSctPageNavi* pageNavi = Extension()->iPageNavi;
       
  3270     if(pageNavi)
       
  3271         {
       
  3272         pageNavi->MakeVisible(PageCount()>1);
       
  3273         }
       
  3274     
       
  3275     HandleFocusStatusChanged();
  2196     
  3276     
  2197     }
  3277     }
  2198 
  3278 
  2199 EXPORT_C void CAknCharMap::SetBuffer(TDes& aSpecialChars)
  3279 EXPORT_C void CAknCharMap::SetBuffer(TDes& aSpecialChars)
  2200     {
  3280     {
  2369         {
  3449         {
  2370         return EKeyWasConsumed;
  3450         return EKeyWasConsumed;
  2371         }
  3451         }
  2372     
  3452     
  2373     TUint code=aKeyEvent.iCode;
  3453     TUint code=aKeyEvent.iCode;
  2374     
  3454 	
  2375     // First key event enables the highlight
  3455     // First key event enables the highlight
  2376     if ( iExtension->iSingleClickEnabled && !iExtension->iHighlightVisible )
  3456     if ( iExtension->iSingleClickEnabled && !iExtension->iHighlightVisible )
  2377         {
  3457         {
  2378         if ( code == EKeyUpArrow || code == EKeyDownArrow || 
  3458         if ( code == EKeyUpArrow || code == EKeyDownArrow || 
  2379              code == EKeyLeftArrow || code == EKeyRightArrow || 
  3459              code == EKeyLeftArrow || code == EKeyRightArrow || 
  2380              code == EKeyEnter )
  3460              code == EKeyEnter )
  2381             {
  3461             {
  2382             iExtension->iKeyBrdEvent = ETrue;
       
  2383             iExtension->iHighlightVisible = ETrue;
  3462             iExtension->iHighlightVisible = ETrue;
  2384             if ( LengthOfRecentChar() == 0 && CurrentPage() == 1 )
  3463             iCursorPos = TPoint( 0, 0 );
  2385             	{
       
  2386                 iCursorPos = TPoint( 0, 1 );
       
  2387             	}
       
  2388             else
       
  2389             	{
       
  2390                 iCursorPos = TPoint( 0, 0 );
       
  2391             	}
       
  2392             DrawCursor();
  3464             DrawCursor();
       
  3465             HandleFocusStatusChanged();
  2393             return EKeyWasConsumed;
  3466             return EKeyWasConsumed;
  2394             }
  3467             }
  2395         }
  3468         }
  2396     
  3469     
  2397     switch (code)
  3470     switch (code)
  2398         {
  3471         {
  2399         case EKeyLeftArrow:
  3472         case EKeyLeftArrow:
  2400         case '4':
  3473         case '4':
  2401             {
  3474             {
       
  3475             if (iExtension->iRadioButton && (iCursorPos.iX == 0)) // Radio button.
       
  3476                 {
       
  3477                 if (iExtension->iRadioButton->EnterControl(iCursorPos.iX,iCursorPos.iY))
       
  3478                     {
       
  3479                     LeaveControl();
       
  3480                     break;
       
  3481                     }
       
  3482                 }
       
  3483 
  2402             if (AknLayoutUtils::PenEnabled())
  3484             if (AknLayoutUtils::PenEnabled())
  2403                 {
  3485                 {
  2404                 if (!iIsMirrored)
  3486                 if (!iIsMirrored)
  2405                     {
  3487                     {
  2406                     if ((iCursorPos.iX == 0) && (iCursorPos.iY == ColMin(0)))
  3488                     if ((iCursorPos.iX == 0) && (iCursorPos.iY == ColMin(0)))
  2407                         {
  3489                         {
  2408                         // western, move left from first one in grid, focus pageNavi last button
  3490                         if (!Layout_Meta_Data::IsLandscapeOrientation())
  2409                         if ( iExtension->iPageNavi )
       
  2410                             {
  3491                             {
  2411                             TInt maxButt = iExtension->iPageNavi->LastButton();
  3492                             // Last table button.
  2412                             if ( iExtension->iPageNavi->EnterControl( maxButt,0 ) )
  3493                             if (iExtension->iTableNavi &&
       
  3494                                 iExtension->iTableNavi->EnterControl(TableCount() - 1,0))
       
  3495                                 {
       
  3496                                 LeaveControl();
       
  3497                                 break;
       
  3498                                 }
       
  3499                             }
       
  3500                         else
       
  3501                             {
       
  3502                             // Right page button.
       
  3503                             if (iExtension->iPageNavi &&
       
  3504                                 iExtension->iPageNavi->EnterControl(1,0))
  2413                                 {
  3505                                 {
  2414                                 LeaveControl();
  3506                                 LeaveControl();
  2415                                 break;
  3507                                 break;
  2416                                 }
  3508                                 }
  2417                             }
  3509                             }
  2419                     }
  3511                     }
  2420                 else
  3512                 else
  2421                     {
  3513                     {
  2422                     if (((iCursorPos.iY == ColMax(0)) && (iCursorPos.iX == RowMax(ColMax(0)))))
  3514                     if (((iCursorPos.iY == ColMax(0)) && (iCursorPos.iX == RowMax(ColMax(0)))))
  2423                         {
  3515                         {
  2424                         // mirrored, move left from last one in grid, focus pgNavi first button
  3516                         if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  3517                             {
       
  3518                             // Left page button.
       
  3519                             if (iExtension->iPageNavi &&
       
  3520                                 iExtension->iPageNavi->EnterControl(0,0))
       
  3521                                 {
       
  3522                                 LeaveControl();
       
  3523                                 break;
       
  3524                                 }
       
  3525                             }
       
  3526                         else
       
  3527                             {
       
  3528                             // First table button.
       
  3529                             if (iExtension->iTableNavi &&
       
  3530                                 iExtension->iTableNavi->EnterControl(0,0))
       
  3531                                 {
       
  3532                                 LeaveControl();
       
  3533                                 break;
       
  3534                                 }
       
  3535                             }
       
  3536                         }
       
  3537                     }
       
  3538                 }
       
  3539             MoveFocus(-1,0);
       
  3540             break;
       
  3541             }
       
  3542         case EKeyRightArrow:
       
  3543         case '6':
       
  3544             {
       
  3545             if (iExtension->iRadioButton &&
       
  3546                 (iCursorPos.iX == RowMax(iCursorPos.iY)) &&
       
  3547                     (iCursorPos.iY <= (iExtension->iRadioButton->Count() - 2)))
       
  3548                 {
       
  3549                 // Radio button.
       
  3550                 if (iExtension->iRadioButton->EnterControl(iCursorPos.iX,iCursorPos.iY+1))
       
  3551                     {
       
  3552                     LeaveControl();
       
  3553                     break;
       
  3554                     }
       
  3555                 }
       
  3556             if (AknLayoutUtils::PenEnabled())
       
  3557                 {
       
  3558                 if (!iIsMirrored)
       
  3559                     {
       
  3560                     if ((iCursorPos.iY == ColMax(0)) &&
       
  3561                         (iCursorPos.iX == RowMax(ColMax(0))))
       
  3562                         {
       
  3563                         if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  3564                             {
       
  3565                             // Left page button.
       
  3566                             if (iExtension->iPageNavi &&
       
  3567                                 iExtension->iPageNavi->EnterControl(0,0))
       
  3568                                 {
       
  3569                                 LeaveControl();
       
  3570                                 break;
       
  3571                                 }
       
  3572                             }
       
  3573                         else
       
  3574                             {
       
  3575                             // First table button.
       
  3576                             if (iExtension->iTableNavi &&
       
  3577                                 iExtension->iTableNavi->EnterControl(0,0))
       
  3578                                 {
       
  3579                                 LeaveControl();
       
  3580                                 break;
       
  3581                                 }
       
  3582                             }
       
  3583                         }
       
  3584                     }
       
  3585                 else
       
  3586                     {
       
  3587                     if ((iCursorPos.iY == ColMin(0)) &&
       
  3588                         (iCursorPos.iX == 0))
       
  3589                         {
       
  3590                         if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  3591                             {
       
  3592                             // First table button.
       
  3593                             if (iExtension->iTableNavi &&
       
  3594                                 iExtension->iTableNavi->EnterControl(0,0))
       
  3595                                 {
       
  3596                                 LeaveControl();
       
  3597                                 break;
       
  3598                                 }
       
  3599 
       
  3600                             }
       
  3601                         else
       
  3602                             {
       
  3603                             // Left page button.
       
  3604                             if (iExtension->iPageNavi &&
       
  3605                                 iExtension->iPageNavi->EnterControl(1,0))
       
  3606                                 {
       
  3607                                 LeaveControl();
       
  3608                                 break;
       
  3609                                 }
       
  3610                             }
       
  3611                         }
       
  3612                     }
       
  3613                 }
       
  3614             MoveFocus(1,0);
       
  3615             break;
       
  3616             }
       
  3617         case EKeyUpArrow:
       
  3618         case '2':
       
  3619             {
       
  3620             if (AknLayoutUtils::PenEnabled())
       
  3621                 {
       
  3622                 if (iCursorPos.iY == ColMin(iCursorPos.iX))
       
  3623                     {
       
  3624                     if (!iExtension->iRadioButton && iCursorPos.iX < TableCount())
       
  3625                         {
       
  3626                         // Table button up.
       
  3627                         if ( iExtension->iTableNavi &&
       
  3628                             iExtension->iTableNavi->EnterControl(iCursorPos.iX,0))
       
  3629                             {
       
  3630                             LeaveControl();
       
  3631                             break;
       
  3632                             }
       
  3633                         }
       
  3634                     else
       
  3635                         {
       
  3636                         if (iCursorPos.iX == MaxCols() - 1)
       
  3637                             {
       
  3638                             // Right page button.
       
  3639                             if ( iExtension->iPageNavi &&
       
  3640                                 iExtension->iPageNavi->EnterControl(1,0))
       
  3641                                 {
       
  3642                                 LeaveControl();
       
  3643                                 break;
       
  3644                                 }
       
  3645                             }
       
  3646                         if (Layout_Meta_Data::IsLandscapeOrientation())
       
  3647                             {
       
  3648                             if ((!iExtension->iRadioButton &&
       
  3649                                  (iCursorPos.iX == TableCount())) ||
       
  3650                                ((iExtension->iRadioButton) &&
       
  3651                                  (iCursorPos.iX == MaxCols()-2)))
       
  3652                                 {
       
  3653                                 // Left page button.
       
  3654                                 if ( iExtension->iPageNavi &&
       
  3655                                     iExtension->iPageNavi->EnterControl(0,0))
       
  3656                                     {
       
  3657                                     LeaveControl();
       
  3658                                     break;
       
  3659                                     }
       
  3660                                 }
       
  3661                             }
       
  3662                         // Grid bottom row.
       
  3663                         if (ColMax(0) > ColMax(iCursorPos.iX))
       
  3664                             {
       
  3665                             EnterControl(RowMax(ColMax(0)), ColMax(0));
       
  3666                             break;
       
  3667                             }
       
  3668                         EnterControl(iCursorPos.iX, ColMax( iCursorPos.iX));
       
  3669                         break;
       
  3670                         }
       
  3671                     }
       
  3672                 }
       
  3673             MoveFocus(0,-1);
       
  3674             break;
       
  3675             }
       
  3676         case EKeyDownArrow:
       
  3677         case '8':
       
  3678             {
       
  3679             if (AknLayoutUtils::PenEnabled())
       
  3680                 {
       
  3681                 if (iCursorPos.iY == ColMax(iCursorPos.iX))
       
  3682                     {
       
  3683                     if (iCursorPos.iX > RowMax(ColMax(0)))
       
  3684                         {
       
  3685                         // Grid last item.
       
  3686                         EnterControl(RowMax(ColMax(0)), ColMax(0));
       
  3687                         break;
       
  3688                         }
       
  3689                     if ((iCursorPos.iX == MaxCols() - 1) ||
       
  3690                         (!Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3691                             iExtension->iRadioButton &&
       
  3692                                 (iCursorPos.iX == MaxCols() - 2)))
       
  3693                         {
       
  3694                         // Right page button.
       
  3695                         if (iExtension->iPageNavi &&
       
  3696                             iExtension->iPageNavi->EnterControl(1,0))
       
  3697                             {
       
  3698                             LeaveControl();
       
  3699                             break;
       
  3700                             }
       
  3701                         }
       
  3702                     if ((Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3703                             !iExtension->iRadioButton &&
       
  3704                                 (iCursorPos.iX == TableCount())) ||
       
  3705                         (!Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3706                             (iCursorPos.iX == 0)) ||
       
  3707                         (Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3708                             iExtension->iRadioButton &&
       
  3709                                 (iCursorPos.iX == MaxCols() - 2)))
       
  3710                         {
       
  3711                         // Left page button.
  2425                         if (iExtension->iPageNavi &&
  3712                         if (iExtension->iPageNavi &&
  2426                             iExtension->iPageNavi->EnterControl(0,0))
  3713                             iExtension->iPageNavi->EnterControl(0,0))
  2427                             {
  3714                             {
  2428                             LeaveControl();
  3715                             LeaveControl();
  2429                             break;
  3716                             break;
  2430                             }
  3717                             }
  2431                         }
  3718                         }
  2432                     }
  3719                     if (!iExtension->iRadioButton &&
  2433                 }
  3720                             iCursorPos.iX < TableCount())
  2434             MoveFocus(-1,0);
       
  2435             break;
       
  2436             }
       
  2437         case EKeyRightArrow:
       
  2438         case '6':
       
  2439             {
       
  2440             if (AknLayoutUtils::PenEnabled())
       
  2441                 {
       
  2442                 if (!iIsMirrored)
       
  2443                     {
       
  2444                     if ((iCursorPos.iY == ColMax(0)) &&
       
  2445                         (iCursorPos.iX == RowMax(ColMax(0))))
       
  2446                         {
  3721                         {
  2447                         // western, move right from last one in grid, focus pgNavi first button
  3722                          // Table button down.
  2448                         if (iExtension->iPageNavi &&
  3723                         if (iExtension->iTableNavi &&
  2449                             iExtension->iPageNavi->EnterControl(0,0))
  3724                             iExtension->iTableNavi->EnterControl(iCursorPos.iX,0))
  2450                             {
  3725                             {
  2451                             LeaveControl();
  3726                             LeaveControl();
  2452                             break;
  3727                             break;
  2453                             }
  3728                             }
  2454                         }
  3729                         }
  2455                     }
       
  2456                 else
       
  2457                     {
       
  2458                     if ((iCursorPos.iY == ColMin(0)) &&
       
  2459                         (iCursorPos.iX == 0))
       
  2460                         {
       
  2461                         // mirrored, move right from first one in grid, focus pgNavi last button
       
  2462                         if ( iExtension->iPageNavi )
       
  2463                             {
       
  2464                             TInt maxButt = iExtension->iPageNavi->LastButton();
       
  2465                             if ( iExtension->iPageNavi->EnterControl( maxButt,0 ) )
       
  2466                                 {
       
  2467                                 LeaveControl();
       
  2468                                 break;
       
  2469                                 }
       
  2470                             }
       
  2471                         }
       
  2472                     }
       
  2473                 }
       
  2474             MoveFocus(1,0);
       
  2475             break;
       
  2476             }
       
  2477         case EKeyUpArrow:
       
  2478         case '2':
       
  2479             {
       
  2480             if (AknLayoutUtils::PenEnabled())
       
  2481                 {
       
  2482                 if ( iCursorPos.iY == ColMin(iCursorPos.iX) )
       
  2483                     {
       
  2484                     // cell is at the top row, need to go on to PageNavi
       
  2485                     if ( iExtension->iPageNavi )
       
  2486                         {
       
  2487                         TInt aX = 0;
       
  2488                         
       
  2489                         if ( iCursorPos.iX == MaxCols() - 1 )
       
  2490                             {
       
  2491                             aX = iExtension->iPageNavi->LastButton();
       
  2492                             }
       
  2493                         else if ( iCursorPos.iX == MaxCols() - 2 )
       
  2494                             {
       
  2495                             // a bit complex as unable-emotion SCT has no SC/Emotion icon
       
  2496                             if ( iExtension->IsEmotionEnabled() )
       
  2497                                 {
       
  2498                                 aX = iIsMirrored? 1 : 2;
       
  2499                                 }
       
  2500                             else
       
  2501                                 {
       
  2502                                 aX = -1;
       
  2503                                 }
       
  2504                             }
       
  2505                         else if (iCursorPos.iX == 1 )  
       
  2506                             {
       
  2507                             aX = iIsMirrored? 2 : 1;
       
  2508                             }
       
  2509                         else if ( iCursorPos.iX == 0 )
       
  2510                             {
       
  2511                             // first button in PageNavi
       
  2512                             aX = 0;
       
  2513                             }
       
  2514                         else
       
  2515                             {
       
  2516                             aX = -1;
       
  2517                             }
       
  2518                         if ( iExtension->iPageNavi->EnterControl( aX,0 ) )
       
  2519                             {
       
  2520                             LeaveControl();
       
  2521                             break;
       
  2522                             }
       
  2523                         }
       
  2524                     EnterControl(iCursorPos.iX, ColMax( iCursorPos.iX));
       
  2525                     break;
       
  2526                     }
       
  2527                 }
       
  2528                 MoveFocus(0,-1);
       
  2529                 break;
       
  2530             }
       
  2531         case EKeyDownArrow:
       
  2532         case '8':
       
  2533             {
       
  2534             if (AknLayoutUtils::PenEnabled())
       
  2535                 {
       
  2536                 if (iCursorPos.iY == ColMax(iCursorPos.iX))
       
  2537                     {
       
  2538                     if (  iExtension->iPageNavi )
       
  2539                         {
       
  2540                         TInt aX = 0;
       
  2541                     
       
  2542                         if ( iCursorPos.iX == MaxCols() - 1 )
       
  2543                             {
       
  2544                             aX = iExtension->iPageNavi->LastButton();
       
  2545                             }
       
  2546                         else if ( iCursorPos.iX == MaxCols() - 2 )
       
  2547                             {
       
  2548                              // a bit complex as unable-emotion SCT has no SC/Emotion icon
       
  2549                             if ( iExtension->IsEmotionEnabled() )
       
  2550                                 {
       
  2551                                 aX = iIsMirrored? 1 : 2;
       
  2552                                 }
       
  2553                             else
       
  2554                                 {
       
  2555                                 aX = -1;
       
  2556                                 }
       
  2557                             }
       
  2558                         else if ( iCursorPos.iX == 1 )  
       
  2559                             {
       
  2560                             aX = iIsMirrored? 2 : 1;
       
  2561                             }
       
  2562                         else if ( iCursorPos.iX == 0 )
       
  2563                             {
       
  2564                             // default: first button in PageNavi
       
  2565                             aX = 0;
       
  2566                             }
       
  2567                         else
       
  2568                             {
       
  2569                             aX = -1;
       
  2570                             }
       
  2571                         if ( iExtension->iPageNavi->EnterControl( aX,0 ) )
       
  2572                             {
       
  2573                             LeaveControl();
       
  2574                             break;
       
  2575                             }
       
  2576                         }
       
  2577                     // cell is at bottom row
       
  2578                     if (iCursorPos.iX > RowMax(ColMax(0)))
       
  2579                         {
       
  2580                         // Grid last item.
       
  2581                         EnterControl(RowMax(ColMax(0)), ColMax(0));
       
  2582                         break;
       
  2583                         }
       
  2584                     // Grid top row.
  3730                     // Grid top row.
  2585                     EnterControl(iCursorPos.iX, ColMin(iCursorPos.iX));
  3731                     EnterControl(iCursorPos.iX, ColMin(iCursorPos.iX));
  2586                     break;
  3732                     break;
  2587                     }
  3733                     }
  2588                 }
  3734                 }
  2675 
  3821 
  2676         TAknLayoutRect gridWithScrollLayRect;
  3822         TAknLayoutRect gridWithScrollLayRect;
  2677         gridWithScrollLayRect.LayoutRect(relativePopup, AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
  3823         gridWithScrollLayRect.LayoutRect(relativePopup, AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
  2678 
  3824 
  2679         TAknLayoutRect gridLayRect;
  3825         TAknLayoutRect gridLayRect;
  2680         gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(), AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
  3826         if (iExtension->iHasCategoryButtonUi)
       
  3827             {
       
  3828             gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(), AknLayoutScalable_Avkon::grid_graphic_popup_pane(2));
       
  3829             }
       
  3830         else
       
  3831             {
       
  3832             gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(), AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
       
  3833             }
  2681 
  3834 
  2682         // Grid.
  3835         // Grid.
  2683         TRect contentRect = Extension()->iMenuSct ? Rect() : gridLayRect.Rect();
  3836         TRect contentRect = Extension()->iMenuSct ? Rect() : gridLayRect.Rect();
  2684         if ( Extension()->iMenuSct )
  3837         if ( Extension()->iMenuSct )
  2685             {
  3838             {
  2695         else
  3848         else
  2696             {
  3849             {
  2697             iOffset.iX = contentRect.iTl.iX + 1;
  3850             iOffset.iX = contentRect.iTl.iX + 1;
  2698             iGridTopLeft.iX = contentRect.iTl.iX;
  3851             iGridTopLeft.iX = contentRect.iTl.iX;
  2699             }
  3852             }
       
  3853 
       
  3854         // Category buttons.
       
  3855         if (iExtension && iExtension->iHasCategoryButtonUi)
       
  3856             {
       
  3857             if (iExtension->iRadioButton)
       
  3858                 {
       
  3859                 TAknLayoutRect categoryButtonLayRect;
       
  3860                 categoryButtonLayRect.LayoutRect(gridWithScrollLayRect.Rect(),AknLayoutScalable_Avkon::grid_sct_catagory_button_pane());
       
  3861 
       
  3862                 TAknLayoutRect oneButtonLayRect;
       
  3863                 oneButtonLayRect.LayoutRect(categoryButtonLayRect.Rect(),AknLayoutScalable_Avkon::cell_sct_catagory_button_pane());
       
  3864 
       
  3865                 TSize size(oneButtonLayRect.Rect().Width(), oneButtonLayRect.Rect().Height()*iExtension->iRadioButton->Count());
       
  3866                 TRect rectRadio(categoryButtonLayRect.Rect().iTl, size);
       
  3867                 iExtension->iRadioButton->SetRect(rectRadio);
       
  3868                 }
       
  3869             }
       
  3870 
  2700 
  3871 
  2701         // Background context.
  3872         // Background context.
  2702         if(iExtension && iExtension->iBgContext)
  3873         if(iExtension && iExtension->iBgContext)
  2703             {
  3874             {
  2704             TInt varietyNumber = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
  3875             TInt varietyNumber = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
  2709 
  3880 
  2710         TRAP_IGNORE( UpdateScrollIndicatorL() );
  3881         TRAP_IGNORE( UpdateScrollIndicatorL() );
  2711         }
  3882         }
  2712     else
  3883     else
  2713         {
  3884         {
  2714         TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 7 : 6;
  3885         
       
  3886         TInt variety;
       
  3887         if (!IsJapaneseSctUi())
       
  3888             {
       
  3889             variety = Layout_Meta_Data::IsLandscapeOrientation() ? 3 : 1;
       
  3890             if(TableCount() > 1) variety--;
       
  3891             }
       
  3892         else
       
  3893             {
       
  3894             variety = Layout_Meta_Data::IsLandscapeOrientation() ? 5 : 4;
       
  3895             }
  2715         
  3896         
  2716         // Popup.
  3897         // Popup.
  2717         TAknLayoutRect popupGridLayRect;
  3898         TAknLayoutRect popupGridLayRect;
  2718         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  3899         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  2719         TRect popupGridRect = popupGridLayRect.Rect();
  3900         TRect popupGridRect = popupGridLayRect.Rect();
  2734             {
  3915             {
  2735             iOffset.iX = gridRect.iTl.iX + 1;
  3916             iOffset.iX = gridRect.iTl.iX + 1;
  2736             iGridTopLeft.iX = gridRect.iTl.iX;
  3917             iGridTopLeft.iX = gridRect.iTl.iX;
  2737             }
  3918             }
  2738 
  3919 
       
  3920         // Category
       
  3921         if (iExtension->iHasCategoryButtonUi && iExtension->iRadioButton) // Radio buttons.
       
  3922             {
       
  3923             TAknLayoutRect oneButtonLayRect;
       
  3924             TAknLayoutRect categoryButtonLayRect;
       
  3925             TInt oneButtonLayVariety, categoryButtonLayVariety;
       
  3926             
       
  3927             if (Layout_Meta_Data::IsLandscapeOrientation())
       
  3928                 {
       
  3929                 oneButtonLayVariety = 5;
       
  3930                 categoryButtonLayVariety = 1;
       
  3931                 }
       
  3932             else
       
  3933                 {
       
  3934                 oneButtonLayVariety = 4;
       
  3935                 categoryButtonLayVariety = 0;
       
  3936                 }
       
  3937             
       
  3938             oneButtonLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_control_pane(oneButtonLayVariety));
       
  3939             categoryButtonLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_catg_pane(categoryButtonLayVariety));
       
  3940 
       
  3941             TSize size(oneButtonLayRect.Rect().Width(), 
       
  3942                        oneButtonLayRect.Rect().Height() * iExtension->iRadioButton->Count());
       
  3943             TRect rectRadio(categoryButtonLayRect.Rect().iTl, size);
       
  3944             iExtension->iRadioButton->SetRect(rectRadio);
       
  3945             }
       
  3946 
       
  3947         // Table navigation.
       
  3948         if (iExtension->iTableNavi)
       
  3949             {
       
  3950             TAknLayoutRect tableNaviLayRect;
       
  3951             tableNaviLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_control_pane(variety));
       
  3952             iExtension->iTableNavi->SetRect(tableNaviLayRect.Rect());
       
  3953             }
       
  3954 
  2739         // Page navigation.
  3955         // Page navigation.
  2740         if (iExtension->iPageNavi)
  3956         if (iExtension->iPageNavi)
  2741             {
  3957             {
  2742             iExtension->iPageNavi->MakeVisible(ETrue);
  3958             if (PageCount() > 1)
  2743 
  3959                 {
  2744             TAknLayoutRect pageNaviLayRect;
  3960                 iExtension->iPageNavi->MakeVisible(ETrue);
  2745             pageNaviLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_control_pane(variety));
  3961                 
  2746             iExtension->iPageNavi->SetRect(pageNaviLayRect.Rect());
  3962                 TAknLayoutRect pageNaviLayRect;
       
  3963                 pageNaviLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::graphic2_pages_pane(variety));
       
  3964                 iExtension->iPageNavi->SetRect(pageNaviLayRect.Rect());
       
  3965                 }
       
  3966             else
       
  3967                 {
       
  3968                 iExtension->iPageNavi->MakeVisible(EFalse);
       
  3969                 }
  2747             }
  3970             }
  2748 
  3971 
  2749         // Background context.
  3972         // Background context.
  2750         if(iExtension->iBgContext)
  3973         if(iExtension->iBgContext)
  2751             {
  3974             {
  2767 
  3990 
  2768 void CAknCharMap::DoHandleResourceChangeL(TInt aType)
  3991 void CAknCharMap::DoHandleResourceChangeL(TInt aType)
  2769     {
  3992     {
  2770     if (aType == KEikDynamicLayoutVariantSwitch)
  3993     if (aType == KEikDynamicLayoutVariantSwitch)
  2771         {
  3994         {
  2772     
  3995         TInt pos = (iFirstVisibleRow + iCursorPos.iY) * iMaxColumns + iCursorPos.iX;
  2773         SetSmileyAnimationActivityInCurrentPageL(EFalse);
  3996 
  2774         
  3997         // Cursor position before layout switch.
  2775         TInt cursorIndexBeforeSwitch = (iFirstVisibleRow + iCursorPos.iY) * iMaxColumns + iCursorPos.iX;
  3998         TInt previousCursorPosition;
  2776         TInt recentLengthBeforeSwitch = iMaxColumns;
  3999         TInt previousLength = iMaxColumns;
  2777         TBool recentWasSetBeforeSwitch = iSetRecentSct;
  4000         if (pos < previousLength)
       
  4001             {
       
  4002             previousCursorPosition = pos; // recent char
       
  4003             }
       
  4004         else
       
  4005             {
       
  4006             previousCursorPosition = pos - previousLength; // grid.
       
  4007             }
  2778 
  4008 
  2779         // Disabled because the buffer content may change due to diffent layout.
  4009         // Disabled because the buffer content may change due to diffent layout.
  2780         if (recentWasSetBeforeSwitch) DisableRecentCharsRow();
  4010         TBool recentWasSet = iSetRecentSct;
       
  4011         if (recentWasSet) DisableRecentCharsRow();
  2781 
  4012 
  2782         // Calculate the new magnitudes (iMaxColumns, etc.).
  4013         // Calculate the new magnitudes (iMaxColumns, etc.).
  2783         DoLayout();
  4014         DoLayout();
  2784 
  4015 
  2785         // Append right amount of recent characters due to different layout.
  4016         // Append right amount of recent characters due to different layout.
  2786         if (recentWasSetBeforeSwitch) AppendRecentCharL();
  4017         if (recentWasSet) AppendRecentCharL();
  2787 
  4018 
  2788         // Sets the character case because the buffer content may have changed.
  4019         // Sets the character case because the buffer content may have changed.
  2789         SetCharacterCaseL(iSpecialCharCase);
  4020         SetCharacterCaseL(iSpecialCharCase);
  2790         
  4021 
  2791         TInt cursorIndexAfterSwitch;
  4022         // Calculates the index position of the cursor in the char table and
  2792         if ( !iExtension->iKeyBrdEvent )
  4023         // update the x and y positions for the new grid with it
  2793             {
  4024         TInt currentCursorPosition = previousCursorPosition;
  2794             cursorIndexAfterSwitch = cursorIndexBeforeSwitch;
  4025         TInt currentLength = iMaxColumns; // iMaxColumns may have changed.
  2795             }
  4026         if (pos < previousLength) // recent char
  2796         else
  4027             {
  2797             {
  4028             if (pos >= currentLength) // cannot be shown.
  2798             // status after layout switch.
  4029                 {
  2799             TInt recentLengthAfterSwitch = iMaxColumns; // recentLength has
  4030                 currentCursorPosition = 0;
  2800                                                         // changed after switch
  4031                 }
  2801             if ( cursorIndexBeforeSwitch < recentLengthBeforeSwitch )
  4032             }
  2802                 {
  4033         else // grid cell
  2803                 cursorIndexAfterSwitch = cursorIndexBeforeSwitch;
  4034             {
  2804                 }
  4035             currentCursorPosition += currentLength;
  2805             else
  4036             }
  2806                 {
  4037 
  2807                 cursorIndexAfterSwitch = cursorIndexBeforeSwitch -
       
  2808                             recentLengthBeforeSwitch + recentLengthAfterSwitch;
       
  2809                 }
       
  2810             }
       
  2811         // the new first row is the top row on the page where the new focus is.
  4038         // the new first row is the top row on the page where the new focus is.
  2812         TInt pageVolume = iMaxColumns * iExtension->iMaxVisibleRows;
  4039         iFirstVisibleRow = iExtension->iMaxVisibleRows *
  2813         iFirstVisibleRow = (cursorIndexAfterSwitch / pageVolume * pageVolume) / iMaxColumns;
  4040             (currentCursorPosition / (iMaxColumns * iExtension->iMaxVisibleRows));
  2814         
       
  2815         SetSmileyAnimationActivityInCurrentPageL(ETrue);
       
  2816 
  4041 
  2817         // the cursor positions are relative to current page
  4042         // the cursor positions are relative to current page
  2818         TInt cursorIndexAfterSwitchInPage = cursorIndexAfterSwitch - (iMaxColumns * iFirstVisibleRow);
  4043         iCursorPos.iY = (currentCursorPosition -
  2819         iCursorPos.iX = cursorIndexAfterSwitchInPage % iMaxColumns;
  4044             (iMaxColumns * iFirstVisibleRow)) / iMaxColumns;
  2820         iCursorPos.iY = cursorIndexAfterSwitchInPage / iMaxColumns;
  4045 
  2821         
  4046         iCursorPos.iX = currentCursorPosition -
  2822         iOldCursorPos = iCursorPos;
  4047             (iMaxColumns * iFirstVisibleRow) - (iMaxColumns * iCursorPos.iY);
       
  4048 
       
  4049         iOldCursorPos.iY = (previousCursorPosition -
       
  4050             (iMaxColumns * iFirstVisibleRow)) / iMaxColumns;
       
  4051 
       
  4052         iOldCursorPos.iX = previousCursorPosition -
       
  4053             (iMaxColumns * iFirstVisibleRow) - (iMaxColumns * iOldCursorPos.iY);
  2823 
  4054 
  2824         // for full screen touch UI.
  4055         // for full screen touch UI.
  2825         CEikDialog* dlg;
  4056         CEikDialog* dlg;
  2826         MopGetObject(dlg);
  4057         MopGetObject(dlg);
  2827         CEikDialogExtension* dlgExtension = dlg ? dlg->Extension() : NULL;
  4058         CEikDialogExtension* dlgExtension = dlg ? dlg->Extension() : NULL;
  2836                 dlgExtension->iPublicFlags.Clear(CEikDialogExtension::EUseVirtualInput);
  4067                 dlgExtension->iPublicFlags.Clear(CEikDialogExtension::EUseVirtualInput);
  2837                 }
  4068                 }
  2838             }
  4069             }
  2839 
  4070 
  2840         // Sets alternate UI controls.
  4071         // Sets alternate UI controls.
  2841         if (AknLayoutUtils::PenEnabled())
  4072         if (iExtension->iHasCategoryButtonUi)
  2842             {
  4073             {
  2843             EnableNavigationButtonsL();
  4074             if (AknLayoutUtils::PenEnabled())
       
  4075                 {
       
  4076                 EnableCategoryInputFieldL();
       
  4077                 EnableNavigationButtonsL();
       
  4078                 }
       
  4079             else
       
  4080                 {
       
  4081                 DisableCategoryInputFieldL();
       
  4082                 DisableNavigationButtonsL();
       
  4083                 }
       
  4084             EnableCategoryButtonsL();
  2844             }
  4085             }
  2845         else
  4086         else
  2846             {
  4087             {
  2847             DisableNavigationButtonsL();
  4088             DisableCategoryInputFieldL();
  2848             }
  4089             DisableCategoryButtonsL();
  2849 
  4090             if (AknLayoutUtils::PenEnabled())
       
  4091                 {
       
  4092                 EnableNavigationButtonsL();
       
  4093                 }
       
  4094             else
       
  4095                 {
       
  4096                 DisableNavigationButtonsL();
       
  4097                 }
       
  4098             }
  2850 
  4099 
  2851         // and finally updates the page counts (from setcasetable)
  4100         // and finally updates the page counts (from setcasetable)
  2852         iSpecialCharPages.Reset(); // reset the current page count for different charsets
  4101         iSpecialCharPages.Reset(); // reset the current page count for different charsets
  2853         iSpecialCharPages.AppendL( PageCountFromChars(*iChars) );
  4102         iSpecialCharPages.AppendL( PageCountFromChars(*iChars) );
  2854         for (TInt i(1); i < iSpecialCharCases.Count(); ++i)
  4103         for (TInt i(1); i < iSpecialCharCases.Count(); ++i)
  2878         // !resize an option but the cost only differs with the creation of the graphic objects!
  4127         // !resize an option but the cost only differs with the creation of the graphic objects!
  2879         CreateOffscreenBackgroundL();
  4128         CreateOffscreenBackgroundL();
  2880         iOffscreenBgDrawn = EFalse;
  4129         iOffscreenBgDrawn = EFalse;
  2881         }
  4130         }
  2882 
  4131 
  2883     else if( aType == KAknsMessageSkinChange )
  4132 
       
  4133     if( aType == KAknsMessageSkinChange )
  2884         {
  4134         {
  2885         iOffscreenBgDrawn = EFalse;
  4135         iOffscreenBgDrawn = EFalse;
  2886         }
  4136         }
  2887 
       
  2888     else if(aType == KEikMessageFadeAllWindows) // focus gained // KEikMessageWindowsFadeChange
       
  2889         {
       
  2890         Extension()->iCharMapFocusGained = ETrue;
       
  2891         SetSmileyAnimationActivityInCurrentPageL(ETrue);
       
  2892         }
       
  2893     
       
  2894     else if(aType == KAknMessageFocusLost) // focus lost
       
  2895         {
       
  2896         Extension()->iCharMapFocusGained = EFalse;
       
  2897         SetSmileyAnimationActivityInCurrentPageL(EFalse);
       
  2898         
       
  2899         if ( iExtension->iHighlightVisible )
       
  2900             {
       
  2901             iExtension->iHighlightVisible = EFalse;
       
  2902             DrawCursor();
       
  2903             }
       
  2904         }
       
  2905     }
  4137     }
  2906 
  4138 
  2907 void CAknCharMap::EnableNavigationButtonsL()
  4139 void CAknCharMap::EnableNavigationButtonsL()
  2908     {
  4140     {
  2909     if ( iExtension )
  4141     if ( iExtension )
  2910         {
  4142         {
       
  4143         if ( !iExtension->iTableNavi )
       
  4144             {
       
  4145             iExtension->iTableNavi = new(ELeave) CAknSctTableNavi(this, iExtension);
       
  4146             iExtension->iTableNavi->SetContainerWindowL(*this);
       
  4147             TResourceReader reader;
       
  4148             iCoeEnv->CreateResourceReaderLC(reader, R_AVKON_SCT_TABLE_NAVI_CONTROL);
       
  4149             iExtension->iTableNavi->ConstructFromResourceL(reader);
       
  4150             iExtension->iTableNavi->SetNonFocusing();
       
  4151             iExtension->iTableNavi->SetMopParent(iExtension);
       
  4152             CleanupStack::PopAndDestroy(); // reader
       
  4153             }
       
  4154 
       
  4155         iExtension->iTableNavi->MakeVisible(ETrue);
       
  4156 
  2911         if ( !iExtension->iPageNavi )
  4157         if ( !iExtension->iPageNavi )
  2912             {
  4158             {
  2913             iExtension->iPageNavi = new(ELeave) CAknSctPageNavi(this, iExtension);
  4159             iExtension->iPageNavi = new(ELeave) CAknSctPageNavi(this, iExtension);
  2914             iExtension->iPageNavi->SetContainerWindowL(*this);
  4160             iExtension->iPageNavi->SetContainerWindowL(*this);
  2915             TResourceReader reader;
  4161             TResourceReader reader;
  2924         }
  4170         }
  2925     }
  4171     }
  2926 
  4172 
  2927 void CAknCharMap::DisableNavigationButtonsL()
  4173 void CAknCharMap::DisableNavigationButtonsL()
  2928     {
  4174     {
       
  4175     if ( iExtension && iExtension->iTableNavi )
       
  4176         {
       
  4177         iExtension->iTableNavi->MakeVisible( EFalse );
       
  4178         }
  2929     if ( iExtension && iExtension->iPageNavi )
  4179     if ( iExtension && iExtension->iPageNavi )
  2930         {
  4180         {
  2931         iExtension->iPageNavi->MakeVisible( EFalse );
  4181         iExtension->iPageNavi->MakeVisible( EFalse );
       
  4182         }
       
  4183     }
       
  4184 
       
  4185 void CAknCharMap::EnableCategoryButtonsL()
       
  4186     {
       
  4187     if (!iExtension->iRadioButton)
       
  4188         {
       
  4189         iExtension->iRadioButton = new(ELeave) CAknSctRadioButton(this, iExtension);
       
  4190         iExtension->iRadioButton->SetContainerWindowL(*this);
       
  4191         TResourceReader reader;
       
  4192         iCoeEnv->CreateResourceReaderLC(reader, R_AVKON_SCT_CATEGORY_BUTTON_CONTROL);
       
  4193         iExtension->iRadioButton->ConstructFromResourceL(reader);
       
  4194         iExtension->iRadioButton->SetNonFocusing();
       
  4195         iExtension->iRadioButton->SetMopParent(iExtension);
       
  4196         CleanupStack::PopAndDestroy(); // reader
       
  4197         }
       
  4198     iExtension->iRadioButton->MakeVisible(ETrue);
       
  4199     }
       
  4200 
       
  4201 void CAknCharMap::DisableCategoryButtonsL()
       
  4202     {
       
  4203     if (iExtension && iExtension->iRadioButton)
       
  4204         {
       
  4205         iExtension->iRadioButton->MakeVisible(EFalse);
  2932         }
  4206         }
  2933     }
  4207     }
  2934 
  4208 
  2935 void CAknCharMap::EnableCategoryInputFieldL()
  4209 void CAknCharMap::EnableCategoryInputFieldL()
  2936     {
  4210     {
  3019     CWindowGc& gc=SystemGc();
  4293     CWindowGc& gc=SystemGc();
  3020     gc.UseFont(iFont);
  4294     gc.UseFont(iFont);
  3021 
  4295 
  3022     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  4296     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  3023     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
  4297     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
  3024     AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
       
  3025 
  4298 
  3026     TRect rect = Rect();
  4299     TRect rect = Rect();
  3027 
  4300 
  3028     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
  4301     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
  3029         {
  4302         {
  3030         TRect mainPaneRect;
  4303         TRect mainPaneRect;
  3031         if(!AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EPopupParent, mainPaneRect))
  4304         if(!AknLayoutUtils::LayoutMetricsRect(
       
  4305             AknLayoutUtils::EPopupParent, mainPaneRect))
  3032             {
  4306             {
  3033             mainPaneRect = iAvkonAppUi->ClientRect();
  4307             mainPaneRect = iAvkonAppUi->ClientRect();
  3034             }
  4308             }
  3035 
  4309 
  3036         TAknLayoutScalableParameterLimits charMapDialogVariety = AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
  4310         TAknLayoutScalableParameterLimits charMapDialogVariety =
       
  4311             AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
       
  4312 
  3037         TInt maxVariety = charMapDialogVariety.LastVariety();
  4313         TInt maxVariety = charMapDialogVariety.LastVariety();
       
  4314 
       
  4315         AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
  3038         TInt maxVarietyOffset = 0;
  4316         TInt maxVarietyOffset = 0;
  3039         TInt varietyOffset = maxVariety + 1;
  4317         TInt varietyOffset = maxVariety + 1;
  3040 
  4318 
  3041         if(Layout_Meta_Data::IsLandscapeOrientation())
  4319         if(Layout_Meta_Data::IsLandscapeOrientation())
  3042             {
  4320             {
  3063             varietyNumber -= 1;
  4341             varietyNumber -= 1;
  3064             }
  4342             }
  3065         varietyNumber += maxVarietyOffset;
  4343         varietyNumber += maxVarietyOffset;
  3066 
  4344 
  3067         TAknLayoutRect popupGridLayRect;
  4345         TAknLayoutRect popupGridLayRect;
  3068         popupGridLayRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::popup_grid_graphic_window(varietyNumber));
  4346         popupGridLayRect.LayoutRect(mainPaneRect,
       
  4347             AknLayoutScalable_Avkon::popup_grid_graphic_window(varietyNumber));
  3069 
  4348 
  3070         // Background height.
  4349         // Background height.
  3071         TInt backgroundHeightOffset = popupGridLayRect.Rect().Height() - rect.iBr.iY;
  4350         TInt backgroundHeightOffset =
       
  4351             popupGridLayRect.Rect().Height() - rect.iBr.iY;
       
  4352 
  3072         rect.iBr.iY += backgroundHeightOffset;
  4353         rect.iBr.iY += backgroundHeightOffset;
  3073         }
  4354         }
  3074     else
  4355     else
  3075         {
  4356         {
  3076         TAknLayoutRect popupGridLayRect;
  4357         TAknLayoutRect popupGridLayRect;
  3077         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  4358         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
  4359             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  3078 
  4360 
  3079         // Background height.
  4361         // Background height.
  3080         TInt backgroundHeightOffset = popupGridLayRect.Rect().Height() - rect.iBr.iY;
  4362         TInt backgroundHeightOffset =
       
  4363             popupGridLayRect.Rect().Height() - rect.iBr.iY;
       
  4364 
  3081         rect.iBr.iY += backgroundHeightOffset * 2;
  4365         rect.iBr.iY += backgroundHeightOffset * 2;
  3082         }
  4366         }
  3083 
  4367 
  3084     // Grid (main).
  4368     // Grid (main).
  3085     if ( !Extension()->iMenuSct )
  4369     if ( !Extension()->iMenuSct )
  3086         {
  4370         {
  3087         // 1) Draw the background
  4371         // 1) Draw the background
       
  4372 
  3088         // Check if we got an offscreen bitmap allocated for skin background and
  4373         // Check if we got an offscreen bitmap allocated for skin background and
  3089         // there is bitmap background in the current skin.
  4374         // there is bitmap background in the current skin.
  3090         if( CAknEnv::Static()->TransparencyEnabled() )
  4375         if ( iOffscreenBg )
  3091             {
  4376             {
  3092             TRegionFix<10> clipReg;
  4377             DrawOffscreenBackgroundIfRequired();
  3093             clipReg.AddRect(rect);
  4378             gc.BitBlt( rect.iTl, iOffscreenBg );
  3094 
  4379             }
  3095             if ( iFirstVisibleRow == 0 && iSetRecentSct )
  4380         else
  3096                 {
  4381             {
  3097                 TPoint pos = iGridTopLeft;
  4382             if( CAknEnv::Static()->TransparencyEnabled() )
  3098                 TSize size(iGridItemWidth*iMaxColumns+1, iGridItemHeight);
  4383                 {
  3099                 if(iIsMirrored)
  4384                 TRegionFix<10> clipReg;
  3100                     {
  4385                 clipReg.AddRect(rect);
  3101                     pos.iX += iGridItemWidth - size.iWidth;
  4386                 if ( iFirstVisibleRow == 0 && iSetRecentSct )
  3102                     }
  4387                     {
  3103                 // eliminate the overlap area between menu sct and the first menu item.
  4388                     TPoint pos = iGridTopLeft;
  3104                 if ( Extension()->iMenuSct )
  4389                     TInt endX = pos.iX + iGridItemWidth * iMaxColumns + 1;
  3105                     {
  4390                     TInt endY = pos.iY + iGridItemHeight;
  3106                     size.iHeight--;
  4391                     // eliminate the overlap area between menu sct and the first menu item.
  3107                     }
  4392                     if ( Extension()->iMenuSct )
  3108                 clipReg.SubRect(TRect(pos,size));
  4393                         {
  3109                 }
  4394                         endY--;
  3110             
  4395                         }
  3111             // Take scroll bar out of clip region
  4396                     clipReg.SubRect( TRect( pos, TPoint( endX, endY ) ) );
  3112             if (iSBFrame)
  4397                     }
  3113                 {
  4398                 // Take scroll bar out of clip region
  3114                 clipReg.SubRect(iSBFrame->GetScrollBarHandle(CEikScrollBar::EVertical)->Rect());
  4399                 if (iSBFrame)
  3115                 }
  4400                     {
  3116 
  4401                     clipReg.SubRect(iSBFrame->GetScrollBarHandle(
  3117             gc.SetClippingRegion(clipReg);
  4402                         CEikScrollBar::EVertical)->Rect());
  3118             }
  4403                     }
  3119         
  4404                 gc.SetClippingRegion(clipReg);
  3120         AknsDrawUtils::Background( skin, cc, this, gc, rect,KAknsDrawParamNoClearUnderImage);
  4405                 }
  3121         
  4406             AknsDrawUtils::Background( skin, cc, this, gc, rect,KAknsDrawParamNoClearUnderImage);
  3122         if( CAknEnv::Static()->TransparencyEnabled() )
  4407             if( CAknEnv::Static()->TransparencyEnabled() )
  3123             {
  4408                 {
  3124             gc.CancelClippingRegion();
  4409                 gc.CancelClippingRegion();
  3125             }
  4410                 }
  3126 
  4411             }
  3127         // 2) Draw the grid
  4412 
  3128         gc.SetPenStyle(CGraphicsContext::ESolidPen);
  4413         gc.SetPenStyle(CGraphicsContext::ESolidPen);
  3129         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
  4414         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
  3130         gc.SetPenSize(TSize(1,1));
  4415         gc.SetPenSize(TSize(1,1));
       
  4416 
       
  4417         // 2) Draw the grid
  3131         DrawGrid(gc);
  4418         DrawGrid(gc);
  3132         }
  4419         }
  3133 
  4420 
  3134     // Grid (recent).
  4421     // Grid (recent).
  3135     if (iFirstVisibleRow==0 && iSetRecentSct)
  4422     if (iFirstVisibleRow==0 && iSetRecentSct)
  3151             if(!EmotionsAreAllReadyToDraw(charIndex, iMaxColumns)) break;
  4438             if(!EmotionsAreAllReadyToDraw(charIndex, iMaxColumns)) break;
  3152             }
  4439             }
  3153         
  4440         
  3154         // grid is focused and cursor pos is same with the current index.
  4441         // grid is focused and cursor pos is same with the current index.
  3155         if ( iExtension->iMenuSct )
  4442         if ( iExtension->iMenuSct )
  3156             {
  4443         	{
  3157             highlighted = iExtension->iMenuSctHighlighted && 
  4444             highlighted = iExtension->iMenuSctHighlighted && 
  3158                           (iExtension->iFocusHandler->FocusedControl()==this) && 
  4445                           (iExtension->iFocusHandler->FocusedControl()==this) && 
  3159                           (j==cursorPos);
  4446                           (j==cursorPos);
  3160             }
  4447         	}
  3161         else
  4448         else
  3162             {
  4449         	{
  3163             highlighted = ((iExtension->iFocusHandler->FocusedControl()==this) && (j==cursorPos));
  4450         	highlighted = ((iExtension->iFocusHandler->FocusedControl()==this) && (j==cursorPos));
  3164             }
  4451         	}
  3165         DrawItem(gc, CursorRect(j, charIndex), charIndex, highlighted, EFalse);
  4452         DrawItem(gc, CursorRect(j, charIndex), charIndex, highlighted, EFalse);
  3166         charIndex++;
  4453         charIndex++;
  3167         }
  4454         }
  3168     iDrawnBefore = ETrue;
  4455     iDrawnBefore = ETrue;
  3169     gc.DiscardFont();
  4456     gc.DiscardFont();
  3270     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
  4557     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
  3271 
  4558 
  3272     if( aHighlighted )
  4559     if( aHighlighted )
  3273         {
  4560         {
  3274         TRgb color = AKN_LAF_COLOR(210);
  4561         TRgb color = AKN_LAF_COLOR(210);
  3275         
  4562 		
  3276         if( !( iExtension->iFlags & EAknCharMapPressedDown ) 
  4563         if( !( iExtension->iFlags & EAknCharMapPressedDown ) 
  3277             || iExtension->iSingleClickEnabled )
  4564             || iExtension->iSingleClickEnabled )
  3278             {
  4565             {
  3279             AknsUtils::GetCachedColor( skin, 
  4566             AknsUtils::GetCachedColor( skin, 
  3280                     color, 
  4567                     color, 
  3281                     KAknsIIDQsnHighlightColors, 
  4568                     KAknsIIDQsnHighlightColors, 
  3282                     EAknsCIQsnHighlightColorsCG1 );
  4569                     EAknsCIQsnHighlightColorsCG1 );
  3283             }
  4570             }
  3284             
  4571 			
  3285         else
  4572         else
  3286             {
  4573             {
  3287             AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2 );
  4574             AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2 );
  3288             }
  4575             }
  3289         aGc.SetBrushColor(color);
  4576         aGc.SetBrushColor(color);
  3327         {
  4614         {
  3328         if ( Layout_Meta_Data::IsLandscapeOrientation() )
  4615         if ( Layout_Meta_Data::IsLandscapeOrientation() )
  3329             {
  4616             {
  3330             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(1);
  4617             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(1);
  3331             }
  4618             }
       
  4619         else if (IsJapaneseSctUi())
       
  4620             {
       
  4621             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(2);
       
  4622             }
  3332         else
  4623         else
  3333             {
  4624             {
  3334             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(0);
  4625             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(0);
  3335             }
  4626             }
  3336         }
  4627         }
  3340         }
  4631         }
  3341 
  4632 
  3342     TRect textRect = aSctPosition;
  4633     TRect textRect = aSctPosition;
  3343     if( IsRecentChar(aCharIndex) )
  4634     if( IsRecentChar(aCharIndex) )
  3344         {
  4635         {
       
  4636         textRect.Move(0, -1);       //because height of recent char frame decreased 1.
  3345         if( Extension()->iMenuSct )
  4637         if( Extension()->iMenuSct )
  3346             {
  4638             {
  3347             textRect.Move(0, -1);   //because menu sct will also shrink 1.
  4639             textRect.Move(0, -1);   //because menu sct will also shrink 1.
  3348             }
  4640             }
  3349         }
  4641         }
  3425         {
  4717         {
  3426         AknsUtils::GetCachedColor( skin, color,
  4718         AknsUtils::GetCachedColor( skin, color,
  3427             KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 );
  4719             KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 );
  3428         }
  4720         }
  3429     
  4721     
  3430     CAknSmileyIcon* icon = iExtension->EmotionIcon(symbol[0]);
  4722     if(TEmotionUtils::IsEmotionChar(symbol[0]))
  3431     if(icon) 
  4723         {
  3432         {
  4724         iExtension->DrawEmotion(aGc, textLayout.TextRect(), symbol[0]);
  3433         iExtension->DrawEmotion( aGc, textLayout.TextRect(), icon );
       
  3434         }
  4725         }
  3435     else
  4726     else
  3436         {
  4727         {
  3437         textLayout.DrawText( aGc, symbol, EFalse, color );
  4728         textLayout.DrawText( aGc, symbol, EFalse, color );
  3438         }
  4729         }
  3459 // Draw the outter thick frame for the all recent chars.
  4750 // Draw the outter thick frame for the all recent chars.
  3460 //-------------------------------------------------------
  4751 //-------------------------------------------------------
  3461 //
  4752 //
  3462 void CAknCharMap::DrawRecentCharFrame( CWindowGc& aGc) const
  4753 void CAknCharMap::DrawRecentCharFrame( CWindowGc& aGc) const
  3463     {
  4754     {
  3464     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  4755     MAknsSkinInstance*   skin = AknsUtils::SkinInstance();
  3465     MAknsControlContext* cc = iExtension->iBgContext;
  4756     MAknsControlContext* cc = iExtension->iBgContext;
  3466     if ( !cc )
  4757     if ( !cc )
  3467         {
  4758         {
  3468         cc = AknsDrawUtils::ControlContext( this );
  4759         cc = AknsDrawUtils::ControlContext( this );
  3469         }
  4760         }
  3470 
  4761 
  3471     TPoint pos = iGridTopLeft;
  4762     TPoint pos = iGridTopLeft;
  3472     TSize size(iGridItemWidth*iMaxColumns+1, iGridItemHeight);
  4763     TInt endX = pos.iX + iGridItemWidth * iMaxColumns + 1;
  3473     
  4764     TInt endY = pos.iY + iGridItemHeight;
       
  4765     TRect drawRect(TPoint(pos.iX, pos.iY), TPoint(endX, endY));
  3474     // eliminate the overlap area between menu sct and the first menu item.
  4766     // eliminate the overlap area between menu sct and the first menu item.
  3475     if ( Extension()->iMenuSct )
  4767     if ( Extension()->iMenuSct )
  3476         {
  4768         {
  3477         // provide a dirty fix for Menu SCT, since Layout data is not suitable for this
  4769         drawRect = Rect();
  3478         size = TSize( Rect().Width()- 1, iGridItemHeight - 1 );
  4770         endY--;
  3479         }
  4771         }
       
  4772 
       
  4773     AknsDrawUtils::Background( skin, cc, this, aGc, drawRect );
       
  4774 
       
  4775     SetRecentCharFrameStyle(aGc);
  3480     if(iIsMirrored)
  4776     if(iIsMirrored)
  3481         {
  4777         {
  3482         pos.iX += iGridItemWidth - size.iWidth;
  4778         pos.iX = iGridTopLeft.iX - ((iMaxColumns - 1) * iGridItemWidth);
  3483         }
  4779         endX = iGridTopLeft.iX + iGridItemWidth + 1;
  3484 
  4780         }
  3485     AknsDrawUtils::Background(skin, cc, this, aGc, TRect(pos,size));
  4781 
  3486 
  4782     aGc.DrawRect( TRect(TPoint(pos.iX-1, pos.iY-1), TPoint(endX, endY)));
  3487     SetRecentCharFrameStyle(aGc);
  4783     
  3488     aGc.DrawRect(TRect(pos,size));
       
  3489 
       
  3490     MTouchFeedback* feedback = MTouchFeedback::Instance();
  4784     MTouchFeedback* feedback = MTouchFeedback::Instance();
  3491     CFeedbackSpec* spec = CFeedbackSpec::New();
  4785     CFeedbackSpec* spec = CFeedbackSpec::New();
  3492 
  4786 
  3493     if ( spec && feedback )
  4787     if ( spec && feedback )
  3494         {
  4788         {
  3495         CAknCharMap* mutableThis = MUTABLE_CAST( CAknCharMap* ,this );
  4789         CAknCharMap* mutableThis = MUTABLE_CAST( CAknCharMap* ,this );
  3496         TInt recentChars = mutableThis->LengthOfRecentChar();
  4790         TInt recentChars = mutableThis->LengthOfRecentChar();
  3497         TRect rect;
  4791         TRect rect;
  3498         spec->AddFeedback( ETouchEventStylusDown, 
  4792         spec->AddFeedback( ETouchEventStylusDown, 
  3499                            ETouchFeedbackList );
  4793                            ETouchFeedbackBasicItem );
  3500         rect.SetRect( pos, TPoint( pos.iX + recentChars * iGridItemWidth, pos.iY + iGridItemHeight ));
  4794         rect.SetRect( pos, TPoint( pos.iX + recentChars * iGridItemWidth, pos.iY + iGridItemHeight ));
  3501         if ( iIsMirrored )
  4795         if ( iIsMirrored )
  3502             {
  4796             {
  3503             TInt emptyRecentSlots = iMaxColumns - recentChars;
  4797             TInt emptyRecentSlots = iMaxColumns - recentChars;
  3504             rect.Move( emptyRecentSlots * iGridItemWidth, 0 );
  4798             rect.Move( emptyRecentSlots * iGridItemWidth, 0 );
  3577     MTouchFeedback* feedback = MTouchFeedback::Instance();
  4871     MTouchFeedback* feedback = MTouchFeedback::Instance();
  3578     CFeedbackSpec* spec = CFeedbackSpec::New();
  4872     CFeedbackSpec* spec = CFeedbackSpec::New();
  3579 
  4873 
  3580     if ( feedback && spec )
  4874     if ( feedback && spec )
  3581         {
  4875         {
  3582         TInt orphans = numberOfCells % iMaxColumns;
  4876         TInt orphans = NumberOfVisibleChars() % iMaxColumns;
  3583         TInt rows = numberOfCells / iMaxColumns;
  4877         TInt rows = NumberOfVisibleChars() / iMaxColumns;
  3584         CAknCharMap* mutableThis = MUTABLE_CAST( CAknCharMap* ,this );
  4878         CAknCharMap* mutableThis = MUTABLE_CAST( CAknCharMap* ,this );
  3585         TInt recentChars = mutableThis->LengthOfRecentChar();    
  4879         TInt recentChars = mutableThis->LengthOfRecentChar();    
  3586         TRect rectMain;
  4880         TRect rectMain;
  3587         TPoint nextTopLeft = iGridTopLeft;    
  4881         TPoint nextTopLeft = iGridTopLeft;    
  3588 
  4882 
  3598             {
  4892             {
  3599             rectMain.Move( ( 1 - iMaxColumns ) * iGridItemWidth, 0 );
  4893             rectMain.Move( ( 1 - iMaxColumns ) * iGridItemWidth, 0 );
  3600             }
  4894             }
  3601 
  4895 
  3602         spec->AddFeedback( ETouchEventStylusDown, 
  4896         spec->AddFeedback( ETouchEventStylusDown, 
  3603                            ETouchFeedbackList );
  4897                            ETouchFeedbackBasicItem );
  3604         if ( rows )
  4898         if ( rows )
  3605             {
  4899             {
  3606             feedback->SetFeedbackArea( this, KAreaIdMain, rectMain, spec );
  4900             feedback->SetFeedbackArea( this, KAreaIdMain, rectMain, spec );
  3607             }
  4901             }
  3608         else
  4902         else
  3807          ( (iChaMapTableCase!=EAknCharMapTableSpecialChar && !iPictoInterface->Interface()->IsPictograph((*iChars)[0])) || 
  5101          ( (iChaMapTableCase!=EAknCharMapTableSpecialChar && !iPictoInterface->Interface()->IsPictograph((*iChars)[0])) || 
  3808            (iChaMapTableCase==EAknCharMapTableSpecialChar && (*iChars)[0]==KHistoryEmptyChar) ) 
  5102            (iChaMapTableCase==EAknCharMapTableSpecialChar && (*iChars)[0]==KHistoryEmptyChar) ) 
  3809        )
  5103        )
  3810         {
  5104         {
  3811         caseChange = ETrue;
  5105         caseChange = ETrue;
  3812 
  5106         // Cursor was on the second line
       
  5107         if (aDeltaY < 0)
       
  5108             {
       
  5109             globalYPos--;
       
  5110             }
  3813         // Cursor was on the second line and first position
  5111         // Cursor was on the second line and first position
  3814         if (aDeltaX < 0 && iCursorPos.iX == 0)
  5112         if (aDeltaX < 0 && iCursorPos.iX == 0)
  3815             {
  5113             {
  3816             globalYPos--;
  5114             globalYPos--;
  3817             //iCursorPos.iY = 0;
  5115             //iCursorPos.iY = 0;
  4067             else
  5365             else
  4068                 {
  5366                 {
  4069                 pt.iX = index;
  5367                 pt.iX = index;
  4070                 }
  5368                 }
  4071             }
  5369             }
       
  5370         
       
  5371         HandleFocusStatusChanged();
  4072 
  5372 
  4073         iCursorPos = pt;
  5373         iCursorPos = pt;
  4074         UpdateScrollIndicatorL();
  5374         UpdateScrollIndicatorL();
  4075         DrawNow();
  5375         DrawNow();
  4076         }
  5376         }
  4103         if ((iRows > iExtension->iMaxVisibleRows) &&
  5403         if ((iRows > iExtension->iMaxVisibleRows) &&
  4104             (iOldCursorPos.iY + oldFirstVisibleRow != iCursorPos.iY + iFirstVisibleRow))
  5404             (iOldCursorPos.iY + oldFirstVisibleRow != iCursorPos.iY + iFirstVisibleRow))
  4105             {
  5405             {
  4106             UpdateScrollIndicatorL();
  5406             UpdateScrollIndicatorL();
  4107             }
  5407             }
       
  5408         
       
  5409         HandleFocusStatusChanged();
  4108 
  5410 
  4109         if (oldFirstVisibleRow == iFirstVisibleRow)
  5411         if (oldFirstVisibleRow == iFirstVisibleRow)
  4110             {
  5412             {
  4111                 // Draw only cursor if the view to the content was not scrolled.
  5413                 // Draw only cursor if the view to the content was not scrolled.
  4112             DrawCursor();
  5414             DrawCursor();
  4195 
  5497 
  4196     // Calculate the relative rect for the grid
  5498     // Calculate the relative rect for the grid
  4197     TRect parent = gridWithScrollLayRect.Rect();
  5499     TRect parent = gridWithScrollLayRect.Rect();
  4198 
  5500 
  4199     TAknWindowComponentLayout scrollbarLayout;
  5501     TAknWindowComponentLayout scrollbarLayout;
  4200     scrollbarLayout = AknLayoutScalable_Avkon::scroll_pane_cp5(0);
  5502     if (iExtension->iHasCategoryButtonUi)
       
  5503         {
       
  5504         scrollbarLayout = AknLayoutScalable_Avkon::scroll_pane_cp5(1);
       
  5505         }
       
  5506     else
       
  5507         {
       
  5508         scrollbarLayout = AknLayoutScalable_Avkon::scroll_pane_cp5(0);
       
  5509         }
  4201 
  5510 
  4202     vSbarModel.iScrollSpan = PageCount() * iExtension->iMaxVisibleRows;
  5511     vSbarModel.iScrollSpan = PageCount() * iExtension->iMaxVisibleRows;
  4203     vSbarModel.iThumbSpan = iExtension->iMaxVisibleRows;
  5512     vSbarModel.iThumbSpan = iExtension->iMaxVisibleRows;
  4204 
  5513 
  4205     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  5514     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  4431     return result;
  5740     return result;
  4432     }
  5741     }
  4433 
  5742 
  4434 void CAknCharMap::CreateOffscreenBackgroundL()
  5743 void CAknCharMap::CreateOffscreenBackgroundL()
  4435     {
  5744     {
  4436     
  5745     // Offscreen background bitmap for pictograph table - needed for performance.
       
  5746     // It is created always even if the current skin does not contain bitmap
       
  5747     // background, because skin change is done in a non-leaving function
       
  5748     // HandleResourceChange so memory allocations should not be done there.
       
  5749 
       
  5750     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  5751     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  5752 
       
  5753     iOffscreenBgDrawn = EFalse;
       
  5754 
       
  5755     TRect popupGridRect;
       
  5756     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
       
  5757         {
       
  5758         TRect mainPaneRect;
       
  5759         if(!AknLayoutUtils::LayoutMetricsRect(
       
  5760             AknLayoutUtils::EPopupParent, mainPaneRect))
       
  5761             {
       
  5762             mainPaneRect = iAvkonAppUi->ClientRect();
       
  5763             }
       
  5764         TAknLayoutScalableParameterLimits charMapDialogVariety =
       
  5765             AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
       
  5766 
       
  5767         TInt maxVariety = charMapDialogVariety.LastVariety();
       
  5768 
       
  5769         AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
       
  5770         TInt maxVarietyOffset = 0;
       
  5771         TInt varietyOffset = maxVariety + 1;
       
  5772         if(Layout_Meta_Data::IsLandscapeOrientation())
       
  5773             {
       
  5774             varietyOffset = (maxVariety + 1) / KAknSctCBaButtonDirections;
       
  5775             }
       
  5776 
       
  5777         if(location == AknLayoutUtils::EAknCbaLocationRight)
       
  5778             {
       
  5779             maxVarietyOffset = varietyOffset;
       
  5780             }
       
  5781         else if(location == AknLayoutUtils::EAknCbaLocationLeft)
       
  5782             {
       
  5783             maxVarietyOffset = varietyOffset + varietyOffset;
       
  5784             }
       
  5785         TInt varietyNumber = varietyOffset - iRows;
       
  5786 
       
  5787         if(varietyNumber < 0)
       
  5788             {
       
  5789             varietyNumber = 0;
       
  5790             }
       
  5791         else if(iRows<=0)
       
  5792             {
       
  5793             varietyNumber -= 1;
       
  5794             }
       
  5795 
       
  5796         varietyNumber += maxVarietyOffset;
       
  5797 
       
  5798         TAknLayoutRect popupGridLayRect;
       
  5799         popupGridLayRect.LayoutRect(mainPaneRect,
       
  5800             AknLayoutScalable_Avkon::popup_grid_graphic_window(varietyNumber));
       
  5801 
       
  5802         popupGridRect = popupGridLayRect.Rect();
       
  5803         }
       
  5804     else
       
  5805         {
       
  5806         TAknLayoutRect popupGridLayRect;
       
  5807         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
  5808             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
       
  5809 
       
  5810         popupGridRect = popupGridLayRect.Rect();
       
  5811         }
       
  5812 
       
  5813 
       
  5814     if(iOffscreenBg)
       
  5815         {
       
  5816         delete iOffscreenBg;
       
  5817         iOffscreenBg = NULL;
       
  5818         }
       
  5819 
       
  5820     iOffscreenBg = new( ELeave ) CFbsBitmap;
       
  5821     TDisplayMode mode = iCoeEnv->ScreenDevice()->DisplayMode();
       
  5822 
       
  5823     // This is larger rect that is actually needed for the charmap
       
  5824     // control - the problem is that we do not know the changed rect
       
  5825     // of the charmap control yet (because the dialog is just about
       
  5826     // to resize itself).
       
  5827 
       
  5828     if(iBitmapDevice)
       
  5829         {
       
  5830         delete iBitmapDevice;
       
  5831         iBitmapDevice = NULL;
       
  5832         }
       
  5833 
       
  5834     if(iBitmapGc)
       
  5835         {
       
  5836         delete iBitmapGc;
       
  5837         iBitmapGc = NULL;
       
  5838         }
       
  5839 
       
  5840     User::LeaveIfError(
       
  5841         iOffscreenBg->Create( popupGridRect.Size(), mode ) );
       
  5842     iBitmapDevice = CFbsBitmapDevice::NewL( iOffscreenBg );
       
  5843     User::LeaveIfError( iBitmapDevice->CreateContext( iBitmapGc ) );
       
  5844 
  4437     }
  5845     }
  4438 
  5846 
  4439 TInt CAknCharMap::NextPageL()
  5847 TInt CAknCharMap::NextPageL()
  4440     {
  5848     {
  4441     SetSmileyAnimationActivityInCurrentPageL(EFalse);
  5849     HandleFocusStatusChanged(EFalse);
  4442     
  5850     
  4443     TInt page(0);
  5851     TInt page(0);
  4444     iFirstVisibleRow =
  5852     iFirstVisibleRow =
  4445         (((iCursorPos.iY + iFirstVisibleRow) / iExtension->iMaxVisibleRows) + 1)
  5853         (((iCursorPos.iY + iFirstVisibleRow) / iExtension->iMaxVisibleRows) + 1)
  4446                                                     * iExtension->iMaxVisibleRows;
  5854                                                     * iExtension->iMaxVisibleRows;
  4475             }
  5883             }
  4476 
  5884 
  4477         }
  5885         }
  4478     UpdateHeadingPane( ETrue );
  5886     UpdateHeadingPane( ETrue );
  4479     UpdateScrollIndicatorL();
  5887     UpdateScrollIndicatorL();
  4480     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  5888     HandleFocusStatusChanged();
  4481     DrawNow();
  5889     DrawNow();
  4482 
  5890 
  4483     return page;
  5891     return page;
  4484     }
  5892     }
  4485 
  5893 
  4486 TInt CAknCharMap::PrevPageL()
  5894 TInt CAknCharMap::PrevPageL()
  4487     {
  5895     {
  4488     SetSmileyAnimationActivityInCurrentPageL(EFalse);
  5896     HandleFocusStatusChanged(EFalse);
  4489     
  5897     
  4490     TInt page(0);
  5898     TInt page(0);
  4491     TInt firstVisibleRow =
  5899     TInt firstVisibleRow =
  4492         (((iCursorPos.iY + iFirstVisibleRow) / iExtension->iMaxVisibleRows) - 1) *
  5900         (((iCursorPos.iY + iFirstVisibleRow) / iExtension->iMaxVisibleRows) - 1) *
  4493             iExtension->iMaxVisibleRows;
  5901             iExtension->iMaxVisibleRows;
  4520             iCursorPos = TPoint(0, 0);
  5928             iCursorPos = TPoint(0, 0);
  4521             }
  5929             }
  4522         }
  5930         }
  4523     UpdateHeadingPane( ETrue );
  5931     UpdateHeadingPane( ETrue );
  4524     UpdateScrollIndicatorL();
  5932     UpdateScrollIndicatorL();
  4525     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  5933     HandleFocusStatusChanged();
  4526     DrawNow();
  5934     DrawNow();
  4527 
  5935 
  4528     return page;
  5936     return page;
  4529     }
  5937     }
  4530 
  5938 
  4579         }
  5987         }
  4580 
  5988 
  4581     // Draw the background of the item if requested
  5989     // Draw the background of the item if requested
  4582     else if ( aDrawBackground )
  5990     else if ( aDrawBackground )
  4583         {
  5991         {
  4584         aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
  5992         if ( iOffscreenBg )
  4585         aGc.SetBrushColor(AKN_LAF_COLOR(0));
  5993             {
  4586 
  5994             TRect offscreenRect = aSctPosition;
  4587         TRect innerRect = aSctPosition;
  5995             if (IsRecentChar(aCharIndex))
  4588         if (IsRecentChar(aCharIndex))
  5996                 {
  4589             {
  5997                 TRgb colorRecentLine = AKN_LAF_COLOR(215);
  4590             innerRect.Shrink(1,1);
  5998                 AknsUtils::GetCachedColor( skin, colorRecentLine,
  4591             }
  5999                         KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG7 );
  4592         aGc.Clear( innerRect );
  6000                 aGc.SetPenColor(colorRecentLine);
       
  6001                 // draw top line
       
  6002                 aGc.DrawLine( aSctPosition.iTl,
       
  6003                     TPoint( aSctPosition.iBr.iX, aSctPosition.iTl.iY ) );
       
  6004                 // draw under line
       
  6005                 aGc.DrawLine( TPoint( aSctPosition.iTl.iX, aSctPosition.iBr.iY - 1 ),
       
  6006                               TPoint( aSctPosition.iBr.iX, aSctPosition.iBr.iY - 1) );
       
  6007                 if (aCharIndex == 0)
       
  6008                     {
       
  6009                     // draw left line
       
  6010                     aGc.DrawLine( aSctPosition.iTl,
       
  6011                         TPoint( aSctPosition.iTl.iX, aSctPosition.iBr.iY ) );
       
  6012                     }
       
  6013                 if (aCharIndex == (iMaxColumns-1) )
       
  6014                     {
       
  6015                     // draw right line
       
  6016                     aGc.DrawLine( TPoint( aSctPosition.iBr.iX -1, aSctPosition.iTl.iY ),
       
  6017                                   TPoint( aSctPosition.iBr.iX -1, aSctPosition.iBr.iY ) );
       
  6018                     }
       
  6019                 }
       
  6020             TPoint topleft = offscreenRect.iTl;
       
  6021 
       
  6022             // Our offscreen bitmap's origo is in the control rect's top left.
       
  6023             offscreenRect.Move( -( Rect().iTl ) );
       
  6024             aGc.BitBlt( topleft, iOffscreenBg, offscreenRect );
       
  6025             }
       
  6026         else
       
  6027             {
       
  6028             aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  6029             aGc.SetBrushColor(AKN_LAF_COLOR(0));
       
  6030 
       
  6031             TRect innerRect = aSctPosition;
       
  6032             if (IsRecentChar(aCharIndex))
       
  6033                 {
       
  6034                 innerRect.Shrink(1,1);
       
  6035                 }
       
  6036             aGc.Clear( innerRect );
       
  6037             }
  4593         }
  6038         }
  4594     if (iPictoInterface->Interface()->IsPictograph((*iChars)[aCharIndex]))
  6039     if (iPictoInterface->Interface()->IsPictograph((*iChars)[aCharIndex]))
  4595         {
  6040         {
  4596         if (iExtension->iPictographsBufferGrouping)
  6041         if (iExtension->iPictographsBufferGrouping)
  4597             {
  6042             {
  4607         }
  6052         }
  4608     }
  6053     }
  4609 
  6054 
  4610 void CAknCharMap::DrawOffscreenBackgroundIfRequired() const
  6055 void CAknCharMap::DrawOffscreenBackgroundIfRequired() const
  4611     {
  6056     {
  4612     
  6057     if ( iOffscreenBg )
       
  6058         {
       
  6059         if ( !iOffscreenBgDrawn )
       
  6060             {
       
  6061 
       
  6062             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  6063             MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  6064 
       
  6065             TRect popupGridRect;
       
  6066             if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
       
  6067                 {
       
  6068                 TRect mainPaneRect;
       
  6069                 if(!AknLayoutUtils::LayoutMetricsRect(
       
  6070                     AknLayoutUtils::EPopupParent, mainPaneRect))
       
  6071                     {
       
  6072                     mainPaneRect = iAvkonAppUi->ClientRect();
       
  6073                     }
       
  6074                 TAknLayoutScalableParameterLimits charMapDialogVariety =
       
  6075                     AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
       
  6076 
       
  6077                 TInt maxVariety = charMapDialogVariety.LastVariety();
       
  6078 
       
  6079                 AknLayoutUtils::TAknCbaLocation location =
       
  6080                     AknLayoutUtils::CbaLocation();
       
  6081                 TInt maxVarietyOffset = 0;
       
  6082                 TInt varietyOffset = maxVariety + 1;
       
  6083                 if(Layout_Meta_Data::IsLandscapeOrientation())
       
  6084                     {
       
  6085                     varietyOffset = (maxVariety + 1)/KAknSctCBaButtonDirections;
       
  6086                     }
       
  6087 
       
  6088                 if(location == AknLayoutUtils::EAknCbaLocationRight)
       
  6089                     {
       
  6090                     maxVarietyOffset = varietyOffset;
       
  6091                     }
       
  6092                 else if(location == AknLayoutUtils::EAknCbaLocationLeft)
       
  6093                     {
       
  6094                     maxVarietyOffset = varietyOffset + varietyOffset;
       
  6095                     }
       
  6096                 TInt varietyNumber = varietyOffset - iRows;
       
  6097 
       
  6098                 if(varietyNumber < 0)
       
  6099                     {
       
  6100                     varietyNumber = 0;
       
  6101                     }
       
  6102                 else if(iRows<=0)
       
  6103                     {
       
  6104                     varietyNumber -= 1;
       
  6105                     }
       
  6106                 varietyNumber += maxVarietyOffset;
       
  6107 
       
  6108                 TAknLayoutRect popupGridLayRect;
       
  6109                 popupGridLayRect.LayoutRect(mainPaneRect,
       
  6110                     AknLayoutScalable_Avkon::popup_grid_graphic_window(varietyNumber));
       
  6111 
       
  6112                 popupGridRect = popupGridLayRect.Rect();
       
  6113 
       
  6114                 popupGridRect.iTl.iY = Rect().iTl.iY;
       
  6115                 popupGridRect.Move(-popupGridRect.iTl.iX,0);
       
  6116                 TPoint point = TPoint( 0, 0 );
       
  6117                 AknsDrawUtils::DrawBackground(
       
  6118                     skin,
       
  6119                     cc,
       
  6120                     this,
       
  6121                     *iBitmapGc,
       
  6122                     point,
       
  6123                     popupGridRect,
       
  6124                     KAknsDrawParamDefault );
       
  6125                 }
       
  6126             else
       
  6127                 {
       
  6128                 TAknLayoutRect popupGridLayRect;
       
  6129                 popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
  6130                     AknLayoutScalable_Avkon::popup_grid_graphic2_window(
       
  6131                         0));
       
  6132 
       
  6133                 popupGridRect = popupGridLayRect.Rect();
       
  6134 
       
  6135                 popupGridRect.iTl.iY = Rect().iTl.iY;
       
  6136                 popupGridRect.Move(-popupGridRect.iTl.iX,0);
       
  6137                 TPoint point = TPoint( 0, 0 );
       
  6138                 AknsDrawUtils::DrawBackground(
       
  6139                     skin,
       
  6140                     cc,
       
  6141                     this,
       
  6142                     *iBitmapGc,
       
  6143                     point,
       
  6144                     popupGridRect,
       
  6145                     KAknsDrawParamDefault );
       
  6146                 }
       
  6147             iOffscreenBgDrawn = ETrue;
       
  6148             }
       
  6149         }
  4613     }
  6150     }
  4614 
  6151 
  4615 EXPORT_C CCoeControl* CAknCharMap::ComponentControl(TInt aIndex) const
  6152 EXPORT_C CCoeControl* CAknCharMap::ComponentControl(TInt aIndex) const
  4616     {
  6153     {
  4617     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  6154     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  4621             return iSBFrame->VerticalScrollBar();
  6158             return iSBFrame->VerticalScrollBar();
  4622             }
  6159             }
  4623         aIndex--;
  6160         aIndex--;
  4624         }
  6161         }
  4625 
  6162 
       
  6163     if (iExtension->iRadioButton)
       
  6164         {
       
  6165          if ( aIndex == 0 )
       
  6166             {
       
  6167             return iExtension->iRadioButton;
       
  6168             }
       
  6169         aIndex--;
       
  6170         }
       
  6171 
  4626     if (iExtension->iCategoryTitle)
  6172     if (iExtension->iCategoryTitle)
  4627         {
  6173         {
  4628         if ( aIndex == 0 )
  6174         if ( aIndex == 0 )
  4629             {
  6175             {
  4630             return iExtension->iCategoryTitle;
  6176             return iExtension->iCategoryTitle;
  4634     if (iExtension->iCategoryEntry)
  6180     if (iExtension->iCategoryEntry)
  4635         {
  6181         {
  4636         if ( aIndex == 0 )
  6182         if ( aIndex == 0 )
  4637             {
  6183             {
  4638             return iExtension->iCategoryEntry;
  6184             return iExtension->iCategoryEntry;
       
  6185             }
       
  6186         aIndex--;
       
  6187         }
       
  6188 
       
  6189     if (iExtension->iTableNavi)
       
  6190         {
       
  6191          if ( aIndex == 0 )
       
  6192             {
       
  6193             return iExtension->iTableNavi;
  4639             }
  6194             }
  4640         aIndex--;
  6195         aIndex--;
  4641         }
  6196         }
  4642     if (iExtension->iPageNavi)
  6197     if (iExtension->iPageNavi)
  4643         {
  6198         {
  4656     TInt num = 0;
  6211     TInt num = 0;
  4657     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  6212     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  4658         {
  6213         {
  4659         num++;
  6214         num++;
  4660         }
  6215         }
       
  6216     if (iExtension->iRadioButton)
       
  6217         {
       
  6218         num++;
       
  6219         }
  4661     if (iExtension->iCategoryTitle)
  6220     if (iExtension->iCategoryTitle)
  4662         {
  6221         {
  4663         num++;
  6222         num++;
  4664         }
  6223         }
  4665     if (iExtension->iCategoryEntry)
  6224     if (iExtension->iCategoryEntry)
       
  6225         {
       
  6226         num++;
       
  6227         }
       
  6228     if (iExtension->iTableNavi)
  4666         {
  6229         {
  4667         num++;
  6230         num++;
  4668         }
  6231         }
  4669     if (iExtension->iPageNavi)
  6232     if (iExtension->iPageNavi)
  4670         {
  6233         {
  4703         currentcasechars = iExtension->iCharsQwerty;
  6266         currentcasechars = iExtension->iCharsQwerty;
  4704 
  6267 
  4705     iSpecialCharPages.AppendL( PageCountFromChars(*currentcasechars) );
  6268     iSpecialCharPages.AppendL( PageCountFromChars(*currentcasechars) );
  4706 
  6269 
  4707     iSpecialCharCases.AppendL( iSpecialCharCase );
  6270     iSpecialCharCases.AppendL( iSpecialCharCase );
       
  6271     if (iExtension->iRadioButton)
       
  6272         {
       
  6273         // Set the sct case mode to valid
       
  6274         iExtension->iRadioButton->SetValidSctCase(iSpecialCharCase);
       
  6275         }
  4708 
  6276 
  4709     if (aCase.Count() > 0)
  6277     if (aCase.Count() > 0)
  4710         {
  6278         {
  4711         for (TInt i(0); i < aCase.Count(); ++i)
  6279         for (TInt i(0); i < aCase.Count(); ++i)
  4712             {
  6280             {
  4713             HBufC* chars = CharsFromCase(aCase[i]);
  6281             HBufC* chars = CharsFromCase(aCase[i]);
  4714             if (chars)
  6282             if (chars)
  4715                 {
  6283                 {
  4716                 iSpecialCharCases.AppendL( aCase[i] );
  6284                 iSpecialCharCases.AppendL( aCase[i] );
  4717                 iSpecialCharPages.AppendL( PageCountFromChars(*chars) );
  6285                 iSpecialCharPages.AppendL( PageCountFromChars(*chars) );
       
  6286                 if (iExtension->iRadioButton)
       
  6287                     {
       
  6288                     // Set the sct case mode to valid
       
  6289                     iExtension->iRadioButton->SetValidSctCase(aCase[i]);
       
  6290                     }
  4718                 }
  6291                 }
  4719             }
  6292             }
  4720         }
  6293         }
  4721 
  6294 
  4722     if (iExtension->iPictographsBuffer && iPictoInterface)
  6295     if (iExtension->iPictographsBuffer && iPictoInterface)
  4728         iPictographCases.AppendL(EAknCharMapTablePicto);
  6301         iPictographCases.AppendL(EAknCharMapTablePicto);
  4729         if (iExtension->iPictographsBufferGrouping)
  6302         if (iExtension->iPictographsBufferGrouping)
  4730             {
  6303             {
  4731             iPictographPages.AppendL( PageCountFromChars(*iPictographsBuffer2) );
  6304             iPictographPages.AppendL( PageCountFromChars(*iPictographsBuffer2) );
  4732             iPictographCases.AppendL(EAknCharMapTablePicto2);
  6305             iPictographCases.AppendL(EAknCharMapTablePicto2);
  4733             }
  6306             if (iExtension->iRadioButton)
       
  6307                 {
       
  6308                 // Set the sct case mode to valid
       
  6309                 iExtension->iRadioButton->SetValidSctCase(EAknSCTPictograph1);
       
  6310                 iExtension->iRadioButton->SetValidSctCase(EAknSCTPictograph2);
       
  6311                 }
       
  6312             }
       
  6313         else
       
  6314             {
       
  6315             if (iExtension->iRadioButton)
       
  6316                 {
       
  6317                 // Set the sct case mode to valid
       
  6318                 iExtension->iRadioButton->SetValidSctCase(EAknSCTPictograph);
       
  6319                 }
       
  6320             }
       
  6321         }
       
  6322 
       
  6323     if (iExtension->iRadioButton)
       
  6324         {
       
  6325         // Remove invalid category buttons
       
  6326         iExtension->iRadioButton->RemoveInvalidButton();
       
  6327         __ASSERT_DEBUG( iExtension->iRadioButton->Count() > 0,
       
  6328             Panic(EAknPanicInvalidValue));
  4734         }
  6329         }
  4735     }
  6330     }
  4736 
  6331 
  4737 void CAknCharMap::SetTitleL(TPtrC aTitle)
  6332 void CAknCharMap::SetTitleL(TPtrC aTitle)
  4738     {
  6333     {
  4826     return page;
  6421     return page;
  4827     }
  6422     }
  4828 
  6423 
  4829 void CAknCharMap::CountMaxColumnsAndCellSizes()
  6424 void CAknCharMap::CountMaxColumnsAndCellSizes()
  4830     {
  6425     {
  4831     const TBool isLandscape = Layout_Meta_Data::IsLandscapeOrientation();
       
  4832 
       
  4833     TRect mainPaneRect;
  6426     TRect mainPaneRect;
  4834     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
  6427     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
  4835         {
  6428         {
  4836         if(!AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect))
  6429         if(!AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect))
  4837             {
  6430             {
  4844         TInt maxVariety = charMapDialogVariety.LastVariety();
  6437         TInt maxVariety = charMapDialogVariety.LastVariety();
  4845 
  6438 
  4846         AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
  6439         AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
  4847         TInt maxVarietyOffset = 0;
  6440         TInt maxVarietyOffset = 0;
  4848         TInt varietyOffset = maxVariety + 1;
  6441         TInt varietyOffset = maxVariety + 1;
  4849         if(isLandscape)
  6442         if(Layout_Meta_Data::IsLandscapeOrientation())
  4850             {
  6443             {
  4851             varietyOffset = (maxVariety + 1) / KAknSctCBaButtonDirections;
  6444             varietyOffset = (maxVariety + 1) / KAknSctCBaButtonDirections;
  4852             }
  6445             }
  4853 
  6446 
  4854         if(location == AknLayoutUtils::EAknCbaLocationRight)
  6447         if(location == AknLayoutUtils::EAknCbaLocationRight)
  4868         gridWithScrollLayRect.LayoutRect(popupGridLayRect.Rect(),
  6461         gridWithScrollLayRect.LayoutRect(popupGridLayRect.Rect(),
  4869             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
  6462             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
  4870 
  6463 
  4871 
  6464 
  4872         TAknLayoutRect gridLayRect;
  6465         TAknLayoutRect gridLayRect;
  4873         gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
  6466         if (iExtension->iHasCategoryButtonUi)
  4874             AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
  6467             {
       
  6468             gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
       
  6469                 AknLayoutScalable_Avkon::grid_graphic_popup_pane(2));
       
  6470             }
       
  6471         else
       
  6472             {
       
  6473             gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
       
  6474                 AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
       
  6475             }
  4875 
  6476 
  4876         TRect gridRect = Extension()->iMenuSct ? Rect(): gridLayRect.Rect();
  6477         TRect gridRect = Extension()->iMenuSct ? Rect(): gridLayRect.Rect();
  4877 
  6478 
  4878         TAknLayoutRect firstCellLayRect;
  6479         TAknLayoutRect firstCellLayRect;
  4879         firstCellLayRect.LayoutRect(gridRect,
  6480         firstCellLayRect.LayoutRect(gridRect,
  4880             AknLayoutScalable_Avkon::cell_graphic_popup_pane_cp2(0,0,0));
  6481             AknLayoutScalable_Avkon::cell_graphic_popup_pane_cp2(0,0,0));
  4881 
  6482 
       
  6483         TRect firstCellRect;
       
  6484         if ( Extension()->iMenuSct )
       
  6485             {
       
  6486             firstCellRect = TRect( TPoint(0, 0),
       
  6487                  TSize( firstCellLayRect.Rect().Width(), Rect().Height() ) );
       
  6488             }
       
  6489         else
       
  6490             {
       
  6491             firstCellRect = firstCellLayRect.Rect();
       
  6492             }
       
  6493 
  4882         TAknLayoutRect rightCellLayRect;
  6494         TAknLayoutRect rightCellLayRect;
  4883         rightCellLayRect.LayoutRect(gridRect,
  6495         rightCellLayRect.LayoutRect(gridRect,
  4884             AknLayoutScalable_Avkon::cell_graphic_popup_pane_cp2(0,1,0));
  6496             AknLayoutScalable_Avkon::cell_graphic_popup_pane_cp2(0,1,0));
  4885         TRect firstCellRect;
  6497 
       
  6498         // Max columns.
       
  6499         iMaxColumns = gridRect.Width() / firstCellRect.Width();
       
  6500 
       
  6501         // Max visible rows.
       
  6502         iExtension->iMaxVisibleRows = gridRect.Height() / firstCellRect.Height();
  4886 
  6503 
  4887         // Cell width.
  6504         // Cell width.
  4888         iGridItemWidth =
  6505         iGridItemWidth =
  4889             rightCellLayRect.Rect().iTl.iX - firstCellLayRect.Rect().iTl.iX;
  6506             rightCellLayRect.Rect().iTl.iX - firstCellLayRect.Rect().iTl.iX;
  4890         if (iGridItemWidth < 0)
  6507         if (iGridItemWidth < 0)
  4891             {
  6508             {
  4892             iGridItemWidth = -iGridItemWidth;
  6509             iGridItemWidth = -iGridItemWidth;
  4893             }
  6510             }
  4894         
       
  4895         if ( Extension()->iMenuSct )
       
  4896             {
       
  4897             firstCellRect = TRect( TPoint(0, 0),
       
  4898                  TSize( iGridItemWidth, Rect().Height() ) );
       
  4899             }
       
  4900         else
       
  4901             {
       
  4902             firstCellRect = firstCellLayRect.Rect();
       
  4903             }
       
  4904 
       
  4905 
       
  4906         TInt firstVisibleIndex = iFirstVisibleRow * iMaxColumns;
       
  4907         // Max columns.
       
  4908         iMaxColumns = gridRect.Width() / firstCellRect.Width();
       
  4909         iFirstVisibleRow = firstVisibleIndex / iMaxColumns;
       
  4910 
       
  4911         // Max visible rows.
       
  4912         iExtension->iMaxVisibleRows = gridRect.Height() / firstCellRect.Height();
       
  4913 
  6511 
  4914         // Cell height.
  6512         // Cell height.
  4915         if ( Extension()->iMenuSct )
  6513         if ( Extension()->iMenuSct )
  4916             {
  6514             {
  4917             iGridItemHeight = firstCellRect.Height();
  6515             iGridItemHeight = firstCellRect.Height();
  4926             }
  6524             }
  4927         }
  6525         }
  4928     else
  6526     else
  4929         {
  6527         {
  4930         TAknLayoutRect popupGridLayRect;
  6528         TAknLayoutRect popupGridLayRect;
  4931         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  6529         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
  6530             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
       
  6531 
  4932         TRect popupGridRect = popupGridLayRect.Rect();
  6532         TRect popupGridRect = popupGridLayRect.Rect();
  4933 
  6533 
  4934         TInt gridVariety = isLandscape ? 7 : 6;
  6534         TInt gridVariety;
       
  6535         if (!IsJapaneseSctUi())
       
  6536             {
       
  6537             if(!Layout_Meta_Data::IsLandscapeOrientation())
       
  6538                 {
       
  6539                 gridVariety = (TableCount() > 1) ? 0 : 1;
       
  6540                 }
       
  6541             else
       
  6542                 {
       
  6543                 gridVariety = (TableCount() > 1) ? 2 : 3;
       
  6544                 }
       
  6545             }
       
  6546         else
       
  6547             {
       
  6548             gridVariety = !Layout_Meta_Data::IsLandscapeOrientation() ? 4 : 5;
       
  6549             }
       
  6550 
  4935         TAknLayoutRect gridLayRect;
  6551         TAknLayoutRect gridLayRect;
  4936         gridLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_pane(gridVariety));
  6552         gridLayRect.LayoutRect(popupGridRect,
       
  6553             AknLayoutScalable_Avkon::grid_graphic2_pane(gridVariety));
       
  6554 
  4937         TRect gridRect = gridLayRect.Rect();
  6555         TRect gridRect = gridLayRect.Rect();
  4938 
  6556 
  4939         TInt cellVariety = isLandscape ? 1 : 0;
       
  4940         TAknLayoutRect firstCellLayRect;
  6557         TAknLayoutRect firstCellLayRect;
  4941         firstCellLayRect.LayoutRect(gridRect, AknLayoutScalable_Avkon::cell_graphic2_pane(cellVariety));
  6558         firstCellLayRect.LayoutRect(popupGridRect,
       
  6559             AknLayoutScalable_Avkon::aid_size_cell_graphic2(gridVariety,0,0));
       
  6560 
  4942         TRect firstCellRect = firstCellLayRect.Rect();
  6561         TRect firstCellRect = firstCellLayRect.Rect();
  4943         
       
  4944         TInt firstVisibleIndex = iFirstVisibleRow * iMaxColumns;
       
  4945 
  6562 
  4946         // Max columns.
  6563         // Max columns.
  4947         iMaxColumns = gridRect.Width() / firstCellRect.Width();
  6564         iMaxColumns = gridRect.Width() / firstCellRect.Width();
  4948         iFirstVisibleRow = firstVisibleIndex / iMaxColumns;
       
  4949 
  6565 
  4950         // Max visible rows.
  6566         // Max visible rows.
  4951         iExtension->iMaxVisibleRows = gridRect.Height() / firstCellRect.Height();
  6567         iExtension->iMaxVisibleRows = gridRect.Height() / firstCellRect.Height();
  4952 
  6568 
  4953         // Cell.
  6569         // Cell width.
  4954         iGridItemWidth = firstCellRect.Width();
  6570         iGridItemWidth = firstCellRect.Width();
       
  6571 
       
  6572         // Cell height.
  4955         iGridItemHeight = firstCellRect.Height();
  6573         iGridItemHeight = firstCellRect.Height();
  4956         }
  6574         }
  4957     }
  6575     }
  4958 
  6576 
  4959 HBufC* CAknCharMap::CharsFromCase(TInt aCharCase) const
  6577 HBufC* CAknCharMap::CharsFromCase(TInt aCharCase) const
  5079 // to the array in which all the special characters are placed by the normal
  6697 // to the array in which all the special characters are placed by the normal
  5080 // (rocker) method.
  6698 // (rocker) method.
  5081 //--------------------------------------------------------------------------
  6699 //--------------------------------------------------------------------------
  5082 EXPORT_C void CAknCharMap::HandlePointerEventL(const TPointerEvent& aPointerEvent)
  6700 EXPORT_C void CAknCharMap::HandlePointerEventL(const TPointerEvent& aPointerEvent)
  5083     {
  6701     {
  5084     iExtension->iKeyBrdEvent = EFalse;
       
  5085 
       
  5086     if ( AknLayoutUtils::PenEnabled() && Rect().Contains(aPointerEvent.iPosition))
  6702     if ( AknLayoutUtils::PenEnabled() && Rect().Contains(aPointerEvent.iPosition))
  5087         {
  6703         {
  5088         if (iExtension->iFocusHandler->FocusedControl() != this)// Tapping will move focus to grid.
  6704         if (iExtension->iFocusHandler->FocusedControl() != this)// Tapping will move focus to grid.
  5089             {
  6705             {
  5090             iExtension->iFocusHandler->LeaveControl();
  6706             iExtension->iFocusHandler->LeaveControl();
  5179                         // down event on an item, play feedback
  6795                         // down event on an item, play feedback
  5180                         MTouchFeedback* feedback = MTouchFeedback::Instance();
  6796                         MTouchFeedback* feedback = MTouchFeedback::Instance();
  5181                         if ( feedback &&
  6797                         if ( feedback &&
  5182                              aPointerEvent.iType == TPointerEvent::EButton1Down )
  6798                              aPointerEvent.iType == TPointerEvent::EButton1Down )
  5183                             {
  6799                             {
  5184                             feedback->InstantFeedback( this, ETouchFeedbackList );
  6800                             feedback->InstantFeedback( this, ETouchFeedbackBasicItem );
  5185                             }
  6801                             }
  5186                         if ( aPointerEvent.iType == TPointerEvent::EDrag &&
  6802                         if ( aPointerEvent.iType == TPointerEvent::EDrag &&
  5187                              iCursorPos != iOldCursorPos )
  6803                              iCursorPos != iOldCursorPos )
  5188                             {
  6804                             {
  5189                             // Disable selection.
  6805                             // Disable selection.
  5200                             {
  6816                             {
  5201                             if( iExtension->iSingleClickEnabled )
  6817                             if( iExtension->iSingleClickEnabled )
  5202                                 {
  6818                                 {
  5203                                 iExtension->iHighlightVisible = ETrue;
  6819                                 iExtension->iHighlightVisible = ETrue;
  5204                                 }
  6820                                 }
       
  6821                         
       
  6822                             HandleFocusStatusChanged();
  5205                             }
  6823                             }
  5206                         
  6824                         
  5207                         DrawCursor();
  6825                         DrawCursor();
  5208                         }
  6826                         }
  5209                     else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
  6827                     else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
  5220                             // play feedback
  6838                             // play feedback
  5221                             MTouchFeedback* feedback = MTouchFeedback::Instance();
  6839                             MTouchFeedback* feedback = MTouchFeedback::Instance();
  5222                             if ( feedback )
  6840                             if ( feedback )
  5223                                 {
  6841                                 {
  5224                                 feedback->InstantFeedback( this, 
  6842                                 feedback->InstantFeedback( this, 
  5225                                                            ETouchFeedbackList,
  6843                                                            ETouchFeedbackBasicItem,
  5226                                                            ETouchFeedbackVibra,
  6844                                                            ETouchFeedbackVibra,
  5227                                                            TPointerEvent() );
  6845                                                            TPointerEvent() );
  5228                                 }
  6846                                 }
  5229 
  6847 
  5230                             iExtension->iObserver->HandleControlEventL(
  6848                             iExtension->iObserver->HandleControlEventL(
  5243         else if ( iExtension->iSingleClickEnabled )
  6861         else if ( iExtension->iSingleClickEnabled )
  5244             {
  6862             {
  5245             iExtension->iHighlightVisible = EFalse;
  6863             iExtension->iHighlightVisible = EFalse;
  5246             DrawCursor();
  6864             DrawCursor();
  5247             }
  6865             }
       
  6866 			
       
  6867         CCoeControl::HandlePointerEventL(aPointerEvent);
  5248 
  6868 
  5249         // if Stylus is lifted we clear all flags.
  6869         // if Stylus is lifted we clear all flags.
  5250         if (aPointerEvent.iType == TPointerEvent::EButton1Up)
  6870         if (aPointerEvent.iType == TPointerEvent::EButton1Up)
  5251             {
  6871             {
  5252             iExtension->iFlags &= (~EAknCharMapButton1DownInGrid);
  6872             iExtension->iFlags &= (~EAknCharMapButton1DownInGrid);
  5253             iExtension->iFlags &= (~EAknCharMapHasBeenScrolledByDrag);
  6873             iExtension->iFlags &= (~EAknCharMapHasBeenScrolledByDrag);
  5254             iExtension->iFlags &= (~EAknCharMapPressedDown);
  6874             iExtension->iFlags &= (~EAknCharMapPressedDown);
  5255             if ( iSBFrame )
  6875             if ( !iSBFrame )
  5256                 {
  6876                 {
  5257                 CEikScrollBar* vScrollBar = iSBFrame->VerticalScrollBar();
  6877                 return;
  5258                 if(vScrollBar)
  6878                 }
  5259                     {
  6879             CEikScrollBar* vScrollBar = iSBFrame->VerticalScrollBar();
  5260                     vScrollBar->HandlePointerEventL(aPointerEvent);
  6880             if(vScrollBar)
  5261                     }
  6881                 {
  5262                 }
  6882                 vScrollBar->HandlePointerEventL(aPointerEvent);
  5263             }
  6883                 }
  5264         }
  6884             }
  5265     else
  6885         }
  5266         {
       
  5267         if(iExtension->iSingleClickEnabled)
       
  5268             {
       
  5269             iExtension->iHighlightVisible = EFalse;
       
  5270             DrawCursor();
       
  5271             }
       
  5272         }
       
  5273     
       
  5274     CCoeControl::HandlePointerEventL(aPointerEvent);
       
  5275     }
  6886     }
  5276 
  6887 
  5277 // -----------------------------------------------------------------------------
  6888 // -----------------------------------------------------------------------------
  5278 // CAknCharMap::SetObserver
  6889 // CAknCharMap::SetObserver
  5279 // Sets the observer.
  6890 // Sets the observer.
  5454         {
  7065         {
  5455         if (iExtension->iObserver)
  7066         if (iExtension->iObserver)
  5456             {
  7067             {
  5457             iExtension->iObserver->HandleControlEventL(this, MCoeControlObserver::EEventRequestFocus);
  7068             iExtension->iObserver->HandleControlEventL(this, MCoeControlObserver::EEventRequestFocus);
  5458             }
  7069             }
  5459 
  7070         
       
  7071         HandleFocusStatusChanged();
  5460         DrawDeferred();
  7072         DrawDeferred();
  5461         }
  7073         }
  5462     }
  7074     }
  5463 
  7075 
  5464 // -----------------------------------------------------------------------------
  7076 // -----------------------------------------------------------------------------
  5518             }
  7130             }
  5519         
  7131         
  5520         TPtrC textHistory = iCharMapHistory->RecentString(historyType, CAknCharMapHistory::EHistoryFilterTextOnly);
  7132         TPtrC textHistory = iCharMapHistory->RecentString(historyType, CAknCharMapHistory::EHistoryFilterTextOnly);
  5521         
  7133         
  5522         *charsBuf = InsertSwitchCharAndHistoryToCharsBufL(*charsBuf, 
  7134         *charsBuf = InsertSwitchCharAndHistoryToCharsBufL(*charsBuf, 
  5523                                                           iExtension->SwitchToEmotionChar(), 
  7135                                                           TEmotionUtils::EmotionSwitchToSmileyChar(), 
  5524                                                           textHistory);
  7136                                                           textHistory);
  5525         }
  7137         }
  5526     
  7138     
  5527     // Emotion history
  7139     // Emotion history
  5528     TPtrC emotionHistory = iCharMapHistory->RecentString(CAknCharMapHistory::EHistoryTypeFull, CAknCharMapHistory::EHistoryFilterEmotionOnly);
  7140     TPtrC emotionHistory = iCharMapHistory->RecentString(CAknCharMapHistory::EHistoryTypeFull, CAknCharMapHistory::EHistoryFilterEmotionOnly);
  5529     iExtension->iCharsSmiley = InsertSwitchCharAndHistoryToCharsBufL(iExtension->iCharsSmiley, 
  7141     iExtension->iCharsSmiley = InsertSwitchCharAndHistoryToCharsBufL(iExtension->iCharsSmiley, 
  5530                                                                      iExtension->SwitchToSctChar(), 
  7142                                                                      TEmotionUtils::EmotionSwitchToSctChar(), 
  5531                                                                      emotionHistory);
  7143                                                                      emotionHistory);
  5532 
  7144 
  5533     // ETrue are set to each variable when setting the recent used characters.
  7145     // ETrue are set to each variable when setting the recent used characters.
  5534     iSetRecentSct = ETrue;
  7146     iSetRecentSct = ETrue;
  5535     iSetRecentPic = ETrue;
  7147     iSetRecentPic = ETrue;
  5542         // Check whether recent charcters are included in base charcters.
  7154         // Check whether recent charcters are included in base charcters.
  5543         TBuf<CAknCharMapHistory::KHistoryBufferSize+5> insertBuffer;
  7155         TBuf<CAknCharMapHistory::KHistoryBufferSize+5> insertBuffer;
  5544         for (TInt index=0; index<aHistory.Length(); index++)
  7156         for (TInt index=0; index<aHistory.Length(); index++)
  5545             {
  7157             {
  5546             TChar txt = aHistory[index];
  7158             TChar txt = aHistory[index];
  5547             if(aCharsBuf->Locate(txt)!=KErrNotFound || Extension()->IsEmotionChar(txt) || txt==KHistoryEmptyChar)
  7159             if(aCharsBuf->Locate(txt)!=KErrNotFound || TEmotionUtils::IsEmotionChar(txt) || txt==KHistoryEmptyChar)
  5548                 {
  7160                 {
  5549                 insertBuffer.Append(txt);
  7161                 insertBuffer.Append(txt);
  5550                 }
  7162                 }
  5551             }
  7163             }
  5552 
  7164 
  5657             break;
  7269             break;
  5658         }
  7270         }
  5659     
  7271     
  5660     if (historyType > CAknCharMapHistory::EHistoryTypeNull)
  7272     if (historyType > CAknCharMapHistory::EHistoryTypeNull)
  5661         {
  7273         {
  5662         TBool isEmotion = Extension()->IsEmotionChar(aChar);
  7274         iCharMapHistory->InsertChar(historyType, aChar);
  5663         iCharMapHistory->InsertChar(historyType, aChar, isEmotion);
       
  5664         }
  7275         }
  5665 
  7276 
  5666     // Save recent data
  7277     // Save recent data
  5667     iCharMapHistory->SaveL();
  7278     iCharMapHistory->SaveL();
  5668     }
  7279     }
  5679 
  7290 
  5680     TInt resourceId = R_AVKON_MENU_SCT_ROW_DEFAULT_CONTENTS;
  7291     TInt resourceId = R_AVKON_MENU_SCT_ROW_DEFAULT_CONTENTS;
  5681     if (FeatureManager::FeatureSupported(KFeatureIdChinese))
  7292     if (FeatureManager::FeatureSupported(KFeatureIdChinese))
  5682         {
  7293         {
  5683         resourceId = R_AVKON_MENU_SCT_ROW_DEFAULT_CONTENTS_CHINESE;
  7294         resourceId = R_AVKON_MENU_SCT_ROW_DEFAULT_CONTENTS_CHINESE;
  5684         }
       
  5685     else if (FeatureManager::FeatureSupported(KFeatureIdKorean))
       
  5686         {
       
  5687         // Added korea character support
       
  5688         resourceId = R_AVKON_MENU_SCT_ROW_DEFAULT_CONTENTS_KOREAN;
       
  5689         }
  7295         }
  5690 
  7296 
  5691     CCoeEnv::Static()->CreateResourceReaderLC( reader, resourceId );
  7297     CCoeEnv::Static()->CreateResourceReaderLC( reader, resourceId );
  5692     ConstructFromResourceL( reader );
  7298     ConstructFromResourceL( reader );
  5693     CleanupStack::PopAndDestroy();
  7299     CleanupStack::PopAndDestroy();
  5796     // If the row is empty, nothing to do
  7402     // If the row is empty, nothing to do
  5797     if (LengthOfRecentChar() == 0)
  7403     if (LengthOfRecentChar() == 0)
  5798         {
  7404         {
  5799         return;
  7405         return;
  5800         }
  7406         }
  5801     // The "PlayAnimationL" in "SetSmileyAnimationActivityInCurrentPageL"
  7407     
  5802     // will leave. If we ignore it, just no animation is played.
  7408     HandleFocusStatusChanged(aHighlight);
  5803     TRAP_IGNORE( SetSmileyAnimationActivityInCurrentPageL(aHighlight) );
       
  5804     
  7409     
  5805     CWindowGc& gc = SystemGc();
  7410     CWindowGc& gc = SystemGc();
  5806     if( !CAknEnv::Static()->TransparencyEnabled() )
  7411     if( !CAknEnv::Static()->TransparencyEnabled() )
  5807         {
  7412         {
  5808         ActivateGc();
  7413         ActivateGc();
  5817         gc.DiscardFont();
  7422         gc.DiscardFont();
  5818         DeactivateGc();
  7423         DeactivateGc();
  5819         }
  7424         }
  5820     // Menu SCT is being used.
  7425     // Menu SCT is being used.
  5821     if ( Extension()->iMenuSct )
  7426     if ( Extension()->iMenuSct )
  5822         {
  7427     	{
  5823         Extension()->iMenuSctHighlighted = aHighlight;
  7428     	Extension()->iMenuSctHighlighted = aHighlight;
  5824         }
  7429     	}
  5825     }
  7430     }
  5826 // -----------------------------------------------------------------------------
  7431 // -----------------------------------------------------------------------------
  5827 // CAknCharMap::SetMenuSctRect()
  7432 // CAknCharMap::SetMenuSctRect()
  5828 // Sets the rect for menu SCT.
  7433 // Sets the rect for menu SCT.
  5829 // -----------------------------------------------------------------------------
  7434 // -----------------------------------------------------------------------------
  5885             default:
  7490             default:
  5886                 break;
  7491                 break;
  5887             }
  7492             }
  5888         
  7493         
  5889         CAknCharMapHistory::THistoryFilter historyFilter;
  7494         CAknCharMapHistory::THistoryFilter historyFilter;
  5890         if(Extension()->IsEmotionEnabled())
  7495         if(iExtension->IsEmotionEnabled())
  5891             {
  7496             {
  5892             historyFilter = CAknCharMapHistory::EHistoryFilterMixed;
  7497             historyFilter = CAknCharMapHistory::EHistoryFilterMixed;
  5893             }
  7498             }
  5894         else
  7499         else
  5895             {
  7500             {
  5918                 }
  7523                 }
  5919             else
  7524             else
  5920                 {
  7525                 {
  5921                 iShowCasesRef = &iSpecialCharCases;
  7526                 iShowCasesRef = &iSpecialCharCases;
  5922                 iShowPagesRef = &iSpecialCharPages;
  7527                 iShowPagesRef = &iSpecialCharPages;
  5923 
  7528                 iChars = iCharsBufferLower;
  5924                 if (iCharsBufferUpper && iSpecialCharCase==EAknSCTUpperCase)
  7529                 if (iCharsBufferUpper && iSpecialCharCase==EAknSCTUpperCase)
  5925                     {
       
  5926                     iChars = iCharsBufferUpper;
  7530                     iChars = iCharsBufferUpper;
  5927                     }
       
  5928                 else if (iCharsBufferNumeric && iSpecialCharCase==EAknSCTNumeric)
  7531                 else if (iCharsBufferNumeric && iSpecialCharCase==EAknSCTNumeric)
  5929                     {
       
  5930                     iChars = iCharsBufferNumeric;
  7532                     iChars = iCharsBufferNumeric;
  5931                     }
       
  5932                 else if (iCharsBufferFull && iSpecialCharCase==EAknSCTFullCase)
  7533                 else if (iCharsBufferFull && iSpecialCharCase==EAknSCTFullCase)
  5933                     {
       
  5934                     iChars = iCharsBufferFull;
  7534                     iChars = iCharsBufferFull;
  5935                     }
       
  5936                 else if (iCharsBufferHalf && iSpecialCharCase==EAknSCTHalfCase)
  7535                 else if (iCharsBufferHalf && iSpecialCharCase==EAknSCTHalfCase)
  5937                     {
       
  5938                     iChars = iCharsBufferHalf;
  7536                     iChars = iCharsBufferHalf;
  5939                     }
       
  5940                 else if (iExtension->iCharsQwerty && iSpecialCharCase==EAknSCTQwerty)
  7537                 else if (iExtension->iCharsQwerty && iSpecialCharCase==EAknSCTQwerty)
  5941                     {
       
  5942                     iChars = iExtension->iCharsQwerty;
  7538                     iChars = iExtension->iCharsQwerty;
  5943                     }
  7539 
  5944                 else
  7540                 if(iChars == iCharsBufferLower)
  5945                     {
  7541                     {
  5946                     // default
       
  5947                     iSpecialCharCase = EAknSCTLowerCase;
  7542                     iSpecialCharCase = EAknSCTLowerCase;
  5948                     iChars = iCharsBufferLower;
       
  5949                     }
  7543                     }
  5950                 }
  7544                 }
  5951             // mark that iChars doesn't point to HBufC
  7545             // mark that iChars doesn't point to HBufC
  5952             iExtension->iFlags &= (~EAknCharMapCharsAllocated);
  7546             iExtension->iFlags &= (~EAknCharMapCharsAllocated);
  5953             }
  7547             }
  5965         ptrrecent.Copy(recentChars);
  7559         ptrrecent.Copy(recentChars);
  5966         for (TInt index=0; index < ptrrecent.Length(); index++)
  7560         for (TInt index=0; index < ptrrecent.Length(); index++)
  5967             {
  7561             {
  5968             if (ptrrecent[index] != KHistoryEmptyChar)
  7562             if (ptrrecent[index] != KHistoryEmptyChar)
  5969                 {
  7563                 {
  5970                 if(Extension()->IsEmotionChar(ptrrecent[index]))
  7564                 if(TEmotionUtils::IsEmotionChar(ptrrecent[index]))
  5971                     {
  7565                     {
  5972                     continue;
  7566                     continue;
  5973                     }
  7567                     }
  5974                 else
  7568                 else
  5975                     {
  7569                     {
  5977                     if (err == KErrNotFound)
  7571                     if (err == KErrNotFound)
  5978                         {
  7572                         {
  5979                         ptrrecent.Delete(index,1);
  7573                         ptrrecent.Delete(index,1);
  5980                         ptrrecent.Append(KHistoryEmptyChar);
  7574                         ptrrecent.Append(KHistoryEmptyChar);
  5981                         index--;
  7575                         index--;
  5982                         }
  7576                         }                       
  5983                     }
  7577                     }
  5984                 }
  7578                 }
  5985             }
  7579             }
  5986         if (iExtension->iFlags & EAknCharMapCharsAllocated) // iChars already contains HBufC
  7580         if (iExtension->iFlags & EAknCharMapCharsAllocated) // iChars already contains HBufC
  5987             {                                               // so delete old instance
  7581             {                                               // so delete old instance
  6000             iCursorPos = TPoint(0, 0);
  7594             iCursorPos = TPoint(0, 0);
  6001             }
  7595             }
  6002         iExtension->iFlags |= EAknCharMapCharsAllocated; // mark that iChars points to HBufC
  7596         iExtension->iFlags |= EAknCharMapCharsAllocated; // mark that iChars points to HBufC
  6003         }
  7597         }
  6004     
  7598     
  6005     Extension()->LoadEmotionTumbnails(*iChars);
  7599     iExtension->LoadEmotionTumbnails(*iChars);
  6006     
  7600 
  6007     // control will never get focus event while it is in EditMenu mode
  7601     HandleFocusStatusChanged();
  6008     Extension()->iCharMapFocusGained = ETrue;
       
  6009 
       
  6010     // The "PlayAnimationL" in "SetSmileyAnimationActivityInCurrentPageL"
       
  6011     // will leave. If we ignore it, just no animation is played.
       
  6012     TRAP_IGNORE( SetSmileyAnimationActivityInCurrentPageL(ETrue) );
       
  6013     }
  7602     }
  6014 
  7603 
  6015 // -----------------------------------------------------------------------------
  7604 // -----------------------------------------------------------------------------
  6016 // CAknCharMap::CharacterCase()
  7605 // CAknCharMap::CharacterCase()
  6017 // Get current character case.
  7606 // Get current character case.
  6124                 headingPane->SetPageL( CurrentPage(), PageCount() );
  7713                 headingPane->SetPageL( CurrentPage(), PageCount() );
  6125 
  7714 
  6126                 // Update also title if requested
  7715                 // Update also title if requested
  6127                 if ( aUpdateTitle)
  7716                 if ( aUpdateTitle)
  6128                     {
  7717                     {
  6129                     const TDesC* title = Title();
  7718                     const TDesC* title = (IsJapaneseSctUi())?
       
  7719                                          TitleWithSelectingSpecialChar()
       
  7720                                          :Title();
  6130                     if ( title )
  7721                     if ( title )
  6131                         {
  7722                         {
  6132                         //
  7723                         //
  6133                         headingPane->SetTextL( *title );
  7724                         headingPane->SetTextL( *title );
  6134                         }
  7725                         }
  6255     }
  7846     }
  6256 
  7847 
  6257 
  7848 
  6258 TBool CAknCharMap::IsSupportCategoryButtonUi() const
  7849 TBool CAknCharMap::IsSupportCategoryButtonUi() const
  6259     {
  7850     {
  6260     return EFalse;
  7851     return (iExtension)? iExtension->iHasCategoryButtonUi : EFalse;
  6261     }
  7852     }
  6262 
  7853 
  6263 TBool CAknCharMap::IsJapaneseSctUi() const
  7854 TBool CAknCharMap::IsJapaneseSctUi() const
  6264     {
  7855     {
  6265     //Japanese feature for SCT will not be supported since TB9.2 PS2,
  7856     return (iExtension)? iExtension->iJapaneseSctUi : EFalse;
  6266     //so it always return EFalse.
  7857     }
  6267     return EFalse;
  7858 
  6268     }
       
  6269 
       
  6270 TBool CAknCharMap::IsKoreanSctUi() const
       
  6271     {
       
  6272     return FeatureManager::FeatureSupported( KFeatureIdKorean );
       
  6273     }
       
  6274 // -----------------------------------------------------------------------------
  7859 // -----------------------------------------------------------------------------
  6275 // CAknCharMap::TitleWithSelectingSpecialChar()
  7860 // CAknCharMap::TitleWithSelectingSpecialChar()
  6276 // Return the title string with the selecting special characters
  7861 // Return the title string with the selecting special characters
  6277 // -----------------------------------------------------------------------------
  7862 // -----------------------------------------------------------------------------
  6278 //
  7863 //
  6478     TRAP_IGNORE(MoveCursorL(aX,aY));
  8063     TRAP_IGNORE(MoveCursorL(aX,aY));
  6479     }
  8064     }
  6480 
  8065 
  6481 TBool CAknCharMap::LeaveControl()
  8066 TBool CAknCharMap::LeaveControl()
  6482     {
  8067     {
       
  8068     HandleFocusStatusChanged(EFalse);
       
  8069     
  6483     CWindowGc& gc = SystemGc();
  8070     CWindowGc& gc = SystemGc();
  6484     if( !CAknEnv::Static()->TransparencyEnabled() )
  8071     if( !CAknEnv::Static()->TransparencyEnabled() )
  6485         {
  8072         {
  6486         ActivateGc();
  8073         ActivateGc();
  6487         gc.UseFont(iFont);
  8074         gc.UseFont(iFont);
  6693     }
  8280     }
  6694 
  8281 
  6695 
  8282 
  6696 // for emotion added
  8283 // for emotion added
  6697 
  8284 
       
  8285 void CAknCharMap::HandleFocusStatusChanged(TBool aIsFocused)
       
  8286     {
       
  8287     TInt focusPos = iCursorPos.iX + (iFirstVisibleRow + iCursorPos.iY) * iMaxColumns;
       
  8288     if(focusPos>=0 && focusPos<iChars->Length())
       
  8289         {
       
  8290         aIsFocused &= (iExtension->iFocusHandler->FocusedControl()==this);
       
  8291         iExtension->HandleFocusStatusChanged((*iChars)[focusPos], aIsFocused);
       
  8292         }
       
  8293     }
  6698 
  8294 
  6699 TBool CAknCharMap::EmotionsAreAllReadyToDraw(TInt aIndex, TInt aCount) const
  8295 TBool CAknCharMap::EmotionsAreAllReadyToDraw(TInt aIndex, TInt aCount) const
  6700     {
  8296     {
  6701     for(TInt i(0); i<aCount; i++)
  8297     for(TInt i(0); i<aCount; i++)
  6702         {
  8298         {
  6703         if(aIndex < iChars->Length())
  8299         if(aIndex < iChars->Length())
  6704             {
  8300             {
  6705             TChar code = (*iChars)[aIndex++];
  8301             TChar name = (*iChars)[aIndex++];
  6706             CAknSmileyIcon* icon = Extension()->EmotionIcon(code);
  8302             CSmileyIcon* icon = iExtension->EmotionIcon(name);
  6707             if(icon && !icon->ReadyToDraw())
  8303             if(icon && !icon->ReadyToDraw())
  6708                 {
  8304                 {
  6709                 return EFalse;
  8305                 return EFalse;
  6710                 }
  8306                 }
  6711             }
  8307             }
  6716         }
  8312         }
  6717     
  8313     
  6718     return ETrue;
  8314     return ETrue;
  6719     }
  8315     }
  6720 
  8316 
  6721 void CAknCharMap::SmileyStillImageLoaded(TChar aChar)
  8317 void CAknCharMap::GetFocusSctName(TChar& aChar, TDes& aName) const
  6722     {
  8318     {
  6723     const CAknSmileyIcon* loadedIcon = Extension()->EmotionIcon(aChar);
  8319     TInt pos = iMaxColumns * (iFirstVisibleRow + iCursorPos.iY) + iCursorPos.iX;
  6724     
  8320     
  6725     for(TInt i(0); i<iChars->Length(); i++)
  8321     aChar = (*iChars)[pos];
  6726         {
       
  6727         TChar code = (*iChars)[i];
       
  6728         CAknSmileyIcon* icon = Extension()->EmotionIcon(code);
       
  6729         if(icon == loadedIcon)
       
  6730             {
       
  6731             if((i%iMaxColumns == 0) || (i == iChars->Length()-1))
       
  6732                 {
       
  6733                 DrawDeferred(); // a new line is finished
       
  6734                 }
       
  6735             }
       
  6736         }
       
  6737     }
       
  6738 
       
  6739 void CAknCharMap::SmileyAnimationChanged(TChar aChar)
       
  6740     {
       
  6741     const CAknSmileyIcon* loadedIcon = Extension()->EmotionIcon(aChar);
       
  6742     TInt pageVolume = iExtension->iMaxVisibleRows * iMaxColumns;
       
  6743     
  8322     
  6744     for(TInt i(0); i<iChars->Length(); i++)
  8323     aName.Zero();
  6745         {
       
  6746         TChar code = (*iChars)[i];
       
  6747         CAknSmileyIcon* icon = iExtension->EmotionIcon(code);
       
  6748         if(icon == loadedIcon)
       
  6749             {
       
  6750             TInt index = i % pageVolume;
       
  6751             TPoint pos(index%iMaxColumns, index/iMaxColumns);
       
  6752             
       
  6753             // grid is focused and cursor pos is same with the current index.
       
  6754             TBool highlighted = EFalse;
       
  6755             if(iExtension->iFocusHandler->FocusedControl()==this && iCursorPos==pos)
       
  6756                 {
       
  6757                 highlighted = (!iExtension->iMenuSct || iExtension->iMenuSctHighlighted);
       
  6758                 }
       
  6759 
       
  6760             DrawCell(index, highlighted);
       
  6761             }
       
  6762         }
       
  6763     }
       
  6764 
       
  6765 void CAknCharMap::SetSmileyAnimationActivityInCurrentPageL(TBool aIsActive)
       
  6766     {
       
  6767     TInt pos = iFirstVisibleRow * iMaxColumns;
       
  6768     TInt maxLength = iChars->Length() - pos;
       
  6769     TInt length = iExtension->iMaxVisibleRows * iMaxColumns;
       
  6770     if(length > maxLength) length = maxLength;
       
  6771 
       
  6772     const TPtrC textInCurrentPage = iChars->Mid(pos, length);
       
  6773     
  8324     
  6774     if(Extension()->iCharMapFocusGained && aIsActive)
  8325     if(TEmotionUtils::IsEmotionChar(aChar))
  6775         {
  8326         {
  6776         Extension()->PlayAnimationL(textInCurrentPage);
  8327         CSmileyIcon* icon = iExtension->EmotionIcon(aChar);
  6777         }
  8328         if ( icon )
  6778     else
  8329             {
  6779         {
  8330             aName.Append(icon->Name());
  6780         Extension()->StopAnimation(textInCurrentPage);
  8331             }
  6781         }
       
  6782     }
       
  6783 
       
  6784 void CAknCharMap::GetFocusSctName(TChar& aChar, TDes& aName) const
       
  6785     {
       
  6786     TInt pos = iMaxColumns * (iFirstVisibleRow + iCursorPos.iY) + iCursorPos.iX;
       
  6787 
       
  6788     aChar = (*iChars)[pos];
       
  6789 
       
  6790     aName.Zero();
       
  6791 
       
  6792     if(Extension()->IsEmotionChar(aChar))
       
  6793         {
       
  6794         aName.Append(Extension()->EmotionText(aChar));
       
  6795         }
  8332         }
  6796     else
  8333     else
  6797         {
  8334         {
  6798         aName.Append(aChar);
  8335         aName.Append(aChar);
  6799         }
  8336         }
  6815     TChar sctChar;
  8352     TChar sctChar;
  6816     TBuf<10> sctName;
  8353     TBuf<10> sctName;
  6817     GetFocusSctName(sctChar, sctName);
  8354     GetFocusSctName(sctChar, sctName);
  6818 
  8355 
  6819     if(Extension()->NeedEmotionSwitchIcon() && 
  8356     if(Extension()->NeedEmotionSwitchIcon() && 
  6820        (sctChar==Extension()->SwitchToSctChar() || sctChar==Extension()->SwitchToEmotionChar()))
  8357        (sctChar==TEmotionUtils::EmotionSwitchToSctChar() || sctChar==TEmotionUtils::EmotionSwitchToSmileyChar()))
  6821         {
  8358         {
  6822         SwitchSctAndEmotionL();
  8359         SwitchSctAndEmotionL();
  6823         }
  8360         }
  6824     else if(iFetcherCharsBuffer->Length() + sctName.Length() < iFetcherCharsBuffer->MaxLength())
  8361     else if(iFetcherCharsBuffer->Length() + sctName.Length() < iFetcherCharsBuffer->MaxLength())
  6825         {
  8362         {
  6854 
  8391 
  6855 TBool CAknCharMap::SwitchSctAndEmotionL()
  8392 TBool CAknCharMap::SwitchSctAndEmotionL()
  6856     {
  8393     {
  6857     if(Extension()->IsEmotionEnabled())
  8394     if(Extension()->IsEmotionEnabled())
  6858         {
  8395         {
  6859         Extension()->SwitchEmotionVisibilityL();
  8396         Extension()->iIsShowingEmotion = !Extension()->IsShowingEmotion();
  6860         
       
  6861         SetSmileyAnimationActivityInCurrentPageL(EFalse);
       
  6862         
  8397         
  6863         SetCharacterCaseL(iSpecialCharCase);
  8398         SetCharacterCaseL(iSpecialCharCase);
  6864         
  8399         
  6865         SetSmileyAnimationActivityInCurrentPageL(ETrue);
  8400         CAknSctTableNavi* tableNavi = Extension()->iTableNavi;
  6866         
  8401         if(tableNavi)
  6867         CAknSctPageNavi* pageNavi = Extension()->iPageNavi;
  8402             {
  6868         if(pageNavi)
  8403             tableNavi->UpdateNextTableButtonL();
  6869             {
       
  6870             pageNavi->UpdateNextTableButtonL();
       
  6871             }
  8404             }
  6872 
  8405 
  6873         DrawNow();
  8406         DrawNow();
  6874         
  8407         
  6875         return ETrue;
  8408         return ETrue;