uifw/AvKon/src/AknAdaptiveSearchGrid.cpp
branchRCL_3
changeset 20 d48ab3b357f1
parent 19 aecbbf00d063
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
    59 
    59 
    60 _LIT( KSlashOfPageIndicator, "/" );
    60 _LIT( KSlashOfPageIndicator, "/" );
    61 _LIT( KSpaceCharacter, " " );
    61 _LIT( KSpaceCharacter, " " );
    62 const TInt KCloseAndClearButtonCount = 2;  
    62 const TInt KCloseAndClearButtonCount = 2;  
    63 
    63 
    64    
       
    65 // ============================ MEMBER FUNCTIONS ===============================
    64 // ============================ MEMBER FUNCTIONS ===============================
    66 
    65 
    67 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    68 // CAknAdaptiveSearchGrid::NewL()
    67 // CAknAdaptiveSearchGrid::NewL()
    69 // Two-phased constructor.
    68 // Two-phased constructor.
   123 //
   122 //
   124 CAknAdaptiveSearchGrid::~CAknAdaptiveSearchGrid()
   123 CAknAdaptiveSearchGrid::~CAknAdaptiveSearchGrid()
   125     { 
   124     { 
   126     _AKNTRACE_FUNC_ENTER;
   125     _AKNTRACE_FUNC_ENTER;
   127     CEikonEnv::Static()->EikAppUi()->RemoveFromStack( this );
   126     CEikonEnv::Static()->EikAppUi()->RemoveFromStack( this );
   128     delete iBgContextOfFindPane;
   127     if ( iBgContextOfControlPane )
   129     delete iBgContextOfControlPane;
   128     	{
   130     delete iSkinContextOfFindPane; 
   129 		delete iBgContextOfControlPane;
   131     delete iInputFrame;
   130 		iBgContextOfControlPane = NULL;
   132  
   131     	}
   133     // Clear current region of AS
   132     // Clear current region of AS
   134     iCurrentRegion.Clear();    
   133     iCurrentRegion.Clear();    
   135     iButtonArray.ResetAndDestroy();
   134     iButtonArray.ResetAndDestroy();
   136     
   135     
   137     if ( iEditor )
       
   138         {
       
   139         TRAP_IGNORE(iEditor->TextView()->SetCursorVisibilityL( 
       
   140             TCursor::EFCursorInvisible, TCursor::EFCursorInvisible ));
       
   141         delete iEditor;
       
   142         }   
       
   143     if( iGridChars )
   136     if( iGridChars )
   144         {
   137         {
   145         delete iGridChars;
   138         delete iGridChars;
   146         iGridChars = NULL;
   139         iGridChars = NULL;
   147         }               
   140         }               
   169         {
   162         {
   170         delete iPageIndicator;
   163         delete iPageIndicator;
   171         iPageIndicator = NULL;
   164         iPageIndicator = NULL;
   172         }
   165         }
   173        
   166        
   174     CAknWsEventMonitor* eventMonitor = iAppUi->EventMonitor();    
   167     if ( iAppUi )
   175     eventMonitor->Enable( EFalse ); 
   168         {
   176     eventMonitor->RemoveObserver( this ); 
   169         CAknWsEventMonitor* eventMonitor = iAppUi->EventMonitor();  
       
   170         eventMonitor->Enable( EFalse ); 
       
   171         eventMonitor->RemoveObserver( this ); 
       
   172         }
   177     _AKNTRACE_FUNC_EXIT;
   173     _AKNTRACE_FUNC_EXIT;
   178     }
   174     }
   179 
   175 
   180 // -----------------------------------------------------------------------------
   176 // -----------------------------------------------------------------------------
   181 // CAknAdaptiveSearchGrid::ConstructL()
   177 // CAknAdaptiveSearchGrid::ConstructL()
   196         if ( err == KErrNone )
   192         if ( err == KErrNone )
   197             {
   193             {
   198             Window().SetBackgroundColor(~0);
   194             Window().SetBackgroundColor(~0);
   199             }
   195             }
   200         }        
   196         }        
       
   197     Window().SetPointerGrab( ETrue );
   201 
   198 
   202     CAknWsEventMonitor* eventMonitor = iAppUi->EventMonitor();    
   199     CAknWsEventMonitor* eventMonitor = iAppUi->EventMonitor();    
   203     eventMonitor->AddObserverL( this );
   200     eventMonitor->AddObserverL( this );
   204     eventMonitor->Enable();
   201     eventMonitor->Enable();
   205     
   202     
   206     iSkinContextOfFindPane = CAknsListBoxBackgroundControlContext::NewL( KAknsIIDQsnBgAreaControlPopup, 
       
   207                                                                          TRect(0,0,0,0), 
       
   208                                                                          EFalse, 
       
   209                                                                          KAknsIIDNone, 
       
   210                                                                          TRect(0,0,0,0) );   
       
   211     iBgContextOfFindPane = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrInput, 
       
   212                                                                      TRect(0,0,0,0), 
       
   213                                                                      TRect(0,0,0,0), 
       
   214                                                                      EFalse );    
       
   215     iBgContextOfControlPane = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQgnGrafAdaptSearchPageBg, 
   203     iBgContextOfControlPane = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQgnGrafAdaptSearchPageBg, 
   216                                                                         TRect(0,0,0,0), EFalse );          
   204                                                                         TRect(0,0,0,0), EFalse );          
   217     // Init components
   205     // Init components
   218     InitControlsL( aFieldStyle );
   206     InitControlsL( aFieldStyle );
   219     InitGrid();   
   207     InitGrid();   
   276         case CAknSearchField::EPopupAdaptiveSearchWindow:
   264         case CAknSearchField::EPopupAdaptiveSearchWindow:
   277             flags |= CAknInputFrame::EPopupWindowLayout;
   265             flags |= CAknInputFrame::EPopupWindowLayout;
   278             flags |= CAknInputFrame::EFixedFindWithoutLine;
   266             flags |= CAknInputFrame::EFixedFindWithoutLine;
   279             break;
   267             break;
   280         }
   268         }
   281     iEditor = new (ELeave) CEikEdwin;   
       
   282     
       
   283     iInputFrame = CAknInputFrame::NewL( iEditor, 
       
   284                                         EFalse, 
       
   285                                         KAvkonBitmapFile, 
       
   286                                         EMbmAvkonQgn_indi_find_glass, 
       
   287                                         EMbmAvkonQgn_indi_find_glass_mask, 
       
   288                                         flags );                     
       
   289 
       
   290     iEditor->SetContainerWindowL( *this );
       
   291     iInputFrame->SetContainerWindowL( *this );
       
   292     
       
   293     AknEditUtils::ConstructEditingL( iEditor,
       
   294                                      iTextLimit,
       
   295                                      1,
       
   296                                      EAknEditorCharactersLowerCase,
       
   297                                      EAknEditorAlignLeft,
       
   298                                      EFalse,
       
   299                                      ETrue,
       
   300                                      EFalse );
       
   301     iEditor->SetObserver( this );
       
   302     iEditor->SetBorder( TGulBorder::ENone );
       
   303     iEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
       
   304     iEditor->SetAknEditorAllowedInputModes( EAknEditorTextInputMode |
       
   305                                             EAknEditorNumericInputMode ); 
       
   306     iEditor->AddFlagToUserFlags( CEikEdwin::EAvkonDisableVKB );
       
   307     
       
   308     if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
   309         {
       
   310         iEditor->SetAknEditorPermittedCaseModes( EAknEditorCharactersLowerCase );
       
   311         }
       
   312 
       
   313     TInt editorFlags = EAknEditorFlagNoT9 | 
       
   314                        EAknEditorFlagNoLRNavigation |
       
   315                        EAknEditorFlagForceTransparentFepModes |
       
   316                        EAknEditorFlagNoEditIndicators |
       
   317                        EAknEditorFlagFindPane;
       
   318 
       
   319     iEditor->SetAknEditorFlags( editorFlags );
       
   320     iEditor->CreateTextViewL(); 
       
   321 
       
   322     iInputFrame->SetInputContext( iBgContextOfFindPane );
       
   323     iEditor->SetSkinBackgroundControlContextL( iBgContextOfFindPane );
       
   324   
       
   325     TRgb textColor = KRgbBlack;
       
   326     TInt error = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
       
   327                                             textColor, 
       
   328                                             KAknsIIDQsnTextColors, 
       
   329                                             EAknsCIQsnTextColorsCG19);
       
   330     if( !error )
       
   331         {
       
   332         TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(*iEditor, EColorLabelText, textColor) );       
       
   333         }   
       
   334     
   269     
   335     // Create label for page indicator
   270     // Create label for page indicator
   336     iPageIndicator = new (ELeave) CEikLabel;
   271     iPageIndicator = new (ELeave) CEikLabel;
   337     iPageIndicator->SetObserver( this );
   272     iPageIndicator->SetObserver( this );
   338     iPageIndicator->SetContainerWindowL( *this );
   273     iPageIndicator->SetContainerWindowL( *this );
   407 // Update layout variant. This should be done when 
   342 // Update layout variant. This should be done when 
   408 // KEikDynamicLayoutVariantSwitch message recieved. 
   343 // KEikDynamicLayoutVariantSwitch message recieved. 
   409 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   410 // 
   345 // 
   411 void CAknAdaptiveSearchGrid::UpdateLayoutVariant()
   346 void CAknAdaptiveSearchGrid::UpdateLayoutVariant()
   412     {
   347 	{
   413     _AKNTRACE_FUNC_ENTER;
   348     _AKNTRACE_FUNC_ENTER;
   414     InitGrid(); 
   349 	InitGrid(); 
   415     UpdatePageAndRowCount();                 
   350 	UpdatePageAndRowCount();       	         
   416     if( IsShown() )
   351 	if( IsShown() )
   417         {
   352 		{
   418         ControlsPositions();
   353 		ControlsPositions();
   419         TRAP_IGNORE( UpdateVisibleButtonsL() );  
   354 		TRAP_IGNORE( UpdateVisibleButtonsL() );  
   420         ShowControls();           
   355 		ShowControls();           
   421         }
   356 		}
   422     _AKNTRACE_FUNC_EXIT;
   357     _AKNTRACE_FUNC_EXIT;
   423     }
   358 	}
   424 
   359 
   425 // -----------------------------------------------------------------------------
   360 // -----------------------------------------------------------------------------
   426 // CAknAdaptiveSearchGrid::UpdateSkinL()
   361 // CAknAdaptiveSearchGrid::UpdateSkinL()
   427 // Update adaptive search grid skin. This should be done when 
   362 // Update adaptive search grid skin. This should be done when 
   428 // KAknsMessageSkinChange message recieved. 
   363 // KAknsMessageSkinChange message recieved. 
   429 // -----------------------------------------------------------------------------
   364 // -----------------------------------------------------------------------------
   430 //  
   365 //  
   431 void CAknAdaptiveSearchGrid::UpdateSkinL()
   366 void CAknAdaptiveSearchGrid::UpdateSkinL()
   432     {
   367 	{
   433     CGulIcon* gulIcon = NULL;
   368     CGulIcon* gulIcon = NULL;
   434     gulIcon = GetColorIconL( 0 );        
   369     gulIcon = GetColorIconL( 0 );        
   435     iCloseButton->State()->SetIcon( gulIcon );
   370     iCloseButton->State()->SetIcon( gulIcon );
   436     CGulIcon* gulIcon1 = NULL;
   371     CGulIcon* gulIcon1 = NULL;
   437     gulIcon1 = GetColorIconL( 1 );        
   372     gulIcon1 = GetColorIconL( 1 );        
   438     iDeleteButton->State()->SetIcon( gulIcon1 );
   373     iDeleteButton->State()->SetIcon( gulIcon1 );
   439     CGulIcon* gulIcon2 = NULL;
   374     CGulIcon* gulIcon2 = NULL;
   440     gulIcon2 = GetColorIconL( 2 );        
   375     gulIcon2 = GetColorIconL( 2 );        
   441     iPrevButton->State()->SetIcon( gulIcon2 );      
   376 	iPrevButton->State()->SetIcon( gulIcon2 );		
   442     CGulIcon* gulIcon3 = NULL;
   377     CGulIcon* gulIcon3 = NULL;
   443     gulIcon3 = GetColorIconL( 3 );        
   378     gulIcon3 = GetColorIconL( 3 );        
   444     iNextButton->State()->SetIcon( gulIcon3 );
   379     iNextButton->State()->SetIcon( gulIcon3 );
   445     
   380     
   446     UpdateVisibleButtonsL();                        
   381    	UpdateVisibleButtonsL();	 	    		    
   447         
   382 	    
   448     if( iNumOfPages > 1 )
   383     if( iNumOfPages > 1 )
   449         {   
   384 		{	
   450         // Page pane & page indicator   
   385 		// Page pane & page indicator	
   451         TRect page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane( iLayoutOption) );    
   386     	TRect page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane( iLayoutOption) );	
   452         if( AknsUtils::AvkonSkinEnabled() )
   387     	if( AknsUtils::AvkonSkinEnabled() )
   453             {           
   388 	        {	        
   454             TRgb textColor = KRgbBlack; 
   389 	        TRgb textColor = KRgbBlack; 
   455             TInt error = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
   390     	    TInt error = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
   456                                                     textColor, 
   391     	                                            textColor, 
   457                                                     KAknsIIDQsnTextColors, 
   392     	                                            KAknsIIDQsnTextColors, 
   458                                                     EAknsCIQsnTextColorsCG19);
   393     	                                            EAknsCIQsnTextColorsCG19);
   459             if( !error )                    
   394     	    if( !error )        	        
   460                 AknLayoutUtils::OverrideControlColorL(*iPageIndicator, EColorLabelText, textColor);                                        
   395     	        AknLayoutUtils::OverrideControlColorL(*iPageIndicator, EColorLabelText, textColor);         	                           
   461             }               
   396 		    }			    
   462         iBgContextOfControlPane->SetRect( page_pane );     
   397 		iBgContextOfControlPane->SetRect( page_pane );     
   463         }
   398 		}
   464     }
   399 	}
   465 // CAknAdaptiveSearchGrid::InitGridButtons()
   400 // CAknAdaptiveSearchGrid::InitGridButtons()
   466 // Initiates buttons array of the adaptive search grid.
   401 // Initiates buttons array of the adaptive search grid.
   467 // iTotalGridButtons should be calculated in advance by caling InitGrid() 
   402 // iTotalGridButtons should be calculated in advance by caling InitGrid() 
   468 // -----------------------------------------------------------------------------
   403 // -----------------------------------------------------------------------------
   469 //
   404 //
   494         button->SetObserver( this );        
   429         button->SetObserver( this );        
   495         button->SetContainerWindowL( *this ); 
   430         button->SetContainerWindowL( *this ); 
   496         button->SetBackground(this);
   431         button->SetBackground(this);
   497         button->SetTextColorIds( KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG65 );
   432         button->SetTextColorIds( KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG65 );
   498         button->ActivateL();
   433         button->ActivateL();
       
   434         button->MakeVisible( EFalse );
   499         return button;
   435         return button;
   500         }
   436         }
   501     else
   437     else
   502         {
   438         {
   503         CleanupStack::PopAndDestroy( button );
   439         CleanupStack::PopAndDestroy( button );
   528     {  
   464     {  
   529     TInt layout_option;
   465     TInt layout_option;
   530            
   466            
   531     if( Layout_Meta_Data::IsLandscapeOrientation() )
   467     if( Layout_Meta_Data::IsLandscapeOrientation() )
   532         {
   468         {
   533         CAknToolbar* toolbar = iAppUi->CurrentFixedToolbar();
       
   534         iLayoutOption = KLandscapeSinglePage; 
   469         iLayoutOption = KLandscapeSinglePage; 
   535         layout_option = KLandscapeMaxSize;
   470         layout_option = KLandscapeMaxSize;
   536         if ( toolbar && toolbar->IsShown() )
   471         iToolbarShown = EFalse;
   537              iToolbarShown = ETrue;
       
   538         else
       
   539             iToolbarShown = EFalse;
       
   540         }
   472         }
   541     else
   473     else
   542         {        
   474         {        
   543         CAknToolbar* toolbar = iAppUi->CurrentFixedToolbar();
   475         CAknToolbar* toolbar = iAppUi->CurrentFixedToolbar();
   544         iLayoutOption = KPortraitSinglePage;
   476         iLayoutOption = KPortraitSinglePage;
   565         {
   497         {
   566         TRect controlPaneRect;
   498         TRect controlPaneRect;
   567         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EControlPane,
   499         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EControlPane,
   568                                            controlPaneRect );
   500                                            controlPaneRect );
   569         currentWindowRect.iBr.iY = controlPaneRect.iTl.iY;
   501         currentWindowRect.iBr.iY = controlPaneRect.iTl.iY;
   570         
       
   571         TRect mainPaneRect;
       
   572         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   573                                            mainPaneRect );
       
   574         CAknToolbar* toolbar = iAppUi->CurrentFixedToolbar();   
       
   575         if ( !toolbar 
       
   576              || !toolbar->IsVisible()
       
   577              || mainPaneRect.iBr.iX <= toolbar->Position().iX 
       
   578            )
       
   579             {          
       
   580             currentWindowRect.iBr.iX = mainPaneRect.iBr.iX;
       
   581             }
       
   582         }
   502         }
   583         
   503         
   584     TRect grid_pane = RectFromLayout( currentWindowRect, AknLayoutScalable_Apps::grid_afind_pane( iLayoutOption ) );
   504     TRect grid_pane = RectFromLayout( currentWindowRect, AknLayoutScalable_Apps::grid_afind_pane( iLayoutOption ) );
   585     TRect button_rect = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane( iLayoutOption, 0, 0 ) );  
   505     TRect button_rect = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane( iLayoutOption, 0, 0 ) );  
   586     TSize button_rect_size = button_rect.Size();
   506     TSize button_rect_size = button_rect.Size();
   612 //    
   532 //    
   613 void CAknAdaptiveSearchGrid::Draw( CWindowGc& aGc, const CCoeControl& /*aControl*/, 
   533 void CAknAdaptiveSearchGrid::Draw( CWindowGc& aGc, const CCoeControl& /*aControl*/, 
   614          const TRect& aRect ) const 
   534          const TRect& aRect ) const 
   615     {
   535     {
   616     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   536     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   617     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); 
   537 
   618     aGc.SetBrushColor( KRgbWhite );
   538     TRgb color;
   619     aGc.SetPenColor( KRgbBlack );
   539     TInt error = AknsUtils::GetCachedColor(skin, color, KAknsIIDFsTextColors, 
       
   540         		   EAknsCIFsTextColorsCG3 );
       
   541     if( error == KErrNone )
       
   542         {
       
   543         aGc.SetBrushColor( color );
       
   544         aGc.SetPenColor( color );
       
   545         }
       
   546     else
       
   547         {
       
   548         aGc.SetBrushColor( KRgbWhite );
       
   549         aGc.SetPenColor( KRgbBlack );
       
   550         }
   620     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
   551     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
   621     aGc.DrawRect( aRect );   
   552     aGc.DrawRect( aRect );   
   622     }
   553     }
   623 
   554 
   624 // -----------------------------------------------------------------------------
   555 // -----------------------------------------------------------------------------
   651     InitGridButtons();       
   582     InitGridButtons();       
   652     GridButtonsPositions();      
   583     GridButtonsPositions();      
   653     }
   584     }
   654 
   585 
   655 // -----------------------------------------------------------------------------
   586 // -----------------------------------------------------------------------------
   656 // CAknAdaptiveSearchGrid::MopSupplyObject
       
   657 // Retrieves an object of the same type as that encapsulated in aId.
       
   658 // -----------------------------------------------------------------------------
       
   659 //    
       
   660 TTypeUid::Ptr CAknAdaptiveSearchGrid::MopSupplyObject( TTypeUid aId )
       
   661     {
       
   662     if ( aId.iUid == MAknsControlContext::ETypeId && iSkinContextOfFindPane )
       
   663         {
       
   664         return MAknsControlContext::SupplyMopObject( aId, iSkinContextOfFindPane );
       
   665         }
       
   666     return MAknsControlContext::SupplyMopObject( aId, NULL );
       
   667     }
       
   668 
       
   669 // -----------------------------------------------------------------------------
       
   670 // CAknAdaptiveSearchGrid::CountComponentControls
   587 // CAknAdaptiveSearchGrid::CountComponentControls
   671 // Gets the number of controls contained in a compound control.
   588 // Gets the number of controls contained in a compound control.
   672 // -----------------------------------------------------------------------------
   589 // -----------------------------------------------------------------------------
   673 //   
   590 //   
   674 TInt CAknAdaptiveSearchGrid::CountComponentControls() const
   591 TInt CAknAdaptiveSearchGrid::CountComponentControls() const
   675     {
   592     {
   676     // buttons + controls + search field ( editor, input frame )    
   593     // buttons + controls    
   677     return iButtonArray.Count()+5+2; 
   594     return iButtonArray.Count()+5;
   678     } 
   595     } 
   679 
   596 
   680 // -----------------------------------------------------------------------------
       
   681 // Sets text into search field.
       
   682 // Gets one parameters:
       
   683 // const TDesC& aSearchTxt      - Reference to the text buffer.
       
   684 // -----------------------------------------------------------------------------      
       
   685 //                   
       
   686 void CAknAdaptiveSearchGrid::SetSearchTextToFindPane( const TDesC& aSearchTxt )
       
   687     { 
       
   688     _AKNDEBUG(
       
   689                _LIT( KClassName, "CAknAdaptiveSearchGrid" );
       
   690                _LIT( KFunctionName, "SetSearchTextToFindPane" );
       
   691                _LIT( KFormat, "[%S][%S] search text is: %S");
       
   692                _AKNTRACE( KFormat, 
       
   693                &KClassName, &KFunctionName, &aSearchTxt );
       
   694                );
       
   695 
       
   696     TRAP_IGNORE( iEditor->SetTextL( &aSearchTxt ) );
       
   697     if ( iShown )
       
   698         {
       
   699         TRAP_IGNORE(iEditor->TextView()->SetCursorVisibilityL( TCursor::EFCursorFlashing,
       
   700                                                            TCursor::EFCursorFlashing ));
       
   701         }
       
   702     TInt curPos = iEditor->TextLength(); 
       
   703     //This set selection all off
       
   704     TRAP_IGNORE( iEditor->SetSelectionL( curPos, curPos ) ); 
       
   705     iEditor->DrawNow();
       
   706     } 
       
   707     
       
   708 // -----------------------------------------------------------------------------
   597 // -----------------------------------------------------------------------------
   709 // CAknAdaptiveSearchGrid::ComponentControlh
   598 // CAknAdaptiveSearchGrid::ComponentControlh
   710 // Gets the specified component of a compound control.
   599 // Gets the specified component of a compound control.
   711 // -----------------------------------------------------------------------------
   600 // -----------------------------------------------------------------------------
   712 //    
   601 //    
   728                 return iCloseButton;
   617                 return iCloseButton;
   729             case 3: 
   618             case 3: 
   730                 return iDeleteButton;
   619                 return iDeleteButton;
   731             case 4:
   620             case 4:
   732                 return iPageIndicator;
   621                 return iPageIndicator;
   733             case 5:
       
   734                 return iInputFrame; 
       
   735             case 6:
       
   736                 return iEditor;                             
       
   737             default:
   622             default:
   738                 return NULL;
   623                 return NULL;
   739             }
   624             }
   740         }
   625         }
   741     }   
   626     }   
   744 // CAknAdaptiveSearchGrid::SetAdaptiveSearchGridVisibility
   629 // CAknAdaptiveSearchGrid::SetAdaptiveSearchGridVisibility
   745 // Shows or hides grid.
   630 // Shows or hides grid.
   746 // The position of the top left corner should be set in advance.
   631 // The position of the top left corner should be set in advance.
   747 // -----------------------------------------------------------------------------
   632 // -----------------------------------------------------------------------------
   748 //
   633 //
   749 void CAknAdaptiveSearchGrid::SetVisibilityL( TBool aVisible, TBool aSelectAll )
   634 void CAknAdaptiveSearchGrid::SetVisibilityL( TBool aVisible, TBool /*aSelectAll*/ )
   750     {
   635     {
   751     _AKNTRACE( "[%s][%s] Visible : %d", "CAknAdaptiveSearchGrid", __FUNCTION__, aVisible );
   636     _AKNTRACE( "[%s][%s] Visible : %d", "CAknAdaptiveSearchGrid", __FUNCTION__, aVisible );
   752     if ( aVisible )
   637     if ( aVisible )
   753         {      
   638         {      
   754         SetFocus( ETrue);  
   639         SetFocus( ETrue);  
   755         iCurrentPage = 1;
   640         iCurrentPage = 1;
   756         ShowL();
   641         ShowL();
   757         if ( iEditor )
       
   758             {
       
   759             iEditor->SetFocus( ETrue );
       
   760             TInt curPos = iEditor->TextLength(); 
       
   761             iEditor->SetCursorPosL( curPos, EFalse );
       
   762             if ( aSelectAll) 
       
   763                 {
       
   764                 iEditor->SelectAllL();
       
   765                 }
       
   766             }    
       
   767         }
   642         }
   768     else
   643     else
   769         {
   644         {
   770         HideL();
   645         HideL();
   771         }    
   646         }    
   848 void CAknAdaptiveSearchGrid::ControlsPositions()
   723 void CAknAdaptiveSearchGrid::ControlsPositions()
   849     {
   724     {
   850     TRect cell_pane; 
   725     TRect cell_pane; 
   851     
   726     
   852     TRect grid_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::grid_afind_pane( iLayoutOption ) );   
   727     TRect grid_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::grid_afind_pane( iLayoutOption ) );   
   853     TRect find_pane; 
       
   854      
       
   855     if(iPopupFindpane)
       
   856         {
       
   857         find_pane = RectFromLayout( Rect(), AknLayoutScalable_Avkon::popup_find_window() );
       
   858         }
       
   859     else
       
   860         {
       
   861         find_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::find_pane_cp01( iLayoutOption ) );
       
   862         } 
       
   863     _AKNTRACE( "[%s][%s] rect of find pane is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
       
   864             find_pane.iTl.iX, find_pane.iTl.iY, find_pane.iBr.iX, find_pane.iBr.iY );   
       
   865     iInputFrame->SetRect( find_pane ); 
       
   866     iSkinContextOfFindPane->SetRect( find_pane );        
       
   867    
   728    
   868     // Backspace and close buttons
   729     // Backspace and close buttons
   869     cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane(iLayoutOption, iNumOfCols-2, iNumOfRows-1) );        
   730     cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane(iLayoutOption, iNumOfCols-2, iNumOfRows-1) );        
   870    
   731    
   871     // For ELJG-7VC8Q2, move delete button up
   732     // For ELJG-7VC8Q2, move delete button up
   873         {
   734         {
   874         cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*iNumOfRows;          
   735         cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*iNumOfRows;          
   875         cell_pane.iTl.iY = cell_pane.iTl.iY - iOverlapLength*(iNumOfRows-1); 
   736         cell_pane.iTl.iY = cell_pane.iTl.iY - iOverlapLength*(iNumOfRows-1); 
   876         }
   737         }
   877      _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   738      _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   878             cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   739     		cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   879     iDeleteButton->SetRect( cell_pane );    
   740     iDeleteButton->SetRect( cell_pane );    
   880     cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane(iLayoutOption, iNumOfCols-1, iNumOfRows-1) );        
   741     cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane(iLayoutOption, iNumOfCols-1, iNumOfRows-1) );        
   881    
   742    
   882     // For ELJG-7VC8Q2, move close button up
   743     // For ELJG-7VC8Q2, move close button up
   883     if(iPopupFindpane && ( iLayoutOption == KPortraitSinglePage ||iLayoutOption == KLandscapeSinglePage))
   744     if(iPopupFindpane && ( iLayoutOption == KPortraitSinglePage ||iLayoutOption == KLandscapeSinglePage))
   885         cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*iNumOfRows;          
   746         cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*iNumOfRows;          
   886         cell_pane.iTl.iY = cell_pane.iTl.iY - iOverlapLength*(iNumOfRows-1); 
   747         cell_pane.iTl.iY = cell_pane.iTl.iY - iOverlapLength*(iNumOfRows-1); 
   887         }
   748         }
   888 
   749 
   889      _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   750      _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   890                 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   751         		cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   891     iCloseButton->SetRect( cell_pane ); 
   752     iCloseButton->SetRect( cell_pane ); 
   892 
   753 
   893     // For ELJG-7VC8Q2, Move all the buttons up when there is only one page
   754     // For ELJG-7VC8Q2, Move all the buttons up when there is only one page
   894     if(iPopupFindpane)
   755     if(iPopupFindpane)
   895         {
   756         {
   898             {
   759             {
   899             for ( TInt i = 0; i < iNumOfCols; i++ ) 
   760             for ( TInt i = 0; i < iNumOfCols; i++ ) 
   900                 {
   761                 {
   901                 cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane( iLayoutOption, i, j ) );             
   762                 cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane( iLayoutOption, i, j ) );             
   902                 if(iLayoutOption == KPortraitSinglePage ||iLayoutOption == KLandscapeSinglePage )   
   763                 if(iLayoutOption == KPortraitSinglePage ||iLayoutOption == KLandscapeSinglePage )   
   903                     {
   764             	    {
   904                     cell_pane.iTl.iY -=iOverlapLength*j;
   765                     cell_pane.iTl.iY -=iOverlapLength*j;
   905                     cell_pane.iBr.iY -=iOverlapLength*(j+1); 
   766                     cell_pane.iBr.iY -=iOverlapLength*(j+1); 
   906                     }
   767             	    }
   907                 iButtonArray[temp]->SetRect( cell_pane );
   768                 iButtonArray[temp]->SetRect( cell_pane );
   908                 temp++;
   769                 temp++;
   909                 }               
   770                 }               
   910             } 
   771             } 
   911         }
   772     	}
   912 
   773 
   913    
   774    
   914     if ( Layout_Meta_Data::IsLandscapeOrientation() && AknLayoutUtils::LayoutMirrored() )
   775     if ( Layout_Meta_Data::IsLandscapeOrientation() && AknLayoutUtils::LayoutMirrored() )
   915         {
   776         {
   916         SetCornerAndSize( EHLeftVTop, Rect().Size()); 
   777         SetCornerAndSize( EHLeftVTop, Rect().Size()); 
   928                 {
   789                 {
   929                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   790                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   930                 }
   791                 }
   931 
   792 
   932             _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   793             _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   933                         cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); 
   794                 		cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); 
   934             iDeleteButton->SetRect( cell_pane );        
   795             iDeleteButton->SetRect( cell_pane );        
   935             cell_pane = RectFromLayout( cont_pane, AknLayoutScalable_Apps::cell_afind_grid_control_pane(0,1) ); 
   796             cell_pane = RectFromLayout( cont_pane, AknLayoutScalable_Apps::cell_afind_grid_control_pane(0,1) ); 
   936 
   797 
   937             // For ELJG-7VC8Q2, Move close button up
   798             // For ELJG-7VC8Q2, Move close button up
   938             if(iPopupFindpane)
   799             if(iPopupFindpane)
   939                 {
   800                 {
   940                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);        
   801                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);      	
   941                 }
   802                 }
   942 
   803 
   943             _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   804             _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   944                         cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   805                 		cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   945             iCloseButton->SetRect( cell_pane );         
   806             iCloseButton->SetRect( cell_pane );         
   946             }
   807             }
   947         // Page pane    
   808         // Page pane    
   948         TRect page_pane;       
   809         TRect page_pane;       
   949         page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane( iLayoutOption) );  
   810         page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane( iLayoutOption) );  
   950         _AKNTRACE( "[%s][%s] rect of page pane is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   811         _AKNTRACE( "[%s][%s] rect of page pane is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   951                 page_pane.iTl.iX, page_pane.iTl.iY, page_pane.iBr.iX, page_pane.iBr.iY );
   812         		page_pane.iTl.iX, page_pane.iTl.iY, page_pane.iBr.iX, page_pane.iBr.iY );
   952         AknLayoutUtils::LayoutLabel( iPageIndicator, Rect(), 
   813         AknLayoutUtils::LayoutLabel( iPageIndicator, Rect(), 
   953         TAknWindowComponentLayout::ComposeText( AknLayoutScalable_Apps::afind_page_pane( iLayoutOption ), 
   814         TAknWindowComponentLayout::ComposeText( AknLayoutScalable_Apps::afind_page_pane( iLayoutOption ), 
   954         AknLayoutScalable_Apps::afind_page_pane_t1() ).LayoutLine() );
   815         AknLayoutScalable_Apps::afind_page_pane_t1() ).LayoutLine() );
   955         
   816         
   956         // Next and previous buttons
   817         // Next and previous buttons
   962             if(iPopupFindpane)
   823             if(iPopupFindpane)
   963                 {
   824                 {
   964                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   825                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   965                 }
   826                 }
   966             _AKNTRACE( "[%s][%s] rect of pre page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   827             _AKNTRACE( "[%s][%s] rect of pre page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   967                                 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   828                            		cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   968             iPrevButton->SetRect( cell_pane );
   829             iPrevButton->SetRect( cell_pane );
   969             cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g3( iLayoutOption) );  
   830             cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g3( iLayoutOption) );  
   970             
   831             
   971             // For ELJG-7VC8Q2, Move next button up
   832             // For ELJG-7VC8Q2, Move next button up
   972             if(iPopupFindpane)
   833             if(iPopupFindpane)
   973                 {
   834                 {
   974                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   835                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   975                 }
   836                 }
   976             _AKNTRACE( "[%s][%s] rect of next page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   837             _AKNTRACE( "[%s][%s] rect of next page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   977                                 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   838                            		cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   978             iNextButton->SetRect( cell_pane );  
   839             iNextButton->SetRect( cell_pane );  
   979             }
   840             }
   980         else
   841         else
   981             {
   842             {
   982             cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g2( iLayoutOption) ); 
   843             cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g2( iLayoutOption) ); 
   985             if(iPopupFindpane)
   846             if(iPopupFindpane)
   986                 {
   847                 {
   987                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   848                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   988                 } 
   849                 } 
   989             _AKNTRACE( "[%s][%s] rect of next page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   850             _AKNTRACE( "[%s][%s] rect of next page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   990                                 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   851                            		cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   991             iNextButton->SetRect( cell_pane );       
   852             iNextButton->SetRect( cell_pane );       
   992             cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g3( iLayoutOption) ); 
   853             cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g3( iLayoutOption) ); 
   993             
   854             
   994              // For ELJG-7VC8Q2, Move pre button up
   855              // For ELJG-7VC8Q2, Move pre button up
   995             if(iPopupFindpane)
   856             if(iPopupFindpane)
   996                 {
   857                 {
   997                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   858                 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1);
   998                 }
   859                 }
   999  
   860  
  1000             _AKNTRACE( "[%s][%s] rect of pre page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
   861             _AKNTRACE( "[%s][%s] rect of pre page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
  1001                                 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
   862                            		cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY );
  1002             iPrevButton->SetRect( cell_pane );   
   863             iPrevButton->SetRect( cell_pane );   
  1003             }    
   864             }    
  1004         
   865         
  1005         if( AknsUtils::AvkonSkinEnabled() )
   866         if( AknsUtils::AvkonSkinEnabled() )
  1006             {           
   867             {           
  1125         {   
   986         {   
  1126         iNextButton->MakeVisible( ETrue );  
   987         iNextButton->MakeVisible( ETrue );  
  1127         iPrevButton->MakeVisible( ETrue );          
   988         iPrevButton->MakeVisible( ETrue );          
  1128         iPageIndicator->MakeVisible( ETrue );   
   989         iPageIndicator->MakeVisible( ETrue );   
  1129         }
   990         }
  1130     iCloseButton->MakeVisible( ETrue );
   991     if(iGridChars)
  1131     iDeleteButton->MakeVisible( ETrue );
   992         {
  1132     iInputFrame->MakeVisible( ETrue ); 
   993         iCloseButton->MakeVisible( ETrue );
  1133     iEditor->MakeVisible( ETrue );
   994         iDeleteButton->MakeVisible( ETrue );
       
   995         }
       
   996     else
       
   997         {
       
   998         iCloseButton->MakeVisible( EFalse );
       
   999         iDeleteButton->MakeVisible( EFalse );
       
  1000         }
  1134     }
  1001     }
  1135     
  1002     
  1136 // -----------------------------------------------------------------------------
  1003 // -----------------------------------------------------------------------------
  1137 // CAknAdaptiveSearchGrid::AdaptiveSearchGridShowL()
  1004 // CAknAdaptiveSearchGrid::AdaptiveSearchGridShowL()
  1138 // Makes adaptive search grid visible and activates it.
  1005 // Makes adaptive search grid visible and activates it.
  1157         
  1024         
  1158     CAknToolbar* toolbar = iAppUi->CurrentFixedToolbar();
  1025     CAknToolbar* toolbar = iAppUi->CurrentFixedToolbar();
  1159     TBool needRelayout = EFalse;
  1026     TBool needRelayout = EFalse;
  1160     if( Layout_Meta_Data::IsLandscapeOrientation())
  1027     if( Layout_Meta_Data::IsLandscapeOrientation())
  1161         {
  1028         {
  1162         if ( iLayoutOption == KPortraitMultiPage || iLayoutOption == KPortraitSinglePage )
  1029         if ( iLayoutOption == KPortraitMultiPage 
       
  1030                 || iLayoutOption == KPortraitSinglePage 
       
  1031                 || iFindPaneSizeChanged )
  1163             {       
  1032             {       
  1164             needRelayout = ETrue;
  1033             needRelayout = ETrue;
       
  1034             iFindPaneSizeChanged = EFalse;
  1165             }
  1035             }
  1166         else if ( toolbar && toolbar->IsVisible() && iToolbarShown == EFalse )
       
  1167             {
       
  1168             needRelayout = ETrue;
       
  1169             }
       
  1170             
       
  1171         }
  1036         }
  1172     else if ( iLayoutOption == KLandscapeMultiPage || iLayoutOption == KLandscapeSinglePage )
  1037     else if ( iLayoutOption == KLandscapeMultiPage || iLayoutOption == KLandscapeSinglePage )
  1173         {       
  1038         {       
  1174         needRelayout = ETrue;
  1039         needRelayout = ETrue;
  1175         }
  1040         }
  1238     _AKNTRACE_FUNC_ENTER;
  1103     _AKNTRACE_FUNC_ENTER;
  1239     if ( !iShown ) // nothing to hide
  1104     if ( !iShown ) // nothing to hide
  1240         {
  1105         {
  1241         return;
  1106         return;
  1242         }  
  1107         }  
  1243   
       
  1244     iEditor->TextView()->SetCursorVisibilityL( 
       
  1245         TCursor::EFCursorInvisible, TCursor::EFCursorInvisible);
       
  1246             
       
  1247     SetFocus( EFalse );
  1108     SetFocus( EFalse );
  1248     //fix for TSW error EKDN-7KW9P2
  1109     //fix for TSW error EKDN-7KW9P2
  1249     SetShown( EFalse );
  1110     SetShown( EFalse );
  1250             
  1111             
  1251     if( iAdaptiveSearchGridObserver )
  1112     if( iAdaptiveSearchGridObserver )
  1260 // -----------------------------------------------------------------------------
  1121 // -----------------------------------------------------------------------------
  1261 // CAknAdaptiveSearchGrid::FocusChanged
  1122 // CAknAdaptiveSearchGrid::FocusChanged
  1262 // This function is called whenever a control gains or loses focus.
  1123 // This function is called whenever a control gains or loses focus.
  1263 // -----------------------------------------------------------------------------
  1124 // -----------------------------------------------------------------------------
  1264 // 
  1125 // 
  1265 void CAknAdaptiveSearchGrid::FocusChanged( TDrawNow aDrawNow )
  1126 void CAknAdaptiveSearchGrid::FocusChanged( TDrawNow /*aDrawNow*/ )
  1266     {
  1127     {
  1267     if ( !iShown || IsNonFocusing() )
  1128     if ( !iShown || IsNonFocusing() )
  1268         {
  1129         {
  1269         return; // nothing should be done in this case 
  1130         return; // nothing should be done in this case 
  1270         }      
  1131         }      
  1271     if ( !IsFocused() && iLastFocusedButton )               
  1132     if ( !IsFocused() && iLastFocusedButton )               
  1272         iLastFocusedButton->ResetState();        
  1133         iLastFocusedButton->ResetState();        
  1273     
       
  1274     iInputFrame->SetFocus( IsFocused(), aDrawNow );
       
  1275     }        
  1134     }        
  1276         
  1135         
  1277 
  1136 
  1278 // -----------------------------------------------------------------------------
  1137 // -----------------------------------------------------------------------------
  1279 // CAknAdaptiveSearchGrid::HandleWsEventL
  1138 // CAknAdaptiveSearchGrid::HandleWsEventL
  1297     if( aEvent.Type() == EEventPointer )
  1156     if( aEvent.Type() == EEventPointer )
  1298         {     
  1157         {     
  1299         TPointerEvent& pointerEvent = *aEvent.Pointer();
  1158         TPointerEvent& pointerEvent = *aEvent.Pointer();
  1300         
  1159         
  1301         if( pointerEvent.iType == TPointerEvent::EButton1Down ) 
  1160         if( pointerEvent.iType == TPointerEvent::EButton1Down ) 
  1302             {     
  1161             {
  1303              if( iInputFrame->Rect().Contains(pointerEvent.iPosition) || 
  1162             if ( !iFindpaneRect.Contains( pointerEvent.iPosition ) &&
  1304                 aDestination != this )
  1163                 aDestination != this )
  1305                 {  
  1164                 {
  1306             MTouchFeedback* feedback = MTouchFeedback::Instance();
  1165                 HideL();
  1307             
  1166                 return;
  1308             // according to Touch UI spec tapping on input frame should cause feedback, 
       
  1309             // even if action is to cancel dialog..
       
  1310             if ( feedback )
       
  1311                 {
       
  1312                 feedback->InstantFeedback( this, ETouchFeedbackBasic );
       
  1313                 }
  1167                 }
  1314                 
  1168             }
  1315                 HideL();
  1169         }
  1316                 return;                          
       
  1317                 }                             
       
  1318             }   
       
  1319         }                     
       
  1320     }
  1170     }
  1321         
  1171         
  1322        
  1172        
  1323 // -----------------------------------------------------------------------------
  1173 // -----------------------------------------------------------------------------
  1324 // CAknAdaptiveSearchGrid::HandleControlEventL
  1174 // CAknAdaptiveSearchGrid::HandleControlEventL
  1389             {
  1239             {
  1390             break;
  1240             break;
  1391             }
  1241             }
  1392         }
  1242         }
  1393     _AKNTRACE_FUNC_EXIT;
  1243     _AKNTRACE_FUNC_EXIT;
  1394     }       
  1244     }     
       
  1245 
       
  1246 static CAknButton* GetButtonHelper( RPointerArray<CAknButton> &aButtonArray, TInt aIndex )
       
  1247     {
       
  1248     return ( aIndex < aButtonArray.Count() && aIndex >= 0 ) ? aButtonArray[aIndex] : NULL;
       
  1249     }
  1395 
  1250 
  1396 // -----------------------------------------------------------------------------
  1251 // -----------------------------------------------------------------------------
  1397 // CAknAdaptiveSearchGrid::UpdateVisibleButtonsL()
  1252 // CAknAdaptiveSearchGrid::UpdateVisibleButtonsL()
  1398 // -----------------------------------------------------------------------------
  1253 // -----------------------------------------------------------------------------
  1399 //
  1254 //
  1422 
  1277 
  1423         // Hide all the buttons at the beginning for now. 
  1278         // Hide all the buttons at the beginning for now. 
  1424         CAknButton* tmpButton = NULL;    
  1279         CAknButton* tmpButton = NULL;    
  1425         for( TInt i = 0; i < iButtonArray.Count(); i++ )
  1280         for( TInt i = 0; i < iButtonArray.Count(); i++ )
  1426             {
  1281             {
  1427             tmpButton = static_cast<CAknButton*>( iButtonArray[i] );            
  1282             tmpButton = GetButtonHelper( iButtonArray, i );
  1428             tmpButton->MakeVisible( EFalse );
  1283             if ( NULL != tmpButton )
       
  1284                 {
       
  1285                 tmpButton->MakeVisible( EFalse );
       
  1286                 }
  1429             }
  1287             }
  1430                 
  1288                 
  1431         TInt tempTotalGridButtons = iTotalGridButtons - KCloseAndClearButtonCount;               
  1289         TInt tempTotalGridButtons = iTotalGridButtons - KCloseAndClearButtonCount;               
  1432         if( iNumOfPages == 1 )
  1290         if( iNumOfPages == 1 )
  1433             {       
  1291             {       
  1434             for ( TInt i = 0; i < tempTotalGridButtons; i++ )
  1292             for ( TInt i = 0; i < tempTotalGridButtons; i++ )
  1435                 {
  1293                 {
  1436                 button = static_cast<CAknButton*>( iButtonArray[tempTotalGridButtons-i-1] );
  1294                 button = GetButtonHelper( iButtonArray, tempTotalGridButtons-i-1 );
       
  1295                 if ( NULL == button )
       
  1296                     {
       
  1297                     continue;
       
  1298                     }
       
  1299                 
  1437                 TInt charPosition = numOfChars-i-1-shift_Ind;
  1300                 TInt charPosition = numOfChars-i-1-shift_Ind;
  1438                 if ( charPosition >= 0 ) 
  1301                 if ( charPosition >= 0 ) 
  1439                     {
  1302                     {
  1440                     bState = button->State();
  1303                     bState = button->State();
  1441                     if ( ptr.Mid(charPosition, 1) == KSpaceCharacter )
  1304                     if ( ptr.Mid(charPosition, 1) == KSpaceCharacter )
  1447                         bState->SetTextL( KNullDesC );                          
  1310                         bState->SetTextL( KNullDesC );                          
  1448                         bState->SetIcon( icon );
  1311                         bState->SetIcon( icon );
  1449                         button->SetIconSize( iButtonIconSize );                                      
  1312                         button->SetIconSize( iButtonIconSize );                                      
  1450                         }
  1313                         }
  1451                     else
  1314                     else
  1452                         {
  1315                         { 
  1453                         if( bState->Icon() )
  1316                         if( bState->Icon() )
  1454                             {
  1317                             {
  1455                             bState->SetIcon( NULL );          
  1318                             bState->SetIcon( NULL );          
  1456                             }       
  1319                             }       
  1457                         // If Devanagari
  1320                         // If Devanagari
  1466                             bState->SetTextL( ptr.Mid(charPosition, 1) );
  1329                             bState->SetTextL( ptr.Mid(charPosition, 1) );
  1467                             }
  1330                             }
  1468                         }                  
  1331                         }                  
  1469                     button_rect = button->Rect();
  1332                     button_rect = button->Rect();
  1470                     _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), 
  1333                     _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), 
  1471                             button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1334                     		button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1472                     iCurrentRegion.AddRect( button_rect );
  1335                     iCurrentRegion.AddRect( button_rect );
  1473                     button->MakeVisible( ETrue );
  1336                     button->MakeVisible( ETrue );
  1474                     }
  1337                     }
  1475                 else
  1338                 else
  1476                     {
  1339                     {
  1504                 // last page
  1367                 // last page
  1505                 TInt charsOnLastPage = numOfChars -  numOfCharsInPrevPages; 
  1368                 TInt charsOnLastPage = numOfChars -  numOfCharsInPrevPages; 
  1506                 TInt offset = tempTotalGridButtons - charsOnLastPage;   
  1369                 TInt offset = tempTotalGridButtons - charsOnLastPage;   
  1507                 
  1370                 
  1508                 for ( TInt i = tempTotalGridButtons-1 ; i >= 0 ; --i )
  1371                 for ( TInt i = tempTotalGridButtons-1 ; i >= 0 ; --i )
  1509                     {
  1372                     {                  
  1510                     button = static_cast<CAknButton*>(iButtonArray[i+shift_Ind]);
  1373                     button = GetButtonHelper( iButtonArray, i+shift_Ind );
       
  1374                     if ( NULL == button )
       
  1375                         {
       
  1376                         continue;
       
  1377                         }
       
  1378                 
  1511                     if( i < offset )
  1379                     if( i < offset )
  1512                         {
  1380                         {
  1513                         button->MakeVisible( EFalse );                  
  1381                         button->MakeVisible( EFalse );                  
  1514                         }
  1382                         }
  1515                     else
  1383                     else
  1546                                 bState->SetTextL( ptr.Mid(CharPosition, 1));                      
  1414                                 bState->SetTextL( ptr.Mid(CharPosition, 1));                      
  1547                                 }                 
  1415                                 }                 
  1548                             }                  
  1416                             }                  
  1549                         button_rect = button->Rect();
  1417                         button_rect = button->Rect();
  1550                         _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), 
  1418                         _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), 
  1551                                                 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1419                                            		button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1552                         iCurrentRegion.AddRect( button_rect );
  1420                         iCurrentRegion.AddRect( button_rect );
  1553                         button->MakeVisible( ETrue );
  1421                         button->MakeVisible( ETrue );
  1554                         }
  1422                         }
  1555                     }
  1423                     }
  1556                 }
  1424                 }
  1562                 shift_Ind = 0;
  1430                 shift_Ind = 0;
  1563 
  1431 
  1564                 for ( TInt i = 0; i < numOfChars; i++ )
  1432                 for ( TInt i = 0; i < numOfChars; i++ )
  1565                     {
  1433                     {
  1566                     if ( ( i >= start) && (i < end) )
  1434                     if ( ( i >= start) && (i < end) )
  1567                         {   
  1435                         {                      
  1568                         button = static_cast<CAknButton*>(iButtonArray[i-start-shift_Ind]);
  1436                         button = GetButtonHelper( iButtonArray, i-start-shift_Ind );
       
  1437                         if ( NULL == button )
       
  1438                             {
       
  1439                             continue;
       
  1440                             }
       
  1441                     
  1569                         bState = button->State();               
  1442                         bState = button->State();               
  1570                         if( ptr.Mid(i, 1) == KSpaceCharacter )
  1443                         if( ptr.Mid(i, 1) == KSpaceCharacter )
  1571                             {  
  1444                             {  
  1572                             // Create icon for space button                        
  1445                             // Create icon for space button                        
  1573                             icon = GetColorIconL( 4 );
  1446                             icon = GetColorIconL( 4 );
  1604                                 bState->SetTextL( ptr.Mid(i, 1) );
  1477                                 bState->SetTextL( ptr.Mid(i, 1) );
  1605                                 }
  1478                                 }
  1606                             }                  
  1479                             }                  
  1607                         button_rect = button->Rect();
  1480                         button_rect = button->Rect();
  1608                         _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), 
  1481                         _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), 
  1609                                                 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1482                                            		button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1610                         iCurrentRegion.AddRect( button_rect );
  1483                         iCurrentRegion.AddRect( button_rect );
  1611                         button->MakeVisible( ETrue );
  1484                         button->MakeVisible( ETrue );
  1612                         
  1485                         
  1613                         }                   
  1486                         }                   
  1614                     }
  1487                     }
  1616                         {
  1489                         {
  1617                         tempTotalGridButtons = iTotalGridButtons;
  1490                         tempTotalGridButtons = iTotalGridButtons;
  1618                         }
  1491                         }
  1619                     for ( TInt i = tempTotalGridButtons; i < tempTotalGridButtons+iNumOfCols; i++ )
  1492                     for ( TInt i = tempTotalGridButtons; i < tempTotalGridButtons+iNumOfCols; i++ )
  1620                         {
  1493                         {
  1621                         button = static_cast<CAknButton*>(iButtonArray[i]);
  1494                         button = GetButtonHelper( iButtonArray, i );
  1622                         button->MakeVisible( EFalse );  
  1495                         if ( NULL != button )
       
  1496                             {
       
  1497                             button->MakeVisible( EFalse );  
       
  1498                             }
       
  1499                         
  1623                         }           
  1500                         }           
  1624                 }               
  1501                 }               
  1625             }        
  1502             }        
  1626         button_rect = iDeleteButton->Rect();
  1503         button_rect = iDeleteButton->Rect();
  1627         _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
  1504         _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
  1628                                 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1505                            		button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1629         iCurrentRegion.AddRect( button_rect );
  1506         iCurrentRegion.AddRect( button_rect );
  1630         button_rect = iCloseButton->Rect();
  1507         button_rect = iCloseButton->Rect();
  1631         _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
  1508         _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
  1632                                 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1509                            		button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
  1633         iCurrentRegion.AddRect( button_rect );
       
  1634         button_rect = iInputFrame->Rect();
       
  1635         _AKNTRACE( "[%s][%s] rect of Input Frame is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
       
  1636                                         button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY );
       
  1637         iCurrentRegion.AddRect( button_rect );
  1510         iCurrentRegion.AddRect( button_rect );
  1638         if( iNumOfPages > 1 )
  1511         if( iNumOfPages > 1 )
  1639             {
  1512             {
  1640             TRect page_pane;       
  1513             TRect page_pane;       
  1641             page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane(iLayoutOption) );   
  1514             page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane(iLayoutOption) );   
  1642             _AKNTRACE( "[%s][%s] rect of page pane is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
  1515             _AKNTRACE( "[%s][%s] rect of page pane is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__,
  1643                     page_pane.iTl.iX, page_pane.iTl.iY, page_pane.iBr.iX, page_pane.iBr.iY );
  1516             		page_pane.iTl.iX, page_pane.iTl.iY, page_pane.iBr.iX, page_pane.iBr.iY );
  1644             iCurrentRegion.AddRect( page_pane );
  1517             iCurrentRegion.AddRect( page_pane );
  1645             }    
  1518             }    
  1646         }
  1519         }
  1647     Window().SetShape( iCurrentRegion );
  1520     Window().SetShape( iCurrentRegion );
  1648     _AKNTRACE_FUNC_EXIT;
  1521     _AKNTRACE_FUNC_EXIT;
  1734     {    
  1607     {    
  1735     _AKNTRACE_FUNC_ENTER;
  1608     _AKNTRACE_FUNC_ENTER;
  1736     _AKNTRACE( "[%s][%s] Event Type : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, aType );
  1609     _AKNTRACE( "[%s][%s] Event Type : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, aType );
  1737     switch( aType )
  1610     switch( aType )
  1738         {
  1611         {
  1739         case KEikDynamicLayoutVariantSwitch:
  1612     	case KEikDynamicLayoutVariantSwitch:
  1740             {
  1613         	{
  1741             UpdateLayoutVariant();
  1614         	UpdateLayoutVariant();
  1742             break;
  1615         	break;
  1743             }
  1616         	}
  1744         case KAknsMessageSkinChange:
  1617         case KAknsMessageSkinChange:
  1745             {
  1618         	{
  1746             TRAP_IGNORE( UpdateSkinL() );
  1619         	TRAP_IGNORE( UpdateSkinL() );
  1747             break;
  1620         	break;
  1748             }
  1621         	}
  1749         default:
  1622         default:
  1750             {
  1623         	{
  1751             break;
  1624         	break;
  1752             }
  1625         	}
  1753         }
  1626         }
  1754         
  1627         
  1755     CAknControl::HandleResourceChange( aType );
  1628     CAknControl::HandleResourceChange( aType );
  1756     _AKNTRACE_FUNC_EXIT;
  1629     _AKNTRACE_FUNC_EXIT;
  1757     }
  1630     }
  1785 MAknAdaptiveSearchGridObserver* CAknAdaptiveSearchGrid::AdaptiveSearchGridObserver() 
  1658 MAknAdaptiveSearchGridObserver* CAknAdaptiveSearchGrid::AdaptiveSearchGridObserver() 
  1786     {
  1659     {
  1787     return iAdaptiveSearchGridObserver;
  1660     return iAdaptiveSearchGridObserver;
  1788     }
  1661     }
  1789         
  1662         
       
  1663 
       
  1664 // -----------------------------------------------------------------------------
       
  1665 // CAknAdaptiveSearch::SaveFindPaneRect()
       
  1666 // When the rect of find pane is set, this functions will be notified
       
  1667 // to record the size of it.
       
  1668 // -----------------------------------------------------------------------------
       
  1669 //
       
  1670 void CAknAdaptiveSearchGrid::SaveFindPaneRect( const TRect &aRect )
       
  1671     {
       
  1672     //When width is zero, no need to deal with.
       
  1673     if ( 0 == aRect.Size().iWidth )
       
  1674         {
       
  1675         return;
       
  1676         }
       
  1677     
       
  1678     //The same size already is set. No need to do further process.
       
  1679     if ( aRect == iFindpaneRect )
       
  1680         {
       
  1681         return;    
       
  1682         }
       
  1683 
       
  1684     iFindpaneRect = aRect;
       
  1685     iFindPaneSizeChanged = ETrue;
       
  1686     }
       
  1687 
  1790 // End of File
  1688 // End of File
  1791 
  1689