49 #include "xneditmode.h" |
49 #include "xneditmode.h" |
50 #include "c_xnutils.h" |
50 #include "c_xnutils.h" |
51 #include "xntexteditor.h" |
51 #include "xntexteditor.h" |
52 |
52 |
53 // Constants |
53 // Constants |
54 enum EFlags |
54 |
55 { |
55 enum TSplitInputState |
56 EUsePartialScreenInput = 1, |
56 { |
57 EIsAlreadyFocused, |
57 ESplitInputEnabled = 1, |
58 EIsFocused, |
58 ESplitInputOpen = 2, |
59 ESetText |
59 ESplitInputEditorInStack = 4, |
|
60 EScreenDeviceChanged = 8 |
60 }; |
61 }; |
61 |
62 |
62 const TInt KDefaultLength( 100 ); |
63 const TInt KDefaultLength( 100 ); |
63 |
64 |
64 _LIT8( KCpsPublishing, "cpspublishing" ); |
65 _LIT8( KCpsPublishing, "cpspublishing" ); |
65 _LIT8( KMaxLineAmount, "max-line-amount" ); |
66 _LIT8( KMaxLineAmount, "max-line-amount" ); |
66 _LIT8( KMaxCharAmount, "max-char-amount" ); |
67 _LIT8( KMaxCharAmount, "max-char-amount" ); |
67 _LIT8( KEnablePartialInput, "splitinputenabled" ); |
68 _LIT8( KEnablePartialInput, "splitinputenabled" ); |
|
69 _LIT8( KSplitScreenEnabledTrigger , "splitscreenenabled" ); |
|
70 _LIT8( KSplitScreenDisabledTrigger, "splitscreendisabled" ); |
68 |
71 |
69 _LIT( KEnterChar, "\x2029" ); |
72 _LIT( KEnterChar, "\x2029" ); |
70 |
73 |
71 // Macros |
74 // Macros |
72 #define IS_ARROW_KEY( k ) \ |
75 #define IS_ARROW_KEY( k ) \ |
73 ( k == EStdKeyLeftArrow || k == EStdKeyRightArrow || \ |
76 ( k == EStdKeyLeftArrow || k == EStdKeyRightArrow || \ |
74 k == EStdKeyUpArrow || k == EStdKeyDownArrow ) |
77 k == EStdKeyUpArrow || k == EStdKeyDownArrow ) |
75 |
78 |
76 // ============================ LOCAL FUNCTIONS ================================ |
79 // ============================ LOCAL FUNCTIONS ================================ |
77 |
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 TBool IsFlagSet( TInt aFlags, TInt aFlag ) |
|
85 { |
|
86 return aFlags & aFlag; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void SetFlag( TInt& aFlags, TInt aFlag ) |
|
93 { |
|
94 aFlags |= aFlag; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void ClearFlag( TInt& aFlags, TInt aFlag ) |
|
101 { |
|
102 aFlags &= ~aFlag; |
|
103 } |
|
104 |
78 // ============================ MEMBER FUNCTIONS =============================== |
105 // ============================ MEMBER FUNCTIONS =============================== |
|
106 |
79 // ----------------------------------------------------------------------------- |
107 // ----------------------------------------------------------------------------- |
80 // CXnTextEditorAdapter::NewL |
108 // CXnTextEditorAdapter::NewL |
81 // Symbian static 1st phase constructor |
109 // Symbian static 1st phase constructor |
82 // ----------------------------------------------------------------------------- |
110 // ----------------------------------------------------------------------------- |
83 // |
111 // |
193 |
221 |
194 // Set numeric keymap |
222 // Set numeric keymap |
195 iEditor->SetAknEditorNumericKeymap( EAknEditorPlainNumberModeKeymap ); |
223 iEditor->SetAknEditorNumericKeymap( EAknEditorPlainNumberModeKeymap ); |
196 |
224 |
197 // Enable partial Screen |
225 // Enable partial Screen |
198 CXnProperty* prop( iNode.GetPropertyL( KEnablePartialInput ) ); |
226 CXnProperty* enablepartialinput( iNode.GetPropertyL( KEnablePartialInput ) ); |
199 |
227 iSplitInputFlags = 0; |
200 if ( prop && prop->StringValue() == XnPropertyNames::KTrue ) |
228 |
|
229 if ( enablepartialinput && |
|
230 enablepartialinput->StringValue() == XnPropertyNames::KTrue ) |
201 { |
231 { |
202 iEditor->SetAknEditorFlags( EAknEditorFlagEnablePartialScreen ); |
232 iEditor->SetAknEditorFlags( EAknEditorFlagEnablePartialScreen ); |
203 |
233 SetFlag( iSplitInputFlags, ESplitInputEnabled ); |
204 iFlags.Set( EUsePartialScreenInput ); |
|
205 } |
234 } |
206 |
235 |
207 iEditor->SetAlignment( AknLayoutUtils::LayoutMirrored() ? |
236 iEditor->SetAlignment( AknLayoutUtils::LayoutMirrored() ? |
208 EAknEditorAlignRight : EAknEditorAlignLeft ); |
237 EAknEditorAlignRight : EAknEditorAlignLeft ); |
209 |
238 |
296 } |
327 } |
297 } |
328 } |
298 |
329 |
299 return ret; |
330 return ret; |
300 } |
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // CXnTextEditorAdapter::RefusesFocusLoss |
|
335 // (other items were commented in a header). |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 TBool CXnTextEditorAdapter::RefusesFocusLoss() const |
|
339 { |
|
340 return iRefusesFocusLoss; |
|
341 } |
301 |
342 |
302 // ----------------------------------------------------------------------------- |
343 // ----------------------------------------------------------------------------- |
303 // CXnTextEditorAdapter::FocusChanged |
344 // CXnTextEditorAdapter::FocusChanged |
304 // (other items were commented in a header). |
345 // (other items were commented in a header). |
305 // ----------------------------------------------------------------------------- |
346 // ----------------------------------------------------------------------------- |
306 // |
347 // |
307 void CXnTextEditorAdapter::FocusChanged( TDrawNow /*aDrawNow*/ ) |
348 void CXnTextEditorAdapter::FocusChanged( TDrawNow aDrawNow ) |
308 { |
349 { |
309 TBool isFocused( IsFocused() ? ETrue : EFalse ); |
350 TBool isFocused( IsFocused() ? ETrue : EFalse ); |
310 TBool wasFocused( iFlags.IsSet( EIsFocused ) ? ETrue : EFalse ); |
351 TInt value; |
311 |
352 |
312 if ( isFocused != wasFocused ) |
353 if ( isFocused ) |
313 { |
354 { |
314 TInt value; |
355 value = EPSAiDontForwardNumericKeysToPhone; |
315 |
356 |
316 if ( isFocused ) |
357 if( !IsFlagSet( iSplitInputFlags, ESplitInputEnabled ) ) |
317 { |
358 { |
318 value = EPSAiDontForwardNumericKeysToPhone; |
359 TRAP_IGNORE( iAppui->AddToStackL( iAppui->View(), iEditor ) ); |
319 |
360 // AddToStackL calls iEditor->SetFocus( ETrue ); |
320 iFlags.Set( EIsFocused ); |
361 } |
321 |
362 else if( !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
322 TRAP_IGNORE( iAppui->AddToStackL( iAppui->View(), iEditor ) ); |
363 { |
323 } |
364 TRAP_IGNORE( iAppui->AddToStackL( iAppui->View(), iEditor ) ); |
324 else |
365 SetFlag( iSplitInputFlags, ESplitInputEditorInStack ); |
325 { |
366 } |
326 value = EPSAiForwardNumericKeysToPhone; |
367 } |
327 |
368 else |
328 iFlags.Clear( EIsFocused ); |
369 { |
329 |
370 value = EPSAiForwardNumericKeysToPhone; |
|
371 |
|
372 if( !IsFlagSet( iSplitInputFlags, ESplitInputEnabled ) ) |
|
373 { |
330 iAppui->RemoveFromStack( iEditor ); |
374 iAppui->RemoveFromStack( iEditor ); |
331 iEditor->SetFocus( EFalse ); |
375 iEditor->SetFocus( EFalse, aDrawNow ); |
332 } |
376 } |
333 |
377 |
334 RProperty::Set( KPSUidAiInformation, |
378 // Remove editor from stack if it has not beed removed AND split screen has been closed |
335 KActiveIdleForwardNumericKeysToPhone, value ); |
379 else if( IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) && |
336 } |
380 !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
|
381 { |
|
382 iAppui->RemoveFromStack( iEditor ); |
|
383 iEditor->SetFocus( EFalse, aDrawNow ); |
|
384 ClearFlag( iSplitInputFlags, ESplitInputEditorInStack ); |
|
385 } |
|
386 } |
|
387 |
|
388 if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
|
389 { |
|
390 value = EPSAiDontForwardNumericKeysToPhone; |
|
391 } |
|
392 |
|
393 iRefusesFocusLoss = isFocused; |
|
394 |
|
395 RProperty::Set( KPSUidAiInformation, |
|
396 KActiveIdleForwardNumericKeysToPhone, |
|
397 value ); |
337 } |
398 } |
338 |
399 |
339 // ----------------------------------------------------------------------------- |
400 // ----------------------------------------------------------------------------- |
340 // CXnTextEditorAdapter::Draw |
401 // CXnTextEditorAdapter::Draw |
341 // Draws the editor component |
402 // Draws the editor component |
346 // Do nothing. |
407 // Do nothing. |
347 // Background is drawn through MCoeControlBackground of CEikEdwin. |
408 // Background is drawn through MCoeControlBackground of CEikEdwin. |
348 } |
409 } |
349 |
410 |
350 // ----------------------------------------------------------------------------- |
411 // ----------------------------------------------------------------------------- |
|
412 // CXnTextEditorAdapter::HandleResourceChange |
|
413 // |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 void CXnTextEditorAdapter::HandleResourceChange( TInt aType ) |
|
417 { |
|
418 if ( aType == KAknSplitInputEnabled ) |
|
419 { |
|
420 if( IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) && |
|
421 !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
|
422 { |
|
423 iUiEngine->EnablePartialTouchInput( iNode, ETrue ); |
|
424 SetFlag( iSplitInputFlags, ESplitInputOpen ); |
|
425 if ( !IsFlagSet( iSplitInputFlags, EScreenDeviceChanged ) ) |
|
426 { |
|
427 TRAP_IGNORE( iNode.ReportTriggerEventL( KSplitScreenEnabledTrigger, |
|
428 KNullDesC8, KNullDesC8) ); |
|
429 } |
|
430 else |
|
431 { |
|
432 ClearFlag( iSplitInputFlags, EScreenDeviceChanged ); |
|
433 } |
|
434 } |
|
435 } |
|
436 |
|
437 if ( aType == KAknSplitInputDisabled ) |
|
438 { |
|
439 if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
|
440 { |
|
441 iUiEngine->EnablePartialTouchInput( iNode, EFalse ); |
|
442 ClearFlag( iSplitInputFlags, ESplitInputOpen ); |
|
443 |
|
444 // Note that after orientation switch, split screen is first closed and |
|
445 // then opened again. Therefore these must be discarded |
|
446 if ( !IsFlagSet( iSplitInputFlags, EScreenDeviceChanged ) ) |
|
447 { |
|
448 TRAP_IGNORE( iNode.ReportTriggerEventL( KSplitScreenDisabledTrigger, |
|
449 KNullDesC8, KNullDesC8) ); |
|
450 |
|
451 // If editor is not focused anymore, remove if from stack |
|
452 CXnNodePluginIf* focusedNode( NULL ); |
|
453 TRAP_IGNORE( focusedNode = iUiEngine->FocusedNodeL() ); |
|
454 if( focusedNode != &iNode && |
|
455 IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) ) |
|
456 { |
|
457 iAppui->RemoveFromStack( iEditor ); |
|
458 iEditor->SetFocus( EFalse ); |
|
459 ClearFlag( iSplitInputFlags, ESplitInputEditorInStack ); |
|
460 |
|
461 // Forward keys to phone again |
|
462 RProperty::Set( KPSUidAiInformation, |
|
463 KActiveIdleForwardNumericKeysToPhone, |
|
464 EPSAiForwardNumericKeysToPhone ); |
|
465 } |
|
466 } |
|
467 } |
|
468 } |
|
469 CCoeControl::HandleResourceChange( aType ); |
|
470 } |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
351 // CXnTextEditorAdapter::HandlePointerEventL |
473 // CXnTextEditorAdapter::HandlePointerEventL |
352 // |
474 // |
353 // ----------------------------------------------------------------------------- |
475 // ----------------------------------------------------------------------------- |
354 // |
476 // |
355 void CXnTextEditorAdapter::HandlePointerEventL( |
477 void CXnTextEditorAdapter::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
356 const TPointerEvent& aPointerEvent ) |
478 { |
357 { |
479 TPointerEvent pointerEvent( aPointerEvent ); |
358 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
480 TRect rect( iEditor->TextView()->ViewRect() ); |
359 { |
481 TPoint point( aPointerEvent.iPosition ); |
360 iFlags.Clear( EIsAlreadyFocused ); |
482 |
361 |
483 // this opens partial screen also when margin is tapped |
362 if ( IsFocused() ) |
484 if( !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
363 { |
485 { |
364 iFlags.Set( EIsAlreadyFocused ); |
486 if( point.iX < rect.iTl.iX ) |
365 } |
487 { |
366 } |
488 pointerEvent.iPosition.iX = rect.iTl.iX; |
367 |
489 } |
368 if ( iFlags.IsSet( EIsAlreadyFocused ) ) |
490 else if( point.iX > rect.iBr.iX ) |
369 { |
491 { |
370 CCoeControl::HandlePointerEventL( aPointerEvent ); |
492 pointerEvent.iPosition.iX = rect.iBr.iX; |
371 } |
493 } |
372 else |
494 |
373 { |
495 if( point.iY < rect.iTl.iY ) |
374 TPointerEvent pointerEvent( aPointerEvent ); |
496 { |
375 TRect rect( iEditor->TextView()->ViewRect() ); |
497 pointerEvent.iPosition.iY = rect.iTl.iY; |
376 TPoint point( aPointerEvent.iPosition ); |
498 } |
377 |
499 else if( point.iY > rect.iBr.iY ) |
378 // this opens partial screen also when margin is tapped |
500 { |
379 if ( iFlags.IsSet( EUsePartialScreenInput ) ) |
501 pointerEvent.iPosition.iY = rect.iBr.iY; |
380 { |
502 } |
381 if( point.iX < rect.iTl.iX ) |
503 } |
382 { |
504 |
383 pointerEvent.iPosition.iX = rect.iTl.iX; |
505 CXnControlAdapter::HandlePointerEventL( pointerEvent ); |
384 } |
506 } |
385 else if( point.iX > rect.iBr.iX ) |
507 |
386 { |
508 // ----------------------------------------------------------------------------- |
387 pointerEvent.iPosition.iX = rect.iBr.iX; |
509 // CXnTextEditorAdapter::HandleScreenDeviceChangedL |
388 } |
510 // |
389 |
511 // ----------------------------------------------------------------------------- |
390 if( point.iY < rect.iTl.iY ) |
512 // |
391 { |
513 void CXnTextEditorAdapter::HandleScreenDeviceChangedL() |
392 pointerEvent.iPosition.iY = rect.iTl.iY; |
514 { |
393 } |
515 if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
394 else if( point.iY > rect.iBr.iY ) |
516 { |
395 { |
517 SetFlag( iSplitInputFlags, EScreenDeviceChanged ); |
396 pointerEvent.iPosition.iY = rect.iBr.iY; |
518 } |
397 } |
|
398 } |
|
399 |
|
400 CXnControlAdapter::HandlePointerEventL( pointerEvent ); |
|
401 } |
|
402 } |
519 } |
403 |
520 |
404 // ----------------------------------------------------------------------------- |
521 // ----------------------------------------------------------------------------- |
405 // From MCoeControlBackground |
522 // From MCoeControlBackground |
406 // CXnTextEditorAdapter::Draw |
523 // CXnTextEditorAdapter::Draw |
477 |
594 |
478 TRAP_IGNORE( text = iEditor->GetTextInHBufL() ); |
595 TRAP_IGNORE( text = iEditor->GetTextInHBufL() ); |
479 |
596 |
480 // Ownership is transfered to the calller |
597 // Ownership is transfered to the calller |
481 return text; |
598 return text; |
|
599 } |
|
600 |
|
601 // ----------------------------------------------------------------------------- |
|
602 // CXnTextEditorAdapter::HandleEditorEvent |
|
603 // ----------------------------------------------------------------------------- |
|
604 // |
|
605 void CXnTextEditorAdapter::HandleEditorEvent( TInt aReason ) |
|
606 { |
|
607 if( aReason == CXnTextEditor::KDeactivateTextEditor && |
|
608 IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
|
609 { |
|
610 iAppui->RemoveFromStack( iEditor ); |
|
611 iEditor->SetFocus( EFalse ); |
|
612 ClearFlag( iSplitInputFlags, ESplitInputEditorInStack ); |
|
613 iRefusesFocusLoss = EFalse; |
|
614 } |
482 } |
615 } |
483 |
616 |
484 // ----------------------------------------------------------------------------- |
617 // ----------------------------------------------------------------------------- |
485 // CXnTextEditorAdapter::SetPropertiesL |
618 // CXnTextEditorAdapter::SetPropertiesL |
486 // Sets text properties |
619 // Sets text properties |