fep/aknfep/UiPlugins/AknFepUiInterface/AvkonImpl/src/AknFepUiAvkonCtrlPinyinPopup.cpp
branchRCL_3
changeset 56 8152b1f1763a
parent 50 5a1685599b76
equal deleted inserted replaced
50:5a1685599b76 56:8152b1f1763a
    43 #include "aknfepuilayoutdatamgr.h"
    43 #include "aknfepuilayoutdatamgr.h"
    44 #include <skinlayout.cdl.h>
    44 #include <skinlayout.cdl.h>
    45 
    45 
    46 #include "data_caging_path_literals.hrh"
    46 #include "data_caging_path_literals.hrh"
    47 
    47 
       
    48 _LIT(KFepUiControlsBitmapFile, "aknfepuictrls.mbm");
       
    49 
    48 CAknFepUICtrlPinyinPopup* CAknFepUICtrlPinyinPopup::NewL(RWindow& aParent, CAknFepUiLayoutDataMgr* aLafDataMgr )
    50 CAknFepUICtrlPinyinPopup* CAknFepUICtrlPinyinPopup::NewL(RWindow& aParent, CAknFepUiLayoutDataMgr* aLafDataMgr )
    49     {
    51     {
    50     CAknFepUICtrlPinyinPopup* self = new(ELeave) CAknFepUICtrlPinyinPopup( aLafDataMgr );
    52     CAknFepUICtrlPinyinPopup* self = new(ELeave) CAknFepUICtrlPinyinPopup( aLafDataMgr );
    51     CleanupStack::PushL(self);
    53     CleanupStack::PushL(self);
    52     self->ConstructL(aParent);
    54     self->ConstructL(aParent);
    58     {
    60     {
    59     iInputPaneArray.ResetAndDestroy();
    61     iInputPaneArray.ResetAndDestroy();
    60     iPages.Reset();
    62     iPages.Reset();
    61     delete iSpellingArray;
    63     delete iSpellingArray;
    62     delete iSpellingIndexArray;
    64     delete iSpellingIndexArray;
       
    65     delete iNaviArrowBitmapLeft;
       
    66     delete iNaviArrowBitmapLeftMask;
       
    67     delete iNaviArrowBitmapRight;
       
    68     delete iNaviArrowBitmapRightMask;
    63     delete iBgContext;
    69     delete iBgContext;
    64     delete iKeystrokeArray;
    70     delete iKeystrokeArray;
    65     delete iInEffectKeystrokeArray;
    71     delete iInEffectKeystrokeArray;
    66     delete iShowKeystrokeArray;
    72     delete iShowKeystrokeArray;
    67     delete iOptimizeSpelling;
    73     delete iOptimizeSpelling;
   205             } 
   211             } 
   206         
   212         
   207         TAknWindowLineLayout layoutEntryItem = 
   213         TAknWindowLineLayout layoutEntryItem = 
   208                 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutEntryItem));
   214                 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutEntryItem));
   209         TAknTextLineLayout entryTextLine = 
   215         TAknTextLineLayout entryTextLine = 
   210             CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EEEPTextLine));
   216             CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EEntryTextLayout));
   211         TInt layoutLinePrevLeft = 0;
   217         TInt layoutLinePrevLeft = 0;
   212         TInt layoutLinePrevWidth = 0;
   218         TInt layoutLinePrevWidth = 0;
   213 
   219 
   214         TAknLayoutRect layoutRectEntryItem;
   220         TAknLayoutRect layoutRectEntryItem;
   215         layoutRectEntryItem.LayoutRect(Rect(),layoutEntryItem);
   221         layoutRectEntryItem.LayoutRect(Rect(),layoutEntryItem);
   217     
   223     
   218         TAknLayoutText layoutText;
   224         TAknLayoutText layoutText;
   219         layoutText.LayoutText(rectEntryItem,entryTextLine);
   225         layoutText.LayoutText(rectEntryItem,entryTextLine);
   220         TRect rectText = layoutText.TextRect();
   226         TRect rectText = layoutText.TextRect();
   221         
   227         
   222         TInt rightLimit = rectText.iBr.iX;
   228         TInt rightLimit = iIndiFepArrowRight.Rect().iTl.iX;
   223         // value is 3 for 176*208 resolution
   229         // value is 3 for 176*208 resolution
   224         TInt distance = rectText.iTl.iX - rectEntryItem.iTl.iX + rectEntryItem.iBr.iX - rectText.iBr.iX;
   230         TInt distance = rectText.iTl.iX - rectEntryItem.iTl.iX + rectEntryItem.iBr.iX - rectText.iBr.iX;
   225         
   231         
   226         for(TInt i = 0;i < spellingLeftNum;i ++)
   232         for(TInt i = 0;i < spellingLeftNum;i ++)
   227             {
   233             {
   283         curPage.iStartIndex = index;
   289         curPage.iStartIndex = index;
   284         curPage.iEndIndex = index;
   290         curPage.iEndIndex = index;
   285         TInt spellingLeftNum = aCount - index > EMaxCandidates? EMaxCandidates:aCount - index;
   291         TInt spellingLeftNum = aCount - index > EMaxCandidates? EMaxCandidates:aCount - index;
   286  
   292  
   287         TAknWindowLineLayout layoutEntryItem = 
   293         TAknWindowLineLayout layoutEntryItem = 
   288                 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData( EInputLayout ));
   294                 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutEntryItem));
   289         TAknTextLineLayout entryTextLine = 
   295         TAknTextLineLayout entryTextLine = 
   290             CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EInputTextLayout ));
   296             CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EEntryTextLayout));
   291         TInt layoutLinePrevLeft = 0;
   297         TInt layoutLinePrevLeft = 0;
   292         TInt layoutLinePrevWidth = 0;
   298         TInt layoutLinePrevWidth = 0;
   293 
   299 
   294         TAknLayoutRect layoutRectEntryItem;
   300         TAknLayoutRect layoutRectEntryItem;
   295         layoutRectEntryItem.LayoutRect(Rect(),layoutEntryItem);
   301         layoutRectEntryItem.LayoutRect(Rect(),layoutEntryItem);
   695         iRectCoverMainPaneInput.DrawRect(gc);
   701         iRectCoverMainPaneInput.DrawRect(gc);
   696         iRectFirstShadowInput.DrawRect(gc);
   702         iRectFirstShadowInput.DrawRect(gc);
   697         iRectOutlineFrameInput.DrawRect(gc);
   703         iRectOutlineFrameInput.DrawRect(gc);
   698         iRectInsideAreaInput.DrawRect(gc);
   704         iRectInsideAreaInput.DrawRect(gc);
   699         }
   705         }
       
   706 
       
   707     if((iVisibleCount >= 1) && (iPages.Count() > 1))
       
   708         {
       
   709         if(iCurDisplayPage != 0)
       
   710             {
       
   711             iIndiFepArrowLeft.DrawImage(gc, iNaviArrowBitmapLeft, iNaviArrowBitmapLeftMask);
       
   712             }
       
   713 
       
   714         if (iPages.Count() > iCurDisplayPage + 1)
       
   715             {
       
   716             iIndiFepArrowRight.DrawImage(gc, iNaviArrowBitmapRight, iNaviArrowBitmapRightMask);
       
   717             }
       
   718 	    }
   700     }
   719     }
   701 
   720 
   702 TTypeUid::Ptr CAknFepUICtrlPinyinPopup::MopSupplyObject(TTypeUid aId)
   721 TTypeUid::Ptr CAknFepUICtrlPinyinPopup::MopSupplyObject(TTypeUid aId)
   703     {
   722     {
   704     if (aId.iUid == MAknsControlContext::ETypeId)
   723     if (aId.iUid == MAknsControlContext::ETypeId)
   705         return ( MAknsControlContext::SupplyMopObject(aId, iBgContext));
   724         return ( MAknsControlContext::SupplyMopObject(aId, iBgContext));
   706     return CCoeControl::MopSupplyObject(aId);
   725     return CCoeControl::MopSupplyObject(aId);
   707     }
   726     }
   708 
   727 
   709 void CAknFepUICtrlPinyinPopup::ConstructL( RWindow& aParent )
   728 void CAknFepUICtrlPinyinPopup::ConstructL(RWindow& /*aParent*/)
   710     {
   729     {
   711     CreateWindowL( aParent );
   730     CreateWindowL();
       
   731     ConstructBitmapsL();
       
   732     RWindow& window = Window();
   712 
   733 
   713     for(TInt i = 0; i < EMaxPhraseCandidate; i++)
   734     for(TInt i = 0; i < EMaxPhraseCandidate; i++)
   714         {
   735         {
   715         CAknFepUICtrlInputPane* inputPane = 
   736         CAknFepUICtrlInputPane* inputPane = 
   716             CAknFepUICtrlInputPane::NewL(aParent, CAknFepUICtrlInputPane::ELayoutPhrasePinyinPopupPane, iLafDataMgr);
   737             CAknFepUICtrlInputPane::NewL(window, CAknFepUICtrlInputPane::ELayoutPhrasePinyinPopupPane, iLafDataMgr);
   717         inputPane->SetMopParent(this);
   738         inputPane->SetMopParent(this);
   718         CleanupStack::PushL(inputPane);
   739         CleanupStack::PushL(inputPane);
   719         // ownership is passed, unless allocation is unsuccessful, in which case we still have it on the stack
   740         // ownership is passed, unless allocation is unsuccessful, in which case we still have it on the stack
   720         User::LeaveIfError(iInputPaneArray.Append(inputPane));
   741         User::LeaveIfError(iInputPaneArray.Append(inputPane));
   721         CleanupStack::Pop(); // inputPane
   742         CleanupStack::Pop(); // inputPane
   743     iFirstValidZhuyinGrp = new(ELeave)CDesCArrayFlat(1);
   764     iFirstValidZhuyinGrp = new(ELeave)CDesCArrayFlat(1);
   744     iChineseCharsDisped = new(ELeave)CDesCArrayFlat(1);
   765     iChineseCharsDisped = new(ELeave)CDesCArrayFlat(1);
   745     iZhuyinSymbolsForChineseCharsDisped = new(ELeave)CDesCArrayFlat(1);
   766     iZhuyinSymbolsForChineseCharsDisped = new(ELeave)CDesCArrayFlat(1);
   746     
   767     
   747     SetNonFocusing();
   768     SetNonFocusing();
       
   769     window.SetOrdinalPosition(0, ECoeWinPriorityFep); // right at the front
       
   770     window.SetNonFading(ETrue);
   748 
   771 
   749     TRect outerRect = TRect();
   772     TRect outerRect = TRect();
   750     TRect innerRect = TRect();
   773     TRect innerRect = TRect();
   751     CalculateFrameRects(outerRect, innerRect);
   774     CalculateFrameRects(outerRect, innerRect);
   752 
   775 
   753     iBgContext = CAknsFrameBackgroundControlContext::NewL(KAknsIIDQsnFrPopupSub, outerRect, innerRect, ETrue);
   776     iBgContext = CAknsFrameBackgroundControlContext::NewL(KAknsIIDQsnFrPopupSub, outerRect, innerRect, ETrue);
   754     iLastResouce = 0;
   777     iLastResouce = 0;
   755     MakeVisible(EFalse);
   778     MakeVisible(EFalse);
       
   779     }
       
   780 
       
   781 void CAknFepUICtrlPinyinPopup::ConstructBitmapsL()
       
   782     {
       
   783     MAknsSkinInstance* skin = AknsUtils::SkinInstance();    
       
   784     
       
   785     TFileName bmpFile;
       
   786     bmpFile.Copy(_L("z:"));
       
   787     bmpFile.Append(KDC_BITMAP_DIR);
       
   788     bmpFile.Append(KFepUiControlsBitmapFile);      
       
   789     
       
   790     AknsUtils::CreateColorIconL( skin,
       
   791                                      KAknsIIDQgnIndiFepArrowLeft,
       
   792                                      KAknsIIDQsnIconColors,
       
   793                                      EAknsCIQsnIconColorsCG20,
       
   794                                      iNaviArrowBitmapLeft,
       
   795                                      iNaviArrowBitmapLeftMask,
       
   796                                      bmpFile,
       
   797                                      EMbmAknfepuictrlsQgn_indi_fep_arrow_left,
       
   798                                      EMbmAknfepuictrlsQgn_indi_fep_arrow_left_mask,
       
   799                                      AKN_LAF_COLOR( 0 )
       
   800                                  );  
       
   801 
       
   802     AknsUtils::CreateColorIconL( skin,
       
   803                                      KAknsIIDQgnIndiFepArrowRight,
       
   804                                      KAknsIIDQsnIconColors,
       
   805                                      EAknsCIQsnIconColorsCG20,
       
   806                                      iNaviArrowBitmapRight,
       
   807                                      iNaviArrowBitmapRightMask,
       
   808                                      bmpFile,
       
   809                                      EMbmAknfepuictrlsQgn_indi_fep_arrow_right,
       
   810                                      EMbmAknfepuictrlsQgn_indi_fep_arrow_right_mask,
       
   811                                      AKN_LAF_COLOR( 0 )
       
   812                                  );    
   756     }
   813     }
   757 
   814 
   758 CAknFepUICtrlPinyinPopup::CAknFepUICtrlPinyinPopup( CAknFepUiLayoutDataMgr* aLafDataMgr )
   815 CAknFepUICtrlPinyinPopup::CAknFepUICtrlPinyinPopup( CAknFepUiLayoutDataMgr* aLafDataMgr )
   759     : 
   816     : 
   760     iSelected(0),
   817     iSelected(0),
   776     iEEPContent.Zero();
   833     iEEPContent.Zero();
   777     }
   834     }
   778 
   835 
   779 void CAknFepUICtrlPinyinPopup::LayoutRects()
   836 void CAknFepUICtrlPinyinPopup::LayoutRects()
   780     {
   837     {
       
   838     // left arrow
       
   839     iIndiFepArrowLeft = 
       
   840         CAknFepChineseUIDataConv::AnyToLayoutRect( iLafDataMgr->RequestData( EIndiFepArrowLeft ));
       
   841     AknIconUtils::SetSize( iNaviArrowBitmapLeft, iIndiFepArrowLeft.Rect().Size());
       
   842 
       
   843     // right arrow
       
   844     iIndiFepArrowRight = 
       
   845         CAknFepChineseUIDataConv::AnyToLayoutRect( iLafDataMgr->RequestData( EIndiFepArrowRight ));
       
   846     AknIconUtils::SetSize( iNaviArrowBitmapRight, iIndiFepArrowRight.Rect().Size());
       
   847 
   781     // cover main pane
   848     // cover main pane
   782     iRectCoverMainPaneInput = 
   849     iRectCoverMainPaneInput = 
   783         CAknFepChineseUIDataConv::AnyToLayoutRect( iLafDataMgr->RequestData( ERectCoverMainPaneInput ));
   850         CAknFepChineseUIDataConv::AnyToLayoutRect( iLafDataMgr->RequestData( ERectCoverMainPaneInput ));
   784     // first shadow
   851     // first shadow
   785     iRectFirstShadowInput = 
   852     iRectFirstShadowInput = 
   809     {
   876     {
   810     TRect rect = Rect();
   877     TRect rect = Rect();
   811 
   878 
   812     CAknFepUICtrlInputPane* inputPane = iInputPaneArray[aIndex];
   879     CAknFepUICtrlInputPane* inputPane = iInputPaneArray[aIndex];
   813     TAknWindowLineLayout layoutEntryItem = 
   880     TAknWindowLineLayout layoutEntryItem = 
   814            CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData( EInputLayout ));
   881             CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutEntryItem));
   815     TAknTextLineLayout layoutLineText = 
   882     TAknTextLineLayout layoutLineText = 
   816         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData( EInputTextLayout ));
   883         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EEntryTextLayout));
   817     TAknLayoutRect layoutRectEntryItem;
   884     TAknLayoutRect layoutRectEntryItem;
   818     layoutRectEntryItem.LayoutRect( rect, layoutEntryItem );
   885     layoutRectEntryItem.LayoutRect(rect,layoutEntryItem);
   819     TRect rectEntryItem = layoutRectEntryItem.Rect();
   886     TRect rectEntryItem = layoutRectEntryItem.Rect();
   820     
   887     
   821     TAknLayoutText layoutText;
   888     TAknLayoutText layoutText;
   822     layoutText.LayoutText( rectEntryItem, layoutLineText );
   889     layoutText.LayoutText(rectEntryItem,layoutLineText);
   823     
       
   824     // Get text rect
       
   825     TRect rectText = layoutText.TextRect();
   890     TRect rectText = layoutText.TextRect();
   826     TInt minWidth = rectText.Width();
       
   827     
   891     
   828     // value is 3 for 176*208 resolution
   892     // value is 3 for 176*208 resolution
   829     TInt distance = rectText.iTl.iX - rectEntryItem.iTl.iX + rectEntryItem.iBr.iX - rectText.iBr.iX;
   893     TInt distance = rectText.iTl.iX - rectEntryItem.iTl.iX + rectEntryItem.iBr.iX - rectText.iBr.iX;
   830     
   894     
   831     if ( aIndex > 0 )
   895     if( aIndex > 0)
   832         {
   896         {
   833         CAknFepUICtrlInputPane* inputPanePrev = iInputPaneArray[aIndex - 1];
   897         CAknFepUICtrlInputPane* inputPanePrev = iInputPaneArray[aIndex - 1];
   834         rectText.iTl.iX = inputPanePrev->Rect().iBr.iX;
   898         rectText.iTl.iX = inputPanePrev->Rect().iBr.iX;
   835         }
   899         }
   836     
   900     rectText.SetWidth(inputPane->LabelTextWidthInPixels() + distance);
   837     TInt width = inputPane->LabelTextWidthInPixels();
   901     rectText.SetHeight(rect.Height());
   838     // Only there has text that need the distance.
   902 
   839     if ( width > 0 ) 
   903     inputPane->SetRect(rectText);
   840     	{
   904     inputPane->SetHighlighted(aIndex == iSelected);
   841 		width = width > minWidth ? width : minWidth;
       
   842 		width += distance;
       
   843     	}
       
   844     rectText.SetWidth( width );
       
   845     rectText.SetHeight( rect.Height());
       
   846 
       
   847     inputPane->SetRect( rectText );
       
   848     inputPane->SetHighlighted( aIndex == iSelected );
       
   849     }
   905     }
   850 
   906 
   851 void CAknFepUICtrlPinyinPopup::SetInputPaneVisibility()
   907 void CAknFepUICtrlPinyinPopup::SetInputPaneVisibility()
   852     {
   908     {
   853     TInt number = iVisibleCount;
   909     TInt number = iVisibleCount;
   887     }
   943     }
   888 
   944 
   889 void CAknFepUICtrlPinyinPopup::CalculateFrameRects(TRect& aOuterRect, TRect& aInnerRect) const
   945 void CAknFepUICtrlPinyinPopup::CalculateFrameRects(TRect& aOuterRect, TRect& aInnerRect) const
   890     {
   946     {
   891     TRect windowRect = 
   947     TRect windowRect = 
   892         CAknFepChineseUIDataConv::AnyToRect( iLafDataMgr->RequestData( EPopupRectEEP ));
   948         CAknFepChineseUIDataConv::AnyToRect( iLafDataMgr->RequestData( EPopupRectEntry ));
   893     TInt rectHeight = windowRect.iBr.iY - windowRect.iTl.iY;
   949     TInt rectHeight = windowRect.iBr.iY - windowRect.iTl.iY;
   894     TInt rectWidth = windowRect.Width();
   950     TInt rectWidth = windowRect.Width();
   895     windowRect.iTl.iX = 0;
   951     windowRect.iTl.iX = 0;
   896     windowRect.iTl.iY = 0;
   952     windowRect.iTl.iY = 0;
   897     windowRect.SetHeight(rectHeight);
   953     windowRect.SetHeight(rectHeight);