35 #include "MsgEditorCommon.h" // |
35 #include "MsgEditorCommon.h" // |
36 #include "MsgBodyControlEditor.h" // for CMsgBodyControlEditor |
36 #include "MsgBodyControlEditor.h" // for CMsgBodyControlEditor |
37 #include "MsgBaseControl.h" // for TMsgEditPermissionFlags |
37 #include "MsgBaseControl.h" // for TMsgEditPermissionFlags |
38 #include "MsgBaseControlObserver.h" // for MMsgBaseControlObserver |
38 #include "MsgBaseControlObserver.h" // for MMsgBaseControlObserver |
39 #include "MsgEditorCustomDraw.h" // for CMsgEditorCustomDraw |
39 #include "MsgEditorCustomDraw.h" // for CMsgEditorCustomDraw |
|
40 #include "MsgEditor.hrh" |
|
41 #include <MmsViewer.rsg> // resouce identifiers |
40 |
42 |
41 // ========== EXTERNAL DATA STRUCTURES ===================== |
43 // ========== EXTERNAL DATA STRUCTURES ===================== |
42 |
44 |
43 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
45 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
44 |
46 |
79 // Destructor. |
81 // Destructor. |
80 // --------------------------------------------------------- |
82 // --------------------------------------------------------- |
81 // |
83 // |
82 CMsgBodyControlEditor::~CMsgBodyControlEditor() |
84 CMsgBodyControlEditor::~CMsgBodyControlEditor() |
83 { |
85 { |
84 |
86 if (iItemFinder) |
|
87 { |
|
88 TRAP_IGNORE(iItemFinder->SetItemFinderObserverL( NULL )); |
|
89 } |
85 } |
90 } |
86 |
91 |
87 // --------------------------------------------------------- |
92 // --------------------------------------------------------- |
88 // CMsgBodyControlEditor::ConstructL |
93 // CMsgBodyControlEditor::ConstructL |
89 // |
94 // |
112 CItemFinder::EEmailAddress | |
117 CItemFinder::EEmailAddress | |
113 CItemFinder::EPhoneNumber | |
118 CItemFinder::EPhoneNumber | |
114 CItemFinder::EUriScheme ); |
119 CItemFinder::EUriScheme ); |
115 |
120 |
116 iItemFinder->AddObserver( *this ); |
121 iItemFinder->AddObserver( *this ); |
|
122 iItemFinder->SetItemFinderObserverL( this ); |
|
123 |
117 iFocusChangedBeforeParseFinish = EFalse; |
124 iFocusChangedBeforeParseFinish = EFalse; |
118 |
125 |
119 CEikRichTextEditor::ConstructL( iParentControl, 0, iMaxNumberOfChars, edwinFlags ); |
126 CEikRichTextEditor::ConstructL( iParentControl, 0, iMaxNumberOfChars, edwinFlags ); |
120 // 107-24185 : Emoticon support for SMS and MMS |
127 // 107-24185 : Emoticon support for SMS and MMS |
121 AddFlagToUserFlags(EAvkonEnableSmileySupport); |
128 AddFlagToUserFlags(EAvkonEnableSmileySupport); |
248 { |
255 { |
249 if ( IsReadOnly() ) |
256 if ( IsReadOnly() ) |
250 { |
257 { |
251 switch ( aKeyEvent.iCode ) |
258 switch ( aKeyEvent.iCode ) |
252 { |
259 { |
|
260 case EKeyDevice3: |
|
261 case EKeyEnter: |
|
262 { |
|
263 // Restore highlight |
|
264 const CItemFinder::CFindItemExt& item = |
|
265 iItemFinder->CurrentItemExt(); |
|
266 |
|
267 if ( item.iItemType != CItemFinder::ENoneSelected ) |
|
268 { |
|
269 SetSelectionL( item.iStart, item.iEnd + 1 ); |
|
270 } |
|
271 else if ( iInitTop ) |
|
272 { |
|
273 SetHighlightL( 0, EMsgFocusDown, ETrue ); |
|
274 } |
|
275 else |
|
276 { |
|
277 SetHighlightL( TextLength(), EMsgFocusUp, ETrue ); |
|
278 } |
|
279 return EKeyWasConsumed; |
|
280 } |
253 case EKeyUpArrow: |
281 case EKeyUpArrow: |
254 case EKeyDownArrow: |
282 case EKeyDownArrow: |
255 break; |
283 break; |
256 |
284 |
257 default: |
285 default: |
265 return EKeyWasConsumed; |
293 return EKeyWasConsumed; |
266 } |
294 } |
267 else |
295 else |
268 { |
296 { |
269 return CEikRichTextEditor::OfferKeyEventL( aKeyEvent, aType ); |
297 return CEikRichTextEditor::OfferKeyEventL( aKeyEvent, aType ); |
|
298 } |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------- |
|
302 // CMsgBodyControlEditor::HandleFindItemEventL |
|
303 // |
|
304 // Handles finditem events. |
|
305 // --------------------------------------------------------- |
|
306 // |
|
307 void CMsgBodyControlEditor::HandleFindItemEventL( |
|
308 const CItemFinder::CFindItemExt& aItem, |
|
309 MAknItemFinderObserver::TEventFlag aEvent, |
|
310 TUint aFlags) |
|
311 { |
|
312 // We will send new EMsgFindItemEvent so that we can separate |
|
313 // single click item activation and old key based activation. |
|
314 // This is just quick fix for doing it, other implementations should |
|
315 // be considered(e.g. storing state in editor or using some flags). |
|
316 // This is done because in AppUI::HandleKeyEvent we must separate |
|
317 // activation methods for enabling highlight when using keys. |
|
318 if ( MAknItemFinderObserver::EPointerEvent == aEvent ) |
|
319 { |
|
320 TKeyEvent event; |
|
321 event.iCode = EMsgFindItemKeyEvent; |
|
322 event.iScanCode = EMsgFindItemKeyEvent; |
|
323 event.iModifiers = 0; |
|
324 event.iRepeats = 0; |
|
325 |
|
326 iCoeEnv->WsSession().SimulateKeyEvent( event ); |
270 } |
327 } |
271 } |
328 } |
272 |
329 |
273 // --------------------------------------------------------- |
330 // --------------------------------------------------------- |
274 // CMsgBodyControlEditor::HandlePointerEventL |
331 // CMsgBodyControlEditor::HandlePointerEventL |
295 |
352 |
296 TBool tappedOverTag( RichText()->CursorOverTag( docPos, parser, start, length ) ); |
353 TBool tappedOverTag( RichText()->CursorOverTag( docPos, parser, start, length ) ); |
297 |
354 |
298 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
355 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
299 { |
356 { |
300 iPreviousItemStart = -1; |
357 if ( !tappedOverTag ) |
301 iPreviousItemLength = -1; |
|
302 |
|
303 if ( tappedOverTag ) |
|
304 { |
358 { |
305 TPoint relativeTapPoint( aPointerEvent.iPosition - iPosition ); |
359 // Reset current finditem |
306 if ( iItemFinder->ItemWasTappedL( relativeTapPoint ) ) |
360 iItemFinder->ResetCurrentItem(); |
307 { |
|
308 iPreviousItemStart = start; |
|
309 iPreviousItemLength = length; |
|
310 |
|
311 forwardRequest = EFalse; |
|
312 } |
|
313 } |
361 } |
314 else |
362 else |
315 { |
363 { |
316 iItemFinder->ResetCurrentItem(); |
364 // Find item tapped, do not forward event |
317 } |
|
318 } |
|
319 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
320 { |
|
321 if ( tappedOverTag && |
|
322 start >= iPreviousItemStart && |
|
323 length <= iPreviousItemLength ) |
|
324 { |
|
325 TKeyEvent event; |
|
326 event.iCode = EKeyDevice3; |
|
327 event.iScanCode = EStdKeyDevice3; |
|
328 event.iModifiers = 0; |
|
329 event.iRepeats = 0; |
|
330 |
|
331 iCoeEnv->WsSession().SimulateKeyEvent( event ); |
|
332 |
|
333 forwardRequest = EFalse; |
365 forwardRequest = EFalse; |
334 } |
366 } |
335 } |
367 } |
336 } |
368 } |
337 |
369 |