textinput/peninputcommonctrls/src/peninputdropdownlist/peninputlistonerowwithiconwithbubble.cpp
changeset 27 694fa80c203c
parent 24 fc42a86c98e3
child 35 0f326f2e628e
equal deleted inserted replaced
24:fc42a86c98e3 27:694fa80c203c
     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             }
       
   155         else if ( iContentRect.Contains(aPoint) )
       
   156             { 
       
   157             CCandidate* candidate = FindCandidate(aPoint, iClickedCandidateIndex);        
       
   158                 
       
   159             if ( candidate )
       
   160                 {
       
   161                 // If click in candidates area
       
   162                 if(iClickedRect != candidate->GetRect())
       
   163                     {
       
   164                     // Reset clicked rect when move to other candidate.
       
   165                     iMoveLatestRect = iClickedRect;
       
   166                     iClickedRect.SetRect(candidate->GetRect().iTl, candidate->GetRect().Size());
       
   167                     
       
   168                     iOwner->ClearBubble();
       
   169                     iOwner->DrawBubble(iClickedRect, candidate->GetCandidate());                    
       
   170                     }
       
   171                 }
       
   172             else
       
   173                 {
       
   174                 iOwner->ClearBubble();
       
   175                 iMoveLatestRect = iClickedRect;
       
   176                 
       
   177                 iClickedRect = KEmptyRect;
       
   178                 }            
       
   179             }
       
   180         else
       
   181             {
       
   182             CompareRect(iClickedRect, iMoveLatestRect);
       
   183             iOwner->ClearBubble();
       
   184             iClickedRect = KEmptyRect;
       
   185             iMoveLatestRect = iClickedRect;
       
   186             }
       
   187         CompareRect(iMoveLatestRect, iClickedRect);
       
   188         }
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CListOneRowWithIconWithBubble::HandlePointerUpL
       
   193 // handle pointer up function
       
   194 // (other items were commented in a header).
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 void CListOneRowWithIconWithBubble::HandlePointerUpL(const TPoint& aPoint)
       
   198     {
       
   199     // Reset the button clicked flag to EFalse
       
   200     iIndicateButtonClicked = EFalse;
       
   201 
       
   202     if ( !iClickedRect.IsEmpty() )
       
   203         {
       
   204         // Find out which rectangle was clicked and save it for 
       
   205         // later usage (HandlePointerUpL)
       
   206         if ( iContentRect.Contains(aPoint) )
       
   207             {
       
   208             // The point is inside the content rect
       
   209             // Check whether the point is inside the same last clicked
       
   210             // candidate rectangle
       
   211              
       
   212             if ( iClickedRect.Contains(aPoint) )
       
   213                 {
       
   214                 if ( iClickedCandidateIndex != KErrNotFound )
       
   215                     {
       
   216                     // Redraw the selected aread  
       
   217                     DrawSelection(iClickedRect, EFalse);
       
   218 
       
   219                     // We have selected a candidate and iClickedCandidateIndex is the selected Index.
       
   220                     // Then send message to plugin
       
   221                     CCandidate* candidate = iOwner->GetCandidate(iClickedCandidateIndex);
       
   222                     if ( candidate )
       
   223                         {
       
   224                         iOwner->ReportCandidateSelectEventL(candidate->GetCandidate(),
       
   225                                                            iClickedCandidateIndex);
       
   226                         }
       
   227                     }
       
   228                 }
       
   229             }
       
   230         else if ( iNavigationRect.Contains(aPoint) )
       
   231             {
       
   232             if ( iNavigationRect == iClickedRect ) 
       
   233                 {
       
   234                 iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() );
       
   235                 iOwner->SetCapture(ETrue);
       
   236                 }
       
   237             }
       
   238 
       
   239         iClickedRect =  KEmptyRect;   
       
   240         }
       
   241     iOwner->ClearBubble();    
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CListOneRowWithIconWithBubble::HandlePointerLeave
       
   246 // handle pointer leave function
       
   247 // (other items were commented in a header).
       
   248 // -----------------------------------------------------------------------------
       
   249 //
       
   250 void CListOneRowWithIconWithBubble::HandlePointerLeave(const TPoint& /*aPoint*/)
       
   251     {
       
   252     iMoveLatestRect = iClickedRect;
       
   253     iClickedRect = KEmptyRect;
       
   254     DrawSelection( iMoveLatestRect, EFalse );
       
   255     DrawHighightCell(iMoveLatestRect, ETrue);
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CListOneRowWithIconWithBubble::CompareRect
       
   260 // Compare src and des rect
       
   261 // (other items were commented in a header).
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 TBool CListOneRowWithIconWithBubble::CompareRect(const TRect& aSrcRect, const TRect& aDesRect)
       
   265     {
       
   266     if(aSrcRect != aDesRect)  
       
   267         {
       
   268         DrawSelection(aDesRect, ETrue);
       
   269         DrawSelection(aSrcRect, EFalse);
       
   270         DrawHighightCell(aSrcRect, ETrue);
       
   271         }
       
   272           
       
   273     return EFalse;
       
   274     }
       
   275 
       
   276 // End Of File