meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewertimefield.cpp
branchRCL_3
changeset 18 6b8f3b30d0ec
parent 16 b5fbb9b25d57
child 22 d620048b4810
equal deleted inserted replaced
17:67369d1b217f 18:6b8f3b30d0ec
    58 // ---------------------------------------------------------------------------
    58 // ---------------------------------------------------------------------------
    59 //
    59 //
    60 CESMRViewerTimeField::CESMRViewerTimeField()
    60 CESMRViewerTimeField::CESMRViewerTimeField()
    61     {
    61     {
    62     FUNC_LOG;
    62     FUNC_LOG;
    63     
    63 
    64     SetFieldId( EESMRFieldMeetingTime );
    64     SetFieldId( EESMRFieldMeetingTime );
    65     SetFocusType( EESMRHighlightFocus );
    65     SetFocusType( EESMRHighlightFocus );
    66     }
    66     }
    67 
    67 
    68 // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
    97 //
    97 //
    98 void CESMRViewerTimeField::ConstructL()
    98 void CESMRViewerTimeField::ConstructL()
    99     {
    99     {
   100     FUNC_LOG;
   100     FUNC_LOG;
   101     
   101 
   102     iLabel = CMRLabel::NewL();
   102     iLabel = CMRLabel::NewL();
   103     iLabel->SetParent( this );
   103     iLabel->SetParent( this );
   104     CESMRField::ConstructL( iLabel ); // ownership transfered
   104     CESMRField::ConstructL( iLabel ); // ownership transfered
   105 
   105 
   106     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapClock );
   106     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapClock );
   116     FUNC_LOG;
   116     FUNC_LOG;
   117 
   117 
   118     CCalEntry& entry = aEntry.Entry();
   118     CCalEntry& entry = aEntry.Entry();
   119 
   119 
   120     iStartTime = entry.StartTimeL().TimeLocalL();
   120     iStartTime = entry.StartTimeL().TimeLocalL();
   121     iEndTime   = entry.EndTimeL().TimeLocalL();    
   121     iEndTime   = entry.EndTimeL().TimeLocalL();
   122     
   122 
   123     if ( aEntry.IsAllDayEventL() )
   123     if ( aEntry.IsAllDayEventL() )
   124         {
   124         {
   125         // set the field as hidden:
   125         // set the field as hidden:
   126         iObserver->HideControl( FieldId() );
   126         iObserver->HideControl( FieldId() );
   127         }
   127         }
   136 // ---------------------------------------------------------------------------
   136 // ---------------------------------------------------------------------------
   137 //
   137 //
   138 void CESMRViewerTimeField::InitializeL()
   138 void CESMRViewerTimeField::InitializeL()
   139     {
   139     {
   140     FUNC_LOG;
   140     FUNC_LOG;
   141     
   141 
   142     TAknLayoutText text = NMRLayoutManager::GetLayoutText(
   142     TAknLayoutText text = NMRLayoutManager::GetLayoutText(
   143             Rect(),
   143             Rect(),
   144             NMRLayoutManager::EMRTextLayoutTextEditor );
   144             NMRLayoutManager::EMRTextLayoutTextEditor );
   145 
   145 
   146     iLabel->SetFont( text.Font() );
   146     iLabel->SetFont( text.Font() );
   156 // ---------------------------------------------------------------------------
   156 // ---------------------------------------------------------------------------
   157 //
   157 //
   158 void CESMRViewerTimeField::SizeChanged()
   158 void CESMRViewerTimeField::SizeChanged()
   159     {
   159     {
   160     FUNC_LOG;
   160     FUNC_LOG;
   161     
   161 
   162     TRect rect = Rect();
   162     TRect rect = Rect();
   163     TAknLayoutRect rowLayoutRect =
   163     TAknLayoutRect rowLayoutRect =
   164         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   164         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   165     rect = rowLayoutRect.Rect();
   165     rect = rowLayoutRect.Rect();
   166 
   166 
   170     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   170     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   171 
   171 
   172     // Layouting lock icon
   172     // Layouting lock icon
   173     if( iLockIcon )
   173     if( iLockIcon )
   174         {
   174         {
   175         TAknWindowComponentLayout iconLayout( 
   175         TAknWindowComponentLayout iconLayout(
   176                 NMRLayoutManager::GetWindowComponentLayout( 
   176                 NMRLayoutManager::GetWindowComponentLayout(
   177                     NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
   177                     NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
   178         AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
   178         AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
   179         }
   179         }
   180     
   180 
   181     // Layouting label
   181     // Layouting label
   182     TAknLayoutText viewerLayoutText;
   182     TAknTextComponentLayout viewerLayoutText;
   183     if( iLockIcon )
   183     if( iLockIcon )
   184     	{
   184         {
   185     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
   185         viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
   186     			NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
   186                 NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
   187     	}
   187         }
   188     else
   188     else
   189     	{
   189         {
   190     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
   190         viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
   191     			NMRLayoutManager::EMRTextLayoutTextEditor );
   191                 NMRLayoutManager::EMRTextLayoutTextEditor );
   192     	}
   192         }
   193 
   193 
   194     TRect viewerRect( viewerLayoutText.TextRect() );    
   194     AknLayoutUtils::LayoutLabel( iLabel, rect, viewerLayoutText );
   195     iLabel->SetRect( viewerRect );
   195     TRect viewerRect( iLabel->Rect() );
   196 
   196 
   197     // Move focus rect so that it's relative to field's position.
   197     // Move focus rect so that it's relative to field's position.
   198     viewerRect.Move( -Position() );
   198     viewerRect.Move( -Position() );
   199     SetFocusRect( viewerRect );
   199     SetFocusRect( viewerRect );
   200 
       
   201     // Setting font also for the label
       
   202     iLabel->SetFont( viewerLayoutText.Font() );
       
   203     }
   200     }
   204 
   201 
   205 // ---------------------------------------------------------------------------
   202 // ---------------------------------------------------------------------------
   206 // CESMRViewerTimeField::CountComponentControls()
   203 // CESMRViewerTimeField::CountComponentControls()
   207 // ---------------------------------------------------------------------------
   204 // ---------------------------------------------------------------------------
   208 //
   205 //
   209 TInt CESMRViewerTimeField::CountComponentControls() const
   206 TInt CESMRViewerTimeField::CountComponentControls() const
   210     {
   207     {
   211     FUNC_LOG;
   208     FUNC_LOG;
   212     
   209 
   213     TInt count( 0 );
   210     TInt count( 0 );
   214     if ( iIcon )
   211     if ( iIcon )
   215     	{
   212     	{
   216     	++count;
   213     	++count;
   217     	}
   214     	}
   218 
   215 
   219     if ( iLabel )
   216     if ( iLabel )
   220     	{
   217     	{
   221     	++count;
   218     	++count;
   222     	}
   219     	}
   223     
   220 
   224     if ( iLockIcon )
   221     if ( iLockIcon )
   225     	{
   222     	{
   226     	++count;
   223     	++count;
   227     	}
   224     	}
   228     return count;
   225     return count;
   233 // ---------------------------------------------------------------------------
   230 // ---------------------------------------------------------------------------
   234 //
   231 //
   235 CCoeControl* CESMRViewerTimeField::ComponentControl( TInt aIndex ) const
   232 CCoeControl* CESMRViewerTimeField::ComponentControl( TInt aIndex ) const
   236     {
   233     {
   237     FUNC_LOG;
   234     FUNC_LOG;
   238     
   235 
   239     switch ( aIndex )
   236     switch ( aIndex )
   240         {
   237         {
   241         case 0:
   238         case 0:
   242             return iIcon;
   239             return iIcon;
   243         case 1:
   240         case 1:
   254 // ---------------------------------------------------------------------------
   251 // ---------------------------------------------------------------------------
   255 //
   252 //
   256 void CESMRViewerTimeField::SetOutlineFocusL( TBool aFocus )
   253 void CESMRViewerTimeField::SetOutlineFocusL( TBool aFocus )
   257     {
   254     {
   258     FUNC_LOG;
   255     FUNC_LOG;
   259     
   256 
   260     CESMRField::SetOutlineFocusL ( aFocus );
   257     CESMRField::SetOutlineFocusL ( aFocus );
   261 
   258 
   262     iLabel->SetFocus( aFocus );
   259     iLabel->SetFocus( aFocus );
   263     }
   260     }
   264 
   261 
   267 // ---------------------------------------------------------------------------
   264 // ---------------------------------------------------------------------------
   268 //
   265 //
   269 TBool CESMRViewerTimeField::ExecuteGenericCommandL( TInt aCommand )
   266 TBool CESMRViewerTimeField::ExecuteGenericCommandL( TInt aCommand )
   270     {
   267     {
   271     FUNC_LOG;
   268     FUNC_LOG;
   272     
   269 
   273     TBool retValue( EFalse );
   270     TBool retValue( EFalse );
   274     
   271 
   275     if( (aCommand == EAknCmdOpen) && IsLocked()  )
   272     if( (aCommand == EAknCmdOpen) && IsLocked()  )
   276     	{
   273     	{
   277 		HandleTactileFeedbackL();
   274 		HandleTactileFeedbackL();
   278 		
   275 
   279     	CESMRGlobalNote::ExecuteL(
   276     	CESMRGlobalNote::ExecuteL(
   280     			CESMRGlobalNote::EESMRUnableToEdit );
   277     			CESMRGlobalNote::EESMRUnableToEdit );
   281     	retValue = ETrue;
   278     	retValue = ETrue;
   282     	}
   279     	}
   283     
   280 
   284     if ( EMRCmdDoEnvironmentChange == aCommand )
   281     if ( EMRCmdDoEnvironmentChange == aCommand )
   285         {
   282         {
   286         FormatTimeFieldStringL();
   283         FormatTimeFieldStringL();
   287         retValue = ETrue;
   284         retValue = ETrue;
   288         }
   285         }
   289     
   286 
   290     return retValue;
   287     return retValue;
   291     }
   288     }
   292 
   289 
   293 // ---------------------------------------------------------------------------
   290 // ---------------------------------------------------------------------------
   294 // CESMRViewerTimeField::LockL()
   291 // CESMRViewerTimeField::LockL()
   299 	FUNC_LOG;
   296 	FUNC_LOG;
   300 	if( IsLocked() )
   297 	if( IsLocked() )
   301 		{
   298 		{
   302 		return;
   299 		return;
   303 		}
   300 		}
   304 	
   301 
   305 	CESMRField::LockL();
   302 	CESMRField::LockL();
   306 	
   303 
   307 	delete iLockIcon;
   304 	delete iLockIcon;
   308 	iLockIcon = NULL;
   305 	iLockIcon = NULL;
   309 	iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue );
   306 	iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue );
   310 	iLockIcon->SetParent( this );
   307 	iLockIcon->SetParent( this );
   311 	}
   308 	}
   316 //
   313 //
   317 void CESMRViewerTimeField::FormatTimeFieldStringL()
   314 void CESMRViewerTimeField::FormatTimeFieldStringL()
   318     {
   315     {
   319     HBufC* timeFormatString =
   316     HBufC* timeFormatString =
   320         iEikonEnv->AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO );
   317         iEikonEnv->AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO );
   321     
   318 
   322     HBufC* finalBuf = HBufC::NewLC( KTimeBufferSize );
   319     HBufC* finalBuf = HBufC::NewLC( KTimeBufferSize );
   323     HBufC* startBuf = HBufC::NewLC( KTempBufferSize );
   320     HBufC* startBuf = HBufC::NewLC( KTempBufferSize );
   324     HBufC* endBuf = HBufC::NewLC( KTempBufferSize );
   321     HBufC* endBuf = HBufC::NewLC( KTempBufferSize );
   325     const TInt KNumBuffers( 4 );
   322     const TInt KNumBuffers( 4 );
   326 
   323 
   333     finalPtr.Append( KTimeSeparator );
   330     finalPtr.Append( KTimeSeparator );
   334     finalPtr.Append( endPtr );
   331     finalPtr.Append( endPtr );
   335     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finalPtr );
   332     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finalPtr );
   336     iLabel->SetTextL( finalPtr );
   333     iLabel->SetTextL( finalPtr );
   337     CleanupStack::PopAndDestroy( KNumBuffers, timeFormatString );
   334     CleanupStack::PopAndDestroy( KNumBuffers, timeFormatString );
   338     
   335 
   339     }
   336     }
   340 
   337 
   341 // EOF
   338 // EOF