|
1 /* |
|
2 * Copyright (c) 2002-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 email field. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2ContactEditorEmailField.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include <MPbk2FieldProperty.h> |
|
23 #include "MPbk2ContactEditorUiBuilder.h" |
|
24 #include <CPbk2PresentationContactField.h> |
|
25 #include <Pbk2PresentationUtils.h> |
|
26 |
|
27 // Virtual Phonebook |
|
28 #include <MVPbkContactFieldTextData.h> |
|
29 |
|
30 // System includes |
|
31 #include <eikcapc.h> |
|
32 #include <eikedwin.h> |
|
33 #include <AknUtils.h> |
|
34 |
|
35 // -------------------------------------------------------------------------- |
|
36 // CPbk2ContactEditorEmailField::CPbk2ContactEditorEmailField |
|
37 // -------------------------------------------------------------------------- |
|
38 // |
|
39 inline CPbk2ContactEditorEmailField::CPbk2ContactEditorEmailField |
|
40 ( CPbk2PresentationContactField& aContactField, |
|
41 MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
42 CPbk2IconInfoContainer& aIconInfoContainer ) : |
|
43 CPbk2ContactEditorTextField( aContactField, aUiBuilder, |
|
44 aIconInfoContainer ) |
|
45 { |
|
46 } |
|
47 |
|
48 // -------------------------------------------------------------------------- |
|
49 // CPbk2ContactEditorEmailField::~CPbk2ContactEditorEmailField |
|
50 // -------------------------------------------------------------------------- |
|
51 // |
|
52 CPbk2ContactEditorEmailField::~CPbk2ContactEditorEmailField() |
|
53 { |
|
54 } |
|
55 |
|
56 // -------------------------------------------------------------------------- |
|
57 // CPbk2ContactEditorEmailField::NewLC |
|
58 // -------------------------------------------------------------------------- |
|
59 // |
|
60 CPbk2ContactEditorEmailField* CPbk2ContactEditorEmailField::NewLC |
|
61 ( CPbk2PresentationContactField& aContactField, |
|
62 MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
63 CPbk2IconInfoContainer& aIconInfoContainer ) |
|
64 { |
|
65 CPbk2ContactEditorEmailField* self = |
|
66 new ( ELeave ) CPbk2ContactEditorEmailField( aContactField, |
|
67 aUiBuilder, aIconInfoContainer ); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // -------------------------------------------------------------------------- |
|
74 // CPbk2ContactEditorEmailField::ConstructL |
|
75 // -------------------------------------------------------------------------- |
|
76 // |
|
77 inline void CPbk2ContactEditorEmailField::ConstructL() |
|
78 { |
|
79 // Create and insert a line in the dialog |
|
80 iControl = static_cast<CEikEdwin*>(iUiBuilder.CreateLineL( |
|
81 FieldLabel(), ControlId(), EEikCtEdwin)); |
|
82 |
|
83 // Control is now owned by the dialog |
|
84 TInt maxFieldLength = iContactField.MaxDataLength(); |
|
85 AknEditUtils::ConstructEditingL(iControl, maxFieldLength, |
|
86 maxFieldLength, EAknEditorTextCase | EAknEditorCharactersUpperCase |
|
87 | EAknEditorCharactersLowerCase, EAknEditorAlignLeft, |
|
88 ETrue, ETrue, EFalse); |
|
89 |
|
90 // Get text |
|
91 TPtrC dataPtr(MVPbkContactFieldTextData::Cast( |
|
92 iContactField.FieldData()).Text()); |
|
93 HBufC* textBuf = HBufC::NewLC(dataPtr.Length()); |
|
94 TPtr text = textBuf->Des(); |
|
95 text.Zero(); |
|
96 Pbk2PresentationUtils::AppendWithNewlineTranslationL(text, dataPtr); |
|
97 |
|
98 // T9 should be deactivated in all contact editors always |
|
99 DeactivateT9(iContactField.FieldProperty().EditMode()); |
|
100 |
|
101 if (iContactField.FieldProperty().EditMode() == |
|
102 EPbk2FieldEditModeLatinOnly) |
|
103 { |
|
104 iControl->SetAknEditorSpecialCharacterTable( |
|
105 R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG ); |
|
106 } |
|
107 else |
|
108 { |
|
109 // If not in 'only latin mode', convert digits to |
|
110 // foreign characters if necessary |
|
111 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(text); |
|
112 } |
|
113 |
|
114 switch (iContactField.FieldProperty().DefaultCase()) |
|
115 { |
|
116 case EPbk2FieldDefaultCaseLower: |
|
117 { |
|
118 iControl->SetAknEditorCase(EAknEditorLowerCase); |
|
119 break; |
|
120 } |
|
121 case EPbk2FieldDefaultCaseText: |
|
122 { |
|
123 iControl->SetAknEditorCase(EAknEditorTextCase); |
|
124 break; |
|
125 } |
|
126 default: |
|
127 { |
|
128 // Do nothing |
|
129 break; |
|
130 } |
|
131 } |
|
132 |
|
133 // Set formatted text to editor control |
|
134 iControl->SetTextL(&text); |
|
135 // SetTextL method above copied the text to the control, |
|
136 // so it is safe to destroy the buffer |
|
137 CleanupStack::PopAndDestroy(textBuf); |
|
138 |
|
139 iUiBuilder.LoadBitmapToFieldL |
|
140 ( iContactField.FieldProperty(), iIconInfoContainer, ControlId() ); |
|
141 |
|
142 // Place cursor to the end of the line |
|
143 iControl->AddFlagToUserFlags(CEikEdwin::EJustAutoCurEnd); |
|
144 |
|
145 // CreateTextViewL() is flagged as deprecated but if it is not |
|
146 // called here the ActivateL() below crashes sometimes. |
|
147 iControl->CreateTextViewL(); |
|
148 iCaptionedCtrl = iUiBuilder.LineControl(ControlId()); |
|
149 iCaptionedCtrl->SetTakesEnterKey(EFalse); |
|
150 } |
|
151 |
|
152 // End of File |