36 #include <CommonContentPolicy.h> |
36 #include <CommonContentPolicy.h> |
37 #include <StringLoader.h> |
37 #include <StringLoader.h> |
38 #include <centralrepository.h> |
38 #include <centralrepository.h> |
39 #include <CommonUiInternalCRKeys.h> |
39 #include <CommonUiInternalCRKeys.h> |
40 #include <akntitle.h> |
40 #include <akntitle.h> |
|
41 #include <touchfeedback.h> |
41 |
42 |
42 #include <NpdLib.rsg> |
43 #include <NpdLib.rsg> |
43 #include "NpdLib.hrh" |
44 #include "NpdLib.hrh" |
44 #include <finditem.hrh> |
45 #include <finditem.hrh> |
45 #include <CMessageData.h> |
46 #include <CMessageData.h> |
232 NotepadUtil::LoadFileL( *iCoeEnv, *iFilename, iGuessEncoding, |
234 NotepadUtil::LoadFileL( *iCoeEnv, *iFilename, iGuessEncoding, |
233 iEncoding, *(iEditor->Text()) ); |
235 iEncoding, *(iEditor->Text()) ); |
234 iEditor->SetAmountToFormat(iEditor->Text()->DocumentLength()); |
236 iEditor->SetAmountToFormat(iEditor->Text()->DocumentLength()); |
235 iEditor->HandleTextChangedL(); |
237 iEditor->HandleTextChangedL(); |
236 iAutoFinder->SetEditor((CEikRichTextEditor**)&iEditor); |
238 iAutoFinder->SetEditor((CEikRichTextEditor**)&iEditor); |
237 |
239 iAutoFinder->SetItemFinderObserverL( this ); |
238 RefreshTitleL(); |
240 RefreshTitleL(); |
239 } |
241 } |
240 |
242 |
241 // ----------------------------------------------------------------------------- |
243 // ----------------------------------------------------------------------------- |
242 // CNotepadViewerDialog::LoadFileL file handle |
244 // CNotepadViewerDialog::LoadFileL file handle |
250 TBool error = NotepadUtil::LoadFileL( *iCoeEnv, aFile, iGuessEncoding, |
252 TBool error = NotepadUtil::LoadFileL( *iCoeEnv, aFile, iGuessEncoding, |
251 iEncoding, *(iEditor->Text()) ); |
253 iEncoding, *(iEditor->Text()) ); |
252 iEditor->SetAmountToFormat(iEditor->Text()->DocumentLength()); |
254 iEditor->SetAmountToFormat(iEditor->Text()->DocumentLength()); |
253 iEditor->HandleTextChangedL(); |
255 iEditor->HandleTextChangedL(); |
254 iAutoFinder->SetEditor((CEikRichTextEditor**)&iEditor); |
256 iAutoFinder->SetEditor((CEikRichTextEditor**)&iEditor); |
255 |
257 iAutoFinder->SetItemFinderObserverL( this ); |
256 RefreshTitleL(); |
258 RefreshTitleL(); |
257 if( error != KErrNone) |
259 if( error != KErrNone) |
258 { |
260 { |
259 |
261 |
260 HBufC* text = StringLoader::LoadLC(R_NOTEPAD_QTN_FILE_CORRUPTED); |
262 HBufC* text = StringLoader::LoadLC(R_NOTEPAD_QTN_FILE_CORRUPTED); |
528 iEditor->SetTextL(NULL); |
532 iEditor->SetTextL(NULL); |
529 iEditor->SetTextL(&iContent); |
533 iEditor->SetTextL(&iContent); |
530 iEditor->SetAmountToFormat(iContent.Length()); // Will ensure first Format in SetTextL is in correct mode |
534 iEditor->SetAmountToFormat(iContent.Length()); // Will ensure first Format in SetTextL is in correct mode |
531 iEditor->HandleTextChangedL(); |
535 iEditor->HandleTextChangedL(); |
532 iAutoFinder->SetEditor((CEikRichTextEditor**)&iEditor); |
536 iAutoFinder->SetEditor((CEikRichTextEditor**)&iEditor); |
|
537 iAutoFinder->SetItemFinderObserverL( this ); |
533 RefreshTitleL(); |
538 RefreshTitleL(); |
|
539 iEditor->EnableKineticScrollingL( ETrue ); |
534 } |
540 } |
535 } |
541 } |
536 |
542 |
537 // ----------------------------------------------------------------------------- |
543 // ----------------------------------------------------------------------------- |
538 // CNotepadViewerDialog::OfferKeyEventL |
544 // CNotepadViewerDialog::OfferKeyEventL |
575 keyResponse = CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
581 keyResponse = CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
576 } |
582 } |
577 |
583 |
578 return keyResponse; |
584 return keyResponse; |
579 } |
585 } |
|
586 void CNotepadViewerDialog::HandleFindItemEventL( |
|
587 const CItemFinder::CFindItemExt& aItem, |
|
588 MAknItemFinderObserver::TEventFlag aEvent, |
|
589 TUint aFlags) |
|
590 { |
|
591 if ( MAknItemFinderObserver::EPointerEvent == aEvent ) |
|
592 { |
|
593 iFlags |= ENotepadMenuByOkKey; |
|
594 } |
|
595 iFlags |= EMenuByItemActication; |
|
596 } |
580 // ----------------------------------------------------------------------------- |
597 // ----------------------------------------------------------------------------- |
581 // CNotepadViewerDialog::HandleDialogPointerEventL |
598 // CNotepadViewerDialog::HandleDialogPointerEventL |
582 // from CoeControl |
599 // from CoeControl |
583 // ----------------------------------------------------------------------------- |
600 // ----------------------------------------------------------------------------- |
584 // |
601 // |
586 { |
603 { |
587 if(!AknLayoutUtils::PenEnabled()) |
604 if(!AknLayoutUtils::PenEnabled()) |
588 { |
605 { |
589 return; |
606 return; |
590 } |
607 } |
591 |
608 if( CItemFinder::ENoneSelected == iAutoFinder->CurrentItemExt().iItemType ) |
592 if( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
609 { |
593 { |
610 // when you selected is not item, return |
594 TRect rect = iEditor->Rect(); |
611 return; |
595 if ( !iAutoFinder->ItemWasTappedL( aPointerEvent.iPosition - rect.iTl ) ) |
612 } |
596 { |
613 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
597 return; |
614 TTouchLogicalFeedback fbLogicalType; |
598 } |
615 TTouchFeedbackType fbType; |
599 |
616 switch( aPointerEvent.iType ) |
600 DisplayMenuL(); |
617 { |
601 } |
618 case TPointerEvent::EButton1Down: |
|
619 { |
|
620 fbLogicalType = ETouchFeedbackBasic; |
|
621 fbType = TTouchFeedbackType( ETouchFeedbackAudio|ETouchFeedbackVibra ); |
|
622 } |
|
623 break; |
|
624 case TPointerEvent::EButton1Up: |
|
625 { |
|
626 fbLogicalType = ETouchFeedbackIncreasingPopUp; |
|
627 fbType = ETouchFeedbackVibra; |
|
628 } |
|
629 break; |
|
630 default: |
|
631 return; |
|
632 } |
|
633 if ( feedback ) |
|
634 { |
|
635 feedback->InstantFeedback( this, |
|
636 fbLogicalType, fbType, TPointerEvent() ); |
|
637 if( ETouchFeedbackVibra == fbType ) |
|
638 { |
|
639 DisplayMenuL(); |
|
640 } |
|
641 } |
602 } |
642 } |
603 |
643 |
604 // ----------------------------------------------------------------------------- |
644 // ----------------------------------------------------------------------------- |
605 // CNotepadViewerDialog::HandleNumberCallL |
645 // CNotepadViewerDialog::HandleNumberCallL |
606 // ----------------------------------------------------------------------------- |
646 // ----------------------------------------------------------------------------- |
687 break; |
727 break; |
688 default: |
728 default: |
689 { |
729 { |
690 if ( iFindMenu->CommandIsValidL(aCommandId) ) // can't really leave |
730 if ( iFindMenu->CommandIsValidL(aCommandId) ) // can't really leave |
691 { |
731 { |
|
732 TBool selectionVisibility ( ETrue ); |
|
733 if ( aCommandId == EFindItemCmdCopy && iAutoFinder && iEditor && iEditor->TextView() ) |
|
734 { |
|
735 selectionVisibility = iEditor->TextView()->SelectionVisible(); |
|
736 iEditor->TextView()->SetSelectionVisibilityL( EFalse ); |
|
737 const CItemFinder::CFindItemExt& item = iAutoFinder->CurrentItemExt(); |
|
738 iEditor->SetSelectionL( item.iStart, item.iEnd + 1 ); |
|
739 } |
|
740 |
692 iFindMenu->HandleItemFinderCommandL(aCommandId); |
741 iFindMenu->HandleItemFinderCommandL(aCommandId); |
|
742 |
|
743 if ( aCommandId == EFindItemCmdCopy && iAutoFinder && iEditor && iEditor->TextView() ) |
|
744 { |
|
745 iEditor->TextView()->SetSelectionVisibilityL( selectionVisibility ); |
|
746 iEditor->ClearSelectionL(); |
|
747 iEditor->DrawDeferred(); // sometimes editor does not update itself |
|
748 } |
|
749 |
693 return; |
750 return; |
694 } |
751 } |
695 CNotepadDialogBase::ProcessCommandL(aCommandId); |
752 CNotepadDialogBase::ProcessCommandL(aCommandId); |
696 break; |
753 break; |
697 } |
754 } |
708 CEikMenuPane* aMenuPane ) |
765 CEikMenuPane* aMenuPane ) |
709 { |
766 { |
710 __ASSERT_DEBUG(aResourceId > 0, Panic(ENotepadLibraryPanicNoMenuResource)); |
767 __ASSERT_DEBUG(aResourceId > 0, Panic(ENotepadLibraryPanicNoMenuResource)); |
711 __ASSERT_DEBUG(aMenuPane, Panic(ENotepadLibraryPanicNullMenuPane)); |
768 __ASSERT_DEBUG(aMenuPane, Panic(ENotepadLibraryPanicNullMenuPane)); |
712 __ASSERT_DEBUG(iEditor, Panic(ENotepadLibraryPanicNoEdwin)); |
769 __ASSERT_DEBUG(iEditor, Panic(ENotepadLibraryPanicNoEdwin)); |
|
770 |
|
771 const TBool activatedByItemActication = iFlags & EMenuByItemActication; |
|
772 if ( !activatedByItemActication && iEditor && iAutoFinder |
|
773 && iEditor->SelectionLength() != |
|
774 ( iAutoFinder->CurrentItemExt().iEnd - |
|
775 iAutoFinder->CurrentItemExt().iStart + 1 ) ) |
|
776 { |
|
777 iAutoFinder->ResetCurrentItem(); // do not show item specific commands |
|
778 } |
|
779 |
713 TInt index; |
780 TInt index; |
714 switch ( aResourceId ) |
781 switch ( aResourceId ) |
715 { |
782 { |
716 case R_SENDUI_MENU: |
783 case R_SENDUI_MENU: |
717 index = 2; |
784 index = 2; |