textinput/peninputcommonctrls/src/peninputdropdownlist/peninputlistmultirowwithiconwithbubble.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 <peninputdropdownlistcontext.h>
       
    23 #include <peninputdropdownlist.h>
       
    24 #include <AknsDrawUtils.h>
       
    25 #include "peninputlistmultirowwithicon.h"
       
    26 #include "peninputlistmultirowwithiconwithbubble.h"
       
    27 #include "peninputlayout.h"
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // Implementation of Class CListMultiRowWithIconWithBubble 
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CListMultiRowWithIconWithBubble::CListMultiRowWithIconWithBubble
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave
       
    37 // (other items were commented in a header).
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CListMultiRowWithIconWithBubble::CListMultiRowWithIconWithBubble(CListManager* aManager, 
       
    41                                              MFepCtrlDropdownListContext *aOwner)
       
    42 : CListMultiRowWithIcon(aManager, aOwner)
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CListMultiRowWithIconWithBubble::NewL
       
    48 // factory function
       
    49 // (other items were commented in a header).
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CListMultiRowWithIconWithBubble* CListMultiRowWithIconWithBubble::NewL(CListManager* aManager, 
       
    53                                                    MFepCtrlDropdownListContext *aOwner)
       
    54     {
       
    55     CListMultiRowWithIconWithBubble* self = new (ELeave) CListMultiRowWithIconWithBubble(aManager, aOwner);
       
    56     CleanupStack::PushL(self);
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop();
       
    59     return self;
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CListMultiRowWithIconWithBubble::~CListMultiRowWithIconWithBubble
       
    64 // desstrutor function
       
    65 // (other items were commented in a header).
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CListMultiRowWithIconWithBubble::~CListMultiRowWithIconWithBubble()
       
    69     {     
       
    70     }
       
    71 
       
    72     
       
    73 // -----------------------------------------------------------------------------
       
    74 // CListMultiRowWithIconWithBubble::HandlePointerDownL
       
    75 // handle pointer down 
       
    76 // (other items were commented in a header).
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void CListMultiRowWithIconWithBubble::HandlePointerDownL(const TPoint& aPoint)
       
    80     {
       
    81     CList::HandlePointerDownL(aPoint);
       
    82 
       
    83     // also consider fuzzy boundry of drop down list
       
    84     TRect fuzzyrect = iRect;
       
    85     fuzzyrect.Grow(iOwner->FuzzyBoundry(), iOwner->FuzzyBoundry());
       
    86 
       
    87     if (!fuzzyrect.Contains(aPoint))
       
    88         {
       
    89         iOwner->SetCapture(EFalse);
       
    90         iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex());
       
    91         iOwner->ClearBubble();
       
    92         return;
       
    93         }
       
    94 
       
    95     // If click in navigation rect and NextButton is not disable, then do 
       
    96     if ( iNavigationRect.Contains(aPoint) )
       
    97         {   
       
    98         if ( iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable )
       
    99             {
       
   100 			#ifdef RD_TACTILE_FEEDBACK
       
   101 	        static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()->
       
   102 	            DoTactileFeedback(ETouchFeedbackBasic);
       
   103 			#endif
       
   104 	        
       
   105             iClickedRect.SetRect(iNavigationCloseRect.iTl, iNavigationCloseRect.iBr);
       
   106             iIndicateButtonClicked = ETrue;
       
   107             DrawSelection(iClickedRect, ETrue);                
       
   108             }  
       
   109         else if (!iOwner->PageCtrlShown())
       
   110             {
       
   111             iClickedRect = KDummyRect;
       
   112             return;
       
   113             }
       
   114         else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable )
       
   115             {
       
   116 			#ifdef RD_TACTILE_FEEDBACK
       
   117 	        static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()->
       
   118 	            DoTactileFeedback(ETouchFeedbackBasic);
       
   119 			#endif
       
   120             
       
   121             iClickedRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr);
       
   122             iIndicateButtonClicked = ETrue;
       
   123             DrawSelection(iClickedRect, ETrue);                
       
   124             }
       
   125         else if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable )
       
   126             {
       
   127 			#ifdef RD_TACTILE_FEEDBACK
       
   128 	        static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()->
       
   129 	            DoTactileFeedback(ETouchFeedbackBasic);
       
   130 			#endif
       
   131             
       
   132             iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr);
       
   133             iIndicateButtonClicked = ETrue;
       
   134             DrawSelection(iClickedRect, ETrue);                
       
   135             }
       
   136         else
       
   137             {
       
   138             iClickedRect = KDummyRect;                                
       
   139             }
       
   140         }
       
   141     else
       
   142         {
       
   143         TInt index = -1;
       
   144         CCandidate* candidate = FindCandidate(aPoint, index);
       
   145         if(candidate)
       
   146             {
       
   147             iOwner->DrawBubble(iClickedRect, candidate->GetCandidate());
       
   148             }
       
   149         }
       
   150     }
       
   151      
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CListMultiRowWithIconWithBubble::HandlePointerDragL
       
   155 // handle pointer drag function
       
   156 // (other items were commented in a header).
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CListMultiRowWithIconWithBubble::HandlePointerDragL(const TPoint& aPoint)
       
   160     {
       
   161     // Pass the event first to the base
       
   162     CList::HandlePointerDragL(aPoint);
       
   163 
       
   164     CCandidate* candidate = FindCandidate(aPoint, iClickedCandidateIndex);
       
   165     
       
   166     TBool isUpdateBubble = EFalse;
       
   167     if ( candidate )
       
   168         {
       
   169         if (iClickedRect != candidate->GetRect())
       
   170             {// move to the other candidate
       
   171             // set update prview bubble flag
       
   172             isUpdateBubble = ETrue;
       
   173             // remenber the previous cell rect
       
   174             iMoveLatestRect = iClickedRect;
       
   175             // get the new cell rect
       
   176             iClickedRect.SetRect(candidate->GetRect().iTl, candidate->GetRect().Size());
       
   177             }
       
   178         }
       
   179     else if ( iNavigationRect.Contains(aPoint) )
       
   180         {
       
   181         iOwner->ClearBubble();
       
   182         if ( iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable &&
       
   183              iClickedRect !=  iNavigationCloseRect)
       
   184             {
       
   185             iMoveLatestRect = iClickedRect;
       
   186             iClickedRect.SetRect(iNavigationCloseRect.iTl, iNavigationCloseRect.iBr);
       
   187             CompareRect(iMoveLatestRect, iClickedRect);
       
   188             }
       
   189         else if (!iOwner->PageCtrlShown())
       
   190             {
       
   191             return;
       
   192             }
       
   193         else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable &&
       
   194                   iClickedRect != iNavigationPreviousRect )
       
   195             {
       
   196             iMoveLatestRect = iClickedRect;
       
   197             iClickedRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr);
       
   198             CompareRect(iMoveLatestRect, iClickedRect);
       
   199             }
       
   200         else if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable &&
       
   201                   iClickedRect != iNavigationNextRect )
       
   202             {
       
   203             iMoveLatestRect = iClickedRect;
       
   204             iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr);
       
   205             CompareRect(iMoveLatestRect, iClickedRect);
       
   206             } 
       
   207         else if(!((iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable) ||
       
   208                 (iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable) ||
       
   209                 (iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable)))
       
   210             {
       
   211             // Move to navigation area but not valid navigation button
       
   212             TRect dummyrect = KDummyRect;
       
   213             if(iClickedRect != dummyrect)
       
   214                 {
       
   215                 iMoveLatestRect = iClickedRect;
       
   216                 iClickedRect = KDummyRect;
       
   217                 CompareRect(iMoveLatestRect, iClickedRect);
       
   218                 }
       
   219             }
       
   220         }
       
   221     else
       
   222         {// move to the aperture
       
   223         // remember the previous cell 
       
   224         iMoveLatestRect = iClickedRect;
       
   225         // set the new cell to empty
       
   226         iClickedRect = KDummyRect;
       
   227         // redraw the cell only when drag outside at the first time
       
   228         if(iMoveLatestRect != iClickedRect)
       
   229             {
       
   230             iOwner->ClearBubble();
       
   231             DrawSelection(iMoveLatestRect, EFalse);
       
   232             DrawHighightCell(iMoveLatestRect, ETrue);            
       
   233             }
       
   234         }
       
   235     
       
   236     if(candidate && isUpdateBubble)
       
   237         {
       
   238         iOwner->ClearBubble();
       
   239         CompareRect(iMoveLatestRect, iClickedRect);
       
   240         // Show preview bubble when drag into a candidate cell
       
   241         // Make sure show the bubble after redraw clicked cell
       
   242         iOwner->DrawBubble(iClickedRect, candidate->GetCandidate());
       
   243         }
       
   244         
       
   245     }
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CListMultiRowWithIconWithBubble::HandlePointerUpL
       
   249 // handle pointer up function
       
   250 // (other items were commented in a header).
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 void CListMultiRowWithIconWithBubble::HandlePointerUpL(const TPoint& aPoint)
       
   254     {  
       
   255     // Reset the button clicked flag to EFalse
       
   256     iIndicateButtonClicked = EFalse;
       
   257    
       
   258     iOwner->ClearBubble();
       
   259     
       
   260 #ifdef __WINS__
       
   261     // in emulator, double click will be treated as:
       
   262     // 1 pointer down and 2 pointer up, which will cause error
       
   263     if (iClickedRect.IsEmpty() && ((CFepUiBaseCtrl*)iOwner)->PointerDown()) 
       
   264 #else
       
   265     if (iClickedRect.IsEmpty())
       
   266 #endif // __WINS__
       
   267         {
       
   268         iOwner->SetCapture(EFalse);
       
   269         // Change active list object ie. close the dd-list
       
   270         iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() );
       
   271         }
       
   272     else
       
   273         {
       
   274         if ( iContentRect.Contains(aPoint) )
       
   275             {
       
   276             if ( iClickedRect.Contains(aPoint) )
       
   277                 {
       
   278                 // Redraw the selected aread    
       
   279                 DrawSelection(iClickedRect, EFalse);
       
   280                 
       
   281                 iOwner->SetCapture(EFalse);
       
   282                 
       
   283                 // We have selected a candidate and iClickedCandidateIndex is the selected Index.
       
   284                 // Send the candidate to others
       
   285                 if (iClickedCandidateIndex != KErrNotFound)
       
   286                     {
       
   287 			        iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() );
       
   288                     CCandidate* candidate = iOwner->GetCandidate(iClickedCandidateIndex);
       
   289                     if ( candidate )
       
   290                         {
       
   291                         iOwner->ReportCandidateSelectEventL(candidate->GetCandidate(),
       
   292                                                            iClickedCandidateIndex);
       
   293                         }
       
   294                     }
       
   295                 }
       
   296             }
       
   297         else if ( iNavigationCloseRect.Contains(aPoint) )
       
   298             {
       
   299             if ( iNavigationCloseRect == iClickedRect )
       
   300                 {
       
   301                 iOwner->SetCapture(EFalse);
       
   302 		        iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex());
       
   303                 }
       
   304             }
       
   305         else if (!iOwner->PageCtrlShown())
       
   306             {
       
   307             iClickedRect = KEmptyRect;
       
   308             return;
       
   309             }
       
   310         else if ( iNavigationNextRect.Contains(aPoint) )
       
   311             {
       
   312             if ( iNavigationNextRect == iClickedRect )
       
   313                 {
       
   314                 iOwner->NotifyGetNextPage();
       
   315                 UpdateListL();
       
   316                 }
       
   317             }
       
   318         else if ( iNavigationPreviousRect.Contains(aPoint) )
       
   319             {
       
   320             if ( iNavigationPreviousRect == iClickedRect )
       
   321                 {
       
   322                 // Change page to previous
       
   323                 iOwner->NotifyGetPreviousPage(); // do nothing, just to avoid clear candidate
       
   324 
       
   325                 TInt firstIndex = 0;
       
   326                 TInt lastIndex = 0;
       
   327                 
       
   328                 if (iOwner->GetPages()->GetPreviousIndex(iOwner->GetLastCandidateIndex(), 
       
   329                                                          firstIndex,lastIndex))    
       
   330                     {
       
   331                     iOwner->SetFirstCandidateIndex(firstIndex);
       
   332                     iOwner->SetLastCandidateIndex(lastIndex);
       
   333                     }
       
   334                     
       
   335                 UpdateListL(ETrue, EFalse);
       
   336                 }             
       
   337             }
       
   338             
       
   339        	iClickedRect =  KEmptyRect;
       
   340         }
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CListMultiRowWithIconWithBubble::CompareRect
       
   345 // Compare src and des rect 
       
   346 // (other items were commented in a header).
       
   347 // -----------------------------------------------------------------------------
       
   348 //	
       
   349 TBool CListMultiRowWithIconWithBubble::CompareRect(const TRect& aSrcRect, const TRect& aDesRect)
       
   350     {
       
   351     if(aSrcRect != aDesRect)  
       
   352         {
       
   353         DrawSelection(aDesRect, ETrue);
       
   354         DrawSelection(aSrcRect, EFalse);
       
   355         DrawHighightCell(aSrcRect, ETrue);
       
   356         }
       
   357           
       
   358     return EFalse;        
       
   359     }
       
   360 
       
   361 // End Of File