diff -r c8382f7b54ef -r 726fba06891a emailuis/emailui/src/ncsaddressinputfield.cpp --- a/emailuis/emailui/src/ncsaddressinputfield.cpp Wed Sep 15 11:52:37 2010 +0300 +++ b/emailuis/emailui/src/ncsaddressinputfield.cpp Wed Oct 13 14:11:15 2010 +0300 @@ -33,7 +33,6 @@ #include #include #include -#include #include "FreestyleEmailUiAppui.h" #include "FreestyleEmailUiLayoutData.h" @@ -45,7 +44,6 @@ #include "ncsutility.h" #include "ncsheadercontainer.h" #include "txtrich.h" -#include "freestyleemailcenrepkeys.h" // --------------------------------------------------------------------------- // constructor @@ -92,22 +90,23 @@ // ----------------------------------------------------------------------------- // void CNcsAddressInputField::ConstructL( TInt aLabelTextId ) - { + { FUNC_LOG; - // Create label - //Load the label string - HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId ); + // Create label + //Load the label string + HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId ); - TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC(); - CreateControlsL( captionText ); - - iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver, captionText ); + TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC(); + CreateControlsL( captionText ); + + iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver, + captionText ); // iTextEditor is not completely constructed until in SetContainerWindowL() - iTextEditor->SetPopupList(iAddressPopupList); + iTextEditor->SetPopupList(iAddressPopupList); - CleanupStack::PopAndDestroy( aTextBuf ); - } + CleanupStack::PopAndDestroy( aTextBuf ); + } // --------------------------------------------------------------------------- // Destructor @@ -119,8 +118,15 @@ delete iTextEditor; delete iButton; delete iLabel; +// Platform layout change + /*if ( iFont ) + { + ControlEnv()->ScreenDevice()->ReleaseFont( iFont ); + iFont = NULL; + }*/ } +// // ----------------------------------------------------------------------------- // CNcsHeaderContainer::CreateControlsL() // ----------------------------------------------------------------------------- @@ -148,6 +154,7 @@ iLabel->SetBrushStyle(CWindowGc::ENullBrush); } } +// // --------------------------------------------------------------------------- // SetContainerWindow @@ -160,51 +167,39 @@ FUNC_LOG; CCoeControl::SetContainerWindowL(aContainer); - InitComponentArrayL(); - // Check if we need to construct the components - if (Components().Count() == 2) return; + InitComponentArrayL(); + // Check if we need to construct the components + if (Components().Count() == 2) return; - // Load the controls into the compoent array - CCoeControlArray& controls = Components(); - controls.SetControlsOwnedExternally(ETrue); - // - if( iButton ) - { - controls.AppendLC( iButton ); - CleanupStack::Pop( iButton ); - } - else - { - controls.AppendLC( iLabel ); - CleanupStack::Pop( iLabel ); - } - - controls.AppendLC(iTextEditor); + // Load the controls into the compoent array + CCoeControlArray& controls = Components(); + controls.SetControlsOwnedExternally(ETrue); + // + if( iButton ) + { + controls.AppendLC( iButton ); + CleanupStack::Pop( iButton ); + } + else + { + controls.AppendLC( iLabel ); + CleanupStack::Pop( iLabel ); + } + // + controls.AppendLC(iTextEditor); CleanupStack::Pop(iTextEditor); - // Setup the text editor - iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 ); +// + + // Setup the text editor + iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 ); +// iTextEditor->SetBorder( TGulBorder::ENone ); - iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode ); - iTextEditor->SetAknEditorFlags( EAknEditorFlagNoT9 | EAknEditorFlagUseSCTNumericCharmap ); - - CRepository* repository = NULL; - TRAPD( err, repository = CRepository::NewL( KFreestyleEmailCenRep ) ); - if ( !err ) - { - TInt value( 0 ); - err = repository->Get( KEmailFeatureSplitScreen, value ); - if( !err && value ) - { - iTextEditor->SetAknEditorFlags( iTextEditor->AknEditorFlags() | EAknEditorFlagEnablePartialScreen ); - } - } - delete repository; - repository = NULL; - - iTextEditor->SetAknEditorCurrentCase( EAknEditorLowerCase ); - iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); + iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode ); + iTextEditor->SetAknEditorFlags( EAknEditorFlagNoT9 | EAknEditorFlagUseSCTNumericCharmap ); + iTextEditor->SetAknEditorCurrentCase( EAknEditorLowerCase ); + iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); iTextEditor->SetEdwinSizeObserver( this ); iTextEditor->SetupEditorL(); @@ -254,27 +249,27 @@ // ----------------------------------------------------------------------------- // void CNcsAddressInputField::SizeChanged() - { + { FUNC_LOG; - TRect rect = Rect(); - - if( AknLayoutUtils::PenEnabled() ) - { - LayoutTouch(); - } - else - { - LayoutNonTouch(); - } + TRect rect = Rect(); + + if( AknLayoutUtils::PenEnabled() ) + { + LayoutTouch(); + } + else + { + LayoutNonTouch(); + } // This needs to be bidi as in mirrored layout // writing language left to right can be set. // Need to set here as layout sets it also to left or right. iTextEditor->SetAlignment( EAknEditorAlignBidi ); - + UpdateFontSize(); - + if (iTextEditor->ScrollBarFrame()) { TRect rc = iTextEditor->Rect(); @@ -288,37 +283,38 @@ } iTextEditor->SetRect(rc); } - + PositionChanged(); - } + } // ----------------------------------------------------------------------------- // CNcsHeaderContainer::PositionChanged() // set size // ----------------------------------------------------------------------------- void CNcsAddressInputField::PositionChanged() - { + { FUNC_LOG; - + // keep the button in view as long as possible if( iButton && iParentControl->IsVisible() ) - { - const TRect rect( Rect() ); - const TRect buttonRect( iButton->Rect() ); - - TInt newButtonPos( iOriginalButtonPos.iY - iOriginalFieldPos.iY ); + { + const TRect rect( Rect() ); + const TRect buttonRect( iButton->Rect() ); + + TInt newButtonPos( iOriginalButtonPos.iY - iOriginalFieldPos.iY ); + + if( rect.iTl.iY < 0 && newButtonPos + buttonRect.Height() < rect.iBr.iY ) + { + iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos) ); + } + else + { + iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos + rect.iTl.iY) ); + } + } + } - if( rect.iTl.iY < 0 && newButtonPos + buttonRect.Height() < rect.iBr.iY ) - { - iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos) ); - } - else - { - iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos + rect.iTl.iY) ); - } - } - } - +// // ----------------------------------------------------------------------------- // CNcsAddressInputField::LayoutNonTouch() // @@ -348,7 +344,7 @@ iTextEditor->UpdateCustomDrawer(); } - + // ----------------------------------------------------------------------------- // CNcsAddressInputField::HandlePointerEventL() // Handles pointer events @@ -356,33 +352,37 @@ // void CNcsAddressInputField::HandlePointerEventL( const TPointerEvent& aPointerEvent ) { - FUNC_LOG; - CCoeControl::HandlePointerEventL( aPointerEvent ); - - switch ( aPointerEvent.iType ) + FUNC_LOG; + iTextEditor->HandlePointerEventL(aPointerEvent); + if( iButton ) { - case TPointerEvent::EButton1Down: - { + iButton->HandlePointerEventL( aPointerEvent ); + } + + switch( aPointerEvent.iType ) + { + case TPointerEvent::EButton1Down: + { // Save start position so that it can be used in // drag/scrolling calculations iStartPosition = aPointerEvent.iPosition; iIsDraggingStarted = EFalse; break; - } - - case TPointerEvent::EDrag: - { + } + + case TPointerEvent::EDrag: + { if ( !iIsDraggingStarted && iPhysics ) { TInt drag( iStartPosition.iY - aPointerEvent.iPosition.iY ); if ( Abs( drag ) > iPhysics->DragThreshold() ) { - iIsDraggingStarted = ETrue; + iIsDraggingStarted = ETrue; } } break; - } - } + } + } } // ----------------------------------------------------------------------------- @@ -400,6 +400,7 @@ } } } +// // ----------------------------------------------------------------------------- // CNcsAddressInputField::OfferKeyEventL() @@ -408,22 +409,22 @@ // TKeyResponse CNcsAddressInputField::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) - { + { FUNC_LOG; - TKeyResponse ret( EKeyWasNotConsumed ); + TKeyResponse ret( EKeyWasNotConsumed ); - if( aKeyEvent.iCode == EKeyOK ) - { - iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ); - iTextEditor->UpdateAddressListAllL(); - } - else - { - ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType ); - } + if( aKeyEvent.iCode == EKeyOK ) + { + iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ); + iTextEditor->UpdateAddressListAllL(); + } + else + { + ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType ); + } - return ret; - } + return ret; + } // ----------------------------------------------------------------------------- // CNcsAddressInputField::FocusChanged() @@ -436,6 +437,30 @@ { iTextEditor->SetFocus( ETrue, aDrawNow ); //TRAP_IGNORE( iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ) ); + + // make sure that control is visible on screen + if ( Rect().iTl.iY < 0 ) + { + TPoint pt = TPoint( 0, 0 ); + Reposition( pt,Rect().Width() ); + iSizeObserver->UpdateFieldPosition( this ); + } + else + { + TPoint pos = PositionRelativeToScreen(); + pos.iY += Size().iHeight; + CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice(); + TPixelsAndRotation pix; + screenDev->GetDefaultScreenSizeAndRotation( pix ); + const TInt h = pix.iPixelSize.iHeight; + if ( pos.iY >= h - h / 3 ) + { + TPoint pt = TPoint( 0, h / 3 ); + Reposition( pt,Rect().Width() ); + iSizeObserver->UpdateFieldPosition( this ); + } + } + if ( iParentControl ) { TRAP_IGNORE( iParentControl->SetMskL() ); @@ -728,10 +753,10 @@ // CNcsAddressInputField::GetLineRectL() // ----------------------------------------------------------------------------- // -void CNcsAddressInputField::GetLineRect( TRect& aLineRect ) const +void CNcsAddressInputField::GetLineRectL( TRect& aLineRect ) const { FUNC_LOG; - return iTextEditor->GetLineRect( aLineRect ); + return iTextEditor->GetLineRectL( aLineRect ); } // -----------------------------------------------------------------------------