uifw/AvKon/src/AknCharMap.cpp
branchRCL_3
changeset 15 c52421ed5f07
parent 12 941195f2d488
child 18 fcdfafb36fe7
equal deleted inserted replaced
13:a8834a2e9a96 15:c52421ed5f07
   646         }
   646         }
   647     return response;
   647     return response;
   648     }
   648     }
   649 
   649 
   650 TBool CAknSctPageNavi::CalcNextStep( TUint aKey, TInt& aX, TInt& aY )
   650 TBool CAknSctPageNavi::CalcNextStep( TUint aKey, TInt& aX, TInt& aY )
   651 	{
   651     {
   652 	TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
   652     TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
   653 	TBool mirrored = AknLayoutUtils::LayoutMirrored();
   653     TBool mirrored = AknLayoutUtils::LayoutMirrored();
   654 	TBool emotionEnabled = iExtension->IsEmotionEnabled();
   654     TBool emotionEnabled = iExtension->IsEmotionEnabled();
   655 	TInt scPages = iCharMap->PageCount();
   655     TInt scPages = iCharMap->PageCount();
   656 	
   656     
   657 	aX = 0;
   657     aX = 0;
   658 	aY = 0;
   658     aY = 0;
   659 	TInt xOffset = 0;
   659     TInt xOffset = 0;
   660 	TInt yOffset = 0;
   660     TInt yOffset = 0;
   661 	
   661     
   662 	// Simplify key events to two variants
   662     // Simplify key events to two variants
   663 	switch ( aKey )
   663     switch ( aKey )
   664 		{
   664         {
   665         case EKeyLeftArrow:
   665         case EKeyLeftArrow:
   666         case '4':
   666         case '4':
   667         	{
   667             {
   668         	xOffset = -1;
   668             xOffset = -1;
   669         	}
   669             }
   670         	break;
   670             break;
   671         case EKeyRightArrow:
   671         case EKeyRightArrow:
   672         case '6':
   672         case '6':
   673         	{
   673             {
   674         	xOffset = 1;
   674             xOffset = 1;
   675         	}
   675             }
   676         	break;
   676             break;
   677         case EKeyDownArrow:
   677         case EKeyDownArrow:
   678         case '8':
   678         case '8':
   679         	{
   679             {
   680         	yOffset = 1;
   680             yOffset = 1;
   681         	}
   681             }
   682         	break;
   682             break;
   683         case EKeyUpArrow:
   683         case EKeyUpArrow:
   684         case '2':
   684         case '2':
   685         	{
   685             {
   686         	yOffset = -1;
   686             yOffset = -1;
   687         	}
   687             }
   688         	break;
   688             break;
   689         default:
   689         default:
   690         	break;
   690             break;
   691 		}
   691         }
   692 
   692 
   693 	TInt runtimeIndex = iButtonIndex;
   693     TInt runtimeIndex = iButtonIndex;
   694 	if ( !emotionEnabled )
   694     if ( !emotionEnabled )
   695         {
   695         {
   696 	    // SC/Emotion unabled, button regrouped!
   696         // SC/Emotion unabled, button regrouped!
   697         if ( ( mirrored && iButtonIndex == EAknSctPageNaviPrevPage && xOffset != 1 )
   697         if ( ( mirrored && iButtonIndex == EAknSctPageNaviPrevPage && xOffset != 1 )
   698           || ( !mirrored && iButtonIndex == EAknSctPageNaviNextPage && xOffset != -1) )
   698           || ( !mirrored && iButtonIndex == EAknSctPageNaviNextPage && xOffset != -1) )
   699         	{
   699             {
   700             runtimeIndex = iExtension->IsShowingEmotion()?EAknSctTableNaviSpecialChar:EAknSctTableNaviEmotion;
   700             runtimeIndex = iExtension->IsShowingEmotion()?EAknSctTableNaviSpecialChar:EAknSctTableNaviEmotion;
   701         	}
   701             }
   702         }
   702         }
   703     // calculate when moving from PageNavi to grid, the column position
   703     // calculate when moving from PageNavi to grid, the column position
   704     switch ( runtimeIndex ) 
   704     switch ( runtimeIndex ) 
   705     	{
   705         {
   706     	case EAknSctTableNaviExit:
   706         case EAknSctTableNaviExit:
   707     		{
   707             {
   708     		aX = 0;
   708             aX = 0;
   709             if ( ( !mirrored && xOffset == -1 ) || ( mirrored && xOffset == 1 ) )
   709             if ( ( !mirrored && xOffset == -1 ) || ( mirrored && xOffset == 1 ) )
   710             	{
   710                 {
   711                 // Grid end
   711                 // Grid end
   712                 aY = iCharMap->ColMax(0);
   712                 aY = iCharMap->ColMax(0);
   713                 aX = iCharMap->RowMax( aY );
   713                 aX = iCharMap->RowMax( aY );
   714                 return ETrue;
   714                 return ETrue;
   715             	}
   715                 }
   716             else if ( mirrored && xOffset == -1 && scPages >= 2 )
   716             else if ( mirrored && xOffset == -1 && scPages >= 2 )
   717             	{
   717                 {
   718                 xOffset = EAknSctPageNaviNextPage;
   718                 xOffset = EAknSctPageNaviNextPage;
   719             	}
   719                 }
   720             else if ( scPages < 2 
   720             else if ( scPages < 2 
   721                     && ( ( !mirrored && xOffset == 1 ) || ( mirrored && xOffset == -1 ) ) )
   721                     && ( ( !mirrored && xOffset == 1 ) || ( mirrored && xOffset == -1 ) ) )
   722                 {
   722                 {
   723                 if ( !emotionEnabled )
   723                 if ( !emotionEnabled )
   724                     {
   724                     {
   731                     {
   731                     {
   732                     xOffset = LastButton();
   732                     xOffset = LastButton();
   733                     }
   733                     }
   734                 }
   734                 }
   735             else
   735             else
   736             	{
   736                 {
   737                 xOffset = EAknSctTableNaviExit + xOffset;
   737                 xOffset = EAknSctTableNaviExit + xOffset;
   738             	}
   738                 }
   739     		}
   739             }
   740     		break;
   740             break;
   741     	case EAknSctPageNaviPrevPage:
   741         case EAknSctPageNaviPrevPage:
   742     		{
   742             {
   743     		aX = mirrored ? iCharMap->MaxCols()-2 : 1;
   743             aX = mirrored ? iCharMap->MaxCols()-2 : 1;
   744     		if ( mirrored && xOffset == -1 )
   744             if ( mirrored && xOffset == -1 )
   745     			{
   745                 {
   746     		    xOffset = LastButton();
   746                 xOffset = LastButton();
   747     			}
   747                 }
   748     		else
   748             else
   749     			{
   749                 {
   750     		    xOffset = xOffset + EAknSctPageNaviPrevPage;
   750                 xOffset = xOffset + EAknSctPageNaviPrevPage;
   751     			}
   751                 }
   752     		}
   752             }
   753     		break;
   753             break;
   754     	case EAknSctPageNaviNextPage:
   754         case EAknSctPageNaviNextPage:
   755     		{
   755             {
   756     		aX = mirrored ? 1 : iCharMap->MaxCols()-2;
   756             aX = mirrored ? 1 : iCharMap->MaxCols()-2;
   757     		if ( mirrored && xOffset == 1 )
   757             if ( mirrored && xOffset == 1 )
   758     			{
   758                 {
   759     		    xOffset = 0;
   759                 xOffset = 0;
   760     			}
   760                 }
   761     		else if ( !mirrored && xOffset == 1 )
   761             else if ( !mirrored && xOffset == 1 )
   762     			{
   762                 {
   763     		    xOffset = LastButton();
   763                 xOffset = LastButton();
   764     			}
   764                 }
   765     		else
   765             else
   766     			{
   766                 {
   767     		    xOffset = EAknSctPageNaviNextPage + xOffset;
   767                 xOffset = EAknSctPageNaviNextPage + xOffset;
   768     			}
   768                 }
   769     		}
   769             }
   770     		break;
   770             break;
   771     	case EAknSctTableNaviSpecialChar:
   771         case EAknSctTableNaviSpecialChar:
   772     	case EAknSctTableNaviEmotion:
   772         case EAknSctTableNaviEmotion:
   773     		{
   773             {
   774     		aX = iCharMap->MaxCols()-1;
   774             aX = iCharMap->MaxCols()-1;
   775             if ( ( !mirrored && xOffset == 1 ) || ( mirrored && xOffset == -1 ) )
   775             if ( ( !mirrored && xOffset == 1 ) || ( mirrored && xOffset == -1 ) )
   776             	{
   776                 {
   777                 // Grid start
   777                 // Grid start
   778                 aX = 0;
   778                 aX = 0;
   779                 aY = iCharMap->ColMin( aX );
   779                 aY = iCharMap->ColMin( aX );
   780                 return ETrue;
   780                 return ETrue;
   781                 }
   781                 }
   783                     && ( ( !mirrored && xOffset == -1 ) || ( mirrored && xOffset == 1 ) ) )
   783                     && ( ( !mirrored && xOffset == -1 ) || ( mirrored && xOffset == 1 ) ) )
   784                 {
   784                 {
   785                 xOffset = EAknSctTableNaviExit;
   785                 xOffset = EAknSctTableNaviExit;
   786                 }
   786                 }
   787             else if ( mirrored && xOffset == 1 )
   787             else if ( mirrored && xOffset == 1 )
   788             	{
   788                 {
   789                 xOffset = EAknSctPageNaviPrevPage;
   789                 xOffset = EAknSctPageNaviPrevPage;
   790             	}
   790                 }
   791             else
   791             else
   792             	{
   792                 {
   793                 xOffset = EAknSctPageNaviNextPage;
   793                 xOffset = EAknSctPageNaviNextPage;
   794             	}
   794                 }
   795     		}
   795             }
   796     		break;
   796             break;
   797     	default:
   797         default:
   798     		break;
   798             break;
   799     	}
   799         }
   800     
   800     
   801     if ( yOffset == 1 )
   801     if ( yOffset == 1 )
   802     	{
   802         {
   803         // DOWN
   803         // DOWN
   804         aY = iCharMap->ColMin( aX );
   804         aY = iCharMap->ColMin( aX );
   805         return ETrue;
   805         return ETrue;
   806     	}
   806         }
   807     else if ( yOffset == -1 )
   807     else if ( yOffset == -1 )
   808     	{
   808         {
   809         // and UP
   809         // and UP
   810         aY = iCharMap->ColMax( aX );
   810         aY = iCharMap->ColMax( aX );
   811         return ETrue;
   811         return ETrue;
   812     	}
   812         }
   813 
   813 
   814     // Return False means it's internal moving focus within Page Navi
   814     // Return False means it's internal moving focus within Page Navi
   815     aX = xOffset;
   815     aX = xOffset;
   816     aY = 0;
   816     aY = 0;
   817     return EFalse;
   817     return EFalse;
   818 	}
   818     }
   819 
   819 
   820 TBool CAknSctPageNavi::IsNextButton() const
   820 TBool CAknSctPageNavi::IsNextButton() const
   821     {
   821     {
   822     if (iButtonIndex < iButtonArray.Count() && iButtonArray[iButtonIndex])
   822     if (iButtonIndex < iButtonArray.Count() && iButtonArray[iButtonIndex])
   823         {
   823         {
   836         TResourceReader oneButtonReader;
   836         TResourceReader oneButtonReader;
   837         iCoeEnv->CreateResourceReaderLC(oneButtonReader, resId);
   837         iCoeEnv->CreateResourceReaderLC(oneButtonReader, resId);
   838         CAknSctNaviButton* buttonObj =
   838         CAknSctNaviButton* buttonObj =
   839             CAknSctNaviButton::NewL(*this, buttonId, oneButtonReader);
   839             CAknSctNaviButton::NewL(*this, buttonId, oneButtonReader);
   840         buttonObj->iButtonControl->SetObserver(this); // for handling control events.
   840         buttonObj->iButtonControl->SetObserver(this); // for handling control events.
   841         iButtonArray.Append(buttonObj);
   841         CleanupStack::PushL( buttonObj );
       
   842         iButtonArray.AppendL(buttonObj);
       
   843         CleanupStack::Pop( buttonObj );
   842         CleanupStack::PopAndDestroy(); // oneButtonReader
   844         CleanupStack::PopAndDestroy(); // oneButtonReader
   843         }
   845         }
   844     iTitle = new (ELeave) CEikLabel;
   846     iTitle = new (ELeave) CEikLabel;
   845     }
   847     }
   846 
   848 
   980     TBool mirrored = AknLayoutUtils::LayoutMirrored();
   982     TBool mirrored = AknLayoutUtils::LayoutMirrored();
   981     CAknSctNaviButton* buttonObj;
   983     CAknSctNaviButton* buttonObj;
   982     TRect rect;
   984     TRect rect;
   983 
   985 
   984     if ( iExtension )
   986     if ( iExtension )
   985     	{
   987         {
   986         emotionEnabled = iExtension->IsEmotionEnabled();
   988         emotionEnabled = iExtension->IsEmotionEnabled();
   987     	}
   989         }
   988     
   990     
   989     // Prev button
   991     // Prev button
   990     buttonObj = iButtonArray[1];
   992     buttonObj = iButtonArray[1];
   991     buttonObj->iButtonControl->SetButtonFlags(0);
   993     buttonObj->iButtonControl->SetButtonFlags(0);
   992     TInt col = 0;
   994     TInt col = 0;
   993     if ( !landScape )
   995     if ( !landScape )
   994     	{
   996         {
   995         col = mirrored ? ( !emotionEnabled?4:3 ) : 1;
   997         col = mirrored ? ( !emotionEnabled?4:3 ) : 1;
   996     	}
   998         }
   997     else
   999     else
   998     	{
  1000         {
   999         col = mirrored ? ( !emotionEnabled?6:5 ) : 1;
  1001         col = mirrored ? ( !emotionEnabled?6:5 ) : 1;
  1000     	}
  1002         }
  1001     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
  1003     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
  1002     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
  1004     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
  1003     rect = buttonLayRect.Rect();
  1005     rect = buttonLayRect.Rect();
  1004     buttonObj->iButtonControl->SetRect(rect);
  1006     buttonObj->iButtonControl->SetRect(rect);
  1005     buttonObj->iButtonControl->SetHighlightRect(rect);
  1007     buttonObj->iButtonControl->SetHighlightRect(rect);
  1012     
  1014     
  1013     // Next button
  1015     // Next button
  1014     buttonObj = iButtonArray[2];
  1016     buttonObj = iButtonArray[2];
  1015     buttonObj->iButtonControl->SetButtonFlags(0);
  1017     buttonObj->iButtonControl->SetButtonFlags(0);
  1016     if ( !landScape )
  1018     if ( !landScape )
  1017     	{
  1019         {
  1018         col = mirrored ? 1 : ( !emotionEnabled?4:3 );
  1020         col = mirrored ? 1 : ( !emotionEnabled?4:3 );
  1019     	}
  1021         }
  1020     else
  1022     else
  1021     	{
  1023         {
  1022         col = mirrored ? 1 : ( !emotionEnabled?6:5 );
  1024         col = mirrored ? 1 : ( !emotionEnabled?6:5 );
  1023     	}
  1025         }
  1024     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
  1026     pageButtonLayRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::cell_graphic2_control_pane(cellVar,col) );
  1025     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
  1027     buttonLayRect.LayoutRect( pageButtonLayRect.Rect(), AknLayoutScalable_Avkon::bg_button_pane_cp05(bgVar));
  1026     rect = buttonLayRect.Rect();
  1028     rect = buttonLayRect.Rect();
  1027     buttonObj->iButtonControl->SetRect(rect);
  1029     buttonObj->iButtonControl->SetRect(rect);
  1028     buttonObj->iButtonControl->SetHighlightRect(rect);
  1030     buttonObj->iButtonControl->SetHighlightRect(rect);
  1118     return this;
  1120     return this;
  1119     }
  1121     }
  1120 
  1122 
  1121 TBool CAknSctPageNavi::EnterControl(TInt aX, TInt /*aY*/)
  1123 TBool CAknSctPageNavi::EnterControl(TInt aX, TInt /*aY*/)
  1122     {
  1124     {
  1123 	// Note, the button index is fixed on spite of mirrored case
  1125     // Note, the button index is fixed on spite of mirrored case
  1124     if (IsVisible())
  1126     if (IsVisible())
  1125         {
  1127         {
  1126         if ((aX >= 0) && (aX < iButtonArray.Count()))
  1128         if ((aX >= 0) && (aX < iButtonArray.Count()))
  1127             {
  1129             {
  1128             CAknSctNaviButton* buttonObj;
  1130             CAknSctNaviButton* buttonObj;
  1149     }
  1151     }
  1150 
  1152 
  1151 void CAknSctPageNavi::MoveFocus(TBool aInternalMove, TInt aX, TInt aY )
  1153 void CAknSctPageNavi::MoveFocus(TBool aInternalMove, TInt aX, TInt aY )
  1152     {
  1154     {
  1153     if ( aInternalMove )
  1155     if ( aInternalMove )
  1154     	{
  1156         {
  1155         EnterControl( aX, 0 );
  1157         EnterControl( aX, 0 );
  1156     	}
  1158         }
  1157     else
  1159     else
  1158     	{
  1160         {
  1159         if (iExtension->EnterControl( aX, aY ) )
  1161         if (iExtension->EnterControl( aX, aY ) )
  1160             {
  1162             {
  1161             LeaveControl();
  1163             LeaveControl();
  1162             }
  1164             }
  1163     	}
  1165         }
  1164     }
  1166     }
  1165 
  1167 
  1166 TBool CAknSctPageNavi::LeaveControl()
  1168 TBool CAknSctPageNavi::LeaveControl()
  1167     {
  1169     {
  1168     for (TInt i = 0; i < iButtonArray.Count(); i++ )
  1170     for (TInt i = 0; i < iButtonArray.Count(); i++ )
  1172     return ETrue;
  1174     return ETrue;
  1173     }
  1175     }
  1174 
  1176 
  1175 TBool CAknSctPageNavi::ExitWithKey(TInt /*aKeycode*/)
  1177 TBool CAknSctPageNavi::ExitWithKey(TInt /*aKeycode*/)
  1176     {
  1178     {
  1177     return EFalse;
  1179     if (iButtonArray[iButtonIndex]->iButtonId != EAknSctTableNaviExit)
       
  1180         {
       
  1181         return EFalse;
       
  1182         }
       
  1183     else
       
  1184         {
       
  1185         return ETrue;
       
  1186         }
  1178     }
  1187     }
  1179 
  1188 
  1180 
  1189 
  1181 void CAknSctPageNavi::TableExitL()
  1190 void CAknSctPageNavi::TableExitL()
  1182     {
  1191     {
  1241     for (TInt index(1); index<iButtonArray.Count(); index++)
  1250     for (TInt index(1); index<iButtonArray.Count(); index++)
  1242         {
  1251         {
  1243         CAknSctNaviButton* buttonObj = iButtonArray[index];
  1252         CAknSctNaviButton* buttonObj = iButtonArray[index];
  1244         if ( index == EAknSctPageNaviPrevPage 
  1253         if ( index == EAknSctPageNaviPrevPage 
  1245                || index == EAknSctPageNaviNextPage )
  1254                || index == EAknSctPageNaviNextPage )
  1246         	{
  1255             {
  1247             // No need to display Prev/Next
  1256             // No need to display Prev/Next
  1248             if ( iCharMap->PageCount() < 2 )
  1257             if ( iCharMap->PageCount() < 2 )
  1249                 {
  1258                 {
  1250                 buttonObj->SetEnabled(EFalse);
  1259                 buttonObj->SetEnabled(EFalse);
  1251                 }
  1260                 }
  1252             continue;
  1261             continue;
  1253         	}
  1262             }
  1254         if (iCharMap->TableCount() > 1)
  1263         if (iCharMap->TableCount() > 1)
  1255             {
  1264             {
  1256             switch (iCharMap->NextTableCase())
  1265             switch (iCharMap->NextTableCase())
  1257                 {
  1266                 {
  1258                 case EAknCharMapTableSpecialChar:
  1267                 case EAknCharMapTableSpecialChar:
  1289 
  1298 
  1290 TInt CAknSctPageNavi::LastButton() const
  1299 TInt CAknSctPageNavi::LastButton() const
  1291     {
  1300     {
  1292     TBool emotionEnable = iExtension->IsEmotionEnabled();
  1301     TBool emotionEnable = iExtension->IsEmotionEnabled();
  1293     if ( emotionEnable )
  1302     if ( emotionEnable )
  1294     	{
  1303         {
  1295         return iExtension->IsShowingEmotion()?EAknSctTableNaviSpecialChar:EAknSctTableNaviEmotion;
  1304         return iExtension->IsShowingEmotion()?EAknSctTableNaviSpecialChar:EAknSctTableNaviEmotion;
  1296     	}
  1305         }
  1297     else if ( iCharMap->PageCount() < 2 && !emotionEnable )
  1306     else if ( iCharMap->PageCount() < 2 && !emotionEnable )
  1298         {
  1307         {
  1299         // Only one page, must have no SC/Emotion also, left Exit only.
  1308         // Only one page, must have no SC/Emotion also, left Exit only.
  1300         return EAknSctTableNaviExit;
  1309         return EAknSctTableNaviExit;
  1301         }
  1310         }
  1302     else
  1311     else
  1303     	{
  1312         {
  1304         // emotion doesn't support, no SC/Emotion icon then
  1313         // emotion doesn't support, no SC/Emotion icon then
  1305         TBool mirrored = AknLayoutUtils::LayoutMirrored();
  1314         TBool mirrored = AknLayoutUtils::LayoutMirrored();
  1306         return mirrored ? EAknSctPageNaviPrevPage : EAknSctPageNaviNextPage;
  1315         return mirrored ? EAknSctPageNaviPrevPage : EAknSctPageNaviNextPage;
  1307     	}
  1316         }
  1308     }
  1317     }
  1309 
  1318 
  1310 // ----------------------------------------------------------------------------
  1319 // ----------------------------------------------------------------------------
  1311 // Category button class implementation
  1320 // Category button class implementation
  1312 // ----------------------------------------------------------------------------
  1321 // ----------------------------------------------------------------------------
  1487     return charsSmiley;
  1496     return charsSmiley;
  1488     }
  1497     }
  1489 
  1498 
  1490 void CAknCharMapExtension::LoadEmotionTumbnails(const TDesC& aChars)
  1499 void CAknCharMapExtension::LoadEmotionTumbnails(const TDesC& aChars)
  1491     {
  1500     {
  1492     iSmileyModel->LoadStillImagesL(aChars);
  1501     //If emotion tumbbails can't be load, 
       
  1502     // no emotion tumbnail will be dispalyed.
       
  1503     TRAP_IGNORE( iSmileyModel->LoadStillImagesL(aChars) );
  1493     }
  1504     }
  1494 
  1505 
  1495 void CAknCharMapExtension::SetEmotionSize(const TSize& aSize)
  1506 void CAknCharMapExtension::SetEmotionSize(const TSize& aSize)
  1496     {
  1507     {
  1497     TInt unit = Min(aSize.iWidth, aSize.iHeight);
  1508     TInt unit = Min(aSize.iWidth, aSize.iHeight);
  1823         return;
  1834         return;
  1824 
  1835 
  1825     iExtension->iFlags = 0x00;
  1836     iExtension->iFlags = 0x00;
  1826     iExtension->iFocusHandler = iExtension;
  1837     iExtension->iFocusHandler = iExtension;
  1827     iExtension->SetCharMapControl(this);
  1838     iExtension->SetCharMapControl(this);
  1828 	
  1839     
  1829     if ( iExtension->iSingleClickEnabled )
  1840     if ( iExtension->iSingleClickEnabled )
  1830         {
  1841         {
  1831         iExtension->iHighlightVisible = EFalse;
  1842         iExtension->iHighlightVisible = EFalse;
  1832         }
  1843         }
  1833     
  1844     
  2341         {
  2352         {
  2342         return EKeyWasConsumed;
  2353         return EKeyWasConsumed;
  2343         }
  2354         }
  2344     
  2355     
  2345     TUint code=aKeyEvent.iCode;
  2356     TUint code=aKeyEvent.iCode;
  2346 	
  2357     
  2347     // First key event enables the highlight
  2358     // First key event enables the highlight
  2348     if ( iExtension->iSingleClickEnabled && !iExtension->iHighlightVisible )
  2359     if ( iExtension->iSingleClickEnabled && !iExtension->iHighlightVisible )
  2349         {
  2360         {
  2350         if ( code == EKeyUpArrow || code == EKeyDownArrow || 
  2361         if ( code == EKeyUpArrow || code == EKeyDownArrow || 
  2351              code == EKeyLeftArrow || code == EKeyRightArrow || 
  2362              code == EKeyLeftArrow || code == EKeyRightArrow || 
  2373                         // western, move left from first one in grid, focus pageNavi last button
  2384                         // western, move left from first one in grid, focus pageNavi last button
  2374                         if ( iExtension->iPageNavi )
  2385                         if ( iExtension->iPageNavi )
  2375                             {
  2386                             {
  2376                             TInt maxButt = iExtension->iPageNavi->LastButton();
  2387                             TInt maxButt = iExtension->iPageNavi->LastButton();
  2377                             if ( iExtension->iPageNavi->EnterControl( maxButt,0 ) )
  2388                             if ( iExtension->iPageNavi->EnterControl( maxButt,0 ) )
  2378                             	{
  2389                                 {
  2379                                 LeaveControl();
  2390                                 LeaveControl();
  2380                                 break;
  2391                                 break;
  2381                             	}
  2392                                 }
  2382                             }
  2393                             }
  2383                         }
  2394                         }
  2384                     }
  2395                     }
  2385                 else
  2396                 else
  2386                     {
  2397                     {
  2457                             }
  2468                             }
  2458                         else if ( iCursorPos.iX == MaxCols() - 2 )
  2469                         else if ( iCursorPos.iX == MaxCols() - 2 )
  2459                             {
  2470                             {
  2460                             // a bit complex as unable-emotion SCT has no SC/Emotion icon
  2471                             // a bit complex as unable-emotion SCT has no SC/Emotion icon
  2461                             if ( iExtension->IsEmotionEnabled() )
  2472                             if ( iExtension->IsEmotionEnabled() )
  2462                             	{
  2473                                 {
  2463                                 aX = iIsMirrored? 1 : 2;
  2474                                 aX = iIsMirrored? 1 : 2;
  2464                             	}
  2475                                 }
  2465                             else
  2476                             else
  2466                             	{
  2477                                 {
  2467                                 aX = -1;
  2478                                 aX = -1;
  2468                             	}
  2479                                 }
  2469                             }
  2480                             }
  2470                         else if (iCursorPos.iX == 1 )  
  2481                         else if (iCursorPos.iX == 1 )  
  2471                             {
  2482                             {
  2472                             aX = iIsMirrored? 2 : 1;
  2483                             aX = iIsMirrored? 2 : 1;
  2473                             }
  2484                             }
  2475                             {
  2486                             {
  2476                             // first button in PageNavi
  2487                             // first button in PageNavi
  2477                             aX = 0;
  2488                             aX = 0;
  2478                             }
  2489                             }
  2479                         else
  2490                         else
  2480                         	{
  2491                             {
  2481                             aX = -1;
  2492                             aX = -1;
  2482                         	}
  2493                             }
  2483                         if ( iExtension->iPageNavi->EnterControl( aX,0 ) )
  2494                         if ( iExtension->iPageNavi->EnterControl( aX,0 ) )
  2484                             {
  2495                             {
  2485                             LeaveControl();
  2496                             LeaveControl();
  2486                             break;
  2497                             break;
  2487                             }
  2498                             }
  2499             if (AknLayoutUtils::PenEnabled())
  2510             if (AknLayoutUtils::PenEnabled())
  2500                 {
  2511                 {
  2501                 if (iCursorPos.iY == ColMax(iCursorPos.iX))
  2512                 if (iCursorPos.iY == ColMax(iCursorPos.iX))
  2502                     {
  2513                     {
  2503                     if (  iExtension->iPageNavi )
  2514                     if (  iExtension->iPageNavi )
  2504                     	{
  2515                         {
  2505                         TInt aX = 0;
  2516                         TInt aX = 0;
  2506                     
  2517                     
  2507                         if ( iCursorPos.iX == MaxCols() - 1 )
  2518                         if ( iCursorPos.iX == MaxCols() - 1 )
  2508                             {
  2519                             {
  2509                             aX = iExtension->iPageNavi->LastButton();
  2520                             aX = iExtension->iPageNavi->LastButton();
  2528                             {
  2539                             {
  2529                             // default: first button in PageNavi
  2540                             // default: first button in PageNavi
  2530                             aX = 0;
  2541                             aX = 0;
  2531                             }
  2542                             }
  2532                         else
  2543                         else
  2533                         	{
  2544                             {
  2534                             aX = -1;
  2545                             aX = -1;
  2535                         	}
  2546                             }
  2536                         if ( iExtension->iPageNavi->EnterControl( aX,0 ) )
  2547                         if ( iExtension->iPageNavi->EnterControl( aX,0 ) )
  2537                             {
  2548                             {
  2538                             LeaveControl();
  2549                             LeaveControl();
  2539                             break;
  2550                             break;
  2540                             }
  2551                             }
  2541                     	}
  2552                         }
  2542                     // cell is at bottom row
  2553                     // cell is at bottom row
  2543                     if (iCursorPos.iX > RowMax(ColMax(0)))
  2554                     if (iCursorPos.iX > RowMax(ColMax(0)))
  2544                         {
  2555                         {
  2545                         // Grid last item.
  2556                         // Grid last item.
  2546                         EnterControl(RowMax(ColMax(0)), ColMax(0));
  2557                         EnterControl(RowMax(ColMax(0)), ColMax(0));
  2750         // Append right amount of recent characters due to different layout.
  2761         // Append right amount of recent characters due to different layout.
  2751         if (recentWasSetBeforeSwitch) AppendRecentCharL();
  2762         if (recentWasSetBeforeSwitch) AppendRecentCharL();
  2752 
  2763 
  2753         // Sets the character case because the buffer content may have changed.
  2764         // Sets the character case because the buffer content may have changed.
  2754         SetCharacterCaseL(iSpecialCharCase);
  2765         SetCharacterCaseL(iSpecialCharCase);
  2755 		
  2766         
  2756         SetSmileyAnimationActivityInCurrentPageL(ETrue);
  2767         SetSmileyAnimationActivityInCurrentPageL(ETrue);
  2757 		
  2768         
  2758         TInt cursorIndexAfterSwitch;
  2769         TInt cursorIndexAfterSwitch;
  2759         if ( !iExtension->iKeyBrdEvent )
  2770         if ( !iExtension->iKeyBrdEvent )
  2760             {
  2771             {
  2761             cursorIndexAfterSwitch = cursorIndexBeforeSwitch;
  2772             cursorIndexAfterSwitch = cursorIndexBeforeSwitch;
  2762             }
  2773             }
  2856         }
  2867         }
  2857     
  2868     
  2858     else if(aType == KAknMessageFocusLost) // focus lost
  2869     else if(aType == KAknMessageFocusLost) // focus lost
  2859         {
  2870         {
  2860         SetSmileyAnimationActivityInCurrentPageL(EFalse);
  2871         SetSmileyAnimationActivityInCurrentPageL(EFalse);
  2861 		
  2872         
  2862     	if ( iExtension->iHighlightVisible )
  2873         if ( iExtension->iHighlightVisible )
  2863         	{
  2874             {
  2864         	iExtension->iHighlightVisible = EFalse;
  2875             iExtension->iHighlightVisible = EFalse;
  2865         	DrawCursor();
  2876             DrawCursor();
  2866         	}
  2877             }
  2867     	}
  2878         }
  2868     }
  2879     }
  2869 
  2880 
  2870 void CAknCharMap::EnableNavigationButtonsL()
  2881 void CAknCharMap::EnableNavigationButtonsL()
  2871     {
  2882     {
  2872     if ( iExtension )
  2883     if ( iExtension )
  3048     if ( !Extension()->iMenuSct )
  3059     if ( !Extension()->iMenuSct )
  3049         {
  3060         {
  3050         // 1) Draw the background
  3061         // 1) Draw the background
  3051         // Check if we got an offscreen bitmap allocated for skin background and
  3062         // Check if we got an offscreen bitmap allocated for skin background and
  3052         // there is bitmap background in the current skin.
  3063         // there is bitmap background in the current skin.
  3053 		if( CAknEnv::Static()->TransparencyEnabled() )
  3064         if( CAknEnv::Static()->TransparencyEnabled() )
  3054 			{
  3065             {
  3055 			TRegionFix<10> clipReg;
  3066             TRegionFix<10> clipReg;
  3056 			clipReg.AddRect(rect);
  3067             clipReg.AddRect(rect);
  3057 
  3068 
  3058 			if ( iFirstVisibleRow == 0 && iSetRecentSct )
  3069             if ( iFirstVisibleRow == 0 && iSetRecentSct )
  3059 				{
  3070                 {
  3060 				TPoint pos = iGridTopLeft;
  3071                 TPoint pos = iGridTopLeft;
  3061 				TSize size(iGridItemWidth*iMaxColumns+1, iGridItemHeight);
  3072                 TSize size(iGridItemWidth*iMaxColumns+1, iGridItemHeight);
  3062 				if(iIsMirrored)
  3073                 if(iIsMirrored)
  3063 				    {
  3074                     {
  3064                     pos.iX += iGridItemWidth - size.iWidth;
  3075                     pos.iX += iGridItemWidth - size.iWidth;
  3065 				    }
  3076                     }
  3066 				// eliminate the overlap area between menu sct and the first menu item.
  3077                 // eliminate the overlap area between menu sct and the first menu item.
  3067 				if ( Extension()->iMenuSct )
  3078                 if ( Extension()->iMenuSct )
  3068 					{
  3079                     {
  3069                     size.iHeight--;
  3080                     size.iHeight--;
  3070 					}
  3081                     }
  3071 				clipReg.SubRect(TRect(pos,size));
  3082                 clipReg.SubRect(TRect(pos,size));
  3072 				}
  3083                 }
  3073 			
  3084             
  3074 			// Take scroll bar out of clip region
  3085             // Take scroll bar out of clip region
  3075 			if (iSBFrame)
  3086             if (iSBFrame)
  3076 				{
  3087                 {
  3077 				clipReg.SubRect(iSBFrame->GetScrollBarHandle(CEikScrollBar::EVertical)->Rect());
  3088                 clipReg.SubRect(iSBFrame->GetScrollBarHandle(CEikScrollBar::EVertical)->Rect());
  3078 				}
  3089                 }
  3079 
  3090 
  3080 			gc.SetClippingRegion(clipReg);
  3091             gc.SetClippingRegion(clipReg);
  3081 			}
  3092             }
  3082 		
  3093         
  3083 		AknsDrawUtils::Background( skin, cc, this, gc, rect,KAknsDrawParamNoClearUnderImage);
  3094         AknsDrawUtils::Background( skin, cc, this, gc, rect,KAknsDrawParamNoClearUnderImage);
  3084 		
  3095         
  3085 		if( CAknEnv::Static()->TransparencyEnabled() )
  3096         if( CAknEnv::Static()->TransparencyEnabled() )
  3086 			{
  3097             {
  3087 			gc.CancelClippingRegion();
  3098             gc.CancelClippingRegion();
  3088 			}
  3099             }
  3089 
  3100 
  3090         // 2) Draw the grid
  3101         // 2) Draw the grid
  3091 		gc.SetPenStyle(CGraphicsContext::ESolidPen);
  3102         gc.SetPenStyle(CGraphicsContext::ESolidPen);
  3092         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
  3103         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
  3093         gc.SetPenSize(TSize(1,1));
  3104         gc.SetPenSize(TSize(1,1));
  3094         DrawGrid(gc);
  3105         DrawGrid(gc);
  3095         }
  3106         }
  3096 
  3107 
  3114             if(!EmotionsAreAllReadyToDraw(charIndex, iMaxColumns)) break;
  3125             if(!EmotionsAreAllReadyToDraw(charIndex, iMaxColumns)) break;
  3115             }
  3126             }
  3116         
  3127         
  3117         // grid is focused and cursor pos is same with the current index.
  3128         // grid is focused and cursor pos is same with the current index.
  3118         if ( iExtension->iMenuSct )
  3129         if ( iExtension->iMenuSct )
  3119         	{
  3130             {
  3120             highlighted = iExtension->iMenuSctHighlighted && 
  3131             highlighted = iExtension->iMenuSctHighlighted && 
  3121                           (iExtension->iFocusHandler->FocusedControl()==this) && 
  3132                           (iExtension->iFocusHandler->FocusedControl()==this) && 
  3122                           (j==cursorPos);
  3133                           (j==cursorPos);
  3123         	}
  3134             }
  3124         else
  3135         else
  3125         	{
  3136             {
  3126         	highlighted = ((iExtension->iFocusHandler->FocusedControl()==this) && (j==cursorPos));
  3137             highlighted = ((iExtension->iFocusHandler->FocusedControl()==this) && (j==cursorPos));
  3127         	}
  3138             }
  3128         DrawItem(gc, CursorRect(j, charIndex), charIndex, highlighted, EFalse);
  3139         DrawItem(gc, CursorRect(j, charIndex), charIndex, highlighted, EFalse);
  3129         charIndex++;
  3140         charIndex++;
  3130         }
  3141         }
  3131     iDrawnBefore = ETrue;
  3142     iDrawnBefore = ETrue;
  3132     gc.DiscardFont();
  3143     gc.DiscardFont();
  3233     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
  3244     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
  3234 
  3245 
  3235     if( aHighlighted )
  3246     if( aHighlighted )
  3236         {
  3247         {
  3237         TRgb color = AKN_LAF_COLOR(210);
  3248         TRgb color = AKN_LAF_COLOR(210);
  3238 		
  3249         
  3239         if( !( iExtension->iFlags & EAknCharMapPressedDown ) 
  3250         if( !( iExtension->iFlags & EAknCharMapPressedDown ) 
  3240             || iExtension->iSingleClickEnabled )
  3251             || iExtension->iSingleClickEnabled )
  3241             {
  3252             {
  3242             AknsUtils::GetCachedColor( skin, 
  3253             AknsUtils::GetCachedColor( skin, 
  3243                     color, 
  3254                     color, 
  3244                     KAknsIIDQsnHighlightColors, 
  3255                     KAknsIIDQsnHighlightColors, 
  3245                     EAknsCIQsnHighlightColorsCG1 );
  3256                     EAknsCIQsnHighlightColorsCG1 );
  3246             }
  3257             }
  3247 			
  3258             
  3248         else
  3259         else
  3249             {
  3260             {
  3250             AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2 );
  3261             AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2 );
  3251             }
  3262             }
  3252         aGc.SetBrushColor(color);
  3263         aGc.SetBrushColor(color);
  4392     return result;
  4403     return result;
  4393     }
  4404     }
  4394 
  4405 
  4395 void CAknCharMap::CreateOffscreenBackgroundL()
  4406 void CAknCharMap::CreateOffscreenBackgroundL()
  4396     {
  4407     {
  4397 	
  4408     
  4398     }
  4409     }
  4399 
  4410 
  4400 TInt CAknCharMap::NextPageL()
  4411 TInt CAknCharMap::NextPageL()
  4401     {
  4412     {
  4402     SetSmileyAnimationActivityInCurrentPageL(EFalse);
  4413     SetSmileyAnimationActivityInCurrentPageL(EFalse);
  4540         }
  4551         }
  4541 
  4552 
  4542     // Draw the background of the item if requested
  4553     // Draw the background of the item if requested
  4543     else if ( aDrawBackground )
  4554     else if ( aDrawBackground )
  4544         {
  4555         {
  4545 		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
  4556         aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
  4546 		aGc.SetBrushColor(AKN_LAF_COLOR(0));
  4557         aGc.SetBrushColor(AKN_LAF_COLOR(0));
  4547 
  4558 
  4548 		TRect innerRect = aSctPosition;
  4559         TRect innerRect = aSctPosition;
  4549 		if (IsRecentChar(aCharIndex))
  4560         if (IsRecentChar(aCharIndex))
  4550 			{
  4561             {
  4551 			innerRect.Shrink(1,1);
  4562             innerRect.Shrink(1,1);
  4552 			}
  4563             }
  4553 		aGc.Clear( innerRect );
  4564         aGc.Clear( innerRect );
  4554         }
  4565         }
  4555     if (iPictoInterface->Interface()->IsPictograph((*iChars)[aCharIndex]))
  4566     if (iPictoInterface->Interface()->IsPictograph((*iChars)[aCharIndex]))
  4556         {
  4567         {
  4557         if (iExtension->iPictographsBufferGrouping)
  4568         if (iExtension->iPictographsBufferGrouping)
  4558             {
  4569             {
  4568         }
  4579         }
  4569     }
  4580     }
  4570 
  4581 
  4571 void CAknCharMap::DrawOffscreenBackgroundIfRequired() const
  4582 void CAknCharMap::DrawOffscreenBackgroundIfRequired() const
  4572     {
  4583     {
  4573 	
  4584     
  4574     }
  4585     }
  4575 
  4586 
  4576 EXPORT_C CCoeControl* CAknCharMap::ComponentControl(TInt aIndex) const
  4587 EXPORT_C CCoeControl* CAknCharMap::ComponentControl(TInt aIndex) const
  4577     {
  4588     {
  4578     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  4589     if (iSBFrame && iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
  5751     // If the row is empty, nothing to do
  5762     // If the row is empty, nothing to do
  5752     if (LengthOfRecentChar() == 0)
  5763     if (LengthOfRecentChar() == 0)
  5753         {
  5764         {
  5754         return;
  5765         return;
  5755         }
  5766         }
  5756 
  5767     // The "PlayAnimationL" in "SetSmileyAnimationActivityInCurrentPageL"
  5757     SetSmileyAnimationActivityInCurrentPageL(aHighlight);
  5768     // will leave. If we ignore it, just no animation is played.
       
  5769     TRAP_IGNORE( SetSmileyAnimationActivityInCurrentPageL(aHighlight) );
  5758     
  5770     
  5759     CWindowGc& gc = SystemGc();
  5771     CWindowGc& gc = SystemGc();
  5760     if( !CAknEnv::Static()->TransparencyEnabled() )
  5772     if( !CAknEnv::Static()->TransparencyEnabled() )
  5761         {
  5773         {
  5762         ActivateGc();
  5774         ActivateGc();
  5771         gc.DiscardFont();
  5783         gc.DiscardFont();
  5772         DeactivateGc();
  5784         DeactivateGc();
  5773         }
  5785         }
  5774     // Menu SCT is being used.
  5786     // Menu SCT is being used.
  5775     if ( Extension()->iMenuSct )
  5787     if ( Extension()->iMenuSct )
  5776     	{
  5788         {
  5777     	Extension()->iMenuSctHighlighted = aHighlight;
  5789         Extension()->iMenuSctHighlighted = aHighlight;
  5778     	}
  5790         }
  5779     }
  5791     }
  5780 // -----------------------------------------------------------------------------
  5792 // -----------------------------------------------------------------------------
  5781 // CAknCharMap::SetMenuSctRect()
  5793 // CAknCharMap::SetMenuSctRect()
  5782 // Sets the rect for menu SCT.
  5794 // Sets the rect for menu SCT.
  5783 // -----------------------------------------------------------------------------
  5795 // -----------------------------------------------------------------------------
  5945         iExtension->iFlags |= EAknCharMapCharsAllocated; // mark that iChars points to HBufC
  5957         iExtension->iFlags |= EAknCharMapCharsAllocated; // mark that iChars points to HBufC
  5946         }
  5958         }
  5947     
  5959     
  5948     iExtension->LoadEmotionTumbnails(*iChars);
  5960     iExtension->LoadEmotionTumbnails(*iChars);
  5949 
  5961 
  5950     SetSmileyAnimationActivityInCurrentPageL(ETrue);
  5962     // The "PlayAnimationL" in "SetSmileyAnimationActivityInCurrentPageL"
       
  5963     // will leave. If we ignore it, just no animation is played.
       
  5964     TRAP_IGNORE( SetSmileyAnimationActivityInCurrentPageL(ETrue) );
  5951     }
  5965     }
  5952 
  5966 
  5953 // -----------------------------------------------------------------------------
  5967 // -----------------------------------------------------------------------------
  5954 // CAknCharMap::CharacterCase()
  5968 // CAknCharMap::CharacterCase()
  5955 // Get current character case.
  5969 // Get current character case.
  6699 
  6713 
  6700 void CAknCharMap::SetSmileyAnimationActivityInCurrentPageL(TBool aIsActive)
  6714 void CAknCharMap::SetSmileyAnimationActivityInCurrentPageL(TBool aIsActive)
  6701     {
  6715     {
  6702     TInt begin = iFirstVisibleRow * iMaxColumns;
  6716     TInt begin = iFirstVisibleRow * iMaxColumns;
  6703     TInt end = iExtension->iMaxVisibleRows * iMaxColumns + begin;
  6717     TInt end = iExtension->iMaxVisibleRows * iMaxColumns + begin;
  6704     if(end > iChars->Length()) end = iChars->Length();
  6718     if( end > iChars->Length() ) 
  6705 
  6719         {
  6706     for(TInt i(begin); i<end; i++)
  6720         end = iChars->Length();
       
  6721         }
       
  6722 
       
  6723     for( TInt i(begin); i<end; i++ )
  6707         {
  6724         {
  6708         TChar code = (*iChars)[i];
  6725         TChar code = (*iChars)[i];
  6709         CAknSmileyIcon* icon = iExtension->EmotionIcon(code);
  6726         CAknSmileyIcon* icon = iExtension->EmotionIcon(code);
  6710         if(!icon) continue;
  6727         if( !icon ) 
  6711 
  6728             {
  6712         if((aIsActive) && 
  6729             continue;
  6713            (Extension()->IsShowingEmotion()||Extension()->iMenuSctHighlighted)
  6730             }
       
  6731 
       
  6732         if( ( aIsActive ) && 
       
  6733            ( Extension()->IsShowingEmotion() || Extension()->iMenuSctHighlighted) 
  6714            )
  6734            )
  6715             {
  6735             {
  6716             icon->PlayAnimationL(KAnimationRepeat, KAnimationDelay);
  6736             icon->PlayAnimationL( KAnimationRepeat, KAnimationDelay );
  6717             }
  6737             }
  6718         else
  6738         else
  6719             {
  6739             {
  6720             icon->StopAnimation();
  6740             icon->StopAnimation();
  6721             }
  6741             }