emailuis/emailui/src/ncsaddressinputfield.cpp
branchRCL_3
changeset 73 c8382f7b54ef
parent 64 3533d4323edc
child 80 726fba06891a
--- a/emailuis/emailui/src/ncsaddressinputfield.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncsaddressinputfield.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -92,23 +92,22 @@
 // -----------------------------------------------------------------------------
 //
 void CNcsAddressInputField::ConstructL( TInt aLabelTextId )
-	{
+    {
     FUNC_LOG;
-	// Create label
-	//Load the label string
-	HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
+    // Create label
+    //Load the label string
+    HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
 
-	TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC();
-	CreateControlsL( captionText );
-	
-	iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver,
-                                                captionText );
+    TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC();
+    CreateControlsL( captionText );
+
+    iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver, captionText );
     // iTextEditor is not completely constructed until in SetContainerWindowL()
 
-	iTextEditor->SetPopupList(iAddressPopupList);
+    iTextEditor->SetPopupList(iAddressPopupList);
 
-	CleanupStack::PopAndDestroy( aTextBuf );
-	}
+    CleanupStack::PopAndDestroy( aTextBuf );
+    }
 
 // ---------------------------------------------------------------------------
 // Destructor
@@ -120,15 +119,8 @@
     delete iTextEditor;
     delete iButton;
     delete iLabel;
-// <cmail> Platform layout change
-    /*if ( iFont )
-        {
-        ControlEnv()->ScreenDevice()->ReleaseFont( iFont );
-        iFont = NULL;
-        }</cmail>*/
     }
 
-//<cmail>
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::CreateControlsL()
 // -----------------------------------------------------------------------------
@@ -156,7 +148,6 @@
         iLabel->SetBrushStyle(CWindowGc::ENullBrush);
         }
     }
-//</cmail>
 
 // ---------------------------------------------------------------------------
 // SetContainerWindow
@@ -169,37 +160,34 @@
     FUNC_LOG;
     CCoeControl::SetContainerWindowL(aContainer);
 
-	InitComponentArrayL();
-	// Check if we need to construct the components
-	if (Components().Count() == 2) return;
+    InitComponentArrayL();
+    // Check if we need to construct the components
+    if (Components().Count() == 2) return;
 
-	// Load the controls into the compoent array
-	CCoeControlArray& controls = Components();
-	controls.SetControlsOwnedExternally(ETrue);
-	//<cmail>
-	if( iButton )
-	    {
-	    controls.AppendLC( iButton );
-	    CleanupStack::Pop( iButton );
-	    }
-	else
-	    {
-	    controls.AppendLC( iLabel );
-	    CleanupStack::Pop( iLabel );
-	    }
-	//</cmail>
-	controls.AppendLC(iTextEditor);
+    // Load the controls into the compoent array
+    CCoeControlArray& controls = Components();
+    controls.SetControlsOwnedExternally(ETrue);
+    //<cmail>
+    if( iButton )
+        {
+        controls.AppendLC( iButton );
+        CleanupStack::Pop( iButton );
+        }
+    else
+        {
+        controls.AppendLC( iLabel );
+        CleanupStack::Pop( iLabel );
+        }
+
+    controls.AppendLC(iTextEditor);
     CleanupStack::Pop(iTextEditor);
 
-// <cmail>
-
-	// Setup the text editor
-	iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 );
-// </cmail>
+    // Setup the text editor
+    iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 );
 
     iTextEditor->SetBorder( TGulBorder::ENone );
-	iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
-	iTextEditor->SetAknEditorFlags( EAknEditorFlagNoT9 | EAknEditorFlagUseSCTNumericCharmap );
+    iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
+    iTextEditor->SetAknEditorFlags( EAknEditorFlagNoT9 | EAknEditorFlagUseSCTNumericCharmap );
 
      CRepository* repository = NULL;
      TRAPD( err, repository = CRepository::NewL( KFreestyleEmailCenRep ) );
@@ -214,9 +202,9 @@
          }
     delete repository;
     repository = NULL;
-    
-	iTextEditor->SetAknEditorCurrentCase( EAknEditorLowerCase );
-	iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
+
+    iTextEditor->SetAknEditorCurrentCase( EAknEditorLowerCase );
+    iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
     iTextEditor->SetEdwinSizeObserver( this );
     iTextEditor->SetupEditorL();
 
@@ -266,27 +254,27 @@
 // -----------------------------------------------------------------------------
 //
 void CNcsAddressInputField::SizeChanged()
-	{
+    {
     FUNC_LOG;
 
-   	TRect rect = Rect();
- 
-   	if( AknLayoutUtils::PenEnabled() )
-   	    {
-   	    LayoutTouch();
-   	    }
-   	  else
-   	    {
-   	    LayoutNonTouch();
-   	    }
+    TRect rect = Rect();
+
+    if( AknLayoutUtils::PenEnabled() )
+        {
+        LayoutTouch();
+        }
+    else
+        {
+        LayoutNonTouch();
+        }
 
     // This needs to be bidi as in mirrored layout 
     // writing language left to right can be set. 
     // Need to set here as layout sets it also to left or right.
     iTextEditor->SetAlignment( EAknEditorAlignBidi );
-   	    
+
     UpdateFontSize();
-    
+
     if (iTextEditor->ScrollBarFrame())
         {
         TRect rc = iTextEditor->Rect();
@@ -300,38 +288,37 @@
             }
         iTextEditor->SetRect(rc);
         }
-    
+
     PositionChanged();
-	}
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::PositionChanged()
 // set size
 // -----------------------------------------------------------------------------
 void CNcsAddressInputField::PositionChanged()
-	{
+    {
     FUNC_LOG;
-    
+
     // keep the button in view as long as possible
     if( iButton && iParentControl->IsVisible() )
-    	{
-		const TRect rect( Rect() );
-		const TRect buttonRect( iButton->Rect() );
-		
-		TInt newButtonPos( iOriginalButtonPos.iY - iOriginalFieldPos.iY );
-		
-		if( rect.iTl.iY < 0 && newButtonPos + buttonRect.Height() < rect.iBr.iY )
-			{
-			iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos) );
-			}
-		else
-			{
-			iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos + rect.iTl.iY) );
-			}
-    	}
-	}
+        {
+        const TRect rect( Rect() );
+        const TRect buttonRect( iButton->Rect() );
+
+        TInt newButtonPos( iOriginalButtonPos.iY - iOriginalFieldPos.iY );
 
-//<cmail>
+        if( rect.iTl.iY < 0 && newButtonPos + buttonRect.Height() < rect.iBr.iY )
+            {
+            iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos) );
+            }
+        else
+            {
+            iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos + rect.iTl.iY) );
+            }
+        }
+    }
+
 // -----------------------------------------------------------------------------
 // CNcsAddressInputField::LayoutNonTouch()
 // 
@@ -361,7 +348,7 @@
 
     iTextEditor->UpdateCustomDrawer();
     }
-    
+
 // -----------------------------------------------------------------------------
 // CNcsAddressInputField::HandlePointerEventL()
 // Handles pointer events
@@ -369,38 +356,33 @@
 //
 void CNcsAddressInputField::HandlePointerEventL( const TPointerEvent& aPointerEvent )
     {
-	FUNC_LOG;
-    iTextEditor->HandlePointerEventL(aPointerEvent);
-    if( iButton )
+    FUNC_LOG;
+    CCoeControl::HandlePointerEventL( aPointerEvent );
+
+    switch ( aPointerEvent.iType )
         {
-        iButton->HandlePointerEventL( aPointerEvent );
-        }
-    iTextEditor->HandleTextChangedL();
-    
-    switch( aPointerEvent.iType )
-    	{
-    	case TPointerEvent::EButton1Down:
-    		{
+        case TPointerEvent::EButton1Down:
+            {
             // Save start position so that it can be used in
             // drag/scrolling calculations
             iStartPosition = aPointerEvent.iPosition;
             iIsDraggingStarted = EFalse;
             break;
-    		}
-    		
-    	case TPointerEvent::EDrag:
-    		{
+            }
+
+        case TPointerEvent::EDrag:
+            {
             if ( !iIsDraggingStarted && iPhysics )
                 {
                 TInt drag( iStartPosition.iY - aPointerEvent.iPosition.iY );
                 if ( Abs( drag ) > iPhysics->DragThreshold() )
                     {
-					iIsDraggingStarted = ETrue;
+                    iIsDraggingStarted = ETrue;
                     }
                 }
             break;
-    		}
-    	}
+            }
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -418,7 +400,6 @@
             }
         }
     }
-//</cmail>
 
 // -----------------------------------------------------------------------------
 // CNcsAddressInputField::OfferKeyEventL()
@@ -427,22 +408,22 @@
 //
 TKeyResponse 
 CNcsAddressInputField::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
-	{
+    {
     FUNC_LOG;
-	TKeyResponse ret( EKeyWasNotConsumed );
+    TKeyResponse ret( EKeyWasNotConsumed );
 
-	if( aKeyEvent.iCode == EKeyOK )
-		{
-		iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse );
-		iTextEditor->UpdateAddressListAllL();
-		}
-	else
-		{
-		ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType );
-		}
+    if( aKeyEvent.iCode == EKeyOK )
+        {
+        iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse );
+        iTextEditor->UpdateAddressListAllL();
+        }
+    else
+        {
+        ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType );
+        }
 
-	return ret;
-	}
+    return ret;
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsAddressInputField::FocusChanged()
@@ -455,30 +436,6 @@
 		{
 		iTextEditor->SetFocus( ETrue, aDrawNow );
         //TRAP_IGNORE( iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ) );
-
-        // make sure that control is visible on screen
-		if ( Rect().iTl.iY < 0 )
-			{
-			TPoint pt = TPoint( 0, 0 );
-			Reposition( pt,Rect().Width() );
-            iSizeObserver->UpdateFieldPosition( this );
-			}
-		else
-		    {
-		    TPoint pos = PositionRelativeToScreen();
-		    pos.iY += Size().iHeight;
-    	    CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
-    	    TPixelsAndRotation pix;
-    		screenDev->GetDefaultScreenSizeAndRotation( pix );
-    		const TInt h = pix.iPixelSize.iHeight;
-    		if ( pos.iY >= h - h / 3 )
-    		    {
-    			TPoint pt = TPoint( 0, h / 3 );
-    			Reposition( pt,Rect().Width() );
-                iSizeObserver->UpdateFieldPosition( this );
-    		    }
-		    }
-
         if ( iParentControl )
             {
             TRAP_IGNORE( iParentControl->SetMskL() );
@@ -771,10 +728,10 @@
 // CNcsAddressInputField::GetLineRectL()
 // -----------------------------------------------------------------------------
 //
-void CNcsAddressInputField::GetLineRectL( TRect& aLineRect ) const
+void CNcsAddressInputField::GetLineRect( TRect& aLineRect ) const
 	{
     FUNC_LOG;
-    return iTextEditor->GetLineRectL( aLineRect );
+    return iTextEditor->GetLineRect( aLineRect );
 	}
 
 // -----------------------------------------------------------------------------