85 } |
85 } |
86 |
86 |
87 iEdwinUtils = CMIDEdwinUtils::NewL(this, iDecimalSeparator); |
87 iEdwinUtils = CMIDEdwinUtils::NewL(this, iDecimalSeparator); |
88 |
88 |
89 iConstraints = aConstraints; |
89 iConstraints = aConstraints; |
90 iLastCountLine = 0; |
|
91 iStrict = ETrue; |
90 iStrict = ETrue; |
92 |
91 |
93 // if text is invalid according to constraints, throw IllegalArgumentException, |
92 // if text is invalid according to constraints, throw IllegalArgumentException, |
94 // except for a PHONENUMBER which only has the invalid characters removed |
93 // except for a PHONENUMBER which only has the invalid characters removed |
95 if ((iConstraints & MMIDTextField::EConstraintMask) != MMIDTextField::EPhoneNumber |
94 if ((iConstraints & MMIDTextField::EConstraintMask) != MMIDTextField::EPhoneNumber |
454 } |
453 } |
455 |
454 |
456 void CMIDTextBoxQueryDialog::FocusChanged(TDrawNow aDrawNow) |
455 void CMIDTextBoxQueryDialog::FocusChanged(TDrawNow aDrawNow) |
457 { |
456 { |
458 CAknTextQueryDialog::FocusChanged(aDrawNow); |
457 CAknTextQueryDialog::FocusChanged(aDrawNow); |
459 SetRightScrollBarPosition(); |
458 TRAP_IGNORE(UpdateScrollBarPositionL()); |
460 } |
459 } |
461 // |
460 // |
462 // We do not want to become visible if we are not showing |
461 // We do not want to become visible if we are not showing |
463 // |
462 // |
464 void CMIDTextBoxQueryDialog::MakeVisible(TBool aVisible) |
463 void CMIDTextBoxQueryDialog::MakeVisible(TBool aVisible) |
483 { |
482 { |
484 if (iShowing) |
483 if (iShowing) |
485 { |
484 { |
486 CAknTextQueryDialog::SizeChanged(); |
485 CAknTextQueryDialog::SizeChanged(); |
487 } |
486 } |
488 if (iEditor && iEditor->ScrollBarFrame() && iEditor->ScrollBarFrame()->VerticalScrollBar()) |
487 TRAP_IGNORE(UpdateScrollBarPositionL()); |
489 { |
|
490 iEditorRect = iEditor->Rect(); |
|
491 iEditorRect.SetWidth(iEditorRect.Width() - iEditor->ScrollBarFrame()->VerticalScrollBar()->Rect().Width()); |
|
492 SetRightScrollBarPosition(); |
|
493 } |
|
494 } |
488 } |
495 |
489 |
496 TKeyResponse CMIDTextBoxQueryDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
490 TKeyResponse CMIDTextBoxQueryDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
497 { |
491 { |
498 // If midlet is closed from applications menu or by pressing end key, then |
492 // If midlet is closed from applications menu or by pressing end key, then |
660 #ifdef RD_SCALABLE_UI_V2 |
654 #ifdef RD_SCALABLE_UI_V2 |
661 if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKey || aType == EEventKeyUp) && !iEditor->IsReadOnly() && |
655 if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKey || aType == EEventKeyUp) && !iEditor->IsReadOnly() && |
662 #else |
656 #else |
663 if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKeyUp) && !iEditor->IsReadOnly() && |
657 if (IsConstraintSet(MMIDTextField::ENumeric) && (aType == EEventKeyUp) && !iEditor->IsReadOnly() && |
664 #endif // RD_SCALABLE_UI_V2 |
658 #endif // RD_SCALABLE_UI_V2 |
665 ((scanCode==EStdKeyNkpAsterisk) || (scanCode == EStdKeyMinus) || (scanCode==EStdKeyNkpMinus) || (scanCode == 0x2A) || (scanCode == 0x2D))) |
659 ((scanCode==EStdKeyNkpAsterisk) || (scanCode == EStdKeyMinus) || (scanCode==EStdKeyNkpMinus) || (scanCode == 0x2A) || (scanCode == 0x2D) || |
|
660 (TChar(aKeyEvent.iCode) == TChar('-') && scanCode != EStdKeyMinus))) |
666 { |
661 { |
667 HandleMinusCharEventL(MEikEdwinObserver::EEventTextUpdate); |
662 HandleMinusCharEventL(MEikEdwinObserver::EEventTextUpdate); |
668 return EKeyWasConsumed; |
663 return EKeyWasConsumed; |
669 } |
664 } |
670 |
665 |
686 { |
681 { |
687 res->InsertL(GetCaretPosition(), KFullStopChar); |
682 res->InsertL(GetCaretPosition(), KFullStopChar); |
688 } |
683 } |
689 |
684 |
690 iEditor->HandleTextChangedL(); // notify editor about the text changes |
685 iEditor->HandleTextChangedL(); // notify editor about the text changes |
|
686 TInt cursorPos = GetCaretPosition(); |
691 |
687 |
692 if (Size() < iMaxSize) |
688 if (Size() < iMaxSize) |
693 { |
689 { |
694 SetCursorPositionL(GetCaretPosition() + 1); |
690 SetCursorPositionL(cursorPos + 1); |
|
691 } |
|
692 else if (cursorPos == (iMaxSize - 1) && cursorPos == textLength && scanCode==EStdKeyFullStop) |
|
693 { |
|
694 SetCursorPositionL(iMaxSize); |
695 } |
695 } |
696 |
696 |
697 HandleTextUpdateL(MEikEdwinObserver::EEventTextUpdate); |
697 HandleTextUpdateL(MEikEdwinObserver::EEventTextUpdate); |
698 } |
698 } |
699 //Error tone playing case1: |
699 //Error tone playing case1: |
898 iLastMultitapKey = 0; |
898 iLastMultitapKey = 0; |
899 } |
899 } |
900 |
900 |
901 HandleTextUpdateL(MEikEdwinObserver::EEventTextUpdate); |
901 HandleTextUpdateL(MEikEdwinObserver::EEventTextUpdate); |
902 |
902 |
903 if (iEditor && iEditor->TextLayout()) |
|
904 { |
|
905 if (iLastCountLine != iEditor->TextLayout()->GetLineNumber(iEditor->TextLength() - 1)) |
|
906 { |
|
907 iLastCountLine = iEditor->TextLayout()->GetLineNumber(iEditor->TextLength() - 1); |
|
908 SetRightScrollBarPosition(); |
|
909 } |
|
910 } |
|
911 } |
903 } |
912 } |
904 } |
913 |
905 |
914 void CMIDTextBoxQueryDialog::HandleTextUpdateL(TEdwinEvent aEventType) |
906 void CMIDTextBoxQueryDialog::HandleTextUpdateL(TEdwinEvent aEventType) |
915 { |
907 { |
935 TPtr16 ptr = res->Des(); |
927 TPtr16 ptr = res->Des(); |
936 TInt minusPos = ptr.LocateReverse(TChar('-')); |
928 TInt minusPos = ptr.LocateReverse(TChar('-')); |
937 TInt pointPosL = ptr.Locate(iDecimalSeparator); |
929 TInt pointPosL = ptr.Locate(iDecimalSeparator); |
938 TInt pointPosR = ptr.LocateReverse(iDecimalSeparator); |
930 TInt pointPosR = ptr.LocateReverse(iDecimalSeparator); |
939 TInt cursorPos = GetCaretPosition(); |
931 TInt cursorPos = GetCaretPosition(); |
|
932 TInt endCursorPos = cursorPos; |
940 |
933 |
941 // check if minus sign is inserted on incorrect place |
934 // check if minus sign is inserted on incorrect place |
942 // (not at the beginning) |
935 // (not at the beginning) |
943 if ((minusPos != KErrNotFound) && (minusPos != 0)) |
936 if ((minusPos != KErrNotFound) && (minusPos != 0)) |
944 { |
937 { |
973 textChanged = ETrue; |
966 textChanged = ETrue; |
974 |
967 |
975 // Set correct cusros possition |
968 // Set correct cusros possition |
976 if (pointPosL == 0 && minusPos == pointPosL) |
969 if (pointPosL == 0 && minusPos == pointPosL) |
977 { |
970 { |
978 SetCursorPositionL(pointPosL + 1); |
971 endCursorPos = (pointPosL + 1); |
979 } |
972 } |
980 } |
973 } |
981 } |
974 } |
982 |
975 |
983 // Locate decimal separator again |
976 // Locate decimal separator again |
984 pointPosL = ptr.Locate(iDecimalSeparator); |
977 pointPosL = ptr.Locate(iDecimalSeparator); |
985 pointPosR = ptr.LocateReverse(iDecimalSeparator); |
978 pointPosR = ptr.LocateReverse(iDecimalSeparator); |
986 cursorPos = GetCaretPosition(); |
|
987 |
979 |
988 if ((minusPos != KErrNotFound) && (pointPosL == 0)) |
980 if ((minusPos != KErrNotFound) && (pointPosL == 0)) |
989 { |
981 { |
990 illegalCharPos = pointPosL; |
982 illegalCharPos = pointPosL; |
991 } |
983 } |
1007 { |
999 { |
1008 if (cursorPos == (illegalCharPos + 1)) |
1000 if (cursorPos == (illegalCharPos + 1)) |
1009 { |
1001 { |
1010 cursorPos--; |
1002 cursorPos--; |
1011 } |
1003 } |
1012 SetCursorPositionL(cursorPos); |
1004 |
|
1005 endCursorPos = cursorPos; |
1013 } |
1006 } |
1014 } |
1007 } |
|
1008 SetCursorPositionL(endCursorPos); |
1015 } |
1009 } |
1016 else if (((iConstraints & |
1010 else if (((iConstraints & |
1017 MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr) || |
1011 MMIDTextField::EConstraintMask) == MMIDTextField::EMailAddr) || |
1018 ((iConstraints & |
1012 ((iConstraints & |
1019 MMIDTextField::EConstraintMask) == MMIDTextField::EUrl)) |
1013 MMIDTextField::EConstraintMask) == MMIDTextField::EUrl)) |
1558 CAknTextQueryDialog::HandleResourceChange(aType); |
1552 CAknTextQueryDialog::HandleResourceChange(aType); |
1559 if (aType == KEikDynamicLayoutVariantSwitch || |
1553 if (aType == KEikDynamicLayoutVariantSwitch || |
1560 aType == KEikColorResourceChange || aType == KAknsMessageSkinChange || |
1554 aType == KEikColorResourceChange || aType == KAknsMessageSkinChange || |
1561 aType == KUidValueCoeColorSchemeChangeEvent) |
1555 aType == KUidValueCoeColorSchemeChangeEvent) |
1562 { |
1556 { |
1563 SetRightScrollBarPosition(); |
1557 TRAP_IGNORE(UpdateScrollBarPositionL()); |
1564 } |
1558 } |
1565 |
1559 } |
1566 } |
1560 |
1567 |
1561 /* UpdateScrollBarPositionL |
1568 void CMIDTextBoxQueryDialog::SetRightScrollBarPosition() |
1562 * |
1569 { |
1563 * This method is called for placing scrollbar to correct place in edwin |
1570 // Editor Rect should not be set with empty values |
1564 */ |
1571 if (iEditor && iEditorRect.Height() != 0 && iEditorRect.Width() != 0) |
1565 void CMIDTextBoxQueryDialog::UpdateScrollBarPositionL() |
1572 { |
1566 { |
1573 iEditor->SetRect(iEditorRect); |
1567 if(iEditor && iEditor->TextLayout()) |
|
1568 { |
|
1569 TInt numLines = iEditor->TextLayout()->NumFormattedLines(); |
|
1570 if(numLines == iEditor->MaximumHeightInLines()) |
|
1571 { |
|
1572 if(iEditor->ScrollBarFrame()) |
|
1573 { |
|
1574 iEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff); |
|
1575 } |
|
1576 } |
|
1577 else if(numLines > iEditor->MaximumHeightInLines()) |
|
1578 { |
|
1579 if(!iEditor->ScrollBarFrame()) |
|
1580 { |
|
1581 iEditor->CreatePreAllocatedScrollBarFrameL(); |
|
1582 iEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
1583 } |
|
1584 TRect editorRect = iEditor->Rect(); |
|
1585 if(iEditor->ScrollBarFrame()->VerticalScrollBar()) |
|
1586 { |
|
1587 editorRect.SetWidth(editorRect.Width() - iEditor->ScrollBarFrame()->VerticalScrollBar()->ScrollBarBreadth()); |
|
1588 iEditor->SetRect(editorRect); |
|
1589 } |
|
1590 } |
1574 } |
1591 } |
1575 } |
1592 } |
1576 // End of file |
1593 // End of file |