uifw/AvKon/src/AknQueryControl.cpp
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of AVKON query control.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    21 #include <uikon/eikdefmacros.h>
       
    22 #endif
       
    23 #include "aknQueryControl.h"    //This class
       
    24 #include <barsread.h>           //For TResourceReader
       
    25 
       
    26 #include <aknenv.h>
       
    27 #include <AknBitmapAnimation.h>
       
    28 #include <aknconsts.h>
       
    29 #include <avkon.mbg>
       
    30 #include <avkon.rsg>
       
    31 #include <aknborders.h>
       
    32 #include <AknEcs.h>
       
    33 #include <aknedsts.h>
       
    34 #include <AknLayoutDef.h>
       
    35 #include <AknLayout.lag>
       
    36 
       
    37 #include "akntextcontrol.h"
       
    38 #include "aknqueryeditorindicator.h"
       
    39 #include "aknEditStateIndicator.h"
       
    40 #include "AknUtils.h"
       
    41 #include "aknnoteattributes.h"
       
    42 
       
    43 #include <AknsDrawUtils.h>
       
    44 #include <AknsConstants.h>
       
    45 #include <AknsFrameBackgroundControlContext.h>
       
    46 #include <AknsPointerStore.h>
       
    47 
       
    48 #include <in_sock.h>
       
    49 
       
    50 #include <AknPictographInterface.h>
       
    51 #include <AknPictographDrawerInterface.h>
       
    52 
       
    53 #include "AknQueryExtension.h"
       
    54 #include <skinlayout.cdl.h>
       
    55 
       
    56 #include <AknIconUtils.h>
       
    57 #include "aknappui.h"
       
    58 #include <layoutmetadata.cdl.h>
       
    59 #include <aknlayoutscalable_avkon.cdl.h>
       
    60 #include <aknlayoutscalable_apps.cdl.h>
       
    61 #include "aknkeypad.h"
       
    62 
       
    63 
       
    64 #if defined( RD_SCALABLE_UI_V2)
       
    65 //class CAknButton is available from week 20 version 5.0 onwards
       
    66 #include "aknbutton.h"
       
    67 // For MAknMfneCommandObserver
       
    68 #include <aknmfnecommandobserver.h>
       
    69 #endif //if defined( RD_SCALABLE_UI_V2)
       
    70 #include <aknlocationed.h>
       
    71 
       
    72 #include <eikdialg.h>
       
    73 #include <eikdialogext.h>
       
    74 #include <gulicon.h>
       
    75 #include <StringLoader.h>
       
    76 
       
    77 #include <AknTasHook.h> // for testability hooks
       
    78 #include <tacticon.h>
       
    79 
       
    80 const TInt KPinCodeTacticonInterval = 30000000; // 30s
       
    81 const TInt KPinCodeMaxTacticons = 10;
       
    82 /*******
       
    83  * CAknQueryControlExtension
       
    84  */
       
    85  
       
    86 NONSHARABLE_CLASS(CAknQueryControlExtension) : public CBase
       
    87 {
       
    88 public:
       
    89     ~CAknQueryControlExtension();
       
    90     
       
    91 	CAknLocationEditor *iLocationEd;
       
    92 	
       
    93 	// Saved animation ID for later updates due to skin change.
       
    94 	// The value is saved in CAknQueryControl::ConstructQueryL().
       
    95 	TInt iAnimationId;
       
    96 	 
       
    97 	HBufC* iOriginalPrompt;
       
    98 	CAknButton* iBackspaceButton;
       
    99 	CAknKeypad* iKeypad;
       
   100 	
       
   101 	// Flag indicating whether or not the query CBA has been
       
   102 	// changed to ECS softkeys (Call and Cancel).
       
   103 	TBool iEcsCbaShown;
       
   104 
       
   105     // Timer for pincode query tacticon playback
       
   106     CPeriodic* iPinTacticonTimer;
       
   107     // Counter for tacticons played in a pincode query
       
   108     TInt iPinTacticonsPlayed;
       
   109 };
       
   110 
       
   111 CAknQueryControlExtension::~CAknQueryControlExtension()
       
   112     {
       
   113     delete iOriginalPrompt;
       
   114     delete iBackspaceButton;
       
   115     delete iKeypad;
       
   116 
       
   117     delete iPinTacticonTimer;
       
   118     iPinTacticonTimer = NULL;
       
   119     }
       
   120     
       
   121 CAknLocationEditor *CAknQueryControl::LocationEd() const
       
   122 {
       
   123    if (iExtension)
       
   124 	return iExtension->iLocationEd;
       
   125    else
       
   126 	return NULL;
       
   127 }
       
   128 CAknLocationEditor *&CAknQueryControl::LocationEd()
       
   129 {
       
   130 	return iExtension->iLocationEd;
       
   131 }
       
   132 
       
   133 
       
   134 /*****************************
       
   135  * CAknQueryExtension
       
   136  *****************************/
       
   137 
       
   138 void CAknQueryExtension::CreateEditorContextL()
       
   139     {
       
   140     delete iEditorContext;
       
   141     iEditorContext = NULL;
       
   142     iEditorContext = CAknsFrameBackgroundControlContext::NewL(
       
   143         KAknsIIDQsnFrInput, TRect(0,0,1,1), TRect(0,0,1,1), EFalse );
       
   144     }
       
   145 
       
   146 CAknsFrameBackgroundControlContext* CAknQueryExtension::EditorContext()
       
   147     {
       
   148     return iEditorContext;
       
   149     }
       
   150 
       
   151 CAknQueryExtension* CAknQueryExtension::Instance(
       
   152     const CAknQueryControl* aQueryControl )
       
   153     {
       
   154     return static_cast<CAknQueryExtension*>(
       
   155         AknsPointerStore::RetrievePointer( 
       
   156         static_cast<const CBase*>(aQueryControl) ) );
       
   157     }
       
   158 
       
   159 void CAknQueryExtension::CreateExtensionL(
       
   160     const CAknQueryControl* aQueryControl )
       
   161     {
       
   162     CAknQueryExtension* extension = CAknQueryExtension::NewL();
       
   163     CleanupStack::PushL( extension );
       
   164     AknsPointerStore::StorePointerL( 
       
   165         static_cast<const CBase*>(aQueryControl), extension );
       
   166     CleanupStack::Pop(); // extension
       
   167     }
       
   168 
       
   169 void CAknQueryExtension::DestroyExtension(
       
   170     const CAknQueryControl* aQueryControl )
       
   171     {
       
   172     delete Instance( aQueryControl );
       
   173     AknsPointerStore::RemovePointer( 
       
   174         static_cast<const CBase*>(aQueryControl) );
       
   175     }
       
   176 
       
   177 CAknQueryExtension* CAknQueryExtension::NewL()
       
   178     {
       
   179     return new (ELeave) CAknQueryExtension();
       
   180     }
       
   181 
       
   182 CAknQueryExtension::~CAknQueryExtension()
       
   183     {
       
   184     delete iEditorContext;
       
   185     }
       
   186 
       
   187 /*****************************
       
   188  * TAknQueryEcsObserver
       
   189  *****************************/
       
   190 
       
   191 /**
       
   192 *
       
   193 * This class is local to this cpp file.  It is used to ensure that all reference to aknecs.h is 
       
   194 * done within the CAknQueryControl class implementation and not in its header; that would cause
       
   195 * the client of CAknQueryControl (probably via CAknQueryDialog) to have to have Shared data and 
       
   196 * phone client .h files in the INCLUDE path 
       
   197 *
       
   198 */
       
   199 NONSHARABLE_CLASS(TAknQueryEcsObserver): public MAknEcsObserver
       
   200     {
       
   201     public:
       
   202         TAknQueryEcsObserver( CAknQueryControl* aParent );
       
   203         // May be called from a sub-class of CAknEcsDetector in another DLL
       
   204         IMPORT_C virtual void HandleEcsEvent(CAknEcsDetector* /*aDetector*/, CAknEcsDetector::TState aUpdatedState);
       
   205     private:
       
   206         CAknQueryControl* iParent; // Not owned; set by constructor initializaton
       
   207     };
       
   208 
       
   209 TAknQueryEcsObserver::TAknQueryEcsObserver( CAknQueryControl* aParent ): iParent( aParent )
       
   210     {
       
   211     }
       
   212 
       
   213 
       
   214 EXPORT_C void TAknQueryEcsObserver::HandleEcsEvent( CAknEcsDetector* /*aDetector*/,
       
   215                                                     CAknEcsDetector::TState aUpdatedState )
       
   216     {
       
   217     TRAP_IGNORE( iParent->SetEcsCbaVisibleL( aUpdatedState == CAknEcsDetector::ECompleteMatch ) );
       
   218     
       
   219     // Hide the emergency call number again.
       
   220     // Number should be visible only in Partial or Complete match state
       
   221     if ( aUpdatedState != CAknEcsDetector::EPartialMatch &&
       
   222          aUpdatedState != CAknEcsDetector::ECompleteMatch  )
       
   223         {
       
   224         if ( iParent->QueryType() == EPinLayout )
       
   225             {
       
   226             static_cast<CAknNumericSecretEditor*>
       
   227                 ( iParent->ControlByLayoutOrNull( EPinLayout ) )->RevealSecretText( EFalse );
       
   228             }
       
   229         }
       
   230     
       
   231     // This check must be last action in the routine.  
       
   232     // If the query is cancelled, the iParent is deleted!
       
   233     if ( aUpdatedState == CAknEcsDetector::ECallAttempted )
       
   234         {
       
   235         TRAP_IGNORE( iParent->CancelQueryL() );
       
   236         }
       
   237     }
       
   238 
       
   239 
       
   240 const TInt KMaxLinesInQuery=5;
       
   241 
       
   242 /*****************************
       
   243  * CAknQueryControl
       
   244  *****************************/
       
   245 
       
   246 /************************************************
       
   247  * KQueryTypeToLayout
       
   248  * 
       
   249  * The index into this table is the query type, 
       
   250  * according to the query constants enum in 
       
   251  * avkon.hrh. The values
       
   252  * are the layout methods according to the enum
       
   253  * TLayoutMethod. So this table maps a query type
       
   254  * as read from resource file to a lyout method
       
   255  ************************************************/
       
   256 
       
   257 const CAknQueryControl::TLayoutMethod KQueryTypeToLayout[]= {
       
   258     CAknQueryControl::EDataQueryLayoutM,   // NOT USED  
       
   259     CAknQueryControl::EDataQueryLayoutM,   // EDataLayout=1,
       
   260     CAknQueryControl::EConfQueryLayoutM,   // EConfirmationQueryLayout and EConfirmationLayout
       
   261     CAknQueryControl::ECodeQueryLayoutM,   // ECodeLayout,
       
   262     CAknQueryControl::ETimeQueryLayoutM,   // ETimeLayout,
       
   263     CAknQueryControl::EDateQueryLayoutM,   // EDateLayout,
       
   264     CAknQueryControl::ECodeQueryLayoutM,   // EListLayout,
       
   265     CAknQueryControl::ECodeQueryLayoutM,   // EMultiListLayout,
       
   266     CAknQueryControl::ECodeQueryLayoutM,   // EMultiLineDataLayout,
       
   267     CAknQueryControl::ETimeQueryLayoutM,   // EDurationLayout,
       
   268     CAknQueryControl::ECodeQueryLayoutM,   // ETextSoftNotification, - THIS IS USED FOR NOTES
       
   269     CAknQueryControl::EDataQueryLayoutM,   // ENumberLayout,
       
   270     CAknQueryControl::ECodeQueryLayoutM,   // EPinLayout,
       
   271     CAknQueryControl::EDataQueryLayoutM,   // EPhoneLayout,
       
   272     CAknQueryControl::EDataQueryLayoutM,   // EMessageQueryLayout,
       
   273     CAknQueryControl::EDataQueryLayoutM,   // EStaticSizeDataLayout
       
   274     CAknQueryControl::EDataQueryLayoutM,   // EFloatingPointLayout
       
   275     CAknQueryControl::ETimeQueryLayoutM,   // EIpLayout
       
   276     CAknQueryControl::EDataQueryLayoutM,    // EFixedPointLayout
       
   277     CAknQueryControl::EDataQueryLayoutM    // EDataLayoutAllowEmptyInput - USED FOR EMPTY INPUT
       
   278     };
       
   279 
       
   280 ///
       
   281 /// Construction and Destruction methods
       
   282 ///
       
   283 
       
   284 /**
       
   285  *
       
   286  */
       
   287 EXPORT_C CAknQueryControl::CAknQueryControl() :/* iQueryType(EConfirmationLayout),*/ iNumberOfEditorLines(-1), iHasEditor(EFalse)
       
   288     {
       
   289     AKNTASHOOK_ADD( this, "CAknQueryControl" );
       
   290     }
       
   291 
       
   292 /**
       
   293  *
       
   294  */
       
   295 EXPORT_C CAknQueryControl::~CAknQueryControl()
       
   296     {
       
   297     AKNTASHOOK_REMOVE();
       
   298 	if (iEdwin)
       
   299         AknsUtils::DeregisterControlPosition(iEdwin);
       
   300     else if (iNumberEdwin)
       
   301         AknsUtils::DeregisterControlPosition(iNumberEdwin);
       
   302     else if (iFloatingPointEditor)
       
   303         AknsUtils::DeregisterControlPosition(iFloatingPointEditor);
       
   304     else if (iDateEdwin)
       
   305         AknsUtils::DeregisterControlPosition(iDateEdwin);
       
   306     else if (iTimeEdwin)
       
   307         AknsUtils::DeregisterControlPosition(iTimeEdwin);
       
   308     else if (iDurationEdwin)
       
   309         AknsUtils::DeregisterControlPosition(iDurationEdwin);
       
   310     else if (iSecretEd)
       
   311         AknsUtils::DeregisterControlPosition(iSecretEd);
       
   312     else if (iPinEdwin)
       
   313         AknsUtils::DeregisterControlPosition(iPinEdwin);
       
   314     else if (iExtension && LocationEd())
       
   315     	AknsUtils::DeregisterControlPosition(LocationEd());
       
   316     
       
   317 
       
   318     delete iLineWidths;
       
   319     delete iEcsDetector;
       
   320     delete iEcsObserver;
       
   321     delete iPrompt;
       
   322     delete iEditIndicator;
       
   323     if ( iImage && iImage->IsPictureOwnedExternally() )
       
   324         {
       
   325         delete ((CApaMaskedBitmap*) iImage->Bitmap());
       
   326         }
       
   327     delete iImage;
       
   328     delete iEdwin;
       
   329     delete iDateEdwin;
       
   330     delete iTimeEdwin;
       
   331     delete iDurationEdwin;
       
   332     delete iSecretEd;
       
   333     delete iNumberEdwin;
       
   334     delete iPinEdwin;
       
   335     delete iFloatingPointEditor;
       
   336     if (iExtension)
       
   337     delete LocationEd();
       
   338     delete iAnimation;
       
   339     if ( iQueryType ) // As we must maintain BC, we cannot add private members or change protected members. 
       
   340         {         // We have to use iQueryType to distinguish if the context was added to stack or not
       
   341               // This won't affect to normal usage of iQueryType any way, only a way to indicate if 
       
   342                           // construction was succesful until context was set. 
       
   343         CCoeBrushAndPenContext* brushAndPenContext = (CCoeBrushAndPenContext*)ControlContext();
       
   344         delete brushAndPenContext;
       
   345         }
       
   346     CAknQueryExtension::DestroyExtension( this );
       
   347 	delete iExtension;
       
   348         
       
   349 #if defined( RD_SCALABLE_UI_V2)
       
   350     delete iIncreaseValueButton;
       
   351     delete iDecreaseValueButton;
       
   352 #endif //defined( RD_SCALABLE_UI_V2)
       
   353     }
       
   354 
       
   355 /**
       
   356  * Construct from resource
       
   357  */
       
   358 EXPORT_C void CAknQueryControl::ConstructFromResourceL(TResourceReader &aRes)
       
   359     {
       
   360     // Construct extension
       
   361     CAknQueryExtension::CreateExtensionL( this );
       
   362 	iExtension = new (ELeave)CAknQueryControlExtension;
       
   363     
       
   364     iEcsObserver   = new (ELeave) TAknQueryEcsObserver(this);
       
   365     iEditIndicator = CAknQueryEditIndicator::NewL(this);
       
   366     iEditIndicator->SetObserver(this);
       
   367     
       
   368     iLineWidths = new(ELeave)CArrayFixFlat<TInt>(5);
       
   369 
       
   370     CCoeBrushAndPenContext* brushAndPenContext=CCoeBrushAndPenContext::NewL();
       
   371     brushAndPenContext->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   372     SetControlContext(brushAndPenContext);
       
   373     // This must be straight after setting Graphics Context, it is the only way to indicate
       
   374     // brushAndPenContext is added to stack or not.
       
   375     iQueryType = aRes.ReadUint16();
       
   376     __ASSERT_DEBUG(iQueryType, Panic(EAknPanicLayoutResourceProblem));
       
   377     
       
   378     iEditIndicator->SetQueryType(iQueryType);
       
   379     
       
   380     SetLineWidthsL();
       
   381     ReadPromptL(aRes);
       
   382     ConstructQueryL(aRes);
       
   383 
       
   384     CEikDialog* dlg;
       
   385     MopGetObject( dlg );
       
   386     if ( dlg )
       
   387         {
       
   388         if ( CAknEnv::Static()->TransparencyEnabled() )
       
   389             {
       
   390             dlg->Extension()->iPublicFlags.Set( CEikDialogExtension::EClipChildControlRect );
       
   391             }
       
   392 
       
   393         // set dialog's window as button group's container window in case a fullscreen
       
   394         // virtual input dialog is requested
       
   395         if ( EmbeddedVirtualInput() )
       
   396             {   
       
   397             CEikCba* cba = static_cast<CEikCba*>( dlg->ButtonGroupContainer().ButtonGroup() );
       
   398             cba->SetContainerWindowL( *this );
       
   399             dlg->ButtonGroupContainer().SetContainerWindowL( *cba );
       
   400             dlg->ButtonGroupContainer().SetParent( NULL );
       
   401             cba->SetPosition( TPoint( 0, 0 ) );
       
   402             
       
   403             iExtension->iKeypad = CAknKeypad::NewL( *this, iQueryType );
       
   404             }
       
   405         }
       
   406     }
       
   407 
       
   408 void CAknQueryControl::ConstructQueryL(TResourceReader& aRes)
       
   409     {
       
   410     switch(iQueryType)
       
   411         {
       
   412         case EConfirmationQueryLayout:
       
   413             {
       
   414             TPtrC bmpFile=aRes.ReadTPtrC();
       
   415             TInt bmpId=aRes.ReadInt16();
       
   416             TInt bmpMask=aRes.ReadInt16();
       
   417             TInt animationId = aRes.ReadUint32();
       
   418 
       
   419             // Animation overrides bitmap if it is set.
       
   420             if ( (animationId == 0) && (bmpFile.Length() != 0))
       
   421                 {   
       
   422                 iImage = new(ELeave) CEikImage;
       
   423                 iImage->SetContainerWindowL(*this);
       
   424                 
       
   425                 TBool skinnedFound( EFalse );
       
   426                 if ( bmpFile.CompareF(KAvkonBitmapFile) == 0 ) // Skinning is supported only avkon bitmaps
       
   427                     {
       
   428                     TAknsItemID id;
       
   429                     id.Set(0,0);
       
   430                     id = CAknNoteAttributes::GetSkinnedBitmapID(bmpId);
       
   431                     if ( id.iMajor && id.iMinor ) // skin id found, try loading
       
   432                         {
       
   433                         CApaMaskedBitmap* bitmap = NULL;
       
   434                         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   435 
       
   436                         TRAPD( err, bitmap = AknsUtils::CreateMaskedBitmapL(skin,id));
       
   437                         if ( !err ) 
       
   438                             {
       
   439                             CFbsBitmap* mask = bitmap->Mask();
       
   440                             iImage->SetPicture(bitmap,mask);
       
   441                             iImage->SetPictureOwnedExternally(ETrue);
       
   442                             skinnedFound = ETrue;
       
   443                             }
       
   444                         }
       
   445                     }
       
   446                 if ( !skinnedFound) 
       
   447                     {
       
   448                     iImage->CreatePictureFromFileL(bmpFile,bmpId,bmpMask);
       
   449                     }
       
   450                 }
       
   451             else
       
   452                 {
       
   453                 if (animationId == 0) 
       
   454                     {
       
   455                     // Default animation if neither bitmap nor animation is set.
       
   456                     animationId = R_QGN_NOTE_QUERY_ANIM;
       
   457                     }
       
   458                 }
       
   459             
       
   460             if (animationId != 0)
       
   461                 {
       
   462                 if (!iAnimation)
       
   463                     {// no animation previously set
       
   464                     // Save animation ID for possible skin changes
       
   465                     
       
   466                     //iExtension->iAnimationId = animationId; 
       
   467 
       
   468                     TRAPD( err, SetAnimationL( animationId ) );
       
   469                     if ( err != KErrNone )
       
   470                         {
       
   471                         iAnimation = NULL;
       
   472                         }
       
   473                     }
       
   474                 }
       
   475             break;
       
   476             }
       
   477         case EDataLayoutAllowEmptyInput:
       
   478             {
       
   479             CAknQueryExtension* extension = QueryExtension();
       
   480             if( extension )
       
   481                 {
       
   482                 extension->iAllowEmptyInput = ETrue;
       
   483                 }
       
   484             iQueryType = EDataLayout;    
       
   485             // fall through
       
   486             }
       
   487         case EDataLayout:
       
   488         case EStaticSizeDataLayout:
       
   489             {
       
   490             iEdwin = new(ELeave)CEikEdwin;
       
   491             iEdwin->SetContainerWindowL(*this);
       
   492             iEdwin->SetEdwinObserver(this);
       
   493             iEdwin->ConstructFromResourceL(aRes);
       
   494             iEdwin->SetObserver(this);
       
   495             iEdwin->SetEdwinSizeObserver(this);
       
   496             
       
   497             
       
   498             
       
   499 #if defined( RD_SCALABLE_UI_V2)
       
   500 
       
   501             if ( AknLayoutUtils::PenEnabled() )
       
   502                 {
       
   503                 if ( EmbeddedVirtualInput() )
       
   504         			{
       
   505       				CreateBackspaceButtonL();
       
   506       				//HACK
       
   507       				iEdwin->AddFlagToUserFlags( CEikEdwin::EAvkonDisableVKB );
       
   508       				
       
   509       				iEdwin->SetMaximumHeightInLines( 1 );
       
   510       				
       
   511     
       
   512         			}
       
   513                 }
       
   514             
       
   515 #endif //if defined( RD_SCALABLE_UI_V2)
       
   516             
       
   517 
       
   518 //Set maximum height in lines to KMaxLinesInQuery if it is unset, or an
       
   519 //invalid value has been used.
       
   520             if (!iEdwin->MaximumHeightInLines()||iEdwin->MaximumHeightInLines()>KMaxLinesInQuery)
       
   521                 iEdwin->SetMaximumHeightInLines(KMaxLinesInQuery);
       
   522 
       
   523 //If the maximum number of lines is 1, 
       
   524 //  ensure flags are consistent with a single-line editor scrolling mechanism
       
   525 //else
       
   526 //  ensure flags are consistent with a multi-line editor scrolling mechanism
       
   527 
       
   528             if (1==iEdwin->MaximumHeightInLines())
       
   529                 iEdwin->RemoveFlagFromUserFlags(EEikEdwinNoHorizScrolling | EEikEdwinResizable);
       
   530             else
       
   531                 iEdwin->AddFlagToUserFlags(EEikEdwinNoHorizScrolling | EEikEdwinResizable);
       
   532             if (EDataLayout==iQueryType && iEdwin->InputCapabilities().IsNone())
       
   533                 {
       
   534                 iEdwin->SetAknEditorAllowedInputModes(EAknEditorTextInputMode | EAknEditorNumericInputMode );              
       
   535                 }
       
   536             break;
       
   537             }
       
   538         case ECodeLayout:
       
   539             {
       
   540             iSecretEd = new(ELeave)CEikSecretEditor;
       
   541             iSecretEd->SetContainerWindowL(*this);
       
   542             iSecretEd->ConstructFromResourceL(aRes);
       
   543             iSecretEd->SetObserver(this);
       
   544             iSecretEd->SetSkinTextColorL(EAknsCIQsnTextColorsCG27);
       
   545             
       
   546             
       
   547 #if defined( RD_SCALABLE_UI_V2)
       
   548 
       
   549             if ( AknLayoutUtils::PenEnabled() )
       
   550                 {
       
   551                 if ( EmbeddedVirtualInput() )
       
   552         			{
       
   553       				CreateBackspaceButtonL();
       
   554       				iSecretEd->SetFeature(CEikSecretEditor::EDisablePenInput, 1);
       
   555         			}
       
   556                 }
       
   557             
       
   558 #endif //if defined( RD_SCALABLE_UI_V2)
       
   559             
       
   560             break;
       
   561             }
       
   562         case EDateLayout:
       
   563             {
       
   564             iDateEdwin = new(ELeave)CEikDateEditor;
       
   565             iDateEdwin->SetContainerWindowL(*this);
       
   566             iDateEdwin->ConstructFromResourceL(aRes);
       
   567             iDateEdwin->SetObserver(this);
       
   568             iDateEdwin->SetSkinTextColorL(EAknsCIQsnTextColorsCG27);
       
   569             
       
   570 
       
   571 #if defined( RD_SCALABLE_UI_V2)
       
   572 
       
   573             if ( AknLayoutUtils::PenEnabled() )
       
   574                 {
       
   575        			if ( EmbeddedVirtualInput() )
       
   576         			{
       
   577       				CreateBackspaceButtonL();
       
   578       				iDateEdwin->SetFeature(CEikMfne::EDisablePenInput, 1);
       
   579         			}
       
   580         		else
       
   581         			{
       
   582         			iDateEdwin->SetFeature( CEikMfne::EFingerSupport, CEikMfne::EnableWithAllHighlight );
       
   583         			}
       
   584                 }
       
   585             
       
   586 #endif //if defined( RD_SCALABLE_UI_V2)
       
   587             
       
   588             break;
       
   589             }
       
   590         case ETimeLayout:
       
   591             {
       
   592             iTimeEdwin = new(ELeave)CEikTimeEditor;
       
   593             iTimeEdwin->SetContainerWindowL(*this);
       
   594             iTimeEdwin->ConstructFromResourceL(aRes);
       
   595             iTimeEdwin->SetObserver(this);
       
   596             iTimeEdwin->SetSkinTextColorL(EAknsCIQsnTextColorsCG27);
       
   597             
       
   598             
       
   599 #if defined( RD_SCALABLE_UI_V2)
       
   600 
       
   601             if ( AknLayoutUtils::PenEnabled() )
       
   602                 {
       
   603                 if ( EmbeddedVirtualInput() )
       
   604         			{
       
   605       				CreateBackspaceButtonL();
       
   606       				iTimeEdwin->SetFeature(CEikMfne::EDisablePenInput, 1);
       
   607         			}
       
   608         		else
       
   609         			{
       
   610         			iTimeEdwin->SetFeature( CEikMfne::EFingerSupport, CEikMfne::EnableWithAllHighlight );
       
   611         			}
       
   612                 }
       
   613                 
       
   614 #endif //if defined( RD_SCALABLE_UI_V2)
       
   615             
       
   616             break;
       
   617             }
       
   618         case EDurationLayout:
       
   619             {
       
   620             iDurationEdwin = new(ELeave)CEikDurationEditor;
       
   621             iDurationEdwin->SetContainerWindowL(*this);
       
   622             iDurationEdwin->ConstructFromResourceL(aRes);
       
   623             iDurationEdwin->SetObserver(this);
       
   624             iDurationEdwin->SetSkinTextColorL(EAknsCIQsnTextColorsCG27);
       
   625 #if defined( RD_SCALABLE_UI_V2)
       
   626 
       
   627             if ( AknLayoutUtils::PenEnabled() )
       
   628                 {
       
   629                 iDurationEdwin->SetFeature( CEikMfne::EFingerSupport, CEikMfne::EnableWithAllHighlight );
       
   630                 }
       
   631             
       
   632 #endif //if defined( RD_SCALABLE_UI_V2)            
       
   633             break;
       
   634             }
       
   635         case ENumberLayout:
       
   636             {
       
   637             iNumberEdwin = new(ELeave)CAknIntegerEdwin;
       
   638             iNumberEdwin->SetContainerWindowL(*this);
       
   639             iNumberEdwin->ConstructFromResourceL(aRes);
       
   640             iNumberEdwin->SetObserver(this);
       
   641             break;
       
   642             }
       
   643         case EPinLayout:
       
   644             {
       
   645             iPinEdwin = new(ELeave)CAknNumericSecretEditor;
       
   646             iPinEdwin->SetContainerWindowL(*this);
       
   647             iPinEdwin->ConstructFromResourceL(aRes);
       
   648             iPinEdwin->SetObserver(this);
       
   649             iPinEdwin->SetSkinTextColorL(EAknsCIQsnTextColorsCG27);
       
   650             
       
   651             // reset tacticon playback counter and play tacticon, which
       
   652             // also resets the tacticon timer
       
   653             if ( iExtension )
       
   654                 {
       
   655                 iExtension->iPinTacticonsPlayed = 0;
       
   656                 PlayPinCodeTacticon();
       
   657                 }
       
   658             
       
   659 #if defined( RD_SCALABLE_UI_V2)
       
   660 
       
   661             if ( AknLayoutUtils::PenEnabled() )
       
   662                 {
       
   663                 if ( EmbeddedVirtualInput() )
       
   664         			{
       
   665       				CreateBackspaceButtonL();
       
   666       				iPinEdwin->SetFeature(CEikSecretEditor::EDisablePenInput, 1);
       
   667         			}
       
   668                 }
       
   669             
       
   670 #endif //if defined( RD_SCALABLE_UI_V2)
       
   671                    
       
   672             break;
       
   673             }
       
   674         case EPhoneLayout:
       
   675             {
       
   676             iEdwin = new(ELeave)CEikEdwin;
       
   677             iEdwin->AddFlagToUserFlags(EEikEdwinAlternativeWrapping);
       
   678             iEdwin->SetContainerWindowL(*this);
       
   679             iEdwin->SetEdwinObserver(this);
       
   680             iEdwin->ConstructFromResourceL(aRes);
       
   681             iEdwin->SetEdwinSizeObserver(this);
       
   682 
       
   683 //Set maximum height in lines to KMaxLinesInQuery if it is unset, or an
       
   684 //invalid value has been used.
       
   685             if (!iEdwin->MaximumHeightInLines()||iEdwin->MaximumHeightInLines()>KMaxLinesInQuery)
       
   686                 iEdwin->SetMaximumHeightInLines(KMaxLinesInQuery);
       
   687 
       
   688 //If the maximum number of lines is 1, 
       
   689 //  ensure flags are consistent with a single-line editor scrolling mechanism
       
   690 //else
       
   691 //  ensure flags are consistent with a multi-line editor scrolling mechanism
       
   692 
       
   693             if (1==iEdwin->MaximumHeightInLines())
       
   694                 iEdwin->RemoveFlagFromUserFlags(EEikEdwinNoHorizScrolling | EEikEdwinResizable);
       
   695             else
       
   696                 iEdwin->AddFlagToUserFlags(EEikEdwinNoHorizScrolling | EEikEdwinResizable);
       
   697             iEdwin->SetAknEditorInputMode(EAknEditorNumericInputMode);
       
   698             iEdwin->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);
       
   699             iEdwin->SetObserver(this);
       
   700             break;
       
   701             }
       
   702         case EFloatingPointLayout:
       
   703             {
       
   704             iFloatingPointEditor = new ( ELeave ) CEikFloatingPointEditor;
       
   705             iFloatingPointEditor->SetContainerWindowL( *this );
       
   706             iFloatingPointEditor->SetEdwinObserver( this );
       
   707             iFloatingPointEditor->ConstructFromResourceL( aRes );
       
   708             iFloatingPointEditor->SetAknEditorAllowedInputModes( EAknEditorNumericInputMode );
       
   709             iFloatingPointEditor->SetObserver(this);
       
   710             break;
       
   711             }
       
   712         default:
       
   713               __ASSERT_DEBUG(0, Panic(EAknPanicLayoutControlResourceProblem));
       
   714             break;
       
   715     }
       
   716 
       
   717     // Construct editor context
       
   718     CAknQueryExtension* extension = QueryExtension();
       
   719     if( extension )
       
   720         {
       
   721         extension->CreateEditorContextL();
       
   722         }
       
   723     }
       
   724 
       
   725 TInt CAknQueryControl::PinCodeTimeoutCallback( TAny* aThis )
       
   726     {
       
   727     // play tacticon
       
   728     static_cast<CAknQueryControl*>( aThis )->PlayPinCodeTacticon();
       
   729     
       
   730     return KErrNone;
       
   731     }
       
   732 
       
   733 void CAknQueryControl::PlayPinCodeTacticon()
       
   734     {
       
   735     // play tacticon
       
   736     RTacticon client;
       
   737     if ( KErrNone == client.Connect() )
       
   738     	{
       
   739     	client.PlayTacticon( ENeutralTacticon );
       
   740     	client.Close();
       
   741     	}
       
   742     
       
   743     if ( iExtension )
       
   744         {
       
   745         iExtension->iPinTacticonsPlayed++;
       
   746         
       
   747         // if the maximum amount of pincode query tacticons has not been
       
   748         // reached, reset timer
       
   749         if ( iExtension->iPinTacticonsPlayed < KPinCodeMaxTacticons )
       
   750             {
       
   751             ResetPinCodeTacticonTimer();
       
   752             }
       
   753         else
       
   754             {
       
   755             // max amount reached, stop timer for good
       
   756             StopPinCodeTacticonTimer();
       
   757             }
       
   758         }
       
   759     }
       
   760 
       
   761 void CAknQueryControl::ResetPinCodeTacticonTimer()
       
   762     {
       
   763     // stop old timer
       
   764     StopPinCodeTacticonTimer();
       
   765 
       
   766     if ( iExtension )
       
   767         {
       
   768         // create new one
       
   769         iExtension->iPinTacticonTimer = 
       
   770             CPeriodic::New( CActive::EPriorityStandard );
       
   771         
       
   772         // start timer, if creation succeeded
       
   773         if ( iExtension->iPinTacticonTimer )
       
   774             {
       
   775             iExtension->iPinTacticonTimer->Start( 
       
   776                         KPinCodeTacticonInterval, KPinCodeTacticonInterval,
       
   777                         TCallBack( PinCodeTimeoutCallback, this ) );
       
   778             }
       
   779         }
       
   780     }
       
   781 
       
   782 void CAknQueryControl::StopPinCodeTacticonTimer()
       
   783     {
       
   784     if ( iExtension )
       
   785         {
       
   786         // delete timer
       
   787         delete iExtension->iPinTacticonTimer;
       
   788         
       
   789         // set the timer null, so that it will not be used again
       
   790         iExtension->iPinTacticonTimer = NULL;
       
   791         }
       
   792     }
       
   793 
       
   794 ///
       
   795 /// CCoeControl methods
       
   796 ///
       
   797 
       
   798 /**
       
   799  *Returns the control owned by this control by the index
       
   800  */
       
   801 CCoeControl* CAknQueryControl::ComponentControl(TInt anIndex) const
       
   802     {
       
   803     if ( AknLayoutUtils::PenEnabled() )
       
   804         {
       
   805         CCoeControl* cba = NULL;
       
   806         CEikDialog* dialog;
       
   807         
       
   808         const_cast<CAknQueryControl*>( this )->MopGetObject( dialog );
       
   809         
       
   810         if ( dialog && EmbeddedVirtualInput() )
       
   811             {
       
   812             cba = static_cast<CEikCba*>( dialog->ButtonGroupContainer().ButtonGroup() );
       
   813             }
       
   814 
       
   815         CCoeControl* controls[] = { iPrompt, 
       
   816                                     iEditIndicator, 
       
   817                                 iEdwin, iDateEdwin, LocationEd(), 
       
   818                                     iTimeEdwin, iSecretEd, iDurationEdwin,
       
   819                                     iNumberEdwin, iPinEdwin, iFloatingPointEditor,
       
   820                                     iImage, iAnimation
       
   821 #if defined( RD_SCALABLE_UI_V2)                              
       
   822                                     ,iIncreaseValueButton, iDecreaseValueButton
       
   823                                     ,( iExtension && iExtension->iKeypad) ? cba : NULL
       
   824                                     ,iExtension ? iExtension->iKeypad : NULL
       
   825                                     ,iExtension ? iExtension->iBackspaceButton : NULL
       
   826 #endif //if defined( RD_SCALABLE_UI_V2)                         
       
   827                                     };
       
   828         
       
   829         for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++)
       
   830             {
       
   831             //subtle: index is decremented only if control is not NULL!
       
   832             if (controls[ii] && anIndex-- == 0) 
       
   833                 {
       
   834                 return controls[ii];
       
   835                 }
       
   836             }
       
   837         }
       
   838     else
       
   839         {
       
   840         CCoeControl* controls[] = { iPrompt, 
       
   841                                     iEditIndicator, 
       
   842                                 	iEdwin, iDateEdwin, LocationEd(), 
       
   843                                     iTimeEdwin, iSecretEd, iDurationEdwin,
       
   844                                     iNumberEdwin, iPinEdwin, iFloatingPointEditor,
       
   845                                     iImage, iAnimation
       
   846                                     };
       
   847         //TODO add buttons to array
       
   848 
       
   849         
       
   850         for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++)
       
   851             {
       
   852             //subtle: index is decremented only if control is not NULL!
       
   853             if (controls[ii] && anIndex-- == 0) 
       
   854                 {
       
   855                 return controls[ii];
       
   856                 }
       
   857             }
       
   858         }
       
   859     return NULL;
       
   860     }     
       
   861 
       
   862 /**
       
   863  * Returns the number of controls inside the compound control.
       
   864  */
       
   865 TInt CAknQueryControl::CountComponentControls() const
       
   866     {
       
   867     TInt count = 0;
       
   868     if ( AknLayoutUtils::PenEnabled() )
       
   869         {
       
   870         CCoeControl* cba = NULL;
       
   871         CEikDialog* dialog;
       
   872         
       
   873         const_cast<CAknQueryControl*>( this )->MopGetObject( dialog );
       
   874         
       
   875         if ( dialog && EmbeddedVirtualInput() )
       
   876             {
       
   877             cba = static_cast<CEikCba*>( dialog->ButtonGroupContainer().ButtonGroup() );
       
   878             }
       
   879 
       
   880         CCoeControl* controls[] = { iPrompt,
       
   881                                     iEditIndicator,
       
   882                                     iEdwin, iDateEdwin, LocationEd(),
       
   883                                     iTimeEdwin, iSecretEd, iDurationEdwin,
       
   884                                     iNumberEdwin, iPinEdwin, iFloatingPointEditor,
       
   885                                     iImage, iAnimation
       
   886 #if defined( RD_SCALABLE_UI_V2)                              
       
   887                                     ,iIncreaseValueButton, iDecreaseValueButton,
       
   888                                     ( iExtension && iExtension->iKeypad) ? cba : NULL,
       
   889                                     iExtension ? iExtension->iKeypad : NULL,
       
   890                                     iExtension ? iExtension->iBackspaceButton : NULL
       
   891 #endif //if defined( RD_SCALABLE_UI_V2)                                   
       
   892                                 };
       
   893                                 
       
   894         for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++)
       
   895             {
       
   896             if (controls[ii])
       
   897                 {
       
   898                 count++;
       
   899                 }
       
   900             }
       
   901         }
       
   902     else
       
   903         {
       
   904         CCoeControl* controls[] = { iPrompt,
       
   905                                     iEditIndicator,
       
   906                                 	iEdwin, iDateEdwin, LocationEd(),
       
   907                                     iTimeEdwin, iSecretEd, iDurationEdwin,
       
   908                                     iNumberEdwin, iPinEdwin, iFloatingPointEditor,
       
   909                                     iImage, iAnimation
       
   910                                 };
       
   911                                 
       
   912         for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++)
       
   913             {
       
   914             if (controls[ii])
       
   915                 {
       
   916                 count++;
       
   917                 }
       
   918             }
       
   919         }
       
   920     return count;
       
   921     }
       
   922 
       
   923 /**
       
   924  * Forward key event to the editor
       
   925  */
       
   926 EXPORT_C TKeyResponse CAknQueryControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType) 
       
   927     {
       
   928     TKeyResponse response( EKeyWasNotConsumed );
       
   929 
       
   930     // Send key handling for emergency call support
       
   931     if ( aKeyEvent.iCode == EKeyYes )
       
   932         {
       
   933         if ( iEcsDetector )
       
   934             {
       
   935             AttemptEmergencyCallL();
       
   936             }
       
   937         // Always eat the key, however, as in former handling of this key
       
   938         response = EKeyWasConsumed;
       
   939         }
       
   940 
       
   941     CCoeControl* ctrl = ControlByLayoutOrNull( iQueryType );
       
   942     if ( ctrl && ctrl->IsFocused() )
       
   943         {
       
   944         response = ctrl->OfferKeyEventL( aKeyEvent, aType );
       
   945         
       
   946         // pin query received key, reset timer if it exists
       
   947         if ( iExtension && iExtension->iPinTacticonTimer && 
       
   948              iQueryType == EPinLayout && response == EKeyWasConsumed )
       
   949             {
       
   950             ResetPinCodeTacticonTimer();
       
   951             }
       
   952         }
       
   953     return response;
       
   954     }
       
   955 
       
   956 /**
       
   957  * Handle a focus changed
       
   958  */
       
   959 void CAknQueryControl::FocusChanged(TDrawNow aDrawNow)
       
   960     {
       
   961     CCoeControl* ctrl = ControlByLayoutOrNull( iQueryType );
       
   962     if (ctrl)
       
   963         {
       
   964         ctrl->DrawDeferred();
       
   965         ctrl->SetFocus( IsFocused(), aDrawNow );
       
   966         Layout();
       
   967         }
       
   968     if ( iAnimation )
       
   969         {
       
   970         iAnimation->SetFocus( IsFocused(), aDrawNow );
       
   971         }
       
   972     }
       
   973 
       
   974 void CAknQueryControl::PrepareForFocusLossL()
       
   975     {
       
   976     CCoeControl* ctrl = ControlByLayoutOrNull( iQueryType );
       
   977     if (ctrl)
       
   978         {
       
   979         ctrl->PrepareForFocusLossL(); 
       
   980         }
       
   981     }
       
   982 
       
   983 ///
       
   984 /// Observer related methods (Handle* methods)
       
   985 ///
       
   986 
       
   987 //
       
   988 //Set observer for component
       
   989 //
       
   990 EXPORT_C void CAknQueryControl::SetQueryControlObserver(MAknQueryControlObserver* aQueryControlObserver)
       
   991     {
       
   992     iQueryControlObserver = aQueryControlObserver;
       
   993     }
       
   994 
       
   995 //
       
   996 //Handle edwin events
       
   997 //
       
   998 EXPORT_C void CAknQueryControl::HandleEdwinEventL(CEikEdwin* /*aEdwin*/,TEdwinEvent /*aEventType*/)
       
   999     {
       
  1000 
       
  1001     }
       
  1002 
       
  1003 //
       
  1004 //Call observer when edwin size changed
       
  1005 //
       
  1006 EXPORT_C TBool CAknQueryControl::HandleEdwinSizeEventL(CEikEdwin* /*aEdwin*/, TEdwinSizeEvent /*aEventType*/, TSize /*aDesirableEdwinSize*/)
       
  1007     {
       
  1008     TInt editorNbr = NbrOfEditorLines(); 
       
  1009     TInt maxLines = KMaxLinesInQuery; 
       
  1010     if (iEdwin)
       
  1011         {
       
  1012         const TInt mHIL = iEdwin->MaximumHeightInLines();
       
  1013         if (mHIL)
       
  1014             {
       
  1015             maxLines = mHIL;
       
  1016             }
       
  1017         }
       
  1018 
       
  1019     if(iQueryControlObserver  && editorNbr <= maxLines)
       
  1020         {
       
  1021         iQueryControlObserver->HandleQueryEditorSizeEventL(this,MAknQueryControlObserver::EQueryControltSizeChanging);
       
  1022         }
       
  1023     return EFalse;
       
  1024     }
       
  1025 
       
  1026 
       
  1027 EXPORT_C void CAknQueryControl::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
       
  1028     {
       
  1029     if (iEditIndicator && aControl == iEditIndicator)
       
  1030     	{
       
  1031     	if ( iExtension && iExtension->iKeypad )
       
  1032         	{
       
  1033         	iExtension->iKeypad->SetState(iEditIndicator->State());
       
  1034         	}
       
  1035         return;	
       
  1036     	}
       
  1037     
       
  1038     if(iQueryControlObserver && aEventType == EEventStateChanged)
       
  1039         {
       
  1040         if ( iNumberEdwin || iFloatingPointEditor)
       
  1041             {
       
  1042             TInt intValue;
       
  1043             TReal realValue;
       
  1044             CAknNumericEdwin::TValidationStatus status = iNumberEdwin ?
       
  1045                 iNumberEdwin->GetTextAsInteger(intValue) : 
       
  1046                     iFloatingPointEditor->GetValueAsReal(realValue);
       
  1047             switch( status )
       
  1048                 {
       
  1049                 case CAknNumericEdwin::EEmpty:
       
  1050                     {
       
  1051                     iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorEmpty);   
       
  1052                     break;
       
  1053                     }
       
  1054                 case CAknNumericEdwin::EValueTooLarge:
       
  1055                     {
       
  1056                     iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorValueTooLarge);   
       
  1057                     break;
       
  1058                     }
       
  1059                 case CAknNumericEdwin::EValueTooSmall:
       
  1060                     {
       
  1061                     iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorValueTooSmall);   
       
  1062                     break;
       
  1063                     }
       
  1064                 case CAknNumericEdwin::EValueNotParsed:
       
  1065                     {
       
  1066                     iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorValueNotParsed);  
       
  1067                     break;
       
  1068                     }
       
  1069                 case CAknNumericEdwin::EValueValid:
       
  1070                     {
       
  1071                     iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorValueValid);  
       
  1072                     break;
       
  1073                     }
       
  1074                 default:
       
  1075                     break;
       
  1076                 }
       
  1077             }
       
  1078         else
       
  1079             {
       
  1080             if(GetTextLength())
       
  1081                 {
       
  1082                 iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorValueValid);
       
  1083                 }
       
  1084             else
       
  1085                 {
       
  1086                 iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorEmpty);
       
  1087                 }
       
  1088             }
       
  1089 
       
  1090         // Emergency Call support. Set the buffer in the Ecs copied from the editor
       
  1091         if ( iEcsDetector )
       
  1092             {
       
  1093             if ( iNumberEdwin || iPinEdwin )
       
  1094                 {
       
  1095                 // In either case, we need to copy the first KAknEcsMaxMatchingLength
       
  1096                 // characters to the emergency call buffer
       
  1097                 if ( iNumberEdwin )
       
  1098                     {
       
  1099                     TBuf<KAknEcsMaxMatchingLength> buf;
       
  1100                     iNumberEdwin->Text()->Extract(buf, 0, KAknEcsMaxMatchingLength );
       
  1101                     iEcsDetector->SetBuffer( buf );
       
  1102                     }   
       
  1103                 else if ( iPinEdwin )
       
  1104                     {
       
  1105                     TPtrC secretBuffer = iPinEdwin->Buffer().Left(KAknEcsMaxMatchingLength);
       
  1106                     iEcsDetector->SetBuffer( secretBuffer );
       
  1107                     // Manage appearance of the PIN query
       
  1108                     // If match is complete, or complete + Send key, show the number
       
  1109                     TBool reveal = EFalse;
       
  1110                     TInt ecsState( iEcsDetector->State() );
       
  1111                     if ( ( ecsState == CAknEcsDetector::ECompleteMatch ) ||
       
  1112                          ( ecsState == CAknEcsDetector::ECompleteMatchThenSendKey ) )
       
  1113                         {
       
  1114                         // Further check to ensure that the matched number is the entire buffer
       
  1115                         // Get the matched text and see if is the same length as the current query length
       
  1116                         if ( GetTextLength() == iEcsDetector->CurrentMatch().Length() ) 
       
  1117                             {
       
  1118                             reveal = ETrue;
       
  1119                             
       
  1120                             if ( ecsState == CAknEcsDetector::ECompleteMatch )
       
  1121                                 {
       
  1122                                 SetEcsCbaVisibleL( ETrue );                                            
       
  1123                                 }
       
  1124                             }
       
  1125                         }
       
  1126                     iPinEdwin->RevealSecretText( reveal );
       
  1127                     }
       
  1128                 }
       
  1129             }
       
  1130             
       
  1131         if (aControl)
       
  1132             {
       
  1133             
       
  1134 #if defined( RD_SCALABLE_UI_V2)
       
  1135             if ( AknLayoutUtils::PenEnabled() )
       
  1136                 {
       
  1137                 if(aControl == iIncreaseValueButton)
       
  1138                     {
       
  1139                     if(iTimeEdwin)
       
  1140                         {
       
  1141                         iTimeEdwin->HandleMfneCommandL(MAknMfneCommandObserver::EMfneIncrementCurrentFieldValue);
       
  1142                         }
       
  1143                     if(iDateEdwin)
       
  1144                         {
       
  1145                         iDateEdwin->HandleMfneCommandL(MAknMfneCommandObserver::EMfneIncrementCurrentFieldValue);
       
  1146                         }
       
  1147                     if(iDurationEdwin)
       
  1148                         {
       
  1149                         iDurationEdwin->HandleMfneCommandL(MAknMfneCommandObserver::EMfneIncrementCurrentFieldValue);
       
  1150                         }                            
       
  1151                     if(iExtension && LocationEd())
       
  1152                         {
       
  1153                         LocationEd()->HandleMfneCommandL(MAknMfneCommandObserver::EMfneIncrementCurrentFieldValue);
       
  1154                         }
       
  1155                          
       
  1156                     }
       
  1157                 else if(aControl == iDecreaseValueButton)
       
  1158                     {
       
  1159                     if(iTimeEdwin)
       
  1160                         {
       
  1161                         iTimeEdwin->HandleMfneCommandL(MAknMfneCommandObserver::EMfneDecrementCurrentFieldValue);
       
  1162                         }
       
  1163                     if(iDateEdwin)
       
  1164                         {
       
  1165                         iDateEdwin->HandleMfneCommandL(MAknMfneCommandObserver::EMfneDecrementCurrentFieldValue);
       
  1166                         }
       
  1167                     if(iDurationEdwin)
       
  1168                         {
       
  1169                         iDurationEdwin->HandleMfneCommandL(MAknMfneCommandObserver::EMfneDecrementCurrentFieldValue);
       
  1170                         }                        
       
  1171                     if(iExtension && LocationEd())
       
  1172                         {
       
  1173                         LocationEd()->HandleMfneCommandL(MAknMfneCommandObserver::EMfneIncrementCurrentFieldValue);
       
  1174                         }
       
  1175                     }
       
  1176                 else if( iExtension && aControl == iExtension->iBackspaceButton )
       
  1177                     {
       
  1178                     TInt scanCode = EStdKeyBackspace;
       
  1179             		TRawEvent event;
       
  1180             		event.Set( TRawEvent::EKeyDown, scanCode );
       
  1181             		event.SetTip( ETrue );
       
  1182             		
       
  1183 					if (iEikonEnv->AppUi())
       
  1184 						{
       
  1185 						static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->DisableNextKeySound( scanCode );
       
  1186 						}	
       
  1187             		
       
  1188             		CCoeEnv::Static()->WsSession().SimulateRawEvent( event );
       
  1189             		event.Set( TRawEvent::EKeyUp, scanCode );
       
  1190             		CCoeEnv::Static()->WsSession().SimulateRawEvent( event );
       
  1191                     }
       
  1192                 }
       
  1193 #endif //if defined( RD_SCALABLE_UI_V2)
       
  1194             }
       
  1195         }
       
  1196     }
       
  1197 
       
  1198 ///
       
  1199 /// DRAWING METHODS
       
  1200 ///
       
  1201 
       
  1202 /**
       
  1203  * Draw the following:-
       
  1204  *  - Text editor frame if there is a text editor, which is true for all
       
  1205  *    queries except confirmation queries  
       
  1206  */
       
  1207 void CAknQueryControl::Draw(const TRect& /*aRect*/) const
       
  1208     {
       
  1209     CWindowGc& gc=SystemGc(); 
       
  1210     TRect rect(Rect());
       
  1211     
       
  1212     TRect dialogRect = DialogRect();
       
  1213     rect.iBr.iY += dialogRect.iBr.iY; 
       
  1214 
       
  1215     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1216 
       
  1217     TRgb color;
       
  1218     TInt error = AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 );
       
  1219     if ( !error )
       
  1220         {        
       
  1221         TRAP_IGNORE(AknLayoutUtils::OverrideControlColorL( *(CAknQueryControl*)this, EColorLabelText, color ) );
       
  1222         }
       
  1223 
       
  1224     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  1225 
       
  1226     if ( CAknEnv::Static()->TransparencyEnabled() )
       
  1227         {
       
  1228         RRegion clipReg;
       
  1229         clipReg.AddRect( rect );
       
  1230     
       
  1231         if ( iHasEditor )
       
  1232             {
       
  1233             clipReg.SubRect( iEditorFrame.Rect() );
       
  1234             }
       
  1235     
       
  1236         if ( iEditIndicator )
       
  1237             {
       
  1238             clipReg.SubRect( 
       
  1239                 TRect( iEditIndicator->Position(),
       
  1240                 iEditIndicator->Size() ) );
       
  1241             }
       
  1242 
       
  1243         gc.SetClippingRegion( clipReg );
       
  1244         clipReg.Close();
       
  1245         
       
  1246         AknsDrawUtils::Background( skin, cc, this, gc, rect, KAknsDrawParamNoClearUnderImage );
       
  1247         
       
  1248         clipReg.AddRect( rect );
       
  1249 
       
  1250         CCoeControl* ctrl = const_cast<CAknQueryControl*>(this)->ControlByLayoutOrNull( iQueryType );
       
  1251         if ( ctrl )
       
  1252             {
       
  1253             clipReg.SubRect( ctrl->Rect() );
       
  1254             }
       
  1255 
       
  1256         gc.CancelClippingRegion();
       
  1257         gc.SetClippingRegion( clipReg );
       
  1258         clipReg.Close();
       
  1259         }
       
  1260     else
       
  1261         {
       
  1262             AknsDrawUtils::Background( skin, cc, this, gc, rect );
       
  1263         }
       
  1264 
       
  1265     DrawEditorFrame(gc,rect);
       
  1266  
       
  1267     if ( CAknEnv::Static()->TransparencyEnabled() )
       
  1268         {
       
  1269         gc.CancelClippingRegion();
       
  1270         }
       
  1271     }
       
  1272 
       
  1273 /**
       
  1274  * Draw text editor frame and shadow 
       
  1275  */
       
  1276 void CAknQueryControl::DrawEditorFrame(CWindowGc& aGc,TRect& /*aRect*/) const
       
  1277     {
       
  1278     if (iHasEditor)
       
  1279         {
       
  1280         TBool skinnedDraw( EFalse );
       
  1281 
       
  1282         CAknQueryExtension* extension = QueryExtension();
       
  1283         if( extension && extension->EditorContext() )
       
  1284             {
       
  1285             // If first-level image exists, frame has already been drawn
       
  1286             // as part of the context.
       
  1287 
       
  1288             if ( CAknEnv::Static()->TransparencyEnabled() )
       
  1289                 {
       
  1290                 const CCoeControl* ctrl = const_cast<CAknQueryControl*>(this)->ControlByLayoutOrNull( iQueryType );
       
  1291                 if ( ctrl )
       
  1292                     {
       
  1293                     skinnedDraw = AknsDrawUtils::Background( 
       
  1294                         AknsUtils::SkinInstance(), 
       
  1295                         extension->EditorContext(), 
       
  1296                         ctrl,
       
  1297                         aGc,
       
  1298                         iEditorFrame.Rect(),
       
  1299                         KAknsDrawParamNoClearUnderImage ); 
       
  1300                     }
       
  1301                 }
       
  1302             else
       
  1303                 {
       
  1304                 skinnedDraw = AknsDrawUtils::Background( 
       
  1305                     AknsUtils::SkinInstance(), 
       
  1306                     extension->EditorContext(), 
       
  1307                     aGc, 
       
  1308                     iEditorFrame.Rect() );                 
       
  1309                 }
       
  1310             }
       
  1311 
       
  1312         // ... otherwise, draw the non-skinned frame
       
  1313         if( !skinnedDraw )
       
  1314             {
       
  1315             iEditorFrame.DrawOutLineRect(aGc);
       
  1316             iEditorVerShadow.DrawRect(aGc); 
       
  1317             iEditorHorShadow.DrawRect(aGc);
       
  1318             }
       
  1319         }
       
  1320     }
       
  1321 
       
  1322 
       
  1323 ///
       
  1324 /// LAYOUT METHODS
       
  1325 ///
       
  1326 
       
  1327 /**
       
  1328  * Depending on query type and on the number of prompt or editor lines 
       
  1329  * return the window layout.
       
  1330  *
       
  1331  * This is used by a dialog to layout the control correctly.
       
  1332  *
       
  1333  */
       
  1334 void CAknQueryControl::WindowLayout( TAknWindowLineLayout& aLayout ) const
       
  1335     {
       
  1336     if ( EmbeddedVirtualInput() )
       
  1337         {
       
  1338         aLayout = AknLayoutScalable_Avkon::application_window( 0 );
       
  1339         return;
       
  1340         }
       
  1341 
       
  1342     TIndex LAFIndex(NbrOfPromptLines());
       
  1343 
       
  1344     switch (KQueryTypeToLayout[iQueryType])
       
  1345         {
       
  1346         case EConfQueryLayoutM:
       
  1347             aLayout = AknLayoutScalable_Avkon::popup_note_window(LAFIndex.PNWindow());
       
  1348             break;
       
  1349                
       
  1350         case EDataQueryLayoutM: 
       
  1351             aLayout = AknLayoutScalable_Avkon::popup_query_data_window(LAFIndex.PQDWindow(NbrOfEditorLines()));
       
  1352             break;
       
  1353    
       
  1354         case ECodeQueryLayoutM:
       
  1355             aLayout = AknLayoutScalable_Avkon::popup_query_code_window(LAFIndex.PQCWindow());
       
  1356             break;
       
  1357         
       
  1358         case ETimeQueryLayoutM:
       
  1359             aLayout = AknLayoutScalable_Avkon::popup_query_code_window(LAFIndex.PQCWindow());
       
  1360             break;
       
  1361 
       
  1362         case EDateQueryLayoutM:
       
  1363             aLayout = AknLayoutScalable_Avkon::popup_query_code_window(LAFIndex.PQCWindow());;
       
  1364             break;
       
  1365 
       
  1366         default:
       
  1367             __ASSERT_DEBUG(0,Panic(EAknPanicNotSupported));
       
  1368             aLayout = AknLayoutScalable_Avkon::popup_note_window(LAFIndex.PNWindow());            
       
  1369             break;
       
  1370         }
       
  1371     }
       
  1372 
       
  1373 /**
       
  1374  * Layout information in LAF is relative to the size of the dialog and not to the
       
  1375  * size of the internal area (dialog size - margins from UIKLAF). Therefore when
       
  1376  * doing layout do not use Rect(), but LayoutRect() - which returns the size of the
       
  1377  * dialog.
       
  1378  *
       
  1379  * Position is always (0,0) - top 
       
  1380  *
       
  1381  */
       
  1382 TRect CAknQueryControl::LayoutRect() 
       
  1383     {
       
  1384 #ifndef RD_NO_DIALOG_BORDERS    
       
  1385 	TPoint topLeft = Position();
       
  1386     TRect parent   = DialogRect();
       
  1387 	TAknLayoutRect layout;
       
  1388 
       
  1389 	if (KQueryTypeToLayout[iQueryType] == EDataQueryLayoutM)
       
  1390 		layout.LayoutRect(parent, AKN_LAYOUT_WINDOW_Data_query_pop_up_window_graphics_Line_5(parent));
       
  1391     else
       
  1392 		layout.LayoutRect(parent, AKN_LAYOUT_WINDOW_Note_pop_up_window_graphics_Line_5(parent));
       
  1393 
       
  1394 	TRect rect(layout.Rect());
       
  1395 	topLeft.iX -= rect.iTl.iX;
       
  1396     topLeft.iY -= rect.iTl.iY;
       
  1397 
       
  1398     TPoint bottomRight (topLeft);
       
  1399     TSize  size (DialogSize());
       
  1400     bottomRight.iY += size.iHeight; 
       
  1401     bottomRight.iX += size.iWidth;
       
  1402 
       
  1403     return TRect(topLeft,bottomRight);
       
  1404 #else
       
  1405     return Rect();
       
  1406 #endif        		
       
  1407     }
       
  1408 
       
  1409 /**
       
  1410  * Do layout (call SizeChanged) and if the control is
       
  1411  * activated do a redraw
       
  1412  */
       
  1413 void CAknQueryControl::Layout()
       
  1414     {
       
  1415     SizeChanged();
       
  1416     }
       
  1417 
       
  1418 /**
       
  1419  * Perform layout depending on query type.
       
  1420  */
       
  1421 void CAknQueryControl::SizeChanged()
       
  1422     {  
       
  1423     DialogSizeChanged();
       
  1424     iPrompt->SetRect(LayoutRect());
       
  1425     LayoutPrompt(KQueryTypeToLayout[iQueryType]);
       
  1426 
       
  1427     LayoutImageOrAnim(KQueryTypeToLayout[iQueryType]);
       
  1428     LayoutEditor(KQueryTypeToLayout[iQueryType]);
       
  1429     
       
  1430     
       
  1431 	// Layout Keypad
       
  1432     
       
  1433     if ( iExtension && iExtension->iKeypad )
       
  1434     	{
       
  1435         TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
  1436      
       
  1437         TAknLayoutRect layoutRect;
       
  1438         layoutRect.LayoutRect( LayoutRect(), TAknWindowComponentLayout::Compose(
       
  1439             AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ), 
       
  1440             AknLayoutScalable_Apps::grid_vitu2_itu_pane( landscape ? 5 : 0 ) ).LayoutLine() );
       
  1441                  
       
  1442         iExtension->iKeypad->SetRect( layoutRect.Rect() ); 
       
  1443         }
       
  1444 
       
  1445         
       
  1446     // Layout Backspace Button
       
  1447      
       
  1448      if ( iExtension && iExtension->iBackspaceButton )
       
  1449         {
       
  1450         TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
  1451      
       
  1452         TAknLayoutRect layoutRect;
       
  1453  		layoutRect.LayoutRect( LayoutRect(), TAknWindowComponentLayout::Compose(
       
  1454  			AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ), 
       
  1455     		AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ) ).LayoutLine() );
       
  1456     
       
  1457         TAknLayoutRect layout;
       
  1458  		layout.LayoutRect(layoutRect.Rect(), AknLayoutScalable_Apps::bg_button_pane_cp022( 0 ));
       
  1459  
       
  1460 		iExtension->iBackspaceButton->SetRect(layout.Rect());
       
  1461         }
       
  1462         
       
  1463     // Layout CBA
       
  1464     
       
  1465     CEikDialog* dlg;
       
  1466     MopGetObject( dlg );
       
  1467     if ( dlg )
       
  1468         {
       
  1469         // Note: iExtension->iKeypad is used to ensure that SetRect is not called too early
       
  1470 	    if ( iExtension && iExtension->iKeypad && EmbeddedVirtualInput() )
       
  1471             {   
       
  1472             CEikCba* cba = static_cast<CEikCba*>( dlg->ButtonGroupContainer().ButtonGroup() );   
       
  1473             
       
  1474             TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
  1475             
       
  1476         	TAknLayoutRect layoutRect;
       
  1477  			layoutRect.LayoutRect( LayoutRect(), TAknWindowComponentLayout::Compose(
       
  1478  				AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ), 
       
  1479     		AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ) ).LayoutLine() );
       
  1480         
       
  1481 			TAknLayoutRect leftLayout;
       
  1482 			leftLayout.LayoutRect(layoutRect.Rect(), AknLayoutScalable_Apps::bg_button_pane_cp018( 0 ));
       
  1483 
       
  1484 			TAknLayoutRect rightLayout;
       
  1485 			rightLayout.LayoutRect(layoutRect.Rect(), AknLayoutScalable_Apps::bg_button_pane_cp021( 0 ));
       
  1486        		
       
  1487        		TRect rect;
       
  1488        		if ( AknLayoutUtils::LayoutMirrored() )
       
  1489        		    {
       
  1490        		    rect.iTl = rightLayout.Rect().iTl;
       
  1491        		    rect.iBr = leftLayout.Rect().iBr;
       
  1492        		    }
       
  1493        		else
       
  1494        		    {
       
  1495        		    rect.iTl = leftLayout.Rect().iTl;
       
  1496        		    rect.iBr = rightLayout.Rect().iBr;
       
  1497        		    }
       
  1498        		    
       
  1499        		cba->SetRect( rect );
       
  1500             }
       
  1501         }
       
  1502     
       
  1503     CAknQueryExtension* extension = QueryExtension();
       
  1504     if( iHasEditor && extension && extension->EditorContext() )
       
  1505         {
       
  1506         // Layout editor context
       
  1507         TAknLayoutRect topLeft;
       
  1508         TAknLayoutRect bottomRight;
       
  1509         
       
  1510         //How to handle lanscape layout in full screen queries? 
       
  1511         
       
  1512         topLeft.LayoutRect(iEditorFrame.Rect(), SkinLayout::Input_field_skin_placing__general__Line_2());                
       
  1513         bottomRight.LayoutRect(TRect(iEditorFrame.Rect().iBr, iEditorFrame.Rect().iBr), SkinLayout::Input_field_skin_placing__general__Line_5());
       
  1514 
       
  1515         TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
       
  1516         TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
       
  1517         
       
  1518 
       
  1519         extension->EditorContext()->SetFrameRects( outerRect, innerRect );
       
  1520         // Chain with the background (since the frame doesn't occupy the entire
       
  1521         // layout and it may even be transparent)
       
  1522         extension->EditorContext()->SetParentContext( AknsDrawUtils::ControlContextOfParent( this ) );
       
  1523         
       
  1524 
       
  1525 #if defined( RD_SCALABLE_UI_V2)
       
  1526 
       
  1527 		// Create backspace button if not created yet
       
  1528 		if ( AknLayoutUtils::PenEnabled() && EmbeddedVirtualInput() )
       
  1529 			{
       
  1530 			TRAP_IGNORE( CreateBackspaceButtonL() );
       
  1531 			}
       
  1532 
       
  1533 #endif //if defined( RD_SCALABLE_UI_V2)
       
  1534         }
       
  1535 
       
  1536     if (iImage)
       
  1537         {
       
  1538         TAknLayoutRect rect;
       
  1539         rect.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_Note_pop_up_window_elements_Line_1 );
       
  1540         AknIconUtils::SetSize( CONST_CAST( CFbsBitmap*, iImage->Bitmap() ), rect.Rect().Size() );
       
  1541         }            
       
  1542     }
       
  1543 
       
  1544 /**
       
  1545  * Return the minimum size for the control. 
       
  1546  *
       
  1547  * This depends on the type of query and the number of prompt and/or
       
  1548  * editor lines.
       
  1549  *
       
  1550  * Changed this to use only data-query layout
       
  1551  */
       
  1552 EXPORT_C TSize CAknQueryControl::MinimumSize()
       
  1553     {	
       
  1554     DialogSizeChanged();
       
  1555 #ifndef RD_NO_DIALOG_BORDERS
       
  1556 	TRect parent = DialogRect();
       
  1557 	TAknLayoutRect layout;
       
  1558 	layout.LayoutRect(parent, AKN_LAYOUT_WINDOW_Data_query_pop_up_window_graphics_Line_5(parent));
       
  1559 	TRect rect(layout.Rect());
       
  1560 	return (TSize(rect.Size()));
       
  1561 #else
       
  1562     return DialogRect().Size();
       
  1563 #endif
       
  1564     }
       
  1565 
       
  1566 /**
       
  1567  * Return rect that is used by dialog to lay itself out
       
  1568  * This is determined by LAF values only.
       
  1569  */
       
  1570 TRect CAknQueryControl::DialogRect() const
       
  1571     {
       
  1572     return TRect(TPoint(0,0),DialogSize());
       
  1573     }
       
  1574     
       
  1575 /**
       
  1576  * Return the size of the dialog 
       
  1577  */
       
  1578 TSize CAknQueryControl::DialogSize() const
       
  1579     {
       
  1580     return iDialogSize;
       
  1581     }
       
  1582     
       
  1583 /**
       
  1584  * Calculates the size of the dialog. This is determined by
       
  1585  * LAF values only.
       
  1586  */
       
  1587 void CAknQueryControl::DialogSizeChanged()
       
  1588     {
       
  1589     TAknWindowLineLayout lay;
       
  1590     WindowLayout( lay );
       
  1591 	TAknLayoutRect layout;
       
  1592 	layout.LayoutRect(Rect(), lay);
       
  1593 	TRect rect(layout.Rect());	
       
  1594 	iDialogSize = TSize(rect.Size());
       
  1595     }
       
  1596     
       
  1597 /**
       
  1598 * Layout the query prompt. 
       
  1599 *
       
  1600 * There are two possible ways of laying
       
  1601 * out the text, either according to the general note LAF specs
       
  1602 * or according to the data query LAF specs
       
  1603 *
       
  1604 * Data queries layout the prompt according to data query LAF specs.
       
  1605 * Other queries layout the text according to the general note spces
       
  1606 *
       
  1607 * This method is called from SizeChanged, which determines the layout method
       
  1608 * to use (general note or data query) depending on the query type.
       
  1609 */
       
  1610 void CAknQueryControl::LayoutPrompt(const TLayoutMethod& aLayoutM)
       
  1611     {
       
  1612     __ASSERT_DEBUG(iPrompt,Panic(EAknPanicNullPointer));
       
  1613     
       
  1614     if ( AknLayoutUtils::PenEnabled() && EmbeddedVirtualInput() )
       
  1615     	{
       
  1616     	LayoutPromptForFullScreen();
       
  1617         return;     		
       
  1618    		}
       
  1619        
       
  1620     TRect rect = LayoutRect();
       
  1621     for (TInt i = 0; i < NbrOfPromptLines(); i++)
       
  1622         {
       
  1623         if (aLayoutM == EConfQueryLayoutM)
       
  1624             {
       
  1625             // AknLayoutScalable_Avkon::popup_note_window_t1 ? 
       
  1626             AknLayoutUtils::LayoutLabel(iPrompt->Line(i), rect, AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(i) );
       
  1627             }
       
  1628         else if (aLayoutM == ECodeQueryLayoutM || aLayoutM == ETimeQueryLayoutM || aLayoutM == EDateQueryLayoutM )
       
  1629             {
       
  1630             // AknLayoutScalable_Avkon::popup_query_code_window_t1 ? 
       
  1631             AknLayoutUtils::LayoutLabel(iPrompt->Line(i), rect, AKN_LAYOUT_TEXT_Code_query_pop_up_window_texts_Line_1(i) );
       
  1632             }
       
  1633         else if (aLayoutM == EDataQueryLayoutM)
       
  1634             {
       
  1635             // AknLayoutScalable_Avkon::popup_query_code_window_t1 ?             
       
  1636             AknLayoutUtils::LayoutLabel(iPrompt->Line(i), rect, AKN_LAYOUT_TEXT_Data_query_pop_up_window_texts_Line_1(i));
       
  1637             }        
       
  1638         else
       
  1639             {
       
  1640             __ASSERT_DEBUG(0,Panic(EAknPanicNotSupported));
       
  1641             }
       
  1642         }
       
  1643     }
       
  1644 
       
  1645 /**
       
  1646  * Layout the image or the animation.
       
  1647  *
       
  1648  * Confirmation queries can have either an image or an animation and the
       
  1649  * layout is similar to general notes.
       
  1650  *
       
  1651  * This method is called from SizeChanged.
       
  1652  */
       
  1653 void CAknQueryControl::LayoutImageOrAnim(const TLayoutMethod& aLayoutM)
       
  1654     {
       
  1655     if (aLayoutM == EConfQueryLayoutM)
       
  1656         {
       
  1657         // AknLayoutScalable_Avkon::popup_note_window_g1() ? 
       
  1658         if (iImage)
       
  1659             AknLayoutUtils::LayoutImage(iImage, LayoutRect(), AKN_LAYOUT_WINDOW_Note_pop_up_window_elements_Line_1);
       
  1660         
       
  1661         if (iAnimation)
       
  1662             AknLayoutUtils::LayoutControl(iAnimation, LayoutRect(), AKN_LAYOUT_WINDOW_Note_pop_up_window_elements_Line_1);
       
  1663         }
       
  1664     }
       
  1665 
       
  1666 /**
       
  1667  * Layout the editor and its frame.
       
  1668  *
       
  1669  * Queries other than confirmation queries have an editor that the user needs
       
  1670  * to input the query data. This method does the layout of the editor. 
       
  1671  *
       
  1672  * Data queries have a resizable editor and its layout is specified in the LAF.
       
  1673  * 
       
  1674  * Other queries have a fixed size editor with layout specified.
       
  1675  *
       
  1676  *
       
  1677  * This method is called from SizeChanged. Depending on the query type, the
       
  1678  * layout method is chosen accordingly, e.g. data queries use the data query
       
  1679  * method, other queires use the code query method.
       
  1680  *
       
  1681  * The macros at the top are just for avoiding code repetition.
       
  1682  */
       
  1683 void CAknQueryControl::LayoutEditor(const TLayoutMethod& aLayoutM)
       
  1684     {
       
  1685     if ( AknLayoutUtils::PenEnabled() && EmbeddedVirtualInput() )
       
  1686     	{
       
  1687     	LayoutEditorForFullScreen( aLayoutM );
       
  1688     	return;
       
  1689     	}
       
  1690     
       
  1691     TIndex LAFIndex(NbrOfPromptLines());
       
  1692     
       
  1693     if (aLayoutM == EDataQueryLayoutM)
       
  1694         {
       
  1695         iHasEditor = ETrue;
       
  1696         
       
  1697         LayoutEditorFrame(aLayoutM);
       
  1698         
       
  1699         LayoutEditorIndicator(aLayoutM);
       
  1700 
       
  1701         TInt promptLines = NbrOfPromptLines();
       
  1702         TInt numberTextLines = NbrOfEditorLines();
       
  1703 
       
  1704         TInt isNumeric = 0;
       
  1705         CEikEdwin* editor = iEdwin;
       
  1706         if (iNumberEdwin)
       
  1707             {
       
  1708             editor = iNumberEdwin;
       
  1709             }
       
  1710         else if (iFloatingPointEditor)
       
  1711             {
       
  1712             editor = iFloatingPointEditor;
       
  1713             }
       
  1714         
       
  1715         if ( editor )
       
  1716             {
       
  1717             TRect parentRect = LayoutRect();
       
  1718             if (promptLines > 1)
       
  1719                 {
       
  1720                 // There isn't way to give number of prompt lines to layout adaptation layer 
       
  1721                 // through Data_query_pop_up_window_texts_Line_2 layout API. Adaptation layer
       
  1722                 // does'n know which layout should be used. For that reason 2nd and 3rd prompt
       
  1723                 // line area is reduced from the parent rect and adaptation layer expects
       
  1724                 // that only one prompt line exists. 
       
  1725                 TAknLayoutText prompt1;
       
  1726                 prompt1.LayoutText(parentRect, AKN_LAYOUT_TEXT_Data_query_pop_up_window_texts_Line_1(0));
       
  1727                 
       
  1728                 TAknLayoutText prompt2;
       
  1729                 prompt2.LayoutText(parentRect, AKN_LAYOUT_TEXT_Data_query_pop_up_window_texts_Line_1(1));
       
  1730 
       
  1731                 TInt parentOffset = prompt2.TextRect().iBr.iY - prompt1.TextRect().iBr.iY;
       
  1732                 parentRect.iTl.iY += parentOffset * (promptLines - 1);
       
  1733                 }
       
  1734             AknLayoutUtils::LayoutEdwin( editor, parentRect,
       
  1735                 AKN_LAYOUT_MULTILINE_TEXT_Data_query_pop_up_window_texts_Line_2( isNumeric, numberTextLines ), EAknsCIQsnTextColorsCG27);
       
  1736             
       
  1737             //layout data not correct? if editor height is bigger than frame - reduce editor height by one step
       
  1738             if (numberTextLines >= KMaxLinesInQuery && editor->Rect().iBr.iY > iEditorFrame.Rect().iBr.iY) 
       
  1739                 {
       
  1740             	AknLayoutUtils::LayoutEdwin( editor, parentRect,
       
  1741                     AKN_LAYOUT_MULTILINE_TEXT_Data_query_pop_up_window_texts_Line_2( isNumeric, numberTextLines-1 ), EAknsCIQsnTextColorsCG27);            	
       
  1742                     
       
  1743                 //last line possibly w/ cursor might disappear - reveal it
       
  1744                 TRAP_IGNORE(editor->MoveDisplayL(TCursorPosition::EFLineDown));
       
  1745                 }
       
  1746 
       
  1747             editor->SetBorder(TGulBorder::ENone); 
       
  1748             if (IsFocused() && !(editor->IsFocused()) ) 
       
  1749                 editor->SetFocus(ETrue);
       
  1750             }
       
  1751 		
       
  1752         AknsUtils::RegisterControlPosition(editor);
       
  1753         }
       
  1754     else if (aLayoutM == ECodeQueryLayoutM || aLayoutM == EDateQueryLayoutM || aLayoutM == ETimeQueryLayoutM)
       
  1755         {
       
  1756         iHasEditor = ETrue;
       
  1757 
       
  1758         LayoutEditorFrame(aLayoutM);
       
  1759         
       
  1760         LayoutEditorIndicator(aLayoutM);
       
  1761 
       
  1762         if (iSecretEd)
       
  1763             {
       
  1764             AknLayoutUtils::LayoutSecretEditor(iSecretEd, LayoutRect(), 
       
  1765             AKN_LAYOUT_TEXT_Code_query_pop_up_window_texts_Line_2(LAFIndex.PromptLine()));
       
  1766             iSecretEd->SetBorder(TGulBorder::ENone);
       
  1767             if (IsFocused() && !iSecretEd->IsFocused())
       
  1768                 iSecretEd->SetFocus(ETrue);
       
  1769             }    
       
  1770         if (iPinEdwin)
       
  1771             {
       
  1772             AknLayoutUtils::LayoutSecretEditor(iPinEdwin, LayoutRect(), 
       
  1773             AKN_LAYOUT_TEXT_Code_query_pop_up_window_texts_Line_2(LAFIndex.PromptLine()));
       
  1774             iPinEdwin->SetBorder(TGulBorder::ENone);
       
  1775             if (IsFocused() && !iPinEdwin->IsFocused())
       
  1776                 iPinEdwin->SetFocus(ETrue);
       
  1777             }
       
  1778 
       
  1779 //LAYOUT for TIME, DATE and DURATION EDITORS 
       
  1780         CEikMfne* edwin = NULL;
       
  1781         
       
  1782         if ( iTimeEdwin )
       
  1783             {
       
  1784             edwin = iTimeEdwin;
       
  1785             }        
       
  1786         else if ( iDateEdwin )
       
  1787             {
       
  1788             edwin = iDateEdwin;
       
  1789             }
       
  1790         else if ( iDurationEdwin )
       
  1791             {
       
  1792             edwin = iDurationEdwin;
       
  1793             }
       
  1794         else if ( LocationEd() )
       
  1795             {
       
  1796             edwin = LocationEd();
       
  1797             }
       
  1798             
       
  1799         if ( edwin )
       
  1800             {
       
  1801             TInt variety( LAFIndex.PromptLine() );
       
  1802         
       
  1803             AknLayoutUtils::LayoutMfne( edwin, LayoutRect(), 
       
  1804                 TAknWindowComponentLayout::ComposeText( 
       
  1805                     AknLayoutScalable_Avkon::query_popup_pane( variety ),
       
  1806                     AknLayoutScalable_Avkon::query_popup_pane_t1() ) );
       
  1807 
       
  1808             edwin->SetBorder( TGulBorder::ENone );
       
  1809             if ( IsFocused() && !edwin->IsFocused() )
       
  1810                 {
       
  1811                 edwin->SetFocus( ETrue );
       
  1812                 }
       
  1813             edwin->SetUpAndDownKeysConsumed( ETrue );
       
  1814             }     
       
  1815         }
       
  1816     }
       
  1817 
       
  1818 /**
       
  1819  * Layout the editor frame.
       
  1820  *
       
  1821  * For queries that do have an editor, this method will position its frame.
       
  1822  *
       
  1823  * This method is called by LayoutEditor only if the layout
       
  1824  * method implies the presence of an editor, hence the panic if
       
  1825  * the layout is not recognised.
       
  1826  *
       
  1827  */
       
  1828 void CAknQueryControl::LayoutEditorFrame(const TLayoutMethod& aLayoutM)
       
  1829     {
       
  1830     TIndex LAFIndex(NbrOfPromptLines());
       
  1831 
       
  1832     TRect rect   = LayoutRect();
       
  1833     TRect parent = DialogRect();
       
  1834      
       
  1835     if (aLayoutM == EDataQueryLayoutM)
       
  1836         {
       
  1837         iEditorVerShadow.LayoutRect( rect, AKN_LAYOUT_WINDOW_Data_query_pop_up_window_elements_Line_1(LAFIndex.PromptLine()));
       
  1838         iEditorHorShadow.LayoutRect( rect, AKN_LAYOUT_WINDOW_Data_query_pop_up_window_elements_Line_2(parent,LAFIndex.PromptLine()));
       
  1839         iEditorFrame.LayoutRect    ( rect, AKN_LAYOUT_WINDOW_Data_query_pop_up_window_elements_Line_3(parent,LAFIndex.PromptLine()));
       
  1840         }
       
  1841     else if (aLayoutM == ECodeQueryLayoutM || aLayoutM == EDateQueryLayoutM || aLayoutM == ETimeQueryLayoutM)
       
  1842         {
       
  1843         TInt variety( LAFIndex.PromptLine() );
       
  1844         iEditorVerShadow.LayoutRect( rect, AKN_LAYOUT_WINDOW_Code_query_pop_up_window_elements_Line_1( variety ) );
       
  1845         iEditorHorShadow.LayoutRect( rect, AKN_LAYOUT_WINDOW_Code_query_pop_up_window_elements_Line_2( variety ) );
       
  1846                
       
  1847         iEditorFrame.LayoutRect( rect, AknLayoutScalable_Avkon::query_popup_pane( variety ) );
       
  1848         }
       
  1849     else 
       
  1850         __ASSERT_DEBUG(0,Panic(EAknPanicNotSupported));
       
  1851     }
       
  1852 
       
  1853 /**
       
  1854  * Layout editor indicator.
       
  1855  *
       
  1856  * For queries that do have an editor, this method does
       
  1857  * layout for its editing state icons.
       
  1858  *
       
  1859  * If these icons are not to be displayed then this method
       
  1860  * returns without doing anything. 
       
  1861  *
       
  1862  * This method is called by LayoutEditor only if the layout
       
  1863  * method implies the presence of an editor, hence the panic if
       
  1864  * the layout is not recognised.
       
  1865  */
       
  1866 void CAknQueryControl::LayoutEditorIndicator(const TLayoutMethod& aLayoutM)
       
  1867     {
       
  1868     TIndex LAFIndex(NbrOfPromptLines());
       
  1869 
       
  1870     if (!iEditIndicator)
       
  1871         return;
       
  1872 
       
  1873     if (aLayoutM == EDataQueryLayoutM)
       
  1874         {
       
  1875         AknLayoutUtils::LayoutControl(iEditIndicator, LayoutRect(), 
       
  1876             AKN_LAYOUT_WINDOW_Data_query_pop_up_window_elements_Line_4(LAFIndex.PromptLine()));
       
  1877         }
       
  1878     else if (aLayoutM == ECodeQueryLayoutM || aLayoutM == EDateQueryLayoutM || aLayoutM == ETimeQueryLayoutM)
       
  1879         {
       
  1880         TInt variety( LAFIndex.PromptLine() );
       
  1881         
       
  1882         AknLayoutUtils::LayoutControl(iEditIndicator, LayoutRect(), 
       
  1883             AknLayoutScalable_Avkon::indicator_popup_pane( variety ) );
       
  1884         }
       
  1885     else
       
  1886         __ASSERT_DEBUG(0,Panic(EAknPanicNotSupported));
       
  1887     }
       
  1888 
       
  1889 //
       
  1890 // Extension
       
  1891 //
       
  1892 
       
  1893 CAknQueryExtension* CAknQueryControl::QueryExtension() const
       
  1894     {
       
  1895     return CAknQueryExtension::Instance( this );
       
  1896     }
       
  1897 
       
  1898 //
       
  1899 // Prompt related methods
       
  1900 //
       
  1901 
       
  1902 /**
       
  1903  * Read prompt text from resouce
       
  1904  */
       
  1905 EXPORT_C void CAknQueryControl::ReadPromptL(TResourceReader &aRes)
       
  1906     {
       
  1907     delete iPrompt;
       
  1908     iPrompt = NULL;
       
  1909 
       
  1910     iPrompt = CAknTextControl::NewL(CAknText::EFormatted);
       
  1911     iPrompt->ConstructFromResourceL(aRes);
       
  1912     iPrompt->SetContainerWindowL(*this);
       
  1913 
       
  1914     TCallBack cb( StaticPictographCallBack, this );
       
  1915     iPrompt->SetPictographCallBackL( cb );
       
  1916 
       
  1917     DoSetPromptL();
       
  1918     }
       
  1919 
       
  1920 /**
       
  1921  * Set new text into prompt and parse the text
       
  1922  */
       
  1923 EXPORT_C void CAknQueryControl::SetPromptL(const TDesC& aDesC)
       
  1924     {
       
  1925     __ASSERT_DEBUG(iPrompt,Panic(EAknPanicNullPointer));
       
  1926     iPrompt->SetTextL(aDesC);
       
  1927     DoSetPromptL();
       
  1928     }
       
  1929 
       
  1930 /**
       
  1931  * Parse the text in the prompt
       
  1932  *
       
  1933  * Line widths of prompt depend on layout information and on 
       
  1934  * query type
       
  1935  */
       
  1936 void CAknQueryControl::DoSetPromptL()
       
  1937     {
       
  1938      __ASSERT_DEBUG(iPrompt,Panic(EAknPanicNullPointer));     
       
  1939 
       
  1940     TAknLayoutText textRect;
       
  1941 
       
  1942     TAknWindowLineLayout dialogLay;
       
  1943     WindowLayout( dialogLay );
       
  1944 
       
  1945     TAknLayoutRect dialogLayRect;
       
  1946     dialogLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), dialogLay);
       
  1947     TSize dialogSize = dialogLayRect.Rect().Size(); 
       
  1948     TRect parent(TPoint(0,0),dialogSize);
       
  1949     
       
  1950     if (iQueryType == EConfirmationQueryLayout)
       
  1951         {
       
  1952         textRect.LayoutText(parent, AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(1));
       
  1953         }
       
  1954     else        
       
  1955         {
       
  1956         textRect.LayoutText(parent, AKN_LAYOUT_TEXT_Data_query_pop_up_window_texts_Line_1(1));
       
  1957         }
       
  1958            
       
  1959     SetLineWidthsL();            
       
  1960     const CFont *font = textRect.Font();
       
  1961     iPrompt->ParseTextL(font,iLineWidths);
       
  1962     
       
  1963     // Next code block inserts line feeds into the given prompt text so that 
       
  1964     // it always consumes the same amount of vertical space. Prompt should
       
  1965     // always be placed just above the editor i.e. empty lines are added before
       
  1966     // the prompt if needed.
       
  1967     //
       
  1968     
       
  1969     if ( EmbeddedVirtualInput() )
       
  1970         {
       
  1971         // Set line widths for prompt text using Query Input layout
       
  1972         
       
  1973   		TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
  1974     
       
  1975     	TAknLayoutRect rect;
       
  1976  		rect.LayoutRect( LayoutRect(), TAknWindowComponentLayout::Compose(
       
  1977  			AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ), 
       
  1978     		AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ) ).LayoutLine() );
       
  1979     				
       
  1980     	TAknLayoutText layoutText;
       
  1981     	layoutText.LayoutText( rect.Rect(),
       
  1982     		AknLayoutScalable_Apps::area_vitu2_query_pane_t4( 1 ) );
       
  1983                 
       
  1984         font = layoutText.Font();
       
  1985     	
       
  1986     	iLineWidths->Reset();
       
  1987         for (TInt i = 0; i < 3; i++)
       
  1988         	{
       
  1989         	iLineWidths->AppendL(layoutText.TextRect().Width());
       
  1990         	}
       
  1991         	
       
  1992         // text parsing is needed to get correct return value
       
  1993         // from function NbrOfPromptLines 	
       
  1994         iPrompt->ParseTextL( font, iLineWidths );
       
  1995         	
       
  1996         
       
  1997         // calculate needed amount of empty lines
       
  1998         TInt lineFeeds = 3 - NbrOfPromptLines();
       
  1999         
       
  2000         // add empty lines if needed
       
  2001         if ( lineFeeds > 0)
       
  2002         	{
       
  2003         	HBufC* oldText = iPrompt->Text().AllocLC();
       
  2004         	HBufC* newText = oldText->ReAllocL( oldText->Length() + lineFeeds );
       
  2005         
       
  2006         	CleanupStack::Pop(); // oldText
       
  2007         	CleanupStack::PushL( newText );
       
  2008         
       
  2009         	// add empty lines
       
  2010         	for ( TInt i = 0; i < lineFeeds; ++i )
       
  2011             	{
       
  2012             	newText->Des().Insert( 0, _L( "\n" ) );
       
  2013             	}
       
  2014         	iPrompt->SetTextL( *newText );
       
  2015         
       
  2016         	// text parsing is needed because empty lines are added
       
  2017         	iPrompt->ParseTextL( font, iLineWidths );
       
  2018 
       
  2019         	CleanupStack::PopAndDestroy(); // newText
       
  2020         	}
       
  2021         }
       
  2022     
       
  2023     Layout();
       
  2024     }
       
  2025 
       
  2026 void CAknQueryControl::SetLineWidthsL() 
       
  2027     {
       
  2028     if (!iLineWidths)
       
  2029         return;
       
  2030     
       
  2031     iLineWidths->Reset();
       
  2032 
       
  2033     switch(KQueryTypeToLayout[iQueryType])
       
  2034         {
       
  2035         case EConfQueryLayoutM: 
       
  2036             {
       
  2037             TAknLayoutRect parentLayoutRect;
       
  2038             parentLayoutRect.LayoutRect(iAvkonAppUi->ClientRect(), AknLayoutScalable_Avkon::popup_note_window(0));
       
  2039             TAknLayoutText textRect;
       
  2040             for (TInt i = 0; i < 5; i++)
       
  2041                 {
       
  2042                 textRect.LayoutText(parentLayoutRect.Rect(), AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(i));
       
  2043                 iLineWidths->AppendL(textRect.TextRect().Width());
       
  2044                 }
       
  2045             break;
       
  2046             }
       
  2047         case EDataQueryLayoutM:
       
  2048             {
       
  2049             TAknLayoutRect parentLayoutRect;
       
  2050             parentLayoutRect.LayoutRect(iAvkonAppUi->ClientRect(), AknLayoutScalable_Avkon::popup_query_data_window(0));
       
  2051             TAknLayoutText textRect;
       
  2052             for (TInt i = 0; i < 3; i++)
       
  2053                 {
       
  2054                 textRect.LayoutText(parentLayoutRect.Rect(), AKN_LAYOUT_TEXT_Data_query_pop_up_window_texts_Line_1(i));
       
  2055                 iLineWidths->AppendL(textRect.TextRect().Width());
       
  2056                 }
       
  2057             break;
       
  2058             }
       
  2059         case ECodeQueryLayoutM:
       
  2060         case ETimeQueryLayoutM:
       
  2061         case EDateQueryLayoutM:
       
  2062             {
       
  2063             TAknLayoutRect parentLayoutRect;
       
  2064             parentLayoutRect.LayoutRect(iAvkonAppUi->ClientRect(), AknLayoutScalable_Avkon::popup_query_code_window(0));
       
  2065             TAknLayoutText textRect;
       
  2066             for (TInt i = 0; i < 3; i++)
       
  2067                 {                
       
  2068                 textRect.LayoutText(parentLayoutRect.Rect(), AKN_LAYOUT_TEXT_Code_query_pop_up_window_texts_Line_1(i));
       
  2069                 iLineWidths->AppendL(textRect.TextRect().Width());
       
  2070                 }
       
  2071             break;
       
  2072             }
       
  2073         default:
       
  2074             __ASSERT_DEBUG(0,Panic(EAknPanicNotSupported));
       
  2075         }
       
  2076     }
       
  2077 
       
  2078 
       
  2079 ///
       
  2080 /// Editor text related methos
       
  2081 ///
       
  2082 
       
  2083 /**
       
  2084  *Get text from editors
       
  2085  */
       
  2086 EXPORT_C void CAknQueryControl::GetText(TDes &aDes) const 
       
  2087     {
       
  2088     if(iEdwin)
       
  2089         {
       
  2090         iEdwin->GetText(aDes);
       
  2091         }
       
  2092     else if(iSecretEd)
       
  2093         {
       
  2094         iSecretEd->GetText(aDes);
       
  2095         }
       
  2096     else if(iPinEdwin)
       
  2097         {
       
  2098         iPinEdwin->GetText(aDes);
       
  2099         }
       
  2100     else if(iNumberEdwin)
       
  2101         {
       
  2102         iNumberEdwin->GetText(aDes);
       
  2103         }
       
  2104     else if (iFloatingPointEditor)
       
  2105         {
       
  2106         iFloatingPointEditor->GetText(aDes);
       
  2107         }
       
  2108     }
       
  2109 
       
  2110 /**
       
  2111  *Set default text in editors
       
  2112  */
       
  2113 EXPORT_C void CAknQueryControl::SetTextL(const TDesC &aDesC)
       
  2114     {
       
  2115     if( iEdwin )
       
  2116         {
       
  2117         __ASSERT_DEBUG
       
  2118             (
       
  2119             iEdwin->MaxLength()>=aDesC.Length(), 
       
  2120             Panic(EAknPanicOverflow)
       
  2121             );
       
  2122         iEdwin->SetTextL(&aDesC);
       
  2123         }
       
  2124     else if( iSecretEd )
       
  2125         {
       
  2126         __ASSERT_DEBUG
       
  2127             (
       
  2128             iSecretEd->MaxLength()>=aDesC.Length(), 
       
  2129             Panic(EAknPanicOverflow)
       
  2130             );
       
  2131         iSecretEd->SetText(aDesC);
       
  2132         }
       
  2133     else if( iPinEdwin )
       
  2134         {
       
  2135         __ASSERT_DEBUG
       
  2136             ( // secret editor derived
       
  2137             iPinEdwin->MaxLength()>=aDesC.Length(), 
       
  2138             Panic(EAknPanicOverflow)
       
  2139             );
       
  2140         iPinEdwin->SetText(aDesC);
       
  2141         }
       
  2142     else if( iNumberEdwin )
       
  2143         {
       
  2144         __ASSERT_DEBUG
       
  2145             (
       
  2146             iNumberEdwin->MaxLength()>=aDesC.Length(), 
       
  2147             Panic(EAknPanicOverflow)
       
  2148             );
       
  2149 
       
  2150         iNumberEdwin->SetTextL(&aDesC);
       
  2151         }
       
  2152     else if (iFloatingPointEditor)
       
  2153         {
       
  2154         __ASSERT_DEBUG
       
  2155             (
       
  2156             iFloatingPointEditor->MaxLength()>=aDesC.Length(), 
       
  2157             Panic(EAknPanicOverflow)
       
  2158             );
       
  2159 
       
  2160         iFloatingPointEditor->SetTextL(&aDesC);
       
  2161         }
       
  2162     }
       
  2163 
       
  2164 /**
       
  2165  *Set max. length in text based editors.
       
  2166  */
       
  2167 EXPORT_C void CAknQueryControl::SetTextEntryLength(TInt aLength)
       
  2168     {
       
  2169     if( iEdwin )
       
  2170         {
       
  2171         iEdwin->SetMaxLength(aLength);
       
  2172         }
       
  2173     else if( iSecretEd )
       
  2174         {
       
  2175         iSecretEd->SetMaxLength(aLength);
       
  2176         }
       
  2177     else if( iPinEdwin )
       
  2178         {
       
  2179         iPinEdwin->SetMaxLength(aLength);
       
  2180         }
       
  2181     else if( iNumberEdwin )
       
  2182         {
       
  2183         iNumberEdwin->SetMaxLength(aLength);
       
  2184         }
       
  2185     else if ( iFloatingPointEditor )
       
  2186         {
       
  2187         iFloatingPointEditor->SetMaxLength(aLength);
       
  2188         }
       
  2189     }
       
  2190 
       
  2191 /**
       
  2192  * Get maximum text length in text based editors
       
  2193  */
       
  2194 EXPORT_C TInt CAknQueryControl::GetTextEntryLength() const
       
  2195     {
       
  2196     if( iEdwin )
       
  2197         {
       
  2198         return iEdwin->MaxLength();
       
  2199         }
       
  2200     if(iSecretEd)
       
  2201         {
       
  2202         return iSecretEd->MaxLength();
       
  2203         }
       
  2204     if(iPinEdwin)
       
  2205         {
       
  2206         return iPinEdwin->MaxLength();
       
  2207         }
       
  2208     if(iNumberEdwin)
       
  2209         {
       
  2210         return iNumberEdwin->MaxLength();
       
  2211         }
       
  2212     if (iFloatingPointEditor)
       
  2213         {
       
  2214         return iFloatingPointEditor->MaxLength();
       
  2215         }
       
  2216     return -1;
       
  2217     }
       
  2218 
       
  2219 ///
       
  2220 /// API Set methods
       
  2221 ///
       
  2222 
       
  2223 EXPORT_C void CAknQueryControl::SetMinimumAndMaximum(const TTime& aMinimum, const TTime& aMaximum)
       
  2224     {
       
  2225     if( iDateEdwin )
       
  2226         {
       
  2227         iDateEdwin->SetMinimumAndMaximum(aMinimum, aMaximum);
       
  2228         }
       
  2229     else if( iTimeEdwin )
       
  2230         {
       
  2231         iTimeEdwin->SetMinimumAndMaximum(aMinimum, aMaximum);
       
  2232         }
       
  2233     }
       
  2234 
       
  2235 EXPORT_C void CAknQueryControl::SetMinimumAndMaximum(const TTimeIntervalSeconds& aMinimumDuration, const TTimeIntervalSeconds& aMaximumDuration)
       
  2236     {
       
  2237     if( iDurationEdwin )
       
  2238         {
       
  2239         iDurationEdwin->SetMinimumAndMaximum(aMinimumDuration, aMaximumDuration);
       
  2240         }
       
  2241     }
       
  2242 
       
  2243 EXPORT_C void CAknQueryControl::SetMinimumAndMaximum(TInt aMinimumValue, TInt aMaximumValue)    
       
  2244     {
       
  2245     if( iNumberEdwin )
       
  2246         {
       
  2247         iNumberEdwin->SetMinimumIntegerValue(aMinimumValue);
       
  2248         iNumberEdwin->SetMaximumIntegerValue(aMaximumValue);
       
  2249         }
       
  2250     }
       
  2251 
       
  2252 EXPORT_C void CAknQueryControl::SetMinimumAndMaximum(const TReal& aMinimumValue, const TReal& aMaximumValue)    
       
  2253     {
       
  2254     if( iFloatingPointEditor )
       
  2255         {
       
  2256         iFloatingPointEditor->SetMinMax(aMinimumValue, aMaximumValue);
       
  2257         }
       
  2258     }
       
  2259 
       
  2260 
       
  2261 
       
  2262 EXPORT_C TBool CAknQueryControl::CheckNumber()    
       
  2263     {    
       
  2264     return iNumberEdwin->CheckNumber();
       
  2265     }
       
  2266 
       
  2267 EXPORT_C void CAknQueryControl::SetDuration(TTimeIntervalSeconds& aDuration)
       
  2268 //
       
  2269 //Set duration to editor
       
  2270 //
       
  2271 {
       
  2272     if( iDurationEdwin )
       
  2273         {
       
  2274         iDurationEdwin->SetDuration(aDuration);
       
  2275         }
       
  2276 }
       
  2277 
       
  2278 EXPORT_C void CAknQueryControl::SetNumberL(TInt aNumber)
       
  2279 //
       
  2280 //Set number from editor
       
  2281 //
       
  2282 {
       
  2283     if( iNumberEdwin )
       
  2284         {
       
  2285         iNumberEdwin->SetValueL(aNumber);
       
  2286         }
       
  2287 }
       
  2288 
       
  2289 EXPORT_C void CAknQueryControl::SetTime(TTime& aTime)
       
  2290 //
       
  2291 //Set time or date to editor
       
  2292 //
       
  2293 {
       
  2294     if( iTimeEdwin )
       
  2295         {
       
  2296         iTimeEdwin->SetTime(aTime);
       
  2297         }
       
  2298     else if( iDateEdwin )
       
  2299         {
       
  2300         iDateEdwin->SetDate(aTime);
       
  2301         }
       
  2302 }
       
  2303 
       
  2304 EXPORT_C void CAknQueryControl::SetFloatingPointNumberL(const TReal* aNumber)
       
  2305 //
       
  2306 //Set number from editor
       
  2307 //
       
  2308 {
       
  2309     if( iFloatingPointEditor )
       
  2310         {
       
  2311         iFloatingPointEditor->SetValueL( aNumber );
       
  2312         }
       
  2313 }
       
  2314 
       
  2315 EXPORT_C void CAknQueryControl::SetLocation(const TPosition &aLocation)
       
  2316 {
       
  2317 	if (iExtension && LocationEd())
       
  2318 		{
       
  2319 		LocationEd()->Set( aLocation );
       
  2320 		if ( AknLayoutUtils::PenEnabled() )
       
  2321             {
       
  2322             LocationEd()->SetFeature( CEikMfne::EFingerSupport, CEikMfne::EnableWithAllHighlight );
       
  2323 	        }
       
  2324 		}
       
  2325 }
       
  2326 
       
  2327 EXPORT_C void CAknQueryControl::SetNumberOfEditorLines(TInt aNum)
       
  2328     {
       
  2329     iNumberOfEditorLines = aNum;
       
  2330     }
       
  2331 
       
  2332 ///
       
  2333 /// API Get methods
       
  2334 ///
       
  2335 
       
  2336 EXPORT_C TInt CAknQueryControl::GetTextLength() const
       
  2337 //
       
  2338 //Get text length
       
  2339 //
       
  2340 {
       
  2341     if ( iSecretEd )
       
  2342         {
       
  2343         return iSecretEd->Buffer().Length();
       
  2344         }
       
  2345     if ( iPinEdwin )
       
  2346         {
       
  2347         return iPinEdwin->Buffer().Length();
       
  2348         }
       
  2349     if( iEdwin )
       
  2350         {
       
  2351         return iEdwin->TextLength();
       
  2352         }
       
  2353     if( iNumberEdwin )
       
  2354         {
       
  2355         return iNumberEdwin->TextLength();
       
  2356         }
       
  2357     if (iFloatingPointEditor)
       
  2358         {
       
  2359         return iFloatingPointEditor->TextLength();
       
  2360         }
       
  2361       
       
  2362     return -1;
       
  2363 }
       
  2364 
       
  2365 EXPORT_C TTime CAknQueryControl::GetTime() const
       
  2366 //
       
  2367 //Get time or date from editor
       
  2368 //
       
  2369 {
       
  2370     TTime time(0);
       
  2371 
       
  2372     if( iTimeEdwin )
       
  2373         {
       
  2374         return iTimeEdwin->Time();
       
  2375         }
       
  2376 
       
  2377     if( iDateEdwin )
       
  2378         {
       
  2379         return iDateEdwin->Date();
       
  2380         }
       
  2381 
       
  2382     return time;
       
  2383 }
       
  2384 
       
  2385 EXPORT_C TReal CAknQueryControl::GetFloatingPointNumberL() const
       
  2386 //
       
  2387 //Set number from editor
       
  2388 //
       
  2389 {
       
  2390     TReal ret = 0;
       
  2391     if( iFloatingPointEditor )
       
  2392         {
       
  2393         iFloatingPointEditor->GetValueAsReal( ret );
       
  2394         }
       
  2395     return ret;
       
  2396 }
       
  2397 
       
  2398 EXPORT_C void CAknQueryControl::GetLocation(TPosition &aLocation) const
       
  2399 {
       
  2400     if (LocationEd())
       
  2401     	{
       
  2402     	LocationEd()->Get(aLocation);
       
  2403     	}
       
  2404 }
       
  2405 
       
  2406 
       
  2407 EXPORT_C TInt CAknQueryControl::GetNumber() const
       
  2408 {
       
  2409     TInt value = 0;
       
  2410     if(iNumberEdwin)
       
  2411         {
       
  2412         iNumberEdwin->GetTextAsInteger( value );
       
  2413         }
       
  2414     else
       
  2415         {
       
  2416         ASSERT(EFalse);
       
  2417         }
       
  2418     return value;
       
  2419 }
       
  2420 
       
  2421 EXPORT_C TTimeIntervalSeconds CAknQueryControl::GetDuration() const
       
  2422 //
       
  2423 //Get duration from editor
       
  2424 //
       
  2425 {
       
  2426     if( iDurationEdwin )
       
  2427         {
       
  2428         return iDurationEdwin->Duration();
       
  2429         }
       
  2430     return NULL;
       
  2431 }
       
  2432 
       
  2433 /**
       
  2434  * Return number of lines in the editor
       
  2435  * 
       
  2436  * For data queries this can be 1 to 5 lines except if there are 3 lines
       
  2437  * of prompt text in which case only 1 line is permitted.
       
  2438  *
       
  2439  * For all other queries there is only 1 line of text.
       
  2440  */
       
  2441 EXPORT_C TInt CAknQueryControl::NbrOfEditorLines() const
       
  2442     {
       
  2443     TInt nbrOfLines = 0;
       
  2444     if(iEdwin &&  KQueryTypeToLayout[iQueryType] == EDataQueryLayoutM)
       
  2445         {
       
  2446         if (iNumberOfEditorLines == -1)
       
  2447             {
       
  2448             TInt nL = Min(iEdwin->TextLayout()->NumFormattedLines(),KMaxLinesInQuery);
       
  2449             const TInt mHIL= Min(iEdwin->MaximumHeightInLines(),KMaxLinesInQuery);
       
  2450             
       
  2451             if ( mHIL )
       
  2452                 {
       
  2453                 nbrOfLines = Min(nL,mHIL);
       
  2454                 }
       
  2455             else
       
  2456                 {
       
  2457                 nbrOfLines = nL;
       
  2458                 }
       
  2459             }
       
  2460     
       
  2461         else if (iNumberOfEditorLines >= 0 && iNumberOfEditorLines <= KMaxLinesInQuery)
       
  2462             {
       
  2463             nbrOfLines = iNumberOfEditorLines;
       
  2464             }
       
  2465         }
       
  2466 
       
  2467     return Max(1,nbrOfLines);
       
  2468     }
       
  2469 
       
  2470 /**
       
  2471  * Return number of prompt lines
       
  2472  *
       
  2473  * Only confirmation queries can have more than 2 lines
       
  2474  */
       
  2475 EXPORT_C TInt CAknQueryControl::NbrOfPromptLines() const
       
  2476     {
       
  2477     if (iPrompt)
       
  2478         return iPrompt->NumberOfLines();
       
  2479     return 1;
       
  2480     }
       
  2481 
       
  2482 
       
  2483 /**
       
  2484  * Return text editor depening on query type
       
  2485  */
       
  2486 EXPORT_C CCoeControl* CAknQueryControl::ControlByLayoutOrNull(TInt aLayout)
       
  2487     {
       
  2488     CCoeControl* ctrl=NULL;
       
  2489     switch ( aLayout )
       
  2490         {
       
  2491         case EStaticSizeDataLayout:
       
  2492         case EDataLayout:
       
  2493         case EPhoneLayout:
       
  2494             ctrl=iEdwin;
       
  2495             break;
       
  2496         case ECodeLayout:
       
  2497             ctrl=iSecretEd;
       
  2498             break;
       
  2499         case EDateLayout:
       
  2500             ctrl=iDateEdwin;
       
  2501             break;
       
  2502         case ETimeLayout:
       
  2503             ctrl=iTimeEdwin;
       
  2504             break;
       
  2505         case EDurationLayout:
       
  2506             ctrl=iDurationEdwin;
       
  2507             break;
       
  2508         case ENumberLayout:
       
  2509             ctrl=iNumberEdwin;
       
  2510             break;
       
  2511         case EPinLayout:
       
  2512             ctrl=iPinEdwin;
       
  2513             break;
       
  2514         case EFloatingPointLayout:
       
  2515             ctrl=iFloatingPointEditor;
       
  2516 			break;
       
  2517 		case ELocationLayout:
       
  2518 			ctrl=LocationEd();
       
  2519 			break;
       
  2520         default:
       
  2521             break;
       
  2522         }
       
  2523     return ctrl;
       
  2524     }
       
  2525 
       
  2526 /**
       
  2527 *
       
  2528 * Sends and ESC key to the app.  This cannot be called from within OfferKeyEventL.  It must be called
       
  2529 * from within some other non-key event that subsequently does not require references to the object
       
  2530 *
       
  2531 */
       
  2532 void CAknQueryControl::CancelQueryL()
       
  2533     {
       
  2534     if (iQueryControlObserver)
       
  2535         {
       
  2536         iQueryControlObserver->HandleQueryEditorStateEventL(this, MAknQueryControlObserver::EEmergencyCallAttempted, MAknQueryControlObserver::EEditorValueValid);
       
  2537         }
       
  2538     else 
       
  2539         {
       
  2540         TKeyEvent key;
       
  2541         key.iCode=EKeyEscape;
       
  2542         key.iModifiers=0;
       
  2543         key.iScanCode = EStdKeyNull;
       
  2544         iEikonEnv->SimulateKeyEventL(key, EEventKey);
       
  2545         }
       
  2546     }
       
  2547 
       
  2548 /**
       
  2549 * This method looks at the flags that have been set in the query control and 
       
  2550 * acts upon them if possible
       
  2551 * 
       
  2552 */
       
  2553 void CAknQueryControl::DeployFlagsL()
       
  2554     {
       
  2555     // Handle the Emergency call support flags
       
  2556     if (!iEcsDetector )
       
  2557         {
       
  2558         if ( 
       
  2559             (iNumberEdwin && iFlags.IsSet( EEmergencyCallsEnabledByAPI) )
       
  2560             ||
       
  2561             ( iPinEdwin && iFlags.IsSet( EEmergencyCallsEnabledByAPI) )
       
  2562             )
       
  2563             {
       
  2564             iEcsDetector = CAknEcsDetector::NewL();
       
  2565             // Set the control to be the CAknEcsDetector observer, if the object exists
       
  2566             iEcsDetector->SetObserver( iEcsObserver );
       
  2567             }
       
  2568 
       
  2569         }
       
  2570 
       
  2571     // Handle the T9 suppression in edwins. If the flag has not been set, then
       
  2572     // suppress the T9
       
  2573     if ( iFlags.IsClear ( EPredictiveTextEntryPermitted ) )
       
  2574         {
       
  2575         if ( iEdwin )
       
  2576             {
       
  2577             // set the noT9 flag
       
  2578             iEdwin->SetAknEditorFlags( EAknEditorFlagNoT9 | iEdwin->AknEdwinFlags() );
       
  2579             }
       
  2580         }       
       
  2581 
       
  2582     }
       
  2583 
       
  2584 /**
       
  2585 * Method to first set the flags and then to use them on the contained editors
       
  2586 *
       
  2587 */
       
  2588 
       
  2589 void CAknQueryControl::SetAndUseFlagsL(TBitFlags16 aFlags)
       
  2590     {
       
  2591     SetFlags( aFlags );
       
  2592     DeployFlagsL();
       
  2593     }
       
  2594 
       
  2595 void CAknQueryControl::SetFlags(TBitFlags16 aFlags)
       
  2596     {
       
  2597     iFlags = aFlags;
       
  2598     iEditIndicator->SetFlags( aFlags );
       
  2599     }
       
  2600 
       
  2601 EXPORT_C void CAknQueryControl::SetImageL(CEikImage* aImage)
       
  2602     { // Gets ownership of the aImage
       
  2603     
       
  2604 	if ( iImage && iImage->IsPictureOwnedExternally() )
       
  2605         {
       
  2606         delete ((CApaMaskedBitmap*) iImage->Bitmap());
       
  2607         }
       
  2608     
       
  2609 	delete iImage;
       
  2610     iImage = aImage;
       
  2611 
       
  2612     if ( iImage )
       
  2613         {
       
  2614         iImage->SetContainerWindowL(*this);
       
  2615         }
       
  2616 
       
  2617     delete iAnimation;
       
  2618     iAnimation = NULL;
       
  2619 
       
  2620     Layout();
       
  2621     }
       
  2622 
       
  2623 EXPORT_C void CAknQueryControl::SetImageL(const TDesC& aImageFile,
       
  2624                                           TInt aBmpId, TInt aBmpMaskId)
       
  2625     {
       
  2626     CEikImage* image = new(ELeave) CEikImage;
       
  2627     CleanupStack::PushL( image );
       
  2628                
       
  2629     TBool skinnedFound( EFalse );
       
  2630     if ( aImageFile.CompareF(KAvkonBitmapFile) == 0 ) // Skinning is supported only avkon bitmaps
       
  2631 	    {
       
  2632         TAknsItemID id;
       
  2633         id.Set(0,0);
       
  2634         id = CAknNoteAttributes::GetSkinnedBitmapID(aBmpId);
       
  2635         if ( id.iMajor && id.iMinor ) // skin id found, try loading
       
  2636 	        {
       
  2637             CApaMaskedBitmap* bitmap = NULL;
       
  2638             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  2639             TRAPD( err, bitmap = AknsUtils::CreateMaskedBitmapL(skin,id));
       
  2640             if ( !err ) 
       
  2641 	           {
       
  2642                CFbsBitmap* mask = bitmap->Mask();
       
  2643                iImage->SetPicture(bitmap,mask);
       
  2644                iImage->SetPictureOwnedExternally(ETrue);
       
  2645                skinnedFound = ETrue;
       
  2646                }
       
  2647 			}
       
  2648         }
       
  2649     if ( !skinnedFound) 
       
  2650 		{
       
  2651         image->CreatePictureFromFileL(aImageFile,aBmpId,aBmpMaskId);
       
  2652         }
       
  2653 
       
  2654     CleanupStack::Pop(); //image
       
  2655     SetImageL(image); // gets ownership
       
  2656     }
       
  2657 
       
  2658 EXPORT_C void CAknQueryControl::SetAnimationL(TInt aResource)
       
  2659     {
       
  2660     delete iAnimation;
       
  2661     iAnimation = NULL;
       
  2662     iAnimation = CAknBitmapAnimation::NewL();
       
  2663     iAnimation->SetContainerWindowL(*this);
       
  2664 
       
  2665     TAknsItemID iid;
       
  2666     iid.Set( EAknsMajorAvkon, aResource );
       
  2667     if( !iAnimation->ConstructFromSkinL( iid ) )
       
  2668         {
       
  2669         TResourceReader readerForAnimation;
       
  2670         iCoeEnv->CreateResourceReaderLC(readerForAnimation,aResource);
       
  2671         iAnimation->ConstructFromResourceL(readerForAnimation);
       
  2672         CleanupStack::PopAndDestroy(); // readerForAnimation
       
  2673         }
       
  2674 
       
  2675     // Save the animation resource id, because this function will be re-called 
       
  2676     // when handling resource change. 
       
  2677     iExtension->iAnimationId = aResource;
       
  2678     
       
  2679     Layout();
       
  2680     }
       
  2681 
       
  2682 EXPORT_C void CAknQueryControl::StartAnimationL()
       
  2683     {
       
  2684     if (iAnimation)
       
  2685         {
       
  2686         CBitmapAnimClientData *animClientData = iAnimation->BitmapAnimData();
       
  2687         if (animClientData != NULL && animClientData->FrameArray().Count() <= 1)
       
  2688             {
       
  2689             // Not set background frame, if there is only one frame in animation.
       
  2690             }
       
  2691         else
       
  2692             {
       
  2693             const TDisplayMode displayMode( 
       
  2694             CCoeEnv::Static()->ScreenDevice()->DisplayMode() );
       
  2695             
       
  2696             CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
       
  2697             CleanupStack::PushL(bitmap);
       
  2698             
       
  2699             User::LeaveIfError( bitmap->Create( iAnimation->Rect().Size(), displayMode ) );
       
  2700             
       
  2701             CFbsBitmapDevice* doubleBufferDev = CFbsBitmapDevice::NewL( bitmap );
       
  2702             CleanupStack::PushL(doubleBufferDev);    
       
  2703             
       
  2704             CFbsBitGc* doubleBufferGc = 0;
       
  2705             User::LeaveIfError( doubleBufferDev->CreateContext( doubleBufferGc ) );    
       
  2706             CleanupStack::PushL(doubleBufferGc);    
       
  2707             
       
  2708             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  2709             MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  2710             
       
  2711             AknsDrawUtils::DrawBackground( skin, cc, this, *doubleBufferGc,
       
  2712                 TPoint(0,0), iAnimation->Rect(), KAknsDrawParamDefault );
       
  2713             
       
  2714             CleanupStack::PopAndDestroy(2); // doubleBufferGc, doubleBufferDev
       
  2715             
       
  2716             CBitmapFrameData* data = CBitmapFrameData::NewL();
       
  2717             data->SetBitmapsOwnedExternally( EFalse );
       
  2718             data->SetBitmap( bitmap );
       
  2719             
       
  2720             // Set frame to animation
       
  2721             iAnimation->BitmapAnimData()->SetBackgroundFrame( data ); // gets ownership
       
  2722             
       
  2723             CleanupStack::Pop(bitmap); 
       
  2724             }
       
  2725 
       
  2726         iAnimation->StartAnimationL();
       
  2727         }
       
  2728     }
       
  2729 
       
  2730 EXPORT_C TInt CAknQueryControl::CancelAnimation()
       
  2731     {
       
  2732     if ( iAnimation )
       
  2733         {
       
  2734         return iAnimation->CancelAnimation();
       
  2735         }
       
  2736     return KErrGeneral;
       
  2737     }
       
  2738 
       
  2739 
       
  2740 
       
  2741 /** 
       
  2742  * Return true if editor content is valid for query, false 
       
  2743  * otherwise. Some editors always have a valid content. Others
       
  2744  * (those that have a text associated with them) may or may
       
  2745  * not have a valid content.
       
  2746  */ 
       
  2747 TBool CAknQueryControl::EditorContentIsValidL() const
       
  2748     {
       
  2749     TInt   ret  = EFalse;
       
  2750     if (iDateEdwin || iTimeEdwin || iDurationEdwin ||LocationEd()) 
       
  2751         {
       
  2752         CEikMfne* editor = iDateEdwin;
       
  2753         if (!editor && iTimeEdwin)
       
  2754             editor = iTimeEdwin;
       
  2755         if (!editor && iDurationEdwin)
       
  2756             editor = iDurationEdwin;
       
  2757         if (!editor && LocationEd())
       
  2758         	editor = static_cast<CEikMfne*>(LocationEd());
       
  2759         ret = editor->Field(editor->CurrentField())->IsValid();
       
  2760         }
       
  2761     else if (iNumberEdwin || iFloatingPointEditor)
       
  2762         {
       
  2763         TInt intValue;
       
  2764         TReal realValue;
       
  2765 
       
  2766         CAknNumericEdwin::TValidationStatus status = iNumberEdwin ?
       
  2767             iNumberEdwin->GetTextAsInteger(intValue) : iFloatingPointEditor->GetValueAsReal(realValue);
       
  2768 
       
  2769         // At this point too large or small values don't affect the valicy of content,
       
  2770         // range is checked when OkToExitL-method is called when user tries to confirm the query 
       
  2771         if (iNumberEdwin && (status == CAknNumericEdwin::EValueTooSmall || 
       
  2772             status == CAknNumericEdwin::EValueTooLarge ) ) 
       
  2773             {
       
  2774             status = CAknNumericEdwin::EValueValid;
       
  2775 	        }
       
  2776         ret = status == CAknNumericEdwin::EValueValid;
       
  2777         }
       
  2778     else
       
  2779         {//Remaining editors have a non-empty text with at least one char
       
  2780         // which is not a space and is not a control char
       
  2781         CAknQueryExtension* extension = QueryExtension();
       
  2782         if( extension )
       
  2783             {
       
  2784             if ( extension->iAllowEmptyInput )
       
  2785                 {
       
  2786                 return ETrue;
       
  2787                 }
       
  2788             }
       
  2789         
       
  2790         HBufC* buf = HBufC::NewLC(GetTextEntryLength()); //max length
       
  2791         TPtr ptr = buf->Des();
       
  2792         if (GetTextEntryLength()) //check if zero is set as maxlength
       
  2793             {
       
  2794                 GetText(ptr);
       
  2795             }
       
  2796         ret = AknTextUtils::IsEmptyText( ptr );
       
  2797         
       
  2798         if ( !ret && ptr.Length() > 0 && iSecretEd )            
       
  2799             {
       
  2800             TBool isSpace = ETrue;
       
  2801             for ( TInt i = 0; i < ptr.Length(); i++ )            
       
  2802                 {
       
  2803                 TChar c( ptr[i] );
       
  2804                 if ( !c.IsSpace() )
       
  2805                     {
       
  2806                     isSpace = EFalse;
       
  2807                     break;
       
  2808                     }
       
  2809                 }
       
  2810             if ( isSpace )
       
  2811                 {
       
  2812                 ret = ETrue;                
       
  2813                 }
       
  2814             }        
       
  2815 
       
  2816 		// Check if pictographs in buffer	
       
  2817 		if (!ret && iEdwin && iPrompt && ptr.Length())
       
  2818 			{
       
  2819 			CAknPictographInterface* picto = iPrompt->PictographInterface();
       
  2820 
       
  2821 			if ( picto && picto->Interface() && picto->Interface()->ContainsPictographs( ptr ) )
       
  2822 				{
       
  2823 				ret = ETrue;
       
  2824 				}
       
  2825 			}		
       
  2826 		CleanupStack::PopAndDestroy(); // buf    
       
  2827         }
       
  2828     return ret; 
       
  2829     }
       
  2830 
       
  2831 /*****************************************************************
       
  2832  * CAknQueryControl::TIndex
       
  2833  *
       
  2834  * Manage indexes into LAF tables
       
  2835  *
       
  2836  * PN stands for "Popup Note"
       
  2837  *
       
  2838  * PQD stands for "Popup Query Data'
       
  2839  *
       
  2840  * PQC stands for "Popup Query Code'
       
  2841  *
       
  2842  * 'DPQ' stands for "Data Query Popup"
       
  2843  ******************************************************************/
       
  2844 
       
  2845   
       
  2846 CAknQueryControl::TIndex::TIndex(TInt aNumberOfPromptLines)
       
  2847     : iNumberOfPromptLines(aNumberOfPromptLines)
       
  2848     {
       
  2849     }
       
  2850         
       
  2851 void CAknQueryControl::TIndex::SelfTest() const
       
  2852     {
       
  2853     __ASSERT_DEBUG(iNumberOfPromptLines >= 0  && iNumberOfPromptLines <= 5,
       
  2854         Panic(EAknPanicInvalidValue));
       
  2855     }
       
  2856 
       
  2857 /**
       
  2858  * Return index into LAF tables that depend directly on number of prompt lines,
       
  2859  * index is equal to number of prompt lines minus one unless there are no prompt
       
  2860  * lines in which case the index is zero
       
  2861  */
       
  2862 TInt CAknQueryControl::TIndex::PromptLine() const
       
  2863     {
       
  2864     SelfTest();
       
  2865     return iNumberOfPromptLines > 0 ? iNumberOfPromptLines - 1 : 0;
       
  2866     }
       
  2867 
       
  2868 /**
       
  2869  * Return index into Main Pane PQDC Window, which
       
  2870  * depends on total number of prompt lines minus 2, e.g.
       
  2871  * index 0 for 2 prompt lines total.
       
  2872  *
       
  2873  */
       
  2874 TInt CAknQueryControl::TIndex::DQPWindowTextsLine2(TInt aLineNum) const
       
  2875     {
       
  2876     SelfTest();
       
  2877     __ASSERT_DEBUG(aLineNum > 0 && aLineNum <= 5,Panic(EAknPanicInvalidValue));
       
  2878 
       
  2879     static const TInt  KDataQueryPopupWindowTextsLine2Index[3][5] = 
       
  2880     {   {0,  1, 2, 3, 4},    //1 PROMPT LINE
       
  2881         {5,  6, 7, 8, 9},    //2 PROMPT LINES
       
  2882         {10, 10, 10, 10, 10}  }; //3 PROMPT LINES
       
  2883     
       
  2884     return KDataQueryPopupWindowTextsLine2Index[PromptLine()][aLineNum-1];
       
  2885     }
       
  2886 
       
  2887 TInt CAknQueryControl::TIndex::PNWindow() const
       
  2888     {
       
  2889     SelfTest();
       
  2890  
       
  2891     static const TInt KPopupNoteWindowIndex[5] = { 0,0,0,1,2 };
       
  2892     
       
  2893     AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
       
  2894     if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight)
       
  2895         {
       
  2896         // variety numbers for right CBA are 3,4 and 5 
       
  2897         return (KPopupNoteWindowIndex[PromptLine()] + 3);  
       
  2898         }
       
  2899     else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft)
       
  2900         {
       
  2901         /// variety numbers for left CBA are 6,7 and 8 
       
  2902         return (KPopupNoteWindowIndex[PromptLine()] + 6);
       
  2903         }
       
  2904     else // bottom
       
  2905         {
       
  2906         return KPopupNoteWindowIndex[PromptLine()];
       
  2907         }
       
  2908     }
       
  2909 
       
  2910 TInt CAknQueryControl::TIndex::PQDWindow(TInt aLineNum) const
       
  2911     {
       
  2912     SelfTest();
       
  2913     __ASSERT_DEBUG(aLineNum > 0 && aLineNum <= 5,Panic(EAknPanicInvalidValue));
       
  2914 
       
  2915     AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
       
  2916     
       
  2917     if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight)
       
  2918         {
       
  2919         static const TInt KPopupQueryDataWindowIndex[7] = 
       
  2920             {13, 12, 11, 10, 9, 8, 7}; // variety numbers for right CBA are 7-13 
       
  2921         return KPopupQueryDataWindowIndex[PromptLine()+aLineNum-1];
       
  2922         }
       
  2923     else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft)
       
  2924         {
       
  2925         static const TInt KPopupQueryDataWindowIndex[7] = 
       
  2926             {20, 19, 18, 17, 16, 15, 14}; // variety numbers for left CBA are 14-20 
       
  2927         return KPopupQueryDataWindowIndex[PromptLine()+aLineNum-1];
       
  2928         }
       
  2929     else // bottom
       
  2930         {
       
  2931         static const TInt KPopupQueryDataWindowIndex[7] = 
       
  2932             {0, 1, 2, 3, 4, 5, 6}; // variety numbers for bottom CBA are 0-6
       
  2933         return KPopupQueryDataWindowIndex[PromptLine()+aLineNum-1];
       
  2934         }
       
  2935     }
       
  2936     
       
  2937 TInt CAknQueryControl::TIndex::PQCWindow() const
       
  2938     {
       
  2939     SelfTest();
       
  2940     
       
  2941     AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
       
  2942     
       
  2943     if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight)
       
  2944         {
       
  2945         // variety numbers for right CBA are 3,4 and 5 
       
  2946         return iNumberOfPromptLines > 0 ? (iNumberOfPromptLines - 1 + 3) : 3;
       
  2947         }
       
  2948     else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft)
       
  2949         {
       
  2950         // variety numbers for left CBA are 6,7 and 8 
       
  2951         return iNumberOfPromptLines > 0 ? (iNumberOfPromptLines - 1 + 6) : 6;
       
  2952         }
       
  2953     else // bottom
       
  2954         {
       
  2955         // variety numbers for bottom CBA are 0,1 and 2 
       
  2956         return iNumberOfPromptLines > 0 ? (iNumberOfPromptLines - 1) : 0;
       
  2957         }
       
  2958     }    
       
  2959 
       
  2960 TTypeUid::Ptr CAknQueryControl::MopSupplyObject( TTypeUid aId )
       
  2961     {
       
  2962     CAknQueryExtension* extension = QueryExtension();
       
  2963     if( (aId.iUid == MAknsControlContext::ETypeId) && 
       
  2964         extension && extension->EditorContext() && iHasEditor )
       
  2965         {
       
  2966         // Return specific context iff editor exists and the context
       
  2967         // has been constructed.
       
  2968         return MAknsControlContext::SupplyMopObject( 
       
  2969             aId, extension->EditorContext() );
       
  2970         }
       
  2971         
       
  2972     if ( aId.iUid == CAknQueryControl::ETypeId )
       
  2973     	{
       
  2974     	return aId.MakePtr( this );
       
  2975     	}
       
  2976         
       
  2977     return SupplyMopObject( aId, iEditIndicator );
       
  2978     }
       
  2979 
       
  2980 // Callback for doing a redraw when animating pictographs
       
  2981 TInt CAknQueryControl::StaticPictographCallBack( TAny* aPtr )
       
  2982     {
       
  2983     CAknQueryControl* me = static_cast<CAknQueryControl*>( aPtr );
       
  2984     me->PictographCallBack();
       
  2985     return KErrNone;
       
  2986     }
       
  2987 
       
  2988 void CAknQueryControl::PictographCallBack()
       
  2989     {
       
  2990     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  2991     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  2992 
       
  2993     for ( TInt i = 0 ; i < iPrompt->NumberOfLines() ; i++ )
       
  2994         {
       
  2995         CAknPictographInterface* picto = iPrompt->PictographInterface();
       
  2996 
       
  2997         // Only update the note line if it contains pictographs
       
  2998 
       
  2999         if ( picto->Interface()->ContainsPictographs( 
       
  3000             *( iPrompt->Line( i )->Text() ) ) )
       
  3001             {
       
  3002             TRect lineRect = iPrompt->Line(i)->Rect();
       
  3003             Window().Invalidate( lineRect );
       
  3004 
       
  3005             ActivateGc();
       
  3006             Window().BeginRedraw();
       
  3007 
       
  3008             AknsDrawUtils::Background(
       
  3009                 skin,
       
  3010                 cc,
       
  3011                 this,
       
  3012 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
  3013 				SystemGc(),
       
  3014 #else				
       
  3015                 iCoeEnv->SystemGc(),
       
  3016 #endif                
       
  3017                 lineRect );
       
  3018 
       
  3019             Window().EndRedraw();
       
  3020             DeactivateGc();
       
  3021 
       
  3022             // Draw the label after the background.
       
  3023             iPrompt->Line( i )->ActivateL(); // Never leaves
       
  3024             iPrompt->Line( i )->DrawNow();
       
  3025             iPrompt->SetLineModified( i, EFalse );
       
  3026             }
       
  3027         }
       
  3028     }
       
  3029 
       
  3030 TBool CAknQueryControl::EmbeddedVirtualInput() const
       
  3031     {
       
  3032     if ( !QueryExtension()->iVirtualInputStatusFlags.IsSet( CAknQueryExtension::EVirtualInputCheckedAlready ) )
       
  3033         {
       
  3034         QueryExtension()->iVirtualInputStatusFlags.Set( CAknQueryExtension::EVirtualInputCheckedAlready );
       
  3035         
       
  3036         CEikDialog* dialog = NULL;
       
  3037 
       
  3038         // Remove constness. This is unfortunate but this method needs to be
       
  3039         // called from several const methods so better to do it in one place.
       
  3040         const_cast<CAknQueryControl*>( this )->MopGetObject( dialog );
       
  3041 
       
  3042         if ( dialog )
       
  3043             {
       
  3044             if ( dialog->DialogFlags() & EEikDialogFlagVirtualInput )
       
  3045                 {
       
  3046                 QueryExtension()->iVirtualInputStatusFlags.Set( CAknQueryExtension::EVirtualInputEnabled );
       
  3047                 }
       
  3048             }
       
  3049         }
       
  3050         
       
  3051 #ifdef RD_SCALABLE_UI_V2            
       
  3052     if ( AknLayoutUtils::PenEnabled() )
       
  3053     	{
       
  3054     	return QueryExtension()->iVirtualInputStatusFlags.IsSet( CAknQueryExtension::EVirtualInputEnabled );
       
  3055     	}
       
  3056 #endif
       
  3057 	return false;    	
       
  3058     }
       
  3059     
       
  3060     
       
  3061 CEikDialog* CAknQueryControl::Dialog() const
       
  3062     {
       
  3063     CAknQueryControl* control = const_cast<CAknQueryControl*>( this );
       
  3064     
       
  3065     CEikDialog* dialog = NULL;
       
  3066     control->MopGetObject( dialog );
       
  3067     return dialog;
       
  3068     }
       
  3069    
       
  3070     
       
  3071 void CAknQueryControl::CreateIncAndDecButtonsL()
       
  3072 	{
       
  3073 	if (!iIncreaseValueButton)
       
  3074 		{
       
  3075 		iIncreaseValueButton = 
       
  3076 			CAknButton::NewL(KAvkonBitmapFile,
       
  3077 			EMbmAvkonQgn_indi_button_increase,
       
  3078 			EMbmAvkonQgn_indi_button_increase_mask,
       
  3079             -1,
       
  3080             -1,
       
  3081             EMbmAvkonQgn_indi_button_increase_pressed,
       
  3082             EMbmAvkonQgn_indi_button_increase_pressed_mask,
       
  3083             -1,
       
  3084             -1,
       
  3085             KNullDesC,
       
  3086             KNullDesC,
       
  3087             KAknButtonNoFrame | KAknButtonKeyRepeat,
       
  3088             0,
       
  3089             KAknsIIDQgnIndiButtonIncrease,
       
  3090             KAknsIIDNone,
       
  3091             KAknsIIDQgnIndiButtonIncreasePressed,
       
  3092             KAknsIIDNone );
       
  3093             
       
  3094         iIncreaseValueButton->SetContainerWindowL(*this);
       
  3095         iIncreaseValueButton->SetParent(this);
       
  3096         iIncreaseValueButton->SetObserver(this);
       
  3097         iIncreaseValueButton->MakeVisible(ETrue);
       
  3098         iIncreaseValueButton->SetFocusing(EFalse);
       
  3099 		}
       
  3100 		  
       
  3101 	if (!iDecreaseValueButton)
       
  3102 		{
       
  3103 		iDecreaseValueButton = 
       
  3104         	CAknButton::NewL(KAvkonBitmapFile,
       
  3105             EMbmAvkonQgn_indi_button_decrease,
       
  3106             EMbmAvkonQgn_indi_button_decrease_mask,
       
  3107             -1,
       
  3108             -1,
       
  3109             EMbmAvkonQgn_indi_button_decrease_pressed,
       
  3110 			EMbmAvkonQgn_indi_button_decrease_pressed_mask,
       
  3111 			-1,
       
  3112 			-1,
       
  3113 			KNullDesC,
       
  3114 			KNullDesC,
       
  3115 			KAknButtonNoFrame | KAknButtonKeyRepeat,
       
  3116 			0,
       
  3117 			KAknsIIDQgnIndiButtonDecrease,
       
  3118 			KAknsIIDNone,
       
  3119 			KAknsIIDQgnIndiButtonDecreasePressed,
       
  3120 			KAknsIIDNone );
       
  3121 			
       
  3122 		iDecreaseValueButton->SetContainerWindowL(*this);
       
  3123 		iDecreaseValueButton->SetParent(this);
       
  3124 		iDecreaseValueButton->SetObserver(this);
       
  3125 		iDecreaseValueButton->MakeVisible(ETrue);
       
  3126 		iDecreaseValueButton->SetFocusing(EFalse);
       
  3127 		}
       
  3128 	}
       
  3129     
       
  3130 void CAknQueryControl::CreateBackspaceButtonL()
       
  3131 	{
       
  3132 	if (iExtension && !iExtension->iBackspaceButton)
       
  3133 		{
       
  3134 		iExtension->iBackspaceButton = 
       
  3135 			CAknButton::NewL(KAvkonBitmapFile,
       
  3136 			EMbmAvkonQgn_indi_navi_arrow_left,			
       
  3137 			EMbmAvkonQgn_indi_navi_arrow_left_mask,
       
  3138 			-1,
       
  3139 			-1,
       
  3140 			-1,
       
  3141 			-1,
       
  3142 			-1,
       
  3143 			-1,
       
  3144 			KNullDesC,
       
  3145 			KNullDesC,
       
  3146 			KAknButtonKeyRepeat | KAknButtonReportOnKeyDown,
       
  3147 			0,
       
  3148 			KAknsIIDQgnIndiItutBackspace, 
       
  3149 			KAknsIIDNone,
       
  3150 			KAknsIIDNone,
       
  3151 			KAknsIIDNone );
       
  3152 		iExtension->iBackspaceButton->SetContainerWindowL(*this);
       
  3153 		iExtension->iBackspaceButton->SetParent(this);
       
  3154 		iExtension->iBackspaceButton->SetObserver(this);
       
  3155 		iExtension->iBackspaceButton->MakeVisible(ETrue);
       
  3156 		iExtension->iBackspaceButton->SetFocusing(EFalse);	
       
  3157 		
       
  3158 		
       
  3159         iExtension->iBackspaceButton->SetBackgroundIds( KAknsIIDQsnFrFunctionButtonNormal,
       
  3160         	KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive,
       
  3161         	KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive );
       
  3162      
       
  3163 		
       
  3164     	CFbsBitmap *icon = NULL;
       
  3165     	CFbsBitmap *mask = NULL;    
       
  3166     
       
  3167     	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  3168     	AknsUtils::CreateColorIconL( skin,
       
  3169     		KAknsIIDQgnIndiItutBackspace,
       
  3170     		KAknsIIDQsnTextColors,
       
  3171     		EAknsCIQsnIconColorsCG30,
       
  3172     		icon, mask,
       
  3173     		KAvkonBitmapFile,
       
  3174     		EMbmAvkonQgn_indi_navi_arrow_left,
       
  3175     		EMbmAvkonQgn_indi_navi_arrow_left_mask,
       
  3176     		KRgbBlack );    
       
  3177     
       
  3178     	CGulIcon* gulIcon = CGulIcon::NewL( icon, mask );
       
  3179     	iExtension->iBackspaceButton->State()->SetIcon( gulIcon );
       
  3180 		}
       
  3181 	}
       
  3182  
       
  3183 	
       
  3184 void CAknQueryControl::LayoutEditorForFullScreen( const TLayoutMethod& /*aLayoutM*/ )
       
  3185 	{
       
  3186 	TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
  3187 	
       
  3188 	TIndex LAFIndex(NbrOfPromptLines());
       
  3189 	iHasEditor = ETrue;
       
  3190     
       
  3191     TInt variety( LAFIndex.PromptLine() );
       
  3192     iEditorVerShadow.LayoutRect( LayoutRect(), AKN_LAYOUT_WINDOW_Code_query_pop_up_window_elements_Line_1( variety ) );
       
  3193     iEditorHorShadow.LayoutRect( LayoutRect(), AKN_LAYOUT_WINDOW_Code_query_pop_up_window_elements_Line_2( variety ) );
       
  3194     
       
  3195     TAknLayoutRect layoutRect;
       
  3196  	layoutRect.LayoutRect( LayoutRect(), TAknWindowComponentLayout::Compose(
       
  3197  		AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ), 
       
  3198     	AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ) ).LayoutLine() );
       
  3199     
       
  3200     
       
  3201     // Layout editor frame
       
  3202  		
       
  3203  	iEditorFrame.LayoutRect( layoutRect.Rect(), AknLayoutScalable_Apps::input_focus_pane_cp09( 0 ) );
       
  3204        
       
  3205    	// Layout editor indicator
       
  3206         
       
  3207 	TAknWindowLineLayout lineLayout = AknLayoutScalable_Apps::area_vitu2_query_pane_g1( 0 );
       
  3208 	AknLayoutUtils::LayoutControl(iEditIndicator, layoutRect.Rect(), lineLayout );
       
  3209         
       
  3210 	// Layout secret editor
       
  3211 	
       
  3212 	 if( iSecretEd )
       
  3213         {
       
  3214         TAknLayoutRect layoutRect;
       
  3215  		layoutRect.LayoutRect( LayoutRect(), AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ) ); 
       
  3216      
       
  3217         AknLayoutUtils::LayoutSecretEditor( iSecretEd, layoutRect.Rect(),
       
  3218        		TAknWindowComponentLayout::ComposeText( 
       
  3219             AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ),
       
  3220             AknLayoutScalable_Apps::area_vitu2_query_pane_t3( 1 ) ) );
       
  3221      	
       
  3222        	iSecretEd->SetBorder( TGulBorder::ENone );
       
  3223        	if ( IsFocused() && !iSecretEd->IsFocused() )
       
  3224        		{
       
  3225        		iSecretEd->SetFocus( ETrue );
       
  3226        		}
       
  3227        	}
       
  3228         
       
  3229 	// Layout pin editor
       
  3230 	
       
  3231 	if( iPinEdwin )
       
  3232         {
       
  3233         TAknLayoutRect layoutRect;
       
  3234  		layoutRect.LayoutRect( LayoutRect(), AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ) ); 
       
  3235         
       
  3236         AknLayoutUtils::LayoutSecretEditor( iPinEdwin, layoutRect.Rect(),
       
  3237        		TAknWindowComponentLayout::ComposeText( 
       
  3238             AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ),
       
  3239             AknLayoutScalable_Apps::area_vitu2_query_pane_t3( 1 ) ) );
       
  3240         		
       
  3241        	iPinEdwin->SetBorder( TGulBorder::ENone );
       
  3242        	if ( IsFocused() && !iPinEdwin->IsFocused() )
       
  3243        		{
       
  3244        		iPinEdwin->SetFocus( ETrue );
       
  3245        		}
       
  3246        	}
       
  3247 
       
  3248 	// Layout MFNE editor
       
  3249 	
       
  3250 	CEikMfne* edwin = NULL;
       
  3251     if ( iTimeEdwin )
       
  3252     	{
       
  3253         edwin = iTimeEdwin;
       
  3254         }        
       
  3255     else if ( iDateEdwin )
       
  3256         {
       
  3257         edwin = iDateEdwin;
       
  3258         }
       
  3259     if ( edwin )
       
  3260     	{
       
  3261 
       
  3262 		TAknLayoutRect layoutRect;
       
  3263  		layoutRect.LayoutRect( LayoutRect(), AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ) ); 
       
  3264                                                
       
  3265         AknLayoutUtils::LayoutMfne( edwin, layoutRect.Rect(), 
       
  3266         	TAknWindowComponentLayout::ComposeText( 
       
  3267             AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ),
       
  3268             AknLayoutScalable_Apps::area_vitu2_query_pane_t3( 1 ) ) );
       
  3269    
       
  3270         edwin->SetBorder( TGulBorder::ENone );
       
  3271         if ( IsFocused() && !edwin->IsFocused() )
       
  3272         	{
       
  3273             edwin->SetFocus( ETrue );
       
  3274             }
       
  3275         edwin->SetUpAndDownKeysConsumed( ETrue );
       
  3276         }   
       
  3277         
       
  3278     // Layout Edwin editor    
       
  3279         
       
  3280     if ( iEdwin )
       
  3281         {      
       
  3282         TAknLayoutRect layoutRect;
       
  3283  		layoutRect.LayoutRect( LayoutRect(), TAknWindowComponentLayout::Compose(
       
  3284  			AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ), 
       
  3285     		AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ) ).LayoutLine() );
       
  3286       
       
  3287         TAknTextComponentLayout textLayout =
       
  3288             AknLayoutScalable_Apps::area_vitu2_query_pane_t3(1);
       
  3289          
       
  3290         TRect rect( layoutRect.Rect() );
       
  3291         rect.iBr.iX -= 10;        
       
  3292         AknLayoutUtils::LayoutEdwin( iEdwin,
       
  3293             rect,
       
  3294             textLayout.LayoutLine(),
       
  3295             EAknsCIQsnTextColorsCG27,
       
  3296             0,
       
  3297             ETrue );
       
  3298             
       
  3299         iEdwin->SetBorder( TGulBorder::ENone ); 
       
  3300         if ( IsFocused() && !( iEdwin->IsFocused() ) )
       
  3301             {
       
  3302             iEdwin->SetFocus(ETrue);
       
  3303             }
       
  3304         }
       
  3305     }
       
  3306 	    
       
  3307 void CAknQueryControl::LayoutPromptForFullScreen()
       
  3308 	{
       
  3309     if ( NbrOfPromptLines() != 3 )
       
  3310     	{
       
  3311     	return;	
       
  3312     	}
       
  3313     
       
  3314     TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
  3315     
       
  3316     TAknLayoutRect rect;
       
  3317  	rect.LayoutRect( LayoutRect(), TAknWindowComponentLayout::Compose(
       
  3318  		AknLayoutScalable_Apps::popup_vitu2_window( landscape ? 1 : 0 ), 
       
  3319     	AknLayoutScalable_Apps::area_vitu2_query_pane( landscape ? 1 : 0 ) ).LayoutLine() );
       
  3320     	
       
  3321     TAknTextLineLayout lineLayout = AknLayoutScalable_Apps::area_vitu2_query_pane_t4( 1 ).LayoutLine();
       
  3322     AknLayoutUtils::LayoutLabel(iPrompt->Line(0), rect.Rect(), lineLayout );
       
  3323           
       
  3324     lineLayout = AknLayoutScalable_Apps::area_vitu2_query_pane_t5( 1 ).LayoutLine();
       
  3325     AknLayoutUtils::LayoutLabel(iPrompt->Line(1), rect.Rect(), lineLayout );
       
  3326   
       
  3327     lineLayout = AknLayoutScalable_Apps::area_vitu2_query_pane_t6( 1 ).LayoutLine();
       
  3328     AknLayoutUtils::LayoutLabel(iPrompt->Line(2), rect.Rect(), lineLayout );   
       
  3329 	}
       
  3330 
       
  3331 EXPORT_C void CAknQueryControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
  3332     { 
       
  3333     CEikMfne* edwin = NULL;
       
  3334     if ( iTimeEdwin )
       
  3335         {
       
  3336         edwin = iTimeEdwin;
       
  3337         }        
       
  3338     else if ( iDateEdwin )
       
  3339         {
       
  3340         edwin = iDateEdwin;
       
  3341         }
       
  3342     else if ( LocationEd() )
       
  3343         {
       
  3344         edwin = LocationEd();
       
  3345         }
       
  3346     else if ( iDurationEdwin )
       
  3347         {
       
  3348         edwin = iDurationEdwin;
       
  3349         }
       
  3350         
       
  3351     if ( edwin && iEditorFrame.Rect().Contains(aPointerEvent.iPosition) )
       
  3352         {
       
  3353         edwin->HandlePointerEventL(aPointerEvent);
       
  3354         }
       
  3355     else
       
  3356         {
       
  3357         CAknControl::HandlePointerEventL(aPointerEvent); 
       
  3358         }
       
  3359     }
       
  3360 
       
  3361 EXPORT_C void* CAknQueryControl::ExtensionInterface( TUid /*aInterface*/ ) 
       
  3362     { 
       
  3363     return NULL;
       
  3364     }
       
  3365     
       
  3366 EXPORT_C void CAknQueryControl::HandleResourceChange(TInt aType)
       
  3367     {
       
  3368     CCoeControl::HandleResourceChange(aType);
       
  3369     
       
  3370     if( aType == KAknsMessageSkinChange && iExtension->iAnimationId )
       
  3371         {
       
  3372         TRAP_IGNORE(SetAnimationL( iExtension->iAnimationId ));
       
  3373         TRAP_IGNORE(StartAnimationL());
       
  3374         }    
       
  3375     else if( aType == KEikDynamicLayoutVariantSwitch )
       
  3376         {
       
  3377         SizeChanged();
       
  3378         TRAP_IGNORE(DoSetPromptL());
       
  3379         }
       
  3380     }    
       
  3381 
       
  3382 // ---------------------------------------------------------------------------
       
  3383 // Return prompt text needed by FEP to query dialog
       
  3384 // ---------------------------------------------------------------------------
       
  3385 //
       
  3386 void CAknQueryControl::GetCaption(TDes& aCaption) const
       
  3387     {
       
  3388     aCaption = KNullDesC;
       
  3389     
       
  3390     TPtr prompt= iPrompt->Text();
       
  3391     if ( prompt != KNullDesC )
       
  3392        {
       
  3393        const TInt maximumLength=aCaption.MaxLength();
       
  3394        
       
  3395        if ( prompt.Length() > maximumLength )
       
  3396           {
       
  3397           aCaption=prompt.Left(maximumLength);
       
  3398           }
       
  3399        else
       
  3400           {
       
  3401           aCaption= prompt;
       
  3402           }
       
  3403        }
       
  3404     }
       
  3405 
       
  3406 
       
  3407 // ---------------------------------------------------------------------------
       
  3408 // Sets the state of ECS number visibility in the query.
       
  3409 // ---------------------------------------------------------------------------
       
  3410 //
       
  3411 void CAknQueryControl::SetEcsCbaVisibleL( TBool aVisible )
       
  3412     {
       
  3413     if ( iExtension &&
       
  3414          !COMPARE_BOOLS( aVisible, iExtension->iEcsCbaShown ) &&
       
  3415          iFlags.IsSet( EEmergencyCallsCBASupport ) )
       
  3416         {
       
  3417         CEikDialog* dlg;
       
  3418         MopGetObject( dlg );
       
  3419         if ( dlg )
       
  3420             {
       
  3421             CEikButtonGroupContainer& cba = dlg->ButtonGroupContainer();
       
  3422             
       
  3423             if ( aVisible 
       
  3424                 && (GetTextLength() == iEcsDetector->CurrentMatch().Length()) )
       
  3425                 // Further check to ensure that the matched number is the
       
  3426                 // entire buffer. Get the matched text and see if is the same
       
  3427                 // length as the current query length.
       
  3428                 {
       
  3429                 HBufC* cbaLabel =
       
  3430                     StringLoader::LoadLC( R_AVKON_SOFTKEY_CALL_TEXT );
       
  3431                 cba.AddCommandToStackL( 0,
       
  3432                                         EAknSoftkeyEmergencyCall,
       
  3433                                         *cbaLabel );
       
  3434                 CleanupStack::PopAndDestroy( cbaLabel );
       
  3435                 iExtension->iEcsCbaShown = ETrue;
       
  3436                 }
       
  3437             else
       
  3438                 {
       
  3439                 if ( iExtension->iEcsCbaShown )
       
  3440                     {
       
  3441                     cba.RemoveCommandFromStack( 0, EAknSoftkeyEmergencyCall );
       
  3442                     iExtension->iEcsCbaShown = EFalse;
       
  3443                     }
       
  3444                 }
       
  3445             }
       
  3446         }
       
  3447     }
       
  3448 
       
  3449 
       
  3450 // ---------------------------------------------------------------------------
       
  3451 // Attempts an emergency call.
       
  3452 // ---------------------------------------------------------------------------
       
  3453 //
       
  3454 void CAknQueryControl::AttemptEmergencyCallL()
       
  3455     {
       
  3456     if ( iEcsDetector )
       
  3457         {
       
  3458         if ( iEcsDetector->State() == CAknEcsDetector::ECompleteMatch )
       
  3459             {
       
  3460             // Further check to ensure that the matched number is the
       
  3461             // entire buffer. Get the matched text and see if is the same
       
  3462             // length as the current query length.
       
  3463             if ( GetTextLength() == iEcsDetector->CurrentMatch().Length() )
       
  3464                 {
       
  3465                 iEcsDetector->AddChar( (TText)EKeyYes );
       
  3466                 SetEcsCbaVisibleL( EFalse );
       
  3467                 
       
  3468                 // stop playing tacticons for pincode query
       
  3469                 StopPinCodeTacticonTimer();
       
  3470                 }
       
  3471             }
       
  3472         }
       
  3473     }
       
  3474 
       
  3475 
       
  3476 /*****************************
       
  3477  * CAknExtQueryControl
       
  3478  *****************************/
       
  3479 
       
  3480 
       
  3481 ///
       
  3482 /// Construction and Destruction methods
       
  3483 ///
       
  3484 
       
  3485 /**
       
  3486  *
       
  3487  */
       
  3488 EXPORT_C CAknExtQueryControl::CAknExtQueryControl()  : CAknQueryControl()
       
  3489     {
       
  3490     AKNTASHOOK_ADD( this, "CAknExtQueryControl" );
       
  3491     }
       
  3492 
       
  3493 /**
       
  3494  *
       
  3495  */
       
  3496 EXPORT_C CAknExtQueryControl::~CAknExtQueryControl()
       
  3497     {
       
  3498     AKNTASHOOK_REMOVE();
       
  3499 	if (iFixedPointEditor)
       
  3500         AknsUtils::DeregisterControlPosition(iFixedPointEditor);
       
  3501 	if (iIpEditor)
       
  3502         AknsUtils::DeregisterControlPosition(iIpEditor);
       
  3503     delete iIpEditor;
       
  3504     delete iFixedPointEditor;
       
  3505     }
       
  3506 
       
  3507 
       
  3508 void CAknExtQueryControl::ConstructQueryL(TResourceReader& aRes)
       
  3509     {   
       
  3510     if ( iQueryType == EIpLayout)   
       
  3511         {
       
  3512         iIpEditor = new(ELeave)CAknIpFieldEditor;
       
  3513         iIpEditor->SetContainerWindowL(*this);
       
  3514         iIpEditor->ConstructFromResourceL(aRes);
       
  3515         iIpEditor->SetObserver(this);
       
  3516         iIpEditor->SetSkinTextColorL(EAknsCIQsnTextColorsCG27);
       
  3517         if ( AknLayoutUtils::PenEnabled() )
       
  3518             {
       
  3519             iIpEditor->SetFeature( CEikMfne::EFingerSupport, CEikMfne::EnableWithAllHighlight );
       
  3520 	        }
       
  3521         }
       
  3522     else if ( iQueryType == EFixedPointLayout)  
       
  3523         {
       
  3524         iFixedPointEditor = new(ELeave)CEikFixedPointEditor;
       
  3525         iFixedPointEditor->SetContainerWindowL(*this);
       
  3526         iFixedPointEditor->ConstructFromResourceL(aRes);
       
  3527         iFixedPointEditor->SetAknEditorAllowedInputModes( EAknEditorNumericInputMode );
       
  3528         iFixedPointEditor->SetObserver(this);
       
  3529         }
       
  3530     else
       
  3531          __ASSERT_DEBUG(0, Panic(EAknPanicLayoutControlResourceProblem));   
       
  3532 
       
  3533     // Construct editor context
       
  3534     CAknQueryExtension* extension = QueryExtension();
       
  3535     if( extension )
       
  3536         {
       
  3537         extension->CreateEditorContextL();
       
  3538         }
       
  3539     }
       
  3540 
       
  3541 
       
  3542 ///
       
  3543 /// CCoeControl methods
       
  3544 ///
       
  3545 
       
  3546 /**
       
  3547  *Returns the control owned by this control by the index
       
  3548  */
       
  3549 CCoeControl* CAknExtQueryControl::ComponentControl(TInt anIndex) const
       
  3550     {
       
  3551     CCoeControl* controls[] = { iPrompt, 
       
  3552                                 iEditIndicator, 
       
  3553                                 iIpEditor,
       
  3554                                 iFixedPointEditor,
       
  3555                                 iImage, iAnimation };
       
  3556     
       
  3557     for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++)
       
  3558         {
       
  3559         //subtle: index is decremented only if control is not NULL!
       
  3560         if (controls[ii] && anIndex-- == 0) 
       
  3561             {
       
  3562             return controls[ii];
       
  3563             }
       
  3564         }
       
  3565     return NULL;
       
  3566     }     
       
  3567 
       
  3568 /**
       
  3569  * Returns the number of controls inside the compound control.
       
  3570  */
       
  3571 TInt CAknExtQueryControl::CountComponentControls() const
       
  3572     {
       
  3573     TInt count = 0;
       
  3574     CCoeControl* controls[] = { iPrompt,
       
  3575                                 iEditIndicator,
       
  3576                                 iIpEditor,
       
  3577                                 iFixedPointEditor,
       
  3578                                 iImage, iAnimation };
       
  3579                                 
       
  3580     for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++)
       
  3581         {
       
  3582         if (controls[ii])
       
  3583             {
       
  3584             count++;
       
  3585             }
       
  3586         }
       
  3587     return count;
       
  3588     }
       
  3589 
       
  3590 
       
  3591 /**
       
  3592  * Handle a focus changed
       
  3593  */
       
  3594 void CAknExtQueryControl::FocusChanged(TDrawNow aDrawNow)
       
  3595     {
       
  3596     CCoeControl* ctrl = ControlByLayoutOrNull( iQueryType );
       
  3597     if (ctrl)
       
  3598         {
       
  3599         ctrl->SetFocus( IsFocused(), aDrawNow );
       
  3600         Layout();
       
  3601         }
       
  3602     }
       
  3603 
       
  3604 void CAknExtQueryControl::PrepareForFocusLossL()
       
  3605     {
       
  3606     CCoeControl* ctrl = ControlByLayoutOrNull( iQueryType );
       
  3607     if (ctrl)
       
  3608         {
       
  3609         ctrl->PrepareForFocusLossL(); 
       
  3610         }
       
  3611     }
       
  3612 
       
  3613 EXPORT_C void CAknExtQueryControl::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType)
       
  3614     {
       
  3615     //CAknQueryControl::HandleControlEventL(NULL, aEventType);
       
  3616     
       
  3617     if(iQueryControlObserver && aEventType == EEventStateChanged)
       
  3618         {                
       
  3619         if(GetTextLength())
       
  3620             {
       
  3621             iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorValueValid);
       
  3622             }
       
  3623         else
       
  3624             {
       
  3625             iQueryControlObserver->HandleQueryEditorStateEventL(this,MAknQueryControlObserver::EQueryControlEditorStateChanging, MAknQueryControlObserver::EEditorEmpty);
       
  3626             }
       
  3627         }
       
  3628     }
       
  3629 
       
  3630 
       
  3631 ///
       
  3632 /// DRAWING METHODS
       
  3633 ///
       
  3634 
       
  3635 /**
       
  3636  * Layout the ip editor and its frame.
       
  3637  * 
       
  3638  * 
       
  3639  * Queries other than confirmation queries have an editor that the user needs
       
  3640  * to input the query data. This method does the layout of the editor. 
       
  3641  *
       
  3642  * Data queries have a resizable editor and its layout is specified in the LAF.
       
  3643  * 
       
  3644  * Other queries have a fixed size editor with layout specified.
       
  3645  *
       
  3646  *
       
  3647  * This method is called from SizeChanged. Depending on the query type, the
       
  3648  * layout method is chosen accordingly, e.g. data queries use the data query
       
  3649  * method, other queires use the code query method.
       
  3650  *
       
  3651  * The macros at the top are just for avoiding code repetition.
       
  3652  */
       
  3653 void CAknExtQueryControl::LayoutEditor(const TLayoutMethod& aLayoutM)
       
  3654     {   
       
  3655     TIndex LAFIndex(NbrOfPromptLines());
       
  3656     
       
  3657     if (aLayoutM == EDataQueryLayoutM)
       
  3658         {
       
  3659         iHasEditor = ETrue;
       
  3660         
       
  3661         LayoutEditorFrame(aLayoutM);        
       
  3662         LayoutEditorIndicator(aLayoutM);
       
  3663 
       
  3664         TInt promptLines = NbrOfPromptLines();
       
  3665         TInt numberTextLines = NbrOfEditorLines();
       
  3666         TInt isNumeric = 0;
       
  3667 
       
  3668         if ( iFixedPointEditor )
       
  3669             {
       
  3670             if ( promptLines >= 3 )
       
  3671                 {
       
  3672                 AknLayoutUtils::LayoutEdwin( iFixedPointEditor,
       
  3673                                              LayoutRect(),
       
  3674                                              AKN_LAYOUT_TEXT_Data_query_pop_up_window_texts_Line_2( LAFIndex.DQPWindowTextsLine2(numberTextLines), isNumeric ),
       
  3675                                              EAknsCIQsnTextColorsCG27 ) ;
       
  3676                 }
       
  3677             else
       
  3678                 {
       
  3679                 if ( promptLines == 2 )
       
  3680                     {
       
  3681                     AknLayoutUtils::LayoutEdwin( iFixedPointEditor,
       
  3682                                                  LayoutRect(),
       
  3683                                                  AKN_LAYOUT_TEXT_Data_query_pop_up_window_texts_Line_2( LAFIndex.DQPWindowTextsLine2(1), isNumeric  ),
       
  3684                                                  EAknsCIQsnTextColorsCG27 );
       
  3685                     }
       
  3686                 else
       
  3687                     {
       
  3688                     AknLayoutUtils::LayoutEdwin( iFixedPointEditor,
       
  3689                                                  LayoutRect(),
       
  3690                                                  AKN_LAYOUT_MULTILINE_TEXT_Data_query_pop_up_window_texts_Line_2( isNumeric, numberTextLines ),
       
  3691                                                  EAknsCIQsnTextColorsCG27 );
       
  3692                     }
       
  3693                 }
       
  3694             iFixedPointEditor->SetBorder(TGulBorder::ENone); 
       
  3695             if (IsFocused() && !(iFixedPointEditor->IsFocused()) ) 
       
  3696                 iFixedPointEditor->SetFocus(ETrue);
       
  3697 
       
  3698             AknsUtils::RegisterControlPosition( iFixedPointEditor );
       
  3699             }
       
  3700         }    
       
  3701     else if (aLayoutM == ETimeQueryLayoutM)
       
  3702         {
       
  3703         iHasEditor = ETrue;
       
  3704 
       
  3705         LayoutEditorFrame(aLayoutM);
       
  3706         
       
  3707         LayoutEditorIndicator(aLayoutM);
       
  3708 
       
  3709 //LAYOUT for IP EDITOR
       
  3710         if(iIpEditor)
       
  3711             {
       
  3712             AknLayoutUtils::LayoutMfne(iIpEditor,LayoutRect(),
       
  3713               AKN_LAYOUT_TEXT_Code_query_pop_up_window_texts_Line_2(LAFIndex.PromptLine()));
       
  3714 
       
  3715             iIpEditor->SetBorder( TGulBorder::ENone ); 
       
  3716             if ( IsFocused() && !iIpEditor->IsFocused() ) 
       
  3717                 iIpEditor->SetFocus(ETrue);
       
  3718             iIpEditor->SetUpAndDownKeysConsumed( ETrue );
       
  3719             }
       
  3720         }
       
  3721     }
       
  3722 
       
  3723 EXPORT_C void CAknExtQueryControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
  3724     { 
       
  3725     if ( iIpEditor && iEditorFrame.Rect().Contains(aPointerEvent.iPosition) )
       
  3726         {
       
  3727         iIpEditor->HandlePointerEventL(aPointerEvent); 
       
  3728         }
       
  3729     else
       
  3730         {
       
  3731         CAknQueryControl::HandlePointerEventL(aPointerEvent);
       
  3732         }
       
  3733     }
       
  3734 
       
  3735 EXPORT_C void* CAknExtQueryControl::ExtensionInterface( TUid /*aInterface*/ ) 
       
  3736     { 
       
  3737     return NULL;
       
  3738     }
       
  3739 
       
  3740 EXPORT_C TInetAddr CAknExtQueryControl::GetInetAddress() const
       
  3741     {   
       
  3742     TInetAddr ret = TInetAddr();
       
  3743     if( iIpEditor )
       
  3744         {
       
  3745         return iIpEditor->Address();
       
  3746         }
       
  3747     return ret; 
       
  3748     }
       
  3749 
       
  3750 
       
  3751 EXPORT_C void CAknExtQueryControl::SetInetAddress(TInetAddr& aInetAddress)
       
  3752     {
       
  3753     if( iIpEditor )
       
  3754         {
       
  3755         iIpEditor->SetAddress(aInetAddress);
       
  3756         }
       
  3757     }
       
  3758 
       
  3759 EXPORT_C TInt CAknExtQueryControl::GetFixedPointNumber() const
       
  3760     {   
       
  3761     TInt ret = 0;
       
  3762     if( iFixedPointEditor )
       
  3763         {
       
  3764         return iFixedPointEditor->Value();
       
  3765         }
       
  3766     return ret; 
       
  3767     }
       
  3768 
       
  3769 
       
  3770 EXPORT_C void CAknExtQueryControl::SetFixedPointNumberL(const TInt* aNumber)
       
  3771     {
       
  3772     if( iFixedPointEditor )
       
  3773         {
       
  3774         iFixedPointEditor->SetValueL(aNumber);
       
  3775         }
       
  3776     }
       
  3777 
       
  3778 
       
  3779 EXPORT_C void CAknExtQueryControl::SetMinimumAndMaximum(const TInetAddr& aMinimumAddress, const TInetAddr& aMaximumAddress)
       
  3780     {
       
  3781     if( iIpEditor )
       
  3782         {
       
  3783         iIpEditor->SetMinimumAndMaximum(aMinimumAddress, aMaximumAddress);
       
  3784         } 
       
  3785     }
       
  3786 
       
  3787 EXPORT_C void CAknExtQueryControl::SetMinimumAndMaximum(TInt aMinimumValue, TInt aMaximumValue)    
       
  3788     {
       
  3789     if( iFixedPointEditor )
       
  3790         {
       
  3791         iFixedPointEditor->SetMinMax(aMinimumValue, aMaximumValue);
       
  3792         }
       
  3793     }
       
  3794 
       
  3795 
       
  3796 /**
       
  3797  * Return text editor depening on query type
       
  3798  */
       
  3799 EXPORT_C CCoeControl* CAknExtQueryControl::ControlByLayoutOrNull(TInt aLayout)
       
  3800     {
       
  3801     CCoeControl* ctrl=NULL;
       
  3802     if ( aLayout == EIpLayout )
       
  3803         {
       
  3804             ctrl = iIpEditor;
       
  3805         }
       
  3806     else if ( aLayout == EFixedPointLayout )
       
  3807         {
       
  3808             ctrl = iFixedPointEditor;
       
  3809         }
       
  3810     return ctrl;
       
  3811     }
       
  3812 
       
  3813 
       
  3814 /**
       
  3815 * This method looks at the flags that have been set in the query control and 
       
  3816 * acts upon them if possible
       
  3817 * 
       
  3818 */
       
  3819 void CAknExtQueryControl::DeployFlagsL()
       
  3820     {       
       
  3821     }
       
  3822 
       
  3823 /**
       
  3824 * Method to first set the flags and then to use them on the contained editors
       
  3825 *
       
  3826 */
       
  3827 
       
  3828 void CAknExtQueryControl::SetAndUseFlagsL(TBitFlags16 /*aFlags*/)
       
  3829     {
       
  3830     }
       
  3831 
       
  3832 void CAknExtQueryControl::SetFlags(TBitFlags16 /*aFlags*/)
       
  3833     {
       
  3834     }
       
  3835 
       
  3836 
       
  3837 /** 
       
  3838  * Return true if editor content is valid for query, false 
       
  3839  * otherwise. Ip editor always have a valid content.
       
  3840  * 
       
  3841  * 
       
  3842  */ 
       
  3843 TBool CAknExtQueryControl::EditorContentIsValidL() const
       
  3844     {
       
  3845     TInt ret = EFalse;
       
  3846     if ( iIpEditor ) 
       
  3847         {
       
  3848         CEikMfne* editor = iIpEditor;
       
  3849         ret = editor->Field(editor->CurrentField())->IsValid();
       
  3850         }
       
  3851     else if ( iFixedPointEditor ) 
       
  3852         {
       
  3853         TInt intValue;
       
  3854         CAknNumericEdwin::TValidationStatus status = iFixedPointEditor->GetValueAsInteger(intValue);
       
  3855         ret = status == CAknNumericEdwin::EValueValid;
       
  3856         }
       
  3857     return ret; 
       
  3858     }
       
  3859 
       
  3860 
       
  3861 /*****************************************************************
       
  3862  * CAknExtQueryControl::TIndex
       
  3863  *
       
  3864  * Manage indexes into LAF tables
       
  3865  *
       
  3866  * PN stands for "Popup Note"
       
  3867  *
       
  3868  * PQD stands for "Popup Query Data'
       
  3869  *
       
  3870  * 'DPQ' stands for "Data Query Popup"
       
  3871  ******************************************************************/
       
  3872 
       
  3873   
       
  3874 CAknExtQueryControl::TIndex::TIndex(TInt aNumberOfPromptLines)
       
  3875     : iNumberOfPromptLines(aNumberOfPromptLines)
       
  3876     {
       
  3877     }
       
  3878         
       
  3879 void CAknExtQueryControl::TIndex::SelfTest() const
       
  3880     {
       
  3881     __ASSERT_DEBUG(iNumberOfPromptLines >= 0  && iNumberOfPromptLines <= 5,
       
  3882         Panic(EAknPanicInvalidValue));
       
  3883     }
       
  3884 
       
  3885 /**
       
  3886  * Return index into LAF tables that depend directly on number of prompt lines,
       
  3887  * index is equal to number of prompt lines minus one unless there are no prompt
       
  3888  * lines in which case the index is zero
       
  3889  */
       
  3890 TInt CAknExtQueryControl::TIndex::PromptLine() const
       
  3891     {
       
  3892     SelfTest();
       
  3893     return iNumberOfPromptLines > 0 ? iNumberOfPromptLines - 1 : 0;
       
  3894     }
       
  3895 
       
  3896 /**
       
  3897  * Return index into Main Pane PQDC Window, which
       
  3898  * depends on total number of prompt lines minus 2, e.g.
       
  3899  * index 0 for 2 prompt lines total.
       
  3900  *
       
  3901  */
       
  3902 TInt CAknExtQueryControl::TIndex::DQPWindowTextsLine2(TInt aLineNum) const
       
  3903     {
       
  3904     SelfTest();
       
  3905     __ASSERT_DEBUG(aLineNum > 0 && aLineNum <= 5,Panic(EAknPanicInvalidValue));
       
  3906 
       
  3907     static const TInt  KDataQueryPopupWindowTextsLine2Index[3][5] = 
       
  3908     {   {0,  1, 2, 3, 4},    //1 PROMPT LINE
       
  3909         {5,  6, 7, 8, 9},    //2 PROMPT LINES
       
  3910         {10, 10, 10, 10, 10}  }; //3 PROMPT LINES
       
  3911     
       
  3912     return KDataQueryPopupWindowTextsLine2Index[PromptLine()][aLineNum-1];
       
  3913     }
       
  3914 
       
  3915 TInt CAknExtQueryControl::TIndex::PNWindow() const
       
  3916     {
       
  3917     __ASSERT_DEBUG(0,Panic(EAknPanicNotSupported)); // We should never be here
       
  3918     return 0;
       
  3919     /*
       
  3920     SelfTest();
       
  3921     static const TInt  KPopupNoteWindowIndex[5] = { 0,0,0,1,2 };
       
  3922     
       
  3923     return KPopupNoteWindowIndex[PromptLine()];
       
  3924     */
       
  3925     }
       
  3926 
       
  3927 TInt CAknExtQueryControl::TIndex::PQDWindow(TInt aLineNum) const
       
  3928     {
       
  3929     (void)aLineNum; // to remove warning
       
  3930     __ASSERT_DEBUG(0,Panic(EAknPanicNotSupported)); // We should never be here
       
  3931     return 0;
       
  3932     /*
       
  3933     SelfTest();
       
  3934     __ASSERT_DEBUG(aLineNum > 0 && aLineNum <= 5,Panic(EAknPanicInvalidValue));
       
  3935 
       
  3936     static const TInt  KPopupQueryDataWindowIndex[3][5] = 
       
  3937     {   {0, 1, 3, 6, 8},   //1 PROMPT LINE
       
  3938         {2, 4, 7, 9, 10},  //2 PROMPT LINES
       
  3939         {5, 6, 8, 10, 11} }; //3 PROMPT LINES
       
  3940     
       
  3941     return KPopupQueryDataWindowIndex[PromptLine()][aLineNum-1];
       
  3942     */
       
  3943     }
       
  3944 
       
  3945 
       
  3946 // Callback for doing a redraw when animating pictographs
       
  3947 TInt CAknExtQueryControl::StaticPictographCallBack( TAny* aPtr )
       
  3948     {
       
  3949     CAknExtQueryControl* me = static_cast<CAknExtQueryControl*>( aPtr );
       
  3950     me->PictographCallBack();
       
  3951     return KErrNone;
       
  3952     }
       
  3953 
       
  3954 void CAknExtQueryControl::PictographCallBack()
       
  3955     {
       
  3956     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  3957     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  3958 
       
  3959     for ( TInt i = 0 ; i < iPrompt->NumberOfLines() ; i++ )
       
  3960         {
       
  3961         CAknPictographInterface* picto = iPrompt->PictographInterface();
       
  3962 
       
  3963         // Only update the note line if it contains pictographs
       
  3964 
       
  3965         if ( picto->Interface()->ContainsPictographs( 
       
  3966             *( iPrompt->Line( i )->Text() ) ) )
       
  3967             {
       
  3968             TRect lineRect = iPrompt->Line(i)->Rect();
       
  3969             Window().Invalidate( lineRect );
       
  3970 
       
  3971             ActivateGc();
       
  3972             Window().BeginRedraw();
       
  3973 
       
  3974             AknsDrawUtils::Background(
       
  3975                 skin,
       
  3976                 cc,
       
  3977                 this,
       
  3978 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
  3979 				SystemGc(),
       
  3980 #else				
       
  3981                 iCoeEnv->SystemGc(),
       
  3982 #endif                
       
  3983                 lineRect );
       
  3984 
       
  3985             Window().EndRedraw();
       
  3986             DeactivateGc();
       
  3987 
       
  3988             // Draw the label after the background.
       
  3989             iPrompt->Line( i )->ActivateL(); // Never leaves
       
  3990             iPrompt->Line( i )->DrawNow();
       
  3991             iPrompt->SetLineModified( i, EFalse );
       
  3992             }
       
  3993         }
       
  3994     }
       
  3995 
       
  3996 // End of File