meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewersyncfield.cpp
changeset 0 8466d47a6819
child 16 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Synchronisation field for viewers
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cesmrviewersyncfield.h"
       
    19 #include "nmrlayoutmanager.h"
       
    20 #include "nmrbitmapmanager.h"
       
    21 #include "cmrlabel.h"
       
    22 #include "cmrimage.h"
       
    23 #include "mesmrlistobserver.h"
       
    24 
       
    25 #include <calentry.h>
       
    26 #include <StringLoader.h>
       
    27 #include <AknLayout2ScalableDef.h>
       
    28 
       
    29 #include <esmrgui.rsg>
       
    30 // DEBUG
       
    31 #include "emailtrace.h"
       
    32 
       
    33 // ======== MEMBER FUNCTIONS ========
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // CESMRViewerSyncField::NewL()
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CESMRViewerSyncField* CESMRViewerSyncField::NewL()
       
    40     {
       
    41     FUNC_LOG;
       
    42     CESMRViewerSyncField* self = new (ELeave) CESMRViewerSyncField();
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL();
       
    45     CleanupStack::Pop( self );
       
    46     return self;
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CESMRViewerSyncField::~CESMRViewerSyncField()
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CESMRViewerSyncField::~CESMRViewerSyncField()
       
    54     {
       
    55     FUNC_LOG;
       
    56     delete iIcon;
       
    57     delete iLabel;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CESMRViewerSyncField::CESMRViewerSyncField()
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CESMRViewerSyncField::CESMRViewerSyncField()
       
    65     {
       
    66     FUNC_LOG;
       
    67     SetFieldId( EESMRFieldSync );
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CESMRViewerSyncField::ConstructL()
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CESMRViewerSyncField::ConstructL()
       
    75     {
       
    76     FUNC_LOG;
       
    77     iLabel = CMRLabel::NewL();
       
    78     iLabel->SetParent( this );
       
    79     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapSynchronization );
       
    80     iIcon->SetParent( this );
       
    81     
       
    82     SetFocusType( EESMRHighlightFocus );
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CESMRViewerSyncField::InternalizeL()
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CESMRViewerSyncField::InternalizeL( MESMRCalEntry& aEntry )
       
    90     {
       
    91     FUNC_LOG;
       
    92     CCalEntry& entry = aEntry.Entry();
       
    93     CCalEntry::TReplicationStatus rStatus = entry.ReplicationStatusL();
       
    94 
       
    95     HBufC* statusHolder = NULL;
       
    96     switch( rStatus )
       
    97         {
       
    98         case CCalEntry::ERestricted:
       
    99             {
       
   100             statusHolder = StringLoader::LoadLC( R_QTN_CALENDAR_TASK_SYNC_NONE,
       
   101                                                  iEikonEnv );
       
   102             break;
       
   103             }
       
   104         case CCalEntry::EPrivate:
       
   105             {
       
   106             statusHolder = StringLoader::LoadLC( R_QTN_CALENDAR_TASK_SYNC_PRIVATE,
       
   107                                                  iEikonEnv );
       
   108             break;
       
   109             }
       
   110         case CCalEntry::EOpen:
       
   111             {
       
   112             statusHolder = StringLoader::LoadLC( R_QTN_CALENDAR_TASK_SYNC_PUBLIC,
       
   113                                                  iEikonEnv );
       
   114             break;
       
   115             }
       
   116         default: // There is no replication status set - hide field- this should never happen
       
   117             {
       
   118             iObserver->RemoveControl( iFieldId );
       
   119             }
       
   120         }
       
   121         
       
   122     if ( statusHolder )
       
   123         {
       
   124         iLabel->SetTextL( *statusHolder );
       
   125         CleanupStack::PopAndDestroy( statusHolder );
       
   126         }
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // CESMRViewerSyncField::InitializeL()
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 void CESMRViewerSyncField::InitializeL()
       
   134     {
       
   135     FUNC_LOG;
       
   136     // Setting Font for the rich text viewer
       
   137     TAknLayoutText text = NMRLayoutManager::GetLayoutText( 
       
   138             Rect(), 
       
   139             NMRLayoutManager::EMRTextLayoutTextEditor );
       
   140     
       
   141     iLabel->SetFont( text.Font() );
       
   142         
       
   143     // This is called so theme changes will apply when changing theme "on the fly"
       
   144     if ( IsFocused() )
       
   145         {
       
   146         iLabel->FocusChanged( EDrawNow );
       
   147         }
       
   148 
       
   149     AknLayoutUtils::OverrideControlColorL( *iLabel, EColorLabelText,
       
   150                                        KRgbBlack );
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CESMRViewerSyncField::SizeChanged()
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CESMRViewerSyncField::SizeChanged()
       
   158     {
       
   159     TRect rect = Rect();
       
   160     TAknLayoutRect rowLayoutRect =
       
   161         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
       
   162     rect = rowLayoutRect.Rect();
       
   163     
       
   164     TAknWindowComponentLayout iconLayout =
       
   165         NMRLayoutManager::GetWindowComponentLayout( 
       
   166                 NMRLayoutManager::EMRLayoutTextEditorIcon );
       
   167     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
       
   168     
       
   169     TAknLayoutRect bgLayoutRect =
       
   170         NMRLayoutManager::GetLayoutRect( 
       
   171                 rect, NMRLayoutManager::EMRLayoutTextEditorBg );
       
   172     TRect bgRect( bgLayoutRect.Rect() );
       
   173     // Move focus rect so that it's relative to field's position.
       
   174     bgRect.Move( -Position() );
       
   175     SetFocusRect( bgRect );
       
   176     
       
   177     TAknLayoutText labelLayout = 
       
   178         NMRLayoutManager::GetLayoutText( 
       
   179                 rect, NMRLayoutManager::EMRTextLayoutTextEditor );
       
   180     iLabel->SetRect( labelLayout.TextRect() );
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CESMRViewerSyncField::CountComponentControls()
       
   185 // ---------------------------------------------------------------------------
       
   186 //
       
   187 TInt CESMRViewerSyncField::CountComponentControls() const
       
   188     {
       
   189     TInt count( 0 );
       
   190     if ( iIcon )
       
   191         {
       
   192         ++count;
       
   193         }
       
   194 
       
   195     if ( iLabel )
       
   196         {
       
   197         ++count;
       
   198         }
       
   199     return count;
       
   200     }
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 // CESMRViewerSyncField::ComponentControl()
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 CCoeControl* CESMRViewerSyncField::ComponentControl( TInt aIndex ) const
       
   207     {
       
   208     switch ( aIndex )
       
   209         {
       
   210         case 0:
       
   211             return iIcon;
       
   212         case 1:
       
   213             return iLabel;
       
   214         default:
       
   215             return NULL;
       
   216         }
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // CESMRViewerSyncField::SetOutlineFocusL()
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 void CESMRViewerSyncField::SetOutlineFocusL( TBool aFocus )
       
   224     {
       
   225     CESMRField::SetOutlineFocusL ( aFocus );
       
   226     
       
   227     iLabel->SetFocus( aFocus );    
       
   228 
       
   229     if ( !aFocus )
       
   230         {
       
   231         AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText,
       
   232                                                  KRgbBlack );
       
   233         }
       
   234     }
       
   235 // EOF
       
   236