phonebookui/Phonebook2/UIControls/src/CPbk2ContactEditorUIAddressHomeField.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
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 address home field.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "CPbk2ContactEditorUIAddressHomeField.h"
       
    19 
       
    20 // Phonebook 2
       
    21 #include <MPbk2ContactEditorUiBuilder.h>
       
    22 #include "MPbk2ContactEditorFieldVisitor.h"
       
    23 #include "MPbk2ContactEditorUiBuilderExtension.h"
       
    24 #include "CPbk2IconInfoContainer.h"
       
    25 #include <Pbk2CommonUi.rsg>
       
    26 #include "MPbk2UIField.h"
       
    27 #include "Pbk2EditorLineIds.hrh" 
       
    28 #include <Pbk2UIControls.hrh>
       
    29 #include "CPbk2ContactEditorReadonlyField.h"
       
    30 #include <Pbk2UIControls.rsg>
       
    31 // System includes
       
    32 #include <eikcapc.h>
       
    33 #include <eikedwin.h>
       
    34 #include <AknUtils.h>
       
    35 
       
    36 // --------------------------------------------------------------------------
       
    37 // CPbk2ContactEditorUIAddressHomeField::CPbk2ContactEditorUIAddressHomeField
       
    38 // --------------------------------------------------------------------------
       
    39 //
       
    40 CPbk2ContactEditorUIAddressHomeField::CPbk2ContactEditorUIAddressHomeField
       
    41         ( MPbk2UIField* aField,
       
    42 	      MPbk2ContactEditorUiBuilder& aUiBuilder,
       
    43 	      CPbk2IconInfoContainer& aIconInfoContainer,
       
    44 	      TInt aCustomPosition ) :
       
    45             CPbk2ContactEditorUIFieldBase( aField, aUiBuilder,
       
    46                 aIconInfoContainer, aCustomPosition )
       
    47     {
       
    48     }
       
    49 
       
    50 // --------------------------------------------------------------------------
       
    51 // CPbk2ContactEditorUIAddressHomeField::~CPbk2ContactEditorUIAddressHomeField
       
    52 // --------------------------------------------------------------------------
       
    53 //
       
    54 CPbk2ContactEditorUIAddressHomeField::~CPbk2ContactEditorUIAddressHomeField()
       
    55     { 
       
    56     
       
    57     }
       
    58 
       
    59 // --------------------------------------------------------------------------
       
    60 // CPbk2ContactEditorUIAddressHomeField::NewLC
       
    61 // --------------------------------------------------------------------------
       
    62 //
       
    63 CPbk2ContactEditorUIAddressHomeField* CPbk2ContactEditorUIAddressHomeField::NewL
       
    64         ( MPbk2UIField* aField,
       
    65       	  MPbk2ContactEditorUiBuilder& aUiBuilder,
       
    66       	  CPbk2IconInfoContainer& aIconInfoContainer,
       
    67 	      TInt aCustomPosition,
       
    68           const TDesC& aCustomText )
       
    69     {
       
    70     CPbk2ContactEditorUIAddressHomeField* self = 
       
    71         new ( ELeave ) CPbk2ContactEditorUIAddressHomeField( aField,
       
    72             aUiBuilder, aIconInfoContainer, aCustomPosition );
       
    73     CleanupStack::PushL( self );
       
    74     self->ConstructL(aCustomText);
       
    75     CleanupStack::Pop( self );
       
    76     return self;
       
    77     }
       
    78 
       
    79 // --------------------------------------------------------------------------
       
    80 // CPbk2ContactEditorUIAddressHomeField::ConstructL
       
    81 // --------------------------------------------------------------------------
       
    82 //
       
    83 void CPbk2ContactEditorUIAddressHomeField::ConstructL(const TDesC& aCustomText)
       
    84     {
       
    85     User::LeaveIfNull(iField);
       
    86     MPbk2ContactEditorUiBuilderExtension* ext = 
       
    87 	    static_cast<MPbk2ContactEditorUiBuilderExtension*>(
       
    88 	        iUiBuilder.ContactEditorUiBuilderExtension(KNullUid));
       
    89 	
       
    90 	iControl = static_cast<CPbk2ContactEditorReadonlyField*>(
       
    91 	ext->AddCustomFieldToFormL(iCustomPosition, R_PBK2_ADDRESS_HOME_LINE));     
       
    92 	iControl->InitializeL(this);  
       
    93 	SetControlTextL(aCustomText);
       
    94 	iControl->CreateTextViewL();
       
    95 	iCaptionedCtrl = iUiBuilder.LineControl(ControlId()); 
       
    96 	iUiBuilder.TryChangeFocusL(ControlId());
       
    97 	LoadBitmapToFieldL(iField->IconId());
       
    98 	SetFieldLabelL(iField->DefaultLabel());
       
    99 	}
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // CPbk2ContactEditorUIAddressHomeField::ControlId
       
   103 // --------------------------------------------------------------------------
       
   104 //
       
   105 TInt CPbk2ContactEditorUIAddressHomeField::ControlId()
       
   106     {
       
   107      return EPbk2EditorLineAddressHome; 
       
   108     }
       
   109 
       
   110 // --------------------------------------------------------------------------
       
   111 // CPbk2ContactEditorUIAddressHomeField::Control
       
   112 // --------------------------------------------------------------------------
       
   113 //
       
   114 CEikEdwin* CPbk2ContactEditorUIAddressHomeField::Control()
       
   115     {
       
   116     return iControl;
       
   117     }
       
   118 
       
   119 // --------------------------------------------------------------------------
       
   120 // CPbk2ContactEditorUIAddressHomeField::ActivateL
       
   121 // --------------------------------------------------------------------------
       
   122 //
       
   123 void CPbk2ContactEditorUIAddressHomeField::ActivateL()
       
   124     {
       
   125     iCaptionedCtrl->ActivateL();
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CPbk2ContactEditorUIAddressHomeField::HandleCustomFieldCommandL
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 TBool CPbk2ContactEditorUIAddressHomeField::HandleCustomFieldCommandL(TInt aCommand )
       
   133     {
       
   134     TBool ret(EFalse);
       
   135     MPbk2ContactEditorUiBuilderExtension* ext = 
       
   136          static_cast<MPbk2ContactEditorUiBuilderExtension*>(
       
   137              iUiBuilder.ContactEditorUiBuilderExtension(KNullUid));        
       
   138     
       
   139     if(aCommand == EPbk2CmdEditorHandleCustomSelect)
       
   140         {
       
   141         ret = ext->HandleCustomFieldCommandL(EPbk2CmdEditorSelectAddressHome);
       
   142         }
       
   143     return ret;
       
   144     }
       
   145 
       
   146 // --------------------------------------------------------------------------
       
   147 // CPbk2ContactEditorUIAddressHomeField::SetControlTextL
       
   148 // --------------------------------------------------------------------------
       
   149 //
       
   150 void CPbk2ContactEditorUIAddressHomeField::SetControlTextL(const TDesC& aText)
       
   151     {
       
   152     iControl->SetTextL(&aText);
       
   153     }
       
   154 
       
   155 
       
   156 // End of File