textinput/peninputcommonctrls/src/peninputdropdownlist/peninputlistonerowwithiconwithbubble.cpp
branchRCL_3
changeset 44 ecbabf52600f
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 // Include 
       
    19 #include <fbs.h>
       
    20 #include <AknsUtils.h>
       
    21 #include <AknLayoutDef.h>
       
    22 #include <AknsDrawUtils.h> 
       
    23 
       
    24 #include <peninputdropdownlistcontext.h>
       
    25 
       
    26 #include "peninputlistonerowwithiconwithbubble.h"
       
    27 #include "peninputcandidate.h"
       
    28 #include "peninputdropdownlist.h"
       
    29 #include "peninputlayout.h"
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // Implementation of Class CListOneRowWithIconWithBubble 
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CListOneRowWithIconWithBubble::CListOneRowWithIconWithBubble
       
    37 // C++ default constructor can NOT contain any code, that
       
    38 // might leave
       
    39 // (other items were commented in a header).
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CListOneRowWithIconWithBubble::CListOneRowWithIconWithBubble(CListManager* aManager, 
       
    43                                          MFepCtrlDropdownListContext *aOwner)
       
    44 : CListOneRowWithIcon(aManager, aOwner)
       
    45     {
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CListOneRowWithIconWithBubble::NewL
       
    50 // factory function
       
    51 // (other items were commented in a header).
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CListOneRowWithIconWithBubble* CListOneRowWithIconWithBubble::NewL(CListManager* aManager, 
       
    55                                                MFepCtrlDropdownListContext *aOwner)
       
    56     {
       
    57     CListOneRowWithIconWithBubble* self = new (ELeave) CListOneRowWithIconWithBubble(aManager, aOwner);
       
    58     CleanupStack::PushL(self);
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop();
       
    61     return self;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CListOneRowWithIconWithBubble::~CListOneRowWithIconWithBubble
       
    66 // desstrutor function
       
    67 // (other items were commented in a header).
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CListOneRowWithIconWithBubble::~CListOneRowWithIconWithBubble()
       
    71     {     
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CListOneRowWithIconWithBubble::HandlePointerDownL
       
    76 // handle pointer down 
       
    77 // (other items were commented in a header).
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CListOneRowWithIconWithBubble::HandlePointerDownL(const TPoint& aPoint)
       
    81     {
       
    82     // Pass the event first to the base     
       
    83     CList::HandlePointerDownL(aPoint);
       
    84 
       
    85     // If click in navigation rect and NextButton is not disable, then do 
       
    86     if ( iNavigationRect.Contains(aPoint) )
       
    87         {      
       
    88         if ( (iOwner->GetLastCandidateIndex() < iOwner->CandidateCount()) 
       
    89              || ( iOwner->GetPages()->PageCount() > 1 ) )
       
    90             {
       
    91 			#ifdef RD_TACTILE_FEEDBACK
       
    92             static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()->
       
    93                 DoTactileFeedback(ETouchFeedbackBasic);
       
    94 			#endif
       
    95             }        
       
    96         
       
    97         if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable )
       
    98             {
       
    99             // If click in down button and the down button is enabled 
       
   100             iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr);
       
   101             iIndicateButtonClicked = ETrue;
       
   102             DrawSelection(iClickedRect, ETrue);                
       
   103             } 
       
   104         else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable )
       
   105             {
       
   106             // If click in up button and the up button is enabled                 
       
   107             iClickedRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr);
       
   108             iIndicateButtonClicked = ETrue;
       
   109             DrawSelection(iClickedRect, ETrue);                
       
   110             }
       
   111         }
       
   112     else
       
   113         {
       
   114         TInt index = -1;
       
   115         CCandidate* candidate = FindCandidate(aPoint, index);
       
   116         if(candidate)
       
   117             {
       
   118             iOwner->DrawBubble(iClickedRect, candidate->GetCandidate());
       
   119             }
       
   120         }
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CListOneRowWithIconWithBubble::HandlePointerDragL
       
   125 // handle pointer drag function
       
   126 // (other items were commented in a header).
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void CListOneRowWithIconWithBubble::HandlePointerDragL(const TPoint& aPoint)
       
   130     {
       
   131     // Pass the event first to the base
       
   132     CList::HandlePointerDragL(aPoint);
       
   133 
       
   134     if ( iIndicateButtonClicked )  // clicked rect is not outside the whole DDL
       
   135         {
       
   136         if ( iNavigationRect.Contains(aPoint) )
       
   137             {
       
   138             iOwner->ClearBubble();
       
   139             
       
   140             if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable &&
       
   141                  iNavigationNextRect != iClickedRect )
       
   142                 {
       
   143                 // If click in down button and the down button is enabled
       
   144                 iMoveLatestRect = iClickedRect;                
       
   145                 iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr);
       
   146                 } 
       
   147             else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable &&
       
   148                       iNavigationPreviousRect != iClickedRect )
       
   149                 {
       
   150                 // If click in up button and the up button is enabled
       
   151                 iMoveLatestRect = iClickedRect;                    
       
   152                 iClickedRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr);
       
   153                 }  
       
   154             CompareRect(iMoveLatestRect, iClickedRect);
       
   155             }
       
   156         else if ( iContentRect.Contains(aPoint) )
       
   157             { 
       
   158             CCandidate* candidate = FindCandidate(aPoint, iClickedCandidateIndex);        
       
   159                 
       
   160             if ( candidate )
       
   161                 {
       
   162                 // If click in candidates area
       
   163                 if(iClickedRect != candidate->GetRect())
       
   164                     {
       
   165                     // Reset clicked rect when move to other candidate.
       
   166                     iMoveLatestRect = iClickedRect;
       
   167                     iClickedRect.SetRect(candidate->GetRect().iTl, candidate->GetRect().Size());
       
   168                     
       
   169                     CompareRect(iMoveLatestRect, iClickedRect);
       
   170                     iOwner->ClearBubble();
       
   171                     iOwner->DrawBubble(iClickedRect, candidate->GetCandidate());                    
       
   172                     }
       
   173                 }
       
   174             else
       
   175                 {
       
   176                 iOwner->ClearBubble();
       
   177                 iMoveLatestRect = iClickedRect;
       
   178                 
       
   179                 iClickedRect = KEmptyRect;
       
   180                 CompareRect(iMoveLatestRect, iClickedRect);
       
   181                 }            
       
   182             }
       
   183         else
       
   184             {
       
   185             CompareRect(iClickedRect, iMoveLatestRect);
       
   186             iOwner->ClearBubble();
       
   187             iClickedRect = KEmptyRect;
       
   188             iMoveLatestRect = iClickedRect;
       
   189             
       
   190             CompareRect(iMoveLatestRect, iClickedRect);
       
   191             }
       
   192         }
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CListOneRowWithIconWithBubble::HandlePointerUpL
       
   197 // handle pointer up function
       
   198 // (other items were commented in a header).
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 void CListOneRowWithIconWithBubble::HandlePointerUpL(const TPoint& aPoint)
       
   202     {
       
   203     // Reset the button clicked flag to EFalse
       
   204     iIndicateButtonClicked = EFalse;
       
   205 
       
   206     if ( !iClickedRect.IsEmpty() )
       
   207         {
       
   208         // Find out which rectangle was clicked and save it for 
       
   209         // later usage (HandlePointerUpL)
       
   210         if ( iContentRect.Contains(aPoint) )
       
   211             {
       
   212             // The point is inside the content rect
       
   213             // Check whether the point is inside the same last clicked
       
   214             // candidate rectangle
       
   215              
       
   216             if ( iClickedRect.Contains(aPoint) )
       
   217                 {
       
   218                 if ( iClickedCandidateIndex != KErrNotFound )
       
   219                     {
       
   220                     // Redraw the selected aread  
       
   221                     DrawSelection(iClickedRect, EFalse);
       
   222 
       
   223                     // We have selected a candidate and iClickedCandidateIndex is the selected Index.
       
   224                     // Then send message to plugin
       
   225                     CCandidate* candidate = iOwner->GetCandidate(iClickedCandidateIndex);
       
   226                     if ( candidate )
       
   227                         {
       
   228                         iOwner->ReportCandidateSelectEventL(candidate->GetCandidate(),
       
   229                                                            iClickedCandidateIndex);
       
   230                         }
       
   231                     }
       
   232                 }
       
   233             }
       
   234         else if ( iNavigationRect.Contains(aPoint) )
       
   235             {
       
   236             if ( iNavigationRect == iClickedRect ) 
       
   237                 {
       
   238                 iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() );
       
   239                 iOwner->SetCapture(ETrue);
       
   240                 }
       
   241             }
       
   242 
       
   243         iClickedRect =  KEmptyRect;   
       
   244         }
       
   245     iOwner->ClearBubble();    
       
   246     }
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // CListOneRowWithIconWithBubble::HandlePointerLeave
       
   250 // handle pointer leave function
       
   251 // (other items were commented in a header).
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 void CListOneRowWithIconWithBubble::HandlePointerLeave(const TPoint& /*aPoint*/)
       
   255     {
       
   256     iMoveLatestRect = iClickedRect;
       
   257     iClickedRect = KEmptyRect;
       
   258     DrawSelection( iMoveLatestRect, EFalse );
       
   259     DrawHighightCell(iMoveLatestRect, ETrue);
       
   260     }
       
   261 
       
   262 // -----------------------------------------------------------------------------
       
   263 // CListOneRowWithIconWithBubble::CompareRect
       
   264 // Compare src and des rect
       
   265 // (other items were commented in a header).
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 TBool CListOneRowWithIconWithBubble::CompareRect(const TRect& aSrcRect, const TRect& aDesRect)
       
   269     {
       
   270     if(aSrcRect != aDesRect)  
       
   271         {
       
   272         DrawSelection(aDesRect, ETrue);
       
   273         DrawSelection(aSrcRect, EFalse);
       
   274         DrawHighightCell(aSrcRect, ETrue);
       
   275         }
       
   276           
       
   277     return EFalse;
       
   278     }
       
   279 
       
   280 // End Of File