phonebookui/Phonebook2/UIControls/src/CPbk2ContactEditorUIFieldBase.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Phonebook 2 contact editor dialog UI base field.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "CPbk2ContactEditorUIFieldBase.h"
       
    19 #include "MPbk2ContactEditorUiBuilder.h"
       
    20 #include "MPbk2UIField.h"
       
    21 #include <CPbk2IconFactory.h>
       
    22 #include <TPbk2IconId.h>
       
    23 #include <Pbk2UIControls.hrh>
       
    24 
       
    25 
       
    26 
       
    27 // System includes
       
    28 #include <eikedwin.h>
       
    29 #include <eikcapc.h>
       
    30 #include <aknnotewrappers.h>
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CPbk2ContactEditorUIFieldBase::CPbk2ContactEditorUIFieldBase
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C CPbk2ContactEditorUIFieldBase::CPbk2ContactEditorUIFieldBase
       
    37         ( MPbk2UIField* aField,
       
    38           MPbk2ContactEditorUiBuilder& aUiBuilder,
       
    39           CPbk2IconInfoContainer& aIconInfoContainer,
       
    40 		    TInt aCustomPosition ) :
       
    41             iField(aField),
       
    42             iUiBuilder( aUiBuilder ),
       
    43             iIconInfoContainer( aIconInfoContainer ),
       
    44             iCustomPosition( aCustomPosition )
       
    45     {
       
    46     }
       
    47     
       
    48 // -----------------------------------------------------------------------------
       
    49 // CPbk2ContactEditorUIFieldBase::~CPbk2ContactEditorUIFieldBase
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CPbk2ContactEditorUIFieldBase::~CPbk2ContactEditorUIFieldBase()
       
    53     {
       
    54     iLebel.Close();
       
    55     iText.Close();
       
    56     delete iField;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CPbk2ContactEditorUIFieldBase::ControlId
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C TInt CPbk2ContactEditorUIFieldBase::ControlId()
       
    64     {
       
    65     return ( TInt ) this;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CPbk2ContactEditorUIFieldBase::UIField
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 EXPORT_C MPbk2UIField* CPbk2ContactEditorUIFieldBase::UIField() const
       
    73     {
       
    74     return iField;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CPbk2ContactEditorUIFieldBase::HandleCustomFieldCommandL
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C TBool CPbk2ContactEditorUIFieldBase::HandleCustomFieldCommandL(TInt /*aCommand*/ )
       
    82     {
       
    83     return EFalse;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CPbk2ContactEditorUIFieldBase::FieldLabel
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 EXPORT_C const TDesC& CPbk2ContactEditorUIFieldBase::FieldLabel() const
       
    91     {
       
    92     return iLebel;
       
    93     }
       
    94   
       
    95 // -----------------------------------------------------------------------------
       
    96 // CPbk2ContactEditorUIFieldBase::SetFieldLabelL
       
    97 // -----------------------------------------------------------------------------
       
    98 //  
       
    99 EXPORT_C void CPbk2ContactEditorUIFieldBase::SetFieldLabelL( const TDesC& aLabel )
       
   100     {
       
   101     iUiBuilder.SetCurrentLineCaptionL( aLabel );
       
   102     iLebel.Close();
       
   103     iLebel.Create(aLabel.Length());
       
   104     iLebel = aLabel;
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CPbk2ContactEditorUIFieldBase::ControlTextL
       
   109 // -----------------------------------------------------------------------------
       
   110 //  
       
   111 EXPORT_C const TDesC& CPbk2ContactEditorUIFieldBase::ControlText() const
       
   112     {
       
   113     return iText;
       
   114     }
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CPbk2ContactEditorUIFieldBase::SetFocus
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C void CPbk2ContactEditorUIFieldBase::SetFocus()
       
   122     {
       
   123     // It's not fatal if focusing fails
       
   124     TRAP_IGNORE( iUiBuilder.TryChangeFocusL( ControlId() ) );
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CPbk2ContactEditorUIFieldBase::ConsumesKeyEvent
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 EXPORT_C TBool CPbk2ContactEditorUIFieldBase::ConsumesKeyEvent
       
   132         ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   133     {
       
   134     TBool ret(EFalse);
       
   135     
       
   136     if( aKeyEvent.iScanCode == EStdKeyDevice3 )
       
   137     	{
       
   138 		if( aType == EEventKeyDown )
       
   139 			{
       
   140 			iStdKeyDevice3Down = ETrue;
       
   141 			ret = ETrue;
       
   142 			}
       
   143 		else if ( aType == EEventKeyUp )
       
   144 			{
       
   145 			if ( iStdKeyDevice3Down == (TInt)ETrue )
       
   146 				{
       
   147 				ret = HandleCustomFieldCommandL( EPbk2CmdEditorHandleCustomSelect );
       
   148 				}
       
   149 			iStdKeyDevice3Down = EFalse;
       
   150 			}
       
   151     	}
       
   152 	return ret;
       
   153     }   
       
   154 
       
   155 // --------------------------------------------------------------------------
       
   156 // CPbk2ContactEditorUIFieldBase::LoadBitmapToFieldL
       
   157 // --------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C void CPbk2ContactEditorUIFieldBase::LoadBitmapToFieldL
       
   160         ( const TPbk2IconId& aIconId )
       
   161     {
       
   162     CPbk2IconFactory* factory = CPbk2IconFactory::NewLC( iIconInfoContainer );
       
   163     CEikImage* image = factory->CreateImageLC( aIconId );
       
   164     
       
   165     if ( image )
       
   166         {
       
   167         image->SetPictureOwnedExternally( EFalse );
       
   168         image->CopyControlContextFrom( iUiBuilder.LineControl( ControlId() ) );
       
   169         image->SetContainerWindowL( *(iUiBuilder.LineControl( ControlId() )) );
       
   170         image->SetNonFocusing();
       
   171         image->SetBrushStyle( CGraphicsContext::ENullBrush );
       
   172 
       
   173         delete iUiBuilder.LineControl( ControlId() )->iBitmap;
       
   174         iUiBuilder.LineControl( ControlId() )->iBitmap = image;
       
   175         CleanupStack::Pop( image );
       
   176 
       
   177         TRect rect = iUiBuilder.LineControl( ControlId() )->Rect();
       
   178         rect.Resize( -1, -1 );
       
   179         iUiBuilder.LineControl( ControlId() )->SetRect( rect );
       
   180         rect.Resize( 1, 1 );
       
   181         iUiBuilder.LineControl( ControlId() )->SetRect( rect );
       
   182         }
       
   183 
       
   184     CleanupStack::PopAndDestroy( factory );
       
   185     }
       
   186 
       
   187 // End of File