emailuis/emailui/src/ncssubjectfield.cpp
branchRCL_3
changeset 10 f5907b1a1053
parent 8 e1b6206813b4
child 12 4ce476e64c59
equal deleted inserted replaced
8:e1b6206813b4 10:f5907b1a1053
   248 // -----------------------------------------------------------------------------
   248 // -----------------------------------------------------------------------------
   249 //
   249 //
   250 void CNcsSubjectField::FocusChanged( TDrawNow aDrawNow )
   250 void CNcsSubjectField::FocusChanged( TDrawNow aDrawNow )
   251 	{
   251 	{
   252     FUNC_LOG;
   252     FUNC_LOG;
   253 	iDrawAfterFocusChange = aDrawNow;
   253 	if ( IsFocused() )
   254 	DoHandleFocusChanged( this );
   254 		{
   255 	}
   255 		iTextEditor->SetFocus( ETrue );
   256 
   256 		TRAP_IGNORE( iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ) ); 
   257 // -----------------------------------------------------------------------------
   257 
   258 // CNcsSubjectField::HandleFocusChangedL()
   258 		// make sure that control is visible on screen
   259 // -----------------------------------------------------------------------------
   259 		if ( Rect().iTl.iY < 0 )
   260 //
   260 			{
   261 void CNcsSubjectField::HandleFocusChangedL()
   261 			TPoint pt = TPoint( 0, 0 );
   262     {
   262 			Reposition( pt, Rect().Width() );
   263     FUNC_LOG;
   263 			iSizeObserver->UpdateFieldPosition( this );
   264     if ( IsFocused() )
   264 			}
   265         {
   265 		else
   266         iTextEditor->SetFocus( ETrue );
   266 			{
   267         iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse );
   267 			TPoint pos = PositionRelativeToScreen();
   268 
   268 			pos.iY += Size().iHeight;
   269         // make sure that control is visible on screen
   269 			CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
   270         if ( Rect().iTl.iY < 0 )
   270 			TPixelsAndRotation pix;
   271             {
   271 			screenDev->GetDefaultScreenSizeAndRotation( pix );
   272             TPoint pt = TPoint( 0, 0 );
   272 			const TInt h = pix.iPixelSize.iHeight;
   273             Reposition( pt, Rect().Width() );
   273 			if ( pos.iY >= h - h / 3 )
   274             iSizeObserver->UpdateFieldPosition( this );
   274 				{
   275             }
   275 				TPoint pt = TPoint( 0, h / 3 );
   276         else
   276 				Reposition( pt, Rect().Width() );
   277             {
   277 				iSizeObserver->UpdateFieldPosition( this );
   278             TPoint pos = PositionRelativeToScreen();
   278 				}
   279             pos.iY += Size().iHeight;
   279 			}
   280             CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
   280 
   281             TPixelsAndRotation pix;
   281 		if ( iParentControl )
   282             screenDev->GetDefaultScreenSizeAndRotation( pix );
   282 			{
   283             const TInt h = pix.iPixelSize.iHeight;
   283 			TRAP_IGNORE( iParentControl->SetMskL() );
   284             if ( pos.iY >= h - h / 3 )
   284 			}
   285                 {
   285 		}
   286                 TPoint pt = TPoint( 0, h / 3 );
   286 	else
   287                 Reposition( pt, Rect().Width() );
   287 		{
   288                 iSizeObserver->UpdateFieldPosition( this );
   288 		iTextEditor->SetFocus( EFalse );
   289                 }
   289 		}
   290             }
   290 
   291 
   291 	if ( aDrawNow )
   292         if ( iParentControl )
   292 		{
   293             {
   293 		DrawNow();
   294             iParentControl->SetMskL();
   294 		}
   295             }
   295 	}
   296         }
       
   297     else
       
   298         {
       
   299         iTextEditor->HandleTextChangedL();
       
   300         iTextEditor->SetFocus( EFalse );
       
   301         }
       
   302 
       
   303     if ( iDrawAfterFocusChange )
       
   304         {
       
   305         DrawNow();
       
   306         }
       
   307     }
       
   308 
       
   309 // -----------------------------------------------------------------------------
       
   310 // CNcsSubjectField::DoHandleFocusChanged()
       
   311 // -----------------------------------------------------------------------------
       
   312 //
       
   313 TInt CNcsSubjectField::DoHandleFocusChanged( TAny* aSelfPtr )
       
   314     {
       
   315     FUNC_LOG;
       
   316     CNcsSubjectField* self = static_cast<CNcsSubjectField*>( aSelfPtr );
       
   317     TRAPD( err, self->HandleFocusChangedL() );
       
   318     return err;
       
   319     }
       
   320 
   296 
   321 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   322 // CNcsSubjectField::MinimumHeight()
   298 // CNcsSubjectField::MinimumHeight()
   323 // return height of subject control
   299 // return height of subject control
   324 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   350 void CNcsSubjectField::SetSubjectL( const TDesC& aSubject )
   326 void CNcsSubjectField::SetSubjectL( const TDesC& aSubject )
   351     {
   327     {
   352     FUNC_LOG;
   328     FUNC_LOG;
   353     if ( &aSubject && aSubject.Length() > 0 )
   329     if ( &aSubject && aSubject.Length() > 0 )
   354     	{
   330     	{
   355 	    RMemReadStream inputStream( aSubject.Ptr(), aSubject.Size() );
   331         // clear subject if necessary
       
   332         TInt documentLength = iTextEditor->RichText()->DocumentLength();
       
   333         if ( documentLength > 0 )
       
   334             {
       
   335             iTextEditor->RichText()->DeleteL( 0, documentLength );
       
   336             iTextEditor->HandleTextChangedL();
       
   337             }
       
   338 
       
   339         RMemReadStream inputStream( aSubject.Ptr(), aSubject.Size() );
   356 	    CleanupClosePushL( inputStream );
   340 	    CleanupClosePushL( inputStream );
   357 
   341 
   358 	  	iTextEditor->RichText()->ImportTextL( 0, inputStream, CPlainText::EOrganiseByParagraph );
   342 	  	iTextEditor->RichText()->ImportTextL( 0, inputStream, CPlainText::EOrganiseByParagraph );
   359 
   343 
   360 		// Activating the field will set the control to the end of the text
   344 		// Activating the field will set the control to the end of the text