50 |
52 |
51 const TInt KMaxLength = 100; |
53 const TInt KMaxLength = 100; |
52 |
54 |
53 enum TSplitInputState |
55 enum TSplitInputState |
54 { |
56 { |
55 ESplitInputDisabled = 0, |
57 ESplitInputEnabled = 1, |
56 ESplitInputClosed, |
58 ESplitInputOpen = 2, |
57 ESplitInputOpen, |
59 ESplitInputEditorInStack = 4, |
58 ESplitInputRemoveFromStack |
|
59 }; |
60 }; |
60 |
61 |
61 _LIT8( KCpsPublishing, "cpspublishing" ); |
62 _LIT8( KCpsPublishing, "cpspublishing" ); |
62 _LIT8( KMaxLineAmount, "max-line-amount" ); |
63 _LIT8( KMaxLineAmount, "max-line-amount" ); |
63 _LIT8( KMaxCharAmount, "max-char-amount" ); |
64 _LIT8( KMaxCharAmount, "max-char-amount" ); |
70 ( k == EStdKeyLeftArrow || k == EStdKeyRightArrow || \ |
71 ( k == EStdKeyLeftArrow || k == EStdKeyRightArrow || \ |
71 k == EStdKeyUpArrow || k == EStdKeyDownArrow ) |
72 k == EStdKeyUpArrow || k == EStdKeyDownArrow ) |
72 |
73 |
73 // ============================ LOCAL FUNCTIONS ================================ |
74 // ============================ LOCAL FUNCTIONS ================================ |
74 |
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TBool IsFlagSet( TInt aFlags, TInt aFlag ) |
|
80 { |
|
81 return aFlags & aFlag; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void SetFlag( TInt& aFlags, TInt aFlag ) |
|
88 { |
|
89 aFlags |= aFlag; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void ClearFlag( TInt& aFlags, TInt aFlag ) |
|
96 { |
|
97 aFlags &= ~aFlag; |
|
98 } |
|
99 |
75 // ============================ MEMBER FUNCTIONS =============================== |
100 // ============================ MEMBER FUNCTIONS =============================== |
76 |
101 |
77 // ----------------------------------------------------------------------------- |
102 // ----------------------------------------------------------------------------- |
78 // CXnTextEditorAdapter::NewL |
103 // CXnTextEditorAdapter::NewL |
79 // Symbian static 1st phase constructor |
104 // Symbian static 1st phase constructor |
181 |
216 |
182 iEditor->SetSuppressBackgroundDrawing( ETrue ); |
217 iEditor->SetSuppressBackgroundDrawing( ETrue ); |
183 |
218 |
184 // Enable partial Screen |
219 // Enable partial Screen |
185 CXnProperty* enablepartialinput( iNode.GetPropertyL( KEnablePartialInput ) ); |
220 CXnProperty* enablepartialinput( iNode.GetPropertyL( KEnablePartialInput ) ); |
186 iSplitInputState = ESplitInputDisabled; |
221 iSplitInputFlags = 0; |
187 |
222 |
188 if ( enablepartialinput && |
223 if ( enablepartialinput && |
189 enablepartialinput->StringValue() == XnPropertyNames::KTrue ) |
224 enablepartialinput->StringValue() == XnPropertyNames::KTrue ) |
190 { |
225 { |
191 iEditor->SetAknEditorFlags( EAknEditorFlagEnablePartialScreen ); |
226 iEditor->SetAknEditorFlags( EAknEditorFlagEnablePartialScreen ); |
192 iSplitInputState = ESplitInputClosed; |
227 SetFlag( iSplitInputFlags, ESplitInputEnabled ); |
193 } |
228 } |
194 |
229 |
195 iEditor->SetObserver( this ); |
230 iEditor->SetObserver( this ); |
196 |
231 |
197 // Default not focused |
232 // Default not focused |
304 // (other items were commented in a header). |
339 // (other items were commented in a header). |
305 // ----------------------------------------------------------------------------- |
340 // ----------------------------------------------------------------------------- |
306 // |
341 // |
307 void CXnTextEditorAdapter::FocusChanged( TDrawNow aDrawNow ) |
342 void CXnTextEditorAdapter::FocusChanged( TDrawNow aDrawNow ) |
308 { |
343 { |
309 CXnAppUiAdapter* appui( |
|
310 static_cast< CXnAppUiAdapter* >( iAvkonAppUi ) ); |
|
311 |
|
312 TBool isFocused( IsFocused() ? ETrue : EFalse ); |
344 TBool isFocused( IsFocused() ? ETrue : EFalse ); |
313 |
|
314 TInt value; |
345 TInt value; |
315 |
346 |
316 if ( isFocused ) |
347 if ( isFocused ) |
317 { |
348 { |
318 value = EPSAiDontForwardNumericKeysToPhone; |
349 value = EPSAiDontForwardNumericKeysToPhone; |
319 |
350 |
320 if( iSplitInputState == ESplitInputDisabled ) |
351 if( !IsFlagSet( iSplitInputFlags, ESplitInputEnabled ) ) |
321 { |
352 { |
322 TRAP_IGNORE( appui->AddToStackL( appui->View(), iEditor ) ); |
353 TRAP_IGNORE( iAppui->AddToStackL( iAppui->View(), iEditor ) ); |
323 // AddToStackL calls iEditor->SetFocus( ETrue ); |
354 // AddToStackL calls iEditor->SetFocus( ETrue ); |
324 } |
355 } |
325 else if( iSplitInputState == ESplitInputClosed ) |
356 else if( !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
326 { |
357 { |
327 iUiEngine->EnablePartialTouchInput(iNode , ETrue); |
358 TRAP_IGNORE( iAppui->AddToStackL( iAppui->View(), iEditor ) ); |
328 TRAP_IGNORE( appui->AddToStackL( appui->View(), iEditor ) ); |
359 SetFlag( iSplitInputFlags, ESplitInputEditorInStack ); |
329 iSplitInputState = ESplitInputOpen; |
|
330 } |
360 } |
331 } |
361 } |
332 else |
362 else |
333 { |
363 { |
334 value = EPSAiForwardNumericKeysToPhone; |
364 value = EPSAiForwardNumericKeysToPhone; |
335 |
365 |
336 if( iSplitInputState == ESplitInputDisabled ) |
366 if( !IsFlagSet( iSplitInputFlags, ESplitInputEnabled ) ) |
337 { |
367 { |
338 appui->RemoveFromStack( iEditor ); |
368 iAppui->RemoveFromStack( iEditor ); |
339 iEditor->SetFocus( EFalse, aDrawNow ); |
369 iEditor->SetFocus( EFalse, aDrawNow ); |
340 } |
370 } |
341 else if( iSplitInputState == ESplitInputRemoveFromStack ) |
371 |
342 { |
372 // Remove editor from stack if it has not beed removed AND split screen has been closed |
343 appui->RemoveFromStack( iEditor ); |
373 else if( IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) && |
|
374 !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
|
375 { |
|
376 iAppui->RemoveFromStack( iEditor ); |
344 iEditor->SetFocus( EFalse, aDrawNow ); |
377 iEditor->SetFocus( EFalse, aDrawNow ); |
345 iSplitInputState = ESplitInputClosed; |
378 ClearFlag( iSplitInputFlags, ESplitInputEditorInStack ); |
346 } |
379 } |
347 } |
380 } |
348 |
381 |
349 if( iSplitInputState == ESplitInputOpen ) |
382 if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
350 { |
383 { |
351 value = EPSAiDontForwardNumericKeysToPhone; |
384 value = EPSAiDontForwardNumericKeysToPhone; |
352 } |
385 } |
353 |
386 |
354 iRefusesFocusLoss = isFocused; |
387 iRefusesFocusLoss = isFocused; |
355 |
388 |
356 RProperty::Set( KPSUidAiInformation, |
389 RProperty::Set( KPSUidAiInformation, |
357 KActiveIdleForwardNumericKeysToPhone, |
390 KActiveIdleForwardNumericKeysToPhone, |
367 { |
400 { |
368 CXnControlAdapter::Draw( aRect ); |
401 CXnControlAdapter::Draw( aRect ); |
369 } |
402 } |
370 |
403 |
371 // ----------------------------------------------------------------------------- |
404 // ----------------------------------------------------------------------------- |
|
405 // CXnTextEditorAdapter::HandleResourceChange |
|
406 // |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 void CXnTextEditorAdapter::HandleResourceChange( TInt aType ) |
|
410 { |
|
411 if ( aType == KAknSplitInputEnabled ) |
|
412 { |
|
413 if( IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) && |
|
414 !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
|
415 { |
|
416 iUiEngine->EnablePartialTouchInput( iNode, ETrue ); |
|
417 SetFlag( iSplitInputFlags, ESplitInputOpen ); |
|
418 } |
|
419 } |
|
420 |
|
421 if ( aType == KAknSplitInputDisabled ) |
|
422 { |
|
423 if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
|
424 { |
|
425 iUiEngine->EnablePartialTouchInput( iNode, EFalse ); |
|
426 ClearFlag( iSplitInputFlags, ESplitInputOpen ); |
|
427 |
|
428 // If editor is not focused anymore, remove if from stack |
|
429 CXnNodePluginIf* focusedNode( NULL ); |
|
430 TRAP_IGNORE( focusedNode = iUiEngine->FocusedNodeL() ); |
|
431 if( focusedNode != &iNode && |
|
432 IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) ) |
|
433 { |
|
434 iAppui->RemoveFromStack( iEditor ); |
|
435 iEditor->SetFocus( EFalse ); |
|
436 ClearFlag( iSplitInputFlags, ESplitInputEditorInStack ); |
|
437 |
|
438 // Forward keys to phone again |
|
439 RProperty::Set( KPSUidAiInformation, |
|
440 KActiveIdleForwardNumericKeysToPhone, |
|
441 EPSAiForwardNumericKeysToPhone ); |
|
442 } |
|
443 } |
|
444 } |
|
445 CCoeControl::HandleResourceChange( aType ); |
|
446 } |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
372 // CXnTextEditorAdapter::HandleControlEventL |
449 // CXnTextEditorAdapter::HandleControlEventL |
373 // |
450 // |
374 // ----------------------------------------------------------------------------- |
451 // ----------------------------------------------------------------------------- |
375 // |
452 // |
376 void CXnTextEditorAdapter::HandleControlEventL( CCoeControl* aControl, |
453 void CXnTextEditorAdapter::HandleControlEventL( CCoeControl* aControl, |
416 // CXnTextEditorAdapter::HandleEditorEvent |
493 // CXnTextEditorAdapter::HandleEditorEvent |
417 // ----------------------------------------------------------------------------- |
494 // ----------------------------------------------------------------------------- |
418 // |
495 // |
419 void CXnTextEditorAdapter::HandleEditorEvent( TInt aReason ) |
496 void CXnTextEditorAdapter::HandleEditorEvent( TInt aReason ) |
420 { |
497 { |
421 CXnAppUiAdapter* appui( |
498 if( aReason == CXnTextEditor::KDeactivateTextEditor && |
422 static_cast< CXnAppUiAdapter* >( iAvkonAppUi ) ); |
499 IsFlagSet( iSplitInputFlags, ESplitInputOpen ) ) |
423 |
500 { |
424 switch( aReason ) |
501 iAppui->RemoveFromStack( iEditor ); |
425 { |
502 iEditor->SetFocus( EFalse ); |
426 case CXnTextEditor::KDeactivateTextEditor: |
503 ClearFlag( iSplitInputFlags, ESplitInputEditorInStack ); |
427 { |
504 iRefusesFocusLoss = EFalse; |
428 if( iSplitInputState == ESplitInputOpen ) |
505 } |
429 { |
|
430 iUiEngine->EnablePartialTouchInput(iNode, EFalse); |
|
431 iSplitInputState = ESplitInputClosed; |
|
432 appui->RemoveFromStack( iEditor ); |
|
433 iEditor->SetFocus( EFalse ); |
|
434 } |
|
435 break; |
|
436 } |
|
437 case CXnTextEditor::KRemoveSplitInputFromStack: |
|
438 { |
|
439 iSplitInputState = ESplitInputRemoveFromStack; |
|
440 break; |
|
441 } |
|
442 case CXnTextEditor::KKeepSplitInputInStack: |
|
443 { |
|
444 iSplitInputState = ESplitInputOpen; |
|
445 break; |
|
446 } |
|
447 default: |
|
448 break; |
|
449 } |
|
450 } |
506 } |
451 |
507 |
452 // ----------------------------------------------------------------------------- |
508 // ----------------------------------------------------------------------------- |
453 // CXnTextEditorAdapter::SetPropertiesL |
509 // CXnTextEditorAdapter::SetPropertiesL |
454 // Sets text properties |
510 // Sets text properties |
573 else |
629 else |
574 { |
630 { |
575 cf.iFontPresentation.iTextColor = KRgbBlack; |
631 cf.iFontPresentation.iTextColor = KRgbBlack; |
576 } |
632 } |
577 } |
633 } |
578 } |
634 } |
|
635 |
|
636 SetEditorMarginPropertiesL(); |
579 |
637 |
580 CCharFormatLayer *pCharFL = CCharFormatLayer::NewL(cf,cfm); |
638 CCharFormatLayer *pCharFL = CCharFormatLayer::NewL(cf,cfm); |
581 iEditor->SetCharFormatLayer(pCharFL); |
639 iEditor->SetCharFormatLayer(pCharFL); |
582 iEditor->SetTextBaselineSpacing( 2 ); |
640 iEditor->SetTextBaselineSpacing( 2 ); |
583 } |
641 } |
584 |
642 |
|
643 // ----------------------------------------------------------------------------- |
|
644 // CXnTextEditorAdapter::SetEditorMarginPropertiesL |
|
645 // Sets text properties |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 void CXnTextEditorAdapter::SetEditorMarginPropertiesL() |
|
649 { |
|
650 TMargins8 margins; |
|
651 |
|
652 CXnProperty* leftMarginProp( |
|
653 iNode.GetPropertyL( XnPropertyNames::texteditor::KEditorMarginLeft ) ); |
|
654 if( leftMarginProp ) |
|
655 { |
|
656 TInt leftValue = iUiEngine->HorizontalPixelValueL( leftMarginProp, |
|
657 iNode.Rect().Width() ); |
|
658 margins.iLeft = leftValue; |
|
659 } |
|
660 |
|
661 CXnProperty* rightMarginProp( |
|
662 iNode.GetPropertyL( XnPropertyNames::texteditor::KEditorMarginRight ) ); |
|
663 if( rightMarginProp ) |
|
664 { |
|
665 TInt rightValue = iUiEngine->HorizontalPixelValueL( rightMarginProp, |
|
666 iNode.Rect().Width() ); |
|
667 margins.iRight = rightValue; |
|
668 } |
|
669 |
|
670 CXnProperty* topMarginProp( |
|
671 iNode.GetPropertyL( XnPropertyNames::texteditor::KEditorMarginTop ) ); |
|
672 if( topMarginProp ) |
|
673 { |
|
674 TInt topValue = iUiEngine->VerticalPixelValueL( topMarginProp, |
|
675 iNode.Rect().Width() ); |
|
676 margins.iTop = topValue; |
|
677 } |
|
678 |
|
679 CXnProperty* bottomMarginProp( |
|
680 iNode.GetPropertyL( XnPropertyNames::texteditor::KEditorMarginBottom ) ); |
|
681 if( bottomMarginProp ) |
|
682 { |
|
683 TInt bottomValue = iUiEngine->VerticalPixelValueL( bottomMarginProp, |
|
684 iNode.Rect().Width() ); |
|
685 margins.iBottom = bottomValue; |
|
686 } |
|
687 |
|
688 iEditor->SetBorderViewMargins( margins ); |
|
689 } |
|
690 |
585 // End of file |
691 // End of file |