meetingrequest/mrgui/mrfieldbuildercommon/src/cesmrfield.cpp
branchRCL_3
changeset 22 d620048b4810
parent 18 6b8f3b30d0ec
equal deleted inserted replaced
20:efd4f1afd43e 22:d620048b4810
    21 #include "nmrlayoutmanager.h"
    21 #include "nmrlayoutmanager.h"
    22 #include "mesmrfieldeventqueue.h"
    22 #include "mesmrfieldeventqueue.h"
    23 #include "cesmrfieldcommandevent.h"
    23 #include "cesmrfieldcommandevent.h"
    24 #include "cmrbackground.h"
    24 #include "cmrbackground.h"
    25 #include "esmrcommands.h"
    25 #include "esmrcommands.h"
       
    26 #include "cmrrecordinggc.h"
    26 
    27 
    27 #include "emailtrace.h"
    28 #include "emailtrace.h"
    28 
    29 
    29 #include <txtrich.h>
    30 #include <txtrich.h>
    30 #include <eikenv.h>
    31 #include <eikenv.h>
    32 #include <eikbtgpc.h>
    33 #include <eikbtgpc.h>
    33 #include <StringLoader.h>
    34 #include <StringLoader.h>
    34 #include <AknUtils.h>
    35 #include <AknUtils.h>
    35 #include <touchfeedback.h>
    36 #include <touchfeedback.h>
    36 
    37 
       
    38 namespace
       
    39 {
       
    40 // Off-screen x coordinate for fields
       
    41 const TInt KOffScreenPositionX = 1000;
       
    42 }
       
    43 
    37 // ======== MEMBER FUNCTIONS ========
    44 // ======== MEMBER FUNCTIONS ========
    38 
    45 
    39 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
    40 // CESMRField::CESMRField
    47 // CESMRField::CESMRField
    41 // ---------------------------------------------------------------------------
    48 // ---------------------------------------------------------------------------
    63     if ( iEventQueue )
    70     if ( iEventQueue )
    64         {
    71         {
    65         iEventQueue->RemoveObserver( this );
    72         iEventQueue->RemoveObserver( this );
    66         }
    73         }
    67     delete iBackground;
    74     delete iBackground;
       
    75     delete iRecordingGc;
    68     }
    76     }
    69 
    77 
    70 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
    71 // CESMRField::ConstructL
    79 // CESMRField::ConstructL
    72 // ---------------------------------------------------------------------------
    80 // ---------------------------------------------------------------------------
    77     FUNC_LOG;
    85     FUNC_LOG;
    78     iExtControl = aControl;
    86     iExtControl = aControl;
    79 
    87 
    80     iBackground = CMRBackground::NewL();
    88     iBackground = CMRBackground::NewL();
    81     this->SetBackground( iBackground );
    89     this->SetBackground( iBackground );
       
    90     iRecordingGc = new( ELeave ) CMRRecordingGc( SystemGc() );
    82     }
    91     }
    83 
    92 
    84 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
    85 // CESMRField::InitializeL
    94 // CESMRField::InitializeL
    86 // ---------------------------------------------------------------------------
    95 // ---------------------------------------------------------------------------
   217         NMRLayoutManager::GetFieldLayoutRect( listareaLayoutRect.Rect(), 1 );
   226         NMRLayoutManager::GetFieldLayoutRect( listareaLayoutRect.Rect(), 1 );
   218     return TSize( Parent()->Size().iWidth, fieldLayoutRect.Rect().Height() );
   227     return TSize( Parent()->Size().iWidth, fieldLayoutRect.Rect().Height() );
   219     }
   228     }
   220 
   229 
   221 // ---------------------------------------------------------------------------
   230 // ---------------------------------------------------------------------------
       
   231 // CESMRField::Draw
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C void CESMRField::Draw( const TRect& aRect ) const
       
   235     {
       
   236     FUNC_LOG;
       
   237 
       
   238     // Draw only if field is not on screen
       
   239     if ( Position().iX != Parent()->Position().iX )
       
   240         {
       
   241         // Flush cached drawing commands from custom graphics context
       
   242         iRecordingGc->FlushBuffer( aRect );
       
   243         }
       
   244 
       
   245     }
       
   246 
       
   247 // ---------------------------------------------------------------------------
   222 // CESMRField::HandlePointerEventL
   248 // CESMRField::HandlePointerEventL
   223 // ---------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
   224 //
   250 //
   225 EXPORT_C void CESMRField::HandlePointerEventL(
   251 EXPORT_C void CESMRField::HandlePointerEventL(
   226         const TPointerEvent& aPointerEvent )
   252         const TPointerEvent& aPointerEvent )
   254 // ---------------------------------------------------------------------------
   280 // ---------------------------------------------------------------------------
   255 //
   281 //
   256 EXPORT_C void CESMRField::SetContainerWindowL(const CCoeControl& aContainer)
   282 EXPORT_C void CESMRField::SetContainerWindowL(const CCoeControl& aContainer)
   257     {
   283     {
   258     FUNC_LOG;
   284     FUNC_LOG;
       
   285 
       
   286     // Use container window from aContainer
       
   287     // This will set also aContainer as MOP parent and CCoeControl parent
   259     CCoeControl::SetContainerWindowL( aContainer );
   288     CCoeControl::SetContainerWindowL( aContainer );
   260     if ( iExtControl )
   289 
   261         {
   290     // Set this same window and this as parent for component controls
   262         iExtControl->SetContainerWindowL( aContainer );
   291     TInt count( CountComponentControls() );
   263         iExtControl->SetParent( this );
   292 
       
   293     for ( TInt i = 0; i < count; ++i )
       
   294         {
       
   295         ComponentControl( i )->SetContainerWindowL( *this );
   264         }
   296         }
   265     }
   297     }
   266 
   298 
   267 // ---------------------------------------------------------------------------
   299 // ---------------------------------------------------------------------------
   268 // CESMRField::SetListObserver
   300 // CESMRField::SetListObserver
   320 //
   352 //
   321 EXPORT_C void CESMRField::SetOutlineFocusL( TBool aFocus )
   353 EXPORT_C void CESMRField::SetOutlineFocusL( TBool aFocus )
   322     {
   354     {
   323     FUNC_LOG;
   355     FUNC_LOG;
   324     iOutlineFocus = aFocus;
   356     iOutlineFocus = aFocus;
       
   357 
   325     if ( iExtControl )
   358     if ( iExtControl )
   326         {
   359         {
   327         iExtControl->SetFocus( aFocus );
   360         iExtControl->SetFocus( aFocus );
   328         }
   361         }
   329     if ( aFocus )
   362     if ( aFocus )
   827              CCoeControl* aControl )
   860              CCoeControl* aControl )
   828     {
   861     {
   829     FUNC_LOG;
   862     FUNC_LOG;
   830     delete iExtControl;
   863     delete iExtControl;
   831     iExtControl = aControl;
   864     iExtControl = aControl;
       
   865 
       
   866     // Set also container window
       
   867     iExtControl->SetContainerWindowL( *this );
   832     }
   868     }
   833 
   869 
   834 // ---------------------------------------------------------------------------
   870 // ---------------------------------------------------------------------------
   835 // CESMRField::Lock
   871 // CESMRField::Lock
   836 // ---------------------------------------------------------------------------
   872 // ---------------------------------------------------------------------------
   854 // ---------------------------------------------------------------------------
   890 // ---------------------------------------------------------------------------
   855 // CESMRField::SupportsLongTapFunctionalityL
   891 // CESMRField::SupportsLongTapFunctionalityL
   856 // ---------------------------------------------------------------------------
   892 // ---------------------------------------------------------------------------
   857 //
   893 //
   858 EXPORT_C TBool CESMRField::SupportsLongTapFunctionalityL(
   894 EXPORT_C TBool CESMRField::SupportsLongTapFunctionalityL(
   859 		const TPointerEvent &aPointerEvent )
   895 		const TPointerEvent& /*aPointerEvent*/ )
   860 	{
   896 	{
   861     FUNC_LOG;
   897     FUNC_LOG;
   862     // Subclasses may override for field specific actions
   898     // Subclasses may override for field specific actions
   863 	return EFalse;
   899 	return EFalse;
   864 	}
   900 	}
       
   901 
       
   902 // ---------------------------------------------------------------------------
       
   903 // CESMRField::MoveToScreen
       
   904 // ---------------------------------------------------------------------------
       
   905 //
       
   906 EXPORT_C void CESMRField::MoveToScreen( TBool aVisible )
       
   907     {
       
   908     FUNC_LOG
       
   909 
       
   910     // Check that field is activated
       
   911     if ( IsActivated() )
       
   912         {
       
   913         TPoint pos( Position() );
       
   914 
       
   915         if ( aVisible )
       
   916             {
       
   917             // Set x coordinate to parent (field container) x coordinate
       
   918             pos.iX = Parent()->Position().iX;
       
   919             }
       
   920         else
       
   921             {
       
   922             // Move field outside screen
       
   923             pos.iX = KOffScreenPositionX;
       
   924             // Record field drawing commands
       
   925             RecordField();
       
   926             }
       
   927 
       
   928         if ( pos != Position() )
       
   929             {
       
   930             // Set new position only if it different from current one
       
   931             // Setting new position potentially causes relayout in field
       
   932             SetPosition( pos );
       
   933             }
       
   934         }
       
   935     }
   865 
   936 
   866 // ---------------------------------------------------------------------------
   937 // ---------------------------------------------------------------------------
   867 // CESMRField::HandleTactileFeedbackL
   938 // CESMRField::HandleTactileFeedbackL
   868 // ---------------------------------------------------------------------------
   939 // ---------------------------------------------------------------------------
   869 //
   940 //
   890 		// Aquire tactile feedback pointer from TLS
   961 		// Aquire tactile feedback pointer from TLS
   891 		iTactileFeedback = MTouchFeedback::Instance();
   962 		iTactileFeedback = MTouchFeedback::Instance();
   892 		}
   963 		}
   893     }
   964     }
   894 
   965 
       
   966 // ---------------------------------------------------------------------------
       
   967 // CESMRField::RecordField
       
   968 // ---------------------------------------------------------------------------
       
   969 //
       
   970 EXPORT_C void CESMRField::RecordField()
       
   971     {
       
   972     FUNC_LOG;
       
   973 
       
   974     // Record only activated field
       
   975     if ( IsActivated() )
       
   976         {
       
   977         // Purge old draw commands
       
   978         iRecordingGc->PurgeBuffer();
       
   979 
       
   980         // Set recording graphics context to be used for drawing
       
   981         SetCustomGc( iRecordingGc );
       
   982 
       
   983         // Set gc origin to point (-x,-y)
       
   984         // This will cause drawing commands to be relative to point (0,0)
       
   985         iRecordingGc->SetOrigin( -iPosition );
       
   986 
       
   987         // Draw custom background if available
       
   988         const MCoeControlBackground* bg = Background();
       
   989         if ( bg )
       
   990             {
       
   991             bg->Draw( *iRecordingGc, *this, Rect() );
       
   992             }
       
   993 
       
   994         // Draw child controls
       
   995         DrawControl( this );
       
   996 
       
   997         // Reset custom gc
       
   998         SetCustomGc( NULL );
       
   999         }
       
  1000     }
       
  1001 
       
  1002 // ---------------------------------------------------------------------------
       
  1003 // CESMRField::DrawControl
       
  1004 // ---------------------------------------------------------------------------
       
  1005 //
       
  1006 void CESMRField::DrawControl( CCoeControl* aControl ) const
       
  1007     {
       
  1008     TInt count( aControl->CountComponentControls() );
       
  1009 
       
  1010     for ( TInt i = 0; i < count; ++i )
       
  1011         {
       
  1012         CCoeControl* control = aControl->ComponentControl( i );
       
  1013 
       
  1014         // Draw only non-window owning children
       
  1015         if ( !control->OwnsWindow() )
       
  1016             {
       
  1017             TRect rect( control->Rect() );
       
  1018 
       
  1019             // Draw control background if available
       
  1020             const MCoeControlBackground* bg = control->Background();
       
  1021             if ( bg )
       
  1022                 {
       
  1023                 bg->Draw( *iRecordingGc, *control, rect );
       
  1024                 }
       
  1025 
       
  1026             // Draw control foreground
       
  1027             control->DrawForeground( rect );
       
  1028 
       
  1029             // Draw child components
       
  1030             DrawControl( control );
       
  1031             }
       
  1032         }
       
  1033     }
   895 
  1034 
   896 // EOF
  1035 // EOF
   897 
  1036