63
|
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 custom field.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "CPbk2ContactEditorReadonlyField.h"
|
|
21 |
#include <AknUtils.h>
|
|
22 |
#include <AknDef.h>
|
|
23 |
#include <CPbk2AppUiBase.h>
|
|
24 |
#include <Pbk2UIControls.hrh>
|
|
25 |
#include <Pbk2Commands.hrh>
|
|
26 |
#include <MPbk2ContactEditorField2.h>
|
|
27 |
#include <MPbk2ContactEditorUIField.h>
|
|
28 |
#include <MVPbkStoreContactField.h>
|
|
29 |
#include <MVPbkContactFieldData.h>
|
|
30 |
|
|
31 |
|
|
32 |
/// Unnamed namespace for local definitions
|
|
33 |
namespace
|
|
34 |
{
|
|
35 |
|
|
36 |
enum TContactEditorPanicCodes
|
|
37 |
{
|
|
38 |
EEditorTouchFeedbackMissing
|
|
39 |
};
|
|
40 |
|
|
41 |
void Panic(TContactEditorPanicCodes aReason)
|
|
42 |
{
|
|
43 |
_LIT( KPanicText, "CPbk2_editor_ReadonlyField" );
|
|
44 |
User::Panic(KPanicText, aReason);
|
|
45 |
}
|
|
46 |
} /// namespace
|
|
47 |
|
|
48 |
|
|
49 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
50 |
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// CCPbk2ContactEditorReadonlyField::CCPbk2ContactEditorReadonlyField()
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CPbk2ContactEditorReadonlyField::CPbk2ContactEditorReadonlyField()
|
|
56 |
{
|
|
57 |
}
|
|
58 |
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
// CPbk2ContactEditorReadonlyField::~CPbk2ContactEditorReadonlyField()
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CPbk2ContactEditorReadonlyField::~CPbk2ContactEditorReadonlyField()
|
|
64 |
{
|
|
65 |
}
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// CPbk2ContactEditorReadonlyField::InitializeL
|
|
69 |
// -----------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
EXPORT_C void CPbk2ContactEditorReadonlyField::InitializeL(
|
|
72 |
MPbk2ContactEditorUIField* aPbk2ContactEditorField)
|
|
73 |
{
|
|
74 |
ActivateL();
|
|
75 |
iPbk2ContactEditorUIField = aPbk2ContactEditorField;
|
|
76 |
iTouchFeedbackRef = MTouchFeedback::Instance();
|
|
77 |
__ASSERT_ALWAYS( iTouchFeedbackRef, Panic( EEditorTouchFeedbackMissing ));
|
|
78 |
}
|
|
79 |
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
// CPbk2ContactEditorReadonlyField::InitializeL
|
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
void CPbk2ContactEditorReadonlyField::InitializeL(
|
|
85 |
MPbk2ContactEditorField* aPbk2ContactEditorField)
|
|
86 |
{
|
|
87 |
ActivateL();
|
|
88 |
iPbk2ContactEditorField = aPbk2ContactEditorField;
|
|
89 |
iTouchFeedbackRef = MTouchFeedback::Instance();
|
|
90 |
__ASSERT_ALWAYS( iTouchFeedbackRef, Panic( EEditorTouchFeedbackMissing ));
|
|
91 |
}
|
|
92 |
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
// CPbk2ContactEditorReadonlyField::OfferKeyEventL()
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
TKeyResponse CPbk2ContactEditorReadonlyField::OfferKeyEventL(
|
|
98 |
const TKeyEvent& aKeyEvent, TEventCode aType)
|
|
99 |
{
|
|
100 |
TKeyResponse exitCode = EKeyWasNotConsumed;
|
|
101 |
if (aType == EEventKey)
|
|
102 |
{
|
|
103 |
switch (aKeyEvent.iCode)
|
|
104 |
{
|
|
105 |
case EKeyOK:
|
|
106 |
//no op
|
|
107 |
break;
|
|
108 |
case EKeyEnter:
|
|
109 |
{
|
|
110 |
exitCode = EKeyWasConsumed;
|
|
111 |
if (iPbk2ContactEditorField)
|
|
112 |
{
|
|
113 |
MPbk2ContactEditorField2 * tempContactEditorField =
|
|
114 |
reinterpret_cast<MPbk2ContactEditorField2*> (
|
|
115 |
iPbk2ContactEditorField->ContactEditorFieldExtension(
|
|
116 |
KMPbk2ContactEditorFieldExtension2Uid));
|
|
117 |
|
|
118 |
tempContactEditorField->HandleCustomFieldCommandL(
|
|
119 |
EPbk2CmdEditorHandleCustomSelect);
|
|
120 |
}
|
|
121 |
else if (iPbk2ContactEditorUIField)
|
|
122 |
{
|
|
123 |
iPbk2ContactEditorUIField->HandleCustomFieldCommandL(
|
|
124 |
EPbk2CmdEditorHandleCustomSelect);
|
|
125 |
}
|
|
126 |
|
|
127 |
}
|
|
128 |
break;
|
|
129 |
|
|
130 |
case EKeyDelete:
|
|
131 |
case EKeyBackspace:
|
|
132 |
{
|
|
133 |
if (iPbk2ContactEditorField && !iPbk2ContactEditorField->ContactField().FieldData().IsEmpty() )
|
|
134 |
{
|
|
135 |
MPbk2ContactEditorField2* tempContactEditorField =
|
|
136 |
reinterpret_cast<MPbk2ContactEditorField2*> (iPbk2ContactEditorField->ContactEditorFieldExtension(
|
|
137 |
KMPbk2ContactEditorFieldExtension2Uid));
|
|
138 |
tempContactEditorField-> HandleCustomFieldCommandL(
|
|
139 |
EPbk2CmdEditorHandleCustomRemove);
|
|
140 |
exitCode = EKeyWasConsumed;
|
|
141 |
}
|
|
142 |
|
|
143 |
}
|
|
144 |
break;
|
|
145 |
|
|
146 |
default:
|
|
147 |
break;
|
|
148 |
}
|
|
149 |
}
|
|
150 |
else if (aType == EEventKeyDown)
|
|
151 |
{
|
|
152 |
}
|
|
153 |
|
|
154 |
if (exitCode != EKeyWasConsumed)
|
|
155 |
{
|
|
156 |
exitCode = CEikEdwin::OfferKeyEventL(aKeyEvent, aType);
|
|
157 |
}
|
|
158 |
|
|
159 |
return exitCode;
|
|
160 |
}
|
|
161 |
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
// CPbk2ContactEditorReadonlyField::SetTextL()
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
EXPORT_C void CPbk2ContactEditorReadonlyField::SetTextL(const TDesC* aData)
|
|
167 |
{
|
|
168 |
// Shorten data and take max length of head of text,
|
|
169 |
// otherwise edwin takes tail of text.
|
|
170 |
CTextLayout* layout = const_cast<CTextLayout *> (iTextView->Layout());
|
|
171 |
|
|
172 |
if (!layout->Truncating())
|
|
173 |
{
|
|
174 |
layout->SetTruncating(TRUE);
|
|
175 |
}
|
|
176 |
|
|
177 |
TInt maxLen = iTextLimit;
|
|
178 |
HBufC* stripBuf = HBufC::NewLC(maxLen);
|
|
179 |
TPtr stripPtr = stripBuf->Des();
|
|
180 |
stripPtr.Append(aData->Left(maxLen));
|
|
181 |
// Replace some common unicode control characters with spaces
|
|
182 |
// as Edwin can't show them correctly.
|
|
183 |
// - normal ASCII line break (\n)
|
|
184 |
// - normal ASCII tab (\t)
|
|
185 |
// - paragraph separator (0x2029)
|
|
186 |
// - line break (0x2028)
|
|
187 |
_LIT(KParagraphCharacter, "\n\t\x2029\x2028");
|
|
188 |
TChar space(' ');
|
|
189 |
AknTextUtils::ReplaceCharacters(stripPtr, KParagraphCharacter, space);
|
|
190 |
CEikEdwin::SetTextL(stripBuf);
|
|
191 |
CleanupStack::PopAndDestroy(stripBuf);
|
|
192 |
}
|
|
193 |
|
|
194 |
// --------------------------------------------------------------------------
|
|
195 |
// CPbk2ContactEditorReadonlyField::HandlePointerEventL
|
|
196 |
// --------------------------------------------------------------------------
|
|
197 |
//
|
|
198 |
void CPbk2ContactEditorReadonlyField::HandlePointerEventL(
|
|
199 |
const TPointerEvent& aPointerEvent)
|
|
200 |
{
|
|
201 |
//If overriding HandlePointerEventL(), the implementation must include a
|
|
202 |
//base call to CCoeControl's HandlePointerEventL().
|
|
203 |
CCoeControl::HandlePointerEventL(aPointerEvent);
|
|
204 |
|
|
205 |
if (AknLayoutUtils::PenEnabled())
|
|
206 |
{
|
|
207 |
switch (aPointerEvent.iType)
|
|
208 |
{
|
|
209 |
//When stylus dragged two EButton1Up events received per one EButton1Up
|
|
210 |
//event. Prevent EButton1Up processing if stylus dragged out of this
|
|
211 |
//control's rect.
|
|
212 |
case TPointerEvent::EButton1Down:
|
|
213 |
{
|
|
214 |
iTouchFeedbackRef->InstantFeedback(ETouchFeedbackBasic);
|
|
215 |
iButton1UpReceived = EFalse;
|
|
216 |
break;
|
|
217 |
}
|
|
218 |
case TPointerEvent::EButton1Up:
|
|
219 |
{
|
|
220 |
TInt y = aPointerEvent.iPosition.iY;
|
|
221 |
if (Rect().iTl.iY <= y && y <= Rect().iBr.iY
|
|
222 |
&& !iButton1UpReceived)
|
|
223 |
{
|
|
224 |
iTouchFeedbackRef->InstantFeedback(
|
|
225 |
this,
|
|
226 |
ETouchFeedbackBasic,
|
|
227 |
ETouchFeedbackVibra,
|
|
228 |
aPointerEvent);
|
|
229 |
|
|
230 |
if (iPbk2ContactEditorField)
|
|
231 |
{
|
|
232 |
MPbk2ContactEditorField2* tempContactEditorField =
|
|
233 |
reinterpret_cast<MPbk2ContactEditorField2*> (iPbk2ContactEditorField->ContactEditorFieldExtension(
|
|
234 |
KMPbk2ContactEditorFieldExtension2Uid));
|
|
235 |
|
|
236 |
tempContactEditorField-> HandleCustomFieldCommandL(
|
|
237 |
EPbk2CmdEditorHandleCustomSelect);
|
|
238 |
}
|
|
239 |
else if (iPbk2ContactEditorUIField)
|
|
240 |
{
|
|
241 |
iPbk2ContactEditorUIField-> HandleCustomFieldCommandL(
|
|
242 |
EPbk2CmdEditorHandleCustomSelect);
|
|
243 |
}
|
|
244 |
}
|
|
245 |
iButton1UpReceived = ETrue;
|
|
246 |
break;
|
|
247 |
}
|
|
248 |
default:;
|
|
249 |
}
|
|
250 |
}
|
|
251 |
}
|
|
252 |
|
|
253 |
// End of File
|