uifw/AvKon/src/AknCharMap.cpp
branchRCL_3
changeset 12 941195f2d488
parent 10 3d340a0166ff
child 15 c52421ed5f07
equal deleted inserted replaced
10:3d340a0166ff 12:941195f2d488
    92 
    92 
    93 
    93 
    94 const TUint KHistoryEmptyChar = CEditableText::ETabCharacter;
    94 const TUint KHistoryEmptyChar = CEditableText::ETabCharacter;
    95 const TUint KHistoryEmptyCharForDisplay = CEditableText::ESpace;
    95 const TUint KHistoryEmptyCharForDisplay = CEditableText::ESpace;
    96 
    96 
    97 const TInt KAknSctRadioOn = 1;
       
    98 const TInt KAknSctRadioOff = 0;
       
    99 const TInt KAreaIdRecent = 0;
    97 const TInt KAreaIdRecent = 0;
   100 const TInt KAreaIdMain   = 1;
    98 const TInt KAreaIdMain   = 1;
   101 const TInt KAreaIdTail   = 2;
    99 const TInt KAreaIdTail   = 2;
   102 
   100 
   103 
   101 
   243         TBool iPressed;
   241         TBool iPressed;
   244         TBool iRepeat;
   242         TBool iRepeat;
   245     };
   243     };
   246 
   244 
   247 // ----------------------------------------------------------------------------
   245 // ----------------------------------------------------------------------------
   248 // Table Navi class definition
       
   249 // ----------------------------------------------------------------------------
       
   250 //
       
   251 NONSHARABLE_CLASS(CAknSctTableNavi) : public CAknControl, public MAknSctFocusHandler, public MCoeControlObserver
       
   252     {
       
   253     public:
       
   254         CAknSctTableNavi(CAknCharMap* aCharMap, CAknCharMapExtension* aExtension);
       
   255         ~CAknSctTableNavi();
       
   256 
       
   257     public:  // from CCoeControl
       
   258         TInt CountComponentControls() const;
       
   259         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   260         virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode);
       
   261         void ConstructFromResourceL(TResourceReader& aReader);
       
   262         virtual TSize MinimumSize();
       
   263         virtual void SizeChanged();
       
   264         
       
   265     public: // from MCoeControlObserver
       
   266         void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
       
   267 
       
   268     public: // from MAknSctFocusHandler
       
   269         virtual CCoeControl* FocusedControl();
       
   270         virtual TBool EnterControl(TInt aX, TInt aY);
       
   271         virtual void MoveFocus(TInt aX, TInt aY);
       
   272         virtual TBool ExitWithKey(TInt aKeycode);
       
   273         virtual TBool LeaveControl();
       
   274 
       
   275     public:
       
   276         TInt TableCount();
       
   277         void UpdateNextTableButtonL();
       
   278         
       
   279     private:
       
   280         void TableExitL();
       
   281         static TInt TableExitCallBackL(TAny* aThis);
       
   282         void DoTableExitL();
       
   283         
       
   284         void NextTableL();
       
   285         static TInt NextTableCallBackL(TAny* aThis);
       
   286         void DoNextTableL();
       
   287         
       
   288     private:
       
   289         TInt ButtonPosition(TInt aButtonIndex) const;
       
   290 
       
   291     private:  // data
       
   292         TInt iButtonIndex;
       
   293         RPointerArray<CAknSctNaviButton> iButtonArray;
       
   294         CAknCharMap* iCharMap;
       
   295         CAknCharMapExtension* iExtension;
       
   296         CIdle *iIdle;
       
   297         
       
   298         TInt iPressedButtonIndex;
       
   299     };
       
   300 
       
   301 // ----------------------------------------------------------------------------
       
   302 // Navigator class definition
   246 // Navigator class definition
   303 // ----------------------------------------------------------------------------
   247 // ----------------------------------------------------------------------------
   304 //
   248 //
   305 NONSHARABLE_CLASS(CAknSctPageNavi) : public CAknControl, public MAknSctFocusHandler, public MCoeControlObserver
   249 NONSHARABLE_CLASS(CAknSctPageNavi) : public CAknControl, public MAknSctFocusHandler, public MCoeControlObserver
   306     {
   250     {
   329         virtual TBool EnterControl(TInt aX, TInt aY);
   273         virtual TBool EnterControl(TInt aX, TInt aY);
   330         virtual void MoveFocus(TInt aX, TInt aY);
   274         virtual void MoveFocus(TInt aX, TInt aY);
   331         virtual TBool ExitWithKey(TInt aKeycode);
   275         virtual TBool ExitWithKey(TInt aKeycode);
   332         virtual TBool LeaveControl();
   276         virtual TBool LeaveControl();
   333 
   277 
       
   278     public:
       
   279         void UpdateNextTableButtonL();
       
   280         TInt LastButton() const;
       
   281         
   334     private:
   282     private:
       
   283         void MoveFocus(TBool aInternalMove, TInt aX, TInt aY );
   335         TBool IsNextButton() const;
   284         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();
   336 
   293 
   337     private:  // data
   294     private:  // data
   338         TInt iButtonIndex;
   295         TInt iButtonIndex;
   339         RPointerArray<CAknSctNaviButton> iButtonArray;
   296         RPointerArray<CAknSctNaviButton> iButtonArray;
   340         CAknCharMap* iCharMap;
   297         CAknCharMap* iCharMap;
   341         CAknCharMapExtension* iExtension;
   298         CAknCharMapExtension* iExtension;
   342         CEikLabel* iTitle;
   299         CEikLabel* iTitle;
       
   300         CIdle *iIdle;
   343     };
   301     };
   344 
       
   345 // ----------------------------------------------------------------------------
   302 // ----------------------------------------------------------------------------
   346 // Category button class defintion
   303 // Category button class defintion
   347 // ----------------------------------------------------------------------------
   304 // ----------------------------------------------------------------------------
   348 //
   305 //
   349 class CAknSctCategoryButton : public CBase
   306 class CAknSctCategoryButton : public CBase
   375 
   332 
   376 // ----------------------------------------------------------------------------
   333 // ----------------------------------------------------------------------------
   377 // Radio button class defintion
   334 // Radio button class defintion
   378 // ----------------------------------------------------------------------------
   335 // ----------------------------------------------------------------------------
   379 //
   336 //
   380 class CAknSctRadioButton : public CAknControl, public MAknSctFocusHandler
   337 // stay for BC
   381     {
   338 class CAknSctRadioButton : public CAknControl
   382     public:
   339     {
   383         enum TAknSctRadioButtonFlags
       
   384             {
       
   385             EAknSctRadioButtonResize = 0x1,
       
   386             EAknSctRadioButtonEnd
       
   387             };
       
   388     public:
   340     public:
   389         CAknSctRadioButton();
   341         CAknSctRadioButton();
   390         CAknSctRadioButton(CAknCharMap* aCharMap,
       
   391                            CAknCharMapExtension* aExtension);
       
   392         ~CAknSctRadioButton();
   342         ~CAknSctRadioButton();
   393     public: // from MAknSctFocusHandler
       
   394         virtual CCoeControl* FocusedControl();
       
   395         virtual TBool EnterControl(TInt aX, TInt aY);
       
   396         virtual void MoveFocus(TInt aX, TInt aY);
       
   397         virtual TBool ExitWithKey(TInt aKeycode);
       
   398         virtual TBool LeaveControl();
       
   399 
       
   400     public:  // from CCoeControl
       
   401         TInt CountComponentControls() const;
       
   402         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   403         virtual TKeyResponse OfferKeyEventL(
       
   404             const TKeyEvent& aKeyEvent, TEventCode);
       
   405         void ConstructFromResourceL(TResourceReader& aReader);
       
   406 
       
   407         /**
       
   408          * This function handles pointer events directed at the charmapdialog.
       
   409          * @param aPointerEvent The pointer event directed at the charmapdialog.
       
   410          */
       
   411         virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   412 
       
   413         virtual TSize MinimumSize();
       
   414         virtual void SizeChanged();
       
   415         virtual void Draw(const TRect& aRect) const;
       
   416 
       
   417     public:  // New function
       
   418         // The number of Buttons
       
   419         inline TInt Count() const;
       
   420 
       
   421         void SetCurrentCategory(TInt aCategory);
       
   422         void SetValidSctCase(TInt aSctCase);
       
   423         void RemoveInvalidButton();
       
   424 
   343 
   425     private:  // data
   344     private:  // data
   426         RPointerArray<CAknSctCategoryButton> iButtonArray;
   345         RPointerArray<CAknSctCategoryButton> iButtonArray;
   427         MCoeControlObserver* iObserver;
       
   428         TInt iFlags;
       
   429         CAknCharMapExtension* iExtension;
       
   430         CAknCharMap* iCharMap;
       
   431         TInt iButtonIndex;
       
   432         TInt iEntryIndex;
       
   433     };
   346     };
       
   347 
       
   348 CAknSctRadioButton::CAknSctRadioButton()
       
   349     {
       
   350     }
       
   351 
       
   352 CAknSctRadioButton::~CAknSctRadioButton()
       
   353     {
       
   354     iButtonArray.ResetAndDestroy();
       
   355     iButtonArray.Close();
       
   356     }
       
   357 
   434 // end of CAknSctRadioButton class definition
   358 // end of CAknSctRadioButton class definition
   435 
   359 
   436 // ----------------------------------------------------------------------------
   360 // ----------------------------------------------------------------------------
   437 // Extension class defintion
   361 // Extension class defintion
   438 // ----------------------------------------------------------------------------
   362 // ----------------------------------------------------------------------------
   495         TBool iKeyOkEvent; // ETrue is set after pressing OK Key
   419         TBool iKeyOkEvent; // ETrue is set after pressing OK Key
   496 
   420 
   497         // FeatureManager
   421         // FeatureManager
   498         TBool iPictographsBuffer;         // ETrue means Picto is valid.
   422         TBool iPictographsBuffer;         // ETrue means Picto is valid.
   499         TBool iPictographsBufferGrouping; // ETrue means Picto grouping is valid.
   423         TBool iPictographsBufferGrouping; // ETrue means Picto grouping is valid.
   500         TBool iJapaneseSctUi;       // Title and Softkey for Japanese varinat
       
   501         TBool iHasCategoryButtonUi; // Has Category button UI
       
   502         CAknSctRadioButton* iRadioButton;
       
   503         TInt  iCurrentCategory;     // defined enum TAknSCTCategoryButton on avkon.hrh
   424         TInt  iCurrentCategory;     // defined enum TAknSCTCategoryButton on avkon.hrh
   504 
   425 
   505         // QHD layout.
   426         // QHD layout.
   506         CAknCharMap* iCharMapProxy;
   427         CAknCharMap* iCharMapProxy;
   507         MAknSctFocusHandler* iFocusHandler;
   428         MAknSctFocusHandler* iFocusHandler;
   508         CAknSctTableNavi* iTableNavi;
       
   509         CAknSctPageNavi* iPageNavi;
   429         CAknSctPageNavi* iPageNavi;
   510         HBufC* iEntryBuf;
   430         HBufC* iEntryBuf;
   511         CEikLabel* iCategoryTitle;
   431         CEikLabel* iCategoryTitle;
   512         CEikLabel* iCategoryEntry;
   432         CEikLabel* iCategoryEntry;
   513         TBool iSelectAllowed;
   433         TBool iSelectAllowed;
   538 
   458 
   539         /**
   459         /**
   540         * Is keyboard event
   460         * Is keyboard event
   541         */
   461         */
   542         TBool iKeyBrdEvent;
   462         TBool iKeyBrdEvent;
       
   463         
       
   464     private:
       
   465         CAknSctRadioButton iForBCDoNotUse;
   543     };
   466     };
   544 
   467 
   545 // ----------------------------------------------------------------------------
   468 // ----------------------------------------------------------------------------
   546 // Navi button class implementation
   469 // Navi button class implementation
   547 // ----------------------------------------------------------------------------
   470 // ----------------------------------------------------------------------------
   598     }
   521     }
   599 
   522 
   600 TBool CAknSctNaviButton::IsEnabled()
   523 TBool CAknSctNaviButton::IsEnabled()
   601     {
   524     {
   602     return iButtonControl->IsVisible();
   525     return iButtonControl->IsVisible();
   603     }
       
   604 
       
   605 // ----------------------------------------------------------------------------
       
   606 // Table navi class implementation
       
   607 // ----------------------------------------------------------------------------
       
   608 //
       
   609 CAknSctTableNavi::CAknSctTableNavi(CAknCharMap* aCharMap, CAknCharMapExtension* aExtension) : 
       
   610 iCharMap(aCharMap), iExtension(aExtension)
       
   611     {
       
   612     }
       
   613 
       
   614 CAknSctTableNavi::~CAknSctTableNavi()
       
   615     {
       
   616     if (iButtonArray.Count())
       
   617         {
       
   618         iButtonArray.ResetAndDestroy();
       
   619         }
       
   620     iButtonArray.Close();
       
   621     delete iIdle;
       
   622     }
       
   623 
       
   624 TInt CAknSctTableNavi::CountComponentControls() const
       
   625     {
       
   626     return iButtonArray.Count();
       
   627     }
       
   628 
       
   629 CCoeControl* CAknSctTableNavi::ComponentControl( TInt aIndex ) const
       
   630     {
       
   631     CCoeControl* rtn;
       
   632     if (aIndex < iButtonArray.Count())
       
   633         {
       
   634         rtn = iButtonArray[aIndex]->iButtonControl;
       
   635         }
       
   636     else
       
   637         {
       
   638         rtn = NULL;
       
   639         }
       
   640     return rtn;
       
   641     }
       
   642 
       
   643 TKeyResponse CAknSctTableNavi::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aModifiers)
       
   644     {
       
   645     CAknSctNaviButton* buttonObj = iButtonArray[iButtonIndex];
       
   646     buttonObj->iButtonControl->OfferKeyEventL(aKeyEvent,aModifiers);
       
   647     TKeyResponse response = EKeyWasNotConsumed;
       
   648     TUint code=aKeyEvent.iCode;
       
   649     switch (code)
       
   650         {
       
   651         case EKeyEnter:
       
   652         case EKeyOK:
       
   653             {
       
   654             switch (buttonObj->iButtonId)
       
   655                 {
       
   656                 case EAknSctTableNaviExit:
       
   657                     {
       
   658                     iExtension->iKeyOkEvent = ETrue;
       
   659                     TableExitL();
       
   660                     response = EKeyWasConsumed;
       
   661                     }
       
   662                     break;
       
   663                 // add all supported table types here.
       
   664                 case EAknSctTableNaviSpecialChar:
       
   665                 case EAknSctTableNaviEmotion:
       
   666                     {
       
   667                     NextTableL();
       
   668                     response = EKeyWasConsumed;
       
   669                     }
       
   670                     break;
       
   671                 default:
       
   672                     break;
       
   673                 }
       
   674             }
       
   675             break;
       
   676         case EKeyLeftArrow:
       
   677         case '4':
       
   678             {
       
   679             MoveFocus(-1,0);
       
   680             response = EKeyWasConsumed;
       
   681             }
       
   682             break;
       
   683         case EKeyRightArrow:
       
   684         case '6':
       
   685             {
       
   686             MoveFocus(1,0);
       
   687             response = EKeyWasConsumed;
       
   688             }
       
   689             break;
       
   690         case EKeyUpArrow:
       
   691         case '2':
       
   692             {
       
   693             response = EKeyWasConsumed;
       
   694             if ((iButtonIndex==0) && !Layout_Meta_Data::IsLandscapeOrientation())
       
   695                 {
       
   696                 // Left page button.
       
   697                 if (iExtension->iPageNavi && iExtension->iPageNavi->EnterControl(0,0))
       
   698                     {
       
   699                     LeaveControl();
       
   700                     }
       
   701                 }
       
   702             else
       
   703                 {
       
   704                 // Last radio button.
       
   705                 if ((iButtonIndex==0) && iExtension->iRadioButton)
       
   706                     {
       
   707                     if (iExtension->iRadioButton->EnterControl(0,iExtension->iRadioButton->Count()-1))
       
   708                         {
       
   709                         LeaveControl();
       
   710                         }
       
   711                     break;
       
   712                     }
       
   713 
       
   714                 // Grid bottom row.
       
   715                 TInt xPos = ButtonPosition(iButtonIndex);
       
   716                 if (iCharMap->ColMax(0) > iCharMap->ColMax(xPos))
       
   717                     {
       
   718                     xPos = iCharMap->RowMax(iCharMap->ColMax(0));
       
   719                     }
       
   720 
       
   721                 if (iExtension->EnterControl(xPos,iCharMap->ColMax(xPos)))
       
   722                     {
       
   723                     LeaveControl();
       
   724                     break;
       
   725                     }
       
   726                 }
       
   727             }
       
   728             break;
       
   729             
       
   730         case EKeyDownArrow:
       
   731         case '8':
       
   732             {
       
   733             response = EKeyWasConsumed;
       
   734             
       
   735             // First radio button.
       
   736             if ((iButtonIndex==0) && iExtension->iRadioButton)
       
   737                 {
       
   738                 if (iExtension->iRadioButton->EnterControl(0,0))
       
   739                     {
       
   740                     LeaveControl();
       
   741                     }
       
   742                 break;
       
   743                 }
       
   744             
       
   745             // Grid top row.
       
   746             TInt xPos = ButtonPosition(iButtonIndex);
       
   747             if (iExtension->EnterControl(xPos,iCharMap->ColMin(xPos)))
       
   748                 {
       
   749                 LeaveControl();
       
   750                 break;
       
   751                 }
       
   752             }
       
   753             break;
       
   754             
       
   755         default:
       
   756             break;
       
   757         }
       
   758     return response;
       
   759     }
       
   760 
       
   761 void CAknSctTableNavi::TableExitL()
       
   762     {
       
   763     if(!iIdle)
       
   764         {
       
   765         iIdle = CIdle::NewL(CActive::EPriorityStandard);
       
   766         }
       
   767 
       
   768     iIdle->Cancel();
       
   769     iIdle->Start(TCallBack(TableExitCallBackL, this));
       
   770     }
       
   771 
       
   772 TInt CAknSctTableNavi::TableExitCallBackL(TAny* aThis)
       
   773     {
       
   774     ((CAknSctTableNavi*)aThis)->DoTableExitL();
       
   775     return KErrNone;
       
   776     }
       
   777 
       
   778 void CAknSctTableNavi::DoTableExitL()
       
   779     {
       
   780     iCharMap->SetStatusChanged(EAknCharSelectedTableExitButton);
       
   781     }
       
   782 
       
   783 void CAknSctTableNavi::NextTableL()
       
   784     {
       
   785     if(!iIdle)
       
   786         {
       
   787         iIdle = CIdle::NewL(CActive::EPriorityStandard);
       
   788         }
       
   789 
       
   790     iIdle->Cancel();
       
   791     iIdle->Start(TCallBack(NextTableCallBackL, this));
       
   792     }
       
   793 
       
   794 TInt CAknSctTableNavi::NextTableCallBackL(TAny* aThis)
       
   795     {
       
   796     ((CAknSctTableNavi*)aThis)->DoNextTableL();
       
   797     return KErrNone;
       
   798     }
       
   799 
       
   800 void CAknSctTableNavi::DoNextTableL()
       
   801     {
       
   802     iCharMap->SetStatusChanged(EAknCharSelectedNextTableButton);
       
   803     }
       
   804 
       
   805 TInt CAknSctTableNavi::ButtonPosition(TInt aButtonIndex) const
       
   806     {
       
   807     // buttons behind the 1th are behavior as one button
       
   808     return (aButtonIndex==0) ? 0 : 1;
       
   809     }
       
   810 
       
   811 void CAknSctTableNavi::ConstructFromResourceL(TResourceReader& aReader)
       
   812     {
       
   813     // Table navi buttons.
       
   814     TInt counts = aReader.ReadInt16();
       
   815     for (TInt i = 0; i < counts; i++)
       
   816         {
       
   817         TInt buttonId = aReader.ReadInt16();
       
   818         TInt resId = aReader.ReadInt32();
       
   819         TResourceReader buttonReader;
       
   820         iCoeEnv->CreateResourceReaderLC(buttonReader, resId);
       
   821         CAknSctNaviButton* buttonObj = CAknSctNaviButton::NewL(*this, buttonId, buttonReader);
       
   822         buttonObj->SetObserver(this);
       
   823         iButtonArray.Append(buttonObj);
       
   824         CleanupStack::PopAndDestroy(); // buttonReader
       
   825         }
       
   826     }
       
   827 
       
   828 TSize CAknSctTableNavi::MinimumSize()
       
   829     {
       
   830     return Rect().Size();
       
   831     }
       
   832 
       
   833 void CAknSctTableNavi::SizeChanged()
       
   834     {
       
   835     if (iButtonArray.Count()>0)
       
   836         {
       
   837 
       
   838         TInt ctrlVariety = 2;
       
   839         TInt cellVariety = 1;
       
   840         if(!iCharMap->IsJapaneseSctUi())
       
   841             {
       
   842             ctrlVariety = (iCharMap->TableCount()>1) ? 0 : 1;
       
   843             cellVariety = 0;
       
   844             }
       
   845         
       
   846         TAknLayoutRect cellLayRect, buttonLayRect;
       
   847         TRect buttonRect;
       
   848 
       
   849         // Table exit.
       
   850         cellLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(ctrlVariety,0));
       
   851         buttonLayRect.LayoutRect(cellLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(cellVariety));
       
   852         buttonRect = buttonLayRect.Rect();
       
   853 
       
   854         TAknLayoutRect iconLayRect;
       
   855         iconLayRect.LayoutRect(buttonRect, AknLayoutScalable_Avkon::cell_graphic2_control_pane_g1(cellVariety));
       
   856         TSize iconSize = iconLayRect.Rect().Size();
       
   857 
       
   858         CAknSctNaviButton* buttonObj = iButtonArray[0];
       
   859         buttonObj->iButtonControl->SetRect(buttonRect);
       
   860         buttonObj->iButtonControl->SetHighlightRect(buttonRect);
       
   861         buttonObj->iButtonControl->SetIconScaleMode(EAspectRatioPreserved);
       
   862         buttonObj->iButtonControl->SetIconSize(iconSize);
       
   863         buttonObj->SetEnabled(ETrue);
       
   864 
       
   865         // Table change.
       
   866         if (iCharMap->TableCount() > 1)
       
   867             {
       
   868             cellLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(ctrlVariety,1));
       
   869             buttonLayRect.LayoutRect(cellLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(cellVariety));
       
   870             buttonRect = buttonLayRect.Rect();
       
   871             
       
   872             for (TInt i(1); i<iButtonArray.Count(); i++)
       
   873                 {
       
   874                 CAknSctNaviButton* buttonObj = iButtonArray[i];
       
   875                 buttonObj->iButtonControl->SetRect(buttonRect);
       
   876                 buttonObj->iButtonControl->SetHighlightRect(buttonRect);
       
   877                 buttonObj->iButtonControl->SetIconScaleMode(EAspectRatioPreserved);
       
   878                 buttonObj->iButtonControl->SetIconSize(iconSize);
       
   879                 buttonObj->SetEnabled(ETrue);
       
   880                 }
       
   881             }
       
   882 
       
   883         TRAP_IGNORE(UpdateNextTableButtonL());
       
   884         }
       
   885     }
       
   886 
       
   887 void CAknSctTableNavi::HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType)
       
   888     {
       
   889     if(aEventType == EEventStateChanged)
       
   890         {
       
   891         for(TInt i=0; i<iButtonArray.Count(); i++)
       
   892             {
       
   893             CAknSctNaviButton* button = iButtonArray[i];
       
   894             if(button->iButtonControl == aControl)
       
   895                 {
       
   896                 switch(button->iButtonId)
       
   897                     {
       
   898                     case EAknSctTableNaviExit:
       
   899                         {
       
   900                         iExtension->iKeyOkEvent = ETrue;
       
   901                         TableExitL();
       
   902                         }
       
   903                         return;
       
   904                         
       
   905                     case EAknSctTableNaviSpecialChar:
       
   906                     case EAknSctTableNaviEmotion:
       
   907                         {
       
   908                         NextTableL();
       
   909                         }
       
   910                         return;
       
   911                         
       
   912                     default:
       
   913                         break;
       
   914                     }
       
   915             
       
   916                 break;
       
   917                 }
       
   918             }
       
   919         }
       
   920     }
       
   921 
       
   922 
       
   923 void CAknSctTableNavi::UpdateNextTableButtonL()
       
   924     {
       
   925     
       
   926     TBool isFocused = EFalse;
       
   927     
       
   928     // table switch buttons stay in one place.
       
   929     for(TInt index(1); index<iButtonArray.Count(); index++)
       
   930         {
       
   931         CAknSctNaviButton* buttonObj = iButtonArray[index];
       
   932         if(buttonObj->IsEnabled())
       
   933             {
       
   934             isFocused = buttonObj->IsFocused();
       
   935             }
       
   936         }
       
   937     
       
   938     // fresh focused button
       
   939     for (TInt index(1); index<iButtonArray.Count(); index++)
       
   940         {
       
   941         CAknSctNaviButton* buttonObj = iButtonArray[index];
       
   942         if (iCharMap->TableCount() > 1)
       
   943             {
       
   944             switch (iCharMap->NextTableCase())
       
   945                 {
       
   946                 case EAknCharMapTableSpecialChar:
       
   947                     {
       
   948                     TBool isShown = EFalse;
       
   949                     if(iExtension->IsShowingEmotion())
       
   950                         {
       
   951                         isShown = (buttonObj->iButtonId==EAknSctTableNaviSpecialChar);
       
   952                         }
       
   953                     else
       
   954                         {
       
   955                         isShown = (buttonObj->iButtonId==EAknSctTableNaviEmotion);
       
   956                         }
       
   957                     buttonObj->SetEnabled(isShown);
       
   958                     buttonObj->SetFocused(isShown && isFocused);
       
   959                     if(isShown && isFocused)
       
   960                         {
       
   961                         iButtonIndex = index;
       
   962                         }
       
   963                     }
       
   964                     break;
       
   965 
       
   966                 default:
       
   967                     buttonObj->SetEnabled(EFalse);
       
   968                     break;
       
   969                 }
       
   970             }
       
   971         else
       
   972             {
       
   973             buttonObj->SetEnabled(EFalse);
       
   974             }
       
   975         }
       
   976     }
       
   977 
       
   978 CCoeControl* CAknSctTableNavi::FocusedControl()
       
   979     {
       
   980     return this;
       
   981     }
       
   982 
       
   983 TBool CAknSctTableNavi::EnterControl(TInt aX, TInt /*aY*/)
       
   984     {
       
   985     if (IsVisible())
       
   986         {
       
   987         if ((aX >= 0) && (aX < iButtonArray.Count()))
       
   988             {
       
   989             TInt index = aX;
       
   990             if (AknLayoutUtils::LayoutMirrored()) // reverse.
       
   991                 {
       
   992                 index = (iButtonArray.Count() - 1) - aX;
       
   993                 }
       
   994 
       
   995             index = ButtonPosition(index);
       
   996 
       
   997             for(; index<iButtonArray.Count(); index++)
       
   998                 {
       
   999                 CAknSctNaviButton* buttonObj = iButtonArray[index];
       
  1000                 if (buttonObj->IsEnabled())
       
  1001                     {
       
  1002                     iButtonIndex = index;
       
  1003                     iExtension->iFocusHandler = this;
       
  1004                     buttonObj->SetFocused(ETrue);
       
  1005                     return ETrue;
       
  1006                     }
       
  1007                 }
       
  1008             }
       
  1009         }
       
  1010     return EFalse;
       
  1011     }
       
  1012 
       
  1013 void CAknSctTableNavi::MoveFocus(TInt aX, TInt /*aY*/)
       
  1014     {
       
  1015     TInt delta = aX;
       
  1016     if (AknLayoutUtils::LayoutMirrored()) // reverse.
       
  1017         {
       
  1018         delta = -aX;
       
  1019         }
       
  1020 
       
  1021     TInt buttonIndex = iButtonIndex + delta;
       
  1022 
       
  1023     // loop until find next position
       
  1024     for (TInt i = 0; i < iButtonArray.Count(); i++)
       
  1025         {
       
  1026 
       
  1027         if (buttonIndex > iButtonArray.Count() - 1) // goto Next control
       
  1028             {
       
  1029             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1030                 {
       
  1031                 // First radio button.
       
  1032                 if (iExtension->iRadioButton)
       
  1033                     {
       
  1034                     if (iExtension->iRadioButton->EnterControl(0,0))
       
  1035                         {
       
  1036                         LeaveControl();
       
  1037                         }
       
  1038                     break;
       
  1039                     }
       
  1040                 // Grid start.
       
  1041                 if (iExtension->EnterControl(0,iCharMap->ColMin(0)))
       
  1042                     {
       
  1043                     LeaveControl();
       
  1044                     }
       
  1045                 }
       
  1046             else
       
  1047                 {
       
  1048                 // Left page button.
       
  1049                 if (iExtension->iPageNavi &&
       
  1050                     iExtension->iPageNavi->EnterControl(0,0))
       
  1051                     {
       
  1052                     LeaveControl();
       
  1053                     }
       
  1054                 }
       
  1055             break;
       
  1056             }
       
  1057 
       
  1058         else if (buttonIndex < 0) // goto Prev control
       
  1059             {
       
  1060             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1061                 {
       
  1062                 // Right page button.
       
  1063                 if (iExtension->iPageNavi &&
       
  1064                     iExtension->iPageNavi->EnterControl(1,0))
       
  1065                     {
       
  1066                     LeaveControl();
       
  1067                     }
       
  1068                 }
       
  1069             else
       
  1070                 {
       
  1071                 // Grid end.
       
  1072                 TInt posY = iCharMap->ColMax(0);
       
  1073                 if (iExtension->EnterControl(iCharMap->RowMax(posY),posY))
       
  1074                     {
       
  1075                     LeaveControl();
       
  1076                     }
       
  1077                 }
       
  1078             break;
       
  1079             }
       
  1080 
       
  1081         if (iButtonArray[buttonIndex]->IsEnabled()) // goto next button in This control
       
  1082             {
       
  1083             CAknSctNaviButton* buttonObj;
       
  1084             buttonObj = iButtonArray[iButtonIndex];
       
  1085             buttonObj->SetFocused(EFalse);
       
  1086             iButtonIndex = buttonIndex;
       
  1087             buttonObj = iButtonArray[iButtonIndex];
       
  1088             buttonObj->SetFocused(ETrue);
       
  1089             break;
       
  1090             }
       
  1091         
       
  1092         buttonIndex += (delta < 0) ? -1 : 1; // get next position
       
  1093         }
       
  1094     }
       
  1095 
       
  1096 TBool CAknSctTableNavi::LeaveControl()
       
  1097     {
       
  1098     for (TInt i = 0; i < iButtonArray.Count(); i++ )
       
  1099         {
       
  1100         iButtonArray[i]->SetFocused(EFalse);
       
  1101         }
       
  1102     return ETrue;
       
  1103     }
       
  1104 
       
  1105 TBool CAknSctTableNavi::ExitWithKey(TInt /*aKeycode*/)
       
  1106     {
       
  1107     if (iButtonArray[iButtonIndex]->iButtonId != EAknSctTableNaviExit)
       
  1108         {
       
  1109         return EFalse;
       
  1110         }
       
  1111     else
       
  1112         {
       
  1113         return ETrue;
       
  1114         }
       
  1115     }
   526     }
  1116 
   527 
  1117 // ----------------------------------------------------------------------------
   528 // ----------------------------------------------------------------------------
  1118 // Page Navi class implementation
   529 // Page Navi class implementation
  1119 // ----------------------------------------------------------------------------
   530 // ----------------------------------------------------------------------------
  1132         {
   543         {
  1133         iButtonArray.ResetAndDestroy();
   544         iButtonArray.ResetAndDestroy();
  1134         }
   545         }
  1135     iButtonArray.Close();
   546     iButtonArray.Close();
  1136     delete iTitle;
   547     delete iTitle;
       
   548     delete iIdle;
  1137     }
   549     }
  1138 
   550 
  1139 TInt CAknSctPageNavi::CountComponentControls() const
   551 TInt CAknSctPageNavi::CountComponentControls() const
  1140     {
   552     {
  1141     TInt num= 0;
   553     TInt num= 0;
  1180         case EKeyEnter:
   592         case EKeyEnter:
  1181         case EKeyOK:
   593         case EKeyOK:
  1182             {
   594             {
  1183             switch (buttonObj->iButtonId)
   595             switch (buttonObj->iButtonId)
  1184                 {
   596                 {
       
   597                 case EAknSctTableNaviExit:
       
   598                     {
       
   599                     iExtension->iKeyOkEvent = ETrue;
       
   600                     TableExitL();
       
   601                     }
       
   602                     break;
  1185                 case EAknSctPageNaviPrevPage:
   603                 case EAknSctPageNaviPrevPage:
  1186                     {
   604                     {
  1187                     iCharMap->PrevPageL();
   605                     iCharMap->PrevPageL();
  1188                     }
   606                     }
  1189                     break;
   607                     break;
  1190                 case EAknSctPageNaviNextPage:
   608                 case EAknSctPageNaviNextPage:
  1191                     {
   609                     {
  1192                     iCharMap->NextPageL();
   610                     iCharMap->NextPageL();
  1193                     }
   611                     }
  1194                     break;
   612                     break;
       
   613                 // add all supported table types here.
       
   614                 case EAknSctTableNaviSpecialChar:
       
   615                 case EAknSctTableNaviEmotion:
       
   616                     {
       
   617                     NextTableL();
       
   618                     }
       
   619                     break;
  1195                 default:
   620                 default:
  1196                     return EKeyWasConsumed;
   621                     return EKeyWasConsumed;
  1197                 }
   622                 }
  1198             buttonObj->SetFocused(ETrue);
   623             buttonObj->SetFocused(ETrue);
  1199             response = EKeyWasConsumed;
   624             response = EKeyWasConsumed;
  1200             UpdatePageTitleL();
   625             UpdatePageTitleL();
  1201             }
   626             }
  1202             break;
   627             break;
  1203         case EKeyLeftArrow:
   628         case EKeyLeftArrow:
  1204         case '4':
   629         case '4':
  1205             {
       
  1206             MoveFocus(-1,0);
       
  1207             response = EKeyWasConsumed;
       
  1208             }
       
  1209             break;
       
  1210         case EKeyRightArrow:
   630         case EKeyRightArrow:
  1211         case '6':
   631         case '6':
  1212             {
       
  1213             MoveFocus(1,0);
       
  1214             response = EKeyWasConsumed;
       
  1215             }
       
  1216             break;
       
  1217         case EKeyUpArrow:
   632         case EKeyUpArrow:
  1218         case '2':
   633         case '2':
  1219             {
   634         case EKeyDownArrow:
       
   635         case '8':
       
   636             {
       
   637             TInt gridX;
       
   638             TInt gridY;
       
   639             TBool gridInvolved = CalcNextStep( code, gridX, gridY );
       
   640             MoveFocus( !gridInvolved, gridX, gridY );
  1220             response = EKeyWasConsumed;
   641             response = EKeyWasConsumed;
  1221             if (!Layout_Meta_Data::IsLandscapeOrientation())
   642             }
  1222                 {
   643             break;
  1223                 if (iExtension->iRadioButton && !IsNextButton())
   644         default:
       
   645             break;
       
   646         }
       
   647     return response;
       
   648     }
       
   649 
       
   650 TBool CAknSctPageNavi::CalcNextStep( TUint aKey, TInt& aX, TInt& aY )
       
   651 	{
       
   652 	TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
   653 	TBool mirrored = AknLayoutUtils::LayoutMirrored();
       
   654 	TBool emotionEnabled = iExtension->IsEmotionEnabled();
       
   655 	TInt scPages = iCharMap->PageCount();
       
   656 	
       
   657 	aX = 0;
       
   658 	aY = 0;
       
   659 	TInt xOffset = 0;
       
   660 	TInt yOffset = 0;
       
   661 	
       
   662 	// Simplify key events to two variants
       
   663 	switch ( aKey )
       
   664 		{
       
   665         case EKeyLeftArrow:
       
   666         case '4':
       
   667         	{
       
   668         	xOffset = -1;
       
   669         	}
       
   670         	break;
       
   671         case EKeyRightArrow:
       
   672         case '6':
       
   673         	{
       
   674         	xOffset = 1;
       
   675         	}
       
   676         	break;
       
   677         case EKeyDownArrow:
       
   678         case '8':
       
   679         	{
       
   680         	yOffset = 1;
       
   681         	}
       
   682         	break;
       
   683         case EKeyUpArrow:
       
   684         case '2':
       
   685         	{
       
   686         	yOffset = -1;
       
   687         	}
       
   688         	break;
       
   689         default:
       
   690         	break;
       
   691 		}
       
   692 
       
   693 	TInt runtimeIndex = iButtonIndex;
       
   694 	if ( !emotionEnabled )
       
   695         {
       
   696 	    // SC/Emotion unabled, button regrouped!
       
   697         if ( ( mirrored && iButtonIndex == EAknSctPageNaviPrevPage && xOffset != 1 )
       
   698           || ( !mirrored && iButtonIndex == EAknSctPageNaviNextPage && xOffset != -1) )
       
   699         	{
       
   700             runtimeIndex = iExtension->IsShowingEmotion()?EAknSctTableNaviSpecialChar:EAknSctTableNaviEmotion;
       
   701         	}
       
   702         }
       
   703     // calculate when moving from PageNavi to grid, the column position
       
   704     switch ( runtimeIndex ) 
       
   705     	{
       
   706     	case EAknSctTableNaviExit:
       
   707     		{
       
   708     		aX = 0;
       
   709             if ( ( !mirrored && xOffset == -1 ) || ( mirrored && xOffset == 1 ) )
       
   710             	{
       
   711                 // Grid end
       
   712                 aY = iCharMap->ColMax(0);
       
   713                 aX = iCharMap->RowMax( aY );
       
   714                 return ETrue;
       
   715             	}
       
   716             else if ( mirrored && xOffset == -1 && scPages >= 2 )
       
   717             	{
       
   718                 xOffset = EAknSctPageNaviNextPage;
       
   719             	}
       
   720             else if ( scPages < 2 
       
   721                     && ( ( !mirrored && xOffset == 1 ) || ( mirrored && xOffset == -1 ) ) )
       
   722                 {
       
   723                 if ( !emotionEnabled )
  1224                     {
   724                     {
  1225                     // Last radio button.
   725                     // Grid start
  1226                     if (iExtension->iRadioButton->EnterControl(
   726                     aX = 0;
  1227                         0,iExtension->iRadioButton->Count()-1))
   727                     aY = iCharMap->ColMin( aX );
  1228                         {
   728                     return ETrue;
  1229                         LeaveControl();
       
  1230                         }
       
  1231                     break;
       
  1232                     }
       
  1233                 }
       
  1234             TInt xPos;
       
  1235             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1236                 {
       
  1237                 xPos = IsNextButton() ? iCharMap->MaxCols() - 1 : 0;
       
  1238                 }
       
  1239             else
       
  1240                 {
       
  1241                 if (IsNextButton())
       
  1242                     {
       
  1243                     xPos = iCharMap->MaxCols() - 1;
       
  1244                     }
   729                     }
  1245                 else
   730                 else
  1246                     {
   731                     {
  1247                     xPos = !iExtension->iRadioButton ?
   732                     xOffset = LastButton();
  1248                         iCharMap->TableCount() : iCharMap->MaxCols()-2;
       
  1249                     }
   733                     }
  1250                 }
   734                 }
  1251             if (iCharMap->ColMax(0) > iCharMap->ColMax(xPos))
       
  1252                 {
       
  1253                 xPos = iCharMap->RowMax(iCharMap->ColMax(0));
       
  1254                 }
       
  1255             // Grid bottom row.
       
  1256             if (iExtension->EnterControl(xPos,iCharMap->ColMax(xPos)))
       
  1257                 {
       
  1258                 LeaveControl();
       
  1259                 break;
       
  1260                 }
       
  1261             }
       
  1262             break;
       
  1263         case EKeyDownArrow:
       
  1264         case '8':
       
  1265             {
       
  1266             response = EKeyWasConsumed;
       
  1267             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1268                 {
       
  1269                 if (!IsNextButton())
       
  1270                     {
       
  1271                     // First table button.
       
  1272                     if (iExtension->iTableNavi &&
       
  1273                         iExtension->iTableNavi->EnterControl(0,0))
       
  1274                         {
       
  1275                         LeaveControl();
       
  1276                         break;
       
  1277                         }
       
  1278                     }
       
  1279                 else
       
  1280                     {
       
  1281                     // Grid top row.
       
  1282                     TInt xPos = iCharMap->MaxCols() - 1;
       
  1283                     if (iExtension->EnterControl(xPos,iCharMap->ColMin(xPos)))
       
  1284                         {
       
  1285                         LeaveControl();
       
  1286                         break;
       
  1287                         }
       
  1288                     }
       
  1289                 }
       
  1290             else
   735             else
  1291                 {
   736             	{
  1292                 TInt xPos;
   737                 xOffset = EAknSctTableNaviExit + xOffset;
  1293                 if (IsNextButton())
   738             	}
  1294                     {
   739     		}
  1295                     xPos = iCharMap->MaxCols() - 1;
   740     		break;
  1296                     }
   741     	case EAknSctPageNaviPrevPage:
  1297                 else
   742     		{
  1298                     {
   743     		aX = mirrored ? iCharMap->MaxCols()-2 : 1;
  1299                     xPos = !iExtension->iRadioButton ?
   744     		if ( mirrored && xOffset == -1 )
  1300                         iCharMap->TableCount() : iCharMap->MaxCols() - 2;
   745     			{
  1301                     }
   746     		    xOffset = LastButton();
  1302                 // Grid top row.
   747     			}
  1303                 if (iExtension->EnterControl(xPos,iCharMap->ColMin(xPos)))
   748     		else
  1304                     {
   749     			{
  1305                     LeaveControl();
   750     		    xOffset = xOffset + EAknSctPageNaviPrevPage;
  1306                     break;
   751     			}
  1307                     }
   752     		}
  1308                 }
   753     		break;
  1309             }
   754     	case EAknSctPageNaviNextPage:
  1310             break;
   755     		{
  1311         default:
   756     		aX = mirrored ? 1 : iCharMap->MaxCols()-2;
  1312             break;
   757     		if ( mirrored && xOffset == 1 )
  1313         }
   758     			{
  1314     return response;
   759     		    xOffset = 0;
  1315     }
   760     			}
       
   761     		else if ( !mirrored && xOffset == 1 )
       
   762     			{
       
   763     		    xOffset = LastButton();
       
   764     			}
       
   765     		else
       
   766     			{
       
   767     		    xOffset = EAknSctPageNaviNextPage + xOffset;
       
   768     			}
       
   769     		}
       
   770     		break;
       
   771     	case EAknSctTableNaviSpecialChar:
       
   772     	case EAknSctTableNaviEmotion:
       
   773     		{
       
   774     		aX = iCharMap->MaxCols()-1;
       
   775             if ( ( !mirrored && xOffset == 1 ) || ( mirrored && xOffset == -1 ) )
       
   776             	{
       
   777                 // Grid start
       
   778                 aX = 0;
       
   779                 aY = iCharMap->ColMin( aX );
       
   780                 return ETrue;
       
   781                 }
       
   782             else if ( scPages < 2 
       
   783                     && ( ( !mirrored && xOffset == -1 ) || ( mirrored && xOffset == 1 ) ) )
       
   784                 {
       
   785                 xOffset = EAknSctTableNaviExit;
       
   786                 }
       
   787             else if ( mirrored && xOffset == 1 )
       
   788             	{
       
   789                 xOffset = EAknSctPageNaviPrevPage;
       
   790             	}
       
   791             else
       
   792             	{
       
   793                 xOffset = EAknSctPageNaviNextPage;
       
   794             	}
       
   795     		}
       
   796     		break;
       
   797     	default:
       
   798     		break;
       
   799     	}
       
   800     
       
   801     if ( yOffset == 1 )
       
   802     	{
       
   803         // DOWN
       
   804         aY = iCharMap->ColMin( aX );
       
   805         return ETrue;
       
   806     	}
       
   807     else if ( yOffset == -1 )
       
   808     	{
       
   809         // and UP
       
   810         aY = iCharMap->ColMax( aX );
       
   811         return ETrue;
       
   812     	}
       
   813 
       
   814     // Return False means it's internal moving focus within Page Navi
       
   815     aX = xOffset;
       
   816     aY = 0;
       
   817     return EFalse;
       
   818 	}
  1316 
   819 
  1317 TBool CAknSctPageNavi::IsNextButton() const
   820 TBool CAknSctPageNavi::IsNextButton() const
  1318     {
   821     {
  1319     if (iButtonIndex < iButtonArray.Count() && iButtonArray[iButtonIndex])
   822     if (iButtonIndex < iButtonArray.Count() && iButtonArray[iButtonIndex])
  1320         {
   823         {
  1348     if (aEventType == EEventStateChanged && AknLayoutUtils::PenEnabled()) // action on key repeat
   851     if (aEventType == EEventStateChanged && AknLayoutUtils::PenEnabled()) // action on key repeat
  1349         {
   852         {
  1350         for (TInt index=0; index < iButtonArray.Count(); index++)
   853         for (TInt index=0; index < iButtonArray.Count(); index++)
  1351             {
   854             {
  1352             CAknSctNaviButton* buttonObj = iButtonArray[index];
   855             CAknSctNaviButton* buttonObj = iButtonArray[index];
  1353             TRect buttonRect = buttonObj->iButtonControl->Rect();
       
  1354             if (buttonObj->iButtonControl == aControl)
   856             if (buttonObj->iButtonControl == aControl)
  1355                 {
   857                 {
  1356                 if (buttonObj->IsEnabled() && buttonObj->iPressed)
   858                 if (buttonObj->IsEnabled() && buttonObj->iPressed)
  1357                     {
   859                     {
  1358                     iButtonIndex = index;
   860                     iButtonIndex = index;
  1362                             {
   864                             {
  1363                             buttonObj->iRepeat = ETrue; // Set button repeat.
   865                             buttonObj->iRepeat = ETrue; // Set button repeat.
  1364                             iCharMap->PrevPageL();
   866                             iCharMap->PrevPageL();
  1365                             UpdatePageTitleL();
   867                             UpdatePageTitleL();
  1366                             }
   868                             }
  1367                             break;
   869                             return;
  1368                         case EAknSctPageNaviNextPage:
   870                         case EAknSctPageNaviNextPage:
  1369                             {
   871                             {
  1370                             buttonObj->iRepeat = ETrue; // Set button repeat.
   872                             buttonObj->iRepeat = ETrue; // Set button repeat.
  1371                             iCharMap->NextPageL();
   873                             iCharMap->NextPageL();
  1372                             UpdatePageTitleL();
   874                             UpdatePageTitleL();
  1373                             }
   875                             }
  1374                             break;
   876                             return;
  1375                         default:
   877                         default:
  1376                             break;
   878                             break;
  1377                         }
   879                         }
  1378                     }
   880                     }
  1379                 }
   881                 }
  1390             for (TInt index=0; index < iButtonArray.Count(); index++)
   892             for (TInt index=0; index < iButtonArray.Count(); index++)
  1391                 {
   893                 {
  1392                 CAknSctNaviButton* buttonObj = iButtonArray[index];
   894                 CAknSctNaviButton* buttonObj = iButtonArray[index];
  1393                 buttonObj->iPressed = EFalse;
   895                 buttonObj->iPressed = EFalse;
  1394                 buttonObj->iRepeat = EFalse;
   896                 buttonObj->iRepeat = EFalse;
       
   897                 TInt buttonIndex = buttonObj->iButtonId;
  1395                 TRect buttonRect = buttonObj->iButtonControl->Rect();
   898                 TRect buttonRect = buttonObj->iButtonControl->Rect();
  1396                 if (buttonRect.Contains(aPointerEvent.iPosition))
   899                 if ( buttonRect.Contains(aPointerEvent.iPosition))
  1397                     {
   900                     {
  1398                     if (buttonObj->IsEnabled())
   901                     if (buttonObj->IsEnabled())
  1399                         {
   902                         {
  1400                         buttonObj->iButtonControl->SetButtonFlags(KAknButtonKeyRepeat);
       
  1401                         buttonObj->iPressed = ETrue; // Set button pressed.
   903                         buttonObj->iPressed = ETrue; // Set button pressed.
       
   904                         if ( buttonIndex == EAknSctPageNaviPrevPage 
       
   905                           || buttonIndex == EAknSctPageNaviNextPage )
       
   906                             {
       
   907                             // Only Prev/Next button can repeat
       
   908                             buttonObj->iButtonControl->SetButtonFlags( KAknButtonKeyRepeat );
       
   909                             }
  1402                         }
   910                         }
  1403                     }
   911                     }
  1404                 }
   912                 }
  1405             }
   913             }
  1406         else if (aPointerEvent.iType == TPointerEvent::EButton1Up) // action on button release.
   914         else if (aPointerEvent.iType == TPointerEvent::EButton1Up) // action on button release.
  1428                                     {
   936                                     {
  1429                                     iCharMap->NextPageL();
   937                                     iCharMap->NextPageL();
  1430                                     UpdatePageTitleL();
   938                                     UpdatePageTitleL();
  1431                                     }
   939                                     }
  1432                                     break;
   940                                     break;
       
   941                                 case EAknSctTableNaviExit:
       
   942                                     {
       
   943                                     iExtension->iKeyOkEvent = ETrue;
       
   944                                     TableExitL();
       
   945                                     }
       
   946                                     break;
       
   947                                 case EAknSctTableNaviSpecialChar:
       
   948                                 case EAknSctTableNaviEmotion:
       
   949                                     {
       
   950                                     NextTableL();
       
   951                                     }
       
   952                                     break;
  1433                                 default:
   953                                 default:
  1434                                     break;
   954                                     break;
  1435                                 }
   955                                 }
  1436                             }
   956                             }
  1437                         }
   957                         }
  1450     }
   970     }
  1451 
   971 
  1452 void CAknSctPageNavi::SizeChanged()
   972 void CAknSctPageNavi::SizeChanged()
  1453     {
   973     {
  1454 
   974 
  1455     TAknLayoutRect pageButtonLayRect;
   975     TAknLayoutRect pageButtonLayRect, buttonLayRect;
  1456     TInt pageVariate = !iCharMap->IsJapaneseSctUi() ? ((iCharMap->TableCount() > 1) ? 0 : 1) : 2;
   976     TInt cellVar = Layout_Meta_Data::IsLandscapeOrientation()? 3 : 2;
  1457                        
   977     TInt bgVar = 2;
       
   978     TBool landScape = Layout_Meta_Data::IsLandscapeOrientation();       
       
   979     TBool emotionEnabled = ETrue;
       
   980     TBool mirrored = AknLayoutUtils::LayoutMirrored();
  1458     CAknSctNaviButton* buttonObj;
   981     CAknSctNaviButton* buttonObj;
  1459     TRect rect;
   982     TRect rect;
  1460 
   983 
       
   984     if ( iExtension )
       
   985     	{
       
   986         emotionEnabled = iExtension->IsEmotionEnabled();
       
   987     	}
       
   988     
       
   989     // Prev button
       
   990     buttonObj = iButtonArray[1];
       
   991     buttonObj->iButtonControl->SetButtonFlags(0);
       
   992     TInt col = 0;
       
   993     if ( !landScape )
       
   994     	{
       
   995         col = mirrored ? ( !emotionEnabled?4:3 ) : 1;
       
   996     	}
       
   997     else
       
   998     	{
       
   999         col = mirrored ? ( !emotionEnabled?6:5 ) : 1;
       
  1000     	}
       
  1001     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
       
  1002     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
       
  1003     rect = buttonLayRect.Rect();
       
  1004     buttonObj->iButtonControl->SetRect(rect);
       
  1005     buttonObj->iButtonControl->SetHighlightRect(rect);
       
  1006     
       
  1007     // ...Prev button icon
       
  1008     TAknLayoutRect iconLayRect;
       
  1009     iconLayRect.LayoutRect(rect, AknLayoutScalable_Avkon::cell_graphic2_control_pane_g1(bgVar));
       
  1010     TSize iconSize = iconLayRect.Rect().Size();
       
  1011     buttonObj->iButtonControl->SetIconSize(iconSize);
       
  1012     
       
  1013     // Next button
       
  1014     buttonObj = iButtonArray[2];
       
  1015     buttonObj->iButtonControl->SetButtonFlags(0);
       
  1016     if ( !landScape )
       
  1017     	{
       
  1018         col = mirrored ? 1 : ( !emotionEnabled?4:3 );
       
  1019     	}
       
  1020     else
       
  1021     	{
       
  1022         col = mirrored ? 1 : ( !emotionEnabled?6:5 );
       
  1023     	}
       
  1024     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
       
  1025     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
       
  1026     rect = buttonLayRect.Rect();
       
  1027     buttonObj->iButtonControl->SetRect(rect);
       
  1028     buttonObj->iButtonControl->SetHighlightRect(rect);
       
  1029     
       
  1030     // ...Next button icon
       
  1031     buttonObj->iButtonControl->SetIconSize(iconSize);
       
  1032     
       
  1033     // Exit button
  1461     buttonObj = iButtonArray[0];
  1034     buttonObj = iButtonArray[0];
  1462     buttonObj->iButtonControl->SetButtonFlags(0);
  1035     buttonObj->iButtonControl->SetButtonFlags(0);
  1463     if (!AknLayoutUtils::LayoutMirrored())
  1036     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,0) );
  1464         {
  1037     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
  1465         buttonObj->iButtonId = EAknSctPageNaviPrevPage;
  1038     rect = buttonLayRect.Rect();
  1466         pageButtonLayRect.LayoutRect(Rect(),AknLayoutScalable_Avkon::bg_button_pane_cp10(pageVariate));
       
  1467         }
       
  1468     else
       
  1469         {
       
  1470         buttonObj->iButtonId = EAknSctPageNaviNextPage;
       
  1471         pageButtonLayRect.LayoutRect(Rect(),AknLayoutScalable_Avkon::bg_button_pane_cp11(pageVariate));
       
  1472         }
       
  1473     rect = pageButtonLayRect.Rect();
       
  1474     buttonObj->iButtonControl->SetRect(rect);
  1039     buttonObj->iButtonControl->SetRect(rect);
  1475     buttonObj->iButtonControl->SetHighlightRect(rect);
  1040     buttonObj->iButtonControl->SetHighlightRect(rect);
  1476     TAknLayoutRect pageButtonIconLayRect;
  1041     
  1477     pageButtonIconLayRect.LayoutRect(pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::graphic2_pages_pane_g1(pageVariate));
  1042     // ...Exit button icon
  1478     buttonObj->iButtonControl->SetIconScaleMode(EAspectRatioPreserved);
       
  1479     TSize iconSize = pageButtonIconLayRect.Rect().Size();
       
  1480     buttonObj->iButtonControl->SetIconSize(iconSize);
  1043     buttonObj->iButtonControl->SetIconSize(iconSize);
  1481 
  1044     
  1482     buttonObj = iButtonArray[1];
  1045     // Emotion/Special-char button
  1483     buttonObj->iButtonControl->SetButtonFlags(0);
  1046     col = landScape? 6 : 4;
  1484     if (!AknLayoutUtils::LayoutMirrored())
  1047     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
  1485         {
  1048     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
  1486         buttonObj->iButtonId = EAknSctPageNaviNextPage;
  1049     rect = buttonLayRect.Rect();
  1487         pageButtonLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp11(pageVariate));
  1050     for ( TInt i = 3; i < iButtonArray.Count();i++ )
  1488         }
  1051         {
  1489     else
  1052         buttonObj = iButtonArray[i];
  1490         {
  1053         buttonObj->iButtonControl->SetButtonFlags(0);
  1491         buttonObj->iButtonId = EAknSctPageNaviPrevPage;
  1054         buttonObj->iButtonControl->SetRect(rect);
  1492         pageButtonLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp10(pageVariate));
  1055         buttonObj->iButtonControl->SetHighlightRect(rect);
  1493         }
  1056         
  1494     rect = pageButtonLayRect.Rect();
  1057         // ...its icon
  1495     buttonObj->iButtonControl->SetRect(rect);
  1058         buttonObj->iButtonControl->SetIconSize(iconSize);
  1496     buttonObj->iButtonControl->SetHighlightRect(rect);
  1059         }
  1497     buttonObj->iButtonControl->SetIconScaleMode(EAspectRatioPreserved);
  1060     TRAP_IGNORE(UpdateNextTableButtonL());
  1498     buttonObj->iButtonControl->SetIconSize(iconSize);
  1061     
  1499 
       
  1500     // Page text.
  1062     // Page text.
  1501     TRect parentRect = Rect();
  1063     col = landScape? 3 : 2;
  1502     AknLayoutUtils::LayoutLabel(iTitle, parentRect, AknLayoutScalable_Avkon::graphic2_pages_pane_t1(pageVariate).LayoutLine());
  1064     pageButtonLayRect.LayoutRect(Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col));
       
  1065     TAknTextComponentLayout textlayout = AknLayoutScalable_Avkon::cell_graphic2_control_pane_t1();
       
  1066     TRect titleRect( pageButtonLayRect.Rect() );
       
  1067     if ( !emotionEnabled )
       
  1068         {
       
  1069         // start complex dynamic logic to locate title rect when emotion is unable
       
  1070         TInt orientation = mirrored ? -1 : 1;
       
  1071         TInt newLeft = titleRect.iTl.iX + orientation*rect.Width()/2;
       
  1072         TPoint titleTL( newLeft, titleRect.iTl.iY );
       
  1073         titleRect.SetRect( titleTL, titleRect.Size() );
       
  1074         }
       
  1075     AknLayoutUtils::LayoutLabel(iTitle, titleRect, textlayout.LayoutLine());
  1503 
  1076 
  1504     // Page text color
  1077     // Page text color
  1505     TAknLayoutText textLayout;
  1078     TAknLayoutText textLayout;
  1506     textLayout.LayoutText(parentRect, AknLayoutScalable_Avkon::graphic2_pages_pane_t1(pageVariate));
  1079     textLayout.LayoutText( titleRect, textlayout );
  1507     TRect textRect = textLayout.TextRect();
       
  1508     TRgb color = textLayout.Color();
  1080     TRgb color = textLayout.Color();
  1509     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  1081     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  1510     if (skin)
  1082     if (skin)
  1511         {
  1083         {
  1512         (void)AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
  1084         (void)AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
  1520     TRAP_IGNORE(UpdatePageTitleL());
  1092     TRAP_IGNORE(UpdatePageTitleL());
  1521     }
  1093     }
  1522 
  1094 
  1523 void CAknSctPageNavi::UpdatePageTitleL() const
  1095 void CAknSctPageNavi::UpdatePageTitleL() const
  1524     {
  1096     {
       
  1097     TInt pages = iCharMap->PageCount();
       
  1098     if ( pages < 2 )
       
  1099         {
       
  1100         iTitle->MakeVisible( EFalse );
       
  1101         return;
       
  1102         }
  1525     CArrayFix<TInt>* numbers = new(ELeave)CArrayFixFlat<TInt>(2);
  1103     CArrayFix<TInt>* numbers = new(ELeave)CArrayFixFlat<TInt>(2);
  1526     CleanupStack::PushL(numbers);
  1104     CleanupStack::PushL( numbers );
  1527     numbers->AppendL(iCharMap->CurrentPage());
  1105     numbers->AppendL( iCharMap->CurrentPage() );
  1528     numbers->AppendL(iCharMap->PageCount());
  1106     numbers->AppendL( pages );
  1529     HBufC* page =
  1107     HBufC* page =
  1530         StringLoader::LoadL(
  1108         StringLoader::LoadL(
  1531             R_AVKON_SPECIAL_CHARACTERS_PAGE_INDICATOR, *numbers, iEikonEnv);
  1109             R_AVKON_SPECIAL_CHARACTERS_PAGE_INDICATOR, *numbers, iEikonEnv);
  1532     CleanupStack::PopAndDestroy(); // numbers
  1110     CleanupStack::PopAndDestroy(); // numbers
  1533     iTitle->SetTextL(page->Des());
  1111     iTitle->SetTextL(page->Des());
  1540     return this;
  1118     return this;
  1541     }
  1119     }
  1542 
  1120 
  1543 TBool CAknSctPageNavi::EnterControl(TInt aX, TInt /*aY*/)
  1121 TBool CAknSctPageNavi::EnterControl(TInt aX, TInt /*aY*/)
  1544     {
  1122     {
       
  1123 	// Note, the button index is fixed on spite of mirrored case
  1545     if (IsVisible())
  1124     if (IsVisible())
  1546         {
  1125         {
  1547         if ((aX >= 0) && (aX < iButtonArray.Count()))
  1126         if ((aX >= 0) && (aX < iButtonArray.Count()))
  1548             {
  1127             {
  1549             CAknSctNaviButton* buttonObj;
  1128             CAknSctNaviButton* buttonObj;
  1550             buttonObj = iButtonArray[iButtonIndex];
  1129             buttonObj = iButtonArray[iButtonIndex];
  1551             buttonObj->SetFocused(EFalse);
  1130             buttonObj->SetFocused(EFalse);
  1552             TInt index = aX;
  1131             TInt index = aX;
  1553             if (AknLayoutUtils::LayoutMirrored()) // reverse.
       
  1554                 {
       
  1555                 index = iButtonArray.Count() - 1 - aX;
       
  1556                 }
       
  1557             buttonObj = iButtonArray[index];
  1132             buttonObj = iButtonArray[index];
  1558             if (buttonObj->IsEnabled())
  1133             if (buttonObj->IsEnabled())
  1559                 {
  1134                 {
  1560                 iButtonIndex = index;
  1135                 iButtonIndex = index;
  1561                 iExtension->iFocusHandler = this;
  1136                 iExtension->iFocusHandler = this;
  1565             }
  1140             }
  1566         }
  1141         }
  1567     return EFalse;
  1142     return EFalse;
  1568     }
  1143     }
  1569 
  1144 
  1570 void CAknSctPageNavi::MoveFocus(TInt aX, TInt /*aY*/)
  1145 void CAknSctPageNavi::MoveFocus(TInt aX, TInt aY )
  1571     {
  1146     {
  1572     TInt delta = aX;
  1147     (void)aX;
  1573     TInt buttonIndex = iButtonIndex + delta;
  1148     (void)aY;
  1574     for (TInt i = 0; i < iButtonArray.Count(); i++)
  1149     }
  1575         {
  1150 
  1576         if (buttonIndex > iButtonArray.Count() - 1) // Next control.
  1151 void CAknSctPageNavi::MoveFocus(TBool aInternalMove, TInt aX, TInt aY )
  1577             {
  1152     {
  1578             if (!AknLayoutUtils::LayoutMirrored())
  1153     if ( aInternalMove )
  1579                 {
  1154     	{
  1580                 if (!Layout_Meta_Data::IsLandscapeOrientation())
  1155         EnterControl( aX, 0 );
       
  1156     	}
       
  1157     else
       
  1158     	{
       
  1159         if (iExtension->EnterControl( aX, aY ) )
       
  1160             {
       
  1161             LeaveControl();
       
  1162             }
       
  1163     	}
       
  1164     }
       
  1165 
       
  1166 TBool CAknSctPageNavi::LeaveControl()
       
  1167     {
       
  1168     for (TInt i = 0; i < iButtonArray.Count(); i++ )
       
  1169         {
       
  1170         iButtonArray[i]->SetFocused(EFalse);
       
  1171         }
       
  1172     return ETrue;
       
  1173     }
       
  1174 
       
  1175 TBool CAknSctPageNavi::ExitWithKey(TInt /*aKeycode*/)
       
  1176     {
       
  1177     return EFalse;
       
  1178     }
       
  1179 
       
  1180 
       
  1181 void CAknSctPageNavi::TableExitL()
       
  1182     {
       
  1183     if(!iIdle)
       
  1184         {
       
  1185         iIdle = CIdle::NewL(CActive::EPriorityStandard);
       
  1186         }
       
  1187 
       
  1188     iIdle->Cancel();
       
  1189     iIdle->Start(TCallBack(TableExitCallBackL, this));
       
  1190     }
       
  1191 
       
  1192 TInt CAknSctPageNavi::TableExitCallBackL(TAny* aThis)
       
  1193     {
       
  1194     ((CAknSctPageNavi*)aThis)->DoTableExitL();
       
  1195     return KErrNone;
       
  1196     }
       
  1197 
       
  1198 void CAknSctPageNavi::DoTableExitL()
       
  1199     {
       
  1200     iCharMap->SetStatusChanged(EAknCharSelectedTableExitButton);
       
  1201     }
       
  1202 
       
  1203 void CAknSctPageNavi::NextTableL()
       
  1204     {
       
  1205     if(!iIdle)
       
  1206         {
       
  1207         iIdle = CIdle::NewL(CActive::EPriorityStandard);
       
  1208         }
       
  1209 
       
  1210     iIdle->Cancel();
       
  1211     iIdle->Start(TCallBack(NextTableCallBackL, this));
       
  1212     }
       
  1213 
       
  1214 TInt CAknSctPageNavi::NextTableCallBackL(TAny* aThis)
       
  1215     {
       
  1216     ((CAknSctPageNavi*)aThis)->DoNextTableL();
       
  1217     return KErrNone;
       
  1218     }
       
  1219 
       
  1220 void CAknSctPageNavi::DoNextTableL()
       
  1221     {
       
  1222     iCharMap->SetStatusChanged(EAknCharSelectedNextTableButton);
       
  1223     }
       
  1224 
       
  1225 void CAknSctPageNavi::UpdateNextTableButtonL()
       
  1226     {
       
  1227     
       
  1228     TBool isFocused = EFalse;
       
  1229     
       
  1230     // table switch buttons stay in one place.
       
  1231     for(TInt index(3); index<iButtonArray.Count(); index++)
       
  1232         {
       
  1233         CAknSctNaviButton* buttonObj = iButtonArray[index];
       
  1234         if(buttonObj->IsEnabled())
       
  1235             {
       
  1236             isFocused = buttonObj->IsFocused();
       
  1237             }
       
  1238         }
       
  1239     
       
  1240     // fresh focused button
       
  1241     for (TInt index(1); index<iButtonArray.Count(); index++)
       
  1242         {
       
  1243         CAknSctNaviButton* buttonObj = iButtonArray[index];
       
  1244         if ( index == EAknSctPageNaviPrevPage 
       
  1245                || index == EAknSctPageNaviNextPage )
       
  1246         	{
       
  1247             // No need to display Prev/Next
       
  1248             if ( iCharMap->PageCount() < 2 )
       
  1249                 {
       
  1250                 buttonObj->SetEnabled(EFalse);
       
  1251                 }
       
  1252             continue;
       
  1253         	}
       
  1254         if (iCharMap->TableCount() > 1)
       
  1255             {
       
  1256             switch (iCharMap->NextTableCase())
       
  1257                 {
       
  1258                 case EAknCharMapTableSpecialChar:
  1581                     {
  1259                     {
  1582                     // First table button.
  1260                     TBool isShown = EFalse;
  1583                     if (iExtension->iTableNavi &&
  1261                     if(iExtension->IsShowingEmotion())
  1584                         iExtension->iTableNavi->EnterControl(0,0))
       
  1585                         {
  1262                         {
  1586                         LeaveControl();
  1263                         isShown = (buttonObj->iButtonId==EAknSctTableNaviSpecialChar);
  1587                         break;
  1264                         }
       
  1265                     else
       
  1266                         {
       
  1267                         isShown = (buttonObj->iButtonId==EAknSctTableNaviEmotion);
       
  1268                         }
       
  1269                     buttonObj->SetEnabled(isShown);
       
  1270                     buttonObj->SetFocused(isShown && isFocused);
       
  1271                     if(isShown && isFocused)
       
  1272                         {
       
  1273                         iButtonIndex = index;
  1588                         }
  1274                         }
  1589                     }
  1275                     }
  1590                 else
  1276                     break;
  1591                     {
  1277 
  1592                     // First radio button.
  1278                 default:
  1593                     if (iExtension->iRadioButton &&
  1279                     buttonObj->SetEnabled(EFalse);
  1594                         iExtension->iRadioButton->EnterControl(0,0))
  1280                     break;
  1595                         {
  1281                 }
  1596                         LeaveControl();
  1282             }
  1597                         break;
  1283         else
  1598                         }
  1284             {
  1599                     // Grid start.
  1285             buttonObj->SetEnabled(EFalse);
  1600                     TInt yPos = iCharMap->ColMin(0);
  1286             }
  1601                     if (iExtension->EnterControl(iCharMap->RowMin(yPos),yPos))
  1287         }
  1602                         {
  1288     }
  1603                         LeaveControl();
  1289 
  1604                         break;
  1290 TInt CAknSctPageNavi::LastButton() const
  1605                         }
  1291     {
  1606                     }
  1292     TBool emotionEnable = iExtension->IsEmotionEnabled();
  1607                 }
  1293     if ( emotionEnable )
  1608             else
  1294     	{
  1609                 {
  1295         return iExtension->IsShowingEmotion()?EAknSctTableNaviSpecialChar:EAknSctTableNaviEmotion;
  1610                 if (!Layout_Meta_Data::IsLandscapeOrientation())
  1296     	}
  1611                     {
  1297     else if ( iCharMap->PageCount() < 2 && !emotionEnable )
  1612                     // Grid end.
  1298         {
  1613                     TInt yPos = iCharMap->ColMax(0);
  1299         // Only one page, must have no SC/Emotion also, left Exit only.
  1614                     if (iExtension->EnterControl(iCharMap->RowMax(yPos),yPos))
  1300         return EAknSctTableNaviExit;
  1615                         {
  1301         }
  1616                         LeaveControl();
  1302     else
  1617                         break;
  1303     	{
  1618                         }
  1304         // emotion doesn't support, no SC/Emotion icon then
  1619                     }
  1305         TBool mirrored = AknLayoutUtils::LayoutMirrored();
  1620                 else
  1306         return mirrored ? EAknSctPageNaviPrevPage : EAknSctPageNaviNextPage;
  1621                     {
  1307     	}
  1622                     // Last table button.
       
  1623                     TInt xPos = iCharMap->TableCount() - 1;
       
  1624                     if (iExtension->iTableNavi &&
       
  1625                         iExtension->iTableNavi->EnterControl(xPos,0))
       
  1626                         {
       
  1627                         LeaveControl();
       
  1628                         break;
       
  1629                         }
       
  1630                     }
       
  1631                 }
       
  1632             break;
       
  1633             }
       
  1634         else if (buttonIndex < 0) // Prev control
       
  1635             {
       
  1636             if (!AknLayoutUtils::LayoutMirrored())
       
  1637                 {
       
  1638                 if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1639                     {
       
  1640                     // Grid end.
       
  1641                     TInt yPos = iCharMap->ColMax(0);
       
  1642                     if (iExtension->EnterControl(iCharMap->RowMax(yPos),yPos))
       
  1643                         {
       
  1644                         LeaveControl();
       
  1645                         break;
       
  1646                         }
       
  1647                     }
       
  1648                 else
       
  1649                     {
       
  1650                     // Last table button.
       
  1651                     if (iExtension->iTableNavi && 
       
  1652                         iExtension->iTableNavi->EnterControl(iCharMap->TableCount()-1,0))
       
  1653                         {
       
  1654                         LeaveControl();
       
  1655                         break;
       
  1656                         }
       
  1657                     }
       
  1658                 }
       
  1659             else
       
  1660                 {
       
  1661                 if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  1662                     {
       
  1663                     // First table button.
       
  1664                     if (iExtension->iTableNavi &&
       
  1665                         iExtension->iTableNavi->EnterControl(0,0))
       
  1666                         {
       
  1667                         LeaveControl();
       
  1668                         break;
       
  1669                         }
       
  1670                     }
       
  1671                 else
       
  1672                     {
       
  1673                     // Grid start.
       
  1674                     TInt yPos = iCharMap->ColMin(0);
       
  1675                     if (iExtension->EnterControl(iCharMap->RowMin(yPos),yPos))
       
  1676                         {
       
  1677                         LeaveControl();
       
  1678                         break;
       
  1679                         }
       
  1680                     }
       
  1681                 }
       
  1682             }
       
  1683 
       
  1684         if (iButtonArray[buttonIndex]->IsEnabled()) // This control
       
  1685             {
       
  1686             CAknSctNaviButton* buttonObj;
       
  1687             buttonObj = iButtonArray[iButtonIndex];
       
  1688             buttonObj->SetFocused(EFalse);
       
  1689             iButtonIndex = buttonIndex;
       
  1690             buttonObj = iButtonArray[iButtonIndex];
       
  1691             buttonObj->SetFocused(ETrue);
       
  1692             break;
       
  1693             }
       
  1694         buttonIndex += (delta < 0) ? -1 : 1;
       
  1695         }
       
  1696     }
       
  1697 
       
  1698 TBool CAknSctPageNavi::LeaveControl()
       
  1699     {
       
  1700     for (TInt i = 0; i < iButtonArray.Count(); i++ )
       
  1701         {
       
  1702         iButtonArray[i]->SetFocused(EFalse);
       
  1703         }
       
  1704     return ETrue;
       
  1705     }
       
  1706 
       
  1707 TBool CAknSctPageNavi::ExitWithKey(TInt /*aKeycode*/)
       
  1708     {
       
  1709     return EFalse;
       
  1710     }
  1308     }
  1711 
  1309 
  1712 // ----------------------------------------------------------------------------
  1310 // ----------------------------------------------------------------------------
  1713 // Category button class implementation
  1311 // Category button class implementation
  1714 // ----------------------------------------------------------------------------
  1312 // ----------------------------------------------------------------------------
  1756     iButtonControl->DrawDeferred();
  1354     iButtonControl->DrawDeferred();
  1757     }
  1355     }
  1758 
  1356 
  1759 
  1357 
  1760 // ----------------------------------------------------------------------------
  1358 // ----------------------------------------------------------------------------
  1761 // Radio button class implementation
       
  1762 // ----------------------------------------------------------------------------
       
  1763 //
       
  1764 CAknSctRadioButton::CAknSctRadioButton()
       
  1765     {
       
  1766     }
       
  1767 
       
  1768 CAknSctRadioButton::CAknSctRadioButton(
       
  1769     CAknCharMap* aCharMap,
       
  1770     CAknCharMapExtension* aExtension)
       
  1771     :iExtension(aExtension),
       
  1772     iCharMap(aCharMap)
       
  1773     {
       
  1774     }
       
  1775 
       
  1776 CAknSctRadioButton::~CAknSctRadioButton()
       
  1777     {
       
  1778     iButtonArray.ResetAndDestroy();
       
  1779     iButtonArray.Close();
       
  1780     }
       
  1781 
       
  1782 TInt CAknSctRadioButton::CountComponentControls() const
       
  1783     {
       
  1784     return iButtonArray.Count();
       
  1785     }
       
  1786 
       
  1787 CCoeControl* CAknSctRadioButton::ComponentControl( TInt aIndex ) const
       
  1788     {
       
  1789     if (aIndex < iButtonArray.Count())
       
  1790         {
       
  1791         return iButtonArray[aIndex]->iButtonControl;
       
  1792         }
       
  1793     return NULL;
       
  1794     }
       
  1795 
       
  1796 TKeyResponse CAknSctRadioButton::OfferKeyEventL(
       
  1797     const TKeyEvent& aKeyEvent,
       
  1798     TEventCode /*aModifiers*/)
       
  1799     {
       
  1800     TKeyResponse responce = EKeyWasNotConsumed;
       
  1801     TUint code=aKeyEvent.iCode;
       
  1802     switch (code)
       
  1803         {
       
  1804         case EKeyEnter:
       
  1805         case EKeyOK:
       
  1806             {
       
  1807             if (AknLayoutUtils::PenEnabled())
       
  1808                 {
       
  1809                 // Grid.
       
  1810                 TInt yPos = iCharMap->ColMin(0);
       
  1811                 TInt xPos = iCharMap->RowMin(yPos);
       
  1812                 if (iExtension->EnterControl(xPos,yPos))
       
  1813                     {
       
  1814                     CAknButton* buttonCtrlObj;
       
  1815                     TInt currentIndex;
       
  1816                     TInt newIndex;
       
  1817                     for (TInt index=0; index < iButtonArray.Count(); index++)
       
  1818                         {
       
  1819                         buttonCtrlObj = iButtonArray[index]->iButtonControl;
       
  1820                         currentIndex = buttonCtrlObj->StateIndex();
       
  1821                         if (index == iButtonIndex)
       
  1822                             {
       
  1823                             newIndex = KAknSctRadioOn;
       
  1824                             }
       
  1825                         else
       
  1826                             {
       
  1827                             newIndex = KAknSctRadioOff;
       
  1828                             }
       
  1829                         if (currentIndex != newIndex)
       
  1830                             {
       
  1831                             buttonCtrlObj->SetCurrentState(newIndex, ETrue);
       
  1832                             if (newIndex == KAknSctRadioOn)
       
  1833                                 {
       
  1834                                 iExtension->iCurrentCategory =
       
  1835                                     iButtonArray[index]->iButtonId;
       
  1836                                 iCharMap->SetStatusChanged(EAknCharChangedCategory);
       
  1837                                 }
       
  1838                             }
       
  1839                         }
       
  1840                     LeaveControl();
       
  1841                     }
       
  1842                 }
       
  1843             responce = EKeyWasConsumed;
       
  1844             }
       
  1845             break;
       
  1846         case EKeyLeftArrow:
       
  1847         case '4':
       
  1848             {
       
  1849             responce = EKeyWasConsumed;
       
  1850             if (AknLayoutUtils::PenEnabled())
       
  1851                 {
       
  1852                 TInt yPos = iButtonIndex - 1;
       
  1853                 if (iCharMap->RowMax(yPos) < 0)
       
  1854                     {
       
  1855                     if (Layout_Meta_Data::IsLandscapeOrientation())
       
  1856                         {
       
  1857                         if (iExtension->iRadioButton)
       
  1858                             {
       
  1859                             // Right page button.
       
  1860                             if (iExtension->iPageNavi &&
       
  1861                                 iExtension->iPageNavi->EnterControl(1,0))
       
  1862                                 {
       
  1863                                 LeaveControl();
       
  1864                                 break;
       
  1865                                 }
       
  1866                             }
       
  1867                         }
       
  1868                     // Next button up.
       
  1869                     MoveFocus(0,-1);
       
  1870                     break;
       
  1871                     }
       
  1872                 else
       
  1873                     {
       
  1874                     //Previous row end.
       
  1875                     TInt xPos = iCharMap->RowMax(yPos);
       
  1876                     if (iExtension->EnterControl(xPos,yPos))
       
  1877                         {
       
  1878                         LeaveControl();
       
  1879                         break;
       
  1880                         }
       
  1881                     }
       
  1882                 break;
       
  1883                 }
       
  1884             // Move by grid.
       
  1885             iCharMap->TakeFocus();
       
  1886             TInt xPos = iCharMap->CursorPos().iX;
       
  1887             TInt yPos = iCharMap->CursorPos().iY;
       
  1888             if (xPos == 0)
       
  1889                 {
       
  1890                 iCharMap->MoveFocus(-1,0);
       
  1891                 }
       
  1892             iCharMap->ShowFocus();
       
  1893             }
       
  1894             break;
       
  1895         case EKeyRightArrow:
       
  1896         case '6':
       
  1897             {
       
  1898             responce = EKeyWasConsumed;
       
  1899             if (AknLayoutUtils::PenEnabled())
       
  1900                 {
       
  1901                 TInt yPos = iButtonIndex;
       
  1902                 if (iCharMap->RowMax(yPos) < 0)
       
  1903                     {
       
  1904                     // Next button down.
       
  1905                     MoveFocus(0,1);
       
  1906                     break;
       
  1907                     }
       
  1908                 else
       
  1909                     {
       
  1910                     // 1st cell in the row.
       
  1911                     if (iExtension->EnterControl(0,yPos))
       
  1912                         {
       
  1913                         LeaveControl();
       
  1914                         break;
       
  1915                         }
       
  1916                     }
       
  1917                 break;
       
  1918                 }
       
  1919             // Move by grid.
       
  1920             iCharMap->TakeFocus();
       
  1921             TInt xPos = iCharMap->CursorPos().iX;
       
  1922             TInt yPos = iCharMap->CursorPos().iY;
       
  1923             if (xPos == iCharMap->RowMax(yPos))
       
  1924                 {
       
  1925                 iCharMap->MoveFocus(1,0);
       
  1926                 }
       
  1927             iCharMap->ShowFocus();
       
  1928             }
       
  1929             break;
       
  1930         case EKeyDownArrow:
       
  1931         case '8':
       
  1932             {
       
  1933             MoveFocus(0, 1);
       
  1934             responce = EKeyWasConsumed;
       
  1935             }
       
  1936             break;
       
  1937         case EKeyUpArrow:
       
  1938         case '2':
       
  1939             {
       
  1940             MoveFocus(0,-1);
       
  1941             responce = EKeyWasConsumed;
       
  1942             }
       
  1943             break;
       
  1944         default:
       
  1945             break;
       
  1946         }
       
  1947     return responce;
       
  1948     }
       
  1949 
       
  1950 void CAknSctRadioButton::ConstructFromResourceL(TResourceReader& aReader)
       
  1951     {
       
  1952     TInt counts = aReader.ReadInt16();
       
  1953     TResourceReader reader;
       
  1954     TInt categorybutton_id;
       
  1955     TInt sctcase_id;
       
  1956     TInt resId;
       
  1957     CAknSctCategoryButton* buttonObj;
       
  1958     TBool allowCreation;
       
  1959 
       
  1960     for (TInt index=0; index < counts; index++)
       
  1961         {
       
  1962         allowCreation = EFalse;
       
  1963         // button id
       
  1964         categorybutton_id = aReader.ReadInt16();
       
  1965         sctcase_id = aReader.ReadInt16();
       
  1966         switch (categorybutton_id)
       
  1967             {
       
  1968             case EAknSCTCategoryButtonHalfCase:
       
  1969             case EAknSCTCategoryButtonFullCase:
       
  1970                 allowCreation = ETrue;
       
  1971                 break;
       
  1972             case EAknSCTCategoryButtonPicto:
       
  1973                 if (iExtension->iPictographsBuffer)
       
  1974                     {
       
  1975                     allowCreation = ETrue;
       
  1976                     }
       
  1977                 break;
       
  1978             case EAknSCTCategoryButtonPicto1:
       
  1979             case EAknSCTCategoryButtonPicto2:
       
  1980                 if (iExtension->iPictographsBuffer &&
       
  1981                     iExtension->iPictographsBufferGrouping)
       
  1982                     {
       
  1983                     allowCreation = ETrue;
       
  1984                     }
       
  1985                 break;
       
  1986             default:
       
  1987                 break;
       
  1988             }
       
  1989 
       
  1990         if (allowCreation)
       
  1991             {
       
  1992             // read the button resource
       
  1993             resId = aReader.ReadInt32();
       
  1994             iCoeEnv->CreateResourceReaderLC( reader, resId );
       
  1995             // create Category button object
       
  1996             buttonObj = CAknSctCategoryButton::NewL(
       
  1997                 *this, reader, categorybutton_id, sctcase_id);
       
  1998             // Append button
       
  1999             iButtonArray.Append(buttonObj);
       
  2000             CleanupStack::PopAndDestroy(); // reader
       
  2001             }
       
  2002         else
       
  2003             {
       
  2004             // Skip data
       
  2005             resId = aReader.ReadInt32();
       
  2006             }
       
  2007         }
       
  2008 
       
  2009     }
       
  2010 
       
  2011 void CAknSctRadioButton::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  2012     {
       
  2013     TRect rect(Rect());
       
  2014     if (AknLayoutUtils::PenEnabled() && rect.Contains(aPointerEvent.iPosition))
       
  2015         {
       
  2016         if (aPointerEvent.iType == TPointerEvent::EButton1Down)
       
  2017             {
       
  2018             CAknButton* buttonCtrlObj;
       
  2019             TRect rectButton;
       
  2020             TInt currentIndex;
       
  2021             TInt newIndex;
       
  2022             for (TInt index=0; index < iButtonArray.Count(); index++)
       
  2023                 {
       
  2024                 buttonCtrlObj = iButtonArray[index]->iButtonControl;
       
  2025                 rectButton = buttonCtrlObj->Rect();
       
  2026                 currentIndex = buttonCtrlObj->StateIndex();
       
  2027 
       
  2028                 if (rectButton.Contains(aPointerEvent.iPosition))
       
  2029                     {
       
  2030                     newIndex = KAknSctRadioOn;
       
  2031                     }
       
  2032                 else
       
  2033                     {
       
  2034                     newIndex = KAknSctRadioOff;
       
  2035                     }
       
  2036                 if (currentIndex != newIndex)
       
  2037                     {
       
  2038                     buttonCtrlObj->SetCurrentState(newIndex, ETrue);
       
  2039                     if (newIndex == KAknSctRadioOn)
       
  2040                         {
       
  2041                         if (AknLayoutUtils::PenEnabled())
       
  2042                             {
       
  2043                             iButtonIndex = index;
       
  2044                             }
       
  2045                         iExtension->iCurrentCategory =
       
  2046                             iButtonArray[index]->iButtonId;
       
  2047                         iCharMap->SetStatusChanged(EAknCharChangedCategory);
       
  2048                         }
       
  2049                     }
       
  2050                 }
       
  2051             }
       
  2052         else if (aPointerEvent.iType == TPointerEvent::EDrag)
       
  2053             {
       
  2054             }
       
  2055         else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
       
  2056             {
       
  2057             }
       
  2058         }
       
  2059     else
       
  2060         {
       
  2061         CCoeControl::HandlePointerEventL(aPointerEvent);
       
  2062         }
       
  2063     }
       
  2064 
       
  2065 TSize CAknSctRadioButton::MinimumSize()
       
  2066     {
       
  2067     TAknLayoutRect oneButtonLayRect;
       
  2068     if (!AknLayoutUtils::PenEnabled())
       
  2069         {
       
  2070         TAknLayoutScalableParameterLimits charMapDialogVariety =
       
  2071             AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
       
  2072 
       
  2073         // Main pane without softkeys
       
  2074         TRect mainPaneRect;
       
  2075         if(!AknLayoutUtils::LayoutMetricsRect(
       
  2076             AknLayoutUtils::EPopupParent, mainPaneRect))
       
  2077             {
       
  2078             mainPaneRect = iAvkonAppUi->ClientRect();
       
  2079             }
       
  2080 
       
  2081         // Calc the variety
       
  2082         TInt maxVariety = charMapDialogVariety.LastVariety();
       
  2083 
       
  2084         TAknLayoutRect popupGridLayRect;
       
  2085         popupGridLayRect.LayoutRect(mainPaneRect,
       
  2086             AknLayoutScalable_Avkon::popup_grid_graphic_window(maxVariety));
       
  2087 
       
  2088         // Calculate the size relatively
       
  2089         TRect relativeDialog(TPoint(0,0),popupGridLayRect.Rect().Size());
       
  2090 
       
  2091         // Get the layout of the actual character grid with scrollbar
       
  2092         TAknLayoutRect gridWithScrollLayRect;
       
  2093         gridWithScrollLayRect.LayoutRect(relativeDialog,
       
  2094             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
       
  2095 
       
  2096         TAknLayoutRect categoryButtonLayRect;
       
  2097         categoryButtonLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
       
  2098             AknLayoutScalable_Avkon::grid_sct_catagory_button_pane());
       
  2099 
       
  2100         oneButtonLayRect.LayoutRect(categoryButtonLayRect.Rect(),
       
  2101             AknLayoutScalable_Avkon::cell_sct_catagory_button_pane());
       
  2102         }
       
  2103     else
       
  2104         {
       
  2105         TAknLayoutRect popupGridLayRect;
       
  2106         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
  2107             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
       
  2108 
       
  2109         TAknLayoutRect oneButtonLayRect;
       
  2110         TAknLayoutRect categoryButtonLayRect;
       
  2111         if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  2112             {
       
  2113             oneButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2114                 AknLayoutScalable_Avkon::grid_graphic2_control_pane(4));
       
  2115 
       
  2116             categoryButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2117                 AknLayoutScalable_Avkon::grid_graphic2_catg_pane(0));
       
  2118             }
       
  2119         else
       
  2120             {
       
  2121             oneButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2122                 AknLayoutScalable_Avkon::grid_graphic2_control_pane(5));
       
  2123 
       
  2124             categoryButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2125                 AknLayoutScalable_Avkon::grid_graphic2_catg_pane(1));
       
  2126 
       
  2127             }
       
  2128         }
       
  2129 
       
  2130     TSize size(oneButtonLayRect.Rect().Width(),
       
  2131         oneButtonLayRect.Rect().Height() * iButtonArray.Count());
       
  2132     return size;
       
  2133     }
       
  2134 
       
  2135 void CAknSctRadioButton::SizeChanged()
       
  2136     {
       
  2137     TRect base;
       
  2138     if (!AknLayoutUtils::PenEnabled())
       
  2139         {
       
  2140         TAknLayoutScalableParameterLimits charMapDialogVariety =
       
  2141             AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
       
  2142 
       
  2143         // Main pane without softkeys
       
  2144         TRect mainPaneRect;
       
  2145         if(!AknLayoutUtils::LayoutMetricsRect(
       
  2146             AknLayoutUtils::EPopupParent, mainPaneRect))
       
  2147             {
       
  2148             mainPaneRect = iAvkonAppUi->ClientRect();
       
  2149             }
       
  2150 
       
  2151         // Calc the variety
       
  2152         TInt maxVariety = charMapDialogVariety.LastVariety();
       
  2153 
       
  2154         TAknLayoutRect popupGridLayRect;
       
  2155         popupGridLayRect.LayoutRect(mainPaneRect,
       
  2156             AknLayoutScalable_Avkon::popup_grid_graphic_window(maxVariety));
       
  2157 
       
  2158         // Calculate the size relatively
       
  2159         TRect relativeDialog(TPoint(0,0), popupGridLayRect.Rect().Size());
       
  2160 
       
  2161         // Get the layout of the actual character grid with scrollbar
       
  2162         TAknLayoutRect gridWithScrollLayRect;
       
  2163         gridWithScrollLayRect.LayoutRect(relativeDialog,
       
  2164             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
       
  2165 
       
  2166         TAknLayoutRect categoryButtonLayRect;
       
  2167         categoryButtonLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
       
  2168             AknLayoutScalable_Avkon::grid_sct_catagory_button_pane());
       
  2169 
       
  2170         TAknLayoutRect oneButtonLayRect;
       
  2171         oneButtonLayRect.LayoutRect(categoryButtonLayRect.Rect(),
       
  2172             AknLayoutScalable_Avkon::cell_sct_catagory_button_pane());
       
  2173 
       
  2174         base = oneButtonLayRect.Rect();
       
  2175         }
       
  2176     else
       
  2177         {
       
  2178         TAknLayoutRect popupGridLayRect;
       
  2179         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
  2180             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
       
  2181 
       
  2182         TAknLayoutRect oneButtonLayRect;
       
  2183         TAknLayoutRect categoryButtonLayRect;
       
  2184         if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  2185             {
       
  2186             oneButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2187                 AknLayoutScalable_Avkon::grid_graphic2_control_pane(4));
       
  2188 
       
  2189             categoryButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2190                 AknLayoutScalable_Avkon::grid_graphic2_catg_pane(0));
       
  2191             }
       
  2192         else
       
  2193             {
       
  2194             oneButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2195                 AknLayoutScalable_Avkon::grid_graphic2_control_pane(5));
       
  2196 
       
  2197             categoryButtonLayRect.LayoutRect(popupGridLayRect.Rect(),
       
  2198                 AknLayoutScalable_Avkon::grid_graphic2_catg_pane(1));
       
  2199 
       
  2200             }
       
  2201         base.iTl = categoryButtonLayRect.Rect().iTl;
       
  2202         base.SetSize(oneButtonLayRect.Rect().Size());
       
  2203         }
       
  2204 
       
  2205     if (iButtonArray.Count() > 0)
       
  2206         {
       
  2207         CAknButton* buttonCtrlObj;
       
  2208 
       
  2209         TMargins8 margins;
       
  2210         margins.iTop = 1;
       
  2211         margins.iBottom = 0;
       
  2212         margins.iLeft = 0;
       
  2213         margins.iRight = 0;
       
  2214 
       
  2215         // Change the size of buttons
       
  2216         for (TInt index=0; index < iButtonArray.Count(); index++)
       
  2217             {
       
  2218             buttonCtrlObj = iButtonArray[index]->iButtonControl;
       
  2219             if (buttonCtrlObj)
       
  2220                 {
       
  2221                 if (AknLayoutUtils::PenEnabled())
       
  2222                     {
       
  2223                     buttonCtrlObj->SetHighlightRect(base);
       
  2224                     }
       
  2225                 buttonCtrlObj->SetRect( base );
       
  2226                 buttonCtrlObj->SetIconSize( base.Size() );
       
  2227                 buttonCtrlObj->SetMargins( margins );
       
  2228                 buttonCtrlObj->SetIconScaleMode(EAspectRatioPreserved);
       
  2229                 base.Move(TPoint(0, base.Size().iHeight));
       
  2230                 }
       
  2231             }
       
  2232         }
       
  2233     }
       
  2234 
       
  2235 void CAknSctRadioButton::Draw(const TRect& /*aRect*/) const
       
  2236     {
       
  2237     // no draw
       
  2238     }
       
  2239 
       
  2240 /**
       
  2241  * Returns ETrue if the aFlag bitfield in iFlags is set, EFalse if it
       
  2242  * is clear
       
  2243  */
       
  2244 inline TInt CAknSctRadioButton::Count() const
       
  2245     {
       
  2246     return iButtonArray.Count();
       
  2247     }
       
  2248 
       
  2249 void CAknSctRadioButton::SetCurrentCategory(TInt aCategory)
       
  2250     {
       
  2251     CAknSctCategoryButton* buttonObj;
       
  2252     TInt status;
       
  2253 
       
  2254     for (TInt index=0; index < iButtonArray.Count(); index++)
       
  2255         {
       
  2256         buttonObj = iButtonArray[index];
       
  2257         status = (buttonObj->iButtonId == aCategory)?
       
  2258                      KAknSctRadioOn : KAknSctRadioOff;
       
  2259         buttonObj->iButtonControl->SetCurrentState(status, ETrue);
       
  2260         }
       
  2261     }
       
  2262 
       
  2263 void CAknSctRadioButton::SetValidSctCase(TInt aSctCase)
       
  2264     {
       
  2265     CAknSctCategoryButton* buttonObj;
       
  2266 
       
  2267     for (TInt index=0; index < iButtonArray.Count(); index++)
       
  2268         {
       
  2269         buttonObj = iButtonArray[index];
       
  2270         if (buttonObj->iSctCaseId == aSctCase)
       
  2271             {
       
  2272             buttonObj->iValid = ETrue;
       
  2273             break;
       
  2274             }
       
  2275         // Here is the special case for Half-width/Lower/Upper
       
  2276         else if (buttonObj->iSctCaseId == EAknSCTHalfCase
       
  2277               && (aSctCase == EAknSCTLowerCase
       
  2278                  || aSctCase == EAknSCTUpperCase)
       
  2279                 )
       
  2280             {
       
  2281             buttonObj->iValid = ETrue;
       
  2282             break;
       
  2283             }
       
  2284         }
       
  2285     }
       
  2286 
       
  2287 void CAknSctRadioButton::RemoveInvalidButton()
       
  2288     {
       
  2289     CAknSctCategoryButton* buttonObj;
       
  2290 
       
  2291     for (TInt index=iButtonArray.Count()-1; index >= 0; index--)
       
  2292         {
       
  2293         buttonObj = iButtonArray[index];
       
  2294         if (!buttonObj->iValid)
       
  2295             {
       
  2296             if (buttonObj->iSctCaseId == EAknSCTHalfCase)
       
  2297                 {
       
  2298                 if (iButtonArray.Count() > 1)
       
  2299                     {
       
  2300                     delete buttonObj;
       
  2301                     iButtonArray.Remove(index);
       
  2302                     }
       
  2303                 }
       
  2304             else
       
  2305                 {
       
  2306                 delete buttonObj;
       
  2307                 iButtonArray.Remove(index);
       
  2308                 }
       
  2309             }
       
  2310         }
       
  2311     }
       
  2312 
       
  2313 CCoeControl* CAknSctRadioButton::FocusedControl()
       
  2314     {
       
  2315     return this;
       
  2316     }
       
  2317 
       
  2318 TBool CAknSctRadioButton::EnterControl(TInt /*aX*/, TInt aY)
       
  2319     {
       
  2320     if (IsVisible())
       
  2321         {
       
  2322         if ((aY >= 0) && (aY < Count()))
       
  2323             {
       
  2324             if (iExtension->iHasCategoryButtonUi)
       
  2325                 {
       
  2326                 iEntryIndex = aY;
       
  2327                 iExtension->iFocusHandler = this;
       
  2328                 if (AknLayoutUtils::PenEnabled())
       
  2329                     {
       
  2330                     iButtonIndex = aY;
       
  2331                     CAknSctCategoryButton* buttonObj =
       
  2332                         iButtonArray[iButtonIndex];
       
  2333                     buttonObj->SetFocused(ETrue);
       
  2334                     }
       
  2335                 return ETrue;
       
  2336                 }
       
  2337             }
       
  2338         }
       
  2339     return EFalse;
       
  2340     }
       
  2341 
       
  2342 void CAknSctRadioButton::MoveFocus(TInt /*aX*/, TInt aY)
       
  2343     {
       
  2344     CAknSctCategoryButton* buttonObj;
       
  2345     CAknButton* buttonCtrlObj;
       
  2346     TInt buttonIndex = iButtonIndex + aY;
       
  2347     if (buttonIndex > iButtonArray.Count() - 1)
       
  2348         {
       
  2349         if (!AknLayoutUtils::PenEnabled())
       
  2350             {
       
  2351              // First radio button.
       
  2352             buttonIndex = 0;
       
  2353             }
       
  2354         else
       
  2355             {
       
  2356             if (!Layout_Meta_Data::IsLandscapeOrientation())
       
  2357                 {
       
  2358                 // Left page button.
       
  2359                 if (iExtension->iPageNavi &&
       
  2360                     iExtension->iPageNavi->EnterControl(0,0))
       
  2361                     {
       
  2362                     LeaveControl();
       
  2363                     return;
       
  2364                     }
       
  2365                 }
       
  2366             else
       
  2367                 {
       
  2368                 // First table button.
       
  2369                 if (iExtension->iTableNavi &&
       
  2370                     iExtension->iTableNavi->EnterControl(0,0))
       
  2371                     {
       
  2372                     LeaveControl();
       
  2373                     return;
       
  2374                     }
       
  2375                 }
       
  2376             }
       
  2377         }
       
  2378     else if (buttonIndex < 0)
       
  2379         {
       
  2380          if (!AknLayoutUtils::PenEnabled())
       
  2381             {
       
  2382             // Last radio button.
       
  2383             buttonIndex = iButtonArray.Count() - 1;
       
  2384             }
       
  2385          else
       
  2386             {
       
  2387             // First table button.
       
  2388             if (iExtension->iTableNavi &&
       
  2389                 iExtension->iTableNavi->EnterControl(0,0))
       
  2390                 {
       
  2391                 LeaveControl();
       
  2392                 return;
       
  2393                 }
       
  2394             }
       
  2395         }
       
  2396 
       
  2397     if (!AknLayoutUtils::PenEnabled())
       
  2398         {
       
  2399         buttonObj = iButtonArray[iButtonIndex];
       
  2400         buttonCtrlObj = buttonObj->iButtonControl;
       
  2401         buttonCtrlObj->SetCurrentState(KAknSctRadioOff, ETrue);
       
  2402         iButtonIndex = buttonIndex;
       
  2403         buttonObj = iButtonArray[iButtonIndex];
       
  2404         buttonCtrlObj = buttonObj->iButtonControl;
       
  2405         buttonCtrlObj->SetCurrentState(KAknSctRadioOn, ETrue);
       
  2406         iExtension->iCurrentCategory =
       
  2407             iButtonArray[buttonIndex]->iButtonId;
       
  2408         iCharMap->SetStatusChanged(EAknCharChangedCategory);
       
  2409         }
       
  2410     else
       
  2411         {
       
  2412         buttonObj = iButtonArray[iButtonIndex];
       
  2413         buttonObj->SetFocused(EFalse);
       
  2414         iButtonIndex = buttonIndex;
       
  2415         buttonObj = iButtonArray[iButtonIndex];
       
  2416         buttonObj->SetFocused(ETrue);
       
  2417         }
       
  2418     }
       
  2419 
       
  2420 TBool CAknSctRadioButton::LeaveControl()
       
  2421     {
       
  2422     for (TInt i = 0; i < iButtonArray.Count(); i++ )
       
  2423         {
       
  2424         iButtonArray[i]->SetFocused(EFalse);
       
  2425         }
       
  2426     return ETrue;
       
  2427     }
       
  2428 
       
  2429 TBool CAknSctRadioButton::ExitWithKey(TInt /*aKeycode*/)
       
  2430     {
       
  2431     return EFalse;
       
  2432     }
       
  2433 
       
  2434 // ----------------------------------------------------------------------------
       
  2435 // Extension class implementation
  1359 // Extension class implementation
  2436 // ----------------------------------------------------------------------------
  1360 // ----------------------------------------------------------------------------
  2437 //
  1361 //
  2438 CAknCharMapExtension::CAknCharMapExtension() : iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() )
  1362 CAknCharMapExtension::CAknCharMapExtension() : iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() )
  2439     {
  1363     {
  2462     
  1386     
  2463     delete iCharsSmiley;
  1387     delete iCharsSmiley;
  2464     delete iCharsQwerty;
  1388     delete iCharsQwerty;
  2465     delete iBgContext;
  1389     delete iBgContext;
  2466 
  1390 
  2467     delete iRadioButton;
       
  2468     delete iTitleBuf;
  1391     delete iTitleBuf;
  2469 
  1392 
  2470     delete iPageNavi;
  1393     delete iPageNavi;
  2471     delete iTableNavi;
       
  2472     delete iCategoryTitle;
  1394     delete iCategoryTitle;
  2473     delete iCategoryEntry;
  1395     delete iCategoryEntry;
  2474     delete iEntryBuf;
  1396     delete iEntryBuf;
  2475     }
  1397     }
  2476 
  1398 
  2899 
  1821 
  2900     if(err)
  1822     if(err)
  2901         return;
  1823         return;
  2902 
  1824 
  2903     iExtension->iFlags = 0x00;
  1825     iExtension->iFlags = 0x00;
  2904 
       
  2905     // if feature language is Japanese
       
  2906     CAknEnv* env = CAknEnv::Static();
       
  2907     if (env)
       
  2908         {
       
  2909         if (env->IsFeatureLanguage(KFeatureIdJapanese))
       
  2910             {
       
  2911             iExtension->iJapaneseSctUi = ETrue;
       
  2912             iExtension->iHasCategoryButtonUi = ETrue;
       
  2913             }
       
  2914         }
       
  2915     iExtension->iFocusHandler = iExtension;
  1826     iExtension->iFocusHandler = iExtension;
  2916     iExtension->SetCharMapControl(this);
  1827     iExtension->SetCharMapControl(this);
  2917 	
  1828 	
  2918     if ( iExtension->iSingleClickEnabled )
  1829     if ( iExtension->iSingleClickEnabled )
  2919         {
  1830         {
  2960     iSpecialCharCases.Close();
  1871     iSpecialCharCases.Close();
  2961     iSpecialCharPages.Close();
  1872     iSpecialCharPages.Close();
  2962     iPictographCases.Close();
  1873     iPictographCases.Close();
  2963     iPictographPages.Close();
  1874     iPictographPages.Close();
  2964     MTouchFeedback* feedback = MTouchFeedback::Instance();
  1875     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1876     
  2965     if ( feedback != NULL )
  1877     if ( feedback != NULL )
  2966         {
  1878         {
  2967         feedback->RemoveFeedbackForControl( this );
  1879         feedback->RemoveFeedbackForControl( this );
  2968         }
  1880         }
  2969    }
  1881    }
  2975         {
  1887         {
  2976         if ( Layout_Meta_Data::IsLandscapeOrientation() )
  1888         if ( Layout_Meta_Data::IsLandscapeOrientation() )
  2977             {
  1889             {
  2978             specialCharItemLayout =
  1890             specialCharItemLayout =
  2979                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(1);
  1891                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(1);
  2980             }
       
  2981         else if (IsJapaneseSctUi())
       
  2982             {
       
  2983             specialCharItemLayout =
       
  2984                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(2);
       
  2985             }
  1892             }
  2986         else
  1893         else
  2987             {
  1894             {
  2988             specialCharItemLayout =
  1895             specialCharItemLayout =
  2989                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(0);
  1896                 AknLayoutScalable_Avkon::cell_graphic2_pane_t1(0);
  3004     iIsMirrored = AknLayoutUtils::LayoutMirrored();
  1911     iIsMirrored = AknLayoutUtils::LayoutMirrored();
  3005     iDrawnBefore = EFalse;
  1912     iDrawnBefore = EFalse;
  3006     CountMaxColumnsAndCellSizes();
  1913     CountMaxColumnsAndCellSizes();
  3007     SizeChanged();
  1914     SizeChanged();
  3008 
  1915 
  3009     // load Emotion icon resource, but not load images
  1916     // set smiley size
  3010     TSize iconSize(iGridItemWidth,iGridItemHeight);
  1917     TAknWindowComponentLayout cellGraphicsLayout;
  3011     iconSize.iWidth = iconSize.iWidth * 3 / 4;
  1918     if ( Layout_Meta_Data::IsLandscapeOrientation() )
  3012     iconSize.iHeight = iconSize.iHeight * 3 / 4;
  1919         {
  3013     Extension()->SetEmotionSize(iconSize);
  1920         cellGraphicsLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_g5(1);
       
  1921         }
       
  1922     else
       
  1923         {
       
  1924         cellGraphicsLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_g5(0);
       
  1925         }
       
  1926 
       
  1927     TAknLayoutRect cellGraphicsRect;
       
  1928     cellGraphicsRect.LayoutRect(TRect(TSize(iGridItemWidth,iGridItemHeight)), cellGraphicsLayout);
       
  1929     
       
  1930     Extension()->SetEmotionSize(cellGraphicsRect.Rect().Size());
  3014     }
  1931     }
  3015 
  1932 
  3016 
  1933 
  3017 EXPORT_C void CAknCharMap::ConstructFromResourceL(TResourceReader& aReader)
  1934 EXPORT_C void CAknCharMap::ConstructFromResourceL(TResourceReader& aReader)
  3018     {
  1935     {
  3072         }
  1989         }
  3073 
  1990 
  3074     // Alternate components.
  1991     // Alternate components.
  3075     if (AknLayoutUtils::PenEnabled())
  1992     if (AknLayoutUtils::PenEnabled())
  3076         {
  1993         {
  3077         if (iExtension->iHasCategoryButtonUi)
       
  3078             {
       
  3079             EnableCategoryInputFieldL();
       
  3080             EnableCategoryButtonsL();
       
  3081             }
       
  3082         EnableNavigationButtonsL();
  1994         EnableNavigationButtonsL();
  3083         }
       
  3084     else
       
  3085         {
       
  3086         if (iExtension->iHasCategoryButtonUi)
       
  3087             {
       
  3088             EnableCategoryButtonsL();
       
  3089             }
       
  3090         }
  1995         }
  3091 
  1996 
  3092     // Offscreen background.
  1997     // Offscreen background.
  3093     if (offscreen)
  1998     if (offscreen)
  3094         {
  1999         {
  3241         {
  2146         {
  3242         iCursorPos = TPoint(0, 1);
  2147         iCursorPos = TPoint(0, 1);
  3243         }
  2148         }
  3244 
  2149 
  3245     iExtension->iCurrentCategory = Category();
  2150     iExtension->iCurrentCategory = Category();
  3246     if (iExtension->iRadioButton)
       
  3247         {
       
  3248         iExtension->iRadioButton->SetCurrentCategory(iExtension->iCurrentCategory);
       
  3249         }
       
  3250 
  2151 
  3251     // Create and set the scb visible even though there is nothing to scroll
  2152     // Create and set the scb visible even though there is nothing to scroll
  3252     delete iSBFrame;
  2153     delete iSBFrame;
  3253     iSBFrame=NULL;
  2154     iSBFrame=NULL;
  3254 
  2155 
  3260         iSBFrame->VerticalScrollBar()->SetMopParent(iExtension);
  2161         iSBFrame->VerticalScrollBar()->SetMopParent(iExtension);
  3261         UpdateScrollIndicatorL();
  2162         UpdateScrollIndicatorL();
  3262         }
  2163         }
  3263     
  2164     
  3264     iExtension->LoadEmotionTumbnails(*iChars);
  2165     iExtension->LoadEmotionTumbnails(*iChars);
  3265 
       
  3266     CAknSctPageNavi* pageNavi = Extension()->iPageNavi;
       
  3267     if(pageNavi)
       
  3268         {
       
  3269         pageNavi->MakeVisible(PageCount()>1);
       
  3270         }
       
  3271     
  2166     
  3272     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  2167     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  3273     
  2168     
  3274     }
  2169     }
  3275 
  2170 
  3467     switch (code)
  2362     switch (code)
  3468         {
  2363         {
  3469         case EKeyLeftArrow:
  2364         case EKeyLeftArrow:
  3470         case '4':
  2365         case '4':
  3471             {
  2366             {
  3472             if (iExtension->iRadioButton && (iCursorPos.iX == 0)) // Radio button.
       
  3473                 {
       
  3474                 if (iExtension->iRadioButton->EnterControl(iCursorPos.iX,iCursorPos.iY))
       
  3475                     {
       
  3476                     LeaveControl();
       
  3477                     break;
       
  3478                     }
       
  3479                 }
       
  3480 
       
  3481             if (AknLayoutUtils::PenEnabled())
  2367             if (AknLayoutUtils::PenEnabled())
  3482                 {
  2368                 {
  3483                 if (!iIsMirrored)
  2369                 if (!iIsMirrored)
  3484                     {
  2370                     {
  3485                     if ((iCursorPos.iX == 0) && (iCursorPos.iY == ColMin(0)))
  2371                     if ((iCursorPos.iX == 0) && (iCursorPos.iY == ColMin(0)))
  3486                         {
  2372                         {
  3487                         if (!Layout_Meta_Data::IsLandscapeOrientation())
  2373                         // western, move left from first one in grid, focus pageNavi last button
       
  2374                         if ( iExtension->iPageNavi )
  3488                             {
  2375                             {
  3489                             // Last table button.
  2376                             TInt maxButt = iExtension->iPageNavi->LastButton();
  3490                             if (iExtension->iTableNavi &&
  2377                             if ( iExtension->iPageNavi->EnterControl( maxButt,0 ) )
  3491                                 iExtension->iTableNavi->EnterControl(TableCount() - 1,0))
  2378                             	{
  3492                                 {
       
  3493                                 LeaveControl();
  2379                                 LeaveControl();
  3494                                 break;
  2380                                 break;
  3495                                 }
  2381                             	}
  3496                             }
       
  3497                         else
       
  3498                             {
       
  3499                             // Right page button.
       
  3500                             if (iExtension->iPageNavi &&
       
  3501                                 iExtension->iPageNavi->EnterControl(1,0))
       
  3502                                 {
       
  3503                                 LeaveControl();
       
  3504                                 break;
       
  3505                                 }
       
  3506                             }
  2382                             }
  3507                         }
  2383                         }
  3508                     }
  2384                     }
  3509                 else
  2385                 else
  3510                     {
  2386                     {
  3511                     if (((iCursorPos.iY == ColMax(0)) && (iCursorPos.iX == RowMax(ColMax(0)))))
  2387                     if (((iCursorPos.iY == ColMax(0)) && (iCursorPos.iX == RowMax(ColMax(0)))))
  3512                         {
  2388                         {
  3513                         if (!Layout_Meta_Data::IsLandscapeOrientation())
  2389                         // mirrored, move left from last one in grid, focus pgNavi first button
       
  2390                         if (iExtension->iPageNavi &&
       
  2391                             iExtension->iPageNavi->EnterControl(0,0))
  3514                             {
  2392                             {
  3515                             // Left page button.
  2393                             LeaveControl();
  3516                             if (iExtension->iPageNavi &&
  2394                             break;
  3517                                 iExtension->iPageNavi->EnterControl(0,0))
       
  3518                                 {
       
  3519                                 LeaveControl();
       
  3520                                 break;
       
  3521                                 }
       
  3522                             }
       
  3523                         else
       
  3524                             {
       
  3525                             // First table button.
       
  3526                             if (iExtension->iTableNavi &&
       
  3527                                 iExtension->iTableNavi->EnterControl(0,0))
       
  3528                                 {
       
  3529                                 LeaveControl();
       
  3530                                 break;
       
  3531                                 }
       
  3532                             }
  2395                             }
  3533                         }
  2396                         }
  3534                     }
  2397                     }
  3535                 }
  2398                 }
  3536             MoveFocus(-1,0);
  2399             MoveFocus(-1,0);
  3537             break;
  2400             break;
  3538             }
  2401             }
  3539         case EKeyRightArrow:
  2402         case EKeyRightArrow:
  3540         case '6':
  2403         case '6':
  3541             {
  2404             {
  3542             if (iExtension->iRadioButton &&
       
  3543                 (iCursorPos.iX == RowMax(iCursorPos.iY)) &&
       
  3544                     (iCursorPos.iY <= (iExtension->iRadioButton->Count() - 2)))
       
  3545                 {
       
  3546                 // Radio button.
       
  3547                 if (iExtension->iRadioButton->EnterControl(iCursorPos.iX,iCursorPos.iY+1))
       
  3548                     {
       
  3549                     LeaveControl();
       
  3550                     break;
       
  3551                     }
       
  3552                 }
       
  3553             if (AknLayoutUtils::PenEnabled())
  2405             if (AknLayoutUtils::PenEnabled())
  3554                 {
  2406                 {
  3555                 if (!iIsMirrored)
  2407                 if (!iIsMirrored)
  3556                     {
  2408                     {
  3557                     if ((iCursorPos.iY == ColMax(0)) &&
  2409                     if ((iCursorPos.iY == ColMax(0)) &&
  3558                         (iCursorPos.iX == RowMax(ColMax(0))))
  2410                         (iCursorPos.iX == RowMax(ColMax(0))))
  3559                         {
  2411                         {
  3560                         if (!Layout_Meta_Data::IsLandscapeOrientation())
  2412                         // western, move right from last one in grid, focus pgNavi first button
       
  2413                         if (iExtension->iPageNavi &&
       
  2414                             iExtension->iPageNavi->EnterControl(0,0))
  3561                             {
  2415                             {
  3562                             // Left page button.
  2416                             LeaveControl();
  3563                             if (iExtension->iPageNavi &&
  2417                             break;
  3564                                 iExtension->iPageNavi->EnterControl(0,0))
       
  3565                                 {
       
  3566                                 LeaveControl();
       
  3567                                 break;
       
  3568                                 }
       
  3569                             }
       
  3570                         else
       
  3571                             {
       
  3572                             // First table button.
       
  3573                             if (iExtension->iTableNavi &&
       
  3574                                 iExtension->iTableNavi->EnterControl(0,0))
       
  3575                                 {
       
  3576                                 LeaveControl();
       
  3577                                 break;
       
  3578                                 }
       
  3579                             }
  2418                             }
  3580                         }
  2419                         }
  3581                     }
  2420                     }
  3582                 else
  2421                 else
  3583                     {
  2422                     {
  3584                     if ((iCursorPos.iY == ColMin(0)) &&
  2423                     if ((iCursorPos.iY == ColMin(0)) &&
  3585                         (iCursorPos.iX == 0))
  2424                         (iCursorPos.iX == 0))
  3586                         {
  2425                         {
  3587                         if (!Layout_Meta_Data::IsLandscapeOrientation())
  2426                         // mirrored, move right from first one in grid, focus pgNavi last button
       
  2427                         if ( iExtension->iPageNavi )
  3588                             {
  2428                             {
  3589                             // First table button.
  2429                             TInt maxButt = iExtension->iPageNavi->LastButton();
  3590                             if (iExtension->iTableNavi &&
  2430                             if ( iExtension->iPageNavi->EnterControl( maxButt,0 ) )
  3591                                 iExtension->iTableNavi->EnterControl(0,0))
       
  3592                                 {
       
  3593                                 LeaveControl();
       
  3594                                 break;
       
  3595                                 }
       
  3596 
       
  3597                             }
       
  3598                         else
       
  3599                             {
       
  3600                             // Left page button.
       
  3601                             if (iExtension->iPageNavi &&
       
  3602                                 iExtension->iPageNavi->EnterControl(1,0))
       
  3603                                 {
  2431                                 {
  3604                                 LeaveControl();
  2432                                 LeaveControl();
  3605                                 break;
  2433                                 break;
  3606                                 }
  2434                                 }
  3607                             }
  2435                             }
  3614         case EKeyUpArrow:
  2442         case EKeyUpArrow:
  3615         case '2':
  2443         case '2':
  3616             {
  2444             {
  3617             if (AknLayoutUtils::PenEnabled())
  2445             if (AknLayoutUtils::PenEnabled())
  3618                 {
  2446                 {
  3619                 if (iCursorPos.iY == ColMin(iCursorPos.iX))
  2447                 if ( iCursorPos.iY == ColMin(iCursorPos.iX) )
  3620                     {
  2448                     {
  3621                     if (!iExtension->iRadioButton && iCursorPos.iX < TableCount())
  2449                     // cell is at the top row, need to go on to PageNavi
       
  2450                     if ( iExtension->iPageNavi )
  3622                         {
  2451                         {
  3623                         // Table button up.
  2452                         TInt aX = 0;
  3624                         if ( iExtension->iTableNavi &&
  2453                         
  3625                             iExtension->iTableNavi->EnterControl(iCursorPos.iX,0))
  2454                         if ( iCursorPos.iX == MaxCols() - 1 )
       
  2455                             {
       
  2456                             aX = iExtension->iPageNavi->LastButton();
       
  2457                             }
       
  2458                         else if ( iCursorPos.iX == MaxCols() - 2 )
       
  2459                             {
       
  2460                             // a bit complex as unable-emotion SCT has no SC/Emotion icon
       
  2461                             if ( iExtension->IsEmotionEnabled() )
       
  2462                             	{
       
  2463                                 aX = iIsMirrored? 1 : 2;
       
  2464                             	}
       
  2465                             else
       
  2466                             	{
       
  2467                                 aX = -1;
       
  2468                             	}
       
  2469                             }
       
  2470                         else if (iCursorPos.iX == 1 )  
       
  2471                             {
       
  2472                             aX = iIsMirrored? 2 : 1;
       
  2473                             }
       
  2474                         else if ( iCursorPos.iX == 0 )
       
  2475                             {
       
  2476                             // first button in PageNavi
       
  2477                             aX = 0;
       
  2478                             }
       
  2479                         else
       
  2480                         	{
       
  2481                             aX = -1;
       
  2482                         	}
       
  2483                         if ( iExtension->iPageNavi->EnterControl( aX,0 ) )
  3626                             {
  2484                             {
  3627                             LeaveControl();
  2485                             LeaveControl();
  3628                             break;
  2486                             break;
  3629                             }
  2487                             }
  3630                         }
  2488                         }
  3631                     else
  2489                     EnterControl(iCursorPos.iX, ColMax( iCursorPos.iX));
  3632                         {
  2490                     break;
  3633                         if (iCursorPos.iX == MaxCols() - 1)
  2491                     }
       
  2492                 }
       
  2493                 MoveFocus(0,-1);
       
  2494                 break;
       
  2495             }
       
  2496         case EKeyDownArrow:
       
  2497         case '8':
       
  2498             {
       
  2499             if (AknLayoutUtils::PenEnabled())
       
  2500                 {
       
  2501                 if (iCursorPos.iY == ColMax(iCursorPos.iX))
       
  2502                     {
       
  2503                     if (  iExtension->iPageNavi )
       
  2504                     	{
       
  2505                         TInt aX = 0;
       
  2506                     
       
  2507                         if ( iCursorPos.iX == MaxCols() - 1 )
  3634                             {
  2508                             {
  3635                             // Right page button.
  2509                             aX = iExtension->iPageNavi->LastButton();
  3636                             if ( iExtension->iPageNavi &&
  2510                             }
  3637                                 iExtension->iPageNavi->EnterControl(1,0))
  2511                         else if ( iCursorPos.iX == MaxCols() - 2 )
       
  2512                             {
       
  2513                              // a bit complex as unable-emotion SCT has no SC/Emotion icon
       
  2514                             if ( iExtension->IsEmotionEnabled() )
  3638                                 {
  2515                                 {
  3639                                 LeaveControl();
  2516                                 aX = iIsMirrored? 1 : 2;
  3640                                 break;
  2517                                 }
       
  2518                             else
       
  2519                                 {
       
  2520                                 aX = -1;
  3641                                 }
  2521                                 }
  3642                             }
  2522                             }
  3643                         if (Layout_Meta_Data::IsLandscapeOrientation())
  2523                         else if ( iCursorPos.iX == 1 )  
  3644                             {
  2524                             {
  3645                             if ((!iExtension->iRadioButton &&
  2525                             aX = iIsMirrored? 2 : 1;
  3646                                  (iCursorPos.iX == TableCount())) ||
       
  3647                                ((iExtension->iRadioButton) &&
       
  3648                                  (iCursorPos.iX == MaxCols()-2)))
       
  3649                                 {
       
  3650                                 // Left page button.
       
  3651                                 if ( iExtension->iPageNavi &&
       
  3652                                     iExtension->iPageNavi->EnterControl(0,0))
       
  3653                                     {
       
  3654                                     LeaveControl();
       
  3655                                     break;
       
  3656                                     }
       
  3657                                 }
       
  3658                             }
  2526                             }
  3659                         // Grid bottom row.
  2527                         else if ( iCursorPos.iX == 0 )
  3660                         if (ColMax(0) > ColMax(iCursorPos.iX))
       
  3661                             {
  2528                             {
  3662                             EnterControl(RowMax(ColMax(0)), ColMax(0));
  2529                             // default: first button in PageNavi
       
  2530                             aX = 0;
       
  2531                             }
       
  2532                         else
       
  2533                         	{
       
  2534                             aX = -1;
       
  2535                         	}
       
  2536                         if ( iExtension->iPageNavi->EnterControl( aX,0 ) )
       
  2537                             {
       
  2538                             LeaveControl();
  3663                             break;
  2539                             break;
  3664                             }
  2540                             }
  3665                         EnterControl(iCursorPos.iX, ColMax( iCursorPos.iX));
  2541                     	}
  3666                         break;
  2542                     // cell is at bottom row
  3667                         }
       
  3668                     }
       
  3669                 }
       
  3670             MoveFocus(0,-1);
       
  3671             break;
       
  3672             }
       
  3673         case EKeyDownArrow:
       
  3674         case '8':
       
  3675             {
       
  3676             if (AknLayoutUtils::PenEnabled())
       
  3677                 {
       
  3678                 if (iCursorPos.iY == ColMax(iCursorPos.iX))
       
  3679                     {
       
  3680                     if (iCursorPos.iX > RowMax(ColMax(0)))
  2543                     if (iCursorPos.iX > RowMax(ColMax(0)))
  3681                         {
  2544                         {
  3682                         // Grid last item.
  2545                         // Grid last item.
  3683                         EnterControl(RowMax(ColMax(0)), ColMax(0));
  2546                         EnterControl(RowMax(ColMax(0)), ColMax(0));
  3684                         break;
  2547                         break;
  3685                         }
       
  3686                     if ((iCursorPos.iX == MaxCols() - 1) ||
       
  3687                         (!Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3688                             iExtension->iRadioButton &&
       
  3689                                 (iCursorPos.iX == MaxCols() - 2)))
       
  3690                         {
       
  3691                         // Right page button.
       
  3692                         if (iExtension->iPageNavi &&
       
  3693                             iExtension->iPageNavi->EnterControl(1,0))
       
  3694                             {
       
  3695                             LeaveControl();
       
  3696                             break;
       
  3697                             }
       
  3698                         }
       
  3699                     if ((Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3700                             !iExtension->iRadioButton &&
       
  3701                                 (iCursorPos.iX == TableCount())) ||
       
  3702                         (!Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3703                             (iCursorPos.iX == 0)) ||
       
  3704                         (Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3705                             iExtension->iRadioButton &&
       
  3706                                 (iCursorPos.iX == MaxCols() - 2)))
       
  3707                         {
       
  3708                         // Left page button.
       
  3709                         if (iExtension->iPageNavi &&
       
  3710                             iExtension->iPageNavi->EnterControl(0,0))
       
  3711                             {
       
  3712                             LeaveControl();
       
  3713                             break;
       
  3714                             }
       
  3715                         }
       
  3716                     if (!iExtension->iRadioButton &&
       
  3717                             iCursorPos.iX < TableCount())
       
  3718                         {
       
  3719                          // Table button down.
       
  3720                         if (iExtension->iTableNavi &&
       
  3721                             iExtension->iTableNavi->EnterControl(iCursorPos.iX,0))
       
  3722                             {
       
  3723                             LeaveControl();
       
  3724                             break;
       
  3725                             }
       
  3726                         }
  2548                         }
  3727                     // Grid top row.
  2549                     // Grid top row.
  3728                     EnterControl(iCursorPos.iX, ColMin(iCursorPos.iX));
  2550                     EnterControl(iCursorPos.iX, ColMin(iCursorPos.iX));
  3729                     break;
  2551                     break;
  3730                     }
  2552                     }
  3818 
  2640 
  3819         TAknLayoutRect gridWithScrollLayRect;
  2641         TAknLayoutRect gridWithScrollLayRect;
  3820         gridWithScrollLayRect.LayoutRect(relativePopup, AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
  2642         gridWithScrollLayRect.LayoutRect(relativePopup, AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
  3821 
  2643 
  3822         TAknLayoutRect gridLayRect;
  2644         TAknLayoutRect gridLayRect;
  3823         if (iExtension->iHasCategoryButtonUi)
  2645         gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(), AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
  3824             {
       
  3825             gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(), AknLayoutScalable_Avkon::grid_graphic_popup_pane(2));
       
  3826             }
       
  3827         else
       
  3828             {
       
  3829             gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(), AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
       
  3830             }
       
  3831 
  2646 
  3832         // Grid.
  2647         // Grid.
  3833         TRect contentRect = Extension()->iMenuSct ? Rect() : gridLayRect.Rect();
  2648         TRect contentRect = Extension()->iMenuSct ? Rect() : gridLayRect.Rect();
  3834         if ( Extension()->iMenuSct )
  2649         if ( Extension()->iMenuSct )
  3835             {
  2650             {
  3845         else
  2660         else
  3846             {
  2661             {
  3847             iOffset.iX = contentRect.iTl.iX + 1;
  2662             iOffset.iX = contentRect.iTl.iX + 1;
  3848             iGridTopLeft.iX = contentRect.iTl.iX;
  2663             iGridTopLeft.iX = contentRect.iTl.iX;
  3849             }
  2664             }
  3850 
       
  3851         // Category buttons.
       
  3852         if (iExtension && iExtension->iHasCategoryButtonUi)
       
  3853             {
       
  3854             if (iExtension->iRadioButton)
       
  3855                 {
       
  3856                 TAknLayoutRect categoryButtonLayRect;
       
  3857                 categoryButtonLayRect.LayoutRect(gridWithScrollLayRect.Rect(),AknLayoutScalable_Avkon::grid_sct_catagory_button_pane());
       
  3858 
       
  3859                 TAknLayoutRect oneButtonLayRect;
       
  3860                 oneButtonLayRect.LayoutRect(categoryButtonLayRect.Rect(),AknLayoutScalable_Avkon::cell_sct_catagory_button_pane());
       
  3861 
       
  3862                 TSize size(oneButtonLayRect.Rect().Width(), oneButtonLayRect.Rect().Height()*iExtension->iRadioButton->Count());
       
  3863                 TRect rectRadio(categoryButtonLayRect.Rect().iTl, size);
       
  3864                 iExtension->iRadioButton->SetRect(rectRadio);
       
  3865                 }
       
  3866             }
       
  3867 
       
  3868 
  2665 
  3869         // Background context.
  2666         // Background context.
  3870         if(iExtension && iExtension->iBgContext)
  2667         if(iExtension && iExtension->iBgContext)
  3871             {
  2668             {
  3872             TInt varietyNumber = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
  2669             TInt varietyNumber = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
  3877 
  2674 
  3878         TRAP_IGNORE( UpdateScrollIndicatorL() );
  2675         TRAP_IGNORE( UpdateScrollIndicatorL() );
  3879         }
  2676         }
  3880     else
  2677     else
  3881         {
  2678         {
  3882         
  2679         TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 7 : 6;
  3883         TInt variety;
       
  3884         if (!IsJapaneseSctUi())
       
  3885             {
       
  3886             variety = Layout_Meta_Data::IsLandscapeOrientation() ? 3 : 1;
       
  3887             if(TableCount() > 1) variety--;
       
  3888             }
       
  3889         else
       
  3890             {
       
  3891             variety = Layout_Meta_Data::IsLandscapeOrientation() ? 5 : 4;
       
  3892             }
       
  3893         
  2680         
  3894         // Popup.
  2681         // Popup.
  3895         TAknLayoutRect popupGridLayRect;
  2682         TAknLayoutRect popupGridLayRect;
  3896         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  2683         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  3897         TRect popupGridRect = popupGridLayRect.Rect();
  2684         TRect popupGridRect = popupGridLayRect.Rect();
  3912             {
  2699             {
  3913             iOffset.iX = gridRect.iTl.iX + 1;
  2700             iOffset.iX = gridRect.iTl.iX + 1;
  3914             iGridTopLeft.iX = gridRect.iTl.iX;
  2701             iGridTopLeft.iX = gridRect.iTl.iX;
  3915             }
  2702             }
  3916 
  2703 
  3917         // Category
       
  3918         if (iExtension->iHasCategoryButtonUi && iExtension->iRadioButton) // Radio buttons.
       
  3919             {
       
  3920             TAknLayoutRect oneButtonLayRect;
       
  3921             TAknLayoutRect categoryButtonLayRect;
       
  3922             TInt oneButtonLayVariety, categoryButtonLayVariety;
       
  3923             
       
  3924             if (Layout_Meta_Data::IsLandscapeOrientation())
       
  3925                 {
       
  3926                 oneButtonLayVariety = 5;
       
  3927                 categoryButtonLayVariety = 1;
       
  3928                 }
       
  3929             else
       
  3930                 {
       
  3931                 oneButtonLayVariety = 4;
       
  3932                 categoryButtonLayVariety = 0;
       
  3933                 }
       
  3934             
       
  3935             oneButtonLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_control_pane(oneButtonLayVariety));
       
  3936             categoryButtonLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_catg_pane(categoryButtonLayVariety));
       
  3937 
       
  3938             TSize size(oneButtonLayRect.Rect().Width(), 
       
  3939                        oneButtonLayRect.Rect().Height() * iExtension->iRadioButton->Count());
       
  3940             TRect rectRadio(categoryButtonLayRect.Rect().iTl, size);
       
  3941             iExtension->iRadioButton->SetRect(rectRadio);
       
  3942             }
       
  3943 
       
  3944         // Table navigation.
       
  3945         if (iExtension->iTableNavi)
       
  3946             {
       
  3947             TAknLayoutRect tableNaviLayRect;
       
  3948             tableNaviLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_control_pane(variety));
       
  3949             iExtension->iTableNavi->SetRect(tableNaviLayRect.Rect());
       
  3950             }
       
  3951 
       
  3952         // Page navigation.
  2704         // Page navigation.
  3953         if (iExtension->iPageNavi)
  2705         if (iExtension->iPageNavi)
  3954             {
  2706             {
  3955             if (PageCount() > 1)
  2707             iExtension->iPageNavi->MakeVisible(ETrue);
  3956                 {
  2708 
  3957                 iExtension->iPageNavi->MakeVisible(ETrue);
  2709             TAknLayoutRect pageNaviLayRect;
  3958                 
  2710             pageNaviLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_control_pane(variety));
  3959                 TAknLayoutRect pageNaviLayRect;
  2711             iExtension->iPageNavi->SetRect(pageNaviLayRect.Rect());
  3960                 pageNaviLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::graphic2_pages_pane(variety));
       
  3961                 iExtension->iPageNavi->SetRect(pageNaviLayRect.Rect());
       
  3962                 }
       
  3963             else
       
  3964                 {
       
  3965                 iExtension->iPageNavi->MakeVisible(EFalse);
       
  3966                 }
       
  3967             }
  2712             }
  3968 
  2713 
  3969         // Background context.
  2714         // Background context.
  3970         if(iExtension->iBgContext)
  2715         if(iExtension->iBgContext)
  3971             {
  2716             {
  4056                 dlgExtension->iPublicFlags.Clear(CEikDialogExtension::EUseVirtualInput);
  2801                 dlgExtension->iPublicFlags.Clear(CEikDialogExtension::EUseVirtualInput);
  4057                 }
  2802                 }
  4058             }
  2803             }
  4059 
  2804 
  4060         // Sets alternate UI controls.
  2805         // Sets alternate UI controls.
  4061         if (iExtension->iHasCategoryButtonUi)
  2806         if (AknLayoutUtils::PenEnabled())
  4062             {
  2807             {
  4063             if (AknLayoutUtils::PenEnabled())
  2808             EnableNavigationButtonsL();
  4064                 {
       
  4065                 EnableCategoryInputFieldL();
       
  4066                 EnableNavigationButtonsL();
       
  4067                 }
       
  4068             else
       
  4069                 {
       
  4070                 DisableCategoryInputFieldL();
       
  4071                 DisableNavigationButtonsL();
       
  4072                 }
       
  4073             EnableCategoryButtonsL();
       
  4074             }
  2809             }
  4075         else
  2810         else
  4076             {
  2811             {
  4077             DisableCategoryInputFieldL();
  2812             DisableNavigationButtonsL();
  4078             DisableCategoryButtonsL();
  2813             }
  4079             if (AknLayoutUtils::PenEnabled())
  2814 
  4080                 {
       
  4081                 EnableNavigationButtonsL();
       
  4082                 }
       
  4083             else
       
  4084                 {
       
  4085                 DisableNavigationButtonsL();
       
  4086                 }
       
  4087             }
       
  4088 
  2815 
  4089         // and finally updates the page counts (from setcasetable)
  2816         // and finally updates the page counts (from setcasetable)
  4090         iSpecialCharPages.Reset(); // reset the current page count for different charsets
  2817         iSpecialCharPages.Reset(); // reset the current page count for different charsets
  4091         iSpecialCharPages.AppendL( PageCountFromChars(*iChars) );
  2818         iSpecialCharPages.AppendL( PageCountFromChars(*iChars) );
  4092         for (TInt i(1); i < iSpecialCharCases.Count(); ++i)
  2819         for (TInt i(1); i < iSpecialCharCases.Count(); ++i)
  4142 
  2869 
  4143 void CAknCharMap::EnableNavigationButtonsL()
  2870 void CAknCharMap::EnableNavigationButtonsL()
  4144     {
  2871     {
  4145     if ( iExtension )
  2872     if ( iExtension )
  4146         {
  2873         {
  4147         if ( !iExtension->iTableNavi )
       
  4148             {
       
  4149             iExtension->iTableNavi = new(ELeave) CAknSctTableNavi(this, iExtension);
       
  4150             iExtension->iTableNavi->SetContainerWindowL(*this);
       
  4151             TResourceReader reader;
       
  4152             iCoeEnv->CreateResourceReaderLC(reader, R_AVKON_SCT_TABLE_NAVI_CONTROL);
       
  4153             iExtension->iTableNavi->ConstructFromResourceL(reader);
       
  4154             iExtension->iTableNavi->SetNonFocusing();
       
  4155             iExtension->iTableNavi->SetMopParent(iExtension);
       
  4156             CleanupStack::PopAndDestroy(); // reader
       
  4157             }
       
  4158 
       
  4159         iExtension->iTableNavi->MakeVisible(ETrue);
       
  4160 
       
  4161         if ( !iExtension->iPageNavi )
  2874         if ( !iExtension->iPageNavi )
  4162             {
  2875             {
  4163             iExtension->iPageNavi = new(ELeave) CAknSctPageNavi(this, iExtension);
  2876             iExtension->iPageNavi = new(ELeave) CAknSctPageNavi(this, iExtension);
  4164             iExtension->iPageNavi->SetContainerWindowL(*this);
  2877             iExtension->iPageNavi->SetContainerWindowL(*this);
  4165             TResourceReader reader;
  2878             TResourceReader reader;
  4174         }
  2887         }
  4175     }
  2888     }
  4176 
  2889 
  4177 void CAknCharMap::DisableNavigationButtonsL()
  2890 void CAknCharMap::DisableNavigationButtonsL()
  4178     {
  2891     {
  4179     if ( iExtension && iExtension->iTableNavi )
       
  4180         {
       
  4181         iExtension->iTableNavi->MakeVisible( EFalse );
       
  4182         }
       
  4183     if ( iExtension && iExtension->iPageNavi )
  2892     if ( iExtension && iExtension->iPageNavi )
  4184         {
  2893         {
  4185         iExtension->iPageNavi->MakeVisible( EFalse );
  2894         iExtension->iPageNavi->MakeVisible( EFalse );
  4186         }
       
  4187     }
       
  4188 
       
  4189 void CAknCharMap::EnableCategoryButtonsL()
       
  4190     {
       
  4191     if (!iExtension->iRadioButton)
       
  4192         {
       
  4193         iExtension->iRadioButton = new(ELeave) CAknSctRadioButton(this, iExtension);
       
  4194         iExtension->iRadioButton->SetContainerWindowL(*this);
       
  4195         TResourceReader reader;
       
  4196         iCoeEnv->CreateResourceReaderLC(reader, R_AVKON_SCT_CATEGORY_BUTTON_CONTROL);
       
  4197         iExtension->iRadioButton->ConstructFromResourceL(reader);
       
  4198         iExtension->iRadioButton->SetNonFocusing();
       
  4199         iExtension->iRadioButton->SetMopParent(iExtension);
       
  4200         CleanupStack::PopAndDestroy(); // reader
       
  4201         }
       
  4202     iExtension->iRadioButton->MakeVisible(ETrue);
       
  4203     }
       
  4204 
       
  4205 void CAknCharMap::DisableCategoryButtonsL()
       
  4206     {
       
  4207     if (iExtension && iExtension->iRadioButton)
       
  4208         {
       
  4209         iExtension->iRadioButton->MakeVisible(EFalse);
       
  4210         }
  2895         }
  4211     }
  2896     }
  4212 
  2897 
  4213 void CAknCharMap::EnableCategoryInputFieldL()
  2898 void CAknCharMap::EnableCategoryInputFieldL()
  4214     {
  2899     {
  4297     CWindowGc& gc=SystemGc();
  2982     CWindowGc& gc=SystemGc();
  4298     gc.UseFont(iFont);
  2983     gc.UseFont(iFont);
  4299 
  2984 
  4300     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  2985     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  4301     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
  2986     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  2987     AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
  4302 
  2988 
  4303     TRect rect = Rect();
  2989     TRect rect = Rect();
  4304 
  2990 
  4305     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
  2991     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
  4306         {
  2992         {
  4307         TRect mainPaneRect;
  2993         TRect mainPaneRect;
  4308         if(!AknLayoutUtils::LayoutMetricsRect(
  2994         if(!AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EPopupParent, mainPaneRect))
  4309             AknLayoutUtils::EPopupParent, mainPaneRect))
       
  4310             {
  2995             {
  4311             mainPaneRect = iAvkonAppUi->ClientRect();
  2996             mainPaneRect = iAvkonAppUi->ClientRect();
  4312             }
  2997             }
  4313 
  2998 
  4314         TAknLayoutScalableParameterLimits charMapDialogVariety =
  2999         TAknLayoutScalableParameterLimits charMapDialogVariety = AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
  4315             AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
       
  4316 
       
  4317         TInt maxVariety = charMapDialogVariety.LastVariety();
  3000         TInt maxVariety = charMapDialogVariety.LastVariety();
  4318 
       
  4319         AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
       
  4320         TInt maxVarietyOffset = 0;
  3001         TInt maxVarietyOffset = 0;
  4321         TInt varietyOffset = maxVariety + 1;
  3002         TInt varietyOffset = maxVariety + 1;
  4322 
  3003 
  4323         if(Layout_Meta_Data::IsLandscapeOrientation())
  3004         if(Layout_Meta_Data::IsLandscapeOrientation())
  4324             {
  3005             {
  4345             varietyNumber -= 1;
  3026             varietyNumber -= 1;
  4346             }
  3027             }
  4347         varietyNumber += maxVarietyOffset;
  3028         varietyNumber += maxVarietyOffset;
  4348 
  3029 
  4349         TAknLayoutRect popupGridLayRect;
  3030         TAknLayoutRect popupGridLayRect;
  4350         popupGridLayRect.LayoutRect(mainPaneRect,
  3031         popupGridLayRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::popup_grid_graphic_window(varietyNumber));
  4351             AknLayoutScalable_Avkon::popup_grid_graphic_window(varietyNumber));
       
  4352 
  3032 
  4353         // Background height.
  3033         // Background height.
  4354         TInt backgroundHeightOffset =
  3034         TInt backgroundHeightOffset = popupGridLayRect.Rect().Height() - rect.iBr.iY;
  4355             popupGridLayRect.Rect().Height() - rect.iBr.iY;
       
  4356 
       
  4357         rect.iBr.iY += backgroundHeightOffset;
  3035         rect.iBr.iY += backgroundHeightOffset;
  4358         }
  3036         }
  4359     else
  3037     else
  4360         {
  3038         {
  4361         TAknLayoutRect popupGridLayRect;
  3039         TAknLayoutRect popupGridLayRect;
  4362         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
  3040         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  4363             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
       
  4364 
  3041 
  4365         // Background height.
  3042         // Background height.
  4366         TInt backgroundHeightOffset =
  3043         TInt backgroundHeightOffset = popupGridLayRect.Rect().Height() - rect.iBr.iY;
  4367             popupGridLayRect.Rect().Height() - rect.iBr.iY;
       
  4368 
       
  4369         rect.iBr.iY += backgroundHeightOffset * 2;
  3044         rect.iBr.iY += backgroundHeightOffset * 2;
  4370         }
  3045         }
  4371 
  3046 
  4372     // Grid (main).
  3047     // Grid (main).
  4373     if ( !Extension()->iMenuSct )
  3048     if ( !Extension()->iMenuSct )
  4374         {
  3049         {
  4375         // 1) Draw the background
  3050         // 1) Draw the background
  4376 
       
  4377         // Check if we got an offscreen bitmap allocated for skin background and
  3051         // Check if we got an offscreen bitmap allocated for skin background and
  4378         // there is bitmap background in the current skin.
  3052         // there is bitmap background in the current skin.
  4379 		if( CAknEnv::Static()->TransparencyEnabled() )
  3053 		if( CAknEnv::Static()->TransparencyEnabled() )
  4380 			{
  3054 			{
  4381 			TRegionFix<10> clipReg;
  3055 			TRegionFix<10> clipReg;
  4382 			clipReg.AddRect(rect);
  3056 			clipReg.AddRect(rect);
       
  3057 
  4383 			if ( iFirstVisibleRow == 0 && iSetRecentSct )
  3058 			if ( iFirstVisibleRow == 0 && iSetRecentSct )
  4384 				{
  3059 				{
  4385 				TPoint pos = iGridTopLeft;
  3060 				TPoint pos = iGridTopLeft;
  4386 				TInt endX = pos.iX + iGridItemWidth * iMaxColumns + 1;
  3061 				TSize size(iGridItemWidth*iMaxColumns+1, iGridItemHeight);
  4387 				TInt endY = pos.iY + iGridItemHeight;
  3062 				if(iIsMirrored)
       
  3063 				    {
       
  3064                     pos.iX += iGridItemWidth - size.iWidth;
       
  3065 				    }
  4388 				// eliminate the overlap area between menu sct and the first menu item.
  3066 				// eliminate the overlap area between menu sct and the first menu item.
  4389 				if ( Extension()->iMenuSct )
  3067 				if ( Extension()->iMenuSct )
  4390 					{
  3068 					{
  4391 					endY--;
  3069                     size.iHeight--;
  4392 					}
  3070 					}
  4393 				clipReg.SubRect( TRect( pos, TPoint( endX, endY ) ) );
  3071 				clipReg.SubRect(TRect(pos,size));
  4394 				}
  3072 				}
       
  3073 			
  4395 			// Take scroll bar out of clip region
  3074 			// Take scroll bar out of clip region
  4396 			if (iSBFrame)
  3075 			if (iSBFrame)
  4397 				{
  3076 				{
  4398 				clipReg.SubRect(iSBFrame->GetScrollBarHandle(
  3077 				clipReg.SubRect(iSBFrame->GetScrollBarHandle(CEikScrollBar::EVertical)->Rect());
  4399 					CEikScrollBar::EVertical)->Rect());
       
  4400 				}
  3078 				}
       
  3079 
  4401 			gc.SetClippingRegion(clipReg);
  3080 			gc.SetClippingRegion(clipReg);
  4402 			}
  3081 			}
       
  3082 		
  4403 		AknsDrawUtils::Background( skin, cc, this, gc, rect,KAknsDrawParamNoClearUnderImage);
  3083 		AknsDrawUtils::Background( skin, cc, this, gc, rect,KAknsDrawParamNoClearUnderImage);
       
  3084 		
  4404 		if( CAknEnv::Static()->TransparencyEnabled() )
  3085 		if( CAknEnv::Static()->TransparencyEnabled() )
  4405 			{
  3086 			{
  4406 			gc.CancelClippingRegion();
  3087 			gc.CancelClippingRegion();
  4407 			}
  3088 			}
  4408 
  3089 
  4409         gc.SetPenStyle(CGraphicsContext::ESolidPen);
  3090         // 2) Draw the grid
       
  3091 		gc.SetPenStyle(CGraphicsContext::ESolidPen);
  4410         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
  3092         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
  4411         gc.SetPenSize(TSize(1,1));
  3093         gc.SetPenSize(TSize(1,1));
  4412 
       
  4413         // 2) Draw the grid
       
  4414         DrawGrid(gc);
  3094         DrawGrid(gc);
  4415         }
  3095         }
  4416 
  3096 
  4417     // Grid (recent).
  3097     // Grid (recent).
  4418     if (iFirstVisibleRow==0 && iSetRecentSct)
  3098     if (iFirstVisibleRow==0 && iSetRecentSct)
  4610         {
  3290         {
  4611         if ( Layout_Meta_Data::IsLandscapeOrientation() )
  3291         if ( Layout_Meta_Data::IsLandscapeOrientation() )
  4612             {
  3292             {
  4613             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(1);
  3293             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(1);
  4614             }
  3294             }
  4615         else if (IsJapaneseSctUi())
       
  4616             {
       
  4617             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(2);
       
  4618             }
       
  4619         else
  3295         else
  4620             {
  3296             {
  4621             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(0);
  3297             specialCharItemLayout = AknLayoutScalable_Avkon::cell_graphic2_pane_t1(0);
  4622             }
  3298             }
  4623         }
  3299         }
  4627         }
  3303         }
  4628 
  3304 
  4629     TRect textRect = aSctPosition;
  3305     TRect textRect = aSctPosition;
  4630     if( IsRecentChar(aCharIndex) )
  3306     if( IsRecentChar(aCharIndex) )
  4631         {
  3307         {
  4632         textRect.Move(0, -1);       //because height of recent char frame decreased 1.
       
  4633         if( Extension()->iMenuSct )
  3308         if( Extension()->iMenuSct )
  4634             {
  3309             {
  4635             textRect.Move(0, -1);   //because menu sct will also shrink 1.
  3310             textRect.Move(0, -1);   //because menu sct will also shrink 1.
  4636             }
  3311             }
  4637         }
  3312         }
  4747 // Draw the outter thick frame for the all recent chars.
  3422 // Draw the outter thick frame for the all recent chars.
  4748 //-------------------------------------------------------
  3423 //-------------------------------------------------------
  4749 //
  3424 //
  4750 void CAknCharMap::DrawRecentCharFrame( CWindowGc& aGc) const
  3425 void CAknCharMap::DrawRecentCharFrame( CWindowGc& aGc) const
  4751     {
  3426     {
  4752     MAknsSkinInstance*   skin = AknsUtils::SkinInstance();
  3427     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  4753     MAknsControlContext* cc = iExtension->iBgContext;
  3428     MAknsControlContext* cc = iExtension->iBgContext;
  4754     if ( !cc )
  3429     if ( !cc )
  4755         {
  3430         {
  4756         cc = AknsDrawUtils::ControlContext( this );
  3431         cc = AknsDrawUtils::ControlContext( this );
  4757         }
  3432         }
  4758 
  3433 
  4759     TPoint pos = iGridTopLeft;
  3434     TPoint pos = iGridTopLeft;
  4760     TInt endX = pos.iX + iGridItemWidth * iMaxColumns + 1;
  3435     TSize size(iGridItemWidth*iMaxColumns+1, iGridItemHeight);
  4761     TInt endY = pos.iY + iGridItemHeight;
  3436     if(iIsMirrored)
  4762     TRect drawRect(TPoint(pos.iX, pos.iY), TPoint(endX, endY));
  3437         {
       
  3438         pos.iX += iGridItemWidth - size.iWidth;
       
  3439         }
  4763     // eliminate the overlap area between menu sct and the first menu item.
  3440     // eliminate the overlap area between menu sct and the first menu item.
  4764     if ( Extension()->iMenuSct )
  3441     if ( Extension()->iMenuSct )
  4765         {
  3442         {
  4766         drawRect = Rect();
  3443         size.iHeight--;
  4767         endY--;
  3444         }
  4768         }
  3445 
  4769 
  3446     AknsDrawUtils::Background(skin, cc, this, aGc, TRect(pos,size));
  4770     AknsDrawUtils::Background( skin, cc, this, aGc, drawRect );
       
  4771 
  3447 
  4772     SetRecentCharFrameStyle(aGc);
  3448     SetRecentCharFrameStyle(aGc);
  4773     if(iIsMirrored)
  3449     aGc.DrawRect(TRect(pos,size));
  4774         {
  3450 
  4775         pos.iX = iGridTopLeft.iX - ((iMaxColumns - 1) * iGridItemWidth);
       
  4776         endX = iGridTopLeft.iX + iGridItemWidth + 1;
       
  4777         }
       
  4778 
       
  4779     aGc.DrawRect( TRect(TPoint(pos.iX-1, pos.iY-1), TPoint(endX, endY)));
       
  4780     
       
  4781     MTouchFeedback* feedback = MTouchFeedback::Instance();
  3451     MTouchFeedback* feedback = MTouchFeedback::Instance();
  4782     CFeedbackSpec* spec = CFeedbackSpec::New();
  3452     CFeedbackSpec* spec = CFeedbackSpec::New();
  4783 
  3453 
  4784     if ( spec && feedback )
  3454     if ( spec && feedback )
  4785         {
  3455         {
  5098          ( (iChaMapTableCase!=EAknCharMapTableSpecialChar && !iPictoInterface->Interface()->IsPictograph((*iChars)[0])) || 
  3768          ( (iChaMapTableCase!=EAknCharMapTableSpecialChar && !iPictoInterface->Interface()->IsPictograph((*iChars)[0])) || 
  5099            (iChaMapTableCase==EAknCharMapTableSpecialChar && (*iChars)[0]==KHistoryEmptyChar) ) 
  3769            (iChaMapTableCase==EAknCharMapTableSpecialChar && (*iChars)[0]==KHistoryEmptyChar) ) 
  5100        )
  3770        )
  5101         {
  3771         {
  5102         caseChange = ETrue;
  3772         caseChange = ETrue;
  5103         // Cursor was on the second line
  3773 
  5104         if (aDeltaY < 0)
       
  5105             {
       
  5106             globalYPos--;
       
  5107             }
       
  5108         // Cursor was on the second line and first position
  3774         // Cursor was on the second line and first position
  5109         if (aDeltaX < 0 && iCursorPos.iX == 0)
  3775         if (aDeltaX < 0 && iCursorPos.iX == 0)
  5110             {
  3776             {
  5111             globalYPos--;
  3777             globalYPos--;
  5112             //iCursorPos.iY = 0;
  3778             //iCursorPos.iY = 0;
  5490 
  4156 
  5491     // Calculate the relative rect for the grid
  4157     // Calculate the relative rect for the grid
  5492     TRect parent = gridWithScrollLayRect.Rect();
  4158     TRect parent = gridWithScrollLayRect.Rect();
  5493 
  4159 
  5494     TAknWindowComponentLayout scrollbarLayout;
  4160     TAknWindowComponentLayout scrollbarLayout;
  5495     if (iExtension->iHasCategoryButtonUi)
  4161     scrollbarLayout = AknLayoutScalable_Avkon::scroll_pane_cp5(0);
  5496         {
       
  5497         scrollbarLayout = AknLayoutScalable_Avkon::scroll_pane_cp5(1);
       
  5498         }
       
  5499     else
       
  5500         {
       
  5501         scrollbarLayout = AknLayoutScalable_Avkon::scroll_pane_cp5(0);
       
  5502         }
       
  5503 
  4162 
  5504     vSbarModel.iScrollSpan = PageCount() * iExtension->iMaxVisibleRows;
  4163     vSbarModel.iScrollSpan = PageCount() * iExtension->iMaxVisibleRows;
  5505     vSbarModel.iThumbSpan = iExtension->iMaxVisibleRows;
  4164     vSbarModel.iThumbSpan = iExtension->iMaxVisibleRows;
  5506 
  4165 
  5507     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  4166     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  5923             return iSBFrame->VerticalScrollBar();
  4582             return iSBFrame->VerticalScrollBar();
  5924             }
  4583             }
  5925         aIndex--;
  4584         aIndex--;
  5926         }
  4585         }
  5927 
  4586 
  5928     if (iExtension->iRadioButton)
  4587     if (iExtension->iCategoryTitle)
  5929         {
  4588         {
  5930          if ( aIndex == 0 )
  4589         if ( aIndex == 0 )
  5931             {
  4590             {
  5932             return iExtension->iRadioButton;
  4591             return iExtension->iCategoryTitle;
  5933             }
  4592             }
  5934         aIndex--;
  4593         aIndex--;
  5935         }
  4594         }
  5936 
  4595     if (iExtension->iCategoryEntry)
  5937     if (iExtension->iCategoryTitle)
       
  5938         {
  4596         {
  5939         if ( aIndex == 0 )
  4597         if ( aIndex == 0 )
  5940             {
  4598             {
  5941             return iExtension->iCategoryTitle;
       
  5942             }
       
  5943         aIndex--;
       
  5944         }
       
  5945     if (iExtension->iCategoryEntry)
       
  5946         {
       
  5947         if ( aIndex == 0 )
       
  5948             {
       
  5949             return iExtension->iCategoryEntry;
  4599             return iExtension->iCategoryEntry;
  5950             }
       
  5951         aIndex--;
       
  5952         }
       
  5953 
       
  5954     if (iExtension->iTableNavi)
       
  5955         {
       
  5956          if ( aIndex == 0 )
       
  5957             {
       
  5958             return iExtension->iTableNavi;
       
  5959             }
  4600             }
  5960         aIndex--;
  4601         aIndex--;
  5961         }
  4602         }
  5962     if (iExtension->iPageNavi)
  4603     if (iExtension->iPageNavi)
  5963         {
  4604         {
  5976     TInt num = 0;
  4617     TInt num = 0;
  5977     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  4618     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  5978         {
  4619         {
  5979         num++;
  4620         num++;
  5980         }
  4621         }
  5981     if (iExtension->iRadioButton)
  4622     if (iExtension->iCategoryTitle)
  5982         {
  4623         {
  5983         num++;
  4624         num++;
  5984         }
  4625         }
  5985     if (iExtension->iCategoryTitle)
       
  5986         {
       
  5987         num++;
       
  5988         }
       
  5989     if (iExtension->iCategoryEntry)
  4626     if (iExtension->iCategoryEntry)
  5990         {
       
  5991         num++;
       
  5992         }
       
  5993     if (iExtension->iTableNavi)
       
  5994         {
  4627         {
  5995         num++;
  4628         num++;
  5996         }
  4629         }
  5997     if (iExtension->iPageNavi)
  4630     if (iExtension->iPageNavi)
  5998         {
  4631         {
  6031         currentcasechars = iExtension->iCharsQwerty;
  4664         currentcasechars = iExtension->iCharsQwerty;
  6032 
  4665 
  6033     iSpecialCharPages.AppendL( PageCountFromChars(*currentcasechars) );
  4666     iSpecialCharPages.AppendL( PageCountFromChars(*currentcasechars) );
  6034 
  4667 
  6035     iSpecialCharCases.AppendL( iSpecialCharCase );
  4668     iSpecialCharCases.AppendL( iSpecialCharCase );
  6036     if (iExtension->iRadioButton)
       
  6037         {
       
  6038         // Set the sct case mode to valid
       
  6039         iExtension->iRadioButton->SetValidSctCase(iSpecialCharCase);
       
  6040         }
       
  6041 
  4669 
  6042     if (aCase.Count() > 0)
  4670     if (aCase.Count() > 0)
  6043         {
  4671         {
  6044         for (TInt i(0); i < aCase.Count(); ++i)
  4672         for (TInt i(0); i < aCase.Count(); ++i)
  6045             {
  4673             {
  6046             HBufC* chars = CharsFromCase(aCase[i]);
  4674             HBufC* chars = CharsFromCase(aCase[i]);
  6047             if (chars)
  4675             if (chars)
  6048                 {
  4676                 {
  6049                 iSpecialCharCases.AppendL( aCase[i] );
  4677                 iSpecialCharCases.AppendL( aCase[i] );
  6050                 iSpecialCharPages.AppendL( PageCountFromChars(*chars) );
  4678                 iSpecialCharPages.AppendL( PageCountFromChars(*chars) );
  6051                 if (iExtension->iRadioButton)
       
  6052                     {
       
  6053                     // Set the sct case mode to valid
       
  6054                     iExtension->iRadioButton->SetValidSctCase(aCase[i]);
       
  6055                     }
       
  6056                 }
  4679                 }
  6057             }
  4680             }
  6058         }
  4681         }
  6059 
  4682 
  6060     if (iExtension->iPictographsBuffer && iPictoInterface)
  4683     if (iExtension->iPictographsBuffer && iPictoInterface)
  6066         iPictographCases.AppendL(EAknCharMapTablePicto);
  4689         iPictographCases.AppendL(EAknCharMapTablePicto);
  6067         if (iExtension->iPictographsBufferGrouping)
  4690         if (iExtension->iPictographsBufferGrouping)
  6068             {
  4691             {
  6069             iPictographPages.AppendL( PageCountFromChars(*iPictographsBuffer2) );
  4692             iPictographPages.AppendL( PageCountFromChars(*iPictographsBuffer2) );
  6070             iPictographCases.AppendL(EAknCharMapTablePicto2);
  4693             iPictographCases.AppendL(EAknCharMapTablePicto2);
  6071             if (iExtension->iRadioButton)
  4694             }
  6072                 {
       
  6073                 // Set the sct case mode to valid
       
  6074                 iExtension->iRadioButton->SetValidSctCase(EAknSCTPictograph1);
       
  6075                 iExtension->iRadioButton->SetValidSctCase(EAknSCTPictograph2);
       
  6076                 }
       
  6077             }
       
  6078         else
       
  6079             {
       
  6080             if (iExtension->iRadioButton)
       
  6081                 {
       
  6082                 // Set the sct case mode to valid
       
  6083                 iExtension->iRadioButton->SetValidSctCase(EAknSCTPictograph);
       
  6084                 }
       
  6085             }
       
  6086         }
       
  6087 
       
  6088     if (iExtension->iRadioButton)
       
  6089         {
       
  6090         // Remove invalid category buttons
       
  6091         iExtension->iRadioButton->RemoveInvalidButton();
       
  6092         __ASSERT_DEBUG( iExtension->iRadioButton->Count() > 0,
       
  6093             Panic(EAknPanicInvalidValue));
       
  6094         }
  4695         }
  6095     }
  4696     }
  6096 
  4697 
  6097 void CAknCharMap::SetTitleL(TPtrC aTitle)
  4698 void CAknCharMap::SetTitleL(TPtrC aTitle)
  6098     {
  4699     {
  6186     return page;
  4787     return page;
  6187     }
  4788     }
  6188 
  4789 
  6189 void CAknCharMap::CountMaxColumnsAndCellSizes()
  4790 void CAknCharMap::CountMaxColumnsAndCellSizes()
  6190     {
  4791     {
       
  4792     const TBool isLandscape = Layout_Meta_Data::IsLandscapeOrientation();
       
  4793 
  6191     TRect mainPaneRect;
  4794     TRect mainPaneRect;
  6192     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
  4795     if (!AknLayoutUtils::PenEnabled() || Extension()->iMenuSct)
  6193         {
  4796         {
  6194         if(!AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect))
  4797         if(!AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect))
  6195             {
  4798             {
  6202         TInt maxVariety = charMapDialogVariety.LastVariety();
  4805         TInt maxVariety = charMapDialogVariety.LastVariety();
  6203 
  4806 
  6204         AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
  4807         AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
  6205         TInt maxVarietyOffset = 0;
  4808         TInt maxVarietyOffset = 0;
  6206         TInt varietyOffset = maxVariety + 1;
  4809         TInt varietyOffset = maxVariety + 1;
  6207         if(Layout_Meta_Data::IsLandscapeOrientation())
  4810         if(isLandscape)
  6208             {
  4811             {
  6209             varietyOffset = (maxVariety + 1) / KAknSctCBaButtonDirections;
  4812             varietyOffset = (maxVariety + 1) / KAknSctCBaButtonDirections;
  6210             }
  4813             }
  6211 
  4814 
  6212         if(location == AknLayoutUtils::EAknCbaLocationRight)
  4815         if(location == AknLayoutUtils::EAknCbaLocationRight)
  6226         gridWithScrollLayRect.LayoutRect(popupGridLayRect.Rect(),
  4829         gridWithScrollLayRect.LayoutRect(popupGridLayRect.Rect(),
  6227             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
  4830             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane());
  6228 
  4831 
  6229 
  4832 
  6230         TAknLayoutRect gridLayRect;
  4833         TAknLayoutRect gridLayRect;
  6231         if (iExtension->iHasCategoryButtonUi)
  4834         gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
  6232             {
  4835             AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
  6233             gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
       
  6234                 AknLayoutScalable_Avkon::grid_graphic_popup_pane(2));
       
  6235             }
       
  6236         else
       
  6237             {
       
  6238             gridLayRect.LayoutRect(gridWithScrollLayRect.Rect(),
       
  6239                 AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
       
  6240             }
       
  6241 
  4836 
  6242         TRect gridRect = Extension()->iMenuSct ? Rect(): gridLayRect.Rect();
  4837         TRect gridRect = Extension()->iMenuSct ? Rect(): gridLayRect.Rect();
  6243 
  4838 
  6244         TAknLayoutRect firstCellLayRect;
  4839         TAknLayoutRect firstCellLayRect;
  6245         firstCellLayRect.LayoutRect(gridRect,
  4840         firstCellLayRect.LayoutRect(gridRect,
  6291             }
  4886             }
  6292         }
  4887         }
  6293     else
  4888     else
  6294         {
  4889         {
  6295         TAknLayoutRect popupGridLayRect;
  4890         TAknLayoutRect popupGridLayRect;
  6296         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(),
  4891         popupGridLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
  6297             AknLayoutScalable_Avkon::popup_grid_graphic2_window(0));
       
  6298 
       
  6299         TRect popupGridRect = popupGridLayRect.Rect();
  4892         TRect popupGridRect = popupGridLayRect.Rect();
  6300 
  4893 
  6301         TInt gridVariety;
  4894         TInt gridVariety = isLandscape ? 7 : 6;
  6302         if (!IsJapaneseSctUi())
       
  6303             {
       
  6304             if(!Layout_Meta_Data::IsLandscapeOrientation())
       
  6305                 {
       
  6306                 gridVariety = (TableCount() > 1) ? 0 : 1;
       
  6307                 }
       
  6308             else
       
  6309                 {
       
  6310                 gridVariety = (TableCount() > 1) ? 2 : 3;
       
  6311                 }
       
  6312             }
       
  6313         else
       
  6314             {
       
  6315             gridVariety = !Layout_Meta_Data::IsLandscapeOrientation() ? 4 : 5;
       
  6316             }
       
  6317 
       
  6318         TAknLayoutRect gridLayRect;
  4895         TAknLayoutRect gridLayRect;
  6319         gridLayRect.LayoutRect(popupGridRect,
  4896         gridLayRect.LayoutRect(popupGridRect, AknLayoutScalable_Avkon::grid_graphic2_pane(gridVariety));
  6320             AknLayoutScalable_Avkon::grid_graphic2_pane(gridVariety));
       
  6321 
       
  6322         TRect gridRect = gridLayRect.Rect();
  4897         TRect gridRect = gridLayRect.Rect();
  6323 
  4898 
       
  4899         TInt cellVariety = isLandscape ? 1 : 0;
  6324         TAknLayoutRect firstCellLayRect;
  4900         TAknLayoutRect firstCellLayRect;
  6325         firstCellLayRect.LayoutRect(popupGridRect,
  4901         firstCellLayRect.LayoutRect(gridRect, AknLayoutScalable_Avkon::cell_graphic2_pane(cellVariety));
  6326             AknLayoutScalable_Avkon::aid_size_cell_graphic2(gridVariety,0,0));
       
  6327 
       
  6328         TRect firstCellRect = firstCellLayRect.Rect();
  4902         TRect firstCellRect = firstCellLayRect.Rect();
       
  4903         
  6329         TInt firstVisibleIndex = iFirstVisibleRow * iMaxColumns;
  4904         TInt firstVisibleIndex = iFirstVisibleRow * iMaxColumns;
  6330 
  4905 
  6331         // Max columns.
  4906         // Max columns.
  6332         iMaxColumns = gridRect.Width() / firstCellRect.Width();
  4907         iMaxColumns = gridRect.Width() / firstCellRect.Width();
  6333         iFirstVisibleRow = firstVisibleIndex / iMaxColumns;
  4908         iFirstVisibleRow = firstVisibleIndex / iMaxColumns;
  6334 
  4909 
  6335         // Max visible rows.
  4910         // Max visible rows.
  6336         iExtension->iMaxVisibleRows = gridRect.Height() / firstCellRect.Height();
  4911         iExtension->iMaxVisibleRows = gridRect.Height() / firstCellRect.Height();
  6337 
  4912 
  6338         // Cell width.
  4913         // Cell.
  6339         iGridItemWidth = firstCellRect.Width();
  4914         iGridItemWidth = firstCellRect.Width();
  6340 
       
  6341         // Cell height.
       
  6342         iGridItemHeight = firstCellRect.Height();
  4915         iGridItemHeight = firstCellRect.Height();
  6343         }
  4916         }
  6344     }
  4917     }
  6345 
  4918 
  6346 HBufC* CAknCharMap::CharsFromCase(TInt aCharCase) const
  4919 HBufC* CAknCharMap::CharsFromCase(TInt aCharCase) const
  7489                 headingPane->SetPageL( CurrentPage(), PageCount() );
  6062                 headingPane->SetPageL( CurrentPage(), PageCount() );
  7490 
  6063 
  7491                 // Update also title if requested
  6064                 // Update also title if requested
  7492                 if ( aUpdateTitle)
  6065                 if ( aUpdateTitle)
  7493                     {
  6066                     {
  7494                     const TDesC* title = (IsJapaneseSctUi())?
  6067                     const TDesC* title = Title();
  7495                                          TitleWithSelectingSpecialChar()
       
  7496                                          :Title();
       
  7497                     if ( title )
  6068                     if ( title )
  7498                         {
  6069                         {
  7499                         //
  6070                         //
  7500                         headingPane->SetTextL( *title );
  6071                         headingPane->SetTextL( *title );
  7501                         }
  6072                         }
  7622     }
  6193     }
  7623 
  6194 
  7624 
  6195 
  7625 TBool CAknCharMap::IsSupportCategoryButtonUi() const
  6196 TBool CAknCharMap::IsSupportCategoryButtonUi() const
  7626     {
  6197     {
  7627     return (iExtension)? iExtension->iHasCategoryButtonUi : EFalse;
  6198     return EFalse;
  7628     }
  6199     }
  7629 
  6200 
  7630 TBool CAknCharMap::IsJapaneseSctUi() const
  6201 TBool CAknCharMap::IsJapaneseSctUi() const
  7631     {
  6202     {
  7632     return (iExtension)? iExtension->iJapaneseSctUi : EFalse;
  6203     return EFalse;
  7633     }
  6204     }
  7634 
  6205 
  7635 // -----------------------------------------------------------------------------
  6206 // -----------------------------------------------------------------------------
  7636 // CAknCharMap::TitleWithSelectingSpecialChar()
  6207 // CAknCharMap::TitleWithSelectingSpecialChar()
  7637 // Return the title string with the selecting special characters
  6208 // Return the title string with the selecting special characters
  8232         
  6803         
  8233         SetCharacterCaseL(iSpecialCharCase);
  6804         SetCharacterCaseL(iSpecialCharCase);
  8234         
  6805         
  8235         SetSmileyAnimationActivityInCurrentPageL(ETrue);
  6806         SetSmileyAnimationActivityInCurrentPageL(ETrue);
  8236         
  6807         
  8237         CAknSctTableNavi* tableNavi = Extension()->iTableNavi;
  6808         CAknSctPageNavi* pageNavi = Extension()->iPageNavi;
  8238         if(tableNavi)
  6809         if(pageNavi)
  8239             {
  6810             {
  8240             tableNavi->UpdateNextTableButtonL();
  6811             pageNavi->UpdateNextTableButtonL();
  8241             }
  6812             }
  8242 
  6813 
  8243         DrawNow();
  6814         DrawNow();
  8244         
  6815         
  8245         return ETrue;
  6816         return ETrue;