emailuis/emailui/src/ncsheadercontainer.cpp
branchRCL_3
changeset 35 e64954c2c8e2
parent 34 cd2816114bd1
child 24 b5fbb9b25d57
equal deleted inserted replaced
34:cd2816114bd1 35:e64954c2c8e2
   168 	
   168 	
   169 	iAacListBox = CNcsPopupListBox::NewL( 
   169 	iAacListBox = CNcsPopupListBox::NewL( 
   170 	        this, iMailBox, *this, remoteLookupSupported );
   170 	        this, iMailBox, *this, remoteLookupSupported );
   171 	iAacListBox->MakeVisible( EFalse );
   171 	iAacListBox->MakeVisible( EFalse );
   172 
   172 
   173     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
   174         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
       
   175 
       
   176     iRALInProgress = EFalse;
   173     iRALInProgress = EFalse;
   177 
   174 
   178     iToField->EnableKineticScrollingL( iPhysics );
   175     iToField->EnableKineticScrollingL( iPhysics );
   179     iCcField->EnableKineticScrollingL( iPhysics );
   176     iCcField->EnableKineticScrollingL( iPhysics );
   180     iBccField->EnableKineticScrollingL( iPhysics );
   177     iBccField->EnableKineticScrollingL( iPhysics );
   192 	delete iBccField;
   189 	delete iBccField;
   193 	delete iSubjectField;
   190 	delete iSubjectField;
   194     delete iAttachmentField;
   191     delete iAttachmentField;
   195 	delete iAacListBox;
   192 	delete iAacListBox;
   196 	delete iLongTapDetector;
   193 	delete iLongTapDetector;
   197 	delete iBgContext;
       
   198 	}
   194 	}
   199 
   195 
   200 // ---------------------------------------------------------------------------
   196 // ---------------------------------------------------------------------------
   201 // CNcsHeaderContainer::FocusChanged
   197 // CNcsHeaderContainer::FocusChanged
   202 // ---------------------------------------------------------------------------
   198 // ---------------------------------------------------------------------------
   261 // Draws the display
   257 // Draws the display
   262 // -----------------------------------------------------------------------------
   258 // -----------------------------------------------------------------------------
   263 void CNcsHeaderContainer::Draw( const TRect& /*aRect*/ ) const
   259 void CNcsHeaderContainer::Draw( const TRect& /*aRect*/ ) const
   264 	{
   260 	{
   265     FUNC_LOG;
   261     FUNC_LOG;
   266 
       
   267     if ( iBgContext )
       
   268         {
       
   269         CWindowGc& gc = SystemGc();
       
   270 
       
   271         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   272 
       
   273         if ( skin )
       
   274             {
       
   275             AknsDrawUtils::Background( skin, iBgContext, this, gc, Rect() );
       
   276             }
       
   277         }
       
   278 	}
   262 	}
   279 
   263 
   280 // -----------------------------------------------------------------------------
   264 // -----------------------------------------------------------------------------
   281 // CNcsHeaderContainer::DrawAttachmentFocusNow() const
   265 // CNcsHeaderContainer::DrawAttachmentFocusNow() const
   282 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   399 					DrawAttachmentFocusNow();
   383 					DrawAttachmentFocusNow();
   400 					}
   384 					}
   401 				
   385 				
   402 				CNcsComposeViewContainer* container = 
   386 				CNcsComposeViewContainer* container = 
   403 					static_cast<CNcsComposeViewContainer*>( &iParent );
   387 					static_cast<CNcsComposeViewContainer*>( &iParent );
   404 				container->UpdateScrollBarL();
   388 				container->UpdateScrollBar();
   405 				}
   389 				}
   406 			
   390 			
   407 			if( iLongTapEventConsumed )
   391 			if( iLongTapEventConsumed )
   408 				{
   392 				{
   409 				iLongTapEventConsumed = EFalse;
   393 				iLongTapEventConsumed = EFalse;
   423 				parent.HandleAttachmentsOpenCommandL();
   407 				parent.HandleAttachmentsOpenCommandL();
   424 				}          
   408 				}          
   425 	        }
   409 	        }
   426         }
   410         }
   427 
   411 
   428     if ( aPointerEvent.iType != TPointerEvent::EDrag )
   412 	CCoeControl::HandlePointerEventL( aPointerEvent );
   429     	{
       
   430 		CCoeControl::HandlePointerEventL( aPointerEvent );
       
   431     	}
       
   432     }
   413     }
   433 
   414 
   434 // -----------------------------------------------------------------------------
   415 // -----------------------------------------------------------------------------
   435 // CNcsHeaderContainer::HandleLongTapL()
   416 // CNcsHeaderContainer::HandleLongTapL()
   436 // 
   417 // 
   461 // -----------------------------------------------------------------------------
   442 // -----------------------------------------------------------------------------
   462 TBool CNcsHeaderContainer::NeedsLongTapL( const TPoint& aPenEventLocation )
   443 TBool CNcsHeaderContainer::NeedsLongTapL( const TPoint& aPenEventLocation )
   463     {
   444     {
   464 	FUNC_LOG;
   445 	FUNC_LOG;
   465 
   446 
   466     CCoeControl* control = FindFocused();
       
   467     TRect rect = iAttachmentField->Rect();
   447     TRect rect = iAttachmentField->Rect();
   468     TBool result( EFalse );
   448     TBool result( EFalse );
   469 	if( iAttachmentField->IsVisible() && rect.Contains( aPenEventLocation ) &&
   449 	if( iAttachmentField->IsVisible() && rect.Contains( aPenEventLocation ) &&
   470 	    KNoAttachmentLabelFocused !=
   450 	    KNoAttachmentLabelFocused !=
   471             iAttachmentField->FocusedAttachmentLabelIndex() )
   451             iAttachmentField->FocusedAttachmentLabelIndex() )
   570     		}
   550     		}
   571     	}
   551     	}
   572 
   552 
   573     if( doScroll )
   553     if( doScroll )
   574     	{
   554     	{
   575     	DoScrollL();
   555     	DoScroll();
   576     	}
   556     	}
   577 
   557 
   578     return ret;
   558     return ret;
   579 	}
   559 	}
   580 
   560 
   663 		}
   643 		}
   664 	
   644 	
   665     // if focus was changed, update scroll bar
   645     // if focus was changed, update scroll bar
   666     if ( ret == EKeyWasConsumed )
   646     if ( ret == EKeyWasConsumed )
   667         {
   647         {
   668         container->UpdateScrollBarL();
   648         container->UpdateScrollBar();
   669         DoScrollL();
   649         DoScroll();
   670         }
   650         }
   671 
   651 
   672 	// NOTE: If we're leaving the header (down was pushed on last control)
   652 	// NOTE: If we're leaving the header (down was pushed on last control)
   673 	//       then we return EKeyWasNotConsumed to make sure the
   653 	//       then we return EKeyWasNotConsumed to make sure the
   674 	//		 parent moves the focus to the control below this container
   654 	//		 parent moves the focus to the control below this container
   763 // -----------------------------------------------------------------------------
   743 // -----------------------------------------------------------------------------
   764 // CNcsHeaderContainer::PositionChanged()
   744 // CNcsHeaderContainer::PositionChanged()
   765 // set size
   745 // set size
   766 // -----------------------------------------------------------------------------
   746 // -----------------------------------------------------------------------------
   767 void CNcsHeaderContainer::PositionChanged()
   747 void CNcsHeaderContainer::PositionChanged()
   768 	{
   748     {
   769     FUNC_LOG;
   749     FUNC_LOG;
   770 	DrawDeferred();
   750     }
   771 	}
       
   772 
   751 
   773 // -----------------------------------------------------------------------------
   752 // -----------------------------------------------------------------------------
   774 // CNcsHeaderContainer::ChangePositions()
   753 // CNcsHeaderContainer::ChangePositions()
   775 // set positions
   754 // set positions
   776 // -----------------------------------------------------------------------------
   755 // -----------------------------------------------------------------------------
  1326 
  1305 
  1327 // -----------------------------------------------------------------------------
  1306 // -----------------------------------------------------------------------------
  1328 // CNcsHeaderContainer::CalculatePopupRect
  1307 // CNcsHeaderContainer::CalculatePopupRect
  1329 // -----------------------------------------------------------------------------
  1308 // -----------------------------------------------------------------------------
  1330 TRect CNcsHeaderContainer::CalculatePopupRect()
  1309 TRect CNcsHeaderContainer::CalculatePopupRect()
  1331 	{
  1310     {
  1332     FUNC_LOG;
  1311     FUNC_LOG;
  1333     // get focused control rect
  1312     // get focused control rect
  1334 	TRect popupRect;
  1313     TRect popupRect;
  1335 
  1314 
  1336     CCoeControl* focused = FindFocused();
  1315     CCoeControl* focused = FindFocused();
  1337     if ( IsAddressInputField( focused ) )
  1316     if ( IsAddressInputField( focused ) )
  1338         {
  1317         {
  1339         CNcsAddressInputField* aifEditor =
  1318         CNcsAddressInputField* aifEditor =
  1340             static_cast<CNcsAddressInputField*>( focused );
  1319             static_cast<CNcsAddressInputField*>( focused );
  1341 
  1320 
       
  1321         TPoint editorPos = aifEditor->Editor()->PositionRelativeToScreen();
  1342         TRect editorRect = aifEditor->Editor()->Rect();
  1322         TRect editorRect = aifEditor->Editor()->Rect();
  1343         
  1323 
  1344         popupRect.iTl =
  1324         popupRect.iTl = TPoint( editorPos.iX, 
  1345             TPoint( editorRect.iTl.iX - 1, 
  1325             editorPos.iY + aifEditor->CursorPosition() + 1 );
  1346                     editorRect.iTl.iY + aifEditor->CursorPosition() + 1 );
  1326 
  1347         
  1327         popupRect.iBr = TPoint( editorPos.iX + editorRect.Width(),
  1348         popupRect.iBr = 
  1328             iParent.PositionRelativeToScreen().iY + iParent.Rect().Height() );
  1349             TPoint( editorRect.iBr.iX + 1, iParent.Rect().iBr.iY );
       
  1350         }
  1329         }
  1351 
  1330 
  1352     return popupRect;
  1331     return popupRect;
  1353 	}
  1332     }
  1354 
  1333 
  1355 // -----------------------------------------------------------------------------
  1334 // -----------------------------------------------------------------------------
  1356 // CNcsHeaderContainer::DoPopupSelect
  1335 // CNcsHeaderContainer::DoPopupSelect
  1357 // -----------------------------------------------------------------------------
  1336 // -----------------------------------------------------------------------------
  1358 void CNcsHeaderContainer::DoPopupSelectL()
  1337 void CNcsHeaderContainer::DoPopupSelectL()
  1401             else
  1380             else
  1402                 {           
  1381                 {           
  1403                 // selected contact doesn't have email address, launch remote
  1382                 // selected contact doesn't have email address, launch remote
  1404                 // contact lookup rcl must be usable, since otherwise there 
  1383                 // contact lookup rcl must be usable, since otherwise there 
  1405                 // couldn't be any items without email addresses
  1384                 // couldn't be any items without email addresses
       
  1385                 iRALInProgress = ETrue; 
  1406                 CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason
  1386                 CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason
  1407                     exitReason;
  1387                     exitReason;
  1408                 CNcsEmailAddressObject* remAddress = ExecuteRemoteSearchL(
  1388                 CNcsEmailAddressObject* remAddress = ExecuteRemoteSearchL(
  1409                     exitReason,
  1389                     exitReason,
  1410                     emailAddress->DisplayName() );
  1390                     emailAddress->DisplayName() );
       
  1391                 iRALInProgress = EFalse;
       
  1392                 // Refresh the toolbar. It was hidden during the remote search 
       
  1393                 // and now it needs to be shown. FocusChanged () will do it. 
       
  1394                 CNcsComposeViewContainer& parent = 
       
  1395                     static_cast<CNcsComposeViewContainer&>( iParent );
       
  1396                 parent.FocusChanged( EDrawNow );
       
  1397                 
  1411                 if ( remAddress )
  1398                 if ( remAddress )
  1412                     {
  1399                     {
  1413                     CleanupStack::PushL( remAddress );
  1400                     CleanupStack::PushL( remAddress );
  1414                     IncludeAddressL( *remAddress );
  1401                     IncludeAddressL( *remAddress );
  1415                     CleanupStack::PopAndDestroy( remAddress );
  1402                     CleanupStack::PopAndDestroy( remAddress );
  1793 	    {
  1780 	    {
  1794     	CNcsAddressInputField* aifFocused = NULL;
  1781     	CNcsAddressInputField* aifFocused = NULL;
  1795     	aifFocused = static_cast<CNcsAddressInputField*>( focused );
  1782     	aifFocused = static_cast<CNcsAddressInputField*>( focused );
  1796     	aifFocused->AddAddressL( aEml );
  1783     	aifFocused->AddAddressL( aEml );
  1797 	    }
  1784 	    }
  1798 	DoScrollL();
  1785     DoScroll();
  1799     }
  1786     }
  1800 
  1787 
  1801 // ---------------------------------------------------------------------------
  1788 // ---------------------------------------------------------------------------
  1802 // CNcsHeaderContainer::IncludeAddressL
  1789 // CNcsHeaderContainer::IncludeAddressL
  1803 // ---------------------------------------------------------------------------
  1790 // ---------------------------------------------------------------------------
  2034             }
  2021             }
  2035         }
  2022         }
  2036     }
  2023     }
  2037 
  2024 
  2038 // -----------------------------------------------------------------------------
  2025 // -----------------------------------------------------------------------------
  2039 // CNcsHeaderContainer::DoScrollL
  2026 // CNcsHeaderContainer::DoScroll
       
  2027 // -----------------------------------------------------------------------------
  2040 // 
  2028 // 
  2041 // -----------------------------------------------------------------------------
  2029 void CNcsHeaderContainer::DoScroll()
  2042 void CNcsHeaderContainer::DoScrollL()
       
  2043     {
  2030     {
  2044     // scroll the screen if the cursor goes beyond the screen
  2031     // scroll the screen if the cursor goes beyond the screen
  2045     CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
  2032     CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
  2046     
  2033     
  2047     TInt screenPos( -Position().iY );
  2034     TInt screenPos( -Position().iY );
  2048     TInt cursorPos( CursorPosition() );
  2035     TInt cursorPos( CursorPosition() );
  2049     TInt lineHeight( Rect().Height() / LineCount() );
  2036     TInt lineHeight( Rect().Height() / LineCount() );
  2050     TInt screenHeight( parent.Rect().Height() );
  2037     TInt screenHeight( parent.Rect().Height() );
  2051     
  2038 
  2052     if( cursorPos - lineHeight < screenPos )
  2039     if ( cursorPos - lineHeight < screenPos )
  2053         {
  2040         {
  2054         screenPos = cursorPos - lineHeight;             
  2041         screenPos = cursorPos - lineHeight;             
  2055         }
  2042         }
  2056     else
  2043     else if( cursorPos + lineHeight > screenPos + screenHeight )
  2057     if( cursorPos + lineHeight > screenPos + screenHeight )
       
  2058         {
  2044         {
  2059         screenPos = cursorPos + lineHeight - screenHeight;
  2045         screenPos = cursorPos + lineHeight - screenHeight;
  2060         }
  2046         }
  2061     
  2047 
  2062     parent.ScrollL( screenPos );
  2048     parent.Scroll( screenPos );
  2063     PositionChanged();    
  2049     }
  2064     }
  2050 
       
  2051 // ---------------------------------------------------------------------------
       
  2052 // CNcsHeaderContainer::SetPhysicsEmulationOngoing
       
  2053 // ---------------------------------------------------------------------------
       
  2054 //
       
  2055 void CNcsHeaderContainer::SetPhysicsEmulationOngoing( TBool aPhysOngoing )
       
  2056     {
       
  2057     iToField->SetCursorVisible( !aPhysOngoing );
       
  2058     iCcField->SetCursorVisible( !aPhysOngoing );
       
  2059     iBccField->SetCursorVisible( !aPhysOngoing );
       
  2060     iSubjectField->SetCursorVisible( !aPhysOngoing );
       
  2061     }