fep/aknfep/UiPlugins/AknFepUiInterface/AvkonImpl/src/AknFepUiAvkonCtrlCandidatePane.cpp
branchRCL_3
changeset 56 8152b1f1763a
parent 50 5a1685599b76
equal deleted inserted replaced
50:5a1685599b76 56:8152b1f1763a
    33 #include <eiklabel.h>
    33 #include <eiklabel.h>
    34 #include <AknsDrawUtils.h>
    34 #include <AknsDrawUtils.h>
    35 #include <AknBidiTextUtils.h> 
    35 #include <AknBidiTextUtils.h> 
    36 #include <AknsUtils.h>
    36 #include <AknsUtils.h>
    37 #include <AknIconUtils.h>
    37 #include <AknIconUtils.h>
    38 #include <coecntrl.h>
    38 
    39 #include <aknfepuictrls.mbg>
    39 #include <aknfepuictrls.mbg>
    40 #include <skinlayout.cdl.h>
       
    41 #include <aknlayoutscalable_avkon.cdl.h>
       
    42 
       
    43 #include "AknFepUiInterfacePanic.h"
    40 #include "AknFepUiInterfacePanic.h"
    44 #include "AknFepUIAvkonCtrlCandidatePane.h"
    41 #include "AknFepUIAvkonCtrlCandidatePane.h"
       
    42 #include "AknFepUIAvkonCtrlCandidateSelected.h"
    45 #include "aknfepchineseuidataconv.h"
    43 #include "aknfepchineseuidataconv.h"
    46 #include "aknfepuilayoutdatamgr.h"
    44 #include "aknfepuilayoutdatamgr.h"
    47 #include "AknFepUiInputStateBase.h"
    45 
    48 #include "AknFepUIAvkonCtrlCandidateCharacter.h"
    46 
    49 #include "data_caging_path_literals.hrh"
    47 #include "data_caging_path_literals.hrh"
    50 
    48 
    51 const TInt CandidateCountLeft = 10;
    49 const TInt CandidateCountLeft = 10;
    52 const TInt DibertHeight = 480;
       
    53 const TInt ShowAboveCharacter = -1;
       
    54 const TInt ShowBellowCharacter = 1;
       
    55 
    50 
    56 _LIT(KFepUiControlsBitmapFile, "aknfepuictrls.mbm");
    51 _LIT(KFepUiControlsBitmapFile, "aknfepuictrls.mbm");
    57 
    52 
    58 CAknFepUICtrlCandidatePane* CAknFepUICtrlCandidatePane::NewL( RWindow& aParent, 
    53 CAknFepUICtrlCandidatePane* CAknFepUICtrlCandidatePane::NewL(RWindow& aParent, CAknFepUiLayoutDataMgr* aLafDataMgr)
    59 															  CAknFepUiLayoutDataMgr* aLafDataMgr, 
    54     {
    60 															  MAknFepChineseUiMgr* aMgr )
    55     CAknFepUICtrlCandidatePane* self = new(ELeave) CAknFepUICtrlCandidatePane( aLafDataMgr );
    61     {
       
    62     CAknFepUICtrlCandidatePane* self = new(ELeave) CAknFepUICtrlCandidatePane( aLafDataMgr, aMgr );
       
    63     CleanupStack::PushL(self);
    56     CleanupStack::PushL(self);
    64     self->ConstructL(aParent);
    57     self->ConstructL(aParent);
    65     CleanupStack::Pop();
    58     CleanupStack::Pop();
    66     return self;
    59     return self;
    67     }
    60     }
    68 
    61 
    69 CAknFepUICtrlCandidatePane::~CAknFepUICtrlCandidatePane()
    62 CAknFepUICtrlCandidatePane::~CAknFepUICtrlCandidatePane()
    70     {
    63     {
    71     delete iCtrlScroll;
    64     delete iCandidateSelected;
    72     delete iPreview;
    65     delete iNaviArrowBitmapLeft;
       
    66     delete iNaviArrowBitmapLeftMask;
       
    67     delete iNaviArrowBitmapRight;
       
    68     delete iNaviArrowBitmapRightMask;
       
    69     delete iNaviArrowBitmapUp;
       
    70     delete iNaviArrowBitmapUpMask;
       
    71     delete iNaviArrowBitmapDown;
       
    72     delete iNaviArrowBitmapDownMask;
    73     if(iCandidateArray)
    73     if(iCandidateArray)
    74     	{
    74     	{
    75     	iCandidateArray->Reset();
    75     	iCandidateArray->Reset();
    76 		delete iCandidateArray;
    76 		delete iCandidateArray;
    77     	}
    77     	}
    78     iCandidateLabelArray.ResetAndDestroy();
    78     iCandidateLabelArray.ResetAndDestroy();
       
    79     iOrdinalLabelArray.ResetAndDestroy();
    79     iCandidateModeArray.Reset();
    80     iCandidateModeArray.Reset();
    80     iPages.Reset();
    81     iPages.Reset();
    81     }
    82     }
    82 
    83 
    83 const TDesC& CAknFepUICtrlCandidatePane::TextBuffer() const
    84 const TDesC& CAknFepUICtrlCandidatePane::TextBuffer() const
    96     if(newLength - 1 < iSelected)
    97     if(newLength - 1 < iSelected)
    97         {
    98         {
    98         // as far as the client is concerned, they have removed the character that was selected
    99         // as far as the client is concerned, they have removed the character that was selected
    99         // therefore we must now hide the selected candidate, although the highlighting
   100         // therefore we must now hide the selected candidate, although the highlighting
   100         // state remains unchanged
   101         // state remains unchanged
   101 		iCandidateLabelArray[iSelected]->SetHighlight( EFalse );
   102         iCandidateSelected->MakeVisible(EFalse);
   102         }
   103         }
   103     else
   104     else
   104         {
   105         {
   105         if(iHighlighted)
   106         if(iHighlighted)
   106             {
   107             {
   107             // make sure that the candidate is visible, as the selection is now
   108             // make sure that the candidate is visible, as the selection is now
   108             // within a visible range (it might have been hidden last time
   109             // within a visible range (it might have been hidden last time
   109             // the buffer was set)
   110             // the buffer was set)
   110 			iCandidateLabelArray[iSelected]->SetHighlight( ETrue );
   111             iCandidateSelected->MakeVisible(ETrue);
   111             }
   112             }
   112         }
   113         }
   113 
   114 
   114     TPtrC newText = aBuffer.Left(newLength);
   115     TPtrC newText = aBuffer.Left(newLength);
   115     TPtr ptr = iBuffer.Des();
   116     TPtr ptr = iBuffer.Des();
   129                 }
   130                 }
   130             // only update and redraw label background if the value has changed
   131             // only update and redraw label background if the value has changed
   131             if(valueChanged)
   132             if(valueChanged)
   132                 {
   133                 {
   133                 // we have already allocated enough memory for this
   134                 // we have already allocated enough memory for this
   134 				CAknFepUICtrlCandidateCharacter* candidateLabel = iCandidateLabelArray[i];
   135                 CEikLabel* candidateLabel = iCandidateLabelArray[i];
   135                 candidateLabel->SetText( newChar );
   136                 TRAP_IGNORE(candidateLabel->SetTextL(newChar));
       
   137 
       
   138                 // need to update the character if it is in the current selected candidate
       
   139                 if(i == iSelected)
       
   140                     {
       
   141                     iCandidateSelected->SetText(newChar);
       
   142                     iCandidateSelected->SetOrdinal(i + 1);
       
   143                     DrawDeferred();
       
   144                     }
       
   145                 if(i < iVisibleCount)
       
   146                     {
       
   147                     // only redraw characters that are visible
       
   148                     TRect rect = candidateLabel->Rect();
       
   149                     Window().Invalidate(rect);
       
   150                     }
   136                 }
   151                 }
   137             }
   152             }
   138         ptr.Copy(newText);
   153         ptr.Copy(newText);
   139         LayoutLabels();
   154         LayoutLabels();
       
   155         LayoutCandidateSelected();
   140         iVisibleCount = newLength;
   156         iVisibleCount = newLength;
   141         UpdateLabelVisibility();
   157         UpdateLabelVisibility();
   142         }
   158         }
   143     }
   159     }
   144 
   160 
   156     TPage curPage = iPages[iCurDisplayPage];
   172     TPage curPage = iPages[iCurDisplayPage];
   157     iVisibleCount = curPage.iEndIndex - curPage.iStartIndex + 1;
   173     iVisibleCount = curPage.iEndIndex - curPage.iStartIndex + 1;
   158 
   174 
   159     if(iVisibleCount - 1 < iSelected)
   175     if(iVisibleCount - 1 < iSelected)
   160         {
   176         {
   161 		iCandidateLabelArray[iSelected]->SetHighlight( EFalse );
   177         iCandidateSelected->MakeVisible(EFalse);
   162         }
   178         }
   163     else
   179     else
   164         {
   180         {
   165         if(iHighlighted)
   181         if(iHighlighted)
   166             {
   182             {
   167 			iCandidateLabelArray[iSelected]->SetHighlight( ETrue );
   183             iCandidateSelected->MakeVisible(ETrue);
   168             }
   184             }
   169         }
   185         }
   170 
   186 
   171     TBufC<EPhraseLength> buf;
   187     TBufC<EPhraseLength> buf;
   172     TPtr newText = buf.Des();
   188     TPtr newText = buf.Des();
   173 
   189 
   174     for(TInt i = 0; i < iVisibleCount; i ++)
   190     for(TInt i = 0; i < iVisibleCount; i ++)
   175         {
   191         {
   176 		CAknFepUICtrlCandidateCharacter* candidateLabel = iCandidateLabelArray[i];
   192         CEikLabel* candidateLabel = iCandidateLabelArray[i];
   177         const TDesC* txtLabel = candidateLabel->Text();
   193         const TDesC* txtLabel = candidateLabel->Text();
   178         newText = (*iCandidateArray)[curPage.iStartIndex + i];
   194         newText = (*iCandidateArray)[curPage.iStartIndex + i];
   179 
   195 
   180         if (( txtLabel->Compare(newText) != 0 ))
   196         if((txtLabel->Compare(newText) != 0) )
   181             {
   197             {
   182             // we have already allocated enough memory for this
   198             // we have already allocated enough memory for this
   183             TRAP_IGNORE( candidateLabel->SetText( newText ));
   199             TRAP_IGNORE( candidateLabel->SetTextL(newText));
   184             }
   200             }
   185 
   201             
   186         if ( i < iVisibleCount )
   202             // need to update the character if it is in the current selected candidate
   187             {
   203             if(i == iSelected)
   188             // only redraw labels that are visible
   204                 {
   189             TRect rect = candidateLabel->Rect();
   205                 iCandidateSelected->SetText(newText);
   190             Window().Invalidate( rect );
   206                 iCandidateSelected->SetOrdinal(i + 1);
       
   207                 DrawDeferred();
       
   208                 }
       
   209             if(i < iVisibleCount)
       
   210                 {
       
   211                 // only redraw labels that are visible
       
   212                 TRect rect = candidateLabel->Rect();
       
   213                 Window().Invalidate(rect);
   191             }
   214             }
   192         }
   215         }
   193     LayoutLabels();
   216     LayoutLabels();
       
   217     LayoutCandidateSelected();
   194     DrawDeferred();
   218     DrawDeferred();
   195     UpdateLabelVisibility();
   219     UpdateLabelVisibility();
   196     }
   220     }
   197 
   221 
   198 void CAknFepUICtrlCandidatePane::SetHighlighted(TBool aHighlighted)
   222 void CAknFepUICtrlCandidatePane::SetHighlighted(TBool aHighlighted)
   199     {
   223     {
   200     if(!COMPARE_BOOLS(iHighlighted, aHighlighted))
   224     if(!COMPARE_BOOLS(iHighlighted, aHighlighted))
   201         {
   225         {
   202         iHighlighted = aHighlighted;
   226         iHighlighted = aHighlighted;
   203         iCandidateLabelArray[iSelected]->SetHighlight( aHighlighted );
   227         iCandidateSelected->MakeVisible(aHighlighted);
       
   228 
       
   229         iCandidateSelected->DrawDeferred();
   204         }
   230         }
   205     }
   231     }
   206 
   232 
   207 TBool CAknFepUICtrlCandidatePane::Highlighted() const
   233 TBool CAknFepUICtrlCandidatePane::Highlighted() const
   208     {
   234     {
   216 
   242 
   217     TCandidateMode oldMode = iCandidateModeArray[aIndex];
   243     TCandidateMode oldMode = iCandidateModeArray[aIndex];
   218     if(oldMode != aMode)
   244     if(oldMode != aMode)
   219         {
   245         {
   220         iCandidateModeArray[aIndex] = aMode;
   246         iCandidateModeArray[aIndex] = aMode;
   221         
   247         if(iSelected == aIndex)
       
   248             {
       
   249             LayoutCandidateSelected();
       
   250             }
   222         // only do drawing if visible
   251         // only do drawing if visible
   223         if(aIndex < iVisibleCount)
   252         if(aIndex < iVisibleCount)
   224             {
   253             {
   225             LayoutLabel(aIndex);
   254             LayoutLabel(aIndex);
   226             if(iSelected == aIndex && iHighlighted)
   255             if(iSelected == aIndex && iHighlighted)
   227                 {
   256                 {
       
   257                 iCandidateSelected->DrawDeferred();
   228                 }
   258                 }
   229             else
   259             else
   230                 {
   260                 {
   231 				CAknFepUICtrlCandidateCharacter* candidateLabel = iCandidateLabelArray[aIndex];
   261                 CEikLabel* candidateLabel = iCandidateLabelArray[aIndex];
   232                 TRect rect = candidateLabel->Rect();
   262                 TRect rect = candidateLabel->Rect();
   233                 Window().Invalidate(rect);
   263                 Window().Invalidate(rect);
   234                 }
   264                 }
   235             }
   265             }
   236         }
   266         }
   246     return EFalse;
   276     return EFalse;
   247     }
   277     }
   248 
   278 
   249 void CAknFepUICtrlCandidatePane::ShowHorizontalScrollArrows(TBool /*aValue*/)
   279 void CAknFepUICtrlCandidatePane::ShowHorizontalScrollArrows(TBool /*aValue*/)
   250     {
   280     {
   251     // Left & right arrow are not need, so do nothing.
   281     // If the state is changed, the arrows will be redrawn in the new state.
       
   282     //    if(!COMPARE_BOOLS(iShowHorizontalScrollArrows, aValue))
       
   283     //        {
       
   284     //        iShowHorizontalScrollArrows = aValue;
       
   285     //        TRect rect = iIndiFepArrowLeft.Rect();
       
   286     //        Window().Invalidate(rect);
       
   287     //        rect = iIndiFepArrowRight.Rect();
       
   288     //        Window().Invalidate(rect);
       
   289     //        }
   252     }
   290     }
   253 
   291 
   254 void CAknFepUICtrlCandidatePane::ShowUpScrollArrows(TBool aValue)
   292 void CAknFepUICtrlCandidatePane::ShowUpScrollArrows(TBool aValue)
   255     {
   293     {
   256 	// call function of scroll pane to show/hide up arrow.
   294     if (iShowUpScrollArrows != aValue)
   257 	iCtrlScroll->ShowUpScrollArrows( aValue );
   295         {
       
   296         iShowUpScrollArrows = aValue;
       
   297         TRect rect = iIndiFepArrowUp.Rect();
       
   298         Window().Invalidate(rect);
       
   299         }
   258     }
   300     }
   259     
   301     
   260 void CAknFepUICtrlCandidatePane::ShowDownScrollArrows(TBool aValue)
   302 void CAknFepUICtrlCandidatePane::ShowDownScrollArrows(TBool aValue)
   261     {
   303     {
   262 	// call function of scroll pane to show/hide down arrow.
   304     if (iShowDownScrollArrows != aValue)
   263 	iCtrlScroll->ShowDownScrollArrows( aValue );
   305         {
       
   306         iShowDownScrollArrows = aValue;
       
   307         TRect rect = iIndiFepArrowDown.Rect();
       
   308         Window().Invalidate(rect);
       
   309         }
       
   310         
   264     }
   311     }
   265     
   312     
   266 void CAknFepUICtrlCandidatePane::ShowLeftScrollArrows(TBool /*aValue*/)
   313 void CAknFepUICtrlCandidatePane::ShowLeftScrollArrows(TBool /*aValue*/)
   267     {
   314     {
   268 	// Left arrow is not need, so do nothing.
   315     //    if (iShowLeftScrollArrows != aValue)
       
   316     //        {
       
   317     //        iShowLeftScrollArrows = aValue;
       
   318     //        TRect rect = iIndiFepArrowLeft.Rect();
       
   319     //        Window().Invalidate(rect);
       
   320     //        }
   269     }
   321     }
   270         
   322         
   271 void CAknFepUICtrlCandidatePane::ShowRightScrollArrows(TBool /*aValue*/)
   323 void CAknFepUICtrlCandidatePane::ShowRightScrollArrows(TBool /*aValue*/)
   272     {
   324     {
   273 	// Right arrow is not need, so do nothing.
   325     //    if (iShowRightScrollArrows != aValue)
       
   326     //        {
       
   327     //        iShowRightScrollArrows = aValue;
       
   328     //        TRect rect = iIndiFepArrowRight.Rect();
       
   329     //        Window().Invalidate(rect);
       
   330     //        }
   274     }
   331     }
   275 
   332 
   276 TBool CAknFepUICtrlCandidatePane::IsShowVerticalScrollArrows() const
   333 TBool CAknFepUICtrlCandidatePane::IsShowVerticalScrollArrows() const
   277     {
   334     {
   278 	// call function of scroll pane to get scroll state
   335     return iShowVerticalScrollArrows;
   279     return iCtrlScroll->IsShowVerticalScrollArrows();
       
   280     }
   336     }
   281 
   337 
   282 void CAknFepUICtrlCandidatePane::ShowVerticalScrollArrows(TBool aValue)
   338 void CAknFepUICtrlCandidatePane::ShowVerticalScrollArrows(TBool aValue)
   283     {
   339     {
   284 	// call function of scroll pane to set scroll state
   340     // If the state is changed, the arrows will be redrawn in the new state.
   285 	iCtrlScroll->ShowVerticalScrollArrows( aValue );
   341     if(!COMPARE_BOOLS(iShowVerticalScrollArrows, aValue))
       
   342         {
       
   343         iShowVerticalScrollArrows = aValue;
       
   344         TRect rect = iIndiFepArrowUp.Rect();
       
   345         Window().Invalidate(rect);
       
   346         rect = iIndiFepArrowDown.Rect();
       
   347         Window().Invalidate(rect);
       
   348         }
       
   349     }
       
   350 
       
   351 void CAknFepUICtrlCandidatePane::ShowCandidateOrdinals(TBool aValue)
       
   352     {
       
   353     if(!COMPARE_BOOLS(iShowCandidateOrdinals, aValue))
       
   354         {
       
   355         iShowCandidateOrdinals = aValue;
       
   356         iCandidateSelected->ShowOrdinal(aValue);
       
   357         UpdateLabelVisibility();
       
   358         }
       
   359     }
       
   360 
       
   361 TBool CAknFepUICtrlCandidatePane::IsShowCandidateOrdinals() const
       
   362     {
       
   363     return iShowCandidateOrdinals;
   286     }
   364     }
   287 
   365 
   288 TInt CAknFepUICtrlCandidatePane::VisibleCandidateCount() const
   366 TInt CAknFepUICtrlCandidatePane::VisibleCandidateCount() const
   289     {
   367     {
   290     return iVisibleCount;
   368     return iVisibleCount;
   361     {
   439     {
   362     if(iSelected < iVisibleCount - 1)
   440     if(iSelected < iVisibleCount - 1)
   363         {
   441         {
   364         return SelectIndex(iSelected + 1);
   442         return SelectIndex(iSelected + 1);
   365         }
   443         }
   366     else if( iSelected == iVisibleCount - 1 )
       
   367     	{
       
   368 		return SelectIndex(0);
       
   369     	}
       
   370     else
   444     else
   371         {
   445         {
   372         return EFalse;
   446         return EFalse;
   373         }
   447         }
   374     }
   448     }
   377     {
   451     {
   378     if(iSelected > 0)
   452     if(iSelected > 0)
   379         {
   453         {
   380         return SelectIndex(iSelected - 1);
   454         return SelectIndex(iSelected - 1);
   381         }
   455         }
   382     else if( iSelected == 0 )
       
   383     	{
       
   384         return SelectIndex( iVisibleCount - 1 );
       
   385         }
       
   386     else
   456     else
   387         {
   457         {
   388         return EFalse;
   458         return EFalse;
   389         }
   459         }
   390     }
   460     }
   391 
   461 
   392 TBool CAknFepUICtrlCandidatePane::SelectIndex(TInt aIndex, TBool /*selected*/ )
   462 TBool CAknFepUICtrlCandidatePane::SelectIndex(TInt aIndex, TBool selected)
   393     {
   463     {
   394     if( aIndex + 1 > iVisibleCount || aIndex < 0 )
   464     if(aIndex + 1 > iVisibleCount || aIndex < 0)
   395         {
   465         {
   396         return EFalse;
   466         return EFalse;
   397         }
   467         }
   398 
   468     if(iSelected != aIndex)
   399     if ( iSelected != aIndex )
   469         {
   400     	{
   470         if(iSelected + 1 > iVisibleCount && iHighlighted)
   401 		iCandidateLabelArray[iSelected]->SetHighlight( EFalse );
   471             {
   402     	}
   472             // candidate selection is currently hidden, as the current 
   403     
   473             // selection is outside the range of valid candidates, therefore 
   404     if ( iPointDown || iHighlighted )
   474             // show it again
   405     	{
   475             iCandidateSelected->MakeVisible(ETrue);
   406 		iCandidateLabelArray[aIndex]->SetHighlight( ETrue );
   476             }
   407 		
       
   408     	}
       
   409         iSelected = aIndex;
   477         iSelected = aIndex;
   410 
   478         // move and repopulate the selected candidate control
       
   479         const TDesC* txtLabel = iCandidateLabelArray[aIndex]->Text();
       
   480         iCandidateSelected->SetText(*txtLabel);
       
   481         iCandidateSelected->SetOrdinal(iSelected + 1);
       
   482         
       
   483         LayoutCandidateSelected();
       
   484         if( selected )
       
   485            {
       
   486 
       
   487            DrawDeferred();
       
   488            }
       
   489         
       
   490 		}
   411     return ETrue;
   491     return ETrue;
   412     }
   492     }
   413 
   493 
   414 TInt CAknFepUICtrlCandidatePane::SelectedIndex() const
   494 TInt CAknFepUICtrlCandidatePane::SelectedIndex() const
   415     {
   495     {
   444 
   524 
   445 TInt CAknFepUICtrlCandidatePane::LabelTextWidthInPixels( TInt aIndex)
   525 TInt CAknFepUICtrlCandidatePane::LabelTextWidthInPixels( TInt aIndex)
   446     {
   526     {
   447     TAknLayoutText layoutText;
   527     TAknLayoutText layoutText;
   448     TAknTextLineLayout candidatePaneLayoutText = 
   528     TAknTextLineLayout candidatePaneLayoutText = 
   449         CAknFepChineseUIDataConv::AnyToTextLine(iLafDataMgr->RequestData( ECharacterTextLayout ));
   529         CAknFepChineseUIDataConv::AnyToTextLine(iLafDataMgr->RequestData( ECandidatePaneTextLine ));
   450        
   530        
   451     layoutText.LayoutText(Rect(), candidatePaneLayoutText);
   531     layoutText.LayoutText(Rect(), candidatePaneLayoutText);
   452 
   532 
   453     const CFont* font = layoutText.Font();
   533     const CFont* font = layoutText.Font();
   454 
   534 
   507         }
   587         }
   508     // For fix bug of when the count of character in the last page is less than
   588     // For fix bug of when the count of character in the last page is less than
   509     // the previous page of the last page. And then select the last character of 
   589     // the previous page of the last page. And then select the last character of 
   510     // the previous page of the last page, and select next page. First of the last 
   590     // the previous page of the last page, and select next page. First of the last 
   511     // page is not refreshed.
   591     // page is not refreshed.
   512     iCandidateLabelArray[iSelected]->SetHighlight( EFalse );
       
   513     iSelected = 0;
   592     iSelected = 0;
   514     }
   593     }
   515 
   594 
   516 void CAknFepUICtrlCandidatePane::PreviousCandidatePage(void)
   595 void CAknFepUICtrlCandidatePane::PreviousCandidatePage(void)
   517     {
   596     {
   525         }
   604         }
   526     }
   605     }
   527 
   606 
   528 void CAknFepUICtrlCandidatePane::SizeChanged()
   607 void CAknFepUICtrlCandidatePane::SizeChanged()
   529     {
   608     {
       
   609     LayoutRects();
   530     LayoutContainedControls();
   610     LayoutContainedControls();
   531     }
   611     }
   532 
   612 
   533 TInt CAknFepUICtrlCandidatePane::CountComponentControls() const
   613 TInt CAknFepUICtrlCandidatePane::CountComponentControls() const
   534     {
   614     {
   535     TInt count = 0;
   615     TInt count = 0;
   536     count += iCandidateLabelArray.Count();
   616     count += iCandidateLabelArray.Count();
       
   617     count += iOrdinalLabelArray.Count();
   537 
   618 
   538     CCoeControl* controls[] =
   619     CCoeControl* controls[] =
   539         {
   620         {
   540         iCtrlScroll,
   621         iCandidateSelected
   541         iPreview
       
   542         } ;
   622         } ;
   543 
   623 
   544     for (TUint ii = 0 ; ii < (sizeof(controls) / sizeof(CCoeControl*)) ; ii++)
   624     for (TUint ii = 0 ; ii < (sizeof(controls) / sizeof(CCoeControl*)) ; ii++)
   545         {
   625         {
   546         if(controls[ii])
   626         if(controls[ii])
   552     }
   632     }
   553 
   633 
   554 CCoeControl* CAknFepUICtrlCandidatePane::ComponentControl(TInt aIndex) const
   634 CCoeControl* CAknFepUICtrlCandidatePane::ComponentControl(TInt aIndex) const
   555     {
   635     {
   556     TInt candidateCount = iCandidateLabelArray.Count();
   636     TInt candidateCount = iCandidateLabelArray.Count();
       
   637     TInt ordinalCount = iOrdinalLabelArray.Count();
   557 
   638 
   558     if(aIndex < candidateCount)
   639     if(aIndex < candidateCount)
   559         {
   640         {
   560         // because this method is const, the const [] operator is selected
   641         // because this method is const, the const [] operator is selected
   561         // which means that the pointer is const, so have to cast away constness
   642         // which means that the pointer is const, so have to cast away constness
   562         // - a possible alternative is to make the array mutable?
   643         // - a possible alternative is to make the array mutable?
   563         return CONST_CAST(CAknFepUICtrlCandidateCharacter*, iCandidateLabelArray[aIndex]);
   644         return CONST_CAST(CEikLabel*, iCandidateLabelArray[aIndex]);
   564         }
   645         }
   565     aIndex -= candidateCount;
   646     aIndex -= candidateCount;
   566 
   647 
       
   648     if(aIndex < ordinalCount)
       
   649         {
       
   650         // because this method is const, the const [] operator is selected
       
   651         // which means that the pointer is const, so have to cast away constness
       
   652         // - a possible alternative is to make the array mutable?
       
   653         return CONST_CAST(CEikLabel*, iOrdinalLabelArray[aIndex]);
       
   654         }
       
   655     aIndex -= ordinalCount;
       
   656 
   567     CCoeControl* controls[] =
   657     CCoeControl* controls[] =
   568         {
   658         {
   569        // iCandidateSelected,
   659         iCandidateSelected
   570         iCtrlScroll,
       
   571         iPreview
       
   572         } ;
   660         } ;
   573 
   661 
   574     for (TUint ii = 0; (ii < sizeof(controls) / sizeof(CCoeControl*)) ; ii++)
   662     for (TUint ii = 0; (ii < sizeof(controls) / sizeof(CCoeControl*)) ; ii++)
   575         {
   663         {
   576         if (controls[ii] && aIndex-- == 0)
   664         if (controls[ii] && aIndex-- == 0)
   580         }
   668         }
   581     // shouldn't be called while no components.
   669     // shouldn't be called while no components.
   582     return NULL ;
   670     return NULL ;
   583     }
   671     }
   584 
   672 
       
   673 void CAknFepUICtrlCandidatePane::Draw(const TRect& /* aRect */) const
       
   674     {
       
   675     CWindowGc& gc = SystemGc();
       
   676 
       
   677     if(iShowHorizontalScrollArrows)
       
   678         {
       
   679         if (iShowLeftScrollArrows)
       
   680             {
       
   681             iIndiFepArrowLeft.DrawImage(gc, 
       
   682                                         iNaviArrowBitmapLeft, 
       
   683                                         iNaviArrowBitmapLeftMask);     
       
   684             }
       
   685         
       
   686         if (iShowRightScrollArrows)
       
   687             {
       
   688             iIndiFepArrowRight.DrawImage(gc, 
       
   689                                          iNaviArrowBitmapRight, 
       
   690                                          iNaviArrowBitmapRightMask);
       
   691             }
       
   692         }
       
   693     if(iShowVerticalScrollArrows)
       
   694         {
       
   695         if (iShowUpScrollArrows)
       
   696             {
       
   697             iIndiFepArrowUp.DrawImage(gc,
       
   698                                       iNaviArrowBitmapUp, 
       
   699                                       iNaviArrowBitmapUpMask);
       
   700             }
       
   701             
       
   702         if (iShowDownScrollArrows)
       
   703             {
       
   704             iIndiFepArrowDown.DrawImage(gc, 
       
   705                                         iNaviArrowBitmapDown, 
       
   706                                         iNaviArrowBitmapDownMask);
       
   707             }
       
   708         }
       
   709     }
       
   710 
   585 void CAknFepUICtrlCandidatePane::ConstructL(RWindow& aParent)
   711 void CAknFepUICtrlCandidatePane::ConstructL(RWindow& aParent)
   586     {
   712     {
   587     SetContainerWindowL(aParent);
   713     SetContainerWindowL(aParent);
       
   714     ConstructBitmapsL();
   588 
   715 
   589     TBuf<EOneCandidate> ordinal;
   716     TBuf<EOneCandidate> ordinal;
   590     for(TInt i = 0; i < EMaxCandidates; i++)
   717     for(TInt i = 0; i < EMaxCandidates; i++)
   591         {
   718         {
   592         CAknFepUICtrlCandidateCharacter* candidateLabel = CAknFepUICtrlCandidateCharacter::NewL( aParent, this );
   719         CEikLabel* candidateLabel = new(ELeave) CEikLabel;
   593         CleanupStack::PushL(candidateLabel);
   720         CleanupStack::PushL(candidateLabel);
   594         candidateLabel->SetContainerWindowL(aParent);
   721         candidateLabel->SetContainerWindowL(aParent);
       
   722         candidateLabel->SetBufferReserveLengthL(EPhraseLength);
   595         // ownership is passed, unless allocation is unsuccessful, in which case we still have it on the stack
   723         // ownership is passed, unless allocation is unsuccessful, in which case we still have it on the stack
   596         User::LeaveIfError(iCandidateLabelArray.Append(candidateLabel));
   724         User::LeaveIfError(iCandidateLabelArray.Append(candidateLabel));
   597         CleanupStack::Pop(); // candidateLabel
   725         CleanupStack::Pop(); // candidateLabel
   598 
   726 
       
   727         CEikLabel* ordinalLabel = new(ELeave) CEikLabel;
       
   728         CleanupStack::PushL(ordinalLabel);
       
   729         ordinalLabel->SetContainerWindowL(aParent);
       
   730         ordinalLabel->SetBufferReserveLengthL(EOneCandidate);
       
   731         ordinal.Num((i+1)%10); // digits are [1, 2,,, 9, 0] - only want the last digit in the case of 10!
       
   732         ordinalLabel->SetTextL(ordinal);
       
   733         // ownership is passed, unless allocation is unsuccessful, in which case we still have it on the stack
       
   734         User::LeaveIfError(iOrdinalLabelArray.Append(ordinalLabel));
       
   735         CleanupStack::Pop(); // ordinalLabel
       
   736 
   599         User::LeaveIfError(iCandidateModeArray.Append(ECandidateModeNormal));
   737         User::LeaveIfError(iCandidateModeArray.Append(ECandidateModeNormal));
   600         }
   738         }
   601 
   739 
       
   740     iCandidateSelected = CAknFepUICtrlCandidateSelected::NewL(aParent);
       
   741     iCandidateSelected->MakeVisible(iHighlighted);
       
   742     iCandidateSelected->SetMopParent(this);
   602     iCandidateArray = new(ELeave) CDesCArrayFlat(1);
   743     iCandidateArray = new(ELeave) CDesCArrayFlat(1);
   603     
   744     }
   604     // scroll part
   745 
   605     iCtrlScroll = CAknFepUICtrlCandidateScroll::NewL( aParent, this );
   746 void CAknFepUICtrlCandidatePane::ConstructBitmapsL()
   606     iCtrlScroll->SetMopParent(this);
   747     {    
   607     
   748     MAknsSkinInstance* skin = AknsUtils::SkinInstance();  
   608     // character preview
   749     
   609     iPreview = CAknFepPreview::NewL( aParent );
   750     TFileName bmpFile;
   610     }
   751     bmpFile.Copy(_L("z:"));
   611 
   752     bmpFile.Append(KDC_BITMAP_DIR);
   612 CAknFepUICtrlCandidatePane::CAknFepUICtrlCandidatePane(CAknFepUiLayoutDataMgr* aLafDataMgr, MAknFepChineseUiMgr* aMgr )
   753     bmpFile.Append(KFepUiControlsBitmapFile);  
       
   754 
       
   755     AknsUtils::CreateColorIconL( skin,
       
   756                                  KAknsIIDQgnIndiFepArrowLeft,
       
   757                                  KAknsIIDQsnIconColors,
       
   758                                  EAknsCIQsnIconColorsCG20,
       
   759                                  iNaviArrowBitmapLeft,
       
   760                                  iNaviArrowBitmapLeftMask,
       
   761                                  bmpFile,
       
   762                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_left,
       
   763                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_left_mask,
       
   764                                  AKN_LAF_COLOR( 0 )
       
   765                              );    
       
   766     AknsUtils::CreateColorIconL( skin,
       
   767                                  KAknsIIDQgnIndiFepArrowRight,
       
   768                                  KAknsIIDQsnIconColors,
       
   769                                  EAknsCIQsnIconColorsCG20,
       
   770                                  iNaviArrowBitmapRight,
       
   771                                  iNaviArrowBitmapRightMask,
       
   772                                  bmpFile,
       
   773                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_right,
       
   774                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_right_mask,
       
   775                                  AKN_LAF_COLOR( 0 )
       
   776                              );    
       
   777 
       
   778     AknsUtils::CreateColorIconL( skin,
       
   779                                  KAknsIIDQgnIndiFepArrowUp,
       
   780                                  KAknsIIDQsnIconColors,
       
   781                                  EAknsCIQsnIconColorsCG20,
       
   782                                  iNaviArrowBitmapUp,
       
   783                                  iNaviArrowBitmapUpMask,
       
   784                                  bmpFile,
       
   785                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_up,
       
   786                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_up_mask,
       
   787                                  AKN_LAF_COLOR( 0 )
       
   788                              );    
       
   789     AknsUtils::CreateColorIconL( skin,
       
   790                                  KAknsIIDQgnIndiFepArrowDown,
       
   791                                  KAknsIIDQsnIconColors,
       
   792                                  EAknsCIQsnIconColorsCG20,
       
   793                                  iNaviArrowBitmapDown,
       
   794                                  iNaviArrowBitmapDownMask,
       
   795                                  bmpFile,
       
   796                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_down,
       
   797                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_down_mask,
       
   798                                  AKN_LAF_COLOR( 0 )
       
   799                              );    
       
   800     }
       
   801 
       
   802 CAknFepUICtrlCandidatePane::CAknFepUICtrlCandidatePane(CAknFepUiLayoutDataMgr* aLafDataMgr)
   613     :
   803     :
   614     iPaneLayout(CAknFepUICtrlContainerChinese::ELayoutCandidate),
   804     iPaneLayout(CAknFepUICtrlContainerChinese::ELayoutCandidate),
   615     iHighlighted(EFalse),
   805     iHighlighted(EFalse),
       
   806     iShowHorizontalScrollArrows(EFalse),
       
   807     iShowVerticalScrollArrows(EFalse),
       
   808     iShowUpScrollArrows(ETrue),
       
   809     iShowDownScrollArrows(ETrue),
       
   810     iShowLeftScrollArrows(ETrue),
       
   811     iShowRightScrollArrows(ETrue),
       
   812     iShowCandidateOrdinals(ETrue),
   616     iCurDisplayPage(0),
   813     iCurDisplayPage(0),
   617     iChineseUiMgr(aMgr),
   814     iOrdinalLableWidth(0)
   618     iPointDown( EFalse )
       
   619     {
   815     {
   620     iLafDataMgr = aLafDataMgr;
   816     iLafDataMgr = aLafDataMgr;
   621     }
   817     }
   622 
   818 
       
   819 void CAknFepUICtrlCandidatePane::LayoutRects()
       
   820     {
       
   821     TRect rect = Rect();
       
   822     
       
   823     TAknWindowLineLayout candidateWindowLine1 = 
       
   824       CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ECandidateWindowLine1));
       
   825     TAknWindowLineLayout candidateWindowLine2 = 
       
   826       CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ECandidateWindowLine2));
       
   827     TAknWindowLineLayout candidateWindowLine3 = 
       
   828       CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ECandidateWindowLine3));
       
   829     TAknWindowLineLayout candidateWindowLine4 = 
       
   830       CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ECandidateWindowLine4));
       
   831 
       
   832     iIndiFepArrowLeft.LayoutRect(rect, candidateWindowLine1); 
       
   833     AknIconUtils::SetSize(iNaviArrowBitmapLeft, iIndiFepArrowLeft.Rect().Size());
       
   834 
       
   835     iIndiFepArrowRight.LayoutRect(rect, candidateWindowLine2); 
       
   836     AknIconUtils::SetSize(iNaviArrowBitmapRight, iIndiFepArrowRight.Rect().Size());
       
   837 
       
   838     iIndiFepArrowUp.LayoutRect(rect, candidateWindowLine3);
       
   839     AknIconUtils::SetSize(iNaviArrowBitmapUp, iIndiFepArrowUp.Rect().Size());
       
   840 
       
   841     iIndiFepArrowDown.LayoutRect(rect, candidateWindowLine4);
       
   842     AknIconUtils::SetSize( iNaviArrowBitmapDown, iIndiFepArrowDown.Rect().Size() );
       
   843     }
       
   844 
   623 void CAknFepUICtrlCandidatePane::LayoutContainedControls()
   845 void CAknFepUICtrlCandidatePane::LayoutContainedControls()
   624     {
   846     {
   625     LayoutLabels();
   847     LayoutLabels();
   626     LayoutScroll();
   848     LayoutCandidateSelected();
   627     }
   849     }
   628 
   850 
   629 void CAknFepUICtrlCandidatePane::LayoutLabel(TInt aIndex)
   851 void CAknFepUICtrlCandidatePane::LayoutLabel(TInt aIndex)
   630     {
   852     {
   631     __ASSERT_DEBUG(aIndex >= 0, AknFepUiInterfacePanic(EAknFepUiInterfacePanicAttemptedLayoutOutsideVisibleCount));
   853     __ASSERT_DEBUG(aIndex >= 0, AknFepUiInterfacePanic(EAknFepUiInterfacePanicAttemptedLayoutOutsideVisibleCount));
   632     __ASSERT_DEBUG(aIndex < iVisibleCount, AknFepUiInterfacePanic(EAknFepUiInterfacePanicAttemptedLayoutOutsideVisibleCount));
   854     __ASSERT_DEBUG(aIndex < iVisibleCount, AknFepUiInterfacePanic(EAknFepUiInterfacePanicAttemptedLayoutOutsideVisibleCount));
   633     TRect rect = Rect();
   855     TRect rect = Rect();
   634     CAknFepUICtrlCandidateCharacter* candidateLabel = iCandidateLabelArray[aIndex];
   856     CEikLabel* candidateLabel = iCandidateLabelArray[aIndex];
       
   857     CEikLabel* ordinalLabel = iOrdinalLabelArray[aIndex];
   635     TAknWindowLineLayout layoutCandidateItem = 
   858     TAknWindowLineLayout layoutCandidateItem = 
   636         CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ECharacterLayout));
   859         CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutCandidateItem));
   637     TAknTextLineLayout candidateLayout = 
   860     TAknTextLineLayout candidateLayout = 
   638         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(ECharacterTextLayout));
   861         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(ECandidatePaneTextLine));
   639     
   862     
   640     // layout candidate label
   863     // layout candidate label
   641     TAknLayoutRect layoutRectCandidateItem;
   864     TAknLayoutRect layoutRectCandidateItem;
   642     layoutRectCandidateItem.LayoutRect( rect,layoutCandidateItem );
   865     layoutRectCandidateItem.LayoutRect(rect,layoutCandidateItem);
   643     TRect rectCandidateItem = layoutRectCandidateItem.Rect();
   866     TRect rectCandidateItem = layoutRectCandidateItem.Rect();
   644     if ( aIndex > 0 )
   867     
       
   868     if(aIndex > 0)
   645 	    {
   869 	    {
   646 	    rectCandidateItem.iTl.iX = iCandidateLabelArray[aIndex - 1]->Rect().iBr.iX;
   870 	    rectCandidateItem.iTl.iX = iCandidateLabelArray[aIndex - 1]->Rect().iBr.iX;
   647         }
   871         }
   648 
       
   649     TAknLayoutText layoutText;
   872     TAknLayoutText layoutText;
   650     layoutText.LayoutText( rectCandidateItem, candidateLayout );
   873     layoutText.LayoutText(rectCandidateItem,candidateLayout);
   651     TInt interval = candidateLayout.il + candidateLayout.ir;
   874     TRect rectText = layoutText.TextRect();
   652 
   875     rectText.SetWidth(LabelTextWidthInPixels(aIndex));
   653     TInt width = LabelTextWidthInPixels( aIndex );
   876 
   654     TInt minwidth = layoutRectCandidateItem.Rect().Width() - interval ;    
   877     candidateLabel->SetRect(rectText);
   655     if ( width < minwidth )
   878     candidateLabel->SetFont(layoutText.Font());
   656     	{
   879 
   657 		width = minwidth;
   880     // layout ordinal label
   658     	}    
   881     TAknTextLineLayout ordinalLayout = 
   659     rectCandidateItem.SetWidth( width + interval );
   882         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EOrdinalCandidateTextLayout));
   660     candidateLabel->SetRect( rectCandidateItem );
   883     TBufC16<1> buf;
       
   884     TAknLayoutText layoutOrdinal;
       
   885     TPtr16 ptr = buf.Des();
       
   886     ptr = (*(ordinalLabel->Text())).Left(EOneCandidate);
       
   887     
       
   888     layoutOrdinal.LayoutText(rectCandidateItem,ordinalLayout);
       
   889     
       
   890     const CFont* font = layoutOrdinal.Font();
       
   891     
       
   892     TRect rectOrdinal = layoutOrdinal.TextRect();
       
   893     // align ordinal label and candidate label 
       
   894     
       
   895     /* removed in 2006.03.29
       
   896     rectOrdinal.iTl.iY = rectText.iTl.iY;
       
   897     rectOrdinal.SetWidth(font->TextWidthInPixels(ptr));
       
   898     rectOrdinal.SetHeight(font->HeightInPixels());
       
   899     */
       
   900     
       
   901     // inserted in 2006.03.29
       
   902     TPoint ordinalPosition;
       
   903     TInt ordinalWidth = font->TextWidthInPixels(ptr);
       
   904     ordinalPosition.iX = rectText.iTl.iX - ordinalWidth;
       
   905     ordinalPosition.iY = rectText.iTl.iY;
       
   906     
       
   907     rectOrdinal = TRect(ordinalPosition,
       
   908                         TPoint(ordinalPosition.iX + rectOrdinal.Width(),
       
   909                                ordinalPosition.iY + rectOrdinal.Height()));
       
   910     // end inserting                               
       
   911 
       
   912     ordinalLabel->SetRect(rectOrdinal);
       
   913     ordinalLabel->SetFont(font);
       
   914     iOrdinalLableWidth = rectOrdinal.Width();
   661 
   915 
   662     // override colours if skin data present
   916     // override colours if skin data present
   663     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   917     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   664     TRgb candidateLabelTextColor = layoutText.Color();
   918     TRgb candidateLabelTextColor = layoutText.Color();
       
   919     TRgb ordinalLabelTextColor = layoutOrdinal.Color();
   665 
   920 
   666     AknsUtils::GetCachedColor(skin, candidateLabelTextColor, 
   921     AknsUtils::GetCachedColor(skin, candidateLabelTextColor, 
   667                               KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19);
   922                               KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19);
   668 
   923 
       
   924     AknsUtils::GetCachedColor(skin, ordinalLabelTextColor,
       
   925         KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19);
       
   926 
   669     TRAP_IGNORE(
   927     TRAP_IGNORE(
   670         candidateLabel->OverrideColorL(EColorLabelText, candidateLabelTextColor);
   928         candidateLabel->OverrideColorL(EColorLabelText, candidateLabelTextColor);
       
   929         ordinalLabel->OverrideColorL(EColorLabelText, ordinalLabelTextColor);
   671         );
   930         );
   672     }
   931     }
   673 
   932 
   674 void CAknFepUICtrlCandidatePane::LayoutLabels()
   933 void CAknFepUICtrlCandidatePane::LayoutLabels()
   675     {
   934     {
   676     for(TInt i = 0; i < iVisibleCount; i++)
   935     for(TInt i = 0; i < iVisibleCount; i++)
   677         {
   936         {
   678         LayoutLabel(i);
   937         LayoutLabel(i);
   679         }
   938         }
   680     }
   939     }
   681 void CAknFepUICtrlCandidatePane::LayoutScroll()
   940 
   682     {
   941 void CAknFepUICtrlCandidatePane::LayoutCandidateSelected()
   683     TAknWindowLineLayout scrolllayout =  CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(EScrollLayout));
   942     {
   684     AknLayoutUtils::LayoutControl( iCtrlScroll, Rect(), scrolllayout );
   943     TCandidateMode candidateMode = iCandidateModeArray[iSelected];
       
   944     iCandidateSelected->SetCandidateMode(candidateMode);
       
   945     iCandidateSelected->SetLayout(iPaneLayout);
       
   946 
       
   947     TRect ordinalRect = iOrdinalLabelArray[iSelected]->Rect();
       
   948 
       
   949     TAknLayoutRect layoutRect;
       
   950     TAknWindowLineLayout layoutCandidateItem = 
       
   951         CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutCandidateItem));
       
   952     layoutRect.LayoutRect(Rect(),layoutCandidateItem);
       
   953     
       
   954     TRect rectLayoutCandidateItem = layoutRect.Rect();
       
   955     rectLayoutCandidateItem.iTl.iX = ordinalRect.iTl.iX;
       
   956 
       
   957     TAknTextLineLayout candidateLayout = 
       
   958         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(ECandidatePaneTextLine));
       
   959     TAknTextLineLayout ordinalLayout = 
       
   960         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EOrdinalCandidateTextLayout));
       
   961     rectLayoutCandidateItem.SetWidth(iCandidateLabelArray[iSelected]->Rect().Width() + candidateLayout.il - ordinalLayout.il);
       
   962 
       
   963     rectLayoutCandidateItem.SetHeight(rectLayoutCandidateItem.Height() - 1);
       
   964     
       
   965     iCandidateSelected->SetRect(rectLayoutCandidateItem);
   685     }
   966     }
   686 
   967 
   687 void CAknFepUICtrlCandidatePane::UpdateLabelVisibility()
   968 void CAknFepUICtrlCandidatePane::UpdateLabelVisibility()
   688     {
   969     {
   689     TInt number = 0;
   970     TInt number = 0;
   701         {
   982         {
   702         number =  iVisibleCount;
   983         number =  iVisibleCount;
   703         }
   984         }
   704     for(TInt i = 0; i < EMaxCandidates; i++)
   985     for(TInt i = 0; i < EMaxCandidates; i++)
   705         {
   986         {
   706         CAknFepUICtrlCandidateCharacter* candidateLabel = iCandidateLabelArray[i];
   987         CEikLabel* candidateLabel = iCandidateLabelArray[i];
       
   988         CEikLabel* ordinalLabel = iOrdinalLabelArray[i];
   707         if(i < number)
   989         if(i < number)
   708             {
   990             {
   709             candidateLabel->MakeVisible(ETrue);
   991             candidateLabel->MakeVisible(ETrue);
       
   992             ordinalLabel->MakeVisible(iShowCandidateOrdinals); // only show if needed
   710             }
   993             }
   711         else
   994         else
   712             {
   995             {
   713             candidateLabel->MakeVisible(EFalse);
   996             candidateLabel->MakeVisible(EFalse);
       
   997             ordinalLabel->MakeVisible(EFalse); // don't show it as there is no character to go with it
   714             }
   998             }
   715         }
   999         }
   716     }
  1000     }
   717 
  1001 
   718 void CAknFepUICtrlCandidatePane::ResetCandidateState()
  1002 void CAknFepUICtrlCandidatePane::ResetCandidateState()
   741         return;
  1025         return;
   742         }
  1026         }
   743         
  1027         
   744     TPage curPage;
  1028     TPage curPage;
   745     TInt index = iUnpagedIndex;
  1029     TInt index = iUnpagedIndex;
   746     CAknFepUICtrlCandidateCharacter* candidateLabel;
  1030     CEikLabel* candidateLabel;
   747     
  1031     
   748     curPage.iStartIndex = index;
  1032     curPage.iStartIndex = index;
   749     curPage.iEndIndex = index;
  1033     curPage.iEndIndex = index;
   750     TInt candidateLeftNum = phraseCandidateNum - index > EMaxCandidates? 
  1034     TInt candidateLeftNum = phraseCandidateNum - index > EMaxCandidates? 
   751                             EMaxCandidates : phraseCandidateNum - index;
  1035                             EMaxCandidates : phraseCandidateNum - index;
   752 
  1036 
   753     TAknWindowLineLayout layoutCandidateItem = 
  1037     TAknWindowLineLayout layoutCandidateItem = 
   754         CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ECharacterLayout));
  1038         CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutCandidateItem));
   755     TAknWindowLineLayout candidateRect = 
       
   756         CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(EScrollLayout));
       
   757     
       
   758     TAknTextLineLayout candidateLayout = 
  1039     TAknTextLineLayout candidateLayout = 
   759         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(ECharacterTextLayout));
  1040         CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(ECandidatePaneTextLine));
   760     
  1041     
   761     TInt interval = candidateLayout.il + candidateLayout.ir;
       
   762     // avoid accessing layout data member
  1042     // avoid accessing layout data member
   763     TAknLayoutRect layoutRect;
  1043     TAknLayoutRect layoutRect;
   764     layoutRect.LayoutRect(Rect(),layoutCandidateItem);
  1044     layoutRect.LayoutRect(Rect(),layoutCandidateItem);
   765     TRect rectLayoutCandidateItem = layoutRect.Rect();
  1045     TRect rectLayoutCandidateItem = layoutRect.Rect();
       
  1046 
   766     TAknLayoutText layoutText;
  1047     TAknLayoutText layoutText;
   767     layoutText.LayoutText(rectLayoutCandidateItem,candidateLayout);
  1048     layoutText.LayoutText(rectLayoutCandidateItem,candidateLayout);
   768     TRect rectText = Rect();  
  1049     TRect rectText = layoutText.TextRect();
   769     TInt distance = rectText.iTl.iX - rectLayoutCandidateItem.iTl.iX + rectText.iBr.iX - rectLayoutCandidateItem.iBr.iX;
  1050             
   770     rectLayoutCandidateItem.iBr.iX += distance - candidateRect.iW;
  1051     TInt distance = rectText.iTl.iX - rectLayoutCandidateItem.iTl.iX + rectLayoutCandidateItem.iBr.iX - rectText.iBr.iX;
   771 
  1052     rectLayoutCandidateItem.iTl.iX += distance;
       
  1053 
       
  1054     TInt width = 0;
   772     TInt i = 0;     
  1055     TInt i = 0;     
   773 
  1056 
   774     const TInt candidateWidth = rectLayoutCandidateItem.Width();
  1057     const TInt candidateWidth = rectLayoutCandidateItem.Width();
   775     for ( i = 0; i < candidateLeftNum; i ++ )
  1058     for ( i = 0; i < candidateLeftNum; i ++ )
   776         {
  1059         {
   778         candidateLabel = iCandidateLabelArray[i];
  1061         candidateLabel = iCandidateLabelArray[i];
   779         // labelWidth in the font
  1062         // labelWidth in the font
   780         const CFont* font = layoutText.Font();
  1063         const CFont* font = layoutText.Font();
   781         TPtrC newText = (*iCandidateArray)[iUnpagedIndex + i];
  1064         TPtrC newText = (*iCandidateArray)[iUnpagedIndex + i];
   782         TInt labelWidth = font->TextWidthInPixels( newText );
  1065         TInt labelWidth = font->TextWidthInPixels( newText );
   783         labelWidth = interval + ( labelWidth > layoutText.TextRect().Width() ? labelWidth : layoutText.TextRect().Width());
       
   784         if ( labelWidth > candidateWidth )
  1066         if ( labelWidth > candidateWidth )
   785             {
  1067             {
   786             TBufC<EPhraseLength+10> buf1;
  1068             TBufC<EPhraseLength+10> buf1;
   787             TPtr text( buf1.Des() );
  1069             TPtr text( buf1.Des() );
   788             
  1070             
   792             
  1074             
   793             iCandidateArray->Delete( iUnpagedIndex + i );
  1075             iCandidateArray->Delete( iUnpagedIndex + i );
   794             TRAP_IGNORE(
  1076             TRAP_IGNORE(
   795             {
  1077             {
   796             iCandidateArray->InsertL( iUnpagedIndex + i, text );
  1078             iCandidateArray->InsertL( iUnpagedIndex + i, text );
   797             candidateLabel->SetText(text);
  1079             candidateLabel->SetTextL(text);
   798             });
  1080             });
   799             	
  1081             	
   800             }
  1082             }
   801         else
  1083         else
   802             {
  1084             {
   803             TRAP_IGNORE( candidateLabel->SetText(newText));
  1085             TRAP_IGNORE( candidateLabel->SetTextL(newText));
   804             rectLayoutCandidateItem.iTl.iX += labelWidth;
  1086             width = LabelTextWidthInPixels(i)+ iOrdinalLableWidth; 
   805             }
  1087             rectLayoutCandidateItem.iTl.iX += width;
   806         if (rectLayoutCandidateItem.iTl.iX > rectLayoutCandidateItem.iBr.iX)
  1088             }
       
  1089         if (rectLayoutCandidateItem.iTl.iX >= rectLayoutCandidateItem.iBr.iX)
   807             {
  1090             {
   808             if (index>0)
  1091             if (index>0)
   809                 {
  1092                 {
   810                 curPage.iEndIndex = index - 1;
  1093                 curPage.iEndIndex = index - 1;
   811                 }
  1094                 }
   845     return iCurDisplayPage == 0;
  1128     return iCurDisplayPage == 0;
   846     }
  1129     }
   847 
  1130 
   848 TBool CAknFepUICtrlCandidatePane::IsLastPage()
  1131 TBool CAknFepUICtrlCandidatePane::IsLastPage()
   849     {
  1132     {
   850 	if( iPages.Count() == 0 )
  1133     if( iCandidateArray->Count() == iUnpagedIndex )
   851 		{
       
   852 		return ETrue;
       
   853 		}
       
   854 	else if( iCandidateArray->Count() == iUnpagedIndex )
       
   855         {
  1134         {
   856         return iCurDisplayPage == iPages.Count() - 1;
  1135         return iCurDisplayPage == iPages.Count() - 1;
   857         }
  1136         }
   858     return EFalse;
  1137     return EFalse;
   859     }
  1138     }
   860 
  1139 
   861 void CAknFepUICtrlCandidatePane::SetInVisiable()
  1140 void CAknFepUICtrlCandidatePane::SetInVisiable()
   862     {
  1141     {
   863 	iCandidateLabelArray[iSelected]->SetHighlight( EFalse );
       
   864 	TRAP_IGNORE( iPreview->HideL());
       
   865     for (TInt i = 0; i < EMaxCandidates; i ++)
  1142     for (TInt i = 0; i < EMaxCandidates; i ++)
   866         {
  1143         {
   867 		CAknFepUICtrlCandidateCharacter* candidateLabel = iCandidateLabelArray[i];
  1144         CEikLabel* candidateLabel = iCandidateLabelArray[i];
       
  1145         CEikLabel* ordinalLabel = iOrdinalLabelArray[i];
   868         candidateLabel->MakeVisible(EFalse);
  1146         candidateLabel->MakeVisible(EFalse);
   869         }
  1147         ordinalLabel->MakeVisible(EFalse);
       
  1148         }
       
  1149     iCandidateSelected->MakeVisible(EFalse);
   870     }
  1150     }
   871 
  1151 
   872 TBool CAknFepUICtrlCandidatePane::NeedGetNewCandidatePage()
  1152 TBool CAknFepUICtrlCandidatePane::NeedGetNewCandidatePage()
   873     {
  1153     {
   874     return (iCandidateArray->Count() - iUnpagedIndex < CandidateCountLeft);
  1154     return (iCandidateArray->Count() - iUnpagedIndex < CandidateCountLeft);
   879 	{
  1159 	{
   880 	if (!aEnable)
  1160 	if (!aEnable)
   881 		{
  1161 		{
   882 		for (TInt i=0; i<iVisibleCount; i++)
  1162 		for (TInt i=0; i<iVisibleCount; i++)
   883 			{
  1163 			{
   884 			iCandidateLabelArray[i]->SetText( KNullDesC );
  1164 			TRAP_IGNORE(iCandidateLabelArray[i]->SetTextL(KNullDesC));
   885 			}
  1165 			}
   886 		TRAP_IGNORE( HidePreviewL();)
       
   887 		iCandidateArray->Reset();
  1166 		iCandidateArray->Reset();
   888 		iVisibleCount = 0;
  1167 		iVisibleCount = 0;
   889 		DrawNow();
  1168 		DrawNow();
   890 		}
  1169 		}
   891 	}
  1170 	}
   892 
       
   893 void CAknFepUICtrlCandidatePane::FepUIClosePressed()
       
   894 	{
       
   895 	// Click close to close container
       
   896 	if ( iChineseUiMgr )
       
   897 		{
       
   898 		iChineseUiMgr->CloseContainer();
       
   899 		}
       
   900 	}
       
   901 
       
   902 void CAknFepUICtrlCandidatePane::SetFepUiState( MAknFepUiStateCtrl* aFepUiState )
       
   903     {
       
   904 	iFepUiState = aFepUiState;
       
   905     }
       
   906 
       
   907 void CAknFepUICtrlCandidatePane::HidePreviewL()
       
   908 	{
       
   909 	if( iPreview && iPreview->IsVisible())
       
   910 		{
       
   911 		iPreview->HideL();
       
   912 		}
       
   913 	}
       
   914 void CAknFepUICtrlCandidatePane::HandlePointerEventL( const TPointerEvent & aPointerEvent )
       
   915 	{
       
   916 	CCoeControl::HandlePointerEventL( aPointerEvent );
       
   917     // Press will pop up preview
       
   918 	if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   919 		{
       
   920 		for ( TInt i = 0; i < iVisibleCount; i++ )
       
   921             {
       
   922 	        if ( iCandidateLabelArray[i]->Rect().Contains( aPointerEvent.iPosition ))
       
   923 		        {
       
   924 				iPointDown = ETrue;
       
   925                 SelectIndex( i );
       
   926 	            const TDesC* txtLabel = iCandidateLabelArray[i]->Text();
       
   927 	            TPoint point = iCandidateLabelArray[i]->PositionRelativeToScreen();
       
   928 	            TRect rect( point, iCandidateLabelArray[i]->Size());
       
   929 	            // if container is show on top, the preview should show bellow the character
       
   930 	            // else the preview should show above the character.
       
   931 	            TInt bottom = ShowAboveCharacter;
       
   932 	            if ( point.iY < iCandidateLabelArray[i]->Rect().iBr.iY )
       
   933 	                {
       
   934 				    bottom = ShowBellowCharacter;
       
   935 	                }
       
   936 	            rect.Move( 0, (iCandidateLabelArray[i]->Size().iHeight ) * bottom );
       
   937 	            iPreview->ShowL( rect, *txtLabel );
       
   938 	            break;
       
   939 	    	    }	        
       
   940             }
       
   941         }
       
   942 	// Up will submit text
       
   943 	else if ( aPointerEvent.iType == TPointerEvent::EButton1Up && iPointDown )
       
   944 		{
       
   945 		iPointDown = EFalse;
       
   946 	    for ( TInt i = 0; i < iVisibleCount; i++ )
       
   947 	        {
       
   948 		    if ( iCandidateLabelArray[i]->Rect().Contains( aPointerEvent.iPosition ))
       
   949 			    {
       
   950 			    if ( iChineseUiMgr )
       
   951 			        {
       
   952 			        const TDesC* text = iCandidateLabelArray[i]->Text();	    
       
   953 			        iChineseUiMgr->SubmitSelectedTextL( *text );			        
       
   954 			        }
       
   955 			    break;
       
   956 			    }
       
   957 	        }
       
   958 	    if( iPreview->IsVisible())
       
   959 	    	{
       
   960 			iPreview->HideL();
       
   961 	    	}
       
   962 	    
       
   963 	    if( !iHighlighted )
       
   964 	    	{
       
   965 			iCandidateLabelArray[iSelected]->SetHighlight( iHighlighted );
       
   966 	    	}
       
   967 		}
       
   968 	// Drag out of candidate pane, hide preview
       
   969 	else if ( aPointerEvent.iType == TPointerEvent::EDrag && iPointDown )
       
   970 		{
       
   971 	    TBool bContain = EFalse;
       
   972 		for ( TInt i = 0; ( !bContain ) && ( i < iVisibleCount ); i++ )
       
   973 		    {
       
   974 			if ( iCandidateLabelArray[i]->Rect().Contains( aPointerEvent.iPosition ))
       
   975 				{
       
   976 				TBool bSameIndex = ( i == iSelected );
       
   977 				SelectIndex( i );
       
   978 				if ( !bSameIndex )
       
   979 					{
       
   980 					const TDesC* txtLabel = iCandidateLabelArray[i]->Text();
       
   981 					TPoint point = iCandidateLabelArray[i]->PositionRelativeToScreen();
       
   982 					TRect rect( point, iCandidateLabelArray[i]->Size());
       
   983 					TInt bottom = ShowAboveCharacter;
       
   984 					// If container is moved to top,
       
   985 					// then pop up preview below the character
       
   986 					if ( point.iY < iCandidateLabelArray[i]->Rect().iBr.iY )
       
   987 						{
       
   988 						bottom = ShowBellowCharacter;
       
   989 						}
       
   990 					rect.Move( 0, (iCandidateLabelArray[i]->Size().iHeight ) * bottom );
       
   991 					iPreview->ShowL( rect, *txtLabel );
       
   992 					}
       
   993 				bContain = ETrue;
       
   994 				break;
       
   995 			    }
       
   996 		    }
       
   997 		if ( !bContain )
       
   998 			{
       
   999 			iPreview->HideL();
       
  1000 			iCandidateLabelArray[iSelected]->SetHighlight( iHighlighted );	
       
  1001 			if( !iHighlighted )
       
  1002 				{
       
  1003 				iSelected = 0;
       
  1004 				}
       
  1005 			}
       
  1006 		else if( bContain && !iPreview->IsVisible())
       
  1007 			{
       
  1008 			const TDesC* txtLabel = iCandidateLabelArray[iSelected]->Text();
       
  1009 			TPoint point = iCandidateLabelArray[iSelected]->PositionRelativeToScreen();
       
  1010 			TRect rect( point, iCandidateLabelArray[iSelected]->Size());
       
  1011 			TInt bottom = ShowAboveCharacter;
       
  1012 			// If container is moved to top,
       
  1013 			// then pop up preview below the character
       
  1014 			if ( point.iY < iCandidateLabelArray[iSelected]->Rect().iBr.iY )
       
  1015 				{
       
  1016 				bottom = ShowBellowCharacter;
       
  1017 				}
       
  1018 			rect.Move( 0, (iCandidateLabelArray[iSelected]->Size().iHeight ) * bottom );
       
  1019 			iPreview->ShowL( rect, *txtLabel );
       
  1020 			}
       
  1021 		}
       
  1022 	else
       
  1023 		{
       
  1024 		// do nothing
       
  1025 		}
       
  1026 	}
       
  1027 
       
  1028 CAknFepPreview* CAknFepPreview::NewL( RWindowTreeNode& aParent )
       
  1029 	{
       
  1030 	CAknFepPreview* self = new(ELeave) CAknFepPreview;
       
  1031     CleanupStack::PushL(self);
       
  1032     self->ConstructL( aParent );
       
  1033     CleanupStack::Pop();
       
  1034     return self;
       
  1035 	}
       
  1036 
       
  1037 CAknFepPreview::~CAknFepPreview()
       
  1038 	{
       
  1039 	delete iPreviewLabel;
       
  1040 	}
       
  1041 
       
  1042 void CAknFepPreview::Draw( const TRect& /*aRect*/ ) const
       
  1043 	{
       
  1044     CWindowGc& gc = SystemGc();
       
  1045 	
       
  1046 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1047 	TRect outerRect;
       
  1048 	TRect innerRect;
       
  1049 	CalculateFrameRects( outerRect, innerRect );
       
  1050 	gc.SetBrushColor( KRgbGray );
       
  1051 	// draw the whole frame background according to the containing context, which in this case
       
  1052 	// is the candidate pane, to avoid corner drawing mess and to cope with masked grid frame centre
       
  1053 	MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
       
  1054 	AknsDrawUtils::DrawFrame( skin, gc, outerRect, innerRect,
       
  1055 							  KAknsIIDQsnFrInputCharPreview, KAknsIIDDefault ); 	
       
  1056 	}
       
  1057 
       
  1058 void CAknFepPreview::SizeChanged()
       
  1059 	{
       
  1060     TRect rect = Rect();
       
  1061     TAknTextLineLayout candidateLayout = AknLayoutScalable_Avkon::cell_hyb_candi_pane_t1(0);
       
  1062     // Get preview rect and font. 
       
  1063     TAknLayoutText layoutText;
       
  1064     layoutText.LayoutText( rect, candidateLayout );
       
  1065     TRect rectText = layoutText.TextRect();
       
  1066     const CFont* font = layoutText.Font();
       
  1067 
       
  1068     iPreviewLabel->SetRect( rectText );
       
  1069     iPreviewLabel->SetFont( font );
       
  1070     // override with skin text color
       
  1071     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1072     
       
  1073     TRgb labelTextColor;
       
  1074     AknsUtils::GetCachedColor( skin, labelTextColor, 
       
  1075                                KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 );
       
  1076 
       
  1077     TRAP_IGNORE( 
       
  1078     		iPreviewLabel->OverrideColorL(EColorLabelText, labelTextColor);	 )
       
  1079 	}
       
  1080 
       
  1081 void CAknFepPreview::ShowL( TRect& aRect, const TDesC& aCharacter )
       
  1082 	{
       
  1083 	SetRect( aRect );
       
  1084 
       
  1085 	iPreviewLabel->SetTextL( aCharacter );
       
  1086 	MakeVisible( ETrue );
       
  1087 	RWindow& window = Window();
       
  1088 	window.SetOrdinalPosition( 0, ECoeWinPriorityAlwaysAtFront + 100 );
       
  1089 	DrawNow();
       
  1090 	}
       
  1091 
       
  1092 void CAknFepPreview::HideL()
       
  1093 	{
       
  1094 	MakeVisible( EFalse );
       
  1095 	iPreviewLabel->SetTextL( KNullDesC );
       
  1096 	DrawNow();
       
  1097 	}
       
  1098 
       
  1099 TInt CAknFepPreview::CountComponentControls() const
       
  1100 	{
       
  1101     CCoeControl* controls[] = 
       
  1102         {
       
  1103         iPreviewLabel
       
  1104         };
       
  1105     TInt count = 0;
       
  1106     for ( TUint ii = 0 ; ii < (sizeof(controls) / sizeof(CCoeControl*)); ii++ )
       
  1107         {
       
  1108         if ( controls[ii] )
       
  1109             {
       
  1110             count++;
       
  1111             }   
       
  1112         }
       
  1113 
       
  1114     return count ;
       
  1115 	}
       
  1116 
       
  1117 CCoeControl* CAknFepPreview::ComponentControl(TInt aIndex) const
       
  1118 	{
       
  1119     CCoeControl* controls[] = 
       
  1120         {
       
  1121         iPreviewLabel
       
  1122         };
       
  1123 
       
  1124     for ( TUint ii = 0; (ii < sizeof(controls) / sizeof(CCoeControl*)); ii++ )
       
  1125         {
       
  1126         if ( controls[ii] && aIndex-- == 0 )
       
  1127             {
       
  1128             return controls[ii];
       
  1129             }
       
  1130         }
       
  1131     // shouldn't be called while no components.
       
  1132     return NULL ;
       
  1133 	}
       
  1134 
       
  1135 CAknFepPreview::CAknFepPreview()
       
  1136 	{
       
  1137 	}
       
  1138 
       
  1139 void CAknFepPreview::ConstructL( RWindowTreeNode& /*aParent */)
       
  1140 	{
       
  1141 	RWindowGroup& wg = CCoeEnv::Static()->RootWin();
       
  1142 	CreateWindowL( wg );
       
  1143 	RWindow& window = Window();
       
  1144 	iPreviewLabel = new( ELeave ) CEikLabel;
       
  1145 	iPreviewLabel->SetContainerWindowL( window );
       
  1146 	iPreviewLabel->SetLabelAlignment( ELayoutAlignCenter );	
       
  1147 	iPreviewLabel->SetMopParent( this );
       
  1148 	window.SetRequiredDisplayMode( EColor16MA );
       
  1149 	window.SetTransparencyAlphaChannel();
       
  1150 	window.SetOrdinalPosition( 0, ECoeWinPriorityAlwaysAtFront + 100 );
       
  1151 	window.SetFaded( EFalse, RWindowTreeNode::EFadeIncludeChildren ); 
       
  1152 	// Enable receive drag event.
       
  1153 	Window().PointerFilter( EPointerFilterDrag, 0 );
       
  1154 	MakeVisible( EFalse );
       
  1155 	ActivateL();
       
  1156 	}
       
  1157 
       
  1158 void CAknFepPreview::CalculateFrameRects(TRect& aOuterRect, TRect& aInnerRect) const
       
  1159 	{
       
  1160 	TRect windowRect = Rect();
       
  1161 
       
  1162 	TAknLayoutRect topLeft;
       
  1163 	topLeft.LayoutRect( windowRect, SkinLayout::Highlight_skin_placing__grid__Line_2());
       
  1164 
       
  1165 	TAknLayoutRect bottomRight;
       
  1166 	bottomRight.LayoutRect( windowRect, SkinLayout::Highlight_skin_placing__grid__Line_5());
       
  1167 
       
  1168 	aOuterRect = TRect( topLeft.Rect().iTl, bottomRight.Rect().iBr );
       
  1169 	aInnerRect = TRect( topLeft.Rect().iBr, bottomRight.Rect().iTl );
       
  1170 	}
       
  1171 
       
  1172 CAknFepUICtrlCandidateScroll* CAknFepUICtrlCandidateScroll::NewL(
       
  1173 							RWindowTreeNode& aParent, MAknFepUIEventObserver* aObserver )
       
  1174 	{
       
  1175 	CAknFepUICtrlCandidateScroll* self = new(ELeave) CAknFepUICtrlCandidateScroll;
       
  1176     CleanupStack::PushL(self);
       
  1177     self->ConstructL( aParent, aObserver );
       
  1178     CleanupStack::Pop();
       
  1179     return self;
       
  1180 	}
       
  1181 
       
  1182 CAknFepUICtrlCandidateScroll::~CAknFepUICtrlCandidateScroll()
       
  1183 	{
       
  1184 	// delete bitmaps
       
  1185 	delete iScrollCloseBitmap;
       
  1186 	delete iScrollCloseBitmapMask; 
       
  1187     delete iNaviArrowBitmapUp;
       
  1188     delete iNaviArrowBitmapUpMask;
       
  1189     delete iNaviArrowBitmapDown;
       
  1190     delete iNaviArrowBitmapDownMask;
       
  1191 	}
       
  1192 
       
  1193 void CAknFepUICtrlCandidateScroll::SizeChanged()
       
  1194 	{
       
  1195 	LayoutIcon();
       
  1196 	}
       
  1197 
       
  1198 void CAknFepUICtrlCandidateScroll::Draw( const TRect& /*aRect*/ ) const
       
  1199 	{
       
  1200     CWindowGc& gc = SystemGc();
       
  1201 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1202 
       
  1203 	// draw the whole frame background according to the containing context, which in this case
       
  1204 	// is the candidate pane, to avoid corner drawing mess and to cope with masked grid frame centre
       
  1205 	MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
       
  1206 	TRect rect = Rect();
       
  1207 	
       
  1208 	// Draw scroll background
       
  1209 	AknsDrawUtils::DrawBackground( skin, cc, this, gc,
       
  1210 								   rect.iTl, rect, KAknsDrawParamDefault );
       
  1211 
       
  1212 	// Draw close Rects
       
  1213 	if ( iShowClose )
       
  1214 		{
       
  1215 		TRect outerRect;
       
  1216 		TRect innerRect;
       
  1217 		CalculateCloseRects( outerRect, innerRect );
       
  1218 		AknsDrawUtils::DrawFrame( skin, gc, outerRect, innerRect,
       
  1219 								  KAknsIIDQsnFrKeypadButtonFrNormal, KAknsIIDDefault ); 
       
  1220 		// Draw close bitmap
       
  1221 		iIndiFepClose.DrawImage( gc, 
       
  1222 								 iScrollCloseBitmap, 
       
  1223 								 iScrollCloseBitmapMask );
       
  1224 		}
       
  1225 	
       
  1226 	// Draw Up arrow & Down arrow
       
  1227 	if ( iShowVerticalScrollArrows )
       
  1228 	    {
       
  1229 	    if ( iShowUpScrollArrows )
       
  1230 	        {
       
  1231 	        iIndiFepArrowUp.DrawImage( gc,
       
  1232 	                                   iNaviArrowBitmapUp, 
       
  1233 	                                   iNaviArrowBitmapUpMask );
       
  1234 	        }
       
  1235 	            
       
  1236 	    if ( iShowDownScrollArrows )
       
  1237 	        {
       
  1238 	        iIndiFepArrowDown.DrawImage( gc, 
       
  1239 	                                     iNaviArrowBitmapDown, 
       
  1240 	                                     iNaviArrowBitmapDownMask );
       
  1241 	        }
       
  1242 	    }
       
  1243 	}
       
  1244 
       
  1245 void CAknFepUICtrlCandidateScroll::HandlePointerEventL( const TPointerEvent & aPointerEvent )
       
  1246 	{
       
  1247 	// Close area is click will close the container
       
  1248 	if ( iObServer != NULL && iIndiFepClose.Rect().Contains( aPointerEvent.iPosition ))
       
  1249 		{
       
  1250 		iObServer->FepUIClosePressed();
       
  1251 		}
       
  1252 	}
       
  1253 
       
  1254 void CAknFepUICtrlCandidateScroll::ShowUpScrollArrows(TBool aValue)
       
  1255     {
       
  1256 	// Update the up arrow if needed
       
  1257     if ( iShowUpScrollArrows != aValue )
       
  1258         {
       
  1259         iShowUpScrollArrows = aValue;
       
  1260         TRect rect = iIndiFepArrowUp.Rect();
       
  1261         Window().Invalidate(rect);
       
  1262         }
       
  1263     }
       
  1264     
       
  1265 void CAknFepUICtrlCandidateScroll::ShowDownScrollArrows( TBool aValue )
       
  1266     {
       
  1267 	// Update the down arrow if needed
       
  1268     if ( iShowDownScrollArrows != aValue )
       
  1269         {
       
  1270         iShowDownScrollArrows = aValue;
       
  1271         TRect rect = iIndiFepArrowDown.Rect();
       
  1272         Window().Invalidate(rect);
       
  1273         }        
       
  1274     }
       
  1275 
       
  1276 void CAknFepUICtrlCandidateScroll::ShowVerticalScrollArrows( TBool aValue )
       
  1277     {
       
  1278     // If the state is changed, the arrows will be redrawn in the new state.
       
  1279     if(!COMPARE_BOOLS(iShowVerticalScrollArrows, aValue))
       
  1280         {
       
  1281         iShowVerticalScrollArrows = aValue;
       
  1282         //TRect rect = iIndiFepArrowUp.Rect();
       
  1283         DrawDeferred();
       
  1284         //rect = iIndiFepArrowDown.Rect();
       
  1285         //Window().Invalidate(rect);
       
  1286         }
       
  1287     }
       
  1288 
       
  1289 TBool CAknFepUICtrlCandidateScroll::IsShowVerticalScrollArrows() const
       
  1290     {
       
  1291     return iShowVerticalScrollArrows;
       
  1292     }
       
  1293 
       
  1294 void CAknFepUICtrlCandidateScroll::ConstructL( RWindowTreeNode& aParent, 
       
  1295 											   MAknFepUIEventObserver* aObserver )
       
  1296 	{
       
  1297     CreateWindowL( aParent );
       
  1298     ConstructBitmapsL();    
       
  1299     iObServer = aObserver; 
       
  1300     
       
  1301     TRect rect;
       
  1302     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, rect );
       
  1303     // Dibert will not need close button
       
  1304     iShowClose = rect.Height() == DibertHeight ? EFalse : ETrue;
       
  1305     
       
  1306 	}
       
  1307 
       
  1308 void CAknFepUICtrlCandidateScroll::ConstructBitmapsL()
       
  1309 	{
       
  1310     MAknsSkinInstance* skin = AknsUtils::SkinInstance();  
       
  1311     
       
  1312     TFileName bmpFile;
       
  1313     bmpFile.Copy(_L("z:"));
       
  1314     bmpFile.Append( KDC_BITMAP_DIR );
       
  1315     bmpFile.Append( KFepUiControlsBitmapFile );  
       
  1316 
       
  1317     // Create close bitmap
       
  1318     AknsUtils::CreateColorIconL( skin,
       
  1319  							     KAknsIIDQgnGrafFepCandiListClose,
       
  1320  							     KAknsIIDQsnIconColors,
       
  1321  							     EAknsCIQsnIconColorsCG20,
       
  1322  							     iScrollCloseBitmap,
       
  1323  							     iScrollCloseBitmapMask,
       
  1324  							     bmpFile,
       
  1325  							     EMbmAknfepuictrlsQgn_indi_input_candi_list_close,
       
  1326  							     EMbmAknfepuictrlsQgn_indi_input_candi_list_close_mask,
       
  1327  							     AKN_LAF_COLOR( 0 )); 
       
  1328     
       
  1329     // Create Up bitmap
       
  1330     AknsUtils::CreateColorIconL( skin,
       
  1331                                  KAknsIIDQgnIndiFepArrowUp,
       
  1332                                  KAknsIIDQsnIconColors,
       
  1333                                  EAknsCIQsnIconColorsCG20,
       
  1334                                  iNaviArrowBitmapUp,
       
  1335                                  iNaviArrowBitmapUpMask,
       
  1336                                  bmpFile,
       
  1337                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_up,
       
  1338                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_up_mask,
       
  1339                                  AKN_LAF_COLOR( 0 ));
       
  1340     
       
  1341     // Create Down bitmap
       
  1342     AknsUtils::CreateColorIconL( skin,
       
  1343                                  KAknsIIDQgnIndiFepArrowDown,
       
  1344                                  KAknsIIDQsnIconColors,
       
  1345                                  EAknsCIQsnIconColorsCG20,
       
  1346                                  iNaviArrowBitmapDown,
       
  1347                                  iNaviArrowBitmapDownMask,
       
  1348                                  bmpFile,
       
  1349                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_down,
       
  1350                                  EMbmAknfepuictrlsQgn_indi_fep_arrow_down_mask,
       
  1351                                  AKN_LAF_COLOR( 0 )); 
       
  1352 	}
       
  1353 
       
  1354 CAknFepUICtrlCandidateScroll::CAknFepUICtrlCandidateScroll()
       
  1355 : iShowVerticalScrollArrows(EFalse),
       
  1356   iShowUpScrollArrows(ETrue),
       
  1357   iShowDownScrollArrows(ETrue),
       
  1358   iShowClose(ETrue)
       
  1359 	{	
       
  1360 	}
       
  1361 
       
  1362 void CAknFepUICtrlCandidateScroll::LayoutIcon()
       
  1363 	{
       
  1364     TRect rect = Rect();
       
  1365     // layout arrow up
       
  1366     TAknWindowLineLayout arrowUpLayout = AknLayoutScalable_Avkon::cell_hyb_candi_scroll_pane_g1(0);
       
  1367     iIndiFepArrowUp.LayoutRect( rect, arrowUpLayout );    
       
  1368     AknIconUtils::SetSize(iNaviArrowBitmapUp, iIndiFepArrowUp.Rect().Size());
       
  1369     
       
  1370     // layout arrow down
       
  1371     TAknWindowLineLayout arrowDownLayout = AknLayoutScalable_Avkon::cell_hyb_candi_scroll_pane_g2(0);
       
  1372     iIndiFepArrowDown.LayoutRect( rect, arrowDownLayout );    
       
  1373     AknIconUtils::SetSize( iNaviArrowBitmapDown, iIndiFepArrowDown.Rect().Size());
       
  1374     
       
  1375     // layout close
       
  1376     TAknWindowLineLayout closeLayout = AknLayoutScalable_Avkon::cell_hyb_candi_scroll_pane_g3(0);
       
  1377     iIndiFepClose.LayoutRect( rect, closeLayout );
       
  1378     AknIconUtils::SetSize( iScrollCloseBitmap, iIndiFepClose.Rect().Size());   
       
  1379     }
       
  1380 
       
  1381 void CAknFepUICtrlCandidateScroll::CalculateCloseRects(TRect& aOuterRect, TRect& aInnerRect) const
       
  1382 	{
       
  1383 	TRect windowRect = iIndiFepClose.Rect();
       
  1384 
       
  1385 	TAknLayoutRect topLeft;
       
  1386 	topLeft.LayoutRect( windowRect, SkinLayout::Highlight_skin_placing__grid__Line_2());
       
  1387 
       
  1388 	TAknLayoutRect bottomRight;
       
  1389 	bottomRight.LayoutRect( windowRect, SkinLayout::Highlight_skin_placing__grid__Line_5());
       
  1390 
       
  1391 	aOuterRect = TRect( topLeft.Rect().iTl, bottomRight.Rect().iBr );
       
  1392 	aInnerRect = TRect( topLeft.Rect().iBr, bottomRight.Rect().iTl );
       
  1393 	}
       
  1394 
       
  1395 // End of file
  1171 // End of file