|
1 /* |
|
2 * Copyright (c) 2002-2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "AknPhoneNumberEditor.h" |
|
19 #include "AknPhedView.h" |
|
20 |
|
21 #include <AknUtils.h> |
|
22 #include <frmtlay.h> |
|
23 #include <eikenv.h> |
|
24 #include <barsread.h> |
|
25 #include <aknedsts.h> |
|
26 #include <featmgr.h> |
|
27 #include <aknextendedinputcapabilities.h> |
|
28 #include <eikcoctl.rsg> |
|
29 #include <txtetext.h> |
|
30 |
|
31 #include <AknTasHook.h> |
|
32 #include <touchfeedback.h> |
|
33 #include <aknnotedialog.h> |
|
34 |
|
35 static const TInt KPlainTextPos = 0; |
|
36 |
|
37 typedef CArrayFixFlat<CAknPhoneNumberEditor::TFormat> CFormatArray; |
|
38 |
|
39 NONSHARABLE_CLASS( CAknPhoneNumberEditorExtension ) : public CBase, |
|
40 public MObjectProvider |
|
41 { |
|
42 public: |
|
43 CAknPhoneNumberEditorExtension(); |
|
44 ~CAknPhoneNumberEditorExtension(); |
|
45 |
|
46 protected: // from MObjectProvider |
|
47 TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); |
|
48 |
|
49 public: |
|
50 CFormatArray* iFormats; |
|
51 CAknExtendedInputCapabilities* iExtendedInputCapabilities; |
|
52 TInt iPointPos; |
|
53 CAknCcpuSupport* iCcpuSupport; |
|
54 HBufC* iPasteText; |
|
55 }; |
|
56 |
|
57 CAknPhoneNumberEditorExtension::CAknPhoneNumberEditorExtension() |
|
58 { |
|
59 iFormats = NULL; |
|
60 iExtendedInputCapabilities = NULL; |
|
61 } |
|
62 |
|
63 |
|
64 CAknPhoneNumberEditorExtension::~CAknPhoneNumberEditorExtension() |
|
65 { |
|
66 delete iPasteText; |
|
67 delete iFormats; |
|
68 delete iExtendedInputCapabilities; |
|
69 delete iCcpuSupport; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CAknPhoneNumberEditorExtension::MopSupplyObject |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 TTypeUid::Ptr CAknPhoneNumberEditorExtension::MopSupplyObject( TTypeUid aId ) |
|
77 { |
|
78 if ( aId.iUid == CAknExtendedInputCapabilities::ETypeId ) |
|
79 { |
|
80 return aId.MakePtr( iExtendedInputCapabilities ); |
|
81 } |
|
82 |
|
83 return TTypeUid::Null(); |
|
84 } |
|
85 |
|
86 enum TAknPhedFlags |
|
87 { |
|
88 ERedrawAll, |
|
89 EInlineEditInProgress, |
|
90 EFeaturePhoneNumberGrouping |
|
91 }; |
|
92 |
|
93 enum TAknPhedControlPanic |
|
94 { |
|
95 ELeaveInStateChange, |
|
96 EIncorrectInlineEditState |
|
97 }; |
|
98 |
|
99 void PhedControlPanic( TAknPhedControlPanic aPanic ) |
|
100 { |
|
101 _LIT( KAknPhedControl,"AknPhedControl" ); |
|
102 User::Panic( KAknPhedControl, aPanic ); |
|
103 } |
|
104 |
|
105 |
|
106 EXPORT_C CAknPhoneNumberEditor::TFormat::TFormat() |
|
107 { |
|
108 Mem::FillZ( this, sizeof( *this ) ); |
|
109 } |
|
110 |
|
111 EXPORT_C CAknPhoneNumberEditor::TFormat::TFormat( TResourceReader& aReader ) |
|
112 { |
|
113 Mem::FillZ( this, sizeof( *this ) ); |
|
114 |
|
115 TInt top = aReader.ReadInt16(); |
|
116 TInt left = aReader.ReadInt16(); |
|
117 TInt bottom = aReader.ReadInt16(); |
|
118 TInt right = aReader.ReadInt16(); |
|
119 iOuterRect = TRect( TPoint( left, top ), TPoint( right, bottom ) ); |
|
120 |
|
121 iBorderType = aReader.ReadInt32(); |
|
122 iNumLines = aReader.ReadInt16(); |
|
123 iBottomBaselineOffset = aReader.ReadInt16(); |
|
124 iBaselineSeparation = aReader.ReadInt16(); |
|
125 iFont = AknLayoutUtils::FontFromId( aReader.ReadInt16() ); |
|
126 } |
|
127 |
|
128 EXPORT_C CAknPhoneNumberEditor::TFormat::TFormat( const TRect& aOuterRect, TInt aBorderType, |
|
129 TInt aNumLines, TInt aBottomBaselineOffset, TInt aBaselineSeparation, const CFont* aFont ) |
|
130 : iOuterRect( aOuterRect ), iBorderType( aBorderType ), iNumLines( aNumLines ), |
|
131 iBottomBaselineOffset( aBottomBaselineOffset ), iBaselineSeparation( aBaselineSeparation ), |
|
132 iFont( aFont ) |
|
133 { |
|
134 } |
|
135 |
|
136 |
|
137 |
|
138 EXPORT_C CAknPhoneNumberEditor::CAknPhoneNumberEditor() |
|
139 { |
|
140 iFlags.Set( ERedrawAll ); |
|
141 AKNTASHOOK_ADD( this, "CAknPhoneNumberEditor" ); |
|
142 } |
|
143 |
|
144 EXPORT_C CAknPhoneNumberEditor::~CAknPhoneNumberEditor() |
|
145 { |
|
146 AKNTASHOOK_REMOVE(); |
|
147 delete iView; |
|
148 delete iModel; |
|
149 delete iExtension; |
|
150 delete iFepState; |
|
151 } |
|
152 |
|
153 EXPORT_C void CAknPhoneNumberEditor::ConstructFromResourceL( TResourceReader& aReader ) |
|
154 { |
|
155 TInt maxChars = aReader.ReadInt16(); |
|
156 TInt maxLines = aReader.ReadInt16(); |
|
157 HBufC* truncation = aReader.ReadHBufCL(); |
|
158 CleanupStack::PushL( truncation ); |
|
159 TInt formatCount = aReader.ReadInt16(); |
|
160 ConstructL( maxChars, maxLines, formatCount, *truncation ); |
|
161 CleanupStack::PopAndDestroy(); // truncation |
|
162 |
|
163 for ( TInt ii=0; ii<formatCount; ii++ ) |
|
164 { |
|
165 AddFormat( TFormat(aReader ) ); |
|
166 } |
|
167 |
|
168 SetFormat( 0 ); |
|
169 |
|
170 TUint cap = iExtension->iExtendedInputCapabilities->Capabilities(); |
|
171 cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB; |
|
172 iExtension->iExtendedInputCapabilities->SetCapabilities( cap ); |
|
173 |
|
174 } |
|
175 |
|
176 EXPORT_C void CAknPhoneNumberEditor::ConstructL( TInt aMaxChars, |
|
177 TInt aMaxLines, |
|
178 TInt aMaxFormats, |
|
179 const TDesC& aTruncation ) |
|
180 { |
|
181 iExtension = new(ELeave) CAknPhoneNumberEditorExtension(); |
|
182 iExtension->iFormats = new(ELeave) CFormatArray( 1 ); |
|
183 iExtension->iFormats->ResizeL( aMaxFormats ); |
|
184 iModel = CAknPhedModel::NewL( aMaxChars ); |
|
185 iView = new(ELeave) CAknPhedView( iModel ); |
|
186 iView->ConstructL( aMaxLines, aTruncation ); |
|
187 iView->SetWindows( &iEikonEnv->RootWin(), DrawableWindow() ); |
|
188 iView->SetChangeReceiver( this ); |
|
189 CreateFepStateL(); |
|
190 iExtension->iExtendedInputCapabilities = CAknExtendedInputCapabilities::NewL(); |
|
191 |
|
192 TUint cap = iExtension->iExtendedInputCapabilities->Capabilities(); |
|
193 cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB; |
|
194 iExtension->iExtendedInputCapabilities->SetCapabilities( cap ); |
|
195 |
|
196 EnableDragEvents(); |
|
197 EnableCcpuSupportL( ETrue ); |
|
198 } |
|
199 |
|
200 EXPORT_C void CAknPhoneNumberEditor::AddFormat( const TFormat& aFormat ) |
|
201 { |
|
202 iExtension->iFormats->At( iNumFormats++ ) = aFormat; |
|
203 } |
|
204 |
|
205 EXPORT_C TInt CAknPhoneNumberEditor::CountFormats() const |
|
206 { |
|
207 return iNumFormats; |
|
208 } |
|
209 |
|
210 EXPORT_C CAknPhoneNumberEditor::TFormat& CAknPhoneNumberEditor::Format( TInt aFormatIndex ) const |
|
211 { |
|
212 return iExtension->iFormats->At( aFormatIndex ); |
|
213 } |
|
214 |
|
215 EXPORT_C TInt CAknPhoneNumberEditor::CurrentFormatIndex() const |
|
216 { |
|
217 return iCurrentFormatIndex; |
|
218 } |
|
219 |
|
220 EXPORT_C TBool CAknPhoneNumberEditor::WouldTextFitInFormat( TInt aFormatIndex ) const |
|
221 { |
|
222 TFormat& format = Format( aFormatIndex ); |
|
223 |
|
224 // create a line and see how many times the text takes to fit it. |
|
225 TAknPhedViewLine line; |
|
226 line.SetModel( iModel ); |
|
227 line.SetFormat( format.iFont, Border().InnerRect( format.iOuterRect ), |
|
228 format.iBaselineSeparation ); |
|
229 |
|
230 TInt count = 1; |
|
231 line.SetRightPos( 0 ); |
|
232 if ( line.LeftPos() > 0 ) |
|
233 { |
|
234 while ( line.LeftPos() != iModel->Length() ) |
|
235 { |
|
236 line.SetRightPos( line.LeftPos() ); |
|
237 line.SetRightLine( &line ); |
|
238 count++; |
|
239 } |
|
240 } |
|
241 return count <= format.iNumLines; |
|
242 } |
|
243 |
|
244 EXPORT_C void CAknPhoneNumberEditor::SetFormat( TInt aFormatIndex ) |
|
245 { |
|
246 iCurrentFormatIndex = aFormatIndex; |
|
247 TFormat& format = Format( aFormatIndex ); |
|
248 SetBorder( format.iBorderType ); |
|
249 SetRect( format.iOuterRect ); |
|
250 } |
|
251 |
|
252 EXPORT_C TPtrC CAknPhoneNumberEditor::Text( TInt aFrom ) const |
|
253 { |
|
254 return iModel->UnFormattedText(aFrom); |
|
255 } |
|
256 |
|
257 EXPORT_C void CAknPhoneNumberEditor::SetText( const TDesC& aText ) |
|
258 { |
|
259 iModel->SetText( aText ); |
|
260 } |
|
261 |
|
262 void CAknPhoneNumberEditor::DrawChanges() |
|
263 { |
|
264 // DrawChanges actually draws everything. Flicker is not |
|
265 // a problem now. |
|
266 DrawDeferred(); |
|
267 } |
|
268 |
|
269 EXPORT_C void CAknPhoneNumberEditor::SizeChanged() |
|
270 { |
|
271 TFormat& format = Format( CurrentFormatIndex() ); |
|
272 TPoint pt = DrawableWindow()->Position(); |
|
273 TSize size = DrawableWindow()->Size(); |
|
274 TRect rect = Rect(); |
|
275 TInt offset = rect.iBr.iX - ( pt.iX + size.iWidth ); |
|
276 if ( offset > 0 ) |
|
277 { |
|
278 rect.iTl.iX -= offset; |
|
279 rect.iBr.iX = pt.iX + size.iWidth; |
|
280 SetRect( rect ); |
|
281 } |
|
282 iView->SetFormat( format.iNumLines, format.iFont, Border().InnerRect( Rect() ), |
|
283 format.iBottomBaselineOffset, format.iBaselineSeparation); |
|
284 } |
|
285 |
|
286 EXPORT_C TKeyResponse CAknPhoneNumberEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
287 TEventCode aType ) |
|
288 { |
|
289 if ( aType != EEventKey ) |
|
290 return EKeyWasNotConsumed; |
|
291 |
|
292 TKeyResponse resp = EKeyWasConsumed; |
|
293 |
|
294 TInt cursorX = iView->CursorPosition().iX; |
|
295 TBool targetPosUsed = EFalse; |
|
296 |
|
297 // when user inputs digit, the screen should be drawn, otherwise |
|
298 // we need to check whether the screen will be drawn by view |
|
299 TBool needDraw = EFalse; |
|
300 |
|
301 // record cursorline before cursor moves for preventing flicker |
|
302 TInt cursorLinePre = iView->CursorLine(); |
|
303 |
|
304 // record leftpos of current line to help to decide how the |
|
305 // cursor moves between different lines. |
|
306 const CAknPhedViewLineArray* lineArray = iView->LineArray(); |
|
307 TInt leftPosPre = lineArray->At( cursorLinePre ).LeftPos(); |
|
308 |
|
309 // phone number editor does not respond to shift key. |
|
310 // The code is still here because it may need to be turned back on if |
|
311 // the phone number editor needs to support selection, cut, copy and paste. |
|
312 TBool shift = ( ( aKeyEvent.iModifiers & EModifierShift ) == EModifierShift ); |
|
313 TBool cousorChanged = EFalse; |
|
314 switch(aKeyEvent.iCode) |
|
315 { |
|
316 case EKeyLeftArrow: |
|
317 if (shift) |
|
318 iModel->SelectLeft(); |
|
319 else |
|
320 iModel->CursorLeft(); |
|
321 cousorChanged = ETrue; |
|
322 break; |
|
323 |
|
324 case EKeyRightArrow: |
|
325 if (shift) |
|
326 iModel->SelectRight(); |
|
327 else |
|
328 iModel->CursorRight(); |
|
329 cousorChanged = ETrue; |
|
330 break; |
|
331 |
|
332 case EKeyUpArrow: |
|
333 if ( shift ) |
|
334 targetPosUsed = iView->SelectUp( TargetCursorPos( cursorX ) ); |
|
335 else |
|
336 targetPosUsed = iView->CursorUp( TargetCursorPos( cursorX ) ); |
|
337 cousorChanged = ETrue; |
|
338 break; |
|
339 |
|
340 case EKeyDownArrow: |
|
341 if ( shift ) |
|
342 targetPosUsed = iView->SelectDown( TargetCursorPos( cursorX ) ); |
|
343 else |
|
344 targetPosUsed = iView->CursorDown( TargetCursorPos( cursorX ) ); |
|
345 cousorChanged = ETrue; |
|
346 break; |
|
347 |
|
348 case EKeyBackspace: |
|
349 iModel->DeleteLeft(); |
|
350 needDraw = ETrue; |
|
351 break; |
|
352 |
|
353 default: |
|
354 if ( aKeyEvent.iCode < ENonCharacterKeyBase ) |
|
355 { |
|
356 iModel->Insert( TText( aKeyEvent.iCode ) ); |
|
357 needDraw = ETrue; |
|
358 } |
|
359 else |
|
360 resp = EKeyWasNotConsumed; |
|
361 break; |
|
362 } |
|
363 |
|
364 if ( iExtension->iExtendedInputCapabilities ) |
|
365 { |
|
366 iExtension->iExtendedInputCapabilities->ReportEventL( |
|
367 CAknExtendedInputCapabilities:: |
|
368 MAknEventObserver::EControlContentUpdatedInternally, |
|
369 NULL ); |
|
370 } |
|
371 |
|
372 if ( shift && iExtension->iCcpuSupport ) |
|
373 { |
|
374 iExtension->iCcpuSupport->HandleSelectionChangeL(); |
|
375 } |
|
376 if ( cousorChanged ) |
|
377 { |
|
378 ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ); |
|
379 } |
|
380 // see if we want to remember the old cursor X position |
|
381 if ( targetPosUsed ) |
|
382 { |
|
383 if ( iTargetCursorPos == CAknPhedView::KNoPos ) |
|
384 iTargetCursorPos = cursorX; |
|
385 } |
|
386 else |
|
387 iTargetCursorPos = CAknPhedView::KNoPos; |
|
388 |
|
389 // To prevent flicker by avoiding drawing screen multi-times in short |
|
390 // time. When cursor moves between two lines that are both shown at |
|
391 // the same time, the screen will be drawn by CAknPhedView, and the |
|
392 // DrawNow need not be called, otherwise the screen should be drawn here. |
|
393 TInt leftPosPost = lineArray->At( iView->CursorLine() ).LeftPos(); |
|
394 if ( needDraw || |
|
395 Abs( leftPosPost - leftPosPre ) != lineArray->At( 0 ).LineWidth() ) |
|
396 { |
|
397 DrawNow(); |
|
398 } |
|
399 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
|
400 return resp; |
|
401 } |
|
402 |
|
403 EXPORT_C TSize CAknPhoneNumberEditor::MinimumSize() |
|
404 { |
|
405 return iView->Rect().Size(); |
|
406 } |
|
407 |
|
408 EXPORT_C void CAknPhoneNumberEditor::FocusChanged( TDrawNow aDrawNow ) |
|
409 { |
|
410 if ( iView ) |
|
411 { |
|
412 if ( IsFocused() ) |
|
413 iView->EnableCursor(); |
|
414 else |
|
415 iView->DisableCursor(); |
|
416 } |
|
417 |
|
418 if ( iExtension->iCcpuSupport ) |
|
419 { |
|
420 TRAP_IGNORE( iExtension->iCcpuSupport->HandleFocusChangeL() ); |
|
421 } |
|
422 if ( ! IsFocused() ) |
|
423 { |
|
424 TRAP_IGNORE( ReportAknEdStateEventL( MAknEdStateObserver::EAknSyncEdwinState ) ); |
|
425 } |
|
426 if ( aDrawNow ) |
|
427 DrawNow(); |
|
428 } |
|
429 |
|
430 EXPORT_C void CAknPhoneNumberEditor::Draw( const TRect& aRect ) const |
|
431 { |
|
432 CEikBorderedControl::Draw( aRect ); |
|
433 iView->Draw( SystemGc(), iFlags[ERedrawAll], this ); |
|
434 } |
|
435 |
|
436 EXPORT_C TCoeInputCapabilities CAknPhoneNumberEditor::InputCapabilities() const |
|
437 { |
|
438 if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
439 { |
|
440 TCoeInputCapabilities inputCaps( |
|
441 TCoeInputCapabilities::EWesternAlphabetic | |
|
442 TCoeInputCapabilities::ENavigation, |
|
443 const_cast<CAknPhoneNumberEditor*>( this ), NULL ); |
|
444 |
|
445 // Voip-enabled phone editor wants to use edit-key style hash key mode selection. |
|
446 iExtension->iExtendedInputCapabilities->SetEditorType( |
|
447 CAknExtendedInputCapabilities::EPhoneNumberEditor ); |
|
448 iExtension->iExtendedInputCapabilities->SetCapabilities( |
|
449 CAknExtendedInputCapabilities::EForceHashKeySelectionStatusFlagOff | |
|
450 CAknExtendedInputCapabilities::EForceEditSubmenuStatusFlagOff ); |
|
451 inputCaps.SetObjectProvider( |
|
452 const_cast<CAknPhoneNumberEditorExtension*>( iExtension ) ); |
|
453 |
|
454 return inputCaps; |
|
455 } |
|
456 else if ( FeatureManager::FeatureSupported( KFeatureIdCsVideoTelephony ) ) |
|
457 { |
|
458 TCoeInputCapabilities inputCaps( |
|
459 TCoeInputCapabilities::EDialableCharacters | |
|
460 TCoeInputCapabilities::ENavigation, |
|
461 const_cast<CAknPhoneNumberEditor*>(this), NULL); |
|
462 |
|
463 iExtension->iExtendedInputCapabilities->SetEditorType( |
|
464 CAknExtendedInputCapabilities::EPhoneNumberEditor ); |
|
465 inputCaps.SetObjectProvider( |
|
466 const_cast<CAknPhoneNumberEditorExtension*>( iExtension ) ); |
|
467 |
|
468 return inputCaps; |
|
469 } |
|
470 return TCoeInputCapabilities( 0, const_cast<CAknPhoneNumberEditor*>(this), NULL ); |
|
471 } |
|
472 |
|
473 EXPORT_C TInt CAknPhoneNumberEditor::TextLength() const |
|
474 { |
|
475 return iModel->Length(); |
|
476 } |
|
477 |
|
478 EXPORT_C TInt CAknPhoneNumberEditor::CursorPos() const |
|
479 { |
|
480 return iModel->CursorPosition(); |
|
481 } |
|
482 |
|
483 EXPORT_C TInt CAknPhoneNumberEditor::SelectionLength() const |
|
484 { |
|
485 return iModel->SelectionWidth(); |
|
486 } |
|
487 |
|
488 EXPORT_C TCursorSelection CAknPhoneNumberEditor::Selection() const |
|
489 { |
|
490 return TCursorSelection( iModel->CursorPosition(), iModel->AnchorPosition() ); |
|
491 } |
|
492 |
|
493 EXPORT_C void CAknPhoneNumberEditor::ClearSelectionL() |
|
494 { |
|
495 if ( iModel->SelectionExists() ) |
|
496 iModel->DeleteLeft(); |
|
497 } |
|
498 |
|
499 EXPORT_C void CAknPhoneNumberEditor::SetSelectionL( TInt aCursorPos,TInt aAnchorPos ) |
|
500 { |
|
501 iModel->SetRealCursorPosition(aCursorPos); |
|
502 iModel->SetAnchorPosition( aAnchorPos ); |
|
503 ReportAknEdStateEventL( |
|
504 MAknEdStateObserver::EAknCursorPositionChanged ); |
|
505 } |
|
506 |
|
507 EXPORT_C void CAknPhoneNumberEditor::SetCursorPosL( TInt aCursorPos,TBool aSelect ) |
|
508 { |
|
509 TInt anchor = iModel->AnchorPosition(); |
|
510 iModel->SetRealCursorPosition( aCursorPos ); |
|
511 if ( aSelect ) |
|
512 iModel->SetAnchorPosition( anchor ); |
|
513 ReportAknEdStateEventL( |
|
514 MAknEdStateObserver::EAknCursorPositionChanged ); |
|
515 } |
|
516 |
|
517 EXPORT_C void CAknPhoneNumberEditor::SelectAllL() |
|
518 { |
|
519 iModel->SetRealCursorPosition(iModel->Length()); |
|
520 iModel->SetAnchorPosition( 0 ); |
|
521 } |
|
522 |
|
523 EXPORT_C void CAknPhoneNumberEditor::GetText( TDes& aDes ) const |
|
524 { |
|
525 if ( Text().Length() <= aDes.MaxLength() ) |
|
526 { |
|
527 aDes = Text(); |
|
528 } |
|
529 else |
|
530 { |
|
531 aDes = Text().Left( aDes.MaxLength() ); |
|
532 } |
|
533 } |
|
534 |
|
535 EXPORT_C HBufC* CAknPhoneNumberEditor::GetTextInHBufL() const |
|
536 { |
|
537 return Text().AllocL(); |
|
538 } |
|
539 |
|
540 EXPORT_C void CAknPhoneNumberEditor::SetTextL( const TDesC* aDes ) |
|
541 { |
|
542 if ( aDes ) |
|
543 iModel->SetText( *aDes ); |
|
544 else |
|
545 iModel->SetText( KNullDesC() ); |
|
546 } |
|
547 |
|
548 EXPORT_C void CAknPhoneNumberEditor::CancelFepTransaction() |
|
549 { |
|
550 CCoeFep* fep = iCoeEnv->Fep(); |
|
551 if ( fep ) |
|
552 { |
|
553 fep->CancelTransaction(); |
|
554 } |
|
555 } |
|
556 |
|
557 EXPORT_C void CAknPhoneNumberEditor::UpdateScrollBarsL() |
|
558 { |
|
559 } |
|
560 |
|
561 EXPORT_C CEikScrollBarFrame* CAknPhoneNumberEditor::CreateScrollBarFrameL() |
|
562 { |
|
563 return NULL; |
|
564 } |
|
565 |
|
566 EXPORT_C TInt CAknPhoneNumberEditor::LineCursorWidth() const |
|
567 { |
|
568 return 0; |
|
569 } |
|
570 |
|
571 EXPORT_C TMargins8 CAknPhoneNumberEditor::Margins() const |
|
572 { |
|
573 return TMargins8(); |
|
574 } |
|
575 |
|
576 void CAknPhoneNumberEditor::StartFepInlineEditL( |
|
577 const TDesC& aInitialInlineText, |
|
578 TInt /*aPositionOfInsertionPointInInlineText*/, |
|
579 TBool /*aCursorVisibility*/, |
|
580 const MFormCustomDraw* /*aCustomDraw*/, |
|
581 MFepInlineTextFormatRetriever& /*aInlineTextFormatRetriever*/, |
|
582 MFepPointerEventHandlerDuringInlineEdit& /*aPointerEventHandlerDuringInlineEdit*/) |
|
583 { |
|
584 if ( aInitialInlineText.Length() == 0 ) |
|
585 { |
|
586 // This method used to ignore aInitialInlineText. For improved |
|
587 // backwards compatibility just do what it did before. |
|
588 // That is, do not admit a new state of "in inline edit", but with no text. |
|
589 iFlags.Clear( EInlineEditInProgress ); |
|
590 } |
|
591 else |
|
592 { |
|
593 // flag is set by a StartFepInlineEdit with text |
|
594 // or by UpdateFepInlineTextL. Should not get a 2nd start. |
|
595 __ASSERT_DEBUG( !iFlags[EInlineEditInProgress], |
|
596 PhedControlPanic(EIncorrectInlineEditState) ); |
|
597 iModel->Insert( aInitialInlineText[0] ); |
|
598 iFlags.Set( EInlineEditInProgress ); |
|
599 DrawChanges(); |
|
600 } |
|
601 } |
|
602 |
|
603 void CAknPhoneNumberEditor::UpdateFepInlineTextL(const TDesC& aNewInlineText, |
|
604 TInt /*aPositionOfInsertionPointInInlineText*/ ) |
|
605 { |
|
606 if ( iFlags[EInlineEditInProgress] ) |
|
607 iModel->DeleteLeft(); |
|
608 |
|
609 if ( aNewInlineText != KNullDesC ) |
|
610 { |
|
611 iModel->Insert( aNewInlineText[0] ); |
|
612 } |
|
613 else |
|
614 { |
|
615 iModel->DeleteLeft(); |
|
616 } |
|
617 |
|
618 iFlags.Set( EInlineEditInProgress ); |
|
619 DrawChanges(); |
|
620 } |
|
621 |
|
622 void CAknPhoneNumberEditor::SetInlineEditingCursorVisibilityL(TBool /*aCursorVisibility*/) |
|
623 { |
|
624 } |
|
625 |
|
626 void CAknPhoneNumberEditor::CancelFepInlineEdit() |
|
627 { |
|
628 iFlags.Clear( EInlineEditInProgress ); |
|
629 } |
|
630 |
|
631 TInt CAknPhoneNumberEditor::DocumentLengthForFep() const |
|
632 { |
|
633 return iModel->UnFormattedText( 0 ).Length(); |
|
634 } |
|
635 |
|
636 TInt CAknPhoneNumberEditor::DocumentMaximumLengthForFep() const |
|
637 { |
|
638 // Lie to FEP about the maximum length, because we handle our own overflow. |
|
639 return iModel->MaxDisplayLength() + 1; |
|
640 } |
|
641 |
|
642 void CAknPhoneNumberEditor::SetCursorSelectionForFepL( const TCursorSelection& aCursorSelection ) |
|
643 { |
|
644 iModel->SetRealCursorPosition( iModel->Uncompensate( aCursorSelection.iCursorPos ) ); |
|
645 iModel->SetAnchorPosition( iModel->Uncompensate( aCursorSelection.iAnchorPos ) ); |
|
646 |
|
647 ReportAknEdStateEventL( |
|
648 MAknEdStateObserver::EAknCursorPositionChanged ); |
|
649 DrawNow(); |
|
650 } |
|
651 |
|
652 void CAknPhoneNumberEditor::GetCursorSelectionForFep( TCursorSelection& aCursorSelection ) const |
|
653 { |
|
654 aCursorSelection.iCursorPos = iModel->CursorPosition(); |
|
655 aCursorSelection.iAnchorPos = iModel->AnchorPosition(); |
|
656 } |
|
657 |
|
658 void CAknPhoneNumberEditor::GetEditorContentForFep( TDes& aEditorContent, |
|
659 TInt aDocumentPosition, |
|
660 TInt aLengthToRetrieve ) const |
|
661 { |
|
662 TInt realLength = Min( iModel->Length() - aDocumentPosition, aLengthToRetrieve ); |
|
663 if ( iModel->Length() > 0 ) |
|
664 { |
|
665 if ( iModel->UnFormattedText( 0 ).Length() >= aDocumentPosition + realLength ) |
|
666 { |
|
667 aEditorContent.Copy( |
|
668 iModel->UnFormattedText( 0 ).Mid( aDocumentPosition, realLength ) ); |
|
669 } |
|
670 } |
|
671 } |
|
672 void CAknPhoneNumberEditor::GetFormatForFep( TCharFormat& /*aFormat*/, |
|
673 TInt /*aDocumentPosition*/ ) const |
|
674 { |
|
675 } |
|
676 |
|
677 void CAknPhoneNumberEditor::GetScreenCoordinatesForFepL( TPoint& /*aLeftSideOfBaseLine*/, |
|
678 TInt& /*aHeight*/, |
|
679 TInt& /*aAscent*/, |
|
680 TInt /*aDocumentPosition*/) const |
|
681 { |
|
682 } |
|
683 |
|
684 void CAknPhoneNumberEditor::DoCommitFepInlineEditL() |
|
685 { |
|
686 iFlags.Clear( EInlineEditInProgress ); |
|
687 } |
|
688 |
|
689 MCoeFepAwareTextEditor_Extension1* CAknPhoneNumberEditor::Extension1(TBool& aSetToTrue) |
|
690 { |
|
691 aSetToTrue=ETrue; |
|
692 return STATIC_CAST( MCoeFepAwareTextEditor_Extension1*, this ); |
|
693 } |
|
694 |
|
695 TInt CAknPhoneNumberEditor::TargetCursorPos( TInt aCurrentPos ) |
|
696 { |
|
697 if ( iTargetCursorPos == CAknPhedView::KNoPos ) |
|
698 return aCurrentPos; |
|
699 else |
|
700 return iTargetCursorPos; |
|
701 } |
|
702 |
|
703 void CAknPhoneNumberEditor::StateChanged() |
|
704 { |
|
705 #ifdef _DEBUG |
|
706 TRAPD(err, ReportEventL( MCoeControlObserver::EEventStateChanged ) ); |
|
707 // phone number editor should never leave. |
|
708 TRAP_IGNORE(__ASSERT_DEBUG( err == KErrNone, PhedControlPanic( ELeaveInStateChange ) ) ); |
|
709 #else |
|
710 TRAP_IGNORE( ReportEventL( MCoeControlObserver::EEventStateChanged ) ); |
|
711 #endif // _DEBUG |
|
712 } |
|
713 |
|
714 CEikScrollBarFrame* CAknPhoneNumberEditor::CreateScrollBarFrameL(TBool /*aPreAlloc*/) |
|
715 { |
|
716 return NULL; |
|
717 } |
|
718 |
|
719 void CAknPhoneNumberEditor::SetStateTransferingOwnershipL( CState* aState, |
|
720 TUid /*aTypeSafetyUid*/) |
|
721 { |
|
722 if ( iFepState ) |
|
723 delete iFepState; |
|
724 iFepState=aState; |
|
725 } |
|
726 |
|
727 MCoeFepAwareTextEditor_Extension1::CState* CAknPhoneNumberEditor::State( TUid /*aTypeSafetyUid*/ ) |
|
728 { |
|
729 return iFepState; |
|
730 } |
|
731 |
|
732 void CAknPhoneNumberEditor::CreateFepStateL() |
|
733 { |
|
734 CAknEdwinState* fepState = new(ELeave) CAknEdwinState(); |
|
735 iFepState = fepState; |
|
736 |
|
737 fepState->SetObjectProvider( this ); |
|
738 fepState->SetFlags( EAknEditorFlagFixedCase | EAknEditorFlagNoT9 | |
|
739 EAknEditorFlagNoEditIndicators | EAknEditorFlagSelectionVisible ); |
|
740 fepState->SetDefaultInputMode( EAknEditorNumericInputMode ); |
|
741 fepState->SetCurrentInputMode( EAknEditorNumericInputMode ); |
|
742 fepState->SetPermittedInputModes( EAknEditorNumericInputMode ); |
|
743 fepState->SetDefaultCase( EAknEditorLowerCase ); |
|
744 fepState->SetCurrentCase( EAknEditorLowerCase ); |
|
745 fepState->SetPermittedCases( EAknEditorLowerCase|EAknEditorUpperCase ); |
|
746 fepState->SetSpecialCharacterTableResourceId( 0 ); |
|
747 fepState->SetNumericKeymap( EAknEditorStandardNumberModeKeymap ); |
|
748 } |
|
749 |
|
750 EXPORT_C void CAknPhoneNumberEditor::MCoeFepAwareTextEditor_Reserved_2() |
|
751 { |
|
752 } |
|
753 |
|
754 EXPORT_C void CAknPhoneNumberEditor::MCoeFepAwareTextEditor_Extension1_Reserved_2() |
|
755 { |
|
756 } |
|
757 |
|
758 EXPORT_C void CAknPhoneNumberEditor::MCoeFepAwareTextEditor_Extension1_Reserved_3() |
|
759 { |
|
760 } |
|
761 |
|
762 EXPORT_C void CAknPhoneNumberEditor::MCoeFepAwareTextEditor_Extension1_Reserved_4() |
|
763 { |
|
764 } |
|
765 |
|
766 |
|
767 // --------------------------------------------------------- |
|
768 // CAknPhoneNumberEditor::ChangeEditorMode |
|
769 // --------------------------------------------------------- |
|
770 // |
|
771 EXPORT_C TInt CAknPhoneNumberEditor::ChangeEditorMode( TBool aDefaultMode ) |
|
772 { |
|
773 TInt value( EAknEditorNumericInputMode ); // Return value. |
|
774 |
|
775 if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
776 { |
|
777 CAknEdwinState* fepState = ( CAknEdwinState* )iFepState; |
|
778 |
|
779 // Get current input mode. |
|
780 TInt currentInputMode = fepState->CurrentInputMode(); |
|
781 |
|
782 // Set default values. |
|
783 if ( aDefaultMode ) |
|
784 { |
|
785 fepState->SetCurrentInputMode( EAknEditorNumericInputMode ); |
|
786 value = EAknEditorNumericInputMode; |
|
787 } |
|
788 // Set next input mode. 123 -> abc -> 123... |
|
789 else |
|
790 { |
|
791 if ( currentInputMode == EAknEditorNumericInputMode ) |
|
792 { |
|
793 fepState->SetCurrentInputMode( EAknEditorTextInputMode ); |
|
794 fepState->SetSpecialCharacterTableResourceId( |
|
795 R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG ); |
|
796 value = EAknEditorTextInputMode; |
|
797 } |
|
798 else if ( currentInputMode == EAknEditorTextInputMode ) |
|
799 { |
|
800 fepState->SetCurrentInputMode(EAknEditorNumericInputMode); |
|
801 fepState->SetSpecialCharacterTableResourceId( 0 ); |
|
802 value = EAknEditorNumericInputMode; |
|
803 } |
|
804 } |
|
805 |
|
806 fepState->SetCurrentCase(EAknEditorLowerCase); |
|
807 // Set some other VoIP specific editor settings. |
|
808 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) ) |
|
809 { |
|
810 fepState->SetFlags( EAknEditorFlagNoT9 |
|
811 | EAknEditorFlagLatinInputModesOnly | EAknEditorFlagNoEditIndicators ); |
|
812 } |
|
813 else |
|
814 { |
|
815 fepState->SetFlags( EAknEditorFlagNoT9 |
|
816 | EAknEditorFlagLatinInputModesOnly ); |
|
817 } |
|
818 |
|
819 fepState->SetPermittedInputModes( |
|
820 EAknEditorNumericInputMode|EAknEditorTextInputMode ); |
|
821 fepState->SetNumericKeymap(EAknEditorAlphanumericNumberModeKeymap); |
|
822 |
|
823 // Report FEP from new settings. |
|
824 TRAP_IGNORE( fepState->ReportAknEdStateEventL( |
|
825 MAknEdStateObserver::EAknEdwinStateEventStateUpdate ) ); |
|
826 |
|
827 fepState->SetMenu(); |
|
828 } |
|
829 DrawChanges(); |
|
830 return value; |
|
831 } |
|
832 |
|
833 // --------------------------------------------------------- |
|
834 // CAknPhoneNumberEditor::GetEditorMode |
|
835 // --------------------------------------------------------- |
|
836 // |
|
837 EXPORT_C TInt CAknPhoneNumberEditor::GetEditorMode() const |
|
838 { |
|
839 CAknEdwinState* fepState = ( CAknEdwinState* )iFepState; |
|
840 |
|
841 TInt currentInputMode = fepState->CurrentInputMode(); |
|
842 |
|
843 fepState->SetCurrentCase(EAknEditorLowerCase); |
|
844 if ( currentInputMode == EAknEditorNumericInputMode ) |
|
845 { |
|
846 fepState->SetSpecialCharacterTableResourceId( 0 ); |
|
847 } |
|
848 else if ( currentInputMode == EAknEditorTextInputMode ) |
|
849 { |
|
850 |
|
851 fepState->SetSpecialCharacterTableResourceId( |
|
852 R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG ); |
|
853 } |
|
854 |
|
855 fepState->SetMenu(); |
|
856 return currentInputMode; |
|
857 } |
|
858 |
|
859 // --------------------------------------------------------- |
|
860 // CAknPhoneNumberEditor::ResetEditorToDefaultValues |
|
861 // --------------------------------------------------------- |
|
862 // |
|
863 EXPORT_C void CAknPhoneNumberEditor::ResetEditorToDefaultValues() |
|
864 { |
|
865 CAknEdwinState* fepState = ( CAknEdwinState* )iFepState; |
|
866 CloseVKB(); |
|
867 // Set FEP-state to default values. |
|
868 fepState->SetFlags( EAknEditorFlagFixedCase | EAknEditorFlagNoT9 | |
|
869 EAknEditorFlagNoEditIndicators ); |
|
870 fepState->SetDefaultInputMode( EAknEditorNumericInputMode ); |
|
871 fepState->SetCurrentInputMode( EAknEditorNumericInputMode ); |
|
872 fepState->SetPermittedInputModes( EAknEditorNumericInputMode ); |
|
873 fepState->SetDefaultCase( EAknEditorLowerCase ); |
|
874 fepState->SetCurrentCase( EAknEditorLowerCase ); |
|
875 fepState->SetPermittedCases( EAknEditorLowerCase | EAknEditorUpperCase ); |
|
876 fepState->SetSpecialCharacterTableResourceId( 0 ); |
|
877 fepState->SetNumericKeymap( EAknEditorStandardNumberModeKeymap ); |
|
878 |
|
879 DrawChanges(); |
|
880 } |
|
881 |
|
882 // -------------------------------------------------------------------------- |
|
883 // CAknPhoneNumberEditor::HandlePointerEventL |
|
884 // -------------------------------------------------------------------------- |
|
885 // |
|
886 EXPORT_C void CAknPhoneNumberEditor::HandlePointerEventL( |
|
887 const TPointerEvent& aPointerEvent) |
|
888 { |
|
889 TCursorSelection selectionBefore = Selection(); |
|
890 TInt cursor = iView->GetCursorPosByPoint( aPointerEvent.iPosition ); |
|
891 // if cursro is not in accepted range. cancel current selection |
|
892 |
|
893 if ( cursor < 0 ) |
|
894 { |
|
895 cursor = CursorPos(); |
|
896 DrawNow(); |
|
897 return; |
|
898 } |
|
899 |
|
900 const CAknPhedViewLineArray* lineArray = iView->LineArray(); |
|
901 TInt cursorLinePre = iView->CursorLine(); |
|
902 TInt leftPosPre = lineArray->At( cursorLinePre ).LeftPos(); |
|
903 switch( aPointerEvent.iType ) |
|
904 { |
|
905 case TPointerEvent::EButton1Down: |
|
906 { |
|
907 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
908 |
|
909 if ( feedback ) |
|
910 { |
|
911 feedback->InstantFeedback( this, ETouchFeedbackEdit ); |
|
912 } |
|
913 } |
|
914 //cancel previous selection |
|
915 if ( iExtension->iPointPos != cursor ) |
|
916 { |
|
917 SetCursorPosL( iModel->Uncompensate( cursor ), EFalse ); |
|
918 iExtension->iPointPos = cursor; |
|
919 } |
|
920 break; |
|
921 case TPointerEvent::EButton1Up: |
|
922 if ( iExtension->iPointPos == cursor ) |
|
923 { |
|
924 SetCursorPosL( iModel->Uncompensate( cursor ), EFalse ); |
|
925 } |
|
926 else |
|
927 { |
|
928 SetSelectionL( iModel->Uncompensate( cursor ), |
|
929 iModel->Uncompensate( iExtension->iPointPos ) ); |
|
930 } |
|
931 break; |
|
932 case TPointerEvent::EButtonRepeat: |
|
933 case TPointerEvent::EDrag: |
|
934 { |
|
935 SetSelectionL( iModel->Uncompensate( cursor ), |
|
936 iModel->Uncompensate( iExtension->iPointPos ) ); |
|
937 TCursorSelection selectionAfter = Selection(); |
|
938 TBool selectionChanged = |
|
939 ( ( selectionAfter.iCursorPos != selectionBefore.iCursorPos ) |
|
940 || ( selectionAfter.iAnchorPos != selectionBefore.iAnchorPos ) ); |
|
941 if ( selectionChanged ) |
|
942 { |
|
943 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
944 if ( feedback ) |
|
945 { |
|
946 feedback->InstantFeedback( this, ETouchFeedbackTextSelection ); |
|
947 } |
|
948 } |
|
949 } |
|
950 break; |
|
951 default: |
|
952 break; |
|
953 } |
|
954 |
|
955 // same handling as OfferKeyEvent to prevent flicker. |
|
956 TInt leftPosPost = lineArray->At( iView->CursorLine() ).LeftPos(); |
|
957 if ( Abs( leftPosPost - leftPosPre ) != lineArray->At( 0 ).LineWidth() ) |
|
958 { |
|
959 DrawNow(); |
|
960 } |
|
961 } |
|
962 |
|
963 // -------------------------------------------------------------------------- |
|
964 // CAknPhoneNumberEditor::MopSupplyObject |
|
965 // -------------------------------------------------------------------------- |
|
966 // |
|
967 EXPORT_C TTypeUid::Ptr CAknPhoneNumberEditor::MopSupplyObject( TTypeUid aId ) |
|
968 { |
|
969 if ( aId.iUid == CEikMenuBar::ETypeId ) |
|
970 { |
|
971 return aId.MakePtr( iEikonEnv->AppUiFactory()->MenuBar() ); |
|
972 } |
|
973 return TTypeUid::Null(); |
|
974 } |
|
975 |
|
976 // -------------------------------------------------------------------------- |
|
977 // CAknPhoneNumberEditor::CcpuIsFocused |
|
978 // -------------------------------------------------------------------------- |
|
979 // |
|
980 EXPORT_C TBool CAknPhoneNumberEditor::CcpuIsFocused() const |
|
981 { |
|
982 return IsFocused(); |
|
983 } |
|
984 |
|
985 // -------------------------------------------------------------------------- |
|
986 // CAknPhoneNumberEditor::CcpuCanCut |
|
987 // -------------------------------------------------------------------------- |
|
988 // |
|
989 EXPORT_C TBool CAknPhoneNumberEditor::CcpuCanCut() const |
|
990 { |
|
991 return ( iExtension->iCcpuSupport && SelectionLength() != 0 ); |
|
992 } |
|
993 |
|
994 // -------------------------------------------------------------------------- |
|
995 // CAknPhoneNumberEditor::CcpuCutL |
|
996 // -------------------------------------------------------------------------- |
|
997 // |
|
998 EXPORT_C void CAknPhoneNumberEditor::CcpuCutL() |
|
999 { |
|
1000 ClipboardL( EFalse ); |
|
1001 } |
|
1002 |
|
1003 // -------------------------------------------------------------------------- |
|
1004 // CAknPhoneNumberEditor::CcpuCanCopy |
|
1005 // -------------------------------------------------------------------------- |
|
1006 // |
|
1007 EXPORT_C TBool CAknPhoneNumberEditor::CcpuCanCopy() const |
|
1008 { |
|
1009 return ( iExtension->iCcpuSupport && SelectionLength() != 0 ); |
|
1010 } |
|
1011 |
|
1012 // -------------------------------------------------------------------------- |
|
1013 // CAknPhoneNumberEditor::CcpuCopyL |
|
1014 // -------------------------------------------------------------------------- |
|
1015 // |
|
1016 EXPORT_C void CAknPhoneNumberEditor::CcpuCopyL() |
|
1017 { |
|
1018 ClipboardL( ETrue ); |
|
1019 } |
|
1020 |
|
1021 // -------------------------------------------------------------------------- |
|
1022 // CAknPhoneNumberEditor::CcpuCanPaste |
|
1023 // -------------------------------------------------------------------------- |
|
1024 // |
|
1025 EXPORT_C TBool CAknPhoneNumberEditor::CcpuCanPaste() const |
|
1026 { |
|
1027 if ( !iExtension->iCcpuSupport ) |
|
1028 return EFalse; |
|
1029 |
|
1030 if ( iExtension->iPasteText ) |
|
1031 { |
|
1032 delete iExtension->iPasteText; |
|
1033 iExtension->iPasteText = NULL; |
|
1034 } |
|
1035 TRAPD( err, DoCanPasteL() ); |
|
1036 return ( err == KErrNone ); |
|
1037 } |
|
1038 |
|
1039 // -------------------------------------------------------------------------- |
|
1040 // CAknPhoneNumberEditor::DoCanPasteL |
|
1041 // Check if there are data in clipboard and if the format of the data is |
|
1042 // accepted by phone number editor |
|
1043 // -------------------------------------------------------------------------- |
|
1044 // |
|
1045 void CAknPhoneNumberEditor::DoCanPasteL() const |
|
1046 { |
|
1047 CClipboard* cb = NULL; |
|
1048 cb = CClipboard::NewForReadingL( iCoeEnv->FsSession() ); |
|
1049 CleanupStack::PushL( cb ); |
|
1050 CStreamStore& store = cb->Store(); |
|
1051 CStreamDictionary& dict = cb->StreamDictionary(); |
|
1052 |
|
1053 // get plain text data from clipboard |
|
1054 CPlainText* text = CPlainText::NewL(); |
|
1055 CleanupStack::PushL( text ); |
|
1056 TInt dataLength = text->PasteFromStoreL( store, dict, KPlainTextPos); |
|
1057 if ( dataLength == 0 ) |
|
1058 { |
|
1059 User::Leave( KErrNotFound ); |
|
1060 } |
|
1061 HBufC* hBuf = HBufC::NewL( dataLength ); |
|
1062 TPtr buf = hBuf->Des(); |
|
1063 text->Extract( buf, KPlainTextPos, dataLength ); |
|
1064 CleanupStack::PopAndDestroy( text ); |
|
1065 CleanupStack::PushL( hBuf ); |
|
1066 |
|
1067 // get the list of allowed characters in phone number editor |
|
1068 CAknEdwinState* fepState = ( CAknEdwinState* )iFepState; |
|
1069 HBufC* specTable = NULL; |
|
1070 if ( fepState->NumericKeymap() == |
|
1071 EAknEditorAlphanumericNumberModeKeymap ) |
|
1072 { |
|
1073 TInt resId = fepState->SpecialCharacterTableResourceId(); |
|
1074 if ( resId > 0 ) |
|
1075 { |
|
1076 specTable = iEikonEnv->AllocReadResourceLC( resId ); |
|
1077 } |
|
1078 } |
|
1079 HBufC* allowChars = iEikonEnv->AllocReadResourceLC( |
|
1080 R_EIK_ALLOWED_STANDARDNUMBERMODEKEYMAP ); |
|
1081 |
|
1082 // check if the characters are allowed, if one character is not allowed, |
|
1083 // it will not be pasted into phone number editor |
|
1084 if ( fepState->CurrentInputMode() != EAknEditorTextInputMode ) |
|
1085 { |
|
1086 TInt pos = 0; |
|
1087 TInt index = 0; |
|
1088 while ( index < buf.Length() ) |
|
1089 { |
|
1090 pos = allowChars->Locate( buf[index] ); |
|
1091 if ( pos == KErrNotFound && specTable && specTable->Length() > 0 ) |
|
1092 { |
|
1093 pos = specTable->Locate( buf[index] ); |
|
1094 } |
|
1095 if ( pos == KErrNotFound ) |
|
1096 { |
|
1097 buf.Delete( index, 1 ); |
|
1098 } |
|
1099 else |
|
1100 { |
|
1101 index++; |
|
1102 } |
|
1103 } |
|
1104 if ( buf.Length() == 0 ) |
|
1105 { |
|
1106 User::Leave( KErrNotFound ); |
|
1107 } |
|
1108 } |
|
1109 iExtension->iPasteText = HBufC::NewL( buf.Length() ); |
|
1110 TPtr pasteBuf = iExtension->iPasteText->Des(); |
|
1111 pasteBuf.Copy( buf ); |
|
1112 CleanupStack::PopAndDestroy( allowChars ); |
|
1113 if ( specTable ) |
|
1114 { |
|
1115 CleanupStack::PopAndDestroy( specTable ); |
|
1116 } |
|
1117 CleanupStack::PopAndDestroy( hBuf ); |
|
1118 CleanupStack::PopAndDestroy( cb ); |
|
1119 } |
|
1120 |
|
1121 // -------------------------------------------------------------------------- |
|
1122 // CAknPhoneNumberEditor::CcpuPasteL |
|
1123 // -------------------------------------------------------------------------- |
|
1124 // |
|
1125 EXPORT_C void CAknPhoneNumberEditor::CcpuPasteL() |
|
1126 { |
|
1127 if ( iExtension->iPasteText ) |
|
1128 { |
|
1129 iModel->Paste( iExtension->iPasteText->Des() ); |
|
1130 DrawNow(); |
|
1131 } |
|
1132 } |
|
1133 |
|
1134 // -------------------------------------------------------------------------- |
|
1135 // CAknPhoneNumberEditor::CcpuCanUndo |
|
1136 // -------------------------------------------------------------------------- |
|
1137 // |
|
1138 EXPORT_C TBool CAknPhoneNumberEditor::CcpuCanUndo() const |
|
1139 { |
|
1140 return EFalse; |
|
1141 } |
|
1142 |
|
1143 // -------------------------------------------------------------------------- |
|
1144 // CAknPhoneNumberEditor::CcpuUndoL |
|
1145 // -------------------------------------------------------------------------- |
|
1146 // |
|
1147 EXPORT_C void CAknPhoneNumberEditor::CcpuUndoL() |
|
1148 { |
|
1149 } |
|
1150 |
|
1151 // -------------------------------------------------------------------------- |
|
1152 // CAknPhoneNumberEditor::EnableCcpuSupportL |
|
1153 // -------------------------------------------------------------------------- |
|
1154 // |
|
1155 void CAknPhoneNumberEditor::EnableCcpuSupportL( TBool aSupport ) |
|
1156 { |
|
1157 CAknCcpuSupport* ccpu = NULL; |
|
1158 CAknEdwinState* edwinState = ( CAknEdwinState* )iFepState; |
|
1159 |
|
1160 if ( aSupport ) |
|
1161 { |
|
1162 ccpu = new( ELeave ) CAknCcpuSupport( this ); |
|
1163 ccpu->SetMopParent( this ); |
|
1164 CleanupStack::PushL( ccpu ); |
|
1165 ccpu->ConstructL(); |
|
1166 CleanupStack::Pop( ccpu ); |
|
1167 if ( edwinState ) |
|
1168 { |
|
1169 edwinState->SetCcpuState( this ); |
|
1170 } |
|
1171 } |
|
1172 else |
|
1173 { |
|
1174 if ( edwinState ) |
|
1175 { |
|
1176 edwinState->SetCcpuState( NULL ); |
|
1177 } |
|
1178 } |
|
1179 delete iExtension->iCcpuSupport; |
|
1180 iExtension->iCcpuSupport = ccpu; |
|
1181 } |
|
1182 |
|
1183 // -------------------------------------------------------------------------- |
|
1184 // CAknPhoneNumberEditor::ClipboardL |
|
1185 // implementate copy and cut |
|
1186 // -------------------------------------------------------------------------- |
|
1187 // |
|
1188 void CAknPhoneNumberEditor::ClipboardL( TBool aIsCopy ) |
|
1189 { |
|
1190 CancelFepTransaction(); |
|
1191 TInt selectLength = SelectionLength(); |
|
1192 if ( selectLength == 0 ) |
|
1193 { |
|
1194 iEikonEnv->InfoMsg( aIsCopy ? |
|
1195 R_EIK_TBUF_NOTHING_TO_COPY : R_EIK_TBUF_NOTHING_TO_CUT ); |
|
1196 } |
|
1197 else |
|
1198 { |
|
1199 HBufC* buf = HBufC::NewLC( selectLength ); |
|
1200 TPtr text = buf->Des(); |
|
1201 if ( aIsCopy ) |
|
1202 { |
|
1203 iModel->Copy( text ); |
|
1204 } |
|
1205 else |
|
1206 { |
|
1207 iModel->Cut( text ); |
|
1208 DrawNow(); |
|
1209 } |
|
1210 PlaceDataOnClipboardL( text ); |
|
1211 CleanupStack::PopAndDestroy( buf ); |
|
1212 iEikonEnv->InfoMsg( R_EIK_TBUF_COPIED ); |
|
1213 if ( iExtension->iCcpuSupport ) |
|
1214 { |
|
1215 iExtension->iCcpuSupport->HandleSelectionChangeL(); |
|
1216 } |
|
1217 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog(); |
|
1218 dlg->SetTimeout( CAknNoteDialog::EShortTimeout ); |
|
1219 dlg->SetTone( CAknNoteDialog::ENoTone ); |
|
1220 dlg->ExecuteLD( R_AVKON_NOTE_CONF_COPIED ); |
|
1221 } |
|
1222 } |
|
1223 |
|
1224 // -------------------------------------------------------------------------- |
|
1225 // CAknPhoneNumberEditor::PlaceDataOnClipboardL |
|
1226 // -------------------------------------------------------------------------- |
|
1227 // |
|
1228 void CAknPhoneNumberEditor::PlaceDataOnClipboardL( const TDesC& aText ) |
|
1229 { |
|
1230 CClipboard* cb = CClipboard::NewForWritingLC( iCoeEnv->FsSession() ); |
|
1231 |
|
1232 CStreamStore& store = cb->Store(); |
|
1233 CStreamDictionary& dict = cb->StreamDictionary(); |
|
1234 |
|
1235 CPlainText* text = CPlainText::NewL(); |
|
1236 CleanupStack::PushL( text ); |
|
1237 text->InsertL( KPlainTextPos, aText ); |
|
1238 text->CopyToStoreL( store, dict, KPlainTextPos, aText.Length() ); |
|
1239 CleanupStack::PopAndDestroy( text ); |
|
1240 cb->CommitL(); |
|
1241 |
|
1242 CleanupStack::PopAndDestroy( cb ); |
|
1243 } |
|
1244 |
|
1245 // -------------------------------------------------------------------------- |
|
1246 // CAknPhoneNumberEditor::OpenVKB |
|
1247 // -------------------------------------------------------------------------- |
|
1248 // |
|
1249 EXPORT_C void CAknPhoneNumberEditor::OpenVKB( ) |
|
1250 { |
|
1251 TUint cap = iExtension->iExtendedInputCapabilities->Capabilities(); |
|
1252 cap &= ~CAknExtendedInputCapabilities::EInputEditorDisableVKB; |
|
1253 iExtension->iExtendedInputCapabilities->SetCapabilities( cap ); |
|
1254 TRAP_IGNORE( ReportAknEdStateEventL( |
|
1255 MAknEdStateObserver::EAknActivatePenInputRequest ) ); |
|
1256 } |
|
1257 |
|
1258 // -------------------------------------------------------------------------- |
|
1259 // CAknPhoneNumberEditor::CloseVKB |
|
1260 // -------------------------------------------------------------------------- |
|
1261 // |
|
1262 void CAknPhoneNumberEditor::CloseVKB( ) |
|
1263 { |
|
1264 TUint cap = iExtension->iExtendedInputCapabilities->Capabilities(); |
|
1265 cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB; |
|
1266 iExtension->iExtendedInputCapabilities->SetCapabilities( cap ); |
|
1267 ReportAknEdStateEventL( MAknEdStateObserver::EAknClosePenInputRequest ); |
|
1268 } |
|
1269 |
|
1270 // -------------------------------------------------------------------------- |
|
1271 // CAknPhoneNumberEditor::ReportAknEdStateEventL |
|
1272 // -------------------------------------------------------------------------- |
|
1273 // |
|
1274 void CAknPhoneNumberEditor::ReportAknEdStateEventL( |
|
1275 MAknEdStateObserver::EAknEdwinStateEvent aStateEvent ) |
|
1276 { |
|
1277 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*,State(KNullUid) ); |
|
1278 if ( edwinState ) |
|
1279 { |
|
1280 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( aStateEvent ) ); |
|
1281 } |
|
1282 } |
|
1283 // -------------------------------------------------------------------------- |
|
1284 // CAknPhoneNumberEditor::AknEditorFlags |
|
1285 // -------------------------------------------------------------------------- |
|
1286 // |
|
1287 EXPORT_C TInt CAknPhoneNumberEditor::AknEditorFlags() |
|
1288 { |
|
1289 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*,State(KNullUid) ); |
|
1290 if ( !edwinState ) |
|
1291 { |
|
1292 return 0; |
|
1293 } |
|
1294 return edwinState->Flags(); |
|
1295 } |
|
1296 |
|
1297 |
|
1298 // End of file |