uifw/EikStd/dlgsrc/EIKDIALG.CPP
changeset 0 2f259fa3e83a
child 3 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1997-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <eikdialg.h>
       
    20 #include <eikon.hrh>
       
    21 #include <eikmover.h>
       
    22 #include <eikcapc.h>
       
    23 #include <eikcapca.h>
       
    24 #include <eikcmbut.h>
       
    25 #include <eikdialg.pan>
       
    26 #include <eikform.pan>
       
    27 #include <barsread.h>
       
    28 #include <eikenv.h>
       
    29 #include <AknDef.h>
       
    30 #include <eikbtpan.h>
       
    31 #include <eikbtgpc.h>
       
    32 #include <eikcore.rsg>
       
    33 #include <eikappui.h>
       
    34 #include <eikdialg.h>
       
    35 #include <eikdpsel.h>
       
    36 #include "EIKDBCOB.H"
       
    37 #include <eiklbbut.h>
       
    38 #include <aknborders.h>
       
    39 #include <avkon.rsg>
       
    40 #include <avkon.hrh>
       
    41 #include <eikdpage.h>
       
    42 #include <eikmop.h>
       
    43 #include <aknenv.h>
       
    44 //<SKIN>
       
    45 #include "eikdialogext.h"
       
    46 #include <AknsListBoxBackgroundControlContext.h>
       
    47 #include <AknsDrawUtils.h>
       
    48 #include <AknUtils.h>
       
    49 #include <AknsUtils.h>
       
    50 #include <aknlayoutscalable_avkon.cdl.h>
       
    51 #include <skinlayout.cdl.h>
       
    52 #include <eikdpobs.h>
       
    53 
       
    54 #include <aknedwindrawingmodifier.h>
       
    55 
       
    56 #include <AknMediatorFacade.h>
       
    57 #include <AknMediatorObserver.h>
       
    58     
       
    59 #include <aknglobalpopupprioritycontroller.h>
       
    60 #include <aknview.h>
       
    61 #include <aknViewAppUi.h>
       
    62 
       
    63 #include <gfxtranseffect/gfxtranseffect.h>
       
    64 #include <akntransitionutils.h>
       
    65 
       
    66 #include <AknTasHook.h> // for testability hooks
       
    67 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
    68 #include <akntranseffect.h>
       
    69 #endif
       
    70 #include <AknQueryDialog.h>
       
    71 #include <aknQueryControl.h>
       
    72 
       
    73 #include "akncbacontentobserver.h"
       
    74 
       
    75 TBool IsBlankScreenDisplayed();
       
    76 
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // Returns ETrue if CBA is embedded to dialog.
       
    80 // @return ETrue if cba is embedded.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 TBool CbaEmbeddedInDialog( const TInt& aFlags )
       
    84     {
       
    85     return AknLayoutUtils::PenEnabled() && 
       
    86         !( aFlags & EEikDialogFlagFillAppClientRect ) &&
       
    87         !( aFlags & EEikDialogFlagFillScreen ) &&
       
    88         !( aFlags & EEikDialogFlagVirtualInput );
       
    89     }
       
    90 
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void InvalidateWindows( CCoeControl* aControl )
       
    96     {
       
    97     if ( aControl )
       
    98         {
       
    99         if ( aControl->OwnsWindow() )
       
   100             {
       
   101             ( (RWindow*) aControl->DrawableWindow() )->ClearRedrawStore();
       
   102             }
       
   103 
       
   104         for ( TInt i = aControl->CountComponentControls() - 1; i >= 0; --i )
       
   105             {
       
   106             InvalidateWindows( aControl->ComponentControl( i ) );
       
   107             }
       
   108         }
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // Finds out if this control belongs to the window group that is in focus.
       
   113 // This information can be used to skip effects when the window group is
       
   114 // not visible.
       
   115 //
       
   116 // @param aThis The control in question.
       
   117 //
       
   118 // @return ETrue if the window group is in focus, otherwise EFalse
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TBool IsFocusedWindowGroup( CEikDialog* aThis )
       
   122     {
       
   123     RWindowTreeNode* node = aThis->DrawableWindow();
       
   124     // this code finds out if this control belongs to window group
       
   125     // that is in focus, there are some rare cases when the latest opened
       
   126     // popup goes behind another one (e.g. system lock query -> power key menu)
       
   127     // we don't want transition in that case
       
   128     RWsSession& wsSession = CEikonEnv::Static()->WsSession();
       
   129 
       
   130     TInt nodeWindowGroupId = node->WindowGroupId();
       
   131     TInt focusedWindowGroupId = wsSession.GetFocusWindowGroup();
       
   132     
       
   133     if ( nodeWindowGroupId == focusedWindowGroupId )
       
   134         {
       
   135         return aThis->IsFocused();
       
   136         }
       
   137 
       
   138     TInt count = wsSession.NumWindowGroups( 0 );
       
   139 
       
   140     // because there is not leave here,so no need to use CleanupStack.
       
   141     CArrayFixFlat<TInt>* wgIds = new CArrayFixFlat<TInt>( count );
       
   142     if ( wgIds )
       
   143         {
       
   144         // Get list of window group ids from WServ
       
   145         wsSession.WindowGroupList( 0, wgIds );
       
   146 
       
   147         // Select the first in the list (which will always be the forground app)
       
   148         // and we assume that there always will be at least one window group with zero priority
       
   149         TInt wgId = (*wgIds)[0];
       
   150 
       
   151         delete wgIds;
       
   152 
       
   153         if ( focusedWindowGroupId == wgId )
       
   154             {
       
   155             return ETrue;
       
   156             }
       
   157         }
       
   158     return EFalse;
       
   159     }
       
   160 
       
   161 GLDEF_C void Panic(TEikDialogPanic aPanic)
       
   162 	{
       
   163 	_LIT(KPanicCat,"EIKON-DIALOG");
       
   164 	User::Panic(KPanicCat,aPanic);
       
   165 	}
       
   166 
       
   167 GLDEF_C void Panic(TEikFormPanic aPanic)
       
   168 	{
       
   169 	_LIT(KPanicCat,"EIKON-FORM");
       
   170 	User::Panic(KPanicCat,aPanic);
       
   171 	}
       
   172 
       
   173 enum
       
   174     { // follow on from values in UIKON.HRH
       
   175     EEikDialogFlagSleeping	=0x20000,
       
   176 	EEikDialogFlagBroughtForward=0x40000,
       
   177 	// EEikDialogFlagNoBackgroundFade = 0x80000 in uikon.hrh,
       
   178 	EEikDialogAttemptFadeWhenVisible=0x100000
       
   179     // 0x20000 is used by uikon.hrh
       
   180     };
       
   181 
       
   182 // AknSecondaryDisplaySupportUtilities
       
   183 #if ((defined(__COVER_DISPLAY) || defined(__VOICE_UI )))   
       
   184 
       
   185 void IssueMediatorCommand(CEikDialog* aDialog)
       
   186     {
       
   187     CAknMediatorFacade* caps = AknMediatorFacade(aDialog);
       
   188     if (caps)
       
   189         {
       
   190         caps->IssueCommand();
       
   191         }
       
   192     }
       
   193 	
       
   194 void CancelMediatorCommand(CEikDialog* aDialog)
       
   195     {
       
   196     CAknMediatorFacade* caps = AknMediatorFacade(aDialog);
       
   197     if (caps)
       
   198         {
       
   199         caps->CancelCommand();
       
   200         }
       
   201     }
       
   202 
       
   203 #else
       
   204 
       
   205 void CancelMediatorCommand(CEikDialog*){}
       
   206 void IssueMediatorCommand(CEikDialog*){}
       
   207 
       
   208 #endif
       
   209 
       
   210 EXPORT_C CEikDialog::CEikDialog()
       
   211     {
       
   212 //	__DECLARE_NAME(_S("CEikDialog"));
       
   213 //	No border in Avkon
       
   214 	iBorder=TGulBorder(TGulBorder::ENone);
       
   215     SetMopParent(iEikonEnv->EikAppUi());
       
   216 #if defined (__DEBUG__)
       
   217 	RDebug::ProfileReset(PROFILE_POINT_EIKON_DIALOG_LOAD,1);
       
   218 	RDebug::ProfileStart(PROFILE_POINT_EIKON_DIALOG_LOAD);
       
   219 #endif
       
   220 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   221     GfxTransEffect::Register(this,KGfxPopupDefaultControlUid);
       
   222 #endif
       
   223     AKNTASHOOK_ADD( this, "CEikDialog" );
       
   224     }
       
   225 
       
   226 EXPORT_C CEikDialog::~CEikDialog()
       
   227     {
       
   228     AKNTASHOOK_REMOVE();
       
   229 
       
   230     EnableContentObserver( EFalse );
       
   231 
       
   232     if ( GfxTransEffect::IsRegistered( this ) )
       
   233         {
       
   234         // ensure that this is not drawn since parts are destroyed
       
   235         MakeVisible( EFalse ); 
       
   236         CAknTransitionUtils::MakeVisibleSubComponents( this,
       
   237                                         CAknTransitionUtils::EForceInvisible );
       
   238         GfxTransEffect::Deregister(this); //Always deregister in destructor.
       
   239         }
       
   240 
       
   241     // remove from stack before deleting members, this way focus changed will behave correctly
       
   242 	if (!(iDialogFlags&EEikDialogFlagModeless))
       
   243 	    iEikonEnv->RemoveFromStack(this);
       
   244 
       
   245 	FadeBehindPopup(EFalse);
       
   246 	if (iDialogFlags&EEikDialogFlagBroughtForward)
       
   247 		iEikonEnv->BringForwards(EFalse);
       
   248 	AknGlobalPopupPriorityController::RemovePopupPriority(*this);
       
   249 	delete iButtonCommandObserver;
       
   250 	delete iTitleBar;
       
   251 	delete iPageSelector;
       
   252 	delete iButtonGroupContainer;
       
   253 	delete iExtension ;
       
   254 	iExtension = NULL;
       
   255 	StopWaitingAsRequired();
       
   256     }
       
   257 
       
   258 void CEikDialog::DynamicConstructL()
       
   259 	{
       
   260     PreLayoutDynInitL();
       
   261 
       
   262     if ( iPageSelector && iPageSelector->IsForm() && Extension() )
       
   263         {
       
   264         Extension()->iPublicFlags.Set( CEikDialogExtension::EFullyConstructed );
       
   265         }
       
   266 
       
   267     EnableContentObserver( ETrue );
       
   268 
       
   269     Layout();
       
   270     PostLayoutDynInitL();
       
   271 	}
       
   272 
       
   273 /**
       
   274  * Prepares the dialog, constructing it from the resource with id aResourceId.
       
   275  *
       
   276  * The dialog is  added to the stack in here to avoid a possible reallocation
       
   277  * of the stack in RunLD,  the purpose is to be able to display note dialogs in OOM
       
   278  * situations.
       
   279  */
       
   280 EXPORT_C void CEikDialog::PrepareLC(TInt aResourceId)
       
   281     {
       
   282     CleanupStack::PushL(this);
       
   283 	BaseConstructL();
       
   284     StaticConstructL(aResourceId);
       
   285 	
       
   286 	if (!(iDialogFlags&EEikDialogFlagModeless))
       
   287 		{
       
   288 		AknGlobalPopupPriorityController::AddPopupToControlStackL(*this,ECoeStackPriorityDialog,ECoeStackFlagRefusesAllKeys);
       
   289 		}
       
   290     }
       
   291 
       
   292 /**
       
   293  * Reads the dialog resources into the dialog, constructing it from the specified resource.
       
   294  * The function is only to help loading dialog resources and 
       
   295  * extracting dialog data.
       
   296  *
       
   297  * Code is same as in PrepareLC() but iEikonEnv->EikAppUi()->AddToStackL() is omitted
       
   298  */
       
   299 EXPORT_C void CEikDialog::ReadResourceLC(TInt aResourceId)
       
   300     {
       
   301     CleanupStack::PushL(this);
       
   302 	BaseConstructL();
       
   303     StaticConstructL(aResourceId);
       
   304     }
       
   305 
       
   306 /**
       
   307  * Prepares and runs the dialog and returns the id of the button used to dismiss
       
   308  * it. The dialog is constructed from the resource with id aResourceId and is destroyed
       
   309  * on exit.
       
   310  */
       
   311 EXPORT_C TInt CEikDialog::ExecuteLD(TInt aResourceId)
       
   312     {
       
   313 	PrepareLC(aResourceId);
       
   314 	return(RunLD());
       
   315     }
       
   316 
       
   317 void CEikDialog::BaseConstructL()
       
   318 	{
       
   319     CreateWindowL();
       
   320 	Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorDialogBackground,*this));
       
   321 	EnableDragEvents();
       
   322 	Window().SetPointerGrab(ETrue);
       
   323     iContext=this;
       
   324     Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorDialogBackground,*this));
       
   325 
       
   326 	iButtonCommandObserver=CEikDialogButtonCommandObserver::NewL(*this);
       
   327     if (!iExtension)
       
   328         {
       
   329 	    iExtension = CEikDialogExtension::NewL( *this ) ;        
       
   330         }
       
   331 	}
       
   332 
       
   333 void CEikDialog::StaticConstructL(TInt aResourceId)
       
   334     {
       
   335     TResourceReader reader;
       
   336     iCoeEnv->CreateResourceReaderLC(reader,aResourceId);
       
   337     ConstructFromResourceL(reader);
       
   338 	CleanupStack::PopAndDestroy();
       
   339 	
       
   340     if ( CAknEnv::Static()->TransparencyEnabled() )
       
   341         {
       
   342         if ( !(iDialogFlags & EEikDialogFlagFillAppClientRect ||
       
   343            iDialogFlags & EEikDialogFlagFillScreen ) )
       
   344             {
       
   345             Window().SetRequiredDisplayMode( EColor16MA );
       
   346             TInt err = Window().SetTransparencyAlphaChannel();
       
   347 
       
   348             if ( err == KErrNone )
       
   349                 {
       
   350                 Window().SetBackgroundColor(~0);
       
   351                 }
       
   352             }
       
   353         }
       
   354     }
       
   355 
       
   356 /**
       
   357  * Constructs a sleeping dialog from the resources identified by aResourceId.
       
   358  * A sleeping dialog is one which can be displayed at any time since its memorey
       
   359  * resources are pre-allocated.
       
   360  */
       
   361 EXPORT_C void CEikDialog::ConstructSleepingDialogL(TInt aResourceId)
       
   362 	{
       
   363 	CommonConstructSleepingDialogL(aResourceId);
       
   364     AknGlobalPopupPriorityController::AddPopupToControlStackL(*this,ECoeStackPriorityDialog,ECoeStackFlagRefusesAllKeys|ECoeStackFlagRefusesFocus|ECoeStackFlagSharable);
       
   365 	}
       
   366 
       
   367 /**
       
   368  * Constructs a sleeping dialog from the resources identified by aResourceId
       
   369  * at a high priority on the control stack.
       
   370  */
       
   371 EXPORT_C void CEikDialog::ConstructSleepingAlertDialogL(TInt aResourceId)
       
   372 	{
       
   373  	CommonConstructSleepingDialogL(aResourceId);
       
   374     AknGlobalPopupPriorityController::AddPopupToControlStackL(*this,ECoeStackPriorityAlert,ECoeStackFlagRefusesAllKeys|ECoeStackFlagRefusesFocus|ECoeStackFlagSharable);
       
   375 	}
       
   376 
       
   377 void CEikDialog::CommonConstructSleepingDialogL(TInt aResourceId)
       
   378 	//
       
   379 	// code common to both ConstructSleepingDialogL & ConstructSleepingAlertDialogL
       
   380 	//
       
   381 	{
       
   382 	iDialogFlags|=EEikDialogFlagSleeping;
       
   383 	BaseConstructL();
       
   384 	StaticConstructL(aResourceId);
       
   385 	MakeVisible(EFalse);
       
   386 	if (iButtonGroupContainer)
       
   387 		{
       
   388 		// non visible CBA's do not recieve keys
       
   389 		iButtonGroupContainer->MakeVisible(EFalse);
       
   390 		}
       
   391 	}
       
   392 
       
   393 TInt CEikDialog::WaitAsRequired()
       
   394     {
       
   395     TInt exitConfirmed=0;
       
   396 #if defined (__DEBUG__)
       
   397 	RDebug::ProfileEnd(PROFILE_POINT_EIKON_DIALOG_LOAD);
       
   398 	TProfile profile;
       
   399 	RDebug::ProfileResult(&profile,PROFILE_POINT_EIKON_DIALOG_LOAD,1);
       
   400 	TBuf<60> tmp;
       
   401 	_LIT(KMsg,"Time to load dialog: %d milliseconds");
       
   402 	tmp.Format(KMsg,profile.iTime/1000);
       
   403 	iEikonEnv->VerboseInfoMsg(tmp);
       
   404 #endif
       
   405 
       
   406     if (iDialogFlags&EEikDialogFlagWait)
       
   407         {
       
   408 		iExitConfirmed=(&exitConfirmed);
       
   409         iWait.Start();
       
   410         }
       
   411 
       
   412 	return(exitConfirmed);
       
   413     }
       
   414 
       
   415 void CEikDialog::StopWaitingAsRequired()
       
   416 	{
       
   417 	CAknEnv::StopSchedulerWaitWithBusyMessage(iWait);
       
   418 	}
       
   419 
       
   420 /**
       
   421  * Rouses a sleeping dialog by dynamically constructing it and then 
       
   422  * bringing it to the front.
       
   423  */
       
   424 EXPORT_C TInt CEikDialog::RouseSleepingDialog()
       
   425 	{ // none of following ...L calls to Leave
       
   426 	if (IsVisible())
       
   427 		ExitSleepingDialog(); // eg for rousing an already roused Alert dialog
       
   428 
       
   429 
       
   430     #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   431     //make sure that "this" is registered
       
   432     if( !GfxTransEffect::IsRegistered( this ) )
       
   433         {
       
   434         if ( iExtension->iRegisteredContext != KNullUid )
       
   435             {
       
   436             GfxTransEffect::Register( this, iExtension->iRegisteredContext );
       
   437             }
       
   438         else
       
   439             {
       
   440             GfxTransEffect::Register( this, KGfxPopupDefaultControlUid );
       
   441             }
       
   442         }
       
   443     #endif
       
   444     //if registered then do not animate bitmaps until after transition is complete
       
   445     if( GfxTransEffect::IsRegistered( this ) ) 
       
   446         {
       
   447         CAknTransitionUtils::SetData(EDontAnimateBitmaps, (TAny*)this);
       
   448         }
       
   449 	ResetLineMinimumSizes();
       
   450 
       
   451 	iEikonEnv->BringForwards(ETrue); // before the call to EnableBackup()
       
   452   	DrawableWindow()->SetOrdinalPosition(0);
       
   453 	if (iButtonGroupContainer && iButtonGroupContainer->Location() == CEikButtonGroupContainer::EExternal)
       
   454 	  	iButtonGroupContainer->ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0);	
       
   455 	AknGlobalPopupPriorityController::ShowPopup(*this, ETrue);
       
   456 	iDialogFlags|=EEikDialogFlagBroughtForward;
       
   457 
       
   458 	TRAPD(err, DynamicConstructL());
       
   459 	if (err)
       
   460         {
       
   461         if( GfxTransEffect::IsRegistered( this ) ) 
       
   462             {
       
   463             CAknTransitionUtils::RemoveData( EDontAnimateBitmaps );
       
   464             }
       
   465         iEikonEnv->HandleError(err); // non mem allocating note shown
       
   466         return KErrNone; // Error handled, no need to show another note, 
       
   467         } //we will not delete dialog as there might be enough memory to show it in next try  
       
   468 
       
   469 	if (~iDialogFlags&EEikDialogFlagNoBackup)
       
   470 		DrawableWindow()->EnableBackup();
       
   471 
       
   472 	FadeBehindPopup(ETrue);
       
   473 
       
   474 	AknGlobalPopupPriorityController::RouseSleepingPopup(*this,ETrue);
       
   475 	if (iCoeEnv->LastEvent().Type()==EEventPointer)
       
   476 		ClaimPointerGrab(ETrue); // send pointer up to any dragged component
       
   477     SetInitialCurrentLine();
       
   478 
       
   479 	TInt slidingMode = ESlidingDisabled;                 
       
   480 
       
   481 	if ( (iExtension->LayoutCategory() == CEikDialogExtension::EPopupLayout) &&
       
   482 	     (slidingMode != ESlidingDisabled) &&
       
   483 	     IsVisible() )
       
   484 	    {
       
   485         SlideDialog();	    
       
   486 	    }
       
   487 
       
   488 	TRAP(err, ActivateL());
       
   489 	if (err)
       
   490 		Panic(EEikDialogLeaveInSleepingDialog);
       
   491 
       
   492     IssueMediatorCommand(this);
       
   493 
       
   494     if( GfxTransEffect::IsRegistered(this) && !IsVisible() &&
       
   495         IsFocusedWindowGroup( this ) && !IsBlankScreenDisplayed() )
       
   496 		{
       
   497         MakeVisible( EFalse );
       
   498         GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort );
       
   499         CAknTransitionUtils::MakeVisibleSubComponents( this,
       
   500                                         CAknTransitionUtils::EForceInvisible );
       
   501 
       
   502 		CAknTransitionUtils::SetAllParents(this);
       
   503         InvalidateWindows( this );
       
   504 		GfxTransEffect::Begin(this, KGfxControlAppearAction);
       
   505 		GfxTransEffect::NotifyExternalState(ECaptureComponentsBegin, (const TDesC8*)this);
       
   506 		
       
   507 		TRect demarcation;
       
   508 		CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup, 
       
   509 		                                    demarcation);
       
   510 		GfxTransEffect::SetDemarcation(this, demarcation);
       
   511 
       
   512         MakeVisible(ETrue);
       
   513         CAknTransitionUtils::MakeVisibleSubComponents( this,
       
   514                                         CAknTransitionUtils::EForceVisible );
       
   515 
       
   516 		GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)this);
       
   517 		GfxTransEffect::End(this);
       
   518 		}
       
   519 	else
       
   520 		{
       
   521 		MakeVisible(ETrue);
       
   522 		}
       
   523 		
       
   524 	if( GfxTransEffect::IsRegistered(this) )
       
   525 		{
       
   526 		CAknTransitionUtils::RemoveData(EDontAnimateBitmaps); 
       
   527 		} 
       
   528 		
       
   529 	if (iButtonGroupContainer)
       
   530 		{
       
   531 		if (iButtonGroupContainer->Location() == CEikButtonGroupContainer::EExternal)
       
   532 			{
       
   533 			// Bring CBA to foreground and make visible
       
   534 			// CBA used to be set to high control stack priority here,
       
   535 			// but that resulted in bugs whereby a sleeping dialog which was behind another dialog
       
   536 			// always had a higher CBA - just make sure they have the highest cba priority
       
   537 			CCoeControl* cba = iButtonGroupContainer->ButtonGroup()->AsControl();
       
   538 			AknGlobalPopupPriorityController::AddPopupToControlStackL(*cba,ECoeStackPriorityCba,ECoeStackFlagRefusesFocus);
       
   539 			static_cast<CEikCba*>(cba)->SetSkinBackgroundId( KAknsIIDQsnBgAreaControlPopup );
       
   540 			cba->MakeVisible(ETrue);
       
   541 			cba->DrawNow();
       
   542 			}
       
   543 		}
       
   544 
       
   545     return(WaitAsRequired());
       
   546 	}
       
   547 
       
   548 /**
       
   549  * Exits a sleeping dialog without deleteing it.
       
   550  */
       
   551 EXPORT_C void CEikDialog::ExitSleepingDialog()
       
   552 	{
       
   553 	FadeBehindPopup(EFalse);
       
   554 
       
   555     EnableContentObserver( EFalse );
       
   556 
       
   557 	if(GfxTransEffect::IsRegistered(this) && IsVisible() 
       
   558 
       
   559 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS	
       
   560 	&& !iExtension->iSleepDialogExitBeginCalled
       
   561 #endif
       
   562         && IsFocusedWindowGroup( this )
       
   563         && !IsBlankScreenDisplayed()
       
   564 	)
       
   565 		{
       
   566 		CAknTransitionUtils::SetAllParents(this);
       
   567 		GfxTransEffect::Begin(this, KGfxControlDisappearAction);
       
   568 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   569 		iExtension->iSleepDialogExitBeginCalled = ETrue;
       
   570 #endif
       
   571 		GfxTransEffect::NotifyExternalState(ECaptureComponentsBegin, (const TDesC8*)this);
       
   572 		
       
   573 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   574         TUid t;
       
   575         GfxTransEffect::NotifyExternalState(EGetRegistrationType, (const TDesC8*)&t);
       
   576         iExtension->iRegisteredContext = t;
       
   577 #endif
       
   578 
       
   579 		TRect demarcation;
       
   580 		CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup, 
       
   581 		                                    demarcation);
       
   582 		GfxTransEffect::SetDemarcation(this, demarcation);
       
   583 		
       
   584 		MakeVisible(EFalse);
       
   585         CAknTransitionUtils::MakeVisibleSubComponents( this,
       
   586                                         CAknTransitionUtils::EForceInvisible );
       
   587 
       
   588 		GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)this);
       
   589 		GfxTransEffect::End(this);
       
   590 		}
       
   591 	else
       
   592 		{
       
   593 		MakeVisible(EFalse);
       
   594 		}
       
   595 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   596 	GfxTransEffect::Deregister( this );
       
   597 #endif
       
   598 
       
   599 	if (iButtonGroupContainer)
       
   600 		{
       
   601 		iButtonGroupContainer->MakeVisible(EFalse);
       
   602 		}
       
   603 	AknGlobalPopupPriorityController::RouseSleepingPopup(*this,EFalse);
       
   604 	if (iDialogFlags&EEikDialogFlagBroughtForward)
       
   605 		{
       
   606 		iEikonEnv->BringForwards(EFalse);
       
   607 		AknGlobalPopupPriorityController::ShowPopup(*this, EFalse);
       
   608 		iDialogFlags&=(~EEikDialogFlagBroughtForward);
       
   609 		}
       
   610     StopWaitingAsRequired();
       
   611 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS   
       
   612     if( iExtension )
       
   613         {   
       
   614 	    iExtension->iSleepDialogExitBeginCalled = EFalse;
       
   615 	    }
       
   616 #endif
       
   617     CancelMediatorCommand(this);	
       
   618 	}
       
   619 
       
   620 /**
       
   621  * Returns the id of the control in the line with focus.
       
   622  */
       
   623 EXPORT_C TInt CEikDialog::IdOfFocusControl() const
       
   624 	{
       
   625 	return iPageSelector->FocusedLineId();
       
   626 	}
       
   627 
       
   628 /**
       
   629  * Recalculates the minimum sizes of the lines on the active page.
       
   630  */
       
   631 EXPORT_C void CEikDialog::ResetLineMinimumSizes()
       
   632 	{
       
   633 	iPageSelector->ResetLineMinimumSizes(); // !! what about MP dialogs?
       
   634 	}
       
   635 
       
   636 /**
       
   637  * Constructs the dialog from resources using the resource reader aReader.
       
   638  */
       
   639 EXPORT_C void CEikDialog::ConstructFromResourceL(TResourceReader& aReader)
       
   640     {
       
   641     iDialogFlags |=aReader.ReadInt32();
       
   642             
       
   643 #ifdef RD_SCALABLE_UI_V2            
       
   644     if ( AknLayoutUtils::PenEnabled() )
       
   645     {
       
   646     	if ( iDialogFlags & EEikDialogFlagVirtualInput )
       
   647 	    	{
       
   648 	    	Extension()->iPublicFlags.Set( CEikDialogExtension::EUseVirtualInput );
       
   649 	    	}
       
   650     }
       
   651 #endif
       
   652 
       
   653 	CreateTitleBarL();
       
   654 	iTitleBar->ConstructFromResourceL(aReader);
       
   655 	TInt PageSelectorResourceId=aReader.ReadInt32();
       
   656 	TInt ButtonGroupContainerResourceId=aReader.ReadInt32();
       
   657 	CreateButtonGroupContainerL(ButtonGroupContainerResourceId);
       
   658 	CreatePageSelectorL(PageSelectorResourceId);
       
   659 	if (!iPageSelector)
       
   660 		{
       
   661 		CreatePageSelectorL();
       
   662 		iPageSelector->AddPageL(0,KNullDesC,aReader);
       
   663 		if (iDialogFlags&EEikDialogFlagDensePacking)
       
   664 			iPageSelector->SetAllPagesDensePacked(ETrue);
       
   665 		}
       
   666 	else
       
   667 		ASSERT(aReader.ReadInt16()==0);
       
   668 	
       
   669 	SetBorderStyle();  // Moved to the end of construction to allow access to individual lines.
       
   670 	}
       
   671 
       
   672 void CEikDialog::SetBorderStyle()
       
   673 	{
       
   674 	if (!((iDialogFlags&EEikDialogFlagFillAppClientRect) || 
       
   675 		  (iDialogFlags&EEikDialogFlagFillScreen) ))
       
   676 		{
       
   677 		// One additional check...   (if NoBorder requested then no action to default to no border (see constructor))
       
   678 		if ( !( iDialogFlags & EEikDialogFlagNoBorder ) )
       
   679 			iBorder=TGulBorder(BorderStyle()); // AKNLAF TGulBorder::EThickDeepRaisedWithOutline
       
   680 		// SERIES60 specific request:  If no border and no shadow then position the controls without spacing.
       
   681 		if ( (iDialogFlags & EEikDialogFlagNoBorder) && (iDialogFlags & EEikDialogFlagNoShadow) )
       
   682 			{
       
   683 			}
       
   684 		}
       
   685 	}
       
   686 
       
   687 void CEikDialog::CreatePageSelectorL()
       
   688 	{
       
   689 	iPageSelector=CEikDialogPageSelector::NewL(*this,this);
       
   690 	iPageSelector->SetObserver(this);
       
   691 	RegisterDialgWithPageSelector(); // Added JIn
       
   692 	}
       
   693 
       
   694 void CEikDialog::CreatePageSelectorL(TInt aResourceId)
       
   695 	{
       
   696 	if (aResourceId)
       
   697 		{
       
   698 		TResourceReader reader;
       
   699 		iCoeEnv->CreateResourceReaderLC(reader,aResourceId);
       
   700 		iPageSelector=CEikDialogPageSelector::NewL(*this,reader,this);
       
   701 		iPageSelector->SetObserver(this);
       
   702 		CleanupStack::PopAndDestroy();
       
   703 		if (iDialogFlags&EEikDialogFlagDensePacking)
       
   704 			iPageSelector->SetAllPagesDensePacked(ETrue);
       
   705 		RegisterDialgWithPageSelector(); // Added JIn
       
   706 		}
       
   707 	}
       
   708 
       
   709 void CEikDialog::CreateButtonGroupContainerL(TInt aResourceId)
       
   710 	{
       
   711 	// Avkon simplification: Always use CBA; always set buttons 
       
   712     // Flags:      
       
   713     // buttons are keen on drawing even if not actually visible yet,
       
   714 	// don't activate them in case of sleeping dialog 
       
   715     // yet so extra drawings are suppressed until dialog is really
       
   716 	// roused to screen
       
   717     
       
   718     TUint flags = ( iDialogFlags & EEikDialogFlagSleeping ) ?
       
   719                     ( CEikButtonGroupContainer::EAddToStack |
       
   720                     CEikButtonGroupContainer::EDelayActivation ) :
       
   721                     CEikButtonGroupContainer::EAddToStack;
       
   722     
       
   723     // Softkeys are embedded if dialog doesn't fill application client
       
   724     // rect/whole screen and dialog is not Query Input.
       
   725     // Shortly: softkeys are embedded only to "normal" dialogs
       
   726     TBool isEmbedded = CbaEmbeddedInDialog( iDialogFlags );
       
   727     if ( isEmbedded )
       
   728         {
       
   729         flags |= CEikButtonGroupContainer::EIsEmbedded;
       
   730         flags |= CEikButtonGroupContainer::EDelayActivation;
       
   731         }
       
   732         
       
   733     iButtonGroupContainer = CEikButtonGroupContainer::NewL(
       
   734             CEikButtonGroupContainer::ECba,
       
   735             CEikButtonGroupContainer::EHorizontal,
       
   736             iButtonCommandObserver, aResourceId, *this, flags );
       
   737 
       
   738     EnableContentObserver( ETrue );
       
   739 	
       
   740 	AknGlobalPopupPriorityController::AddSubPopupL(*this, *iButtonGroupContainer->ButtonGroup()->AsControl());
       
   741 	AknGlobalPopupPriorityController::AddPopupToControlStackL(*iButtonGroupContainer->ButtonGroup()->AsControl(), ECoeStackPriorityCba, ECoeStackFlagRefusesFocus);
       
   742 	}
       
   743 
       
   744 void CEikDialog::CreateTitleBarL()
       
   745 	{
       
   746 	iTitleBar=new(ELeave) CEikMover;
       
   747 	iTitleBar->SetContainerWindowL(*this);
       
   748     }
       
   749 
       
   750 /**
       
   751  * Initializes the dialog's controls before the dialog is sized and layed out. Empty by default.
       
   752  */
       
   753 EXPORT_C void CEikDialog::PreLayoutDynInitL()
       
   754     {
       
   755     }
       
   756 
       
   757 /**
       
   758  * Initializes the dialog's controls after the dialog has been sized but before it has been activated.
       
   759  * Empty by default.
       
   760  */
       
   761 EXPORT_C void CEikDialog::PostLayoutDynInitL()
       
   762     {
       
   763     }
       
   764 
       
   765 /**
       
   766  * Sets the size and position of the dialog given the size hint aSize.
       
   767  *
       
   768  * The parameter is ignored if the FlagFillAppClientRect is set.
       
   769  * Otherwise it it centred and given the size asked for
       
   770  */
       
   771 EXPORT_C void CEikDialog::SetSizeAndPosition(const TSize& aSize)
       
   772     {
       
   773 	if (iDialogFlags&EEikDialogFlagFillAppClientRect)
       
   774 	    {
       
   775         // if this is a view app then ask client rect from the currently active view
       
   776         TVwsViewId uid;    
       
   777         if ( iAvkonAppUi->GetActiveViewId( uid ) == KErrNone )
       
   778             {
       
   779             if ( uid.iAppUid != uid.iViewUid )
       
   780                 {
       
   781                 CAknView* view = iAvkonViewAppUi->View(uid.iViewUid);
       
   782                 if (view)
       
   783                     {
       
   784                     SetRect(view->ClientRect());
       
   785                     }
       
   786                 else
       
   787                     {
       
   788                     SetRect(iEikonEnv->EikAppUi()->ClientRect());
       
   789                     }
       
   790                 }
       
   791             else
       
   792                 {
       
   793                 SetRect(iEikonEnv->EikAppUi()->ClientRect());
       
   794                 }
       
   795             }
       
   796          else
       
   797             {
       
   798             SetRect( iEikonEnv->EikAppUi()->ClientRect() );
       
   799             }
       
   800 	    }
       
   801 	else
       
   802         {
       
   803         SetRect( TRect( AknPopupUtils::Position( aSize, this ), aSize ) );
       
   804         }
       
   805     }
       
   806 
       
   807 /**
       
   808  * Returns the border style for this dialog.
       
   809  */
       
   810 EXPORT_C TInt CEikDialog::BorderStyle()
       
   811 	{
       
   812 #ifndef RD_NO_DIALOG_BORDERS
       
   813 	return AknBorderId::EAknBorderNotePopup;
       
   814 #else
       
   815     return TGulBorder::ENone;
       
   816 #endif
       
   817 	}
       
   818 
       
   819 /**
       
   820  * Returns the minimum size of the area that the contents of the dialog should occupy.
       
   821  */
       
   822 EXPORT_C TSize CEikDialog::MinimumSize()
       
   823     {
       
   824 	if (iDialogFlags&EEikDialogFlagFillScreen)
       
   825         {
       
   826         TAknWindowLineLayout windowLineLayoutScreen = AknLayoutScalable_Avkon::Screen().LayoutLine();
       
   827         TRect rectZero = TRect(0,0,0,0);
       
   828         TAknLayoutRect layoutRect;
       
   829         layoutRect.LayoutRect( rectZero, windowLineLayoutScreen );
       
   830         TRect rectScreen( layoutRect.Rect() );
       
   831 
       
   832 		return rectScreen.Size();
       
   833         }
       
   834 	else if (iDialogFlags&EEikDialogFlagFillAppClientRect)
       
   835         {
       
   836         // if this is a view app then ask client rect from the currently active view
       
   837         TVwsViewId uid;    
       
   838         if ( iAvkonAppUi->GetActiveViewId( uid ) == KErrNone )
       
   839             {
       
   840             if ( uid.iAppUid != uid.iViewUid )
       
   841                 {
       
   842                 CAknView* view = iAvkonViewAppUi->View(uid.iViewUid);
       
   843                 if (view)
       
   844                     {
       
   845                     SetRect(view->ClientRect());
       
   846                     }
       
   847                 else
       
   848                     {
       
   849                     SetRect(iEikonEnv->EikAppUi()->ClientRect());
       
   850                     }
       
   851                 }
       
   852             else
       
   853                 {
       
   854                 SetRect(iEikonEnv->EikAppUi()->ClientRect());
       
   855                 }
       
   856             }
       
   857         else
       
   858             {
       
   859             SetRect( iEikonEnv->EikAppUi()->ClientRect() );
       
   860             }
       
   861         }
       
   862 
       
   863 	TSize pageSelectorSize(iPageSelector->MinimumSize());
       
   864 
       
   865 	return pageSelectorSize;
       
   866     }
       
   867 
       
   868 /**
       
   869  * Returns the preferred size of the dialog given that it must fit in a maximum size of aMaxSize.
       
   870  * 
       
   871  * @since ER5U
       
   872  */
       
   873 EXPORT_C TSize CEikDialog::PreferredSize(const TSize& aMaxSize) const
       
   874 	{
       
   875 	if (iDialogFlags&EEikDialogFlagFillScreen)
       
   876 		return iEikonEnv->ScreenDevice()->SizeInPixels();
       
   877 	else if (iDialogFlags&EEikDialogFlagFillAppClientRect)
       
   878 	
       
   879 	    {
       
   880         // if this is a view app then ask client rect from the currently active view
       
   881         TVwsViewId uid;    
       
   882         if ( iAvkonAppUi->GetActiveViewId( uid ) == KErrNone )
       
   883             {
       
   884             if ( uid.iAppUid != uid.iViewUid )
       
   885                 {
       
   886                 CAknView* view = iAvkonViewAppUi->View(uid.iViewUid);
       
   887                 if (view)
       
   888                     {
       
   889                     return view->ClientRect().Size();
       
   890                     }
       
   891                 else
       
   892                     {
       
   893                     return iEikonEnv->EikAppUi()->ClientRect().Size();
       
   894                     }
       
   895                 }
       
   896             else
       
   897                 {
       
   898                 return iEikonEnv->EikAppUi()->ClientRect().Size();
       
   899                 }
       
   900             }
       
   901         else
       
   902             {
       
   903             return iEikonEnv->EikAppUi()->ClientRect().Size();
       
   904             }
       
   905 	    }
       
   906 		
       
   907 
       
   908 	// Calculate max size available to page selector, taking into account the border.
       
   909 	TSize maxSize(aMaxSize);
       
   910 
       
   911 	// Take off border
       
   912 	maxSize-=iBorder.SizeDelta();
       
   913 
       
   914 	const TSize pageSelectorSize(iPageSelector->PreferredSize(maxSize));
       
   915 
       
   916 	TSize preferredSize(0,0);
       
   917 	// Don't allow pageSelector to expand width
       
   918 	preferredSize.iWidth=Min(pageSelectorSize.iWidth,maxSize.iWidth);
       
   919 	// Take its height
       
   920 	preferredSize.iHeight=pageSelectorSize.iHeight;
       
   921 
       
   922 	// Add border back on
       
   923 	preferredSize+=iBorder.SizeDelta();
       
   924 	
       
   925     if ( CbaEmbeddedInDialog( iDialogFlags) )
       
   926         {
       
   927         // If dialog doesn't fill application client rect/whole screen,
       
   928         // dialog is not Query Input and soft keys have some text,
       
   929         // preferred dialog size is extended so that softkey buttons
       
   930         // can be added on bottom of the dialog rect
       
   931         
       
   932         // Preferred size is passed to all dialogs in call to function
       
   933         // SetSizeAndPosition( const TSize& aSize ).
       
   934         // It should be used in all derived dialogs. 
       
   935         
       
   936         CEikCba* cba = static_cast<CEikCba*>(
       
   937                 iButtonGroupContainer->ButtonGroup() );
       
   938         
       
   939         if ( cba->IsVisible() && !cba->IsEmpty() )
       
   940             {
       
   941             TRect screen;
       
   942                 AknLayoutUtils::LayoutMetricsRect( 
       
   943                     AknLayoutUtils::EScreen, screen );
       
   944         
       
   945             TAknLayoutRect cbaRect;
       
   946                 cbaRect.LayoutRect( screen, 
       
   947                 AknLayoutScalable_Avkon::popup_sk_window( 0 ).LayoutLine() );
       
   948             
       
   949             preferredSize += TSize( 0, cbaRect.Rect().Height() );
       
   950             }
       
   951         }
       
   952         
       
   953 	return preferredSize;
       
   954 	}
       
   955 
       
   956 /**
       
   957  * Lays out the dialog's components when the size of the dialog is changed.
       
   958  * Position of DpSel is always at (0,0) relative to dialog.
       
   959  * For Avkon, the DPSEL always stays the same size as the CEikDialog minus an optional title 
       
   960  * bar. 
       
   961  */
       
   962 EXPORT_C void CEikDialog::SizeChanged()
       
   963     {
       
   964 	__ASSERT_DEBUG( iButtonGroupContainer->Location() == CEikButtonGroupContainer::EExternal, 
       
   965 		Panic( EEikDialogPanicIllegalOption ) );
       
   966 
       
   967 	TInt excludeCbaHeight = -1;
       
   968 
       
   969 	if (iButtonGroupContainer)
       
   970         {
       
   971         TAknWindowLineLayout windowLineLayoutScreen = AknLayoutScalable_Avkon::Screen().LayoutLine();
       
   972         TRect rectZero = TRect(0,0,0,0);
       
   973         TAknLayoutRect layoutRect;
       
   974         layoutRect.LayoutRect( rectZero, windowLineLayoutScreen );
       
   975         TRect rectScreen( layoutRect.Rect() );
       
   976 
       
   977         iButtonGroupContainer->SetBoundingRect(rectScreen);
       
   978 
       
   979 		if ( iExtension && iExtension->LayoutCategory() == CEikDialogExtension::EPopupLayout )
       
   980 			{
       
   981 			CCoeControl* cba = iButtonGroupContainer->ButtonGroup()->AsControl();
       
   982 			static_cast<CEikCba*>(cba)->SetSkinBackgroundId( KAknsIIDQsnBgAreaControlPopup );
       
   983 			}
       
   984 
       
   985         if ( CbaEmbeddedInDialog( iDialogFlags ) )
       
   986             {
       
   987             CEikCba* cba = static_cast<CEikCba*>(
       
   988                     iButtonGroupContainer->ButtonGroup() );
       
   989             
       
   990             // If dialog doesn't fill application client rect/whole screen,
       
   991             // dialog is not Query Input and soft keys have some text,
       
   992             // softkeys are located on bottom of the dialog rect
       
   993       
       
   994             if ( cba->IsVisible() && !cba->IsEmpty() )
       
   995                 {
       
   996                 TRect screen;
       
   997                     AknLayoutUtils::LayoutMetricsRect( 
       
   998                         AknLayoutUtils::EScreen, screen );
       
   999         
       
  1000                 TAknLayoutRect cbaRect;
       
  1001                     cbaRect.LayoutRect( screen, 
       
  1002                     AknLayoutScalable_Avkon::popup_sk_window( 
       
  1003                         0 ).LayoutLine() );
       
  1004                 
       
  1005                 TRect rect( Rect() );
       
  1006                 cba->SetRect( TRect(
       
  1007                     rect.iTl.iX ,
       
  1008                     rect.iBr.iY  - cbaRect.Rect().Height(),
       
  1009                     rect.iBr.iX ,
       
  1010                     rect.iBr.iY ) );
       
  1011 
       
  1012                 excludeCbaHeight = cbaRect.Rect().Height();
       
  1013                 }
       
  1014             else
       
  1015                 {
       
  1016                 // Otherway softkeys are located out of dialog rect
       
  1017                 cba->SetRect( TRect(0, 0, 0, 0 ) );
       
  1018                 }
       
  1019             }
       
  1020 		}
       
  1021 	if (iTitleBar)
       
  1022 		{
       
  1023 		TRect nullRect(0,0,0,0);
       
  1024 		iTitleBar->SetRect( nullRect );
       
  1025 		}
       
  1026 
       
  1027     // This calculation left in even though border should be ENone
       
  1028 	TRect rect ( iBorder.InnerRect( Rect() ) );
       
  1029 
       
  1030 	if ( excludeCbaHeight != -1 )
       
  1031 	    {
       
  1032 	    rect.iBr.iY = Min( rect.iBr.iY, Rect().iBr.iY - excludeCbaHeight );
       
  1033 	    }
       
  1034 
       
  1035 	TInt activePageNum = ActivePageId();
       
  1036 	CEikDialogPage* currentPage = NULL ;
       
  1037 	if ( activePageNum >= 0 ) 
       
  1038 		{ // prevent unnecessary resizing of form components
       
  1039 		currentPage = iPageSelector->PageContainer()->Page( activePageNum ) ;
       
  1040 		currentPage->SetFormFlag( CEikDialogPage::EFormResizeOptimisationFlag, ETrue ) ;
       
  1041 		}
       
  1042 	iPageSelector->SetRect(rect);
       
  1043 
       
  1044 	if ( activePageNum >= 0 ) // disable optimisation flag
       
  1045 		currentPage->SetFormFlag( CEikDialogPage::EFormResizeOptimisationFlag,  EFalse ) ;
       
  1046 
       
  1047 	// <SKIN>
       
  1048 	iExtension->iBgContext->SetParentPos( PositionRelativeToScreen() ) ;
       
  1049 	iExtension->iBgContext->SetRect( Rect() ) ;
       
  1050 	}
       
  1051 
       
  1052 /**
       
  1053  * Sets the title text for the dialog to aText.
       
  1054  */
       
  1055 EXPORT_C void CEikDialog::SetTitleL(const TDesC& aText )
       
  1056     {
       
  1057 	iTitleBar->SetTextL(aText);
       
  1058     }
       
  1059 
       
  1060 /**
       
  1061  * Sets the title text for the dialog by reading it from the resource with id aResourceId.
       
  1062  */
       
  1063 EXPORT_C void CEikDialog::SetTitleL(TInt aResourceId )
       
  1064     {
       
  1065 	HBufC* tmpBuf=iCoeEnv->AllocReadResourceLC(aResourceId);
       
  1066 	SetTitleL(tmpBuf->Des());
       
  1067 	CleanupStack::PopAndDestroy(); // tmpBuf
       
  1068     }
       
  1069 
       
  1070 /**
       
  1071  * Dims and inactivates the dialog line containing the control identified by aControlId if
       
  1072  * aDimmed is ETrue. Does not cause a redraw.
       
  1073  */
       
  1074 EXPORT_C void CEikDialog::SetLineDimmedNow(TInt aControlId,TBool aDimmed)
       
  1075     {
       
  1076     CEikCaptionedControl* line=Line(aControlId);
       
  1077 	CCoeControl* control=line->iControl;
       
  1078 	if (control->IsDimmed()==aDimmed)
       
  1079 		return;
       
  1080 	control->SetDimmed(aDimmed);
       
  1081     line->CheckDimmedDisplayState();
       
  1082     control->DrawNow();
       
  1083     }
       
  1084 
       
  1085 /**
       
  1086  * Sets the dialog line containing the control identified by aControlId to a non-focusing state
       
  1087  * so that it will never be given keyboard focus.
       
  1088  */
       
  1089 EXPORT_C void CEikDialog::SetLineNonFocusing(TInt aControlId)
       
  1090 	{
       
  1091     CEikCaptionedControl* line=Line(aControlId);
       
  1092 	line->SetNonFocusing();
       
  1093 	line->iControl->SetNonFocusing();
       
  1094 	}
       
  1095 
       
  1096 /**
       
  1097  * Makes the dialog line containing the control identified by aControlId visible, i.e. sets it
       
  1098  * to draw itself, if aVisible is ETrue.
       
  1099  */
       
  1100 EXPORT_C void CEikDialog::MakeLineVisible(TInt aControlId,TBool aVisible)
       
  1101     {
       
  1102     CEikCaptionedControl* line=Line(aControlId);
       
  1103 	CCoeControl* control=line->iControl;
       
  1104 	if (control->IsVisible()==aVisible)
       
  1105 		return;
       
  1106     control->MakeVisible(aVisible);
       
  1107     line->CheckDimmedDisplayState();
       
  1108     }
       
  1109 
       
  1110 /**
       
  1111  * Makes the whole dialog line containing the control identified by aControlId visible, i.e. sets it
       
  1112  * to draw itself, if aVisible is ETrue.
       
  1113  */
       
  1114 EXPORT_C void CEikDialog::MakeWholeLineVisible(TInt aControlId,TBool aVisible)
       
  1115     {
       
  1116     CEikCaptionedControl* line=Line(aControlId);
       
  1117 	if (line->IsVisible()==aVisible)
       
  1118 		return;
       
  1119 	CCoeControl* control=line->iControl;
       
  1120     if (line->iCaption)
       
  1121 		line->iCaption->MakeVisible(aVisible);
       
  1122 	if (line->iTrailer)
       
  1123 		line->iTrailer->MakeVisible(aVisible);
       
  1124     control->MakeVisible(aVisible);
       
  1125 	line->MakeVisible(aVisible);
       
  1126     }
       
  1127 
       
  1128 /**
       
  1129  * Lays out the dialog, setting it to take its preferred size and position
       
  1130  * for the screen.
       
  1131  *
       
  1132  * TODO (RSD) I have noticed this routine and I suspect that it is responsible for one of
       
  1133  * the sizechanged cascades in Form.  This should use best current information to layout
       
  1134  * the dialog, but I have not investigated too much
       
  1135  * 
       
  1136  * @since ER5U
       
  1137  */
       
  1138 EXPORT_C void CEikDialog::Layout()
       
  1139 	{
       
  1140     TAknWindowLineLayout windowLineLayoutScreen = AknLayoutScalable_Avkon::Screen().LayoutLine();
       
  1141     TRect rectZero = TRect(0,0,0,0);
       
  1142     TAknLayoutRect layoutRect;
       
  1143     layoutRect.LayoutRect( rectZero, windowLineLayoutScreen );
       
  1144     TRect rectScreen( layoutRect.Rect() );
       
  1145 
       
  1146 	TSize maxSize = rectScreen.Size();
       
  1147 
       
  1148 	SetSizeAndPosition(PreferredSize( maxSize ));
       
  1149 	}
       
  1150 
       
  1151 /**
       
  1152  * Deletes the dialog line with the control identified by aControlId.
       
  1153  */
       
  1154 EXPORT_C void CEikDialog::DeleteLine(TInt aControlId, TBool aRedraw)
       
  1155 	{
       
  1156 	iPageSelector->DeleteLine(aControlId, aRedraw);
       
  1157 	}
       
  1158 
       
  1159 /**
       
  1160  * Inserts a line in the dialog on the page identified by aPageId at the line index aIndex
       
  1161  * and constructed from the resource specified by aResourceId.
       
  1162  */
       
  1163 EXPORT_C void CEikDialog::InsertLineL(TInt aIndex,TInt aResourceId,TInt aPageId)
       
  1164 	{
       
  1165 	iPageSelector->InsertLineL(aIndex,aPageId,aResourceId);
       
  1166 	}
       
  1167 
       
  1168 /**
       
  1169  * Sets the page identified by aPageId to be densely packed if aDensePacking is ETrue.
       
  1170  * The spacing between the dialog's lines is then reduced.
       
  1171  * TODO (RSD) This seems to be rather un-avkonlike.  Perhaps should be stubbed out.
       
  1172  */
       
  1173 EXPORT_C void CEikDialog::SetPageDensePacking(TInt aPageId,TBool aDensePacking)
       
  1174 	{
       
  1175 	iPageSelector->SetPageDensePacked(aPageId,aDensePacking);
       
  1176 	}
       
  1177 
       
  1178 /**
       
  1179  * Dynamically constructs a dialog with flags aFlags, buttons constructed from
       
  1180  * the resource aButtonsId, and with a single activated empty page with id 0. The
       
  1181  * dialog is therefore ready to dynamically add lines to.
       
  1182  */
       
  1183 EXPORT_C void CEikDialog::ConstructAutoDialogLC(TInt aFlags,TInt aButtonsId)
       
  1184 	{
       
  1185     CleanupStack::PushL(this);
       
  1186 	BaseConstructL();
       
  1187 	iDialogFlags=aFlags;
       
  1188 	CreateTitleBarL();
       
  1189 	CreateButtonGroupContainerL(aButtonsId);
       
  1190 	CreatePageSelectorL();
       
  1191 	iPageSelector->AddPageL(0,KNullDesC);
       
  1192 	SetBorderStyle();  // Moved to the end of construction to allow access to individual lines.
       
  1193 	}
       
  1194 
       
  1195 /**
       
  1196  * @deprecated
       
  1197  */
       
  1198 EXPORT_C void CEikDialog::DeclareItemAuto(TInt aControlId,TInt aControlType,TAny* aReturnValue)
       
  1199 	{
       
  1200 	CEikCaptionedControl* line=Line(aControlId);
       
  1201 	if (line->iControlType!=aControlType)
       
  1202 		Panic(EEikDialogPanicWrongAutoType);
       
  1203 	line->iReturnValue=aReturnValue;
       
  1204 	}
       
  1205 
       
  1206 /**
       
  1207  * Creates a control line in the dialog.on the active page with caption text aCaption.
       
  1208  * The line can thereafter be accessed through the identifier aControlId.
       
  1209  * A control of type aControlType is created by the Eikon control factory
       
  1210  * and the return value of the line set to aReturnValue.
       
  1211  * If the value of aControlType is not known to the Eikon control factory then
       
  1212  * the construction of the control must be handled by CreateCustomControlL.
       
  1213  */
       
  1214 EXPORT_C CCoeControl* CEikDialog::CreateLineByTypeL(const TDesC& aCaption,TInt aControlId,TInt aControlType,TAny* aReturnValue)
       
  1215 	{
       
  1216 	return iPageSelector->CreateLineByTypeL(aCaption,aControlId,aControlType,aReturnValue);
       
  1217 	}
       
  1218 
       
  1219 /**
       
  1220  * Overloaded member which creates a control line in the dialog on the page specified by aPageId.
       
  1221  *
       
  1222  * @since ER5U
       
  1223  */
       
  1224 EXPORT_C CCoeControl* CEikDialog::CreateLineByTypeL(const TDesC& aCaption,TInt aPageId,TInt aControlId,TInt aControlType,TAny* aReturnValue)
       
  1225 	{
       
  1226 	return iPageSelector->CreateLineByTypeL(aCaption,aPageId,aControlId,aControlType,aReturnValue);
       
  1227 	}
       
  1228 
       
  1229 /**
       
  1230  * Creates a custom control of type aControlType. Returns the control information for the custom control
       
  1231  * which is created. Called when creating a line on the dialog page if the Eikon control factory does not
       
  1232  * recognise the type aControlType.
       
  1233  *
       
  1234  * This method panics by default. It must be reimplemented if it is to be called.
       
  1235  *
       
  1236  * The parent of a custom control should be the line which contains it - not the dialog itself -
       
  1237  * but the line is not accessible at this stage. If necessary, the line should be set as the parent in
       
  1238  * PreLayoutDynInitL
       
  1239  */
       
  1240 EXPORT_C SEikControlInfo CEikDialog::CreateCustomControlL(TInt /*aControlType*/)
       
  1241 	{
       
  1242 	Panic(EEikDialogPanicNoSuchControl);
       
  1243 	return SEikControlInfo();
       
  1244 	}
       
  1245 
       
  1246 EXPORT_C MEikDialogPageObserver::TFormControlTypes CEikDialog::ConvertCustomControlTypeToBaseControlType(TInt /*aControlType*/) const
       
  1247 	{
       
  1248 /** 
       
  1249  * For Forms only:
       
  1250  * This should be overrridden with mappings between the base control types that 
       
  1251  * form knows how to layout (described in eikdpobs.h)
       
  1252  */
       
  1253 	return MEikDialogPageObserver::EUnknownType;
       
  1254 	}
       
  1255 /**
       
  1256  * Sets the caption of the control identified by aControlId to the descriptor aText.
       
  1257  */
       
  1258 EXPORT_C void CEikDialog::SetControlCaptionL(TInt aControlId,const TDesC& aText)
       
  1259 	{
       
  1260 	CEikCaptionedControl* line=Line(aControlId);
       
  1261 	if (line)
       
  1262 		{
       
  1263 		line->SetCaptionL(aText);
       
  1264 		line->DrawNow();
       
  1265 		}
       
  1266 	}
       
  1267 
       
  1268 /**
       
  1269  * Sets the caption of the control identified by aControlId by reading the caption
       
  1270  * text from the resource specified by aResourceId.
       
  1271  */
       
  1272 EXPORT_C void CEikDialog::SetControlCaptionL(TInt aControlId,TInt aResourceId)
       
  1273 	{
       
  1274 	HBufC* captionBuf=iCoeEnv->AllocReadResourceLC(aResourceId);
       
  1275 	SetControlCaptionL(aControlId,captionBuf->Des());
       
  1276 	CleanupStack::PopAndDestroy();
       
  1277 	}
       
  1278 
       
  1279 /**
       
  1280  * Returns a pointer to the caption of the control identified by aControlId.
       
  1281  * Does not imply transfer of ownership.
       
  1282  */
       
  1283 EXPORT_C CEikLabel* CEikDialog::ControlCaption(TInt aControlId) const
       
  1284 	{
       
  1285 	return iPageSelector->Line(aControlId)->iCaption;
       
  1286 	}
       
  1287 
       
  1288 /**
       
  1289  * Returns a pointer to the first control found to be identified by aControlId.
       
  1290  * Panics if the control id is invalid. Does not imply transfer of ownership.
       
  1291  */
       
  1292 EXPORT_C CCoeControl* CEikDialog::Control(TInt aControlId) const
       
  1293 	{
       
  1294 	CEikCaptionedControl* line=iPageSelector->Line(aControlId);
       
  1295 	CCoeControl* control=line->iControl;
       
  1296 	ASSERT(control);
       
  1297 	return control;
       
  1298 	}
       
  1299 
       
  1300 /**
       
  1301  * Returns a pointer to the control identified by aControlId or NULL
       
  1302  * if the control id is invalid. Does not imply transfer of ownership.
       
  1303  */
       
  1304 EXPORT_C CCoeControl* CEikDialog::ControlOrNull(TInt aControlId) const
       
  1305 	{
       
  1306 	if (!iPageSelector)
       
  1307 		return NULL;
       
  1308 	CEikCaptionedControl* line=iPageSelector->LineOrNull(aControlId);
       
  1309 	if (line)
       
  1310 		return line->iControl;
       
  1311 
       
  1312 	return NULL;
       
  1313 	}
       
  1314 
       
  1315 /**
       
  1316  * Returns a reference to the button group container supplying the command
       
  1317  * buttons for the dialog.
       
  1318  *
       
  1319  * @since ER5U
       
  1320  */
       
  1321 EXPORT_C CEikButtonGroupContainer& CEikDialog::ButtonGroupContainer() const
       
  1322 	{
       
  1323 	ASSERT(iButtonGroupContainer);
       
  1324 	return *iButtonGroupContainer;
       
  1325 	}
       
  1326 
       
  1327 /**
       
  1328  * Swaps the the button group container with a new container aContainer. The dialog takes ownership
       
  1329  * of the new container. Returns a pointer to the old button group container and transfers ownership.
       
  1330  *
       
  1331  * @since ER5U
       
  1332  */
       
  1333 EXPORT_C CEikButtonGroupContainer* CEikDialog::SwapButtonGroupContainer(CEikButtonGroupContainer* aContainer)
       
  1334 	{
       
  1335 	ASSERT(iButtonGroupContainer);
       
  1336 	ASSERT(aContainer);
       
  1337 
       
  1338 	CEikButtonGroupContainer* oldContainer=iButtonGroupContainer;
       
  1339 	iButtonGroupContainer=aContainer;
       
  1340 	return oldContainer;
       
  1341 	}
       
  1342 
       
  1343 /**
       
  1344  * Returns a reference to the dialog title bar. 
       
  1345  *
       
  1346  * @since ER5U
       
  1347  */
       
  1348 EXPORT_C CEikMover& CEikDialog::Title() const
       
  1349 	{
       
  1350 	return *iTitleBar;
       
  1351 	}
       
  1352 
       
  1353 /**
       
  1354  * Returns the id of the dialog's active page.
       
  1355  *
       
  1356  * @since ER5U
       
  1357  */
       
  1358 EXPORT_C TInt CEikDialog::ActivePageId() const
       
  1359 	{
       
  1360 	return iPageSelector->ActivePageId();
       
  1361 	}
       
  1362 
       
  1363 /**
       
  1364  * Activates the first page on the dialog. At least one page must be activated
       
  1365  * before the dialog can be used.
       
  1366  *
       
  1367  * @since ER5U
       
  1368  */
       
  1369 EXPORT_C void CEikDialog::ActivateFirstPageL() const
       
  1370 	{
       
  1371 	iPageSelector->ActivateFirstPageL();
       
  1372 	}
       
  1373 
       
  1374 
       
  1375 /**
       
  1376  * Sets the Editable state.  This exists to support forms
       
  1377  *
       
  1378  * @since ER5U
       
  1379  */
       
  1380 EXPORT_C void CEikDialog::SetEditableL( TBool aEditable ) 
       
  1381     {
       
  1382     if ( !iExtension->iFlags[CEikDialogExtension::EEditableStateInitialised] ||
       
  1383          iIsEditable != aEditable )
       
  1384         {
       
  1385         iExtension->iFlags.Set(CEikDialogExtension::EEditableStateInitialised);
       
  1386         iIsEditable = aEditable ;
       
  1387         // tell each of the pages on the dialog about the editable state...
       
  1388         iPageSelector->SetEditableL( aEditable );
       
  1389         DrawNow();
       
  1390         }
       
  1391     }
       
  1392 
       
  1393 /**
       
  1394  * Returns the Editable state.  This exists to support forms
       
  1395  *
       
  1396  * @since ER5U
       
  1397  */	
       
  1398 EXPORT_C TBool CEikDialog::IsEditable() const 
       
  1399 	{
       
  1400 	return ( iIsEditable ) ;
       
  1401 	}
       
  1402 
       
  1403 /**
       
  1404  * Returns the line index of the control aControl or KErrNotFound if the control
       
  1405  * is not on the active page.
       
  1406  */
       
  1407 EXPORT_C TInt CEikDialog::FindLineIndex(const CCoeControl& aControl) const
       
  1408 	{
       
  1409 	return iPageSelector->FindLineIndex(aControl);
       
  1410 	}
       
  1411 
       
  1412 /**
       
  1413  * Returns a pointer to the line containing the control identified by aControlId.
       
  1414  * Does not imply transfer of ownership.
       
  1415  */
       
  1416 EXPORT_C CEikCaptionedControl* CEikDialog::Line(TInt aControlId) const
       
  1417 	{
       
  1418 	return iPageSelector->Line(aControlId);
       
  1419 	}
       
  1420 
       
  1421 /**
       
  1422  * Returns a pointer to the current line.
       
  1423  * Does not imply transfer of ownership.
       
  1424  */
       
  1425 EXPORT_C CEikCaptionedControl* CEikDialog::CurrentLine() const
       
  1426 	{
       
  1427 	return iPageSelector->CurrentLine();
       
  1428 	}
       
  1429 
       
  1430 /**
       
  1431  * Rotates the focus by aDelta steps. Each line is a step, as are dialog tabs..
       
  1432  */
       
  1433 EXPORT_C TBool CEikDialog::RotateFocusByL(TInt aDelta)
       
  1434 	{
       
  1435 	return iPageSelector->RotateFocusByL(aDelta);
       
  1436 	}
       
  1437 
       
  1438 /**
       
  1439  * Returns the index of the dialog's active page. Pages are indexed from 0 in the
       
  1440  * order that they are added.
       
  1441  *
       
  1442  * @since ER5U
       
  1443  */
       
  1444 EXPORT_C TInt CEikDialog::ActivePageIndex() const
       
  1445 	{
       
  1446 	return iPageSelector->ActivePageIndex();
       
  1447 	}
       
  1448 
       
  1449 /**
       
  1450  * Runs the dialog and returns the id of the button used to dismiss it.
       
  1451  * The dialog is destroyed on exit.
       
  1452  */
       
  1453 EXPORT_C TInt CEikDialog::RunLD()
       
  1454 	{
       
  1455     // Moved BringForwards in the beginning to enable 1-frame animations.
       
  1456 	iEikonEnv->BringForwards(ETrue); // before call to EnableBackup()
       
  1457 	AknGlobalPopupPriorityController::ShowPopup(*this, ETrue);
       
  1458 	iDialogFlags|=EEikDialogFlagBroughtForward;
       
  1459 
       
  1460     // This makes sure that forms, ie. dialogs that fill up the whole
       
  1461     // application rect, and therefore look like views,
       
  1462     // not have popup transition effects.
       
  1463     if ( iDialogFlags & EEikDialogFlagFillAppClientRect ||
       
  1464          iDialogFlags & EEikDialogFlagFillScreen ||
       
  1465          (AknLayoutUtils::PenEnabled() && ( iDialogFlags & EEikDialogFlagVirtualInput ) )
       
  1466          )
       
  1467         {
       
  1468         GfxTransEffect::Deregister( this );
       
  1469         }
       
  1470 
       
  1471 	// Need to fade here or background will not be faded during transition
       
  1472 	if(GfxTransEffect::IsRegistered(this) && IsVisible())
       
  1473 	    {
       
  1474 	    CAknTransitionUtils::SetData(EDontAnimateBitmaps, (TAny*)this);
       
  1475 		}
       
  1476 
       
  1477 	DynamicConstructL();
       
  1478 	if (!(iDialogFlags&EEikDialogFlagModeless))
       
  1479 		{
       
  1480         if ( !(iDialogFlags&EEikDialogFlagFillAppClientRect) )
       
  1481             {
       
  1482             // Modal partial screen dialogs (like queries) capture pointer events.
       
  1483             SetGloballyCapturing( ETrue );
       
  1484             SetPointerCapture(ETrue);		    
       
  1485             }
       
  1486 		SetFocus(EFalse);
       
  1487 		AknGlobalPopupPriorityController::AddPopupToControlStackL(*this, ECoeStackPriorityDialog);
       
  1488 		}
       
  1489 
       
  1490 	if (~iDialogFlags&EEikDialogFlagNoBackup)
       
  1491 	    {
       
  1492 		DrawableWindow()->EnableBackup();
       
  1493 	    }
       
  1494 
       
  1495     TBool wgFocused = IsFocusedWindowGroup( this );
       
  1496     if ( !GfxTransEffect::IsRegistered( this ) || !IsVisible() || !wgFocused )
       
  1497 		{
       
  1498 		// Call this when there won't be any effect in order to work exactly
       
  1499 		// like it would if there were no transition effects
       
  1500 	FadeBehindPopup(ETrue);
       
  1501 		}
       
  1502 	
       
  1503     // Get the foreground information _before_ calling ActivateL because something
       
  1504     // unwanted could be flushed to the screen (IsForeground causes a window server
       
  1505     // flush)
       
  1506     CAknAppUi* aknAppUi = static_cast<CAknAppUi*>( CEikonEnv::Static()->EikAppUi() );
       
  1507     TBool threadIsFg = aknAppUi->IsForeground();
       
  1508         		
       
  1509     iExtension->iInitialMade = ETrue;
       
  1510     iPageSelector->ActivateFirstPageL();           
       
  1511     ActivateL();
       
  1512 
       
  1513     if ( iButtonGroupContainer && CbaEmbeddedInDialog( iDialogFlags ) )
       
  1514         {
       
  1515         iButtonGroupContainer->ActivateL();
       
  1516         }
       
  1517 
       
  1518     SetInitialCurrentLine();
       
  1519     iExtension->iInitialMade = EFalse;
       
  1520 
       
  1521     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1522 	    
       
  1523 	TInt slidingMode = AknsDrawUtils::SlidingMode(skin);
       
  1524 
       
  1525 	if ( (iExtension && iExtension->LayoutCategory() == CEikDialogExtension::EPopupLayout) &&
       
  1526 	     (slidingMode != ESlidingDisabled) &&
       
  1527 	     IsVisible() )
       
  1528 	    {
       
  1529         SlideDialog();
       
  1530 	    }
       
  1531 	    	
       
  1532 	IssueMediatorCommand(this);
       
  1533 	
       
  1534     CleanupStack::Pop();
       
  1535 
       
  1536     if ( GfxTransEffect::IsRegistered( this ) && IsVisible() && wgFocused &&
       
  1537 	    Size().iWidth > 0 && Size().iHeight > 0 && threadIsFg && !IsBlankScreenDisplayed())
       
  1538 		{
       
  1539 		MakeVisible(EFalse); //make sure it is invisible when calling begin
       
  1540         CAknTransitionUtils::MakeVisibleSubComponents( this,
       
  1541                                     CAknTransitionUtils::EAppearInvisible );
       
  1542 
       
  1543         InvalidateWindows( this );
       
  1544 		
       
  1545 		CAknTransitionUtils::SetAllParents(this);
       
  1546 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
  1547 		GfxTransEffect::NotifyExternalState(EInternalHandleSequence, (const TDesC8*)this);
       
  1548 #endif
       
  1549 		GfxTransEffect::Begin(this, KGfxControlAppearAction);
       
  1550 		GfxTransEffect::NotifyExternalState(ECaptureComponentsBegin, (const TDesC8*)this);
       
  1551 		
       
  1552 		TRect demarcation;
       
  1553 		CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup, demarcation);
       
  1554 		GfxTransEffect::SetDemarcation(this, demarcation);
       
  1555 
       
  1556 		MakeVisible(ETrue);
       
  1557         CAknTransitionUtils::MakeVisibleSubComponents( this,
       
  1558                                         CAknTransitionUtils::EAppearVisible );
       
  1559 
       
  1560 		GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)this);
       
  1561 		GfxTransEffect::End(this);
       
  1562 		}
       
  1563 	else
       
  1564 		{
       
  1565 		FadeBehindPopup(ETrue);
       
  1566 		}
       
  1567 		
       
  1568     if( GfxTransEffect::IsRegistered( this ) && IsVisible() ) 
       
  1569         { 
       
  1570         CAknTransitionUtils::RemoveData(EDontAnimateBitmaps);   
       
  1571         }
       
  1572         
       
  1573 	// Claim pointer grab and send the pointer up event to the
       
  1574 	// control that otherwise would be receiving the drag events.
       
  1575 	Window().ClaimPointerGrab(ETrue);
       
  1576 	
       
  1577     return(WaitAsRequired());
       
  1578 	}
       
  1579 
       
  1580 
       
  1581 EXPORT_C void CEikDialog::Draw(const TRect& /*aRect*/) const
       
  1582     {
       
  1583     TRect rect=Rect();
       
  1584     CWindowGc& gc=SystemGc(); //No reason to demote the gc, CWindowGc is more usable.
       
  1585 
       
  1586     if ( iExtension->LayoutCategory() == CEikDialogExtension::EPopupLayout )
       
  1587         {
       
  1588         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1589 
       
  1590         TRect windowRect = Rect();
       
  1591     
       
  1592         TAknLayoutRect topLeft;
       
  1593         topLeft.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_2());
       
  1594 
       
  1595         TAknLayoutRect bottomRight;
       
  1596     	bottomRight.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_5());
       
  1597 
       
  1598         TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
       
  1599         TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
       
  1600 
       
  1601         CFbsBitmap* cbaExtension = 0;
       
  1602         cbaExtension = AknsUtils::GetCachedBitmap( skin, KAknsIIDQsnBgSlicePopup );
       
  1603 
       
  1604 
       
  1605         if ( cbaExtension ) 
       
  1606             {
       
  1607             TAknWindowLineLayout lineLayoutPopupBgSlice = SkinLayout::Popup_windows_skin_placing__background_slice__Line_2();
       
  1608             TAknLayoutRect layoutRect;
       
  1609             layoutRect.LayoutRect( windowRect, lineLayoutPopupBgSlice );
       
  1610             TRect rectPopupBgSlice( layoutRect.Rect() );
       
  1611 
       
  1612             AknIconUtils::SetSize( cbaExtension, TSize( rectPopupBgSlice.Width(), rectPopupBgSlice.Height() ) ); 
       
  1613 
       
  1614             gc.BitBlt(TPoint(rect.iTl.iX, rect.iBr.iY - cbaExtension->SizeInPixels().iHeight), cbaExtension);
       
  1615             }
       
  1616 
       
  1617         if ( CAknEnv::Static()->TransparencyEnabled() )
       
  1618             {
       
  1619             TRect rect( outerRect ); 
       
  1620             TRegionFix<16> drawFrameClipReg;
       
  1621             TBool drawFrame = EFalse;
       
  1622             
       
  1623             // Add CBA area to drawing region
       
  1624             if ( iButtonGroupContainer && CbaEmbeddedInDialog( iDialogFlags ) )
       
  1625                 {
       
  1626                 CEikCba* cba = static_cast<CEikCba*>( 
       
  1627                     iButtonGroupContainer->ButtonGroup() );
       
  1628                 
       
  1629                 if ( cba )
       
  1630                     {
       
  1631                     drawFrame = ETrue;
       
  1632             
       
  1633                     drawFrameClipReg.AddRect( 
       
  1634                         TRect( cba->Position(), cba->Rect().Size() ) );
       
  1635                         
       
  1636                     rect.iBr.iY = Min( rect.iBr.iY, 
       
  1637                         Rect().iBr.iY - cba->Rect().Height() );
       
  1638                     }
       
  1639                 }
       
  1640 
       
  1641             // Add area outside page selector area to drawing region. 
       
  1642             if ( iPageSelector && rect != iPageSelector->Rect() )
       
  1643                 {
       
  1644                 drawFrame = ETrue;
       
  1645                 drawFrameClipReg.AddRect( rect );
       
  1646 
       
  1647                 if ( iExtension->iPublicFlags[ CEikDialogExtension::EClipChildControlRect ] )
       
  1648                     {                    
       
  1649                     drawFrameClipReg.SubRect( iPageSelector->Rect() );
       
  1650                     }
       
  1651                 }
       
  1652             
       
  1653             // Draw background
       
  1654             if ( drawFrame )
       
  1655                 {
       
  1656                 gc.SetClippingRegion( drawFrameClipReg );
       
  1657                 
       
  1658                 AknsDrawUtils::DrawFrame( skin, gc, outerRect, innerRect,
       
  1659                     KAknsIIDQsnFrPopup,KAknsIIDQsnFrPopupCenter);
       
  1660                         
       
  1661                 gc.CancelClippingRegion();
       
  1662                 }
       
  1663             }
       
  1664         else
       
  1665             {
       
  1666             AknsDrawUtils::DrawFrame( skin, gc, outerRect, innerRect,
       
  1667                 KAknsIIDQsnFrPopup,KAknsIIDQsnFrPopupCenter);
       
  1668             }    
       
  1669         }
       
  1670     }
       
  1671     
       
  1672 EXPORT_C void CEikDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
  1673     { 
       
  1674     CEikBorderedControl::HandlePointerEventL(aPointerEvent); 
       
  1675     }    
       
  1676 
       
  1677 EXPORT_C void* CEikDialog::ExtensionInterface( TUid /*aInterface*/ )
       
  1678     {
       
  1679     return NULL;
       
  1680     }   
       
  1681 
       
  1682 TKeyResponse CEikDialog::TryAnimateButtonAndExitL(TInt aKeycode)
       
  1683 	{
       
  1684 	TInt buttonId=EEikBidCancel;
       
  1685 	switch (aKeycode)
       
  1686 		{
       
  1687 	case EKeyEnter:
       
  1688 	case EKeyOK:
       
  1689 		buttonId=EEikBidOk;
       
  1690 		break;
       
  1691 	case EKeySpace:
       
  1692 		buttonId=EEikBidSpace;
       
  1693 		break;
       
  1694 	case EKeyTab:
       
  1695 		buttonId=EEikBidTab;
       
  1696 		break;
       
  1697 	case EKeyBackspace:
       
  1698 		buttonId=EEikBidDelete;
       
  1699 		break;
       
  1700 		}
       
  1701 
       
  1702 	CEikButtonGroupContainer& buttonGroupContainer = ButtonGroupContainer();
       
  1703 	CCoeControl* button = buttonGroupContainer.ControlOrNull(buttonId);
       
  1704 
       
  1705 	if (button)
       
  1706 		{
       
  1707 		if (button->IsDimmed() || !button->IsVisible())
       
  1708 			return EKeyWasNotConsumed;
       
  1709 		buttonGroupContainer.AnimateCommand(buttonId);
       
  1710 		}
       
  1711 
       
  1712 	if (button || buttonId==EEikBidCancel || buttonId==EEikBidOk)
       
  1713 		{
       
  1714 		TryExitL(buttonId);
       
  1715 		return EKeyWasConsumed;
       
  1716 		}
       
  1717 
       
  1718 	return EKeyWasNotConsumed;
       
  1719 	}
       
  1720 
       
  1721 /**
       
  1722  * Prepares for a transistion in focus in the dialog. By default, calls the currently
       
  1723  * focused control to prepare fo loss of focus.
       
  1724  */
       
  1725 EXPORT_C void CEikDialog::PrepareForFocusTransitionL()
       
  1726     {
       
  1727 	CEikCaptionedControl* currentLine=CurrentLine();
       
  1728 	if (currentLine)
       
  1729 		currentLine->iControl->PrepareForFocusLossL();
       
  1730     }
       
  1731 
       
  1732 /**
       
  1733  * Handles the key event aKeyEvent with code aType. Returns EKeyWasConsumed if the control
       
  1734  * takes action on the key event or EKeyWasNotConsumed otherwise.
       
  1735  */
       
  1736 EXPORT_C TKeyResponse CEikDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
  1737     {
       
  1738 
       
  1739 
       
  1740 	// Hide the tool tip (if there is one!)
       
  1741 	if ( ( iPageSelector->NumPages() == 1 ) && ( CurrentLine() ) && ( CurrentLine()->ToolTipText( ) ) )
       
  1742 		{
       
  1743 		switch ( aKeyEvent.iScanCode )
       
  1744 			{
       
  1745 			case EStdKeyEscape :
       
  1746 			default :
       
  1747 				break ;
       
  1748 			}
       
  1749 		}
       
  1750     if (!(iDialogFlags&EEikDialogFlagDontEatUpDownEvents) && aKeyEvent.iScanCode != EStdKeyYes)
       
  1751 	{
       
  1752 	if (aType!=EEventKey)
       
  1753 	    return(EKeyWasConsumed);
       
  1754 	}
       
  1755 
       
  1756 	TInt code=aKeyEvent.iCode;
       
  1757 	const TUint modifiers = aKeyEvent.iModifiers;
       
  1758 	TKeyResponse response;
       
  1759 
       
  1760 	// Pass the key event to the button group container first (if required)
       
  1761 
       
  1762 	if (iDialogFlags&EEikDialogFlagAllKeysToButtons || ((modifiers & EAllStdModifiers) == EModifierCtrl) )
       
  1763 		{
       
  1764 		response = iButtonGroupContainer->OfferKeyEventL(aKeyEvent,aType);
       
  1765 		if(response==EKeyWasConsumed)
       
  1766 			return EKeyWasConsumed;
       
  1767 		}
       
  1768 
       
  1769 	//
       
  1770 
       
  1771     switch (code)
       
  1772         {
       
  1773     case EKeyEnter:
       
  1774     case EKeyOK:
       
  1775 	// the next one tries to disable selection_key when
       
  1776 	// left softkey has no command in it.
       
  1777 	if (iButtonGroupContainer && iButtonGroupContainer->ButtonGroup())
       
  1778 	    if (iButtonGroupContainer->ButtonGroup()->CommandId(0) == 0)
       
  1779 		goto KeyToFocus;
       
  1780 
       
  1781 		if(iPageSelector->TakesEnterKey()  || (modifiers&EModifierCtrl && !(modifiers&EModifierPureKeycode)) )
       
  1782 			goto KeyToFocus; // else fall through
       
  1783         break;
       
  1784     case EKeyEscape:
       
  1785 		if (modifiers&EModifierShift)
       
  1786 			iPageSelector->OfferKeyEventL(aKeyEvent, aType);
       
  1787 // Add to remove repeated keypress return event of OK key
       
  1788 		if (aKeyEvent.iRepeats&&EKeyOK==code)
       
  1789 			return EKeyWasConsumed;
       
  1790 		if ((!(modifiers&EModifierCtrl) || modifiers&EModifierPureKeycode) &&
       
  1791 			!(iDialogFlags&EEikDialogFlagModeless))
       
  1792 			TryAnimateButtonAndExitL(code);
       
  1793         break;
       
  1794 	case EKeyTab:
       
  1795 		if (aKeyEvent.iModifiers&EModifierCtrl)
       
  1796 			{
       
  1797 			response = iPageSelector->OfferKeyEventL(aKeyEvent, aType);
       
  1798 			if (response==EKeyWasConsumed)
       
  1799 				break;
       
  1800 			}
       
  1801 		// drop through
       
  1802 	case EKeySpace:
       
  1803 	case EKeyBackspace:
       
  1804 		if (TryAnimateButtonAndExitL(code)==EKeyWasConsumed)
       
  1805 			break;
       
  1806     default:
       
  1807 		iPageSelector->OfferKeyEventL(aKeyEvent, aType);
       
  1808 		break;
       
  1809 	KeyToFocus:
       
  1810 		if(iPageSelector->OfferHotKeysKeyEventL(aKeyEvent,aType)==EKeyWasConsumed)
       
  1811 			return EKeyWasConsumed;
       
  1812 
       
  1813 		}
       
  1814 
       
  1815 	return (aKeyEvent.iScanCode == EStdKeyYes ? EKeyWasNotConsumed:EKeyWasConsumed);
       
  1816     }
       
  1817 
       
  1818 /**
       
  1819 * Hands focus to current dialog line.
       
  1820 */
       
  1821 EXPORT_C void CEikDialog::FocusChanged(TDrawNow aDrawNow)
       
  1822     {
       
  1823     CEikBorderedControl::FocusChanged( aDrawNow );
       
  1824 
       
  1825     TInt controlID = IdOfFocusControl();
       
  1826     if (controlID)
       
  1827         {
       
  1828         Line(controlID)->SetFocus(IsFocused(), aDrawNow);
       
  1829         }
       
  1830     }
       
  1831 
       
  1832 /**
       
  1833  * Tries to initiate user exit of the dialog when the button identified
       
  1834  * by aButtonId is pressed, if this button should exit the dialog. See OkToExitL to
       
  1835  * determine which buttons can exit the dialog.
       
  1836  *
       
  1837  * This will fail if user exit is prevented by the EEikDialogFlagNoUserExit flag.
       
  1838  * If the EEikDialogFlagNotifyEsc flag is not set and the dialog has been cancelled it
       
  1839  * immediately deletes itself. 
       
  1840  */
       
  1841 EXPORT_C void CEikDialog::TryExitL(TInt aButtonId)
       
  1842     {
       
  1843     if ( iDialogFlags & EEikDialogFlagNoUserExit )
       
  1844         {
       
  1845 		return;
       
  1846         }
       
  1847         
       
  1848     // use delayed exit if pointer event handling is in progress
       
  1849     if ( Extension()->iPublicFlags.IsSet( CEikDialogExtension::EDelayedExit ) )
       
  1850         {
       
  1851         Extension()->iButtonId = aButtonId;
       
  1852         Extension()->StartDelayedExit();
       
  1853         return;
       
  1854         }
       
  1855         
       
  1856     TBool effectTriggered = EFalse;
       
  1857     TBool effectButton = aButtonId == EEikBidCancel
       
  1858                       || aButtonId == EAknSoftkeyExit
       
  1859                       || aButtonId == EAknSoftkeyBack
       
  1860                       || aButtonId == EAknSoftkeyNo;
       
  1861 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
  1862     effectButton =    effectButton
       
  1863 					  || aButtonId == EAknSoftkeyClose
       
  1864                       || aButtonId == EAknSoftkeyDone;
       
  1865 #endif
       
  1866     CAknAppUi* aknAppUi = static_cast<CAknAppUi*>( iEikonEnv->EikAppUi() );
       
  1867     if ( GfxTransEffect::IsRegistered( this ) && IsVisible() && effectButton
       
  1868 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS        
       
  1869         && !(iDialogFlags&EEikDialogFlagSleeping)
       
  1870 #endif
       
  1871         && ( !aknAppUi->IsFullScreenApp() || aknAppUi->IsForeground() )
       
  1872         && !IsBlankScreenDisplayed()
       
  1873          )
       
  1874         {
       
  1875         CAknTransitionUtils::SetAllParents(this);
       
  1876         GfxTransEffect::Begin(this, KGfxControlDisappearAction);
       
  1877         GfxTransEffect::NotifyExternalState(ECaptureComponentsBegin, (const TDesC8*)this);
       
  1878 
       
  1879         TRect demarcation;
       
  1880         CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup,
       
  1881                                             demarcation);
       
  1882         GfxTransEffect::SetDemarcation(this, demarcation);
       
  1883         effectTriggered = ETrue;
       
  1884         }
       
  1885 
       
  1886     if (aButtonId!=EEikBidCancel)
       
  1887         PrepareForFocusTransitionL();
       
  1888     else if (!(iDialogFlags&EEikDialogFlagNotifyEsc))
       
  1889 		goto finished;
       
  1890 	if (!OkToExitL(aButtonId))
       
  1891             {
       
  1892         if ( effectTriggered )
       
  1893             {
       
  1894             GfxTransEffect::NotifyExternalState( ECaptureComponentsAbort,
       
  1895                                                  ( const TDesC8* ) this );
       
  1896             GfxTransEffect::Abort( this );
       
  1897             }
       
  1898    			return;
       
  1899             }
       
  1900 
       
  1901 	if (aButtonId!=EEikBidCancel)
       
  1902 		GetAutoValues();
       
  1903 finished:
       
  1904     if (iExitConfirmed)
       
  1905 		*iExitConfirmed=((MappedCommandId( aButtonId ) ==EEikBidCancel)? 0: aButtonId);
       
  1906 
       
  1907     // Remove content observer in order to prevent unnecessary layout 
       
  1908     // calculations in dialog shutdown.
       
  1909     EnableContentObserver( EFalse );
       
  1910 
       
  1911 	if (iDialogFlags&EEikDialogFlagSleeping)
       
  1912 		ExitSleepingDialog();
       
  1913 	else
       
  1914 		{
       
  1915         // Remove content observer in order to prevent unnecessary layout 
       
  1916         // calculations in dialog shutdown.
       
  1917         EnableContentObserver( EFalse );
       
  1918 
       
  1919         if ( effectTriggered )
       
  1920 						{
       
  1921         		MakeVisible(EFalse);
       
  1922                 CAknTransitionUtils::MakeVisibleSubComponents( this,
       
  1923                                         CAknTransitionUtils::EForceInvisible );
       
  1924 
       
  1925         		GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)this);
       
  1926         		GfxTransEffect::End(this);
       
  1927         		}
       
  1928         	else
       
  1929 			    {
       
  1930         		MakeVisible(EFalse);
       
  1931                 CAknTransitionUtils::MakeVisibleSubComponents( this,
       
  1932                                         CAknTransitionUtils::EForceInvisible );
       
  1933         		GfxTransEffect::NotifyExternalState( ECaptureComponentsAbort,
       
  1934                                                  ( const TDesC8* ) this );
       
  1935 		    	GfxTransEffect::Abort(this);
       
  1936 			}
       
  1937 	    delete(this);
       
  1938 		}
       
  1939     }
       
  1940 
       
  1941 /**
       
  1942  * Returns the input capabilites of the dialog. By default, the dialog is
       
  1943  * capable of handling all text input.
       
  1944  *
       
  1945  * @since ER5U
       
  1946  */
       
  1947 EXPORT_C TCoeInputCapabilities CEikDialog::InputCapabilities() const
       
  1948 	{
       
  1949 	return TCoeInputCapabilities(TCoeInputCapabilities::ENavigation);
       
  1950 	}
       
  1951 
       
  1952 void CEikDialog::GetAutoValues()
       
  1953 	{
       
  1954 	iPageSelector->GetAutoValues();
       
  1955 	}
       
  1956 
       
  1957 /**
       
  1958  * Tries to change focus to the line identified by aLineId. Fails if the line id is not
       
  1959  * valid. Calls PrepareForFocusTransitionL before focus is given to the line.
       
  1960  */
       
  1961 EXPORT_C void CEikDialog::TryChangeFocusToL(TInt aLineId)
       
  1962 	{
       
  1963 	iPageSelector->FocusLineL(aLineId);
       
  1964     }
       
  1965 
       
  1966 /** * Returns the number of control components. 
       
  1967  * In Avkon returns 2 as the button group container is not internal
       
  1968  */
       
  1969 EXPORT_C TInt CEikDialog::CountComponentControls() const
       
  1970     {
       
  1971     if ( CbaEmbeddedInDialog( iDialogFlags ) && iButtonGroupContainer
       
  1972             && iButtonGroupContainer->ButtonGroup() )
       
  1973         {
       
  1974         // Count Buttongroup 
       
  1975         return 3;
       
  1976         }
       
  1977 
       
  1978 	return 2;	// Title bar and page selector.
       
  1979     }
       
  1980 
       
  1981 /**
       
  1982  * Returns a pointer to the component control at index aIndex in the component control list.
       
  1983  * Returns the title bar at index 0, then the page selector 
       
  1984  * Does not imply transfer of ownership.
       
  1985  */
       
  1986 EXPORT_C CCoeControl* CEikDialog::ComponentControl(TInt aIndex) const
       
  1987     {
       
  1988     if ( CbaEmbeddedInDialog( iDialogFlags ) )
       
  1989         {
       
  1990         switch (aIndex)
       
  1991             {
       
  1992             case 0:
       
  1993                 return iTitleBar;
       
  1994             case 1:
       
  1995                 return iPageSelector;
       
  1996             case 2:
       
  1997                 return ( iButtonGroupContainer &&
       
  1998                     iButtonGroupContainer->ButtonGroup() ) ?
       
  1999                     iButtonGroupContainer->ButtonGroup()->AsControl() :
       
  2000                     NULL; 
       
  2001             default:
       
  2002                 return NULL;
       
  2003             }
       
  2004         }
       
  2005 
       
  2006 	switch (aIndex)
       
  2007 		{
       
  2008 		case 0:
       
  2009 			return iTitleBar;
       
  2010 		case 1:
       
  2011 		default:
       
  2012 			return iPageSelector;
       
  2013 		}
       
  2014 	}
       
  2015 
       
  2016 /**
       
  2017  * Handles an event of type aEventType reported by the control aControl. By default, handles
       
  2018  * EEventStateChanged by calling HandleControlStateChangeL and EEventInteractionRefused by
       
  2019  * calling HandleInteractionRefused.
       
  2020  */  
       
  2021 EXPORT_C void CEikDialog::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
       
  2022     {
       
  2023     switch (aEventType)
       
  2024         {
       
  2025     case EEventStateChanged:
       
  2026 		{
       
  2027 	    if ( iPageSelector && iPageSelector->IsForm() && Extension() )
       
  2028 	        {
       
  2029 	        if ( Extension()->iPublicFlags.IsSet( CEikDialogExtension::EFullyConstructed ) )
       
  2030 	            {
       
  2031                 TInt lineId = iPageSelector->LineId( *aControl );
       
  2032                 
       
  2033                 if ( lineId != KErrNotFound )
       
  2034                     {
       
  2035                     HandleControlStateChangeL( lineId );
       
  2036                     }
       
  2037 	            }
       
  2038 	        }
       
  2039 		}
       
  2040         break;
       
  2041     case EEventInteractionRefused:
       
  2042 		{
       
  2043 		if (aControl==iButtonGroupContainer)
       
  2044 			HandleInteractionRefused(0);
       
  2045 		else
       
  2046 			{
       
  2047 			TInt lineId=iPageSelector->LineId(*aControl);
       
  2048 			if (lineId!=KErrNotFound)
       
  2049 				HandleInteractionRefused(lineId);
       
  2050 			}
       
  2051 		}
       
  2052         break;
       
  2053     default:
       
  2054         break;
       
  2055         }
       
  2056     }
       
  2057 
       
  2058 /**
       
  2059  * Set the line which initally receives focus.
       
  2060  * This is the first focusable line on the first page in the
       
  2061  * dialog by default. Reimplementations of this method must
       
  2062  * activate a page before doing anything else.
       
  2063  */
       
  2064 EXPORT_C void CEikDialog::SetInitialCurrentLine()
       
  2065     {
       
  2066 	if ( !iExtension->iInitialMade )
       
  2067 	    {
       
  2068 	    TRAP_IGNORE(iPageSelector->ActivateFirstPageL());
       
  2069 	    }
       
  2070 	if( !iIsEditable )
       
  2071 	    {
       
  2072 	    iPageSelector->SetInitialFocus();
       
  2073 	    }
       
  2074     }
       
  2075 
       
  2076 /**
       
  2077  * Handles a dialog button press for the button with id aButtonId.
       
  2078  * The cancel button press is not passed to the handler unless EEikDialogFlagNotifyEsc
       
  2079  * is set. Returns ETrue if the dialog is ready to exit. Returns ETrue by default.
       
  2080  */
       
  2081 EXPORT_C TBool CEikDialog::OkToExitL(TInt /*aButtonId*/)
       
  2082     {
       
  2083     return ETrue;
       
  2084     }
       
  2085 
       
  2086 /**
       
  2087  * Handles a state change in the control with id aControlId. Empty by default.
       
  2088  */
       
  2089 EXPORT_C void CEikDialog::HandleControlStateChangeL(TInt /*aControlId*/)
       
  2090     {
       
  2091     }
       
  2092 
       
  2093 /**
       
  2094  * Handles an attempt by the user to activate a dimmed button with
       
  2095  * id aControlId. Prints an info message by default.
       
  2096  */
       
  2097 EXPORT_C void CEikDialog::HandleInteractionRefused(TInt /*aControlId*/)
       
  2098     {
       
  2099 	// Does nothing in Avkon
       
  2100     }
       
  2101 
       
  2102 /**
       
  2103  * Adjusts all the ids of controls on the page identified by aPageId by incrementing their
       
  2104  * id values by aControlIdDelta.
       
  2105  */
       
  2106 EXPORT_C void CEikDialog::AdjustAllIdsOnPage(TInt aPageId,TInt aControlIdDelta)
       
  2107 	{
       
  2108 	iPageSelector->AdjustAllIds(aPageId,aControlIdDelta);
       
  2109 	}
       
  2110 
       
  2111 /**
       
  2112  * Makes the panel button identified by aButtonId visible if aVisible is ETrue.
       
  2113  */
       
  2114 EXPORT_C void CEikDialog::MakePanelButtonVisible(TInt aButtonId,TBool aVisible)
       
  2115 	{
       
  2116 	// *** ToDo: Check whether this is only applicable for internal button group containers?
       
  2117 	ButtonGroupContainer().MakeCommandVisible(aButtonId,aVisible);
       
  2118 	}
       
  2119 
       
  2120 /**
       
  2121  * Takes any action required when the active dialog page is changed to aPageId.
       
  2122  * Empty by default.
       
  2123  */
       
  2124 EXPORT_C void CEikDialog::PageChangedL(TInt /*aPageId*/)
       
  2125 	{
       
  2126 	}
       
  2127 
       
  2128 /**
       
  2129  * Takes any action required when the current line is changed to aControlId.
       
  2130  * Empty by default.
       
  2131  *
       
  2132  * @since ER5U
       
  2133  */
       
  2134 EXPORT_C void CEikDialog::LineChangedL(TInt /*aControlId*/)
       
  2135 	{
       
  2136 	}
       
  2137 
       
  2138 /**
       
  2139  * Switches the latent line from aNoLongerLatent to aBecomesLatent. If dialog lines are
       
  2140  * latent they are not visible and are not taken into account when laying out the dialog.
       
  2141  * Latent lines can then be swapped around on the dialog later.
       
  2142  */
       
  2143 EXPORT_C void CEikDialog::SwitchLineLatency(TInt aBecomesLatent,TInt aNoLongerLatent)
       
  2144 	{
       
  2145 	CEikCaptionedControl* becomesLatent=Line(aBecomesLatent);
       
  2146 	CEikCaptionedControl* noLongerLatent=Line(aNoLongerLatent);
       
  2147 #if defined(_DEBUG)
       
  2148 	if (becomesLatent->IsLatent() || !noLongerLatent->IsLatent())
       
  2149 		Panic(EEikDialogPanicWrongLatencySwitch);
       
  2150 #endif
       
  2151 	becomesLatent->SetLatent(ETrue);
       
  2152 	noLongerLatent->SetLatent(EFalse);
       
  2153 	noLongerLatent->CheckDimmedDisplayState();
       
  2154 	}
       
  2155 
       
  2156 /**
       
  2157  * Sets the page identified by aPageId to be dimmed if aDimmmed is ETrue.
       
  2158  */
       
  2159 EXPORT_C void CEikDialog::SetPageDimmedNow(TInt aPageId,TBool aDimmed)
       
  2160 	{
       
  2161 	iPageSelector->SetPageDimmed(aPageId,aDimmed,EDrawNow);
       
  2162 	}
       
  2163 
       
  2164 /**
       
  2165  * Prepares the graphics context aGc for drawing the control in its normal state.
       
  2166  */
       
  2167 EXPORT_C void CEikDialog::PrepareContext(CWindowGc& aGc) const
       
  2168 	{
       
  2169 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  2170 	aGc.SetBrushColor(iEikonEnv->ControlColor(EColorDialogBackground,*this));
       
  2171 	aGc.SetPenColor(iEikonEnv->ControlColor(EColorDialogText,*this));
       
  2172 	}
       
  2173 
       
  2174 /**
       
  2175  * Gets the list of logical colors employed in the drawing of the control,
       
  2176  * paired with an explanation of how they are used. Appends the list to aColorUseList.
       
  2177  *
       
  2178  * @since ER5U
       
  2179  */
       
  2180 EXPORT_C void CEikDialog::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const
       
  2181 	{
       
  2182 	TInt commonAttributes = TCoeColorUse::ESurrounds|TCoeColorUse::EActive|TCoeColorUse::ENormal|TCoeColorUse::ENeutral;
       
  2183 	TCoeColorUse colorUse;
       
  2184 
       
  2185 	colorUse.SetLogicalColor(EColorDialogText);
       
  2186 	colorUse.SetUse(TCoeColorUse::EFore|commonAttributes);
       
  2187 	aColorUseList.AppendL(colorUse);
       
  2188 
       
  2189 	colorUse.SetLogicalColor(EColorDialogBackground);
       
  2190 	colorUse.SetUse(TCoeColorUse::EBack|commonAttributes);
       
  2191 	aColorUseList.AppendL(colorUse);
       
  2192 	}
       
  2193 
       
  2194 /**
       
  2195  * Handles a change to the control's resources of type aType
       
  2196  * which are shared across the environment, e.g. colors or fonts.
       
  2197  *
       
  2198  * @since ER5U
       
  2199  */
       
  2200 EXPORT_C void CEikDialog::HandleResourceChange(TInt aType)
       
  2201     {
       
  2202         
       
  2203     if(aType==KEikDynamicLayoutVariantSwitch)
       
  2204         {
       
  2205         if (IsVisible())
       
  2206 			DoResourceChangeLayout();
       
  2207         else if (iExtension)
       
  2208         	iExtension->iFlags.Set(CEikDialogExtension::ELayoutChangeWhileInvisible);
       
  2209 
       
  2210         CCoeControl::HandleResourceChange(aType);
       
  2211         return;
       
  2212         }
       
  2213     else
       
  2214     	{
       
  2215     	CCoeControl::HandleResourceChange(aType);
       
  2216         }
       
  2217     
       
  2218     if( !CAknEnv::Static()->TransparencyEnabled() && aType==KEikColorResourceChange)
       
  2219         {
       
  2220         Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorDialogBackground,*this));
       
  2221         }
       
  2222     }
       
  2223 
       
  2224 void CEikDialog::DoResourceChangeLayout()
       
  2225 	{
       
  2226     // Layout must be forced through - bypass optimisations
       
  2227     // Must work through all pages
       
  2228     
       
  2229     Layout();
       
  2230     SizeChanged();
       
  2231     
       
  2232     TInt lastPage =  ( iPageSelector->PageContainer()->NumPages() - 1 );
       
  2233     TInt pageIndex = 0;
       
  2234     CEikDialogPage* page;
       
  2235 
       
  2236     while ( pageIndex++ <= lastPage )
       
  2237         {
       
  2238         page = iPageSelector->PageContainer()->Page( pageIndex );
       
  2239         page->HandleResourceChange( KEikDynamicLayoutVariantSwitch );
       
  2240         }
       
  2241 
       
  2242    	if (iExtension)
       
  2243    		iExtension->iFlags.Clear(CEikDialogExtension::ELayoutChangeWhileInvisible);
       
  2244 	}
       
  2245 
       
  2246 /**
       
  2247  * Returns a pointer to the dialog's internal button command observer. This is required when creating a
       
  2248  * new button group container for the dialog.
       
  2249  *
       
  2250  * A dialog uses a proxy to observe button commands. This means dialog subclasses can directly observe
       
  2251  * commands issued by controls added to the dialog pages or by menus launched by the dialog.
       
  2252  *
       
  2253  * @since ER5U
       
  2254  */
       
  2255 EXPORT_C MEikCommandObserver* CEikDialog::ButtonCommandObserver() const
       
  2256 	{
       
  2257 	return (MEikCommandObserver*)iButtonCommandObserver;
       
  2258 	}
       
  2259 
       
  2260 /**
       
  2261  * Writes the internal state of the control and its components to aStream.
       
  2262  * Does nothing in release mode.
       
  2263  * Designed to be overidden and base called by subclasses.
       
  2264  *
       
  2265  * @internal
       
  2266  * @since App-Framework_6.1
       
  2267  */
       
  2268 #ifndef _DEBUG
       
  2269 EXPORT_C void CEikDialog::WriteInternalStateL(RWriteStream&) const
       
  2270 	{}
       
  2271 #else
       
  2272 EXPORT_C void CEikDialog::WriteInternalStateL(RWriteStream& aWriteStream) const
       
  2273 	{
       
  2274 	CEikBorderedControl::WriteInternalStateL(aWriteStream);
       
  2275 	}
       
  2276 #endif
       
  2277 
       
  2278 EXPORT_C void CEikDialog::Reserved_2()
       
  2279 	{}
       
  2280 EXPORT_C void CEikDialog::CEikDialog_Reserved_1()
       
  2281 	{}
       
  2282 EXPORT_C void CEikDialog::CEikDialog_Reserved_2()
       
  2283 	{}
       
  2284 
       
  2285 EXPORT_C void CEikDialog::MakeVisible(TBool aVisible)
       
  2286 	{
       
  2287    	if (iExtension && iExtension->iFlags[CEikDialogExtension::ELayoutChangeWhileInvisible])
       
  2288    		DoResourceChangeLayout();
       
  2289 
       
  2290 	// only for popup dialogs
       
  2291 	if ( aVisible )
       
  2292 	    {
       
  2293     	if (!(iDialogFlags&EEikDialogFlagFillAppClientRect) && !(iDialogFlags&EEikDialogFlagFillScreen) &&
       
  2294             !(iDialogFlags&EEikDialogFlagNoBackgroundFade) 
       
  2295             // FIX for PTPA-7FYFDE: Query Input is also faded
       
  2296             // && !( AknLayoutUtils::PenEnabled() && ( iDialogFlags & EEikDialogFlagVirtualInput ) ) 
       
  2297             )
       
  2298     	    {
       
  2299             AknGlobalPopupPriorityController::FadeBehindPopup(*this, iPopupFader, *this, aVisible);
       
  2300     	    }
       
  2301         }
       
  2302     
       
  2303 	CEikBorderedControl::MakeVisible(aVisible);
       
  2304 
       
  2305 	}
       
  2306 
       
  2307 void CEikDialog::FadeBehindPopup(TBool aFade)
       
  2308 	{
       
  2309 	// record the requested fade state
       
  2310 	if (aFade)
       
  2311 		iDialogFlags |= EEikDialogAttemptFadeWhenVisible;
       
  2312 	else
       
  2313 		iDialogFlags &= ~EEikDialogAttemptFadeWhenVisible;
       
  2314 
       
  2315 	// Attempt to set the fade state to the requested fade state
       
  2316 	DoFadeBehindPopup(aFade);
       
  2317 	}
       
  2318 
       
  2319 void CEikDialog::DoFadeBehindPopup(TBool aFade)
       
  2320 	{
       
  2321 	// Fix for ELWG-7DSEKG: Fullscreen dialogs are now added to the fade stack to allow them
       
  2322 	// to be opened on top of popups. PopupFader makes sure that actual fading does not happen.
       
  2323 	//if ((iDialogFlags&EEikDialogFlagFillAppClientRect) || (iDialogFlags&EEikDialogFlagFillScreen) ||
       
  2324     //    ( iDialogFlags & EEikDialogFlagNoBackgroundFade ) ||
       
  2325     
       
  2326     
       
  2327     // FIX for PTPA-7FYFDE: Query Input is added also to the fade stack 
       
  2328     //if ( AknLayoutUtils::PenEnabled() && ( iDialogFlags & EEikDialogFlagVirtualInput ) ) 
       
  2329 	//	{
       
  2330 	//	return;
       
  2331 	//	}
       
  2332       
       
  2333 	// Real fade state is only set on when the dialog is visible
       
  2334 	if (!IsVisible())
       
  2335 		aFade = EFalse;
       
  2336 	
       
  2337 	AknGlobalPopupPriorityController::FadeBehindPopup(*this, iPopupFader, *this, aFade);
       
  2338 	}
       
  2339 
       
  2340 //
       
  2341 //
       
  2342 //
       
  2343 
       
  2344 /**
       
  2345  * @deprecated
       
  2346  */
       
  2347 EXPORT_C void CEikDialog::GetCustomAutoValue(TAny* /*aReturnValue*/,TInt /*aControlType*/,const CCoeControl* /*aControl*/)
       
  2348 	{
       
  2349 	ASSERT(EFalse);
       
  2350 	}
       
  2351 
       
  2352 /**
       
  2353  *  Routine to map the button id ( Avkon softkey command id) to CEikBidCancel if it is a 
       
  2354  *  "cancel" type command type and to CEikBidOk if it is an "accept" type command
       
  2355  *  Other cases left unchanged
       
  2356  *
       
  2357  * @since Avkon
       
  2358  */
       
  2359 EXPORT_C TInt CEikDialog::MappedCommandId( TInt aButtonId )
       
  2360 	{	
       
  2361 	switch ( aButtonId )
       
  2362 		{
       
  2363 // Do not test for case EEikBidCancel; it is defined to be the same as EAknSoftkeyCancel
       
  2364 		case EAknSoftkeyCancel:
       
  2365 		case EAknSoftkeyBack:
       
  2366 		case EAknSoftkeyNo:
       
  2367 		return EEikBidCancel;
       
  2368 
       
  2369 		default:
       
  2370 		break;
       
  2371 		}
       
  2372 
       
  2373 // Also process user range:
       
  2374 	if ( aButtonId >= EAknSoftkeyLowestUserRejectId 
       
  2375 		&& aButtonId < EAknSoftkeyLowestUserAcceptId )
       
  2376 		return EEikBidCancel;
       
  2377 
       
  2378 	return aButtonId;
       
  2379 	}
       
  2380 
       
  2381 EXPORT_C TInt CEikDialog::FormFlagsFromActivePage()
       
  2382 	{
       
  2383 	TInt activePageNum = ActivePageId();
       
  2384 	if (activePageNum >=0) // not sure of valid range,,,,
       
  2385 		return iPageSelector->PageContainer()->Page(activePageNum)->GetFormFlags();
       
  2386 	return 0;
       
  2387 	}
       
  2388 
       
  2389 /* deprecated method
       
  2390 Instead use 
       
  2391 	TInt GetNumberOfLinesOnPage(TInt aPageIndex) const
       
  2392 	TInt GetNumberOfPages() const
       
  2393 	CEikCaptionedControl* GetLineByLineAndPageIndex(TInt aLineIndex, TInt aPageIndex) const
       
  2394 */
       
  2395 
       
  2396 EXPORT_C CEikCaptionedControl* CEikDialog::GetFirstLineOnFirstPageOrNull()
       
  2397 	{
       
  2398 	if (!iPageSelector)
       
  2399 		return 0;
       
  2400 	if (iPageSelector->PageContainer()->NumPages()>0)
       
  2401 		{
       
  2402 		CEikDialogPage* dPagePtr = iPageSelector->PageContainer()->Page(0);
       
  2403 		CEikCaptionedControl* linePtr = dPagePtr->LineOnPageOrNull(0);
       
  2404 		return linePtr;
       
  2405 		}
       
  2406 	else return 0;
       
  2407 	
       
  2408 	};
       
  2409 
       
  2410 /* deprecated method
       
  2411 Instead use 
       
  2412 	TInt GetNumberOfLinesOnPage(TInt aPageIndex) const
       
  2413 	TInt GetNumberOfPages() const
       
  2414 	CEikCaptionedControl* GetLineByLineAndPageIndex(TInt aLineIndex, TInt aPageIndex) const
       
  2415 */
       
  2416 EXPORT_C void CEikDialog::ControlsOnPage(RArray<CEikCaptionedControl*>& aControls, TInt aPageId) const
       
  2417 	{
       
  2418 	if (!iPageSelector || iPageSelector->PageContainer()->NumPages() < aPageId)
       
  2419 		return;
       
  2420 	
       
  2421 	CEikDialogPage* dlgPage = iPageSelector->PageContainer()->Page(aPageId);
       
  2422 	if (!dlgPage)
       
  2423 		return;
       
  2424 
       
  2425 	TInt i = 0;
       
  2426 	CEikCaptionedControl* control = NULL;
       
  2427 	do
       
  2428 		{
       
  2429 		control = dlgPage->LineOnPageOrNull(i++);
       
  2430 		if (control)
       
  2431 			aControls.Append(control);
       
  2432 		}
       
  2433 		while (control != NULL);
       
  2434 	}
       
  2435 
       
  2436 EXPORT_C TInt CEikDialog::DialogFlags()
       
  2437 	{ 
       
  2438 	return iDialogFlags;
       
  2439 	};
       
  2440 
       
  2441 void CEikDialog::RegisterDialgWithPageSelector()
       
  2442 	{
       
  2443 	if (iPageSelector)
       
  2444 		iPageSelector->SetDialg(this);
       
  2445 	};
       
  2446 
       
  2447 EXPORT_C TTypeUid::Ptr CEikDialog::MopSupplyObject(TTypeUid aId)
       
  2448 	{
       
  2449 	if ( aId.iUid == MAknsControlContext::ETypeId 
       
  2450 		&& Extension() 
       
  2451 		&& ( Extension()->LayoutCategory() == CEikDialogExtension::EFormLayout ) )
       
  2452 		return ( MAknsControlContext::SupplyMopObject( aId, iExtension->iBgContext ) ) ;
       
  2453 
       
  2454     if ( aId.iUid == CAknEdwinDrawingModifier::ETypeId )
       
  2455         if ( Extension() && Extension()->iDrawingModifier )
       
  2456             return aId.MakePtr( Extension()->iDrawingModifier );
       
  2457     
       
  2458     if ( aId.iUid == KAknMediatorFacade && iExtension )
       
  2459         { // we actually don't care if this is set or not
       
  2460         return aId.MakePtr(iExtension->iAknDSSD);
       
  2461         }
       
  2462     if( aId.iUid == CEikScrollBarFrame::ETypeId )
       
  2463     	{
       
  2464     	TInt activePageNum = ActivePageId();
       
  2465 		CEikDialogPage* currentPage = NULL ;
       
  2466 		if ( activePageNum >= 0 ) 
       
  2467 			{
       
  2468 			currentPage = iPageSelector->PageContainer()->Page( activePageNum ) ;
       
  2469     		currentPage->SetScbState(ETrue);
       
  2470 			}
       
  2471     	return aId.MakePtr(iPageSelector->PageContainer()->ScrollBar());
       
  2472     	}
       
  2473     	
       
  2474     if ( aId.iUid == CEikDialog::ETypeId )
       
  2475         {
       
  2476         return aId.MakePtr( this );
       
  2477         }
       
  2478 
       
  2479 	return SupplyMopObject(aId, iButtonGroupContainer);
       
  2480 	}
       
  2481 
       
  2482 
       
  2483 EXPORT_C TInt CEikDialog::CountFadedComponents()
       
  2484 	{
       
  2485 	// Don't count the CBA if it contains no commands, since
       
  2486 	// we don't want it to be unfaded.
       
  2487 	CCoeControl* cba = iButtonGroupContainer->ButtonGroup()->AsControl();
       
  2488     TBool fadeCba = static_cast<CEikCba*>( cba )->IsEmpty();
       
  2489 	return fadeCba ? 1 : 2;
       
  2490 	}
       
  2491 
       
  2492 EXPORT_C CCoeControl* CEikDialog::FadedComponent(TInt aIndex)
       
  2493 	{
       
  2494 	switch (aIndex)
       
  2495 		{
       
  2496 		case 0:
       
  2497 			return this;
       
  2498 		case 1:
       
  2499 			return iButtonGroupContainer;
       
  2500 		default:
       
  2501 			return NULL;
       
  2502 		}
       
  2503 	}
       
  2504 
       
  2505 EXPORT_C void CEikDialog::UpdatePageL(TBool aRedraw)
       
  2506 	{
       
  2507 	if (Rect().Height())
       
  2508 		{
       
  2509 		if (iPageSelector)
       
  2510 			if (iPageSelector->IsForm())
       
  2511 				if (iPageSelector->PageContainer())
       
  2512 					{
       
  2513 					iPageSelector->PageContainer()->SetEditableL(iIsEditable);
       
  2514 					if (CurrentLine())
       
  2515 						TryChangeFocusToL(CurrentLine()->iId);
       
  2516 					if (aRedraw)
       
  2517 						DrawDeferred();
       
  2518 					}
       
  2519 		}
       
  2520 	}
       
  2521 
       
  2522 
       
  2523 EXPORT_C TInt CEikDialog::GetNumberOfLinesOnPage(TInt aPageIndex) const
       
  2524 	{
       
  2525 	if (iPageSelector)
       
  2526 		{
       
  2527 		CEikDialogPageContainer* pageContainer = iPageSelector->PageContainer();
       
  2528 		if (pageContainer)
       
  2529 			{
       
  2530 			CEikDialogPage* page = pageContainer->Page(aPageIndex);
       
  2531 			if (page)
       
  2532 				return page->NumberOfLines();
       
  2533 			}
       
  2534 		}
       
  2535 	return 0;
       
  2536 	}
       
  2537 
       
  2538 EXPORT_C TInt CEikDialog::GetNumberOfPages() const
       
  2539 	{
       
  2540 	if (iPageSelector)
       
  2541 		{
       
  2542 		CEikDialogPageContainer* pageContainer = iPageSelector->PageContainer();
       
  2543 		if (pageContainer)
       
  2544 			return pageContainer->NumPages();
       
  2545 		}
       
  2546 	return 0;
       
  2547     }
       
  2548     
       
  2549 //--------------------------------------------------------------------------------
       
  2550 // CEikDialog::HandleDialogPageEventL(TInt aEventID) 
       
  2551 // Handles dialog page events by closing dialog when event is EDialogPageTapped
       
  2552 // and dialog has flag EEikDialogFlagCloseDialogWhenTapped
       
  2553 //--------------------------------------------------------------------------------
       
  2554 //
       
  2555 EXPORT_C void CEikDialog::HandleDialogPageEventL(TInt aEventID )       
       
  2556 	{
       
  2557 	// If event is EDialogPageTapped and flag EEikDialogFlagCloseDialogWhenTapped is on
       
  2558 	if ( (aEventID == MEikDialogPageObserver::EDialogPageTapped) && 
       
  2559 	     (iDialogFlags & EEikDialogFlagCloseDialogWhenTapped) )
       
  2560 	    {	    
       
  2561 	    // Exit from dialog with cancel.
       
  2562 	    TryExitL(EEikBidCancel);
       
  2563 	    }
       
  2564 	}
       
  2565 
       
  2566 EXPORT_C CEikCaptionedControl* CEikDialog::GetLineByLineAndPageIndex(TInt aLineIndex, TInt aPageIndex) const
       
  2567 	{
       
  2568 	if (iPageSelector)
       
  2569 		{
       
  2570 		CEikDialogPageContainer* pageContainer = iPageSelector->PageContainer();
       
  2571 		if (pageContainer)
       
  2572 			{
       
  2573 			CEikDialogPage* page = pageContainer->Page(aPageIndex);
       
  2574 			if (page)
       
  2575 				return page->LineByIndex(aLineIndex);
       
  2576 			}
       
  2577 		}
       
  2578 	return 0;
       
  2579 	}
       
  2580 
       
  2581 EXPORT_C CEikDialogExtension* CEikDialog::Extension() const
       
  2582 	{
       
  2583 	return iExtension ;
       
  2584 	}
       
  2585 
       
  2586 CEikDialogExtension* CEikDialogExtension::NewL( const CEikDialog& aParent ) // static 
       
  2587 	{
       
  2588 	CEikDialogExtension* self = new (ELeave) CEikDialogExtension( aParent ) ;
       
  2589 	CleanupStack::PushL( self ) ;
       
  2590     self->ConstructL();
       
  2591 	CleanupStack::Pop( self ) ;
       
  2592 	return self ;
       
  2593 	}
       
  2594 
       
  2595 CEikDialogExtension::CEikDialogExtension( const CEikDialog& aParent ) : 
       
  2596     CActive( EPriorityLow ),
       
  2597     iParent( aParent )
       
  2598 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
  2599     , iRegisteredContext( KNullUid )
       
  2600 #endif
       
  2601 	{
       
  2602 	}
       
  2603 
       
  2604 CEikDialogExtension::~CEikDialogExtension() 
       
  2605 	{
       
  2606 	if ( IsActive() )
       
  2607 	    {
       
  2608 	    Cancel();
       
  2609 	    }
       
  2610     delete iAknDSSD; // will cancel commands if active
       
  2611 	delete iBgContext ;
       
  2612     delete iDrawingModifier ;
       
  2613 	}
       
  2614 
       
  2615 void CEikDialogExtension::ConstructL()
       
  2616     {
       
  2617 	// <SKIN> create iBgContext
       
  2618     iBgContext = CAknsListBoxBackgroundControlContext::NewL( 
       
  2619         KAknsIIDQsnBgAreaMainListGene, iParent.Rect(), ETrue,
       
  2620         KAknsIIDQsnBgColumnAB, iParent.Rect() )  ; // Last two parameters are effectively place-holders	
       
  2621     iDrawingModifier = new (ELeave )CAknEdwinDrawingModifier();
       
  2622     iDrawingModifier->SetInhibitNotifyNewFormatDrawing( ETrue );
       
  2623     CActiveScheduler::Add( this );
       
  2624     }
       
  2625 
       
  2626 EXPORT_C CEikDialogExtension::TLayoutCategory CEikDialogExtension::LayoutCategory() const
       
  2627 	{
       
  2628 	TLayoutCategory type = EUnknownLayout;
       
  2629 	if ( !iParent.iPageSelector )
       
  2630 		type = ENotConstructed;
       
  2631 	else if ( iParent.iPageSelector->IsForm() )
       
  2632 		type = EFormLayout;
       
  2633 	else if ( (iParent.iDialogFlags)&EEikDialogFlagFillAppClientRect ) // full screen but not Form
       
  2634 		type = EFullScreenLayout;
       
  2635 	else 
       
  2636 		type = EPopupLayout; // ends up being the default. 
       
  2637 
       
  2638 	return type;
       
  2639 	}
       
  2640 
       
  2641 #if (defined(__COVER_DISPLAY) || defined(__VOICE_UI ) )   
       
  2642 
       
  2643 EXPORT_C void CEikDialog::PublishDialogL(TInt aDialogIndex, TUid aCatUid)
       
  2644     {
       
  2645     // create utility for these someday perhaps..
       
  2646     if (!iExtension)
       
  2647         {
       
  2648         iExtension = CEikDialogExtension::NewL( *this );
       
  2649         }
       
  2650     if (!iExtension->iAknDSSD)
       
  2651         {
       
  2652         iExtension->iAknDSSD = CAknMediatorFacade::NewL(this);
       
  2653         }
       
  2654     else // just in case, if someone changes the indeces while previous commands active
       
  2655         {
       
  2656         CancelMediatorCommand(this); // handles flagging  
       
  2657         }
       
  2658     
       
  2659     iExtension->iAknDSSD->CatUid() = aCatUid;
       
  2660     iExtension->iAknDSSD->DialogIndex() = aDialogIndex;
       
  2661     iExtension->iAknDSSD->ResetBuffer();
       
  2662     }	
       
  2663 	
       
  2664 EXPORT_C void CEikDialog::SetMediatorObserver(MAknDialogMediatorObserver* aObserver)
       
  2665     {
       
  2666     if (!iExtension)
       
  2667         {
       
  2668         iExtension = CEikDialogExtension::NewL( *this );
       
  2669         }
       
  2670     if (!iExtension->iAknDSSD)
       
  2671         {
       
  2672         iExtension->iAknDSSD = CAknMediatorFacade::NewL(this);
       
  2673         }
       
  2674 
       
  2675     iExtension->iAknDSSD->SetObserver(aObserver);    
       
  2676     }
       
  2677 #else
       
  2678 EXPORT_C void CEikDialog::PublishDialogL(TInt, TUid) {}
       
  2679 EXPORT_C void CEikDialog::SetMediatorObserver(MAknDialogMediatorObserver*){}
       
  2680 #endif
       
  2681 
       
  2682 void CEikDialogExtension::DoCancel()
       
  2683     {    
       
  2684     }
       
  2685 
       
  2686 void CEikDialogExtension::RunL()
       
  2687     {
       
  2688     const_cast<CEikDialog&>( iParent ).TryExitL( iButtonId );
       
  2689     }
       
  2690 
       
  2691 void CEikDialogExtension::StartDelayedExit()
       
  2692     {
       
  2693     if (!IsActive())
       
  2694         {
       
  2695         TRequestStatus* status = &iStatus;
       
  2696         User::RequestComplete( status, KErrNone );
       
  2697         SetActive();    	
       
  2698         }
       
  2699     }
       
  2700     
       
  2701 // -----------------------------------------------------------------------------
       
  2702 // CAknToolbar::SlideToolbar
       
  2703 // Draws the toolbar with sliding effect.
       
  2704 // -----------------------------------------------------------------------------
       
  2705 //    
       
  2706 EXPORT_C void CEikDialog::SlideDialog()
       
  2707     {
       
  2708 #ifdef RD_SLIDING_ANIMATION_EFFECTS
       
  2709 	TBool useScreenBitmap = EFalse;
       
  2710 	TBool useFrameBitmap = EFalse;
       
  2711 
       
  2712     CFbsBitmap* screenCapture;
       
  2713     CFbsBitmap* frameBitmap;
       
  2714 	
       
  2715     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  2716 	    
       
  2717 	TInt slidingMode = AknsDrawUtils::SlidingMode(skin);
       
  2718 
       
  2719     TPoint startPos = Position();
       
  2720     TRect origRect(Position(),Rect().Size());
       
  2721         
       
  2722     const TSize screenSize = iEikonEnv->EikAppUi()->ApplicationRect().Size();
       
  2723 
       
  2724     // Try to copy screen to backup bitmap
       
  2725     iCoeEnv->WsSession().Flush(); // first update screen (not necessary?)
       
  2726     CWsScreenDevice* scrDevice = static_cast<CWsScreenDevice*>( SystemGc().Device() );
       
  2727     TDisplayMode displayMode( scrDevice->DisplayMode() );
       
  2728 
       
  2729     RWsSession& wsSession = CCoeEnv::Static()->WsSession();
       
  2730 
       
  2731 	TRAPD( SCerr, screenCapture = new (ELeave) CWsBitmap( wsSession ) );
       
  2732     
       
  2733     TInt errCode( KErrNone );
       
  2734     if (SCerr == KErrNone)
       
  2735         {
       
  2736         errCode = screenCapture->Create( screenSize, displayMode );
       
  2737         }
       
  2738         
       
  2739     if (errCode == KErrNone)
       
  2740         {
       
  2741         errCode = scrDevice->CopyScreenToBitmap( screenCapture );
       
  2742         }
       
  2743     
       
  2744     if (errCode == KErrNone)
       
  2745         {
       
  2746         useScreenBitmap = ETrue;
       
  2747         }
       
  2748 
       
  2749 
       
  2750     // Try to draw skin frame to offscreen bitmap
       
  2751     CFbsBitGc* fbsBitGc( NULL );
       
  2752     CFbsBitmapDevice* bmpDevice( NULL );
       
  2753     TRAPD(FBerr, 
       
  2754             { 
       
  2755             frameBitmap = new (ELeave) CFbsBitmap( );
       
  2756             CleanupStack::PushL(frameBitmap);
       
  2757             User::LeaveIfError( frameBitmap->Create( Rect().Size(), displayMode ) );
       
  2758             bmpDevice = CFbsBitmapDevice::NewL( frameBitmap );
       
  2759             CleanupStack::PushL( bmpDevice );
       
  2760                 
       
  2761             fbsBitGc = CFbsBitGc::NewL();
       
  2762             CleanupStack::PushL( fbsBitGc );
       
  2763             
       
  2764             fbsBitGc->Activate( bmpDevice );
       
  2765             CleanupStack::Pop(3);
       
  2766             }  
       
  2767         );
       
  2768     
       
  2769     if ( iExtension->LayoutCategory() == CEikDialogExtension::EPopupLayout && FBerr == KErrNone)
       
  2770         {
       
  2771         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  2772 
       
  2773         TAknLayoutRect topLeft;
       
  2774         topLeft.LayoutRect(Rect(), SkinLayout::Popup_windows_skin_placing__frame_general__Line_2());
       
  2775 
       
  2776         TAknLayoutRect bottomRight;
       
  2777     	bottomRight.LayoutRect(Rect(), SkinLayout::Popup_windows_skin_placing__frame_general__Line_5());
       
  2778 
       
  2779         TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
       
  2780         TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
       
  2781     
       
  2782         useFrameBitmap = ETrue;
       
  2783         if (!AknsDrawUtils::DrawFrame( skin, *fbsBitGc, outerRect, innerRect,
       
  2784 						KAknsIIDQsnFrPopup,KAknsIIDQsnFrPopupCenter) )
       
  2785             {
       
  2786             useFrameBitmap = EFalse;
       
  2787             }
       
  2788         else
       
  2789             {
       
  2790             useFrameBitmap = ETrue;
       
  2791             }
       
  2792         }
       
  2793 
       
  2794 
       
  2795     CEikDialogSlider* slider = NULL;
       
  2796     TRAPD( sliderErr, slider = slider->NewL(SystemGc(),frameBitmap,screenCapture ));
       
  2797 
       
  2798     // sliding from the softkey direction
       
  2799     if (slidingMode == ESlidingFromCBA)
       
  2800         {
       
  2801 	    AknLayoutUtils::TAknCbaLocation location = AknLayoutUtils::CbaLocation();
       
  2802         switch(location)
       
  2803             {
       
  2804             case AknLayoutUtils::EAknCbaLocationRight:
       
  2805                 slidingMode = ESlidingFromRight;
       
  2806                 break;
       
  2807             case AknLayoutUtils::EAknCbaLocationLeft:
       
  2808                 slidingMode = ESlidingFromLeft;
       
  2809                 break;
       
  2810             case AknLayoutUtils::EAknCbaLocationBottom:
       
  2811                 slidingMode = ESlidingFromBottom;
       
  2812                 break;
       
  2813             default:
       
  2814                 slidingMode = ESlidingFromBottom;
       
  2815                 break;
       
  2816             }
       
  2817         }
       
  2818 
       
  2819 
       
  2820     // don't use math-library (one less dependency)
       
  2821     if (slidingMode == ESlidingFromRandom)
       
  2822         {
       
  2823         TTime homeTime;
       
  2824         homeTime.HomeTime();
       
  2825         TInt64 seed = homeTime.Int64();
       
  2826         TInt value = seed & 0xff;
       
  2827         value = value >> 5; // take bits 5-7
       
  2828         slidingMode = ESlidingFromLeft + value;
       
  2829         }
       
  2830         
       
  2831     switch(slidingMode)
       
  2832     	{
       
  2833     	case ESlidingFromLeft:
       
  2834             startPos.iX = 0 - origRect.Size().iWidth; // just out of screen
       
  2835             break;
       
  2836 
       
  2837     	case ESlidingFromTopLeft:
       
  2838             startPos.iX = 0 - origRect.Size().iWidth;
       
  2839             startPos.iY = 0 - origRect.Size().iHeight;
       
  2840             break;
       
  2841 
       
  2842     	case ESlidingFromTop:
       
  2843             startPos.iY = 0 - origRect.Size().iHeight;
       
  2844             break;
       
  2845 
       
  2846     	case ESlidingFromTopRight:
       
  2847             startPos.iX = screenSize.iWidth;
       
  2848             startPos.iY = 0 - origRect.Size().iHeight;
       
  2849             break;
       
  2850 
       
  2851         case ESlidingFromRight:
       
  2852             startPos.iX = screenSize.iWidth;
       
  2853             break;
       
  2854 
       
  2855        	case ESlidingFromBottomRight:
       
  2856             startPos.iX = screenSize.iWidth;
       
  2857             startPos.iY = screenSize.iHeight;
       
  2858             break;
       
  2859 
       
  2860        	case ESlidingFromBottom:
       
  2861             startPos.iY = screenSize.iHeight;
       
  2862             break;
       
  2863 
       
  2864        	case ESlidingFromBottomLeft:
       
  2865             startPos.iX = 0 - origRect.Size().iWidth;
       
  2866             startPos.iY = screenSize.iHeight;
       
  2867             break;
       
  2868     
       
  2869         default:
       
  2870             break;
       
  2871     	}
       
  2872 
       
  2873     TPoint start = startPos;
       
  2874     
       
  2875     TInt stepCount = 12;
       
  2876         
       
  2877     //iCoeEnv->WsSession().Flush();
       
  2878     
       
  2879     // only do sliding if we have screen capture, dialog background in bitmap and slider
       
  2880     // otherwise we have OOM and do no sliding
       
  2881     if (useScreenBitmap && useFrameBitmap && sliderErr == KErrNone)
       
  2882         {
       
  2883         TRAP_IGNORE(slider->SlideDialogL(start, origRect.iTl, stepCount));
       
  2884         }
       
  2885     
       
  2886     //TRAP_IGNORE(ActivateL()); // do we need to do this before slider is deleted?
       
  2887     
       
  2888     if (slider)
       
  2889         {
       
  2890         delete slider;
       
  2891         slider = NULL;
       
  2892         }
       
  2893     
       
  2894 	if (SCerr == KErrNone)
       
  2895 	    {
       
  2896     	delete screenCapture;	    
       
  2897 	    }
       
  2898 	    
       
  2899 	if (FBerr == KErrNone)
       
  2900 	    {
       
  2901 	    delete bmpDevice;
       
  2902 	    delete fbsBitGc;
       
  2903 	    delete frameBitmap;
       
  2904 	    }
       
  2905 #endif //RD_SLIDING_ANIMATION_EFFECTS
       
  2906     }
       
  2907     
       
  2908 #ifdef RD_SLIDING_ANIMATION_EFFECTS
       
  2909 CEikDialogSlider::CEikDialogSlider(CWindowGc& aWindowGc, CFbsBitmap*& aDialogBack, CFbsBitmap*& aScreen)
       
  2910 :iWindowGc(aWindowGc), iDialogBack(aDialogBack), iScreen(aScreen)
       
  2911 	{
       
  2912 	}
       
  2913 	
       
  2914 
       
  2915 CEikDialogSlider* CEikDialogSlider::NewL(CWindowGc& aWindowGc, CFbsBitmap*& aDialogBack, CFbsBitmap*& aScreen)
       
  2916 	{
       
  2917 	CEikDialogSlider* self = new(ELeave)CEikDialogSlider(aWindowGc, aDialogBack, aScreen);
       
  2918 	CleanupStack::PushL(self);
       
  2919 	self->ConstructL();
       
  2920 	CleanupStack::Pop();
       
  2921 	return self;
       
  2922 	}
       
  2923 
       
  2924 
       
  2925 void CEikDialogSlider::ConstructL()
       
  2926 	{
       
  2927     const TSize screenSize = iEikonEnv->EikAppUi()->ApplicationRect().Size();
       
  2928 	
       
  2929 	CreateWindowL();
       
  2930     SetExtent( TPoint(0,0), screenSize);
       
  2931 	}
       
  2932 	
       
  2933 CEikDialogSlider::~CEikDialogSlider()
       
  2934 	{
       
  2935 	}
       
  2936 
       
  2937 void CEikDialogSlider::Draw(const TRect& /* aRect */) const
       
  2938     {
       
  2939     // only SlideDialog does drawing
       
  2940     }
       
  2941     
       
  2942     
       
  2943 void CEikDialogSlider::SlideDialogL(TPoint& aStart, TPoint& aEnd, TInt aStepCount)
       
  2944 	{
       
  2945 	ActivateL();
       
  2946 	
       
  2947     TInt stepX = ( aEnd.iX - aStart.iX ) / aStepCount;
       
  2948     TInt stepY = ( aEnd.iY - aStart.iY ) / aStepCount;
       
  2949     TSize dialogSize = iDialogBack->SizeInPixels();	
       
  2950     TSize ScreenSize = iScreen->SizeInPixels();
       
  2951     TPoint oldPos;
       
  2952     TRect vertiRect; // these are used to restore background under slided dialog
       
  2953     TRect horizRect;
       
  2954 	
       
  2955 	// Because of rounding error, endpoint from sliding is not same as aEnd.
       
  2956 	// To correct this, adjust startpoint.
       
  2957 	aStart.iX = aEnd.iX - aStepCount * stepX;
       
  2958 	aStart.iY = aEnd.iY - aStepCount * stepY;
       
  2959 	
       
  2960 	// slide all but last frame
       
  2961     for (TInt i=0 ; i < aStepCount ; i++)
       
  2962         {
       
  2963         oldPos = aStart;
       
  2964         aStart.iX += stepX;
       
  2965         aStart.iY += stepY;
       
  2966         ActivateGc();
       
  2967         Window().Invalidate( );
       
  2968         Window().BeginRedraw( ); // this flushes window server
       
  2969         
       
  2970         TRect dlgRect(aStart,dialogSize);
       
  2971         
       
  2972         iWindowGc.BitBlt(dlgRect.iTl, iDialogBack);
       
  2973 
       
  2974         if (stepX < dlgRect.Width() && stepY < dlgRect.Height()) // old and new rects are intersecting
       
  2975             {
       
  2976             if (stepY > 0) // dialog moving down, restore area from top of dialog
       
  2977                 {
       
  2978                 vertiRect = TRect(dlgRect.iTl.iX - stepX,
       
  2979                                   dlgRect.iTl.iY - stepY,
       
  2980                                   dlgRect.iBr.iX - stepX,
       
  2981                                   dlgRect.iTl.iY);
       
  2982                 horizRect.iTl.iY = dlgRect.iTl.iY;
       
  2983                 horizRect.iBr.iY = dlgRect.iBr.iY - stepY;
       
  2984                 }
       
  2985             else if (stepY < 0) // moving up
       
  2986                 {
       
  2987                 vertiRect = TRect(dlgRect.iTl.iX - stepX,
       
  2988                                  dlgRect.iBr.iY,
       
  2989                                  dlgRect.iBr.iX - stepX,
       
  2990                                  dlgRect.iBr.iY - stepY);
       
  2991                 horizRect.iTl.iY = dlgRect.iTl.iY - stepY;
       
  2992                 horizRect.iBr.iY = dlgRect.iBr.iY;
       
  2993                 }
       
  2994 
       
  2995             if (stepX > 0) // dialog moving right, restore area from left of dialog
       
  2996                 {
       
  2997                 horizRect.iTl.iX = dlgRect.iTl.iX - stepX;
       
  2998                 horizRect.iBr.iX = dlgRect.iTl.iX;
       
  2999                 }
       
  3000             else if (stepX < 0) // moving left
       
  3001                 {
       
  3002                 horizRect.iTl.iX = dlgRect.iBr.iX;
       
  3003                 horizRect.iBr.iX = dlgRect.iBr.iX - stepX;
       
  3004                 }
       
  3005                 
       
  3006             if (stepX != 0 && stepY == 0) // set y-coordinates if only moving horizontally
       
  3007             	{
       
  3008             	horizRect.iTl.iY = dlgRect.iTl.iY;
       
  3009             	horizRect.iBr.iY = dlgRect.iBr.iY;
       
  3010             	}
       
  3011 
       
  3012             iWindowGc.BitBlt(vertiRect.iTl,iScreen,vertiRect);
       
  3013             iWindowGc.BitBlt(horizRect.iTl,iScreen,horizRect);
       
  3014             }
       
  3015         else // old and new rects are not intersecting -> clear under old rect
       
  3016             {
       
  3017             TRect oldRect(oldPos,dialogSize);
       
  3018             iWindowGc.BitBlt(oldPos,iScreen,oldRect);
       
  3019             }
       
  3020             
       
  3021         Window().EndRedraw();            
       
  3022         DeactivateGc();
       
  3023 
       
  3024         iCoeEnv->WsSession().Flush();
       
  3025         User::After(2000); // give little time to active objects
       
  3026         }
       
  3027 	}
       
  3028 #endif //RD_SLIDING_ANIMATION_EFFECTS
       
  3029 
       
  3030 EXPORT_C void CEikDialog::SetMultilineQuery(TBool aIsMultilineQuery)
       
  3031 	{
       
  3032 	if (iPageSelector)
       
  3033 		{
       
  3034 		CEikDialogPageContainer* pageContainer = iPageSelector->PageContainer();
       
  3035 		if (pageContainer)
       
  3036 			{
       
  3037 			CEikDialogPage* page = pageContainer->Page(0);
       
  3038 			if (page)
       
  3039 				page->SetDoubleQuery(aIsMultilineQuery);
       
  3040 			}
       
  3041 		}
       
  3042 
       
  3043 	}
       
  3044     
       
  3045 
       
  3046 void CEikDialog::HandleEmbeddedSofkeyStateChange()
       
  3047     {
       
  3048     // Check that dialog is constructed and actually with embedded
       
  3049     // softkeys
       
  3050     if ( iExtension && CbaEmbeddedInDialog( iDialogFlags ) )
       
  3051         {
       
  3052         TSize dialogSize( Rect().Size() );
       
  3053         CEikCba* cba = static_cast<CEikCba*>(
       
  3054                 iButtonGroupContainer->ButtonGroup() );
       
  3055         TBool cbaVisible( cba->IsVisible() && !cba->IsEmpty() );
       
  3056 
       
  3057         TRect screenRect;
       
  3058         AknLayoutUtils::LayoutMetricsRect(
       
  3059             AknLayoutUtils::EScreen, screenRect );
       
  3060         TAknLayoutRect cbaRect;
       
  3061         cbaRect.LayoutRect(
       
  3062             screenRect, 
       
  3063             AknLayoutScalable_Avkon::popup_sk_window( 0 ).LayoutLine() );
       
  3064         
       
  3065         if ( cbaVisible )
       
  3066             {
       
  3067             if ( dialogSize.iHeight == MinimumSize().iHeight )
       
  3068                 {
       
  3069                 dialogSize.iHeight += cbaRect.Rect().Height();
       
  3070                 }
       
  3071             }
       
  3072         else
       
  3073             {
       
  3074             dialogSize.iHeight -= cbaRect.Rect().Height();
       
  3075             }
       
  3076 
       
  3077         SetRect( TRect(
       
  3078             AknPopupUtils::Position( dialogSize, this ), dialogSize ) );
       
  3079         }
       
  3080     }
       
  3081 
       
  3082 
       
  3083 TInt CEikDialog::HandleEmbeddedSoftkeyStateChangeCallBack( TAny* aAny )
       
  3084     {
       
  3085     CEikDialog* self = static_cast<CEikDialog*>( aAny );
       
  3086     self->HandleEmbeddedSofkeyStateChange();
       
  3087     return KErrNone;
       
  3088     }
       
  3089 
       
  3090 
       
  3091 void CEikDialog::EnableContentObserver( TBool aEnabled )
       
  3092     {
       
  3093     // Content observer is only used with embedded softkeys.
       
  3094     if ( !CbaEmbeddedInDialog( iDialogFlags ) )
       
  3095         {
       
  3096         return;
       
  3097         }
       
  3098  
       
  3099     // Set observer call back.
       
  3100     TCallBack callBack;
       
  3101     callBack.iPtr = NULL;
       
  3102     
       
  3103     if ( aEnabled )
       
  3104         {
       
  3105         callBack = TCallBack(
       
  3106             HandleEmbeddedSoftkeyStateChangeCallBack, this );
       
  3107         }
       
  3108     
       
  3109     if ( iButtonGroupContainer && iButtonGroupContainer->ButtonGroup() )
       
  3110         {
       
  3111         CCoeControl* control = iButtonGroupContainer->ButtonGroup()->AsControl();
       
  3112         CEikCba* cba = static_cast<CEikCba*>( control );
       
  3113         if ( cba )
       
  3114             {
       
  3115             AknCbaContentObserver::SetContentObserver( cba, callBack );
       
  3116             }
       
  3117         }
       
  3118     }
       
  3119 
       
  3120 
       
  3121 // Checking if the blank screen is being displayed.
       
  3122 // If so, the blank screen will cover everything.
       
  3123 const TInt KWgPriorityOfBlankScreen = 10000; // copied from akncapserverentry.cpp
       
  3124 TBool IsBlankScreenDisplayed()
       
  3125     {
       
  3126     TBool isBlankScreenDisplayed(EFalse);
       
  3127     RWsSession& wsSession = CEikonEnv::Static()->WsSession();
       
  3128     
       
  3129     CArrayFixFlat<TInt> *wgIds = new CArrayFixFlat<TInt>(2);
       
  3130     if (wgIds != NULL)
       
  3131         {
       
  3132         if (KErrNone == wsSession.WindowGroupList(wgIds) && wgIds->Count() > 0)
       
  3133             {
       
  3134             TInt priority = wsSession.GetWindowGroupOrdinalPriority(wgIds->At(0));
       
  3135             RDebug::Printf("IsBlankScreenDisplayed():priority:%d",priority);
       
  3136             if (priority == KWgPriorityOfBlankScreen)
       
  3137                 {
       
  3138                 isBlankScreenDisplayed = ETrue;
       
  3139                 }
       
  3140             }
       
  3141         }
       
  3142     delete wgIds;
       
  3143     RDebug::Printf("IsBlankScreenDisplayed():isBlankScreenDisplayed:%d",isBlankScreenDisplayed);
       
  3144     return isBlankScreenDisplayed;
       
  3145     }
       
  3146