textinput/peninputcommonctrls/src/peninputdropdownlist/peninputlist.cpp
changeset 27 694fa80c203c
parent 24 fc42a86c98e3
child 35 0f326f2e628e
equal deleted inserted replaced
24:fc42a86c98e3 27:694fa80c203c
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Abstract base class for drop-down list objects
       
    15 *
       
    16 */
       
    17 
       
    18 #include <fbs.h>
       
    19 
       
    20 #include "peninputlist.h"
       
    21 #include "peninputcandidate.h"
       
    22 #include "peninputpluginutils.h"
       
    23 #include <AknsDrawUtils.h> 
       
    24 #include "peninputdropdownlist.h"
       
    25 #include "peninputlayout.h"
       
    26 
       
    27 const TInt KInvalidCandIndex = -1;
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // Implementation of Class CList 
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CList::CList
       
    35 // construtor function
       
    36 // (other items were commented in a header).
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CList::CList(CListManager* aManager, MFepCtrlDropdownListContext *aOwner) 
       
    40 : iOwner(aOwner), iManager(aManager), iNextButtonDisable(ETrue),
       
    41   iPreviousButtonDisable(ETrue)
       
    42     {
       
    43     }
       
    44     
       
    45 // -----------------------------------------------------------------------------
       
    46 // CList::~CList
       
    47 // desstrutor function
       
    48 // (other items were commented in a header).
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CList::~CList()
       
    52     {     
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CList::ConstructL
       
    57 // 2nd construtor function
       
    58 // (other items were commented in a header).
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 void CList::ConstructL()
       
    62     {
       
    63     // Pre calculate all areas
       
    64     CalculateAreas();
       
    65     }
       
    66     
       
    67 // -----------------------------------------------------------------------------
       
    68 // CList::HandlePointerDownL
       
    69 // handle pointer down 
       
    70 // (other items were commented in a header).
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CList::HandlePointerDownL(const TPoint& aPoint)
       
    74     {
       
    75     // position where the tap occurred
       
    76 
       
    77     // set clicked rect as empty rect
       
    78     iClickedRect = KEmptyRect;
       
    79 
       
    80     // Check if content rect tapped
       
    81     if ( iContentRect.Contains(aPoint) )
       
    82         {
       
    83         CCandidate* candidate = FindCandidate(aPoint, iClickedCandidateIndex);
       
    84         
       
    85         if ( candidate )
       
    86             {
       
    87 			#ifdef RD_TACTILE_FEEDBACK
       
    88 	        static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()->
       
    89 	            DoTactileFeedback(ETouchFeedbackBasic);
       
    90 			#endif //RD_TACTILE_FEEDBACK
       
    91             TRect rect = candidate->GetRect();
       
    92             iClickedRect.SetRect(rect.iTl,rect.iBr);
       
    93 
       
    94             // Set the flag to indicate that candidate button has been pressed down
       
    95             // so that we know to draw correctly
       
    96             iIndicateButtonClicked = ETrue ;
       
    97             DrawSelection(iClickedRect,ETrue);
       
    98             DrawHighightCell(iClickedRect,EFalse);
       
    99             }
       
   100         else
       
   101             {
       
   102             iClickedRect = KDummyRect;
       
   103             // This is a dummy value so that we know
       
   104             // in HandlePointerUpL that iClickedRect is
       
   105             // is not empty but the pointer down event did
       
   106             // not occure inside any valid rect such as
       
   107             // candidate rect or any of the navigation rects
       
   108             }
       
   109         }
       
   110     } 
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CList::HandlePointerDragL
       
   114 // handle pointer drag function
       
   115 // (other items were commented in a header).
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CList::HandlePointerDragL(const TPoint& /*aPoint*/)
       
   119     {
       
   120     }
       
   121     
       
   122 // -----------------------------------------------------------------------------
       
   123 // CList::HandlePointerUpL
       
   124 // handle pointer up function
       
   125 // (other items were commented in a header).
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CList::HandlePointerUpL( const TPoint& /*aPoint*/)
       
   129     {
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CList::HandlePointerLeave
       
   134 // handle pointer leave function
       
   135 // (other items were commented in a header).
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CList::HandlePointerLeave(const TPoint& /*aPoint*/)
       
   139     {
       
   140     DrawSelection( iClickedRect, EFalse );
       
   141     DrawHighightCell(iClickedRect, ETrue);
       
   142     }
       
   143     
       
   144 // -----------------------------------------------------------------------------
       
   145 // CList::Draw
       
   146 // draw the list
       
   147 // (other items were commented in a header).
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CList::Draw()
       
   151     {
       
   152     // Draw mask
       
   153     iOwner->DrawMask(iRect);
       
   154     
       
   155     // Active bitmap context
       
   156     iOwner->ActivateBitmapContext();
       
   157 
       
   158     iOwner->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   159     iOwner->Gc()->SetBrushColor(iOwner->GetBgColor());
       
   160     iOwner->Gc()->SetPenSize(iOwner->GetPenSize());       
       
   161     iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
       
   162     iOwner->Gc()->SetPenColor( iOwner->GetBorderColor() );          
       
   163     iOwner->Gc()->DrawRect(iRect); 
       
   164     
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CList::Rect
       
   169 // get the rect of list
       
   170 // (other items were commented in a header).
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 const TRect& CList::Rect()
       
   174     {
       
   175     return iRect;
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CList::UpdateList
       
   180 // update the list
       
   181 // (other items were commented in a header).
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 void CList::UpdateListL(TBool /*aDrawFlag*/, TBool /*aRecalculate*/)
       
   185     {
       
   186     // Do nothing, every derived class will have its action
       
   187     }
       
   188 
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CList::ResetStatus
       
   192 // update the list
       
   193 // (other items were commented in a header).
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 void CList::ResetStatus()
       
   197     {
       
   198     iPenDownInCandidate = EFalse;
       
   199     iClickedRect = KEmptyRect;
       
   200     }
       
   201     
       
   202 // -----------------------------------------------------------------------------
       
   203 // CList::FindCandidate
       
   204 // find candidate according to the assigned position
       
   205 // (other items were commented in a header).
       
   206 // -----------------------------------------------------------------------------
       
   207 //    
       
   208 CCandidate* CList::FindCandidate(const TPoint& aPosition, TInt& aIndex)
       
   209     {
       
   210     CCandidate* candidate = NULL;
       
   211     
       
   212     aIndex = KErrNotFound;
       
   213 
       
   214     if ( iOwner->CandidateCount() > 0 )
       
   215         {
       
   216         // Loop through the candidates and find the one that contains
       
   217         // the TPoint aPosition
       
   218         for (TInt i = iOwner->GetFirstCandidateIndex(); i < iOwner->GetLastCandidateIndex(); i++)
       
   219             {
       
   220             candidate = iOwner->GetCandidate(i); 
       
   221             
       
   222             if ( !candidate )
       
   223                 {
       
   224                 continue;
       
   225                 }
       
   226                 
       
   227             TRect rect = candidate->GetRect();
       
   228             
       
   229             if ( rect.Contains(aPosition) )
       
   230                 {
       
   231                 // We found the candidate
       
   232                 aIndex = i;
       
   233                 return candidate;
       
   234                 }
       
   235             }
       
   236         }
       
   237         
       
   238     return NULL;
       
   239     }
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // CList::CalculatePositionsL
       
   243 // calculate the position of all visible cells in the list
       
   244 // (other items were commented in a header).
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 TInt CList::CalculatePositionsL()
       
   248     {
       
   249     return 0;
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 // CList::SetHighlightCell
       
   254 // Set cell to highlight or not
       
   255 // (other items were commented in a header).
       
   256 // -----------------------------------------------------------------------------
       
   257 //
       
   258 void CList::SetHighlightCell(const TInt aCellIndex, TBool aHighlight, TBool aForceDraw)
       
   259     {
       
   260     if ( !aForceDraw && iPenDownInCandidate ) 
       
   261         {
       
   262         return;        
       
   263         }
       
   264         
       
   265     if ( ( aCellIndex<0 ) || ( aCellIndex > iOwner->CandidateCount() ) )
       
   266         {
       
   267         return;
       
   268         }
       
   269 
       
   270     CCandidate* candidate = iOwner->GetCandidate(aCellIndex);
       
   271     
       
   272     if ( ! candidate )
       
   273         {
       
   274         return;
       
   275         }
       
   276 
       
   277     TRect rect = candidate->GetRect();
       
   278     
       
   279     iOwner->DrawMask(rect);
       
   280     iOwner->ActivateBitmapContext();
       
   281 
       
   282 	if (!iDropdownListDrawInfo.iSupportSkin)
       
   283 		{
       
   284 	    iOwner->Gc()->SetBrushStyle(CGraphicsContext::ENullBrush); 
       
   285 	    iOwner->Gc()->SetPenSize(iOwner->GetPenSize());
       
   286 	    iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
       
   287 	    iOwner->Gc()->SetPenColor(iOwner->GetBorderColor());
       
   288 
       
   289 	    // Draw the bottom and right line
       
   290 	    iOwner->Gc()->DrawLine( TPoint(rect.iTl.iX, rect.iBr.iY),rect.iBr);
       
   291 	    iOwner->Gc()->DrawLine( TPoint(rect.iBr.iX, rect.iTl.iY),rect.iBr);
       
   292 	    
       
   293 	    // also draw left and top line
       
   294 	    if (iOwner->GetCellHorizontalMargin() != 0)
       
   295 	        {
       
   296 	        iOwner->Gc()->DrawLine(rect.iTl, TPoint(rect.iTl.iX, rect.iBr.iY));
       
   297 	        }
       
   298 	        
       
   299 	    if (iOwner->GetCellVerticalMargin() != 0)
       
   300 	        {
       
   301 	        iOwner->Gc()->DrawLine(rect.iTl, TPoint(rect.iBr.iX, rect.iTl.iY));
       
   302 	        }
       
   303 
       
   304 	    rect.Shrink(TSize(1,1));
       
   305 	    
       
   306 	    if ((iIsMultiRows) && (iOwner->GetCellVerticalMargin() == 0))
       
   307 	        {        
       
   308 	        if ( ( rect.iTl.iY - 1 - Rect().iTl.iY ) != ( iOwner->GetRowNum() - 1 ) * 
       
   309                                                       iOwner->GetCellHeight() )
       
   310 	            {
       
   311 	            //If it isn't the last row
       
   312 	            rect.iBr.iY = rect.iBr.iY + 1;
       
   313 	            }
       
   314 	        }
       
   315 		}
       
   316 
       
   317     const CFbsBitmap* bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapHighlight);
       
   318     if ( bmp )
       
   319         {
       
   320         if (aHighlight)
       
   321             {
       
   322             CFbsBitmap* bmpTemp = const_cast<CFbsBitmap*>(bmp);
       
   323             AknIconUtils::SetSize(bmpTemp, rect.Size(), EAspectRatioNotPreserved);
       
   324             
       
   325             if (iDropdownListDrawInfo.iSupportSkin)
       
   326                 {
       
   327                 CBitmapDb::TBitmapType bmpID = CBitmapDb::EBitmapHighlight;
       
   328                 CBitmapDb::TBitmapType maskBmpID = CBitmapDb::EBitmapHighlightMask;             
       
   329                 bmp = iOwner->GetBitmapDb()->GetBitMap(bmpID);
       
   330                 bmpTemp = const_cast<CFbsBitmap*>(bmp);
       
   331                 iOwner->Gc()->DrawBitmapMasked(rect, 
       
   332                                                bmp, 
       
   333                                                bmp->SizeInPixels(), 
       
   334                                                iOwner->GetBitmapDb()->GetBitMap(maskBmpID),
       
   335                                                ETrue);
       
   336                 }
       
   337             else
       
   338             	{
       
   339 	            iOwner->Gc()->DrawBitmapMasked(rect, 
       
   340 	                                           bmp, 
       
   341 	                                           bmp->SizeInPixels(), 
       
   342 	                                           iOwner->GetBitmapDb()->GetBitMap(
       
   343                                                                   CBitmapDb::EBitmapHighlightMask),
       
   344 	                                           ETrue);
       
   345             	}
       
   346             }
       
   347         else
       
   348             {
       
   349             // Draw bitmap
       
   350             if (iDropdownListDrawInfo.iSupportSkin)
       
   351             	{
       
   352 			    TRect innerRect = rect;
       
   353 			    innerRect.Shrink( 4, 0 );
       
   354 			    
       
   355 				AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(),
       
   356 										   *iOwner->Gc(),
       
   357 										   rect,
       
   358 										   innerRect,
       
   359 										   iDropdownListDrawInfo.iCandidateLeftImgID,
       
   360 										   iDropdownListDrawInfo.iCandidateMiddleImgID,
       
   361 										   iDropdownListDrawInfo.iCandidateRightImgID);
       
   362             	}
       
   363         	else
       
   364         		{
       
   365 	            bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPrimary);
       
   366 	            iOwner->Gc()->DrawBitmapMasked(rect, 
       
   367 	                                           bmp, 
       
   368 	                                           bmp->SizeInPixels(), 
       
   369 	                                           iOwner->GetBitmapDb()->GetBitMap(
       
   370                                                                     CBitmapDb::EBitmapPrimaryMask),
       
   371 	                                           ETrue);
       
   372         		}
       
   373             }
       
   374         }
       
   375     else
       
   376         {
       
   377         if (aHighlight)
       
   378             {
       
   379             iOwner->Gc()->SetBrushColor(iOwner->GetHighLightBgColor());
       
   380             }
       
   381         else
       
   382             {
       
   383             iOwner->Gc()->SetBrushColor(iOwner->GetBgColor());        
       
   384             }
       
   385 
       
   386         iOwner->Gc()->SetPenStyle(CGraphicsContext::ENullPen);
       
   387         iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   388 
       
   389         rect.Shrink(TSize(1,1));
       
   390 
       
   391         iOwner->Gc()->DrawRect(rect);
       
   392 
       
   393         rect.Shrink(TSize(-1,-1));
       
   394         }       
       
   395     
       
   396     // draw canditate's text
       
   397     iOwner->Gc()->UseFont(iOwner->GetFont());
       
   398 
       
   399     candidate->DrawText(*iOwner->Gc(),iOwner->GetAlignment(),
       
   400                         iOwner->GetTextMargin(),
       
   401                         iOwner->GetTextColor(),
       
   402                         iOwner->GetSpecialTextColor(),
       
   403                         iOwner->GetFixedText());
       
   404     
       
   405     iOwner->Gc()->DiscardFont();      
       
   406     iOwner->Invalidate(candidate->GetRect());
       
   407     }
       
   408 
       
   409 // -----------------------------------------------------------------------------
       
   410 // CList::DrawSelection
       
   411 // Draw selection cell just selected
       
   412 // (other items were commented in a header).
       
   413 // -----------------------------------------------------------------------------
       
   414 //        
       
   415 void CList::DrawSelection(const TRect& aRect, TBool aIndicate)
       
   416     {
       
   417     // Check whether the rect that should be redrawn is in content rect   
       
   418     TRect tmpRect = iContentRect;
       
   419     tmpRect.Intersection(aRect);
       
   420     
       
   421     if ( tmpRect == aRect )
       
   422         {
       
   423         // rect is inside content rect thus we
       
   424         // should be drawing candidate press
       
   425         DrawCandidatePress(aRect, aIndicate);
       
   426         }
       
   427     else
       
   428         {
       
   429         // rect is inside navigation rect thus we
       
   430         // should be drawing navigation press
       
   431         DrawNavigationPress(aRect, aIndicate);     
       
   432         }
       
   433     }
       
   434 
       
   435 // -----------------------------------------------------------------------------
       
   436 // CList::DrawCandidatePress
       
   437 // draw candidate when pressed or un-pressed
       
   438 // (other items were commented in a header).
       
   439 // -----------------------------------------------------------------------------
       
   440 //
       
   441 void CList::DrawCandidatePress(const TRect& aRect, TBool aIndicate)
       
   442     {
       
   443     // We are dealing with the candidates
       
   444     TInt index = 0;
       
   445     // Get the candidate
       
   446     CCandidate* candidate = FindCandidate(aRect.Center(), index);
       
   447     
       
   448     if (!candidate)
       
   449         {
       
   450         return;
       
   451         }
       
   452         
       
   453     iOwner->DrawMask(aRect);
       
   454     
       
   455     iOwner->ActivateBitmapContext();
       
   456     
       
   457     iPenDownInCandidate = EFalse;
       
   458     
       
   459     TBool isDrawBmp = ETrue;
       
   460     CBitmapDb::TBitmapType bmpID = CBitmapDb::EBitmapPrimary;
       
   461     CBitmapDb::TBitmapType maskBmpID = CBitmapDb::EBitmapPrimaryMask;
       
   462     const CFbsBitmap* bmp = NULL;
       
   463     // set bg color
       
   464     if ( aIndicate )
       
   465         {
       
   466         bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPenDown);
       
   467         if ( bmp )
       
   468             {
       
   469             // Draw bitmap
       
   470             bmpID = CBitmapDb::EBitmapPenDown;
       
   471             maskBmpID = CBitmapDb::EBitmapPenDownMask;
       
   472             isDrawBmp = ETrue;                       
       
   473             iPenDownInCandidate = ETrue;           
       
   474             }
       
   475         else
       
   476             {
       
   477             iOwner->Gc()->SetBrushColor(iOwner->GetButtonDownBgColor());
       
   478             }                
       
   479         }
       
   480     else
       
   481         {
       
   482         const RArray<TInt>& secondaryList = iOwner->GetSecondaryList();
       
   483         
       
   484         if ( iOwner->IsEnableSecondary() && (secondaryList.Find(index) != KErrNotFound) )
       
   485             {
       
   486             bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapSecondary);
       
   487             if ( bmp )
       
   488                 {
       
   489                 // Draw bitmap
       
   490                 bmpID = CBitmapDb::EBitmapSecondary;
       
   491                 maskBmpID = CBitmapDb::EBitmapSecondaryMask;
       
   492                 isDrawBmp = ETrue;                                           
       
   493                 }
       
   494             else            
       
   495                 {
       
   496                 bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPrimary);
       
   497                 if ( bmp )
       
   498                     {
       
   499                     // Draw bitmap
       
   500                     bmpID = CBitmapDb::EBitmapPrimary;
       
   501                     maskBmpID = CBitmapDb::EBitmapPrimaryMask;
       
   502                     isDrawBmp = ETrue;                                           
       
   503                     }
       
   504                 else            
       
   505                     {
       
   506                     // If enable multi color and the color has been set, then use the color
       
   507                     iOwner->Gc()->SetBrushColor(iOwner->GetBgColor());                    
       
   508                     }
       
   509                 }                            
       
   510             }
       
   511         else
       
   512             {
       
   513             // Else use background color
       
   514             bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPrimary);
       
   515             if ( bmp )
       
   516                 {
       
   517                 bmpID = CBitmapDb::EBitmapPrimary;
       
   518                 maskBmpID = CBitmapDb::EBitmapPrimaryMask;
       
   519                 isDrawBmp = ETrue;                   
       
   520                 }
       
   521             else
       
   522                 {
       
   523                 iOwner->Gc()->SetBrushColor(iOwner->GetBgColor());
       
   524                 }            
       
   525             }
       
   526         }
       
   527     
       
   528     // Get the candidate rect
       
   529     TRect rect = candidate->GetRect();
       
   530     
       
   531     if (!iDropdownListDrawInfo.iSupportSkin)
       
   532     	{
       
   533 	    iOwner->Gc()->SetBrushStyle( CGraphicsContext::ENullBrush ); 
       
   534 	    iOwner->Gc()->SetPenSize(iOwner->GetPenSize());
       
   535 	    iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
       
   536 	    iOwner->Gc()->SetPenColor(iOwner->GetBorderColor());
       
   537 
       
   538 	    // Draw the bottom line
       
   539 	    iOwner->Gc()->DrawLine( TPoint(rect.iTl.iX, rect.iBr.iY),rect.iBr );
       
   540 	    iOwner->Gc()->DrawLine( TPoint(rect.iBr.iX, rect.iTl.iY),rect.iBr );
       
   541 	    
       
   542 	    if (iOwner->GetCellHorizontalMargin() != 0)
       
   543 	        {
       
   544 	        iOwner->Gc()->DrawLine(rect.iTl, TPoint(rect.iTl.iX, rect.iBr.iY));
       
   545 	        }
       
   546 	        
       
   547 	    if (iOwner->GetCellVerticalMargin() != 0)
       
   548 	        {
       
   549 	        iOwner->Gc()->DrawLine(rect.iTl, TPoint(rect.iBr.iX, rect.iTl.iY));
       
   550 	        }
       
   551 
       
   552 	    rect.Shrink(TSize(1,1));
       
   553 	    
       
   554 	    if ((iIsMultiRows) && (iOwner->GetCellVerticalMargin() == 0))
       
   555 	        {        
       
   556 	        if ( ( rect.iTl.iY - 1 - Rect().iTl.iY ) != ( iOwner->GetRowNum() - 1 ) * 
       
   557                                                       iOwner->GetCellHeight() )
       
   558 	            {
       
   559 	            //If it isn't the last row
       
   560 	            rect.iBr.iY = rect.iBr.iY + 1;
       
   561 	            }
       
   562 	        }
       
   563     	}
       
   564         
       
   565     if ( isDrawBmp )
       
   566         {
       
   567         if (iDropdownListDrawInfo.iSupportSkin)
       
   568         	{
       
   569 			if ( aIndicate )
       
   570 				{
       
   571 /*				
       
   572 				iOwner->Gc()->SetPenStyle(CGraphicsContext::ENullPen);
       
   573 		        iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush );    
       
   574 		        iOwner->Gc()->SetBrushColor(iDropdownListDrawInfo.iCandidatesHighlightColor);
       
   575 		        
       
   576 		        // Draw the whole rect without border
       
   577 		        iOwner->Gc()->DrawRect( rect );  	*/
       
   578 		        
       
   579                 /*bmpID = CBitmapDb::EBitmapHighlight;
       
   580                 maskBmpID = CBitmapDb::EBitmapHighlightMask;		        
       
   581 	            bmp = iOwner->GetBitmapDb()->GetBitMap(bmpID);
       
   582 	            iOwner->Gc()->DrawBitmapMasked(rect, 
       
   583 	                                           bmp, 
       
   584 	                                           bmp->SizeInPixels(), 
       
   585 	                                           iOwner->GetBitmapDb()->GetBitMap(maskBmpID),
       
   586 	                                           ETrue); 		*/
       
   587                 TRect innerRect = rect;
       
   588                 innerRect.Shrink( 4, 0 );
       
   589                 
       
   590                 // ----- draw bitmaps -----
       
   591                 iOwner->ActivateBitmapContext();
       
   592                 iOwner->Gc()->Clear(rect);
       
   593                     
       
   594                 
       
   595                 
       
   596                 AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(),
       
   597                                            *iOwner->Gc(),
       
   598                                            rect,
       
   599                                            innerRect,
       
   600                                            iDropdownListDrawInfo.iCandidatePressedLeftImgID,
       
   601                                            iDropdownListDrawInfo.iCandidatePressedMiddleImgID,
       
   602                                            iDropdownListDrawInfo.iCandidatePressedRightImgID);				
       
   603 				}
       
   604 			else
       
   605 				{
       
   606 			    TRect innerRect = rect;
       
   607 			    innerRect.Shrink( 4, 0 );
       
   608 			    
       
   609 			    // ----- draw bitmaps -----
       
   610 			    iOwner->ActivateBitmapContext();
       
   611 			    iOwner->Gc()->Clear(rect);
       
   612 			    	
       
   613 				
       
   614 				
       
   615 				AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(),
       
   616 										   *iOwner->Gc(),
       
   617 										   rect,
       
   618 										   innerRect,
       
   619 										   iDropdownListDrawInfo.iCandidateLeftImgID,
       
   620 										   iDropdownListDrawInfo.iCandidateMiddleImgID,
       
   621 										   iDropdownListDrawInfo.iCandidateRightImgID);
       
   622 				}
       
   623         	}
       
   624         else
       
   625         	{
       
   626 	        bmp = iOwner->GetBitmapDb()->GetBitMap(bmpID);
       
   627 	        iOwner->Gc()->DrawBitmapMasked(rect, 
       
   628 	                                       bmp, 
       
   629 	                                       bmp->SizeInPixels(), 
       
   630 	                                       iOwner->GetBitmapDb()->GetBitMap(maskBmpID), 
       
   631 	                                       ETrue);
       
   632         	}
       
   633         }
       
   634     else
       
   635         {
       
   636         iOwner->Gc()->SetPenStyle(CGraphicsContext::ENullPen);
       
   637         iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush );    
       
   638         // Draw the whole rect without border
       
   639         iOwner->Gc()->DrawRect( rect );      
       
   640         }
       
   641         
       
   642     // draw canditate's text
       
   643     iOwner->Gc()->UseFont(iOwner->GetFont());
       
   644     TRgb textColor;
       
   645     if (aIndicate)
       
   646         {
       
   647         textColor = iOwner->GetHighLightTextColor();
       
   648         }
       
   649     else
       
   650         {
       
   651         textColor = iOwner->GetTextColor();
       
   652         }
       
   653         
       
   654     candidate->DrawText(*iOwner->Gc(),iOwner->GetAlignment(),
       
   655                         iOwner->GetTextMargin(),        
       
   656                         textColor,
       
   657                         iOwner->GetSpecialTextColor(),
       
   658                         iOwner->GetFixedText());      
       
   659                         
       
   660     iOwner->Gc()->DiscardFont();
       
   661     
       
   662     // Invalidate the rect
       
   663     iOwner->Invalidate(aRect);
       
   664     }
       
   665 
       
   666 // -----------------------------------------------------------------------------
       
   667 // CList::DrawNavigationPress
       
   668 // draw navigation button when pressed or un-pressed
       
   669 // (other items were commented in a header).
       
   670 // -----------------------------------------------------------------------------
       
   671 //
       
   672 TBool CList::DrawNavigationPress(const TRect& /*aRect*/, TBool /*aIndicate*/)
       
   673     {
       
   674     return EFalse;
       
   675     }
       
   676 
       
   677 // -----------------------------------------------------------------------------
       
   678 // CList::CalculateAreas
       
   679 // Calculate all kinds of rectangles
       
   680 // (other items were commented in a header).
       
   681 // -----------------------------------------------------------------------------
       
   682 //    
       
   683 void CList::CalculateAreas()
       
   684     {
       
   685     //
       
   686     }
       
   687 
       
   688 // -----------------------------------------------------------------------------
       
   689 // CList::SizeChanged
       
   690 // size changed function
       
   691 // (other items were commented in a header).
       
   692 // -----------------------------------------------------------------------------
       
   693 //
       
   694 void CList::SizeChanged()
       
   695     {
       
   696     CalculateAreas();
       
   697     }
       
   698 
       
   699 // -----------------------------------------------------------------------------
       
   700 // CList::DrawCandidates
       
   701 // draw all visible candidates to the list
       
   702 // (other items were commented in a header).
       
   703 // -----------------------------------------------------------------------------
       
   704 //    
       
   705 void CList::DrawCandidates()
       
   706     {    
       
   707     const RArray<TInt>& secondaryList = iOwner->GetSecondaryList();
       
   708     
       
   709     TBool isDrawBmp = EFalse;
       
   710     CBitmapDb::TBitmapType bmpID = CBitmapDb::EBitmapPrimary;
       
   711     CBitmapDb::TBitmapType maskBmpID = CBitmapDb::EBitmapPrimaryMask;
       
   712     const CFbsBitmap* bmp = NULL;         
       
   713     for(TInt i = iOwner->GetFirstCandidateIndex(); i < iOwner->GetLastCandidateIndex(); i++)
       
   714         {
       
   715         CCandidate* candidate = iOwner->GetCandidate(i);
       
   716         if ( !candidate )
       
   717             {
       
   718             continue;
       
   719             }
       
   720             
       
   721         TRect rect = candidate->GetRect();
       
   722  
       
   723         if (iDropdownListDrawInfo.iSupportSkin)
       
   724         	{
       
   725         	
       
   726         	if (iOwner->GetHighlightList().Find(i) != KErrNotFound)
       
   727         		{
       
   728 				/*iOwner->Gc()->SetPenStyle(CGraphicsContext::ENullPen);
       
   729 		        iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush );    
       
   730 		        iOwner->Gc()->SetBrushColor(iDropdownListDrawInfo.iCandidatesHighlightColor);
       
   731 		        // Draw the whole rect without border
       
   732 		        iOwner->Gc()->DrawRect( rect );*/
       
   733                 bmpID = CBitmapDb::EBitmapHighlight;
       
   734                 maskBmpID = CBitmapDb::EBitmapHighlightMask;		        
       
   735 	            bmp = iOwner->GetBitmapDb()->GetBitMap(bmpID);
       
   736 	            iOwner->Gc()->DrawBitmapMasked(rect, 
       
   737 	                                           bmp, 
       
   738 	                                           bmp->SizeInPixels(), 
       
   739 	                                           iOwner->GetBitmapDb()->GetBitMap(maskBmpID),
       
   740 	                                           ETrue);
       
   741         		}
       
   742         	else
       
   743         		{
       
   744 			    TRect innerRect = rect;
       
   745 			    innerRect.Shrink( 4, 0 );
       
   746 			    
       
   747 			    // ----- draw bitmaps -----
       
   748 			 	iOwner->ActivateBitmapContext();                
       
   749 			    	
       
   750 				
       
   751 				AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(),
       
   752 													   *iOwner->Gc(),
       
   753 													   rect,
       
   754 													   innerRect,
       
   755 													   iDropdownListDrawInfo.iCandidateLeftImgID,
       
   756 													   iDropdownListDrawInfo.iCandidateMiddleImgID,
       
   757 													   iDropdownListDrawInfo.iCandidateRightImgID);
       
   758         		}
       
   759         	}
       
   760         else
       
   761         	{
       
   762 	        if ( iOwner->IsEnableSecondary() && ( secondaryList.Find(i) != KErrNotFound) )
       
   763 	            {
       
   764 	            bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapSecondary);
       
   765 	            if ( bmp )
       
   766 	                {
       
   767 	                // Draw bitmap
       
   768 	                bmpID = CBitmapDb::EBitmapSecondary;
       
   769 	                maskBmpID = CBitmapDb::EBitmapSecondaryMask;
       
   770 	                isDrawBmp = ETrue;                                           
       
   771 	                }
       
   772 	            else            
       
   773 	                {
       
   774 	                bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPrimary);
       
   775 	                if ( bmp )
       
   776 	                    {
       
   777 	                    // Draw bitmap
       
   778 	                    bmpID = CBitmapDb::EBitmapPrimary;
       
   779 	                    maskBmpID = CBitmapDb::EBitmapPrimaryMask;
       
   780 	                    isDrawBmp = ETrue;                                           
       
   781 	                    }
       
   782 	                else            
       
   783 	                    {
       
   784 	                    // If enable multi color and the color has been set, then use the color
       
   785 	                    iOwner->Gc()->SetBrushColor(iOwner->GetBgColor());                    
       
   786 	                    }
       
   787 	                }                            
       
   788 	            }
       
   789 	        else if (iOwner->GetHighlightList().Find(i) != KErrNotFound)
       
   790 	            {
       
   791 	            bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapHighlight);
       
   792 	            if ( bmp )
       
   793 	                {
       
   794 	                // Draw bitmap
       
   795 	                bmpID = CBitmapDb::EBitmapHighlight;
       
   796 	                maskBmpID = CBitmapDb::EBitmapHighlightMask;
       
   797 	                isDrawBmp = ETrue;                                           
       
   798 	                }
       
   799 	            else            
       
   800 	                {
       
   801 	                // If the cell is set to highlight, use high light color
       
   802 	                iOwner->Gc()->SetBrushColor(iOwner->GetHighLightBgColor());
       
   803 	                }                                        
       
   804 	            }
       
   805 	        else
       
   806 	            {
       
   807 	            // Else use background color
       
   808 	            bmp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPrimary);
       
   809 	            if ( bmp )
       
   810 	                {
       
   811 	                bmpID = CBitmapDb::EBitmapPrimary;
       
   812 	                maskBmpID = CBitmapDb::EBitmapPrimaryMask;
       
   813 	                isDrawBmp = ETrue;                   
       
   814 	                }
       
   815 	            else
       
   816 	                {
       
   817 	                iOwner->Gc()->SetBrushColor(iOwner->GetBgColor());
       
   818 	                }            
       
   819 	            }         
       
   820 
       
   821 	        iOwner->Gc()->SetBrushStyle( CGraphicsContext::ENullBrush ); 
       
   822 	        iOwner->Gc()->SetPenSize(iOwner->GetPenSize());
       
   823 	        iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
       
   824 	        iOwner->Gc()->SetPenColor(iOwner->GetBorderColor());
       
   825 	        // Draw the bottom line
       
   826 	        iOwner->Gc()->DrawLine( rect.iTl, TPoint(rect.iBr.iX, rect.iTl.iY) );
       
   827 	        iOwner->Gc()->DrawLine( TPoint(rect.iTl.iX, rect.iBr.iY),rect.iBr );
       
   828 	        iOwner->Gc()->DrawLine( TPoint(rect.iBr.iX, rect.iTl.iY),rect.iBr );
       
   829 	        
       
   830 	        if (iOwner->GetCellHorizontalMargin() != 0)
       
   831 	            {
       
   832 	            iOwner->Gc()->DrawLine(rect.iTl, TPoint(rect.iTl.iX, rect.iBr.iY));
       
   833 	            }
       
   834 
       
   835 	        rect.Shrink(TSize(1,1));
       
   836 
       
   837 	        if ( isDrawBmp )
       
   838 	            {
       
   839                 bmpID = CBitmapDb::EBitmapSecondary;
       
   840                 maskBmpID = CBitmapDb::EBitmapSecondaryMask;	            
       
   841 	            bmp = iOwner->GetBitmapDb()->GetBitMap(bmpID);
       
   842 	            iOwner->Gc()->DrawBitmapMasked(rect, 
       
   843 	                                           bmp, 
       
   844 	                                           bmp->SizeInPixels(), 
       
   845 	                                           iOwner->GetBitmapDb()->GetBitMap(maskBmpID),
       
   846 	                                           ETrue);                        
       
   847 	            }
       
   848 	        else
       
   849 	            {            
       
   850 	            iOwner->Gc()->SetPenStyle(CGraphicsContext::ENullPen);
       
   851 	            iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush );    
       
   852 	            iOwner->Gc()->DrawRect(rect);
       
   853 	            }
       
   854         	}
       
   855         
       
   856         // Draw the text of the candidate
       
   857         iOwner->Gc()->UseFont(iOwner->GetFont());
       
   858         candidate->DrawText(*iOwner->Gc(),iOwner->GetAlignment(),
       
   859                                           iOwner->GetTextMargin(),        
       
   860                                           iOwner->GetTextColor(),
       
   861                                           iOwner->GetSpecialTextColor(),
       
   862                                           iOwner->GetFixedText());
       
   863         }
       
   864     iOwner->Gc()->DiscardFont();
       
   865     }
       
   866 
       
   867 // -----------------------------------------------------------------------------
       
   868 // CList::CompareRect
       
   869 // Compare two rect is equal or not
       
   870 // (other items were commented in a header).
       
   871 // -----------------------------------------------------------------------------
       
   872 //
       
   873 TBool CList::CompareRect(const TRect& aSrcRect, const TRect& aDesRect)
       
   874     {
       
   875     
       
   876     if (aSrcRect == aDesRect)
       
   877         {
       
   878         DrawSelection(iClickedRect, ETrue);
       
   879         DrawHighightCell(iClickedRect, EFalse);
       
   880         return ETrue;        
       
   881         }
       
   882     else
       
   883         {
       
   884         TBool hasDraw = EFalse;
       
   885         const RArray<TInt>& highLightList = iOwner->GetHighlightList();        
       
   886         for (TInt i=0; i < highLightList.Count(); i++ )
       
   887             {
       
   888             CCandidate* candidate = iOwner->GetCandidate(i);        
       
   889             if ( candidate )
       
   890                 {
       
   891                 if ( iClickedRect == candidate->GetRect() )
       
   892                     {
       
   893                     DrawHighightCell(iClickedRect, ETrue);
       
   894                     hasDraw = ETrue;
       
   895                     break;
       
   896                     }
       
   897                 }
       
   898             }        
       
   899       
       
   900         if ( !hasDraw )
       
   901             {
       
   902             DrawSelection(iClickedRect, EFalse);
       
   903             DrawHighightCell(iClickedRect, ETrue);
       
   904             }
       
   905 
       
   906         return EFalse;        
       
   907         }
       
   908     }
       
   909 
       
   910 // -----------------------------------------------------------------------------
       
   911 // CList::Move
       
   912 // when the drop down list is moved, the function will be called.
       
   913 // (other items were commented in a header).
       
   914 // -----------------------------------------------------------------------------
       
   915 //
       
   916 void CList::Move(const TPoint& aOffsetPoint)
       
   917     {
       
   918     // Move the iRect
       
   919     iRect.Move(aOffsetPoint);
       
   920     
       
   921     // Move the content rect
       
   922     iContentRect.Move(aOffsetPoint);
       
   923     
       
   924     // Move the navigation rect
       
   925     iNavigationRect.Move(aOffsetPoint);
       
   926     
       
   927     // Move the close button rect
       
   928     iNavigationCloseRect.Move(aOffsetPoint);
       
   929     
       
   930     // Move the up button rect
       
   931     iNavigationPreviousRect.Move(aOffsetPoint);
       
   932     
       
   933     // Move the down button rect
       
   934     iNavigationNextRect.Move(aOffsetPoint);
       
   935     
       
   936     }
       
   937 
       
   938 void CList::DrawHighightCell(const TRect& aSrcRect, const TBool aIndidate)
       
   939     {
       
   940     const RArray<TInt>& highLightList = iOwner->GetHighlightList();
       
   941 
       
   942     TInt candIdx;
       
   943     for (TInt i = 0; i < highLightList.Count(); i++)
       
   944         {
       
   945         candIdx = highLightList[i];
       
   946 
       
   947         // if highlight candidate are not in current page, then do not draw it
       
   948         if ((candIdx >= iOwner->GetFirstCandidateIndex()) &&
       
   949             (candIdx <= iOwner->GetLastCandidateIndex()))
       
   950             {
       
   951             CCandidate* candidate = iOwner->GetCandidate(candIdx);
       
   952             
       
   953             if (candidate)
       
   954                 {
       
   955                 if (aSrcRect == candidate->GetRect())
       
   956                     {
       
   957                     if (aIndidate)
       
   958                         {
       
   959                         SetHighlightCell(candIdx, ETrue);
       
   960                         }
       
   961 
       
   962                     continue;    
       
   963                     }
       
   964                 }
       
   965             }
       
   966         }
       
   967     }
       
   968     
       
   969 TInt CList::StartCandIdxOfLine(TInt /*aCandIndex*/)
       
   970     {
       
   971     return KInvalidCandIndex;
       
   972     }
       
   973     
       
   974 void CList::SetNextPageHighlightCellAfterOnePageL(const TInt /*aCellIndex*/)
       
   975     {
       
   976     }
       
   977 
       
   978 void CList::SetDropdownListImgID(TDropdownListDrawInfo aDropdownListDrawInfo)
       
   979 	{
       
   980 	iDropdownListDrawInfo = aDropdownListDrawInfo;
       
   981 	}
       
   982 	
       
   983 
       
   984 // End Of File