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