diff -r 0396474f30f5 -r 4ce476e64c59 meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrlocationfield.cpp --- a/meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrlocationfield.cpp Mon Mar 15 12:39:10 2010 +0200 +++ b/meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrlocationfield.cpp Wed Mar 31 21:08:33 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,34 +12,37 @@ * Contributors: * * Description : ESMR location field implementation - * Version : %version: tr1sido#10 % + * Version : %version: e002sa33#52 % * */ -#include "emailtrace.h" + #include "cesmrlocationfield.h" - -// SYSTEM INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// INCLUDES #include "esmrfieldbuilderdef.h" #include "cesmreditor.h" #include "cesmrfeaturesettings.h" #include "esmrhelper.h" -#include "cesmrborderlayer.h" #include "mesmrfieldevent.h" #include "cesmrgenericfieldevent.h" -#include "cesmrlayoutmgr.h" #include "cesmrglobalnote.h" +#include "cmrbutton.h" +#include "cmrlabel.h" +#include "cmrimage.h" +#include "nmrlayoutmanager.h" +#include "nmrbitmapmanager.h" +#include "cmrstyluspopupmenu.h" +#include "mesmrlistobserver.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "emailtrace.h" +#include "esmrconfig.hrh" // ======== MEMBER FUNCTIONS ======== @@ -47,29 +50,119 @@ // CESMRLocationField::NewL // --------------------------------------------------------------------------- // -CESMRLocationField* CESMRLocationField::NewL( ) +CESMRLocationField* CESMRLocationField::NewL() { FUNC_LOG; CESMRLocationField* self = new (ELeave) CESMRLocationField; - CleanupStack::PushL ( self ); - self->ConstructL ( ); - CleanupStack::Pop ( self ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); return self; } // --------------------------------------------------------------------------- +// CESMRLocationField::CESMRLocationField +// --------------------------------------------------------------------------- +// +CESMRLocationField::CESMRLocationField() + { + FUNC_LOG; + SetFieldId( EESMRFieldLocation ); + SetFocusType( EESMRHighlightFocus ); + } + +// --------------------------------------------------------------------------- +// CESMRLocationField::ConstructL +// --------------------------------------------------------------------------- +// +void CESMRLocationField::ConstructL() + { + FUNC_LOG; + + iFieldButton = CMRButton::NewL( NMRBitmapManager::EMRBitmapLocation ); + iFieldButton->SetParent( this ); + + iTitle = CMRLabel::NewL(); + iTitle->SetParent( this ); + HBufC* title = StringLoader::LoadLC( + R_MEET_REQ_OPTIONS_ADD_LOCATION, + iCoeEnv ); + iTitle->SetTextL( *title ); + CleanupStack::PopAndDestroy( title ); + + iLocation = CESMREditor::NewL( this, + 1, + KMaxTextLength, //from ICAL spec. + // do not change. other text fields do not + // have this limitation + CEikEdwin::EResizable | + CEikEdwin::EAvkonEditor ); + + CESMRField::ConstructL( iLocation ); //ownership transfered + + iLocation->SetEdwinSizeObserver( this ); + iLocation->SetEdwinObserver( this ); + iLocation->SetParent( this ); + + HBufC* buf = StringLoader::LoadLC( R_QTN_MEET_REQ_LOCATION_FIELD, iCoeEnv ); + iLocation->SetDefaultTextL( buf ); // ownership is transferred + CleanupStack::Pop( buf ); + + // Setting background instead of theme skin + NMRBitmapManager::TMRBitmapStruct bitmapStruct; + bitmapStruct = NMRBitmapManager::GetBitmapStruct( NMRBitmapManager::EMRBitmapInputCenter ); + + TRect initialisationRect( 0, 0, 0, 0 ); + iBgControlContext = CAknsBasicBackgroundControlContext::NewL( + bitmapStruct.iItemId, + initialisationRect, + EFalse ); + + iLocation->SetSkinBackgroundControlContextL( iBgControlContext ); + } + + +// --------------------------------------------------------------------------- // CESMRLocationField::~CESMRLocationField // --------------------------------------------------------------------------- // -CESMRLocationField::~CESMRLocationField( ) +CESMRLocationField::~CESMRLocationField() { FUNC_LOG; - delete iIcon; + delete iFieldButton; delete iWaypointIcon; - delete iWaypointIconMask; - delete iFrameBgContext; delete iFeatures; delete iLocationText; + delete iBgControlContext; + delete iMenu; + delete iTitle; + } + +// --------------------------------------------------------------------------- +// CESMRLocationField::MinimumSize +// --------------------------------------------------------------------------- +// +TSize CESMRLocationField::MinimumSize() + { + TRect parentRect( Parent()->Rect() ); + + TRect richTextRect = + NMRLayoutManager::GetFieldLayoutRect( parentRect, 1 ).Rect(); + + TRect textRect( NMRLayoutManager::GetLayoutText( + richTextRect, + NMRLayoutManager::EMRTextLayoutTextEditor ).TextRect() ); + + // Adjust field size so that there's room for expandable editor. + richTextRect.Resize( 0, iSize.iHeight - textRect.Height() ); + + // Add title area to the required size + TSize titleSize( CESMRField::MinimumSize() ); + + TSize completeFieldSize( titleSize ); + completeFieldSize.iHeight += richTextRect.Height(); + + return completeFieldSize; } // --------------------------------------------------------------------------- @@ -79,10 +172,7 @@ void CESMRLocationField::InitializeL() { FUNC_LOG; - iLocation->SetFontL( iLayout->Font(iCoeEnv, iFieldId ), iLayout ); - AknLayoutUtils::OverrideControlColorL( *iLocation, - EColorControlBackground, - iLayout->NormalTextBgColor() ); + // Do nothing } // --------------------------------------------------------------------------- @@ -104,6 +194,12 @@ CleanupStack::PopAndDestroy( location ); + // If the geo value has been set, the waypoint icon has to be shown on right + // side of the location field + CCalGeoValue* geoValue = aEntry.Entry().GeoValueL(); + TReal dummy; + SetWaypointIconL( geoValue && geoValue->GetLatLong( dummy, dummy ) ); + // this is needed to be re-called here, otherwise the CEikEdwin // does not get correctly instantiated with default text iLocation->FocusChanged( EDrawNow ); @@ -125,12 +221,18 @@ // externalize the text only if it differs from the // default text. In other words, default text is not // externalized. - HBufC* defaultText = StringLoader::LoadLC( R_QTN_MEET_REQ_LOCATION_FIELD ); + HBufC* defaultText = StringLoader::LoadLC( + R_QTN_MEET_REQ_LOCATION_FIELD, + iCoeEnv ); if ( defaultText->Compare( *loc ) != 0 ) { CCalEntry& entry = aEntry.Entry(); entry.SetLocationL( *loc ); } + else if ( !iWaypointIcon ) + { + aEntry.Entry().ClearGeoValueL(); + } CleanupStack::PopAndDestroy( defaultText ); CleanupStack::PopAndDestroy( loc ); @@ -139,6 +241,7 @@ { CCalEntry& entry = aEntry.Entry(); entry.SetLocationL( KNullDesC ); + entry.ClearGeoValueL(); } } @@ -150,7 +253,7 @@ { FUNC_LOG; CESMRField::SetOutlineFocusL ( aFocus ); - + if ( FeaturesL().FeatureSupported( CESMRFeatureSettings::EESMRUILocationFeatures ) ) { @@ -166,16 +269,18 @@ iLocationText = NULL; } iLocationText = iLocation->GetTextInHBufL(); - - HBufC* defaultText = StringLoader::LoadLC( R_QTN_MEET_REQ_LOCATION_FIELD ); - + + HBufC* defaultText = StringLoader::LoadLC( + R_QTN_MEET_REQ_LOCATION_FIELD, + iCoeEnv ); + if ( iLocationText && iLocationText->Compare( *defaultText ) != 0 ) { // Create field change event CESMRGenericFieldEvent* event = CESMRGenericFieldEvent::NewLC( this, MESMRFieldEvent::EESMRFieldChangeEvent ); - + // Add this field as parameter TInt fieldId = iFieldId; CESMRFieldEventValue* field = CESMRFieldEventValue::NewLC( @@ -183,7 +288,7 @@ &fieldId ); event->AddParamL( field ); CleanupStack::Pop( field ); - + // Add new value as parameter CESMRFieldEventValue* value = CESMRFieldEventValue::NewLC( CESMRFieldEventValue::EESMRString, @@ -192,7 +297,7 @@ // Encapsulate value, so receiver gets the field value type event->AddParamL( value, ETrue ); CleanupStack::Pop( value ); - + // Send event NotifyEventAsyncL( event ); CleanupStack::Pop( event ); @@ -203,16 +308,6 @@ } // --------------------------------------------------------------------------- -// CESMRLocationField::ExpandedHeight -// --------------------------------------------------------------------------- -// -TInt CESMRLocationField::ExpandedHeight( ) const - { - FUNC_LOG; - return iSize.iHeight; - } - -// --------------------------------------------------------------------------- // CESMRLocationField::HandleEdwinSizeEventL // --------------------------------------------------------------------------- // @@ -220,28 +315,29 @@ TEdwinSizeEvent /*aType*/, TSize aSize ) { FUNC_LOG; - TBool ret( EFalse ); - - TSize newSize = CalculateEditorSize( aSize ); + TBool reDraw( EFalse ); + + if( iSize != aSize ) + { + // Let's save the required size for the iLocation + iSize = aSize; - if ( aEdwin == iLocation && iSize != newSize ) - { - iSize = newSize; + if ( iObserver && aEdwin == iLocation ) + { + iObserver->ControlSizeChanged( this ); + reDraw = ETrue; + } - if ( iObserver && aEdwin->IsFocused() ) + if( iLocation->LineCount() != iLineCount ) { - iObserver->ControlSizeChanged (this ); + // Line count has changed, the whole component needs + // to be redrawn + DrawDeferred(); + iLineCount = iLocation->LineCount(); } + } - if ( iFrameBgContext ) - { - TRect visibleRect = CalculateVisibleRect( iLocation->Rect() ); - iFrameBgContext->SetFrameRects( visibleRect, visibleRect ); - } - - ret = ETrue; - } - return ret; + return reDraw; } // --------------------------------------------------------------------------- @@ -249,110 +345,30 @@ // --------------------------------------------------------------------------- // void CESMRLocationField::HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType) - { + { FUNC_LOG; if ( aEdwin == iLocation && aEventType == EEventTextUpdate ) { - HBufC* text = iLocation->GetTextInHBufL(); - if ( text ) + TInt textLength( iLocation->TextLength() ); + + if ( iLocation->GetLimitLength() <= textLength ) { - CleanupStack::PushL( text ); - TInt textLength( text->Length() ); - if ( iLocation->GetLimitLength() <= textLength ) - { - NotifyEventAsyncL( EESMRCmdSizeExceeded ); - } - CleanupStack::PopAndDestroy( text ); + NotifyEventAsyncL( EESMRCmdSizeExceeded ); } - } - } -// --------------------------------------------------------------------------- -// CESMRLocationField::CESMRLocationField -// --------------------------------------------------------------------------- -// -CESMRLocationField::CESMRLocationField() - : iSize( TSize( 0, 0 ) ) - { - FUNC_LOG; - //do nothing - } - -// --------------------------------------------------------------------------- -// CESMRLocationField::ActivateL -// --------------------------------------------------------------------------- -// -void CESMRLocationField::ActivateL() - { - FUNC_LOG; - CCoeControl::ActivateL(); - TRect rect( iLocation->Rect() ); - TRect inner(rect); - TRect outer(rect); - - delete iFrameBgContext; - iFrameBgContext = NULL; - iFrameBgContext = CAknsFrameBackgroundControlContext::NewL( - KAknsIIDQsnFrInput, - outer, - inner, - EFalse ) ; - - iFrameBgContext->SetParentContext( iBackground ); - iLocation->SetSkinBackgroundControlContextL( iFrameBgContext ); - } - - -// --------------------------------------------------------------------------- -// CESMRLocationField::PositionChanged() -// --------------------------------------------------------------------------- -// -void CESMRLocationField::PositionChanged() - { - FUNC_LOG; - CCoeControl::PositionChanged(); - - if ( iFrameBgContext ) - { - TRect visibleRect = CalculateVisibleRect( iLocation->Rect() ); - iFrameBgContext->SetFrameRects( visibleRect, visibleRect ); + else if ( iWaypointIcon && textLength == 0 ) + { + SetWaypointIconL( EFalse ); + NotifyEventL( EESMRCmdDisableWaypointIcon ); + } } } // --------------------------------------------------------------------------- -// CESMRLocationField::ConstructL +// CESMRLocationField::GetCursorLineVerticalPos // --------------------------------------------------------------------------- // -void CESMRLocationField::ConstructL() +void CESMRLocationField::GetCursorLineVerticalPos(TInt& aUpper, TInt& aLower) { - FUNC_LOG; - SetFieldId( EESMRFieldLocation ); - SetExpandable(); - - iLocation = CESMREditor::NewL( this, - 1, - KMaxTextLength, //from ICAL spec. - // do not change. other text fields do not - // have this limitation - CEikEdwin::EResizable | - CEikEdwin::EAvkonEditor ); - - iLocation->SetEdwinSizeObserver( this ); - iLocation->SetEdwinObserver( this ); - - HBufC* buf = StringLoader::LoadLC( R_QTN_MEET_REQ_LOCATION_FIELD ); - iLocation->SetDefaultTextL( buf ); // ownership is transferred - CleanupStack::Pop( buf ); - - CESMRIconField::ConstructL( KAknsIIDQgnMeetReqIndiLocation, iLocation ); - } - -// --------------------------------------------------------------------------- -// CESMRLocationField::GetMinimumVisibleVerticalArea -// --------------------------------------------------------------------------- -// -void CESMRLocationField::GetMinimumVisibleVerticalArea(TInt& aUpper, TInt& aLower) - { - FUNC_LOG; aLower = iLocation->CurrentLineNumber() * iLocation->RowHeight(); aUpper = aLower - iLocation->RowHeight(); } @@ -378,63 +394,27 @@ { iFeatures = CESMRFeatureSettings::NewL(); } - + return *iFeatures; } // --------------------------------------------------------------------------- -// CESMRCheckbox::SetWaypointIconL +// CESMRLocationField::SetWaypointIconL // --------------------------------------------------------------------------- // void CESMRLocationField::SetWaypointIconL( TBool aEnabled ) { - FUNC_LOG; - delete iIcon; - iIcon = NULL; delete iWaypointIcon; iWaypointIcon = NULL; - delete iWaypointIconMask; - iWaypointIconMask = NULL; - - if( aEnabled ) - { - TAknsItemID iconID; - TInt fileIndex(-1); - TInt fileMaskIndex(-1); - iconID = KAknsIIDQgnPropBlidWaypoint; - CESMRLayoutManager::SetBitmapFallback( iconID, - fileIndex, - fileMaskIndex ); - - TFileName bitmapFilePath; - ESMRHelper::LocateResourceFile( - KESMRMifFile, - KDC_APP_BITMAP_DIR, - bitmapFilePath); - AknsUtils::CreateIconL( AknsUtils::SkinInstance(), - iconID, - iWaypointIcon, - iWaypointIconMask, - bitmapFilePath, - fileIndex, - fileMaskIndex - ); + if ( aEnabled ) + { + iWaypointIcon = CMRImage::NewL( + NMRBitmapManager::EMRBitmapLocationWaypoint, ETrue ); + iWaypointIcon->SetParent( this ); + } - // Even if creating mask failed, bitmap can be used (background is just not displayed correctly) - if( iWaypointIcon ) - { - AknIconUtils::SetSize( iWaypointIcon, KIconSize, EAspectRatioPreserved ); - iIcon = new (ELeave) CEikImage; - iIcon->SetPictureOwnedExternally(ETrue); - iIcon->SetPicture( iWaypointIcon, iWaypointIconMask ); - - LayoutWaypointIcon(); - - // change text rect size to fit icon - iBorder->SetSize( BorderSize() ); - } - } + SizeChanged(); } // --------------------------------------------------------------------------- @@ -444,11 +424,27 @@ TInt CESMRLocationField::CountComponentControls( ) const { FUNC_LOG; - TInt count = CESMRIconField::CountComponentControls ( ); - if ( iIcon ) + TInt count( 0 ); + if( iFieldButton ) + { + ++count; + } + + if ( iTitle ) { ++count; } + + if( iLocation ) + { + ++count; + } + + if( iWaypointIcon ) + { + ++count; + } + return count; } @@ -459,42 +455,111 @@ CCoeControl* CESMRLocationField::ComponentControl( TInt aInd ) const { FUNC_LOG; - if ( aInd == 2 ) + + switch ( aInd ) { - return iIcon; + case 0: + return iFieldButton; + case 1: + return iTitle; + case 2: + return iLocation; + case 3: + return iWaypointIcon; + default: + return NULL; } - return CESMRIconField::ComponentControl ( aInd ); } // --------------------------------------------------------------------------- // CESMRLocationField::SizeChanged // --------------------------------------------------------------------------- // -void CESMRLocationField::SizeChanged( ) +void CESMRLocationField::SizeChanged() { FUNC_LOG; - CESMRIconField::SizeChanged(); - - PositionFieldElements(); - } + TRect rect( Rect() ); + + TAknLayoutRect firstRowLayoutRect( + NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) ); + TRect firstRowRect( firstRowLayoutRect.Rect() ); + + TRect secondRowRect( firstRowRect ); + secondRowRect.Move( 0, firstRowRect.Height() ); + + // Layout field button + if( iFieldButton ) + { + TAknWindowComponentLayout buttonLayout( + NMRLayoutManager::GetWindowComponentLayout( + NMRLayoutManager::EMRLayoutTextEditorIcon ) ); + AknLayoutUtils::LayoutControl( + iFieldButton, firstRowRect, buttonLayout ); + } + + // Layout field title + if( iTitle ) + { + TAknLayoutText labelLayout( + NMRLayoutManager::GetLayoutText( + firstRowRect, + NMRLayoutManager::EMRTextLayoutTextEditor ) ); + + iTitle->SetRect( labelLayout.TextRect() ); + + // Setting font also for the label. Failures are ignored. + iTitle->SetFont( labelLayout.Font() ); + } + + TRect editorRect( 0, 0, 0, 0 ); + + // Layout field editor + if( iLocation ) + { + TAknLayoutText editorLayoutText; -// --------------------------------------------------------------------------- -// CESMRLocationField::PositionFieldElements -// --------------------------------------------------------------------------- -// -void CESMRLocationField::PositionFieldElements() - { - FUNC_LOG; - // editor (editor is wrapped inside the 'iBorder' member) - if ( iIcon ) + if( iWaypointIcon ) + { + editorLayoutText = NMRLayoutManager::GetLayoutText( + secondRowRect, + NMRLayoutManager::EMRTextLayoutSingleRowEditorText ); + } + else + { + editorLayoutText = NMRLayoutManager::GetLayoutText( + secondRowRect, + NMRLayoutManager::EMRTextLayoutTextEditor ); + } + + editorRect = editorLayoutText.TextRect(); + + // Resize height according to actual height required by edwin. + editorRect.Resize( 0, iSize.iHeight - editorRect.Height() ); + + iLocation->SetRect( editorRect ); + + // Try setting font. Failures are ignored. + TRAP_IGNORE( iLocation->SetFontL( editorLayoutText.Font() ) ); + } + + // Layout the waypoint icon + if ( iWaypointIcon ) { - LayoutWaypointIcon(); - - if ( iFrameBgContext && iBorder ) - { - TRect visibleRect = CalculateVisibleRect( iLocation->Rect() ); - iFrameBgContext->SetFrameRects( visibleRect, visibleRect ); - } + TAknWindowComponentLayout iconLayout( + NMRLayoutManager::GetWindowComponentLayout( + NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) ); + AknLayoutUtils::LayoutImage( iWaypointIcon, secondRowRect, iconLayout ); + } + + // Layout field focus + if( iLocation ) + { + // Layouting focus for rich text editor area + TRect bgRect( iLocation->Rect() ); + + // Move focus rect so that it's relative to field's position. + bgRect.Move( -Position() ); + SetFocusRect( bgRect ); } } @@ -508,17 +573,13 @@ if ( aEvent.Type() == MESMRFieldEvent::EESMRFieldCommandEvent ) { TInt* command = static_cast< TInt* >( aEvent.Param( 0 ) ); - + switch ( *command ) { case EESMRCmdDisableWaypointIcon: - { - SetWaypointIconL( EFalse ); - break; - } case EESMRCmdEnableWaypointIcon: { - SetWaypointIconL( ETrue ); + SetWaypointIconL( *command == EESMRCmdEnableWaypointIcon ); break; } default: @@ -533,97 +594,315 @@ // CESMRLocationField::ExecuteGenericCommandL // --------------------------------------------------------------------------- // -void CESMRLocationField::ExecuteGenericCommandL( - TInt aCommand ) - { +TBool CESMRLocationField::ExecuteGenericCommandL( + TInt aCommand ) + { FUNC_LOG; - if ( EESMRCmdSizeExceeded == aCommand ) - { - CESMRGlobalNote::ExecuteL( - CESMRGlobalNote::EESMRCannotDisplayMuchMore ); - - HBufC* text = iLocation->GetTextInHBufL(); - CleanupDeletePushL( text ); - if ( text ) - { - TInt curPos = iLocation->CursorPos(); - if ( curPos > iLocation->GetLimitLength() - 1 ) - curPos = iLocation->GetLimitLength() - 1; - HBufC* newText = - text->Mid( 0, iLocation->GetLimitLength() - 1 ).AllocLC(); - - iLocation->SetTextL ( newText ); - CleanupStack::PopAndDestroy( newText ); - newText = NULL; - - iLocation->SetCursorPosL( curPos, EFalse ); - iLocation->HandleTextChangedL(); - iLocation->UpdateScrollBarsL(); - SetFocus( ETrue ); - } - CleanupStack::PopAndDestroy( text ); - } - } + TBool isUsed( EFalse ); + switch(aCommand) + { + case EESMRCmdSizeExceeded: + { + CESMRGlobalNote::ExecuteL( + CESMRGlobalNote::EESMRCannotDisplayMuchMore ); + + HBufC* text = iLocation->GetTextInHBufL(); + CleanupDeletePushL( text ); + if ( text ) + { + TInt curPos = iLocation->CursorPos(); + if ( curPos > iLocation->GetLimitLength() - 1 ) + curPos = iLocation->GetLimitLength() - 1; + HBufC* newText = + text->Mid( 0, iLocation->GetLimitLength() - 1 ).AllocLC(); + + iLocation->SetTextL ( newText ); + CleanupStack::PopAndDestroy( newText ); + newText = NULL; + + iLocation->SetCursorPosL( curPos, EFalse ); + iLocation->HandleTextChangedL(); + iLocation->UpdateScrollBarsL(); + SetFocus( ETrue ); + } + CleanupStack::PopAndDestroy( text ); + isUsed = ETrue; + break; + } + default: + break; + } + return isUsed; + } + + +// --------------------------------------------------------------------------- +// CESMRLocationField::HandleSingletapEventL +// --------------------------------------------------------------------------- +// +TBool CESMRLocationField::HandleSingletapEventL( const TPoint& aPosition ) + { + FUNC_LOG; + TBool ret( EFalse ); + + if( iTitle->Rect().Contains( aPosition ) || + iFieldButton->Rect().Contains( aPosition ) ) + { + NotifyEventL( EAknSoftkeyContextOptions ); + HandleTactileFeedbackL(); + ret = ETrue; + } + + return ret; + } // --------------------------------------------------------------------------- -// CESMRLocationField::CalculateEditorSize +// CESMRLocationField::HandleLongtapEventL // --------------------------------------------------------------------------- // -TSize CESMRLocationField::CalculateEditorSize( const TSize& aSize ) +void CESMRLocationField::HandleLongtapEventL( const TPoint& aPosition ) { FUNC_LOG; - TSize size( aSize ); - size.iHeight -= KEditorDifference; + + if ( iLocation->Rect().Contains( aPosition ) ) + { + if ( !iMenu ) + { + iMenu = CMRStylusPopupMenu::NewL( *this ); + } + RArray items; + CleanupClosePushL( items ); + + HBufC* maps= NULL; + HBufC* myLocations = NULL; + + if ( FeaturesL().FeatureSupported( + CESMRFeatureSettings::EESMRUIMnFwIntegration ) ) + { + maps = StringLoader::LoadLC( + R_MEET_REQ_OPTIONS_ASSIGN_FROM_MAP, + iCoeEnv ); + CMRStylusPopupMenu::TMenuItem mapsItem( + *maps, + EESMRCmdAssignFromMap ); + items.AppendL( mapsItem ); + } + +//#ifdef RD_USE_MYLOCATIONUI + + myLocations = StringLoader::LoadLC( + R_MEET_REQ_OPTIONS_MY_LOCATIONS, + iCoeEnv ); + + CMRStylusPopupMenu::TMenuItem myLocationsItem( + *myLocations, + EMRCommandMyLocations ); - if ( iLayout->CurrentFontZoom() == EAknUiZoomSmall || - iLayout->CurrentFontZoom() == EAknUiZoomVerySmall) + items.AppendL( myLocationsItem ); + +//#endif //RD_USE_MYLOCATIONUI + + if ( items.Count() == 1 ) + { + // Only one option. Issue command directly + NotifyEventL( items[ 0 ].iCommandId ); + } + else if ( items.Count() > 1 ) + { + iMenu->LaunchPopupL( items.Array(), aPosition ); + iMenuIsShown = ETrue; + } + + if (myLocations ) + { + CleanupStack::PopAndDestroy( myLocations ); + } + + if ( maps ) + { + CleanupStack::PopAndDestroy( maps ); + } + + CleanupStack::PopAndDestroy( &items ); + } + + if( iTitle->Rect().Contains( aPosition ) || + iFieldButton->Rect().Contains( aPosition ) ) { - size.iHeight -= KEditorDifference; + NotifyEventL( EAknSoftkeyContextOptions ); + HandleTactileFeedbackL(); } - - return size; } // --------------------------------------------------------------------------- -// CESMRLocationField::BorderSize +// CESMRLocationField::DynInitMenuPaneL // --------------------------------------------------------------------------- // -TSize CESMRLocationField::BorderSize() const +void CESMRLocationField::DynInitMenuPaneL( + TInt aResourceId, + CEikMenuPane* aMenuPane ) { FUNC_LOG; - TSize borderSize( CESMRIconField::BorderSize() ); - - // If icon exists, we have to adjust the border width - if ( iIcon ) + + if ( aResourceId == R_MR_EDITOR_ORGANIZER_MENU) { - borderSize.iWidth -= ( KIconSize.iWidth + 2 * KEditorDifference ); + // Init assign options + TInt numOptions( 1 ); // My Locations + + if ( FeaturesL().FeatureSupported( + CESMRFeatureSettings::EESMRUIMnFwIntegration ) ) + { + ++numOptions; + } + + #ifndef RD_USE_MYLOCATIONUI + // Disable My Locations + --numOptions; + #endif // RD_USE_MYLOCATIONUI + + switch ( numOptions ) + { + case 0: + { + aMenuPane->SetItemDimmed( EESMRCmdAddLocation, ETrue ); + break; + } + + case 1: + { + // Replace Add location with actual command + TInt pos( 0 ); + CEikMenuPaneItem* item = + aMenuPane->ItemAndPos( EESMRCmdAddLocation, pos ); + + item->iData.iCascadeId = 0; + + if ( FeaturesL().FeatureSupported( + CESMRFeatureSettings::EESMRUIMnFwIntegration ) ) + { + item->iData.iCommandId = EESMRCmdAssignFromMap; + StringLoader::Load(item->iData.iText, + R_MEET_REQ_OPTIONS_ASSIGN_FROM_MAP, iCoeEnv ); + } + +#ifdef RD_USE_MYLOCATIONUI + else + { + item->iData.iCommandId = EMRCommandMyLocations; + StringLoader::Load( item->iData.iText, + R_MEET_REQ_OPTIONS_MY_LOCATIONS, iCoeEnv ); + } +#endif //RD_USE_MYLOCATIONUI + + aMenuPane->SetItemDimmed( item->iData.iCommandId, EFalse ); + break; + } + default: + { + aMenuPane->SetItemDimmed( EESMRCmdAddLocation, EFalse ); + break; + } + } + // Init Show/Search options + TBool showOnMap( EFalse ); + TBool searchFromMap( EFalse ); + + if ( iWaypointIcon ) + { + // Coordinates available -> show on map + showOnMap = ETrue; + } + else + { + HBufC* text = iLocation->GetTextInHBufL(); + if ( text && *text != iLocation->DefaultText() ) + { + // Edited text in field -> enable search from map + searchFromMap = ETrue; + } + delete text; + } + + aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap ); + aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, !searchFromMap ); } - - return borderSize; + else if ( aResourceId == R_MR_EDITOR_LOCATION_MENU ) + { + if ( !FeaturesL().FeatureSupported( + CESMRFeatureSettings::EESMRUIMnFwIntegration ) ) + { + aMenuPane->SetItemDimmed( EESMRCmdAssignFromMap, ETrue ); + } +#ifndef RD_USE_MYLOCATIONUI + aMenuPane->SetItemDimmed( EMRCommandMyLocations, ETrue ); +#endif //RD_USE_MYLOCATIONUI + } } // --------------------------------------------------------------------------- -// CESMRLocationField::LayoutWaypointIcon +// CESMRLocationField::SetContainerWindowL // --------------------------------------------------------------------------- // -void CESMRLocationField::LayoutWaypointIcon() +void CESMRLocationField::SetContainerWindowL( + const CCoeControl& aContainer ) + { + FUNC_LOG; + CCoeControl::SetContainerWindowL( aContainer ); + + iLocation->SetContainerWindowL( aContainer ); + iLocation->SetParent( this ); + + iTitle->SetContainerWindowL( aContainer ); + iTitle->SetParent( this ); + + iFieldButton->SetContainerWindowL(aContainer); + iFieldButton->SetParent(this); + } + +// --------------------------------------------------------------------------- +// CESMRLocationField::OfferKeyEventL() +// --------------------------------------------------------------------------- +// +TKeyResponse CESMRLocationField::OfferKeyEventL( + const TKeyEvent& aEvent, + TEventCode aType ) { FUNC_LOG; - if ( iIcon ) + TKeyResponse response( EKeyWasNotConsumed ); + response = iLocation->OfferKeyEventL ( aEvent, aType ); + + if ( aType == EEventKey && + ( aEvent.iScanCode != EStdKeyUpArrow && + aEvent.iScanCode != EStdKeyDownArrow )) { - // Layout the icon - TRect fieldRect( Rect() ); - TPoint iconPos( fieldRect.iBr.iX - KIconSize.iWidth, - fieldRect.iTl.iY + iLayout->IconTopMargin() ); - - if ( CESMRLayoutManager::IsMirrored() ) - { - iconPos.iX = fieldRect.iTl.iX; - } - - iIcon->SetPosition( iconPos ); - iIcon->SetSize( KIconSize ); + iLocation->DrawDeferred(); } + + return response; } +// --------------------------------------------------------------------------- +// CESMRLocationField::HandlePointerEventL +// --------------------------------------------------------------------------- +// +TBool CESMRLocationField::HandleRawPointerEventL( const TPointerEvent &aPointerEvent ) + { + if ( !iMenuIsShown ) + { + CCoeControl::HandlePointerEventL( aPointerEvent ); + } + + return ETrue; + } + +// --------------------------------------------------------------------------- +// CESMRLocationField::ProcessCommandL +// --------------------------------------------------------------------------- +// +void CESMRLocationField::ProcessCommandL( TInt aCommandId ) + { + NotifyEventL( aCommandId ); + + iMenuIsShown = EFalse; + } // EOF