meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrlocationfield.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 0 8466d47a6819
child 13 8592a65ad3fb
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14  *  Description : ESMR location field implementation
    14  *  Description : ESMR location field implementation
    15  *  Version     : %version: tr1sido#10 %
    15  *  Version     : %version: e002sa33#52 %
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 #include "emailtrace.h"
    19 
    20 #include "cesmrlocationfield.h"
    20 #include "cesmrlocationfield.h"
    21 
       
    22 // SYSTEM INCLUDES
       
    23 #include <calentry.h>
       
    24 #include <StringLoader.h>
       
    25 #include <AknUtils.h>
       
    26 #include <AknsUtils.h>
       
    27 #include <AknIconUtils.h>
       
    28 #include <esmrgui.rsg>
       
    29 #include <AknsDrawUtils.h>
       
    30 #include <AknsFrameBackgroundControlContext.h>
       
    31 #include <data_caging_path_literals.hrh>
       
    32 
       
    33 // INCLUDES
       
    34 #include "esmrfieldbuilderdef.h"
    21 #include "esmrfieldbuilderdef.h"
    35 #include "cesmreditor.h"
    22 #include "cesmreditor.h"
    36 #include "cesmrfeaturesettings.h"
    23 #include "cesmrfeaturesettings.h"
    37 #include "esmrhelper.h"
    24 #include "esmrhelper.h"
    38 #include "cesmrborderlayer.h"
       
    39 #include "mesmrfieldevent.h"
    25 #include "mesmrfieldevent.h"
    40 #include "cesmrgenericfieldevent.h"
    26 #include "cesmrgenericfieldevent.h"
    41 #include "cesmrlayoutmgr.h"
       
    42 #include "cesmrglobalnote.h"
    27 #include "cesmrglobalnote.h"
       
    28 #include "cmrbutton.h"
       
    29 #include "cmrlabel.h"
       
    30 #include "cmrimage.h"
       
    31 #include "nmrlayoutmanager.h"
       
    32 #include "nmrbitmapmanager.h"
       
    33 #include "cmrstyluspopupmenu.h"
       
    34 #include "mesmrlistobserver.h"
       
    35 
       
    36 #include <calentry.h>
       
    37 #include <stringloader.h>
       
    38 #include <esmrgui.rsg>
       
    39 #include <data_caging_path_literals.hrh>
       
    40 #include <aknsbasicbackgroundcontrolcontext.h>
       
    41 #include <eikmfne.h>
       
    42 #include <aknbutton.h>
       
    43 
       
    44 #include "emailtrace.h"
       
    45 #include "esmrconfig.hrh"
    43 
    46 
    44 // ======== MEMBER FUNCTIONS ========
    47 // ======== MEMBER FUNCTIONS ========
    45 
    48 
    46 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    47 // CESMRLocationField::NewL
    50 // CESMRLocationField::NewL
    48 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    49 //
    52 //
    50 CESMRLocationField* CESMRLocationField::NewL( )
    53 CESMRLocationField* CESMRLocationField::NewL()
    51     {
    54     {
    52     FUNC_LOG;
    55     FUNC_LOG;
    53     CESMRLocationField* self = new (ELeave) CESMRLocationField;
    56     CESMRLocationField* self = new (ELeave) CESMRLocationField;
    54     CleanupStack::PushL ( self );
    57     CleanupStack::PushL( self );
    55     self->ConstructL ( );
    58     self->ConstructL();
    56     CleanupStack::Pop ( self );
    59     CleanupStack::Pop( self );
    57     return self;
    60     return self;
    58     }
    61     }
    59 
    62 
    60 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
       
    64 // CESMRLocationField::CESMRLocationField
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CESMRLocationField::CESMRLocationField()
       
    68     {
       
    69     FUNC_LOG;
       
    70     SetFieldId( EESMRFieldLocation );
       
    71     SetFocusType( EESMRHighlightFocus );
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CESMRLocationField::ConstructL
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CESMRLocationField::ConstructL()
       
    79     {
       
    80     FUNC_LOG;
       
    81 
       
    82     iFieldButton = CMRButton::NewL( NMRBitmapManager::EMRBitmapLocation );
       
    83     iFieldButton->SetParent( this );
       
    84 
       
    85     iTitle = CMRLabel::NewL();
       
    86     iTitle->SetParent( this );
       
    87     HBufC* title = StringLoader::LoadLC(
       
    88             R_MEET_REQ_OPTIONS_ADD_LOCATION,
       
    89             iCoeEnv );
       
    90     iTitle->SetTextL( *title );
       
    91     CleanupStack::PopAndDestroy( title );
       
    92 
       
    93     iLocation = CESMREditor::NewL( this,
       
    94                                    1,
       
    95                                    KMaxTextLength, //from ICAL spec.
       
    96                                    // do not change. other text fields do not
       
    97                                    // have this limitation
       
    98                                    CEikEdwin::EResizable |
       
    99                                    CEikEdwin::EAvkonEditor );
       
   100 
       
   101     CESMRField::ConstructL( iLocation ); //ownership transfered
       
   102 
       
   103     iLocation->SetEdwinSizeObserver( this );
       
   104     iLocation->SetEdwinObserver( this );
       
   105     iLocation->SetParent( this );
       
   106 
       
   107     HBufC* buf = StringLoader::LoadLC( R_QTN_MEET_REQ_LOCATION_FIELD, iCoeEnv );
       
   108     iLocation->SetDefaultTextL( buf ); // ownership is transferred
       
   109     CleanupStack::Pop( buf );
       
   110 
       
   111     // Setting background instead of theme skin
       
   112     NMRBitmapManager::TMRBitmapStruct bitmapStruct;
       
   113     bitmapStruct = NMRBitmapManager::GetBitmapStruct( NMRBitmapManager::EMRBitmapInputCenter );
       
   114 
       
   115     TRect initialisationRect( 0, 0, 0, 0 );
       
   116     iBgControlContext = CAknsBasicBackgroundControlContext::NewL(
       
   117                 bitmapStruct.iItemId,
       
   118                 initialisationRect,
       
   119                 EFalse );
       
   120 
       
   121     iLocation->SetSkinBackgroundControlContextL( iBgControlContext );
       
   122     }
       
   123 
       
   124 
       
   125 // ---------------------------------------------------------------------------
    61 // CESMRLocationField::~CESMRLocationField
   126 // CESMRLocationField::~CESMRLocationField
    62 // ---------------------------------------------------------------------------
   127 // ---------------------------------------------------------------------------
    63 //
   128 //
    64 CESMRLocationField::~CESMRLocationField( )
   129 CESMRLocationField::~CESMRLocationField()
    65     {
   130     {
    66     FUNC_LOG;
   131     FUNC_LOG;
    67     delete iIcon;
   132     delete iFieldButton;
    68     delete iWaypointIcon;
   133     delete iWaypointIcon;
    69     delete iWaypointIconMask;
       
    70     delete iFrameBgContext;
       
    71     delete iFeatures;
   134     delete iFeatures;
    72     delete iLocationText;
   135     delete iLocationText;
       
   136     delete iBgControlContext;
       
   137     delete iMenu;
       
   138     delete iTitle;
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // CESMRLocationField::MinimumSize
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 TSize CESMRLocationField::MinimumSize()
       
   146     {
       
   147     TRect parentRect( Parent()->Rect() );
       
   148 
       
   149     TRect richTextRect =
       
   150        NMRLayoutManager::GetFieldLayoutRect( parentRect, 1 ).Rect();
       
   151 
       
   152     TRect textRect( NMRLayoutManager::GetLayoutText(
       
   153             richTextRect,
       
   154        NMRLayoutManager::EMRTextLayoutTextEditor ).TextRect() );
       
   155 
       
   156     // Adjust field size so that there's room for expandable editor.
       
   157     richTextRect.Resize( 0, iSize.iHeight - textRect.Height() );
       
   158 
       
   159     // Add title area to the required size
       
   160     TSize titleSize( CESMRField::MinimumSize() );
       
   161 
       
   162     TSize completeFieldSize( titleSize );
       
   163     completeFieldSize.iHeight += richTextRect.Height();
       
   164 
       
   165     return completeFieldSize;
    73     }
   166     }
    74 
   167 
    75 // ---------------------------------------------------------------------------
   168 // ---------------------------------------------------------------------------
    76 // CESMRLocationField::InitializeL
   169 // CESMRLocationField::InitializeL
    77 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
    78 //
   171 //
    79 void CESMRLocationField::InitializeL()
   172 void CESMRLocationField::InitializeL()
    80     {
   173     {
    81     FUNC_LOG;
   174     FUNC_LOG;
    82     iLocation->SetFontL( iLayout->Font(iCoeEnv, iFieldId ), iLayout );
   175     // Do nothing
    83     AknLayoutUtils::OverrideControlColorL( *iLocation, 
       
    84                                             EColorControlBackground,
       
    85                                             iLayout->NormalTextBgColor() );
       
    86     }
   176     }
    87 
   177 
    88 // ---------------------------------------------------------------------------
   178 // ---------------------------------------------------------------------------
    89 // CESMRLocationField::InternalizeL
   179 // CESMRLocationField::InternalizeL
    90 // ---------------------------------------------------------------------------
   180 // ---------------------------------------------------------------------------
   102         iLocation->ClearSelectionAndSetTextL( *location );
   192         iLocation->ClearSelectionAndSetTextL( *location );
   103         }
   193         }
   104 
   194 
   105     CleanupStack::PopAndDestroy( location );
   195     CleanupStack::PopAndDestroy( location );
   106 
   196 
       
   197     // If the geo value has been set, the waypoint icon has to be shown on right
       
   198     // side of the location field
       
   199     CCalGeoValue* geoValue = aEntry.Entry().GeoValueL();
       
   200     TReal dummy;
       
   201     SetWaypointIconL( geoValue && geoValue->GetLatLong( dummy, dummy ) );
       
   202 
   107     // this is needed to be re-called here, otherwise the CEikEdwin
   203     // this is needed to be re-called here, otherwise the CEikEdwin
   108     // does not get correctly instantiated with default text
   204     // does not get correctly instantiated with default text
   109     iLocation->FocusChanged( EDrawNow );
   205     iLocation->FocusChanged( EDrawNow );
   110     }
   206     }
   111 
   207 
   123         CleanupStack::PushL( loc );
   219         CleanupStack::PushL( loc );
   124 
   220 
   125         // externalize the text only if it differs from the
   221         // externalize the text only if it differs from the
   126         // default text. In other words, default text is not
   222         // default text. In other words, default text is not
   127         // externalized.
   223         // externalized.
   128         HBufC* defaultText = StringLoader::LoadLC( R_QTN_MEET_REQ_LOCATION_FIELD );
   224         HBufC* defaultText = StringLoader::LoadLC(
       
   225                 R_QTN_MEET_REQ_LOCATION_FIELD,
       
   226                 iCoeEnv );
   129         if ( defaultText->Compare( *loc ) != 0 )
   227         if ( defaultText->Compare( *loc ) != 0 )
   130             {
   228             {
   131             CCalEntry& entry = aEntry.Entry();
   229             CCalEntry& entry = aEntry.Entry();
   132             entry.SetLocationL( *loc );
   230             entry.SetLocationL( *loc );
   133             }
   231             }
       
   232         else if ( !iWaypointIcon )
       
   233             {
       
   234             aEntry.Entry().ClearGeoValueL();
       
   235             }
   134 
   236 
   135         CleanupStack::PopAndDestroy( defaultText );
   237         CleanupStack::PopAndDestroy( defaultText );
   136         CleanupStack::PopAndDestroy( loc );
   238         CleanupStack::PopAndDestroy( loc );
   137         }
   239         }
   138     else
   240     else
   139         {
   241         {
   140         CCalEntry& entry = aEntry.Entry();
   242         CCalEntry& entry = aEntry.Entry();
   141         entry.SetLocationL( KNullDesC );
   243         entry.SetLocationL( KNullDesC );
       
   244         entry.ClearGeoValueL();
   142         }
   245         }
   143     }
   246     }
   144 
   247 
   145 // ---------------------------------------------------------------------------
   248 // ---------------------------------------------------------------------------
   146 // CESMRLocationField::SetOutlineFocusL
   249 // CESMRLocationField::SetOutlineFocusL
   148 //
   251 //
   149 void CESMRLocationField::SetOutlineFocusL( TBool aFocus )
   252 void CESMRLocationField::SetOutlineFocusL( TBool aFocus )
   150     {
   253     {
   151     FUNC_LOG;
   254     FUNC_LOG;
   152     CESMRField::SetOutlineFocusL ( aFocus );
   255     CESMRField::SetOutlineFocusL ( aFocus );
   153     
   256 
   154     if ( FeaturesL().FeatureSupported(
   257     if ( FeaturesL().FeatureSupported(
   155             CESMRFeatureSettings::EESMRUILocationFeatures ) )
   258             CESMRFeatureSettings::EESMRUILocationFeatures ) )
   156         {
   259         {
   157         if ( aFocus )
   260         if ( aFocus )
   158             {
   261             {
   164                 {
   267                 {
   165                 delete iLocationText;
   268                 delete iLocationText;
   166                 iLocationText = NULL;
   269                 iLocationText = NULL;
   167                 }
   270                 }
   168             iLocationText = iLocation->GetTextInHBufL();
   271             iLocationText = iLocation->GetTextInHBufL();
   169             
   272 
   170             HBufC* defaultText = StringLoader::LoadLC( R_QTN_MEET_REQ_LOCATION_FIELD );
   273             HBufC* defaultText = StringLoader::LoadLC(
   171                         
   274                     R_QTN_MEET_REQ_LOCATION_FIELD,
       
   275                     iCoeEnv );
       
   276 
   172             if ( iLocationText && iLocationText->Compare( *defaultText ) != 0 )
   277             if ( iLocationText && iLocationText->Compare( *defaultText ) != 0 )
   173                 {
   278                 {
   174                 // Create field change event
   279                 // Create field change event
   175                 CESMRGenericFieldEvent* event = CESMRGenericFieldEvent::NewLC(
   280                 CESMRGenericFieldEvent* event = CESMRGenericFieldEvent::NewLC(
   176                         this,
   281                         this,
   177                         MESMRFieldEvent::EESMRFieldChangeEvent );
   282                         MESMRFieldEvent::EESMRFieldChangeEvent );
   178                 
   283 
   179                 // Add this field as parameter
   284                 // Add this field as parameter
   180                 TInt fieldId = iFieldId;
   285                 TInt fieldId = iFieldId;
   181                 CESMRFieldEventValue* field = CESMRFieldEventValue::NewLC(
   286                 CESMRFieldEventValue* field = CESMRFieldEventValue::NewLC(
   182                         MESMRFieldEventValue::EESMRInteger,
   287                         MESMRFieldEventValue::EESMRInteger,
   183                         &fieldId );
   288                         &fieldId );
   184                 event->AddParamL( field );
   289                 event->AddParamL( field );
   185                 CleanupStack::Pop( field );
   290                 CleanupStack::Pop( field );
   186                 
   291 
   187                 // Add new value as parameter
   292                 // Add new value as parameter
   188                 CESMRFieldEventValue* value = CESMRFieldEventValue::NewLC(
   293                 CESMRFieldEventValue* value = CESMRFieldEventValue::NewLC(
   189                         CESMRFieldEventValue::EESMRString,
   294                         CESMRFieldEventValue::EESMRString,
   190                         iLocationText );
   295                         iLocationText );
   191                 iLocationText = NULL; // Ownership transferred to value
   296                 iLocationText = NULL; // Ownership transferred to value
   192                 // Encapsulate value, so receiver gets the field value type
   297                 // Encapsulate value, so receiver gets the field value type
   193                 event->AddParamL( value, ETrue );
   298                 event->AddParamL( value, ETrue );
   194                 CleanupStack::Pop( value );
   299                 CleanupStack::Pop( value );
   195                 
   300 
   196                 // Send event
   301                 // Send event
   197                 NotifyEventAsyncL( event );
   302                 NotifyEventAsyncL( event );
   198                 CleanupStack::Pop( event );
   303                 CleanupStack::Pop( event );
   199                 }
   304                 }
   200             CleanupStack::PopAndDestroy( defaultText );
   305             CleanupStack::PopAndDestroy( defaultText );
   201             }
   306             }
   202         }
   307         }
   203     }
   308     }
   204 
   309 
   205 // ---------------------------------------------------------------------------
   310 // ---------------------------------------------------------------------------
   206 // CESMRLocationField::ExpandedHeight
       
   207 // ---------------------------------------------------------------------------
       
   208 //
       
   209 TInt CESMRLocationField::ExpandedHeight( ) const
       
   210     {
       
   211     FUNC_LOG;
       
   212     return iSize.iHeight;
       
   213     }
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // CESMRLocationField::HandleEdwinSizeEventL
   311 // CESMRLocationField::HandleEdwinSizeEventL
   217 // ---------------------------------------------------------------------------
   312 // ---------------------------------------------------------------------------
   218 //
   313 //
   219 TBool CESMRLocationField::HandleEdwinSizeEventL( CEikEdwin* aEdwin,
   314 TBool CESMRLocationField::HandleEdwinSizeEventL( CEikEdwin* aEdwin,
   220         TEdwinSizeEvent /*aType*/, TSize aSize )
   315         TEdwinSizeEvent /*aType*/, TSize aSize )
   221     {
   316     {
   222     FUNC_LOG;
   317     FUNC_LOG;
   223     TBool ret( EFalse );
   318     TBool reDraw( EFalse );
   224     
   319 
   225     TSize newSize = CalculateEditorSize( aSize );
   320     if( iSize != aSize )
   226 
   321         {
   227     if ( aEdwin == iLocation && iSize != newSize )
   322         // Let's save the required size for the iLocation
   228             {
   323         iSize = aSize;
   229         iSize = newSize;
   324 
   230 
   325         if ( iObserver && aEdwin == iLocation )
   231             if ( iObserver && aEdwin->IsFocused() )
   326            {
   232             {
   327            iObserver->ControlSizeChanged( this );
   233             iObserver->ControlSizeChanged (this );
   328            reDraw = ETrue;
   234             }
   329            }
   235 
   330 
   236         if ( iFrameBgContext )
   331         if( iLocation->LineCount() != iLineCount )
   237             {
   332             {
   238             TRect visibleRect = CalculateVisibleRect( iLocation->Rect() );
   333             // Line count has changed, the whole component needs
   239             iFrameBgContext->SetFrameRects( visibleRect, visibleRect );
   334             // to be redrawn
   240             }
   335             DrawDeferred();
       
   336             iLineCount = iLocation->LineCount();
       
   337             }
       
   338         }
       
   339 
       
   340     return reDraw;
       
   341     }
       
   342 
       
   343 // ---------------------------------------------------------------------------
       
   344 // CESMRLocationField::HandleEdwinEventL
       
   345 // ---------------------------------------------------------------------------
       
   346 //
       
   347 void CESMRLocationField::HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType)
       
   348     {
       
   349     FUNC_LOG;
       
   350     if ( aEdwin == iLocation && aEventType == EEventTextUpdate )
       
   351         {
       
   352         TInt textLength( iLocation->TextLength() );
   241         
   353         
   242         ret = ETrue;
   354         if ( iLocation->GetLimitLength() <= textLength )
   243         }
   355             {
   244     return ret;
   356             NotifyEventAsyncL( EESMRCmdSizeExceeded );
   245     }
   357             }
   246 
   358         else if ( iWaypointIcon && textLength == 0 )
   247 // ---------------------------------------------------------------------------
   359             {
   248 // CESMRLocationField::HandleEdwinEventL
   360             SetWaypointIconL( EFalse );
   249 // ---------------------------------------------------------------------------
   361             NotifyEventL( EESMRCmdDisableWaypointIcon );
   250 //
   362             }
   251 void CESMRLocationField::HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType)
   363         }
   252 	{
   364     }
   253     FUNC_LOG;
   365 
   254     if ( aEdwin == iLocation && aEventType == EEventTextUpdate )
   366 // ---------------------------------------------------------------------------
   255         {
   367 // CESMRLocationField::GetCursorLineVerticalPos
   256         HBufC* text = iLocation->GetTextInHBufL();
   368 // ---------------------------------------------------------------------------
   257         if ( text )
   369 //
   258             {
   370 void CESMRLocationField::GetCursorLineVerticalPos(TInt& aUpper, TInt& aLower)
   259             CleanupStack::PushL( text );
   371     {
   260             TInt textLength( text->Length() );
       
   261             if ( iLocation->GetLimitLength() <= textLength )
       
   262             	{
       
   263             	NotifyEventAsyncL( EESMRCmdSizeExceeded );
       
   264             	}            
       
   265             CleanupStack::PopAndDestroy( text );
       
   266             }
       
   267         }	
       
   268 	}
       
   269 // ---------------------------------------------------------------------------
       
   270 // CESMRLocationField::CESMRLocationField
       
   271 // ---------------------------------------------------------------------------
       
   272 //
       
   273 CESMRLocationField::CESMRLocationField()
       
   274     : iSize( TSize( 0, 0 ) )
       
   275     {
       
   276     FUNC_LOG;
       
   277     //do nothing
       
   278     }
       
   279 
       
   280 // ---------------------------------------------------------------------------
       
   281 // CESMRLocationField::ActivateL
       
   282 // ---------------------------------------------------------------------------
       
   283 //
       
   284 void CESMRLocationField::ActivateL()
       
   285     {
       
   286     FUNC_LOG;
       
   287     CCoeControl::ActivateL();
       
   288     TRect rect( iLocation->Rect() );
       
   289     TRect inner(rect);
       
   290     TRect outer(rect);
       
   291 
       
   292     delete iFrameBgContext;
       
   293     iFrameBgContext = NULL;
       
   294     iFrameBgContext = CAknsFrameBackgroundControlContext::NewL( 
       
   295             KAknsIIDQsnFrInput, 
       
   296             outer, 
       
   297             inner, 
       
   298             EFalse ) ;
       
   299 
       
   300     iFrameBgContext->SetParentContext( iBackground );
       
   301     iLocation->SetSkinBackgroundControlContextL( iFrameBgContext );
       
   302     }
       
   303 
       
   304 
       
   305 // ---------------------------------------------------------------------------
       
   306 // CESMRLocationField::PositionChanged()
       
   307 // ---------------------------------------------------------------------------
       
   308 //
       
   309 void CESMRLocationField::PositionChanged()
       
   310     {
       
   311     FUNC_LOG;
       
   312     CCoeControl::PositionChanged();
       
   313     
       
   314     if ( iFrameBgContext )
       
   315         {
       
   316         TRect visibleRect = CalculateVisibleRect( iLocation->Rect() );
       
   317         iFrameBgContext->SetFrameRects( visibleRect, visibleRect );
       
   318         }
       
   319     }
       
   320 
       
   321 // ---------------------------------------------------------------------------
       
   322 // CESMRLocationField::ConstructL
       
   323 // ---------------------------------------------------------------------------
       
   324 //
       
   325 void CESMRLocationField::ConstructL()
       
   326     {
       
   327     FUNC_LOG;
       
   328     SetFieldId( EESMRFieldLocation );
       
   329     SetExpandable();
       
   330 
       
   331     iLocation = CESMREditor::NewL( this, 
       
   332                                    1,
       
   333                                    KMaxTextLength, //from ICAL spec.
       
   334                                    // do not change. other text fields do not
       
   335                                    // have this limitation
       
   336                                    CEikEdwin::EResizable |
       
   337                                    CEikEdwin::EAvkonEditor );
       
   338 
       
   339     iLocation->SetEdwinSizeObserver( this );
       
   340     iLocation->SetEdwinObserver( this );
       
   341 
       
   342     HBufC* buf = StringLoader::LoadLC( R_QTN_MEET_REQ_LOCATION_FIELD );
       
   343     iLocation->SetDefaultTextL( buf ); // ownership is transferred
       
   344     CleanupStack::Pop( buf );
       
   345 
       
   346     CESMRIconField::ConstructL( KAknsIIDQgnMeetReqIndiLocation, iLocation );
       
   347     }
       
   348 
       
   349 // ---------------------------------------------------------------------------
       
   350 // CESMRLocationField::GetMinimumVisibleVerticalArea
       
   351 // ---------------------------------------------------------------------------
       
   352 //
       
   353 void CESMRLocationField::GetMinimumVisibleVerticalArea(TInt& aUpper, TInt& aLower)
       
   354     {
       
   355     FUNC_LOG;
       
   356     aLower = iLocation->CurrentLineNumber() * iLocation->RowHeight();
   372     aLower = iLocation->CurrentLineNumber() * iLocation->RowHeight();
   357     aUpper = aLower - iLocation->RowHeight();
   373     aUpper = aLower - iLocation->RowHeight();
   358     }
   374     }
   359 
   375 
   360 // ---------------------------------------------------------------------------
   376 // ---------------------------------------------------------------------------
   376     FUNC_LOG;
   392     FUNC_LOG;
   377     if ( !iFeatures )
   393     if ( !iFeatures )
   378         {
   394         {
   379         iFeatures = CESMRFeatureSettings::NewL();
   395         iFeatures = CESMRFeatureSettings::NewL();
   380         }
   396         }
   381     
   397 
   382     return *iFeatures;
   398     return *iFeatures;
   383     }
   399     }
   384 
   400 
   385 // ---------------------------------------------------------------------------
   401 // ---------------------------------------------------------------------------
   386 // CESMRCheckbox::SetWaypointIconL
   402 // CESMRLocationField::SetWaypointIconL
   387 // ---------------------------------------------------------------------------
   403 // ---------------------------------------------------------------------------
   388 //
   404 //
   389 void CESMRLocationField::SetWaypointIconL( TBool aEnabled )
   405 void CESMRLocationField::SetWaypointIconL( TBool aEnabled )
   390     {
   406     {
   391     FUNC_LOG;
       
   392     delete iIcon;
       
   393     iIcon = NULL;
       
   394     delete iWaypointIcon;
   407     delete iWaypointIcon;
   395     iWaypointIcon = NULL;
   408     iWaypointIcon = NULL;
   396     delete iWaypointIconMask;
   409 
   397     iWaypointIconMask = NULL;
   410     if ( aEnabled )
   398 
   411         {
   399     if( aEnabled )
   412         iWaypointIcon = CMRImage::NewL(
   400         {
   413                 NMRBitmapManager::EMRBitmapLocationWaypoint, ETrue );
   401         TAknsItemID iconID;
   414         iWaypointIcon->SetParent( this );
   402         TInt fileIndex(-1);
   415         }
   403         TInt fileMaskIndex(-1);
   416 
   404         iconID = KAknsIIDQgnPropBlidWaypoint;
   417     SizeChanged();
   405         CESMRLayoutManager::SetBitmapFallback( iconID,
   418     }
   406                                                fileIndex,
   419 
   407                                                fileMaskIndex );
   420 // ---------------------------------------------------------------------------
   408 
   421 // CESMRLocationField::CountComponentControls
   409         TFileName bitmapFilePath;
   422 // ---------------------------------------------------------------------------
   410         ESMRHelper::LocateResourceFile(
   423 //
   411                 KESMRMifFile,
   424 TInt CESMRLocationField::CountComponentControls( ) const
   412                 KDC_APP_BITMAP_DIR,
   425     {
   413                 bitmapFilePath);
   426     FUNC_LOG;
   414 
   427     TInt count( 0 );
   415         AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
   428     if( iFieldButton )
   416                                 iconID,
   429         {
   417                                 iWaypointIcon,
   430         ++count;
   418                                 iWaypointIconMask,
   431         }
   419                                 bitmapFilePath,
   432 
   420                                 fileIndex,
   433     if ( iTitle )
   421                                 fileMaskIndex
   434         {
   422                                 );
   435         ++count;
   423 
   436         }
   424         // Even if creating mask failed, bitmap can be used (background is just not displayed correctly)
   437 
       
   438     if( iLocation )
       
   439         {
       
   440         ++count;
       
   441         }
       
   442 
       
   443     if( iWaypointIcon )
       
   444         {
       
   445         ++count;
       
   446         }
       
   447 
       
   448     return count;
       
   449     }
       
   450 
       
   451 // ---------------------------------------------------------------------------
       
   452 // CESMRLocationField::ComponentControl
       
   453 // ---------------------------------------------------------------------------
       
   454 //
       
   455 CCoeControl* CESMRLocationField::ComponentControl( TInt aInd ) const
       
   456     {
       
   457     FUNC_LOG;
       
   458 
       
   459     switch ( aInd )
       
   460         {
       
   461         case 0:
       
   462             return iFieldButton;
       
   463         case 1:
       
   464             return iTitle;
       
   465         case 2:
       
   466             return iLocation;
       
   467         case 3:
       
   468             return iWaypointIcon;
       
   469         default:
       
   470             return NULL;
       
   471         }
       
   472     }
       
   473 
       
   474 // ---------------------------------------------------------------------------
       
   475 // CESMRLocationField::SizeChanged
       
   476 // ---------------------------------------------------------------------------
       
   477 //
       
   478 void CESMRLocationField::SizeChanged()
       
   479     {
       
   480     FUNC_LOG;
       
   481     TRect rect( Rect() );
       
   482 
       
   483     TAknLayoutRect firstRowLayoutRect(
       
   484             NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) );
       
   485     TRect firstRowRect( firstRowLayoutRect.Rect() );
       
   486 
       
   487     TRect secondRowRect( firstRowRect );
       
   488     secondRowRect.Move( 0, firstRowRect.Height() );
       
   489 
       
   490     // Layout field button
       
   491     if( iFieldButton )
       
   492         {
       
   493         TAknWindowComponentLayout buttonLayout(
       
   494                 NMRLayoutManager::GetWindowComponentLayout(
       
   495                     NMRLayoutManager::EMRLayoutTextEditorIcon ) );
       
   496         AknLayoutUtils::LayoutControl(
       
   497                 iFieldButton, firstRowRect, buttonLayout );
       
   498         }
       
   499 
       
   500     // Layout field title
       
   501     if( iTitle )
       
   502         {
       
   503         TAknLayoutText labelLayout(
       
   504                 NMRLayoutManager::GetLayoutText(
       
   505                         firstRowRect,
       
   506                             NMRLayoutManager::EMRTextLayoutTextEditor ) );
       
   507 
       
   508         iTitle->SetRect( labelLayout.TextRect() );
       
   509 
       
   510         // Setting font also for the label. Failures are ignored.
       
   511         iTitle->SetFont( labelLayout.Font() );
       
   512         }
       
   513 
       
   514     TRect editorRect( 0, 0, 0, 0 );
       
   515 
       
   516     // Layout field editor
       
   517     if( iLocation )
       
   518         {
       
   519         TAknLayoutText editorLayoutText;
       
   520 
   425         if( iWaypointIcon )
   521         if( iWaypointIcon )
   426             {
   522            {
   427             AknIconUtils::SetSize( iWaypointIcon, KIconSize, EAspectRatioPreserved );
   523            editorLayoutText = NMRLayoutManager::GetLayoutText(
   428             iIcon = new (ELeave) CEikImage;
   524                    secondRowRect,
   429             iIcon->SetPictureOwnedExternally(ETrue);
   525                    NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
   430             iIcon->SetPicture( iWaypointIcon, iWaypointIconMask );
   526            }
   431 
   527         else
   432             LayoutWaypointIcon();
   528            {
   433             
   529            editorLayoutText = NMRLayoutManager::GetLayoutText(
   434             // change text rect size to fit icon
   530                    secondRowRect,
   435             iBorder->SetSize( BorderSize() );
   531                    NMRLayoutManager::EMRTextLayoutTextEditor );
   436             }
   532            }
   437         }
   533 
   438     }
   534         editorRect = editorLayoutText.TextRect();
   439 
   535 
   440 // ---------------------------------------------------------------------------
   536         // Resize height according to actual height required by edwin.
   441 // CESMRLocationField::CountComponentControls
   537         editorRect.Resize( 0, iSize.iHeight - editorRect.Height() );
   442 // ---------------------------------------------------------------------------
   538 
   443 //
   539         iLocation->SetRect( editorRect );
   444 TInt CESMRLocationField::CountComponentControls( ) const
   540 
   445     {
   541         // Try setting font. Failures are ignored.
   446     FUNC_LOG;
   542         TRAP_IGNORE( iLocation->SetFontL( editorLayoutText.Font() ) );
   447     TInt count = CESMRIconField::CountComponentControls ( );
   543         }
   448     if ( iIcon )
   544 
   449         {
   545     // Layout the waypoint icon
   450         ++count;
   546     if ( iWaypointIcon )
   451         }
   547         {
   452     return count;
   548         TAknWindowComponentLayout iconLayout(
   453     }
   549                 NMRLayoutManager::GetWindowComponentLayout(
   454 
   550                     NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
   455 // ---------------------------------------------------------------------------
   551         AknLayoutUtils::LayoutImage( iWaypointIcon, secondRowRect, iconLayout );
   456 // CESMRLocationField::ComponentControl
   552         }
   457 // ---------------------------------------------------------------------------
   553 
   458 //
   554     // Layout field focus
   459 CCoeControl* CESMRLocationField::ComponentControl( TInt aInd ) const
   555     if( iLocation )
   460     {
   556         {
   461     FUNC_LOG;
   557         // Layouting focus for rich text editor area
   462     if ( aInd == 2 )
   558         TRect bgRect( iLocation->Rect() );
   463         {
   559 
   464         return iIcon;
   560         // Move focus rect so that it's relative to field's position.
   465         }
   561         bgRect.Move( -Position() );
   466     return CESMRIconField::ComponentControl ( aInd );
   562         SetFocusRect( bgRect );
   467     }
       
   468 
       
   469 // ---------------------------------------------------------------------------
       
   470 // CESMRLocationField::SizeChanged
       
   471 // ---------------------------------------------------------------------------
       
   472 //
       
   473 void CESMRLocationField::SizeChanged( )
       
   474     {
       
   475     FUNC_LOG;
       
   476     CESMRIconField::SizeChanged();
       
   477     
       
   478     PositionFieldElements(); 
       
   479     }
       
   480 
       
   481 // ---------------------------------------------------------------------------
       
   482 // CESMRLocationField::PositionFieldElements
       
   483 // ---------------------------------------------------------------------------
       
   484 //
       
   485 void CESMRLocationField::PositionFieldElements()
       
   486     {
       
   487     FUNC_LOG;
       
   488     // editor (editor is wrapped inside the 'iBorder' member)
       
   489     if ( iIcon )
       
   490         {
       
   491         LayoutWaypointIcon();
       
   492         
       
   493         if ( iFrameBgContext && iBorder )
       
   494             {
       
   495             TRect visibleRect = CalculateVisibleRect( iLocation->Rect() );
       
   496             iFrameBgContext->SetFrameRects( visibleRect, visibleRect );
       
   497             }
       
   498         }
   563         }
   499     }
   564     }
   500 
   565 
   501 // ---------------------------------------------------------------------------
   566 // ---------------------------------------------------------------------------
   502 // CESMRLocationField::HandleFieldEventL
   567 // CESMRLocationField::HandleFieldEventL
   506     {
   571     {
   507     FUNC_LOG;
   572     FUNC_LOG;
   508     if ( aEvent.Type() == MESMRFieldEvent::EESMRFieldCommandEvent )
   573     if ( aEvent.Type() == MESMRFieldEvent::EESMRFieldCommandEvent )
   509         {
   574         {
   510         TInt* command = static_cast< TInt* >( aEvent.Param( 0 ) );
   575         TInt* command = static_cast< TInt* >( aEvent.Param( 0 ) );
   511         
   576 
   512         switch ( *command )
   577         switch ( *command )
   513             {
   578             {
   514             case EESMRCmdDisableWaypointIcon:
   579             case EESMRCmdDisableWaypointIcon:
   515                 {
       
   516                 SetWaypointIconL( EFalse );
       
   517                 break;
       
   518                 }
       
   519             case EESMRCmdEnableWaypointIcon:
   580             case EESMRCmdEnableWaypointIcon:
   520                 {
   581                 {
   521                 SetWaypointIconL( ETrue );
   582                 SetWaypointIconL( *command == EESMRCmdEnableWaypointIcon );
   522                 break;
   583                 break;
   523                 }
   584                 }
   524             default:
   585             default:
   525                 {
   586                 {
   526                 break;
   587                 break;
   531 
   592 
   532 // ---------------------------------------------------------------------------
   593 // ---------------------------------------------------------------------------
   533 // CESMRLocationField::ExecuteGenericCommandL
   594 // CESMRLocationField::ExecuteGenericCommandL
   534 // ---------------------------------------------------------------------------
   595 // ---------------------------------------------------------------------------
   535 //
   596 //
   536 void CESMRLocationField::ExecuteGenericCommandL( 
   597 TBool CESMRLocationField::ExecuteGenericCommandL(
   537 		TInt aCommand )
   598         TInt aCommand )
   538 	{
   599     {
   539     FUNC_LOG;
   600     FUNC_LOG;
   540 	if ( EESMRCmdSizeExceeded == aCommand )
   601     TBool isUsed( EFalse );
   541 		{
   602     switch(aCommand)
   542 		CESMRGlobalNote::ExecuteL( 
   603         {
   543 				CESMRGlobalNote::EESMRCannotDisplayMuchMore );
   604         case EESMRCmdSizeExceeded:
   544 		
   605             {
   545 		HBufC* text = iLocation->GetTextInHBufL();
   606             CESMRGlobalNote::ExecuteL(
   546 		CleanupDeletePushL( text );
   607                     CESMRGlobalNote::EESMRCannotDisplayMuchMore );
   547 		if ( text )
   608 
   548 			{    
   609             HBufC* text = iLocation->GetTextInHBufL();
   549 	    	TInt curPos = iLocation->CursorPos();    	
   610             CleanupDeletePushL( text );
   550 	    	if ( curPos > iLocation->GetLimitLength() - 1 )
   611             if ( text )
   551 	    		curPos = iLocation->GetLimitLength() - 1;
   612                 {
   552 	    	HBufC* newText = 
   613                 TInt curPos = iLocation->CursorPos();
   553 	    		text->Mid( 0, iLocation->GetLimitLength() - 1 ).AllocLC();    	
   614                 if ( curPos > iLocation->GetLimitLength() - 1 )
   554 	    	
   615                     curPos = iLocation->GetLimitLength() - 1;
   555 	    	iLocation->SetTextL ( newText );
   616                 HBufC* newText =
   556 	    	CleanupStack::PopAndDestroy( newText );
   617                     text->Mid( 0, iLocation->GetLimitLength() - 1 ).AllocLC();
   557 	    	newText = NULL;
   618 
   558 	    	
   619                 iLocation->SetTextL ( newText );
   559 	    	iLocation->SetCursorPosL( curPos, EFalse );
   620                 CleanupStack::PopAndDestroy( newText );
   560 	    	iLocation->HandleTextChangedL();
   621                 newText = NULL;
   561 	    	iLocation->UpdateScrollBarsL();
   622 
   562 	    	SetFocus( ETrue );
   623                 iLocation->SetCursorPosL( curPos, EFalse );
   563 			}
   624                 iLocation->HandleTextChangedL();
   564 		CleanupStack::PopAndDestroy( text );	
   625                 iLocation->UpdateScrollBarsL();
   565 		}
   626                 SetFocus( ETrue );
   566 	}
   627                 }
   567 
   628             CleanupStack::PopAndDestroy( text );
   568 // ---------------------------------------------------------------------------
   629             isUsed = ETrue;
   569 // CESMRLocationField::CalculateEditorSize
   630             break;
   570 // ---------------------------------------------------------------------------
   631             }
   571 //
   632         default:
   572 TSize CESMRLocationField::CalculateEditorSize( const TSize& aSize )
   633             break;
   573     {
   634         }
   574     FUNC_LOG;
   635     return isUsed;
   575     TSize size( aSize );
   636     }
   576     size.iHeight -= KEditorDifference;
   637 
   577 
   638 
   578     if ( iLayout->CurrentFontZoom() == EAknUiZoomSmall ||
   639 // ---------------------------------------------------------------------------
   579         iLayout->CurrentFontZoom() == EAknUiZoomVerySmall)
   640 // CESMRLocationField::HandleSingletapEventL
   580         {
   641 // ---------------------------------------------------------------------------
   581         size.iHeight -= KEditorDifference;
   642 //
   582         }
   643 TBool CESMRLocationField::HandleSingletapEventL( const TPoint& aPosition )
   583     
   644     {
   584     return size;
   645     FUNC_LOG;
   585     }
   646     TBool ret( EFalse );
   586 
   647 
   587 // ---------------------------------------------------------------------------
   648     if( iTitle->Rect().Contains( aPosition ) ||
   588 // CESMRLocationField::BorderSize
   649             iFieldButton->Rect().Contains( aPosition ) )
   589 // ---------------------------------------------------------------------------
   650         {
   590 //
   651         NotifyEventL( EAknSoftkeyContextOptions );
   591 TSize CESMRLocationField::BorderSize() const
   652         HandleTactileFeedbackL();
   592     {
   653         ret = ETrue;
   593     FUNC_LOG;
   654         }
   594     TSize borderSize( CESMRIconField::BorderSize() );
   655 
   595     
   656     return ret;
   596     // If icon exists, we have to adjust the border width
   657     }
   597     if ( iIcon )
   658 
   598         {
   659 // ---------------------------------------------------------------------------
   599         borderSize.iWidth -= ( KIconSize.iWidth + 2 * KEditorDifference );
   660 // CESMRLocationField::HandleLongtapEventL
   600         }
   661 // ---------------------------------------------------------------------------
   601     
   662 //
   602     return borderSize;
   663 void CESMRLocationField::HandleLongtapEventL( const TPoint& aPosition )
   603     }
   664     {
   604 
   665     FUNC_LOG;
   605 // ---------------------------------------------------------------------------
   666 
   606 // CESMRLocationField::LayoutWaypointIcon
   667     if ( iLocation->Rect().Contains( aPosition ) )
   607 // ---------------------------------------------------------------------------
   668         {
   608 //
   669         if ( !iMenu )
   609 void CESMRLocationField::LayoutWaypointIcon()
   670             {
   610     {
   671             iMenu = CMRStylusPopupMenu::NewL( *this );
   611     FUNC_LOG;
   672             }
   612     if ( iIcon )
   673         RArray<CMRStylusPopupMenu::TMenuItem> items;
   613         {
   674         CleanupClosePushL( items );
   614         // Layout the icon
   675 
   615         TRect fieldRect( Rect() );
   676         HBufC* maps= NULL;
   616         TPoint iconPos( fieldRect.iBr.iX - KIconSize.iWidth,
   677         HBufC* myLocations = NULL;
   617                         fieldRect.iTl.iY + iLayout->IconTopMargin() );
   678 
   618         
   679         if ( FeaturesL().FeatureSupported(
   619         if ( CESMRLayoutManager::IsMirrored() )
   680                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   620             {
   681             {
   621             iconPos.iX = fieldRect.iTl.iX;
   682             maps = StringLoader::LoadLC(
   622             }
   683                     R_MEET_REQ_OPTIONS_ASSIGN_FROM_MAP,
   623         
   684                     iCoeEnv );
   624         iIcon->SetPosition( iconPos );
   685             CMRStylusPopupMenu::TMenuItem mapsItem(
   625         iIcon->SetSize( KIconSize );
   686                     *maps,
   626         }
   687                     EESMRCmdAssignFromMap );
   627     }
   688             items.AppendL( mapsItem );
   628 
   689             }
       
   690 
       
   691 //#ifdef RD_USE_MYLOCATIONUI
       
   692 
       
   693         myLocations = StringLoader::LoadLC(
       
   694                 R_MEET_REQ_OPTIONS_MY_LOCATIONS,
       
   695                 iCoeEnv );
       
   696 
       
   697         CMRStylusPopupMenu::TMenuItem myLocationsItem(
       
   698                 *myLocations,
       
   699                 EMRCommandMyLocations );
       
   700 
       
   701         items.AppendL( myLocationsItem );
       
   702 
       
   703 //#endif //RD_USE_MYLOCATIONUI
       
   704 
       
   705         if ( items.Count() == 1 )
       
   706             {
       
   707             // Only one option. Issue command directly
       
   708             NotifyEventL( items[ 0 ].iCommandId );
       
   709             }
       
   710         else if ( items.Count() > 1 )
       
   711             {
       
   712             iMenu->LaunchPopupL( items.Array(), aPosition );
       
   713             iMenuIsShown = ETrue;
       
   714             }
       
   715 
       
   716         if (myLocations )
       
   717             {
       
   718             CleanupStack::PopAndDestroy( myLocations );
       
   719             }
       
   720 
       
   721         if ( maps )
       
   722             {
       
   723             CleanupStack::PopAndDestroy( maps );
       
   724             }
       
   725 
       
   726         CleanupStack::PopAndDestroy( &items );
       
   727         }
       
   728 
       
   729     if( iTitle->Rect().Contains( aPosition ) ||
       
   730             iFieldButton->Rect().Contains( aPosition ) )
       
   731         {
       
   732         NotifyEventL( EAknSoftkeyContextOptions );
       
   733         HandleTactileFeedbackL();
       
   734         }
       
   735     }
       
   736 
       
   737 // ---------------------------------------------------------------------------
       
   738 // CESMRLocationField::DynInitMenuPaneL
       
   739 // ---------------------------------------------------------------------------
       
   740 //
       
   741 void CESMRLocationField::DynInitMenuPaneL(
       
   742         TInt aResourceId,
       
   743         CEikMenuPane* aMenuPane )
       
   744     {
       
   745     FUNC_LOG;
       
   746 
       
   747     if ( aResourceId == R_MR_EDITOR_ORGANIZER_MENU)
       
   748         {
       
   749         // Init assign options
       
   750         TInt numOptions( 1 ); // My Locations
       
   751 
       
   752         if ( FeaturesL().FeatureSupported(
       
   753                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
   754             {
       
   755             ++numOptions;
       
   756             }
       
   757 
       
   758         #ifndef RD_USE_MYLOCATIONUI
       
   759         // Disable My Locations
       
   760         --numOptions;
       
   761         #endif // RD_USE_MYLOCATIONUI
       
   762 
       
   763         switch ( numOptions )
       
   764             {
       
   765             case 0:
       
   766                 {
       
   767                 aMenuPane->SetItemDimmed( EESMRCmdAddLocation, ETrue );
       
   768                 break;
       
   769                 }
       
   770 
       
   771             case 1:
       
   772                 {
       
   773                 // Replace Add location with actual command
       
   774                 TInt pos( 0 );
       
   775                 CEikMenuPaneItem* item =
       
   776                         aMenuPane->ItemAndPos( EESMRCmdAddLocation, pos );
       
   777 
       
   778                 item->iData.iCascadeId = 0;
       
   779                 
       
   780                 if ( FeaturesL().FeatureSupported(
       
   781                         CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
   782                     {
       
   783                     item->iData.iCommandId = EESMRCmdAssignFromMap;
       
   784                     StringLoader::Load(item->iData.iText, 
       
   785                             R_MEET_REQ_OPTIONS_ASSIGN_FROM_MAP, iCoeEnv );
       
   786                     }
       
   787                 
       
   788 #ifdef RD_USE_MYLOCATIONUI
       
   789                 else
       
   790                     {
       
   791                     item->iData.iCommandId = EMRCommandMyLocations;
       
   792                     StringLoader::Load( item->iData.iText,
       
   793                             R_MEET_REQ_OPTIONS_MY_LOCATIONS, iCoeEnv );
       
   794                     }
       
   795 #endif //RD_USE_MYLOCATIONUI
       
   796                 
       
   797                 aMenuPane->SetItemDimmed( item->iData.iCommandId, EFalse );
       
   798                 break;
       
   799                 }
       
   800             default:
       
   801                 {
       
   802                 aMenuPane->SetItemDimmed( EESMRCmdAddLocation, EFalse );
       
   803                 break;
       
   804                 }
       
   805             }
       
   806         // Init Show/Search options
       
   807         TBool showOnMap( EFalse );
       
   808         TBool searchFromMap( EFalse );
       
   809 
       
   810         if ( iWaypointIcon )
       
   811             {
       
   812             // Coordinates available -> show on map
       
   813             showOnMap = ETrue;
       
   814             }
       
   815         else
       
   816             {
       
   817             HBufC* text = iLocation->GetTextInHBufL();
       
   818             if ( text && *text != iLocation->DefaultText() )
       
   819                 {
       
   820                 // Edited text in field -> enable search from map
       
   821                 searchFromMap = ETrue;
       
   822                 }
       
   823             delete text;
       
   824             }
       
   825 
       
   826         aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
       
   827         aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, !searchFromMap );
       
   828         }
       
   829     else if ( aResourceId == R_MR_EDITOR_LOCATION_MENU )
       
   830         {
       
   831         if ( !FeaturesL().FeatureSupported(
       
   832                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
   833             {
       
   834             aMenuPane->SetItemDimmed( EESMRCmdAssignFromMap, ETrue );
       
   835             }
       
   836 #ifndef RD_USE_MYLOCATIONUI
       
   837         aMenuPane->SetItemDimmed( EMRCommandMyLocations, ETrue );
       
   838 #endif //RD_USE_MYLOCATIONUI
       
   839         }
       
   840     }
       
   841 
       
   842 // ---------------------------------------------------------------------------
       
   843 // CESMRLocationField::SetContainerWindowL
       
   844 // ---------------------------------------------------------------------------
       
   845 //
       
   846 void CESMRLocationField::SetContainerWindowL(
       
   847         const CCoeControl& aContainer )
       
   848     {
       
   849     FUNC_LOG;
       
   850     CCoeControl::SetContainerWindowL( aContainer );
       
   851 
       
   852     iLocation->SetContainerWindowL( aContainer );
       
   853     iLocation->SetParent( this );
       
   854 
       
   855     iTitle->SetContainerWindowL( aContainer );
       
   856     iTitle->SetParent( this );
       
   857 
       
   858     iFieldButton->SetContainerWindowL(aContainer);
       
   859     iFieldButton->SetParent(this);
       
   860     }
       
   861 
       
   862 // ---------------------------------------------------------------------------
       
   863 // CESMRLocationField::OfferKeyEventL()
       
   864 // ---------------------------------------------------------------------------
       
   865 //
       
   866 TKeyResponse CESMRLocationField::OfferKeyEventL(
       
   867         const TKeyEvent& aEvent,
       
   868         TEventCode aType )
       
   869     {
       
   870     FUNC_LOG;
       
   871     TKeyResponse response( EKeyWasNotConsumed );
       
   872     response = iLocation->OfferKeyEventL ( aEvent, aType );
       
   873 
       
   874     if ( aType == EEventKey &&
       
   875          ( aEvent.iScanCode != EStdKeyUpArrow &&
       
   876            aEvent.iScanCode != EStdKeyDownArrow ))
       
   877         {
       
   878         iLocation->DrawDeferred();
       
   879         }
       
   880 
       
   881     return response;
       
   882     }
       
   883 
       
   884 // ---------------------------------------------------------------------------
       
   885 // CESMRLocationField::HandlePointerEventL
       
   886 // ---------------------------------------------------------------------------
       
   887 //
       
   888 TBool CESMRLocationField::HandleRawPointerEventL( const TPointerEvent &aPointerEvent )
       
   889     {
       
   890     if ( !iMenuIsShown )
       
   891         {
       
   892         CCoeControl::HandlePointerEventL( aPointerEvent );
       
   893         }
       
   894 
       
   895     return ETrue;
       
   896     }
       
   897 
       
   898 // ---------------------------------------------------------------------------
       
   899 // CESMRLocationField::ProcessCommandL
       
   900 // ---------------------------------------------------------------------------
       
   901 //
       
   902 void CESMRLocationField::ProcessCommandL( TInt aCommandId )
       
   903     {
       
   904     NotifyEventL( aCommandId );
       
   905 
       
   906     iMenuIsShown = EFalse;
       
   907     }
   629 // EOF
   908 // EOF