meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewerstartdatefield.cpp
branchRCL_3
changeset 18 6b8f3b30d0ec
parent 16 b5fbb9b25d57
child 22 d620048b4810
equal deleted inserted replaced
17:67369d1b217f 18:6b8f3b30d0ec
    53 // -----------------------------------------------------------------------------
    53 // -----------------------------------------------------------------------------
    54 //
    54 //
    55 CESMRViewerStartDateField::CESMRViewerStartDateField()
    55 CESMRViewerStartDateField::CESMRViewerStartDateField()
    56     {
    56     {
    57     FUNC_LOG;
    57     FUNC_LOG;
    58     
    58 
    59     SetFieldId ( EESMRFieldStartDate );
    59     SetFieldId ( EESMRFieldStartDate );
    60     SetFocusType( EESMRHighlightFocus );
    60     SetFocusType( EESMRHighlightFocus );
    61     }
    61     }
    62 
    62 
    63 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    66 //
    66 //
    67 CESMRViewerStartDateField::~CESMRViewerStartDateField()
    67 CESMRViewerStartDateField::~CESMRViewerStartDateField()
    68     {
    68     {
    69     FUNC_LOG;
    69     FUNC_LOG;
    70     
    70 
    71     delete iIcon;
    71     delete iIcon;
    72     delete iLockIcon;
    72     delete iLockIcon;
    73     }
    73     }
    74 
    74 
    75 // -----------------------------------------------------------------------------
    75 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    78 //
    78 //
    79 CESMRViewerStartDateField* CESMRViewerStartDateField::NewL()
    79 CESMRViewerStartDateField* CESMRViewerStartDateField::NewL()
    80     {
    80     {
    81     FUNC_LOG;
    81     FUNC_LOG;
    82     
    82 
    83     CESMRViewerStartDateField* self = 
    83     CESMRViewerStartDateField* self =
    84             new (ELeave) CESMRViewerStartDateField();
    84             new (ELeave) CESMRViewerStartDateField();
    85     CleanupStack::PushL( self );
    85     CleanupStack::PushL( self );
    86     self->ConstructL();
    86     self->ConstructL();
    87     CleanupStack::Pop( self );
    87     CleanupStack::Pop( self );
    88     return self;
    88     return self;
    93 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    94 //
    94 //
    95 void CESMRViewerStartDateField::ConstructL()
    95 void CESMRViewerStartDateField::ConstructL()
    96     {
    96     {
    97     FUNC_LOG;
    97     FUNC_LOG;
    98     
    98 
    99     iLabel = CMRLabel::NewL();
    99     iLabel = CMRLabel::NewL();
   100     iLabel->SetParent( this );
   100     iLabel->SetParent( this );
   101     CESMRField::ConstructL( iLabel ); // ownership transfered
   101     CESMRField::ConstructL( iLabel ); // ownership transfered
   102 
   102 
   103     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapDateStart );
   103     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapDateStart );
   110 //
   110 //
   111 void CESMRViewerStartDateField::InternalizeL( MESMRCalEntry& aEntry )
   111 void CESMRViewerStartDateField::InternalizeL( MESMRCalEntry& aEntry )
   112     {
   112     {
   113     FUNC_LOG;
   113     FUNC_LOG;
   114 
   114 
   115     CCalEntry& entry = aEntry.Entry();    
   115     CCalEntry& entry = aEntry.Entry();
   116     iStartTime = entry.StartTimeL().TimeLocalL();
   116     iStartTime = entry.StartTimeL().TimeLocalL();
   117 
   117 
   118     FormatDateStringL();
   118     FormatDateStringL();
   119     }
   119     }
   120 
   120 
   123 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
   124 //
   124 //
   125 void CESMRViewerStartDateField::SizeChanged()
   125 void CESMRViewerStartDateField::SizeChanged()
   126     {
   126     {
   127     FUNC_LOG;
   127     FUNC_LOG;
   128     
   128 
   129     TRect rect = Rect();
   129     TRect rect = Rect();
   130     TAknLayoutRect rowLayoutRect =
   130     TAknLayoutRect rowLayoutRect =
   131         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   131         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   132     rect = rowLayoutRect.Rect();
   132     rect = rowLayoutRect.Rect();
   133 
   133 
   137     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   137     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   138 
   138 
   139     // Layouting lock icon
   139     // Layouting lock icon
   140     if( iLockIcon )
   140     if( iLockIcon )
   141     	{
   141     	{
   142     	TAknWindowComponentLayout iconLayout( 
   142     	TAknWindowComponentLayout iconLayout(
   143     			NMRLayoutManager::GetWindowComponentLayout( 
   143     			NMRLayoutManager::GetWindowComponentLayout(
   144     					NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
   144     					NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
   145     	AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
   145     	AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
   146     	}
   146     	}
   147         
   147 
   148     // Layouting label
   148     // Layouting label
   149     TAknLayoutText viewerLayoutText;
   149     TAknTextComponentLayout viewerLayoutText;
   150     if( iLockIcon )
   150     if( iLockIcon )
   151     	{
   151         {
   152     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
   152         viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
   153     			NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
   153                 NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
   154     	}
   154         }
   155     else
   155     else
   156     	{
   156         {
   157     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
   157         viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
   158     			NMRLayoutManager::EMRTextLayoutTextEditor );
   158                 NMRLayoutManager::EMRTextLayoutTextEditor );
   159     	}
   159         }
   160 
   160 
   161     // Layouting viewer field
   161     AknLayoutUtils::LayoutLabel( iLabel, rect, viewerLayoutText );
   162     TRect viewerRect( viewerLayoutText.TextRect() );    
   162     TRect viewerRect( iLabel->Rect() );
   163     iLabel->SetRect( viewerRect );
       
   164 
   163 
   165     // Move focus rect so that it's relative to field's position.
   164     // Move focus rect so that it's relative to field's position.
   166     viewerRect.Move( -Position() );
   165     viewerRect.Move( -Position() );
   167     SetFocusRect( viewerRect );
   166     SetFocusRect( viewerRect );
   168 
       
   169     // Setting font also for the label
       
   170     iLabel->SetFont( viewerLayoutText.Font() );
       
   171     }
   167     }
   172 
   168 
   173 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   174 // CESMRViewerStartDateField::CountComponentControls()
   170 // CESMRViewerStartDateField::CountComponentControls()
   175 // ---------------------------------------------------------------------------
   171 // ---------------------------------------------------------------------------
   176 //
   172 //
   177 TInt CESMRViewerStartDateField::CountComponentControls() const
   173 TInt CESMRViewerStartDateField::CountComponentControls() const
   178     {
   174     {
   179     FUNC_LOG;
   175     FUNC_LOG;
   180     
   176 
   181     TInt count( KComponentCount );
   177     TInt count( KComponentCount );
   182     if( iLockIcon )
   178     if( iLockIcon )
   183     	{
   179     	{
   184     	++count;
   180     	++count;
   185     	}
   181     	}
   191 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   192 //
   188 //
   193 CCoeControl* CESMRViewerStartDateField::ComponentControl( TInt aIndex ) const
   189 CCoeControl* CESMRViewerStartDateField::ComponentControl( TInt aIndex ) const
   194     {
   190     {
   195     FUNC_LOG;
   191     FUNC_LOG;
   196     
   192 
   197     switch ( aIndex )
   193     switch ( aIndex )
   198         {
   194         {
   199         case 0:
   195         case 0:
   200             return iIcon;
   196             return iIcon;
   201         case 1:
   197         case 1:
   212 // ---------------------------------------------------------------------------
   208 // ---------------------------------------------------------------------------
   213 //
   209 //
   214 void CESMRViewerStartDateField::SetOutlineFocusL( TBool aFocus )
   210 void CESMRViewerStartDateField::SetOutlineFocusL( TBool aFocus )
   215     {
   211     {
   216     FUNC_LOG;
   212     FUNC_LOG;
   217     
   213 
   218     CESMRField::SetOutlineFocusL ( aFocus );
   214     CESMRField::SetOutlineFocusL ( aFocus );
   219     iLabel->SetFocus( aFocus );
   215     iLabel->SetFocus( aFocus );
   220     }
   216     }
   221 
   217 
   222 // ---------------------------------------------------------------------------
   218 // ---------------------------------------------------------------------------
   224 // ---------------------------------------------------------------------------
   220 // ---------------------------------------------------------------------------
   225 //
   221 //
   226 TBool CESMRViewerStartDateField::ExecuteGenericCommandL( TInt aCommand )
   222 TBool CESMRViewerStartDateField::ExecuteGenericCommandL( TInt aCommand )
   227     {
   223     {
   228     FUNC_LOG;
   224     FUNC_LOG;
   229     
   225 
   230     TBool retValue( EFalse );
   226     TBool retValue( EFalse );
   231     
   227 
   232     if( (aCommand == EAknCmdOpen) && IsLocked()  )
   228     if( (aCommand == EAknCmdOpen) && IsLocked()  )
   233     	{
   229     	{
   234 		HandleTactileFeedbackL();
   230 		HandleTactileFeedbackL();
   235 		
   231 
   236     	CESMRGlobalNote::ExecuteL(
   232     	CESMRGlobalNote::ExecuteL(
   237     			CESMRGlobalNote::EESMRUnableToEdit );
   233     			CESMRGlobalNote::EESMRUnableToEdit );
   238     	retValue = ETrue;
   234     	retValue = ETrue;
   239     	}
   235     	}
   240     
   236 
   241     if ( EMRCmdDoEnvironmentChange == aCommand )
   237     if ( EMRCmdDoEnvironmentChange == aCommand )
   242         {
   238         {
   243         FormatDateStringL();
   239         FormatDateStringL();
   244         retValue = ETrue;
   240         retValue = ETrue;
   245         }
   241         }
   246     
   242 
   247     return retValue;
   243     return retValue;
   248     }
   244     }
   249 
   245 
   250 // ---------------------------------------------------------------------------
   246 // ---------------------------------------------------------------------------
   251 // CESMRViewerStartDateField::LockL()
   247 // CESMRViewerStartDateField::LockL()
   256 	FUNC_LOG;
   252 	FUNC_LOG;
   257 	if( IsLocked() )
   253 	if( IsLocked() )
   258 		{
   254 		{
   259 		return;
   255 		return;
   260 		}
   256 		}
   261 	
   257 
   262 	CESMRField::LockL();
   258 	CESMRField::LockL();
   263 	
   259 
   264 	delete iLockIcon;
   260 	delete iLockIcon;
   265 	iLockIcon = NULL;
   261 	iLockIcon = NULL;
   266 	iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue );
   262 	iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue );
   267 	iLockIcon->SetParent( this );
   263 	iLockIcon->SetParent( this );
   268 	}
   264 	}
   272 // ---------------------------------------------------------------------------
   268 // ---------------------------------------------------------------------------
   273 //
   269 //
   274 void CESMRViewerStartDateField::FormatDateStringL()
   270 void CESMRViewerStartDateField::FormatDateStringL()
   275     {
   271     {
   276     FUNC_LOG;
   272     FUNC_LOG;
   277     
   273 
   278     // Read format string from AVKON resource
   274     // Read format string from AVKON resource
   279     HBufC* dateFormatString = 
   275     HBufC* dateFormatString =
   280             iEikonEnv->AllocReadResourceLC(
   276             iEikonEnv->AllocReadResourceLC(
   281                     R_QTN_DATE_USUAL_WITH_ZERO);
   277                     R_QTN_DATE_USUAL_WITH_ZERO);
   282     
   278 
   283     TBuf<KMaxTimeBuffer> buf;
   279     TBuf<KMaxTimeBuffer> buf;
   284     iStartTime.FormatL(buf, *dateFormatString);
   280     iStartTime.FormatL(buf, *dateFormatString);
   285 
   281 
   286     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buf );
   282     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buf );
   287     iLabel->SetTextL( buf );
   283     iLabel->SetTextL( buf );
   288     CleanupStack::PopAndDestroy( dateFormatString );    
   284     CleanupStack::PopAndDestroy( dateFormatString );
   289     }
   285     }
   290 
   286 
   291 // EOF
   287 // EOF