meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrpriorityfield.cpp
branchRCL_3
changeset 33 da5135c61bad
parent 0 8466d47a6819
child 17 8592a65ad3fb
equal deleted inserted replaced
32:a3a1ae9acec6 33:da5135c61bad
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  ESMR priority field implementation
    14 * Description:  ESMR priority field implementation
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 #include "emailtrace.h"
       
    19 #include "cesmrpriorityfield.h"
    18 #include "cesmrpriorityfield.h"
    20 
    19 
    21 #include "cesmrlistquery.h"
    20 #include "cesmrlistquery.h"
       
    21 #include "nmrcolormanager.h"
       
    22 #include "cmrimage.h"
       
    23 #include "cmrlabel.h"
       
    24 #include "nmrlayoutmanager.h"
       
    25 #include "nmrbitmapmanager.h"
    22 #include "mesmrtitlepaneobserver.h"
    26 #include "mesmrtitlepaneobserver.h"
    23 
    27 
    24 //<cmail>
       
    25 #include "mesmrcalentry.h"
       
    26 //</cmail>
       
    27 #include <calentry.h>
    28 #include <calentry.h>
    28 #include <esmrgui.rsg>
    29 #include <esmrgui.rsg>
    29 #include <StringLoader.h>
    30 #include <stringloader.h>
    30 #include <barsread.h>
    31 #include <barsread.h>
    31 #include <eiklabel.h>
    32 #include <eiklabel.h>
    32 #include <avkon.hrh>
    33 #include <avkon.hrh>
    33 #include <AknsConstants.h>
    34 #include <aknsconstants.h>
    34 #include <AknUtils.h>
    35 #include <aknutils.h>
       
    36 
       
    37 #include "emailtrace.h"
    35 
    38 
    36 // ======== MEMBER FUNCTIONS ========
    39 // ======== MEMBER FUNCTIONS ========
    37 
    40 
    38 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
       
    42 // CESMRPriorityField::CESMRPriorityField
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CESMRPriorityField::CESMRPriorityField()
       
    46     {
       
    47     FUNC_LOG;
       
    48     SetFieldId( EESMRFieldPriority );
       
    49     SetFocusType( EESMRHighlightFocus );
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CESMRPriorityField::~CESMRPriorityField
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CESMRPriorityField::~CESMRPriorityField()
       
    57     {
       
    58     FUNC_LOG;
       
    59     iArray.ResetAndDestroy();
       
    60     iArray.Close();
       
    61     
       
    62     delete iIcon;    
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
    39 // CESMRPriorityField::NewL
    66 // CESMRPriorityField::NewL
    40 // ---------------------------------------------------------------------------
    67 // ---------------------------------------------------------------------------
    41 //
    68 //
    42 CESMRPriorityField* CESMRPriorityField::NewL( )
    69 CESMRPriorityField* CESMRPriorityField::NewL()
    43     {
    70     {
    44     FUNC_LOG;
    71     FUNC_LOG;
    45     CESMRPriorityField* self = new (ELeave) CESMRPriorityField;
    72     CESMRPriorityField* self = new (ELeave) CESMRPriorityField;
    46     CleanupStack::PushL ( self );
    73     CleanupStack::PushL ( self );
    47     self->ConstructL ( );
    74     self->ConstructL ( );
    48     CleanupStack::Pop ( self );
    75     CleanupStack::Pop ( self );
    49     return self;
    76     return self;
    50     }
    77     }
    51 
    78 
    52 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    53 // CESMRPriorityField::~CESMRPriorityField
    80 // CESMRPriorityField::ConstructL
    54 // ---------------------------------------------------------------------------
    81 // ---------------------------------------------------------------------------
    55 //
    82 //
    56 CESMRPriorityField::~CESMRPriorityField( )
    83 void CESMRPriorityField::ConstructL()
    57     {
    84     {
    58     FUNC_LOG;
    85     FUNC_LOG;    
    59     iArray.ResetAndDestroy ( );
    86     iLabel = CMRLabel::NewL();
    60     iArray.Close ( );
    87     iLabel->SetParent( this );
       
    88     CESMRField::ConstructL( iLabel ); // ownership transfered
       
    89 
       
    90     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapPriorityNormal );
       
    91     iIcon->SetParent( this );
    61     }
    92     }
    62 
    93 
    63 // ---------------------------------------------------------------------------
    94 // ---------------------------------------------------------------------------
    64 // CESMRPriorityField::InitializeL
    95 // CESMRPriorityField::InitializeL
    65 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
    66 //
    97 //
    67 void CESMRPriorityField::InitializeL()
    98 void CESMRPriorityField::InitializeL()
    68     {
    99     {
    69     FUNC_LOG;
   100     FUNC_LOG;
    70     iPriority->SetFont( iLayout->Font( iCoeEnv, iFieldId ) );
   101     NMRColorManager::SetColor( *iLabel, 
    71     iPriority->SetLabelAlignment( CESMRLayoutManager::IsMirrored()
   102                                NMRColorManager::EMRMainAreaTextColor );
    72                                   ? ELayoutAlignRight : ELayoutAlignLeft );
       
    73 
       
    74     AknLayoutUtils::OverrideControlColorL(*iPriority,
       
    75                                           EColorLabelText,
       
    76                                           iLayout->GeneralListAreaTextColor() );
       
    77     }
   103     }
    78 
   104 
    79 // ---------------------------------------------------------------------------
   105 // ---------------------------------------------------------------------------
    80 // CESMRPriorityField::InternalizeL
   106 // CESMRPriorityField::InternalizeL
    81 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
   145 //
   171 //
   146 void CESMRPriorityField::SetOutlineFocusL( TBool aFocus )
   172 void CESMRPriorityField::SetOutlineFocusL( TBool aFocus )
   147     {
   173     {
   148     FUNC_LOG;
   174     FUNC_LOG;
   149     CESMRField::SetOutlineFocusL ( aFocus );
   175     CESMRField::SetOutlineFocusL ( aFocus );    
       
   176     iLabel->SetFocus( aFocus );
   150 
   177 
   151     //Focus gained
   178     //Focus gained
   152     if ( aFocus )
   179     if ( aFocus )
   153         {
   180         {
   154         ChangeMiddleSoftKeyL(EESMRCmdOpenPriorityQuery, R_QTN_MSK_OPEN);
   181         ChangeMiddleSoftKeyL(EESMRCmdOpenPriorityQuery, R_QTN_MSK_OPEN);
   155         }
   182         }
   156     }
   183     }
   157 
   184 
   158 // ---------------------------------------------------------------------------
   185 // ---------------------------------------------------------------------------
       
   186 // CESMRPriorityField::SizeChanged()
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void CESMRPriorityField::SizeChanged()
       
   190     {
       
   191     FUNC_LOG;
       
   192     TRect rect = Rect();
       
   193     TAknLayoutRect rowLayoutRect =
       
   194         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
       
   195     rect = rowLayoutRect.Rect();
       
   196     
       
   197     TAknWindowComponentLayout iconLayout =
       
   198         NMRLayoutManager::GetWindowComponentLayout( 
       
   199                 NMRLayoutManager::EMRLayoutTextEditorIcon );
       
   200     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
       
   201     
       
   202     TAknLayoutRect bgLayoutRect =
       
   203         NMRLayoutManager::GetLayoutRect( 
       
   204                 rect, NMRLayoutManager::EMRLayoutTextEditorBg );
       
   205     TRect bgRect( bgLayoutRect.Rect() );
       
   206     // Move focus rect so that it's relative to field's position.
       
   207     bgRect.Move( -Position() );
       
   208     SetFocusRect( bgRect );
       
   209     
       
   210     TAknLayoutText labelLayout = 
       
   211         NMRLayoutManager::GetLayoutText( 
       
   212                 rect, NMRLayoutManager::EMRTextLayoutTextEditor );
       
   213     iLabel->SetRect( labelLayout.TextRect() );
       
   214     }
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // CESMRPriorityField::CountComponentControls()
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 TInt CESMRPriorityField::CountComponentControls() const
       
   221     {
       
   222     FUNC_LOG;
       
   223     TInt count( 0 );
       
   224     if ( iIcon )
       
   225         {
       
   226         ++count;
       
   227         }
       
   228 
       
   229     if ( iLabel )
       
   230         {
       
   231         ++count;
       
   232         }
       
   233     return count;
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // CESMRPriorityField::ComponentControl()
       
   238 // ---------------------------------------------------------------------------
       
   239 //
       
   240 CCoeControl* CESMRPriorityField::ComponentControl( TInt aIndex ) const
       
   241     {
       
   242     FUNC_LOG;
       
   243     switch ( aIndex )
       
   244         {
       
   245         case 0:
       
   246             return iIcon;
       
   247         case 1:
       
   248             return iLabel;
       
   249         default:
       
   250             return NULL;
       
   251         }
       
   252     }
       
   253 
       
   254 
       
   255 
       
   256 // ---------------------------------------------------------------------------
   159 // CESMRPriorityField::ExecuteGenericCommandL()
   257 // CESMRPriorityField::ExecuteGenericCommandL()
   160 // ---------------------------------------------------------------------------
   258 // ---------------------------------------------------------------------------
   161 //
   259 //
   162 void CESMRPriorityField::ExecuteGenericCommandL( TInt aCommand )
   260 TBool CESMRPriorityField::ExecuteGenericCommandL( TInt aCommand )
   163     {
   261     {
   164     FUNC_LOG;
   262     FUNC_LOG;
       
   263     TBool isUsed( EFalse );
   165     if( aCommand == EESMRCmdOpenPriorityQuery ||
   264     if( aCommand == EESMRCmdOpenPriorityQuery ||
   166         aCommand == EAknCmdOpen )
   265         aCommand == EAknCmdOpen )
   167         {
   266         {
   168         ExecutePriorityQueryL();
   267         ExecutePriorityQueryL();
   169         }
   268         isUsed = ETrue;
       
   269         
       
   270         HandleTactileFeedbackL();
       
   271         }
       
   272     return isUsed;
   170     }
   273     }
   171 
   274 
   172 // ---------------------------------------------------------------------------
   275 // ---------------------------------------------------------------------------
   173 // CESMRPriorityField::ExecutePriorityQueryL
   276 // CESMRPriorityField::ExecutePriorityQueryL
   174 // ---------------------------------------------------------------------------
   277 // ---------------------------------------------------------------------------
   267         }
   370         }
   268     return response;
   371     return response;
   269     }
   372     }
   270 
   373 
   271 // ---------------------------------------------------------------------------
   374 // ---------------------------------------------------------------------------
   272 // CESMRPriorityField::CESMRPriorityField
       
   273 // ---------------------------------------------------------------------------
       
   274 //
       
   275 CESMRPriorityField::CESMRPriorityField( )
       
   276     {
       
   277     FUNC_LOG;
       
   278     //do nothing
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // CESMRPriorityField::ConstructL
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 void CESMRPriorityField::ConstructL( )
       
   286     {
       
   287     FUNC_LOG;
       
   288     SetFieldId ( EESMRFieldPriority );
       
   289     iPriority = new( ELeave ) CEikLabel();
       
   290     _LIT(KEmptyText, "");
       
   291     iPriority->SetTextL( KEmptyText );
       
   292 
       
   293     // ownership transferred
       
   294     CESMRIconField::ConstructL (KAknsIIDQgnFsIndiPriorityNormal, iPriority );
       
   295     }
       
   296 
       
   297 // ---------------------------------------------------------------------------
       
   298 // CESMRPriorityField::UpdateTextL
   375 // CESMRPriorityField::UpdateTextL
   299 // ---------------------------------------------------------------------------
   376 // ---------------------------------------------------------------------------
   300 //
   377 //
   301 void CESMRPriorityField::UpdateTextL( TInt aIndex )
   378 void CESMRPriorityField::UpdateTextL( TInt aIndex )
   302     {
   379     {
   303     FUNC_LOG;
   380     FUNC_LOG;
   304     CESMRPriority* priority = iArray[ aIndex ];
   381     CESMRPriority* priority = iArray[ aIndex ];
   305     iPriority->SetTextL ( priority->Text ( ) );
   382     iLabel->SetTextL ( priority->Text ( ) );
   306 
   383 
   307     TAknsItemID iconID = { 0 , 0 };
   384     NMRBitmapManager::TMRBitmapId bitmapId( 
       
   385             NMRBitmapManager::EMRBitmapPriorityNormal );
   308 
   386 
   309     switch ( priority->Id() )
   387     switch ( priority->Id() )
   310         {
   388         {
   311         case EFSCalenMRPriorityLow:
   389         case EFSCalenMRPriorityLow:
   312         case EFSCalenTodoPriorityLow:
   390         case EFSCalenTodoPriorityLow:
   313             {
   391             {
   314             iconID = KAknsIIDQgnFsIndiPriorityLow;
   392             bitmapId = NMRBitmapManager::EMRBitmapPriorityLow;
   315             break;
   393             break;
   316             }
   394             }
   317         case EFSCalenMRPriorityUnknown:
   395         case EFSCalenMRPriorityUnknown:
   318         case EFSCalenMRPriorityNormal:
   396         case EFSCalenMRPriorityNormal:
   319         case EFSCalenTodoPriorityNormal:
   397         case EFSCalenTodoPriorityNormal:
   320             {
   398             {
   321             iconID = KAknsIIDQgnFsIndiPriorityNormal;
   399             bitmapId = NMRBitmapManager::EMRBitmapPriorityNormal;
   322             break;
   400             break;
   323             }
   401             }
   324         case EFSCalenMRPriorityHigh: // same value as EFSCalenTodoPriorityHigh
   402         case EFSCalenMRPriorityHigh: // same value as EFSCalenTodoPriorityHigh
   325             {
   403             {
   326             iconID = KAknsIIDQgnFsIndiPriorityHigh;
   404             bitmapId = NMRBitmapManager::EMRBitmapPriorityHigh;
   327             break;
   405             break;
   328             }
   406             }
   329         default:
   407         default:
   330         	ASSERT(EFalse);
   408         	ASSERT(EFalse);
   331         	break;
   409         	break;
   332         }
   410         }
   333     IconL( iconID );
   411     
   334     DrawDeferred ( );
   412     delete iIcon;
   335 
   413     iIcon = NULL;
   336     // update titlepane priority icon
   414     iIcon = CMRImage::NewL( bitmapId );
   337     if ( iObserver )
   415     iIcon->SetParent( this );
   338         {
   416 
   339         iObserver->UpdateTitlePanePriorityIconL( priority->Id() );
   417     // This needs to be called so icon will be redrawn
   340         }
   418     SizeChanged();
   341 
   419     DrawDeferred();
   342     // this is needed to call in order to get new
       
   343     // icon drawn
       
   344     CESMRIconField::SizeChanged();
       
   345     }
       
   346 
       
   347 
       
   348 // ---------------------------------------------------------------------------
       
   349 // CESMRPriorityField::UpdateTextL
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 void CESMRPriorityField::SetTitlePaneObserver( MESMRTitlePaneObserver* aObserver )
       
   353     {
       
   354     iObserver = aObserver;
       
   355     }
   420     }
   356 
   421 
   357 // EOF
   422 // EOF
   358 
   423