uifw/uiklaf/src/lafenv.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1997-1999 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 
       
    20 #include <uiklaf/private/lafenv.h>
       
    21 #include <lafpanic.h>
       
    22 #include "LAFSTD.H"
       
    23 #include <barsread.h>
       
    24 #include <w32std.h>
       
    25 #include <gulutil.h>
       
    26 #include <coemain.h>
       
    27 #include <eikpriv.rsg>
       
    28 #include <aknborders.h>
       
    29 #include "lafAknBorders.h"
       
    30 
       
    31 #include <AknUtils.h>
       
    32 #include <eikenv.h>
       
    33 
       
    34 #include <bautils.h>
       
    35 #include <aknnotewrappers.h>
       
    36 #include <fontids.hrh>
       
    37 #include <gulfont.h>
       
    38 #include <uiklaf/private/lafmsg.h>
       
    39 
       
    40 #include <AknFontIdLayoutFont.h>
       
    41 #include <AknSystemFont.h>
       
    42 #include <AknFontId.h>
       
    43 #include <aknlayoutscalable_avkon.cdl.h> // Scalable layout API
       
    44 #include <AknFontProvider.h>
       
    45 
       
    46 const TUint EKeyDefault = EKeyDelete;	//setup as EKeyF11 (#defined in E32Keys.h)
       
    47 const TInt KLafShadowHeight = 3;
       
    48 const TInt KLafEnvDefaultLineSpacingInTwips = 158;
       
    49 const TInt KDefaultFontIndex = 0;
       
    50 
       
    51 _LIT(KRDSupport, "c:\\resource\\errrd" );
       
    52 _LIT(KAknFirstStartedAppThreadName, "akncapserver");
       
    53 
       
    54 const TUint8 KLogicalToAvkonColorMap[] =
       
    55 	{
       
    56 	0,		// EEikColorWindowBackground
       
    57 	215,	// EEikColorWindowText
       
    58 	0,		// EEikColorControlBackground
       
    59 	215,	// EEikColorControlText
       
    60 	0,		// EEikColorControlSurroundBackground
       
    61 	215,	// EEikColorControlSurroundText
       
    62 	244,	// EEikColorControlHighlightBackground
       
    63 	215,	// EEikColorControlHighlightText
       
    64 	0,		// EEikColorControlDimmedBackground
       
    65 	215,	// EEikColorControlDimmedText
       
    66 	244,	// EEikColorControlDimmedHighlightBackground
       
    67 	215,	// EEikColorControlDimmedHighlightText
       
    68 	0,		// EEikColorDialogBackground
       
    69 	215,	// EEikColorDialogText
       
    70 	0,		// EEikColorDialogTitle
       
    71 	0,		// EEikColorDialogTitlePressed
       
    72 	215,	// EEikColorDialogTitleText
       
    73 	215,	// EEikColorDialogTitleTextPressed
       
    74 	0,		// EEikColorMenubarBackground
       
    75 	215,	// EEikColorMenubarText
       
    76 	0,		// EEikColorMenubarTitleBackground
       
    77 	215,	// EEikColorMenubarTitleText
       
    78 	0,		// EEikColorMenuPaneBackground
       
    79 	215,	// EEikColorMenuPaneText
       
    80 	244,	// EEikColorMenuPaneHighlight
       
    81 	215,	// EEikColorMenuPaneTextHighlight
       
    82 	244,	// EEikColorMenuPaneDimmedHighlight
       
    83 	215,	// EEikColorMenuPaneDimmedText
       
    84 	244,	// EEikColorMenuPaneDimmedTextHighlight
       
    85 	43,		// EEikColorButtonFaceClear
       
    86 	0,		// EEikColorButtonFaceSet
       
    87 	43,		// EEikColorButtonFaceSetPressed
       
    88 	0,		// EEikColorButtonFaceClearPressed
       
    89 	215,	// EEikColorButtonText
       
    90 	215,	// EEikColorButtonTextPressed
       
    91 	222,	// EEikColorButtonTextDimmed
       
    92 	215,	// EEikColorMsgWinForeground
       
    93 	244,	// EEikColorMsgWinBackground
       
    94 	215,	// EEikColorScrollBarBorder
       
    95 	0,		// EEikColorScrollBarShaft
       
    96 	0,		// EEikColorScrollBarShaftDimmed
       
    97 	222,	// EEikColorScrollBarShaftPressed
       
    98 	0,		// EEikColorScrollBarNoShaftOrThumb
       
    99 	215,	// EEikColorScrollButtonIcon
       
   100 	215,	// EEikColorScrollButtonIconPressed
       
   101 	222,	// EEikColorScrollButtonIconDimmed
       
   102 	43,		// EEikColorScrollButtonThumbBackground
       
   103 	0,		// EEikColorScrollButtonThumbBackgroundPressed
       
   104 	216,	// EEikColorScrollThumbDimmed
       
   105 	215,	// EEikColorScrollThumbEdge
       
   106 	0,		// EEikColorToolbarBackground
       
   107 	215,	// EEikColorToolbarText
       
   108 	0,		// EEikColorStatusPaneBackground
       
   109 	215,	// EEikColorStatusPaneText
       
   110 	215,	// EEikColorLabelText
       
   111 	215,	// EEikColorLabelTextEmphasis
       
   112 	222,	// EEikColorLabelDimmedText
       
   113 	222,	// EEikColorLabelHighlightPartialEmphasis
       
   114 	215		// EEikColorLabelHighlightFullEmphasis
       
   115 	};
       
   116 
       
   117 
       
   118 /**
       
   119  * Creates an EText parser
       
   120  */
       
   121 EXPORT_C MParser* LafEnv::CreateTextParserL(TInt /*aIndex*/)
       
   122 	{ // static
       
   123 	MParser* parser=NULL;
       
   124 	return parser;
       
   125 	}
       
   126 
       
   127 // Local utility for loading resource file
       
   128 LOCAL_C TInt LoadResFileL(CCoeEnv& aEnv, const TDesC& aFileName)
       
   129 	{
       
   130 	TFileName fileName(aFileName);
       
   131 	BaflUtils::NearestLanguageFile(aEnv.FsSession(), fileName);
       
   132 	return aEnv.AddResourceFileL(fileName);
       
   133 	}
       
   134 
       
   135 //This should only be called by MatchFont() in those cases where it is given a TLogicalFont
       
   136 //without a Uid. In those cases this figures out what font to use based on the category
       
   137 //and calls the relevant FontName() function. All switching by subvariant
       
   138 //occurs in those FontName() functions (e.g. LatinPlain12() ) which then call
       
   139 //MatchFont (so it's a call within a call), but this time
       
   140 //with a Uid. 
       
   141 LOCAL_C const CFont* GetRightFontFromCategory(const TLogicalFont::TFontCategory aCategory)
       
   142     {    
       
   143     switch (aCategory)
       
   144         {
       
   145         case TLogicalFont::EView:
       
   146             return CEikonEnv::Static()->NormalFont();
       
   147         case TLogicalFont::EButton:
       
   148             return CEikonEnv::Static()->DenseFont();
       
   149         case TLogicalFont::EAnnotation:
       
   150             return CEikonEnv::Static()->AnnotationFont();
       
   151         case TLogicalFont::ETitle:
       
   152             return CEikonEnv::Static()->TitleFont();
       
   153         default: //this should never happen as long as TLogicalFont always has
       
   154             // either Uid or a category and not further categories are defined
       
   155             // See the constructor for TLogicalFont
       
   156             __ASSERT_ALWAYS(0,Panic(ELafPanicFontUidUnknownOrMissing));	
       
   157             return NULL;//for compiler
       
   158         }        
       
   159     }
       
   160 	
       
   161 
       
   162 
       
   163 // Fetches the CFont* from the system font array.  THis will return NULL in the
       
   164 // following cases: 
       
   165 // - UID is not found
       
   166 // - UID is found, but the CFont* there is NULL 
       
   167 // (Panics where necessary will happen in MatchFont)
       
   168 LOCAL_C const CFont* GetFontFromSystemArray( CArrayPtr<CAknSystemFont>& aSystemFonts, TInt aIdToBeMatched)
       
   169 	{
       
   170 	TInt count = aSystemFonts.Count();
       
   171 	for ( TInt i = 0; i < count; ++i )
       
   172 		{
       
   173 		const CAknSystemFont* font = aSystemFonts[i];
       
   174 		if ((font) && (font->Uid().iUid == aIdToBeMatched))
       
   175 			{
       
   176 			return font->Font();
       
   177 			}
       
   178 		}
       
   179 
       
   180     // Font was not found
       
   181     CAknFontIdLayoutFont* layoutFont=NULL;
       
   182     CWsScreenDevice& screenDev=*(CEikonEnv::Static()->ScreenDevice());
       
   183 
       
   184     TRAPD(err, 
       
   185         {layoutFont = CAknFontIdLayoutFont::NewL( screenDev , aIdToBeMatched);
       
   186         } );
       
   187 
       
   188     if ( err == KErrNone )
       
   189     	{
       
   190     	CleanupStack::PushL( layoutFont );
       
   191     	// Create font and add to font array
       
   192     	TUid uid = TUid::Uid( aIdToBeMatched);
       
   193     	CAknSystemFont* systemFont = CAknSystemFont::NewL( uid, layoutFont ); 
       
   194     	CleanupStack::Pop( layoutFont );
       
   195 		CleanupStack::PushL( systemFont );
       
   196     	aSystemFonts.AppendL( systemFont );
       
   197     	CleanupStack::Pop( systemFont );
       
   198     	return systemFont->Font();
       
   199     	}
       
   200     else if ( count > KDefaultFontIndex )
       
   201     	{
       
   202     	// return a default font if loading fails
       
   203 		return aSystemFonts[KDefaultFontIndex]->Font();
       
   204     	}	
       
   205     else 
       
   206     	return NULL;
       
   207 
       
   208 	}
       
   209 
       
   210 LOCAL_C TBool IsFirstApp()
       
   211     {
       
   212     RThread thread;
       
   213     return ( thread.Name().CompareF( KAknFirstStartedAppThreadName) == 0 );
       
   214     }
       
   215 
       
   216 /**
       
   217  * Returns the corner of the screen which the busy message should appear in
       
   218  * by default on the device.
       
   219  */
       
   220 EXPORT_C TGulAlignment LafEnv::DefaultBusyMsgCorner()
       
   221 	{// static
       
   222 	return EHRightVBottom;
       
   223 	}
       
   224 
       
   225 /**
       
   226  * Populates aBitmaps with a set of system bitmaps.
       
   227  */
       
   228 EXPORT_C void LafEnv::CreateSystemBitmapsL(CCoeEnv& /*aEnv*/, CArrayPtrFlat<CFbsBitmap>& /*aBitmaps*/)
       
   229 	{ 
       
   230 	// Empty implementation in Avkon
       
   231 	}
       
   232 
       
   233 LOCAL_C void AddStartupFontToSystemFontArrayL( CArrayPtr<CAknSystemFont>& aSystemFonts )
       
   234     {
       
   235     // Construct a font that is the same as the system startup font.  
       
   236     CWsScreenDevice& screenDev=*(CEikonEnv::Static()->ScreenDevice());
       
   237     TInt startupId = TAknFontId::FontIdForStartupNormalFont();
       
   238     CAknFontIdLayoutFont* layoutFont = CAknFontIdLayoutFont::NewL( screenDev , startupId);
       
   239     
       
   240     CleanupStack::PushL( layoutFont );
       
   241     // Create font and add to font array
       
   242     TUid uid = TUid::Uid( startupId); // Tag with the encoded font ID and not the logical
       
   243     CAknSystemFont* systemFont = CAknSystemFont::NewL( uid, layoutFont ); 
       
   244     CleanupStack::Pop( layoutFont );
       
   245     CleanupStack::PushL( systemFont );
       
   246     aSystemFonts.AppendL( systemFont );
       
   247     CleanupStack::Pop( systemFont );
       
   248     // Always should have 2 fonts at this point
       
   249     __ASSERT_ALWAYS( aSystemFonts.Count() == 2, Panic(ELafPanicFontCreationFailure));
       
   250     
       
   251     }
       
   252 /**
       
   253  * Populate aFonts with a set of system fonts defined in eikpriv.rss
       
   254  * A minimum of one font must be created.
       
   255  */
       
   256 
       
   257 EXPORT_C void LafEnv::CreateSystemFontsL(CCoeEnv& aEnv, CArrayPtr<CAknSystemFont>& aFonts)
       
   258 	{
       
   259     // Ensure the system font array is set in Avkon extension
       
   260     CEikonEnv* env = static_cast<CEikonEnv*>(&aEnv);
       
   261     CAknEnv* aAknEnv = static_cast<CAknEnv*>(env->Extension());
       
   262     if (aAknEnv)
       
   263         {
       
   264         aAknEnv->iSystemFontArray = &aFonts;  // Friend class setting access to private member
       
   265         }
       
   266 #ifdef AVKON_RDEBUG_INFO
       
   267     if (!aAknEnv)
       
   268         RDebug::Print(_L("LafEnv::CreateSystemFontsL - System Font Array pointer NOT set into AknEnv"));
       
   269 #endif      
       
   270     TBool isFirstApp = IsFirstApp();
       
   271     
       
   272     // We will want NormalFont at index 0. Add it here by doing what CEikEnv will do
       
   273     TLogicalFont lf;
       
   274     lf.iFontId=TUid::Uid(KLafUidNormalFontVal);
       
   275     (void)LafEnv::MatchFont( aFonts, lf ); // Creates the future iNormalFont
       
   276 	    	
       
   277     if ( isFirstApp )
       
   278         {
       
   279         // Create a 2nd system font in this app that will hold permanently open the dummy 
       
   280     	// font that all apps start up with (the initial iNormalFont)
       
   281     	AddStartupFontToSystemFontArrayL(aFonts);
       
   282     	
       
   283     	// Also set the system defaults and aliases
       
   284     	// AknFontProvider::InitializeSystemL needs WriteDeviceData, and it only a co-incidence that the first app started 
       
   285     	// is AknCapServer with its high capabilities. These checks added for maintainability and debugability
       
   286 
       
   287     	RProcess process;
       
   288 #ifdef AVKON_RDEBUG_INFO
       
   289     	if ( !process.HasCapability( ECapabilityWriteDeviceData) )
       
   290     	    {
       
   291     	    RDebug::Print(_L("LafEnv::CreateSystemFontsL - Not in high enough capability app to initialize fonts system-wide"));
       
   292     	    }
       
   293 #endif 
       
   294         __ASSERT_ALWAYS( process.HasCapability( ECapabilityWriteDeviceData) , Panic(ELafPanicFontCreationFailure) );
       
   295    
       
   296         AknFontProvider::InitializeSystemL( static_cast<CEikonEnv&>(aEnv) );
       
   297         }   
       
   298         
       
   299     return; // nothing created from resource.
       
   300     }
       
   301 
       
   302 LOCAL_C TInt MapSymbianLogicalFontUidToSeries60Id( TInt aUidToMap )
       
   303     {
       
   304     switch (aUidToMap)
       
   305         {
       
   306         case KLafUidNormalFontVal:
       
   307         return EAknLogicalFontPrimaryFont;
       
   308 
       
   309         case KLafUidAnnotationFontVal:
       
   310         return EAknLogicalFontPrimarySmallFont;
       
   311 
       
   312         case KLafUidDenseFontVal:
       
   313         return EAknLogicalFontSecondaryFont;
       
   314 
       
   315         case KLafUidTitleFontVal:
       
   316         return EAknLogicalFontTitleFont;
       
   317 
       
   318         case KLafUidSymbolFontVal:
       
   319         return EAknLogicalFontPrimarySmallFont;
       
   320 
       
   321         case KLafUidLegendFontVal:
       
   322         return EAknLogicalFontPrimarySmallFont;
       
   323 
       
   324         default:		
       
   325         return aUidToMap;
       
   326         }
       
   327     // no return required
       
   328     }
       
   329 
       
   330 /**
       
   331  * Return the nearest match to aLogicalFont in aSystemFonts. 
       
   332  * If given an ordinary font Uid it returns the font.
       
   333  * If it is given one of the LogicalFont Uid's it will
       
   334  * effectively map this to a genuine font Uid and recursively call
       
   335  * MatchFont but this time with a proper Uid (will not do any further nested calls)
       
   336  * If it is given
       
   337  * a LogicalFont with no Uid but with a category, it uses the category to
       
   338  * figure out what Logical Font Uid to use, and then does a recursive call to MatchFont 
       
   339  * (i.e. itself) witha  Logical Font Uid as parameter, 
       
   340  * returning you to the situation just discussed above.
       
   341  * Thus at worst we get a call within a call within a call.
       
   342  * 
       
   343  * The return value must be non-NULL
       
   344  */
       
   345 EXPORT_C const CFont* LafEnv::MatchFont( CArrayPtr<CAknSystemFont>& aSystemFonts,const TLogicalFont& aLogicalFont)
       
   346 	{ 
       
   347 
       
   348 	const CFont* font = NULL;
       
   349 
       
   350 	// Need to check if aLogicalFont actually HAS a uid. If not, we  use its category 
       
   351 	// (Note it is possible to have a TLogicalFont without a uid, but it is impossible 
       
   352 	// to have one without a category.)
       
   353 	TInt uidToMatch = aLogicalFont.iFontId.iUid;
       
   354 
       
   355 	if (uidToMatch == KNullUid.iUid)
       
   356 	//i.e. if there is no Uid 
       
   357 		{	
       
   358 			//this function call involves a call to matchFont itself, but this time WITH a Uid.
       
   359 			//Should never end up in an infinite recursion
       
   360 			//In fact should only ever be one call within another.
       
   361 		font = GetRightFontFromCategory(aLogicalFont.iCategory);
       
   362 		}
       
   363 	else //this is the case that should happen nearly all the time
       
   364 		{
       
   365         // Handle Symbian OS Logical Font Uids. Uid is translated to Series 60 logical font
       
   366         uidToMatch = MapSymbianLogicalFontUidToSeries60Id( uidToMatch );
       
   367 
       
   368         //if the fontid is not in the array or the Uid is there but without a CFont*,
       
   369 		//it returns NULL
       
   370 		font = GetFontFromSystemArray(aSystemFonts, uidToMatch);
       
   371         }
       
   372 
       
   373 
       
   374    	if ( !font )
       
   375         {
       
   376         // Create a Symbian font spec
       
   377         TFontSpec fontSpec;
       
   378 
       
   379     //	fontSpec.iTypeface.iName =  (*(productFontTable[foundIndex].iTypefaceName)).Left(KMaxTypefaceNameLength);
       
   380 
       
   381         fontSpec.iHeight = 12;
       
   382     	CWsScreenDevice& screenDev=*(CEikonEnv::Static()->ScreenDevice());
       
   383 	    User::LeaveIfError(screenDev.GetNearestFontInPixels((CFont*&)font,fontSpec));
       
   384         }
       
   385 
       
   386     __ASSERT_ALWAYS( font, Panic(ELafPanicFontUidUnknownOrMissing) );
       
   387 	return font;
       
   388 	}
       
   389 
       
   390 /**
       
   391  * Returns the nearest match to aBmpUid in aSystemBitmaps.
       
   392  */
       
   393 EXPORT_C CFbsBitmap* LafEnv::MatchBitmap(const CArrayPtrFlat<CFbsBitmap>& aSystemBmps, TUid aBmpUid)
       
   394 	{ // static
       
   395 	CFbsBitmap* bitmap = NULL;
       
   396 	const TInt32 uid = aBmpUid.iUid;
       
   397 	if (uid >= KLafUidEikonTexturedVal && uid <= KLafUidEikonOptimVal)
       
   398 		bitmap = aSystemBmps[uid-KLafUidEikonTexturedVal];
       
   399 	__ASSERT_DEBUG(bitmap,Panic(ELafPanicBitmapIndexOutOfRange));
       
   400 	return bitmap;
       
   401 	}
       
   402 
       
   403 
       
   404 /**
       
   405  * Draw's a logical border for aBorder, onto the graphics context aGc, in the rectangle aRect and using the
       
   406  * set of colors aBorderColors.
       
   407  */
       
   408 EXPORT_C void LafEnv::DrawLogicalBorder(const TGulBorder& aBorder,CGraphicsContext& aGc, const TRect& aRect, const TGulBorder::TColors& aBorderColors)
       
   409 	{ // static
       
   410 	if (AknBorderId::EAknBorderNotePopup <= aBorder.Type() && aBorder.Type() < AknBorderId::EAknBorderMax)
       
   411 		{
       
   412 		LafAknBorders::DrawLogicalBorder(aBorder, aGc, aRect, aBorderColors);
       
   413 		return;
       
   414 		}
       
   415 
       
   416 		TInt type;
       
   417 
       
   418 	switch(aBorder.Type())
       
   419 		{
       
   420 	case TGulBorder::EWindow:
       
   421 		type=TGulBorder::EThickDeepRaisedWithOutline;
       
   422 		break;
       
   423 	case TGulBorder::EFlatContainer:
       
   424 		type=TGulBorder::ESingleBlack;
       
   425 		break;
       
   426 	case TGulBorder::ERaisedContainer:
       
   427 		type=TGulBorder::EShallowRaised;
       
   428 		break;
       
   429 	case TGulBorder::ESunkenContainer:
       
   430 		type=TGulBorder::EShallowSunken;
       
   431 		break;
       
   432 	case TGulBorder::EFlatControl:
       
   433 		type=TGulBorder::ESingleGray;
       
   434 		break;
       
   435 	case TGulBorder::ERaisedControl:
       
   436 		type=TGulBorder::EDeepRaisedWithOutline;
       
   437 		break;
       
   438 	case TGulBorder::ESunkenControl:
       
   439 		type=TGulBorder::EDeepSunkenWithOutline;
       
   440 		break;
       
   441 	case TGulBorder::EFocusedRaisedControl:
       
   442 		type=TGulBorder::EDeepRaisedWithOutline;
       
   443 		break;
       
   444 	case TGulBorder::EFocusedSunkenControl:
       
   445 		type=TGulBorder::EDeepSunkenWithOutline;
       
   446 		break;
       
   447 	default:
       
   448 		type=TGulBorder::ENone;
       
   449 		break;
       
   450 		}
       
   451 
       
   452 	TGulBorder border(type);
       
   453 	border.SetAdjacent(aBorder.Adjacent());
       
   454 	border.Draw(aGc,aRect,aBorderColors);
       
   455 	}
       
   456 
       
   457 /**
       
   458  * Returns the margins of a logical border for aBorder.
       
   459  */
       
   460 EXPORT_C TMargins LafEnv::LogicalBorderMargins(const TGulBorder& aBorder)
       
   461 	{ // static
       
   462 	if (AknBorderId::EAknBorderNotePopup <= aBorder.Type() && aBorder.Type() < AknBorderId::EAknBorderMax)
       
   463 		{
       
   464 		return LafAknBorders::LogicalBorderMargins(aBorder);
       
   465 		}
       
   466 
       
   467 	TInt type;
       
   468 
       
   469 	switch(aBorder.Type())
       
   470 		{
       
   471 	case TGulBorder::EWindow:
       
   472 		type=TGulBorder::EThickDeepRaisedWithOutline;
       
   473 		break;
       
   474 	case TGulBorder::EFlatContainer:
       
   475 		type=TGulBorder::ESingleBlack;
       
   476 		break;
       
   477 	case TGulBorder::ERaisedContainer:
       
   478 		type=TGulBorder::EShallowRaised;
       
   479 		break;
       
   480 	case TGulBorder::ESunkenContainer:
       
   481 		type=TGulBorder::EShallowSunken;
       
   482 		break;
       
   483 	case TGulBorder::EFlatControl:
       
   484 		type=TGulBorder::ESingleGray;
       
   485 		break;
       
   486 	case TGulBorder::ERaisedControl:
       
   487 		type=TGulBorder::EDeepRaisedWithOutline;
       
   488 		break;
       
   489 	case TGulBorder::ESunkenControl:
       
   490 		type=TGulBorder::EDeepSunkenWithOutline;
       
   491 		break;
       
   492 	case TGulBorder::EFocusedRaisedControl:
       
   493 		type=TGulBorder::EDeepRaisedWithOutline;
       
   494 		break;
       
   495 	case TGulBorder::EFocusedSunkenControl:
       
   496 		type=TGulBorder::EDeepSunkenWithOutline;
       
   497 		break;
       
   498 	default:
       
   499 		type=TGulBorder::ENone;
       
   500 		break;
       
   501 		}
       
   502 
       
   503 	TGulBorder border(type);
       
   504 	border.SetAdjacent(aBorder.Adjacent());
       
   505 	return border.Margins();
       
   506 	}
       
   507 
       
   508 /**
       
   509  * Returns the hardware key that corresponds to the default key.
       
   510  */
       
   511 EXPORT_C TBool LafEnv::IsDefaultKey(TUint aCharCode)
       
   512 	{// static
       
   513 	return aCharCode==EKeyDefault;
       
   514 	}
       
   515 
       
   516 /**
       
   517  * Returns the default line spacing used to format text paragraphs.
       
   518  */
       
   519 EXPORT_C TInt LafEnv::DefaultLineSpacingInTwips()
       
   520 	{//static
       
   521 	return KLafEnvDefaultLineSpacingInTwips;
       
   522 	}
       
   523 
       
   524 EXPORT_C TInt LafEnv::EditableControlStandardHeight(const MLafEnv& /*aLafEnv*/ )
       
   525 	{
       
   526     // primary cursor extent is used as the standard editor height.  This is in agreement with	
       
   527     // a text query's editor field.
       
   528     TAknWindowLineLayout primaryLayout = 
       
   529         AknLayoutScalable_Avkon::cursor_primary_pane().LayoutLine();
       
   530     TAknLayoutRect primaryCursor;
       
   531     // AknAppUi->ApplicationRect cannot be called yet. Just need any rectangle:
       
   532     TRect rectParent(0,0,2048,2048); 
       
   533     primaryCursor.LayoutRect( rectParent, primaryLayout );       
       
   534     return primaryCursor.Rect().Height();
       
   535 	}
       
   536 
       
   537 /**
       
   538  * Returns a constant value according to aConstatType.
       
   539  * @internal
       
   540  */
       
   541 EXPORT_C TInt LafEnv::Constant(TConstantType aConstantType)
       
   542 	{//static
       
   543 	TInt retValue = 0;
       
   544 	switch (aConstantType)
       
   545 		{
       
   546 	case EShadowHeight:
       
   547 		retValue = KLafShadowHeight;
       
   548 		break;
       
   549 	default:
       
   550 		__ASSERT_DEBUG(EFalse, Panic(ELafPanicConstantNotKnown));
       
   551 		break;
       
   552 		}
       
   553 	return retValue;
       
   554 	}
       
   555 
       
   556 /**
       
   557 * Sets any device specific font attributes to be applied to CEikonEnv's iCharFormatLayer.
       
   558 * This format layer is used in Edwins. CEikonEnv's iCharFormatLayer may be used in other
       
   559 * apps on some devices, so should be changed with care.
       
   560 *
       
   561 * @internal
       
   562 */
       
   563 EXPORT_C void LafEnv::PrepareCharFormatAndMask(TCharFormat& aCharFormat,
       
   564 											   TCharFormatMask& aCharFormatMask)
       
   565 	{
       
   566     //static
       
   567     aCharFormat.iFontPresentation.iTextColor=KRgbDarkGreen;
       
   568     aCharFormatMask.SetAttrib(EAttColor);
       
   569 	}
       
   570 
       
   571 
       
   572 /**
       
   573 * Allows individual DFRDs to specify a default directory for documents or to generate one.
       
   574 *
       
   575 * The parameters provided are not necessary in the UIKLAF implementation but are there
       
   576 * to allow a DFRD enough information to generate a document directory based on the app being launched
       
   577 *
       
   578 * aFilePath receives the default / generated directory path.
       
   579 *
       
   580 * @internal
       
   581 */
       
   582 EXPORT_C void LafEnv::GetDefaultPath(TDes& aFilePath,TUid /*aAppUid*/,RApaLsSession& /*aLs*/,CCoeEnv& /*aEnv*/)
       
   583 	{
       
   584 	aFilePath = KNullDesC;
       
   585 	}
       
   586 
       
   587  /**
       
   588  * Loads the system resource file
       
   589  *
       
   590  * @internal 
       
   591  * @since App-Framework_6.2
       
   592  */
       
   593 EXPORT_C TInt LafEnv::LoadCoreResFileL(CCoeEnv& aEnv)
       
   594 /**
       
   595 @publishedPartner
       
   596 @test
       
   597 */
       
   598 	{
       
   599 	_LIT(KCoreResFileName,"z:\\Resource\\Uiklaf\\eikcore.rsc");
       
   600 	return LoadResFileL(aEnv, KCoreResFileName);	
       
   601 	}
       
   602 
       
   603  /**
       
   604  * Loads the private resource file
       
   605  *
       
   606  * @internal  
       
   607  * @since App-Framework_6.2
       
   608  */
       
   609 EXPORT_C TInt LafEnv::LoadPrivResFileL(CCoeEnv& aEnv)
       
   610 /**
       
   611 @publishedPartner
       
   612 @test
       
   613 */
       
   614 	{
       
   615     // UNBRANCH TODO: Should this path come from a header?
       
   616 	_LIT(KPrivResFileName,"z:\\Resource\\Uiklaf\\eikpriv.rsc");
       
   617 	return LoadResFileL(aEnv, KPrivResFileName);
       
   618 	}
       
   619 
       
   620  /**
       
   621  * Returns the Coctl Resource File
       
   622  * 
       
   623  * @internal 
       
   624  * @since App-Framework_6.2
       
   625  */
       
   626 EXPORT_C const TDesC& LafEnv::CoctlResourceFile()
       
   627 /**
       
   628 @publishedPartner
       
   629 @test
       
   630 */
       
   631 	{
       
   632 	_LIT(KCoctlResFileName,"z:\\System\\Data\\eikcoctl.rsc");
       
   633 	return KCoctlResFileName;
       
   634 	}
       
   635 
       
   636 /**
       
   637  * Allows to update the list of system bitmaps, aBitmaps, by using aColorList in order to determine what bitmaps
       
   638  * need to be un/loaded.
       
   639  * 
       
   640  * @internal 
       
   641  * @since 6.2
       
   642  */
       
   643 EXPORT_C void LafEnv::UpdateSystemBitmapsL(CCoeEnv& /*aEnv*/, CArrayPtrFlat<CFbsBitmap>& /*aBitmaps*/, const CColorList& /*aColorList*/)
       
   644 /**
       
   645 @publishedPartner
       
   646 @test
       
   647 */
       
   648 	{
       
   649 	}
       
   650 
       
   651 /**
       
   652 @publishedAll
       
   653 @released
       
   654 */
       
   655 const TInt KInfoNoteMaxLen=100;
       
   656 
       
   657 /** Specifies the maximum length of the message buffer. 
       
   658 
       
   659 @publishedAll
       
   660 @released */
       
   661 typedef TBuf<KInfoNoteMaxLen> TEikInfoNoteBuf;
       
   662 
       
   663 LOCAL_C void InfoNote(const TDesC& aDes)
       
   664 	{
       
   665 	TRAP_IGNORE(
       
   666         CAknInformationNote* note = new(ELeave) CAknInformationNote;
       
   667         CleanupStack::PushL(note);
       
   668         note->ExecuteLD(aDes);
       
   669         CleanupStack::Pop(note);
       
   670 	    );
       
   671 	}
       
   672 
       
   673 LOCAL_C void InfoNote(TInt aResourceId,VA_LIST aList)
       
   674     {
       
   675     TEikInfoNoteBuf formatString;
       
   676 	CEikonEnv::Static()->ReadResource(formatString,aResourceId);
       
   677 	TEikInfoNoteBuf messageString;
       
   678 	messageString.FormatList(formatString,aList);
       
   679 	InfoNote(messageString);
       
   680     }
       
   681     
       
   682 
       
   683 EXPORT_C void LafEnv::InfoNote(TInt aResourceId,...)
       
   684     {
       
   685     VA_LIST list;
       
   686     VA_START(list,aResourceId);
       
   687     ::InfoNote(aResourceId,list);
       
   688     }
       
   689 
       
   690 
       
   691 EXPORT_C TBool LafEnv::IsTaskListDisabledAtInitialization()
       
   692     {
       
   693     return ETrue;
       
   694     }
       
   695 
       
   696 EXPORT_C void LafEnv::Beep()
       
   697     {
       
   698     }
       
   699 
       
   700 EXPORT_C CColorList* LafEnv::CreateColorListL( CEikonEnv& /*aEnv*/ )
       
   701     {
       
   702     CArrayFix<TRgb>* colors=new(ELeave) CArrayFixFlat<TRgb>(8);
       
   703 	CleanupStack::PushL(colors);
       
   704     for (TInt ii=EColorWindowBackground;ii<=EColorLabelHighlightFullEmphasis;ii++)
       
   705         {
       
   706         colors->InsertL(TLogicalColor(ii), CAknEnv::AvkonColor(KLogicalToAvkonColorMap[ii]));
       
   707 		}
       
   708 	CColorList* colorList=CColorList::NewL(colors);
       
   709 	CleanupStack::Pop(); // colors. Ownership has been transferred away
       
   710     return colorList;
       
   711     }        
       
   712 
       
   713 EXPORT_C void LafEnv::UpdateColorListL( CColorList* aColorList )
       
   714     {
       
   715     for (TInt ii=EColorWindowBackground;ii<=EColorLabelHighlightFullEmphasis;ii++)
       
   716 		{
       
   717         aColorList->SetColor(TLogicalColor(ii), CAknEnv::AvkonColor(KLogicalToAvkonColorMap[ii]));
       
   718 		}
       
   719     }
       
   720 
       
   721 
       
   722 EXPORT_C void LafEnv::UpdateSystemFontsL( CCoeEnv* /*aEnv*/, CArrayPtr<CAknSystemFont>& aSystemFonts )
       
   723     {
       
   724 	TInt count = aSystemFonts.Count();
       
   725 	for ( TInt i = 0; i < count; ++i )
       
   726 		{
       
   727 		CAknSystemFont* font = aSystemFonts[i];
       
   728 		CFont* cFont = font->Font();
       
   729         if (cFont )
       
   730             {
       
   731             // Font is always of this type (See constructors in this class)
       
   732             CAknFontIdLayoutFont* layoutFont = static_cast<CAknFontIdLayoutFont*>(cFont);
       
   733             // Do not update encoded fonts, as you will just get the same font back again
       
   734             if ( !TAknFontId::IsEncodedFont( layoutFont->FontId() ) )
       
   735                 layoutFont->Update();
       
   736             }
       
   737         }
       
   738     }
       
   739 
       
   740 
       
   741 EXPORT_C void LafEnv::ReleaseSystemFonts( CArrayPtr<CAknSystemFont>& aSystemFonts )
       
   742 	{
       
   743 	const TInt fontCount=aSystemFonts.Count();
       
   744 	for (TInt ii=0;ii<fontCount;ii++)
       
   745 		{
       
   746 		delete aSystemFonts[ii];
       
   747 		}
       
   748 	}
       
   749 	
       
   750 NONSHARABLE_CLASS(CAknBusyMsgWin): public CBase, public MEikBusyMsgWin
       
   751     {
       
   752 public:    
       
   753 	CAknBusyMsgWin(CEikonEnv& aEikonEnv):iEnv(aEikonEnv)
       
   754 	    {
       
   755 	    iRdSupport = BaflUtils::FileExists( iEnv.FsSession(), KRDSupport );
       
   756 	    }
       
   757 	    
       
   758     ~CAknBusyMsgWin()
       
   759         {
       
   760         delete iImpl;
       
   761         }
       
   762 
       
   763     void ConstructL(RWindowGroup& aWindowGroup)
       
   764         {
       
   765         iImpl = new (ELeave) CEikBusyMsgWin(iEnv);
       
   766         iImpl->ConstructL(aWindowGroup);
       
   767         }
       
   768 public:  //from MEikBusyMsgWin
       
   769 	void StartDisplaySpecifyingInitialDelay(const TDesC& aText, TGulAlignment aCorner, 
       
   770 	    TTimeIntervalMicroSeconds32 aInitialDelay)
       
   771 	    {
       
   772 #ifdef _DEBUG
       
   773 	    iImpl->StartDisplaySpecifyingInitialDelay(aText, aCorner, aInitialDelay);
       
   774 #else
       
   775         if(iRdSupport)
       
   776             {
       
   777             iImpl->StartDisplaySpecifyingInitialDelay(aText, aCorner, aInitialDelay);
       
   778             }
       
   779 #endif
       
   780 	    }
       
   781     
       
   782 	void StartDisplay(const TDesC& aText, TGulAlignment aCorner)
       
   783 	    {
       
   784 #ifdef _DEBUG
       
   785 	    iImpl->StartDisplay(aText, aCorner);
       
   786 #else
       
   787         if(iRdSupport)
       
   788             {
       
   789             iImpl->StartDisplay(aText, aCorner);
       
   790             }
       
   791 #endif
       
   792 	    }	    
       
   793 
       
   794 	void Release()
       
   795 	    {
       
   796 	    delete this;
       
   797 	    }
       
   798 private:
       
   799     CEikBusyMsgWin* iImpl;
       
   800     CEikonEnv&      iEnv;
       
   801     TBool           iRdSupport;
       
   802     };	
       
   803 
       
   804 EXPORT_C MEikBusyMsgWin* LafEnv::NewBusyMsgWinL(CCoeEnv& aEnv)
       
   805     {
       
   806     CAknBusyMsgWin* self = new(ELeave) CAknBusyMsgWin( static_cast<CEikonEnv&>(aEnv) );
       
   807     CleanupStack::PushL( self );
       
   808     self->ConstructL( aEnv.RootWin() );
       
   809     CleanupStack::Pop();//self
       
   810     return self;
       
   811     }
       
   812    
       
   813 NONSHARABLE_CLASS(CAknInfoMsgWin): public CBase, public MEikInfoMsgWin
       
   814     {
       
   815 public:    
       
   816 	CAknInfoMsgWin(CEikonEnv& aEikonEnv):iEnv(aEikonEnv)
       
   817 	    {
       
   818 	    iRdSupport = BaflUtils::FileExists( iEnv.FsSession(), KRDSupport );    
       
   819 	    }
       
   820 	    
       
   821     ~CAknInfoMsgWin()
       
   822         {
       
   823         delete iImpl;
       
   824         }
       
   825 
       
   826     void ConstructL(RWindowGroup& aWindowGroup, TInt aParam)
       
   827         {
       
   828         iImpl = new (ELeave) CEikInfoMsgWin(iEnv);
       
   829         iImpl->ConstructL(aWindowGroup, aParam);
       
   830         }
       
   831 
       
   832 public:  //from MEikInfoMsgWin
       
   833     
       
   834 	void StartDisplaySpecifyingDuration(const TDesC& aText, TGulAlignment aCorner, TTimeIntervalMicroSeconds32 aDuration)
       
   835 	    {
       
   836 #ifdef _DEBUG
       
   837 	    iImpl->StartDisplaySpecifyingDuration(aText, aCorner, aDuration);
       
   838 #else
       
   839         if(iRdSupport)
       
   840             {
       
   841             iImpl->StartDisplaySpecifyingDuration(aText, aCorner, aDuration);
       
   842             }
       
   843 #endif
       
   844 	    }
       
   845 
       
   846 	void StartDisplay(const TDesC& aText, TGulAlignment aCorner)
       
   847 	    {
       
   848 #ifdef _DEBUG
       
   849 	    iImpl->StartDisplay(aText, aCorner);
       
   850 #else	    
       
   851         if(iRdSupport)
       
   852             {
       
   853             iImpl->StartDisplay(aText, aCorner);
       
   854             }
       
   855 #endif
       
   856 	    }	    
       
   857 
       
   858     void CancelDisplay()
       
   859         {
       
   860         if (iImpl)
       
   861             iImpl->CancelDisplay();
       
   862         }
       
   863 
       
   864 	void Release()
       
   865 	    {
       
   866 	    delete this;
       
   867 	    }
       
   868     	
       
   869 private:
       
   870     CEikInfoMsgWin* iImpl;
       
   871     CEikonEnv&      iEnv;
       
   872     TBool           iRdSupport;
       
   873     };
       
   874        
       
   875 
       
   876 EXPORT_C MEikInfoMsgWin* LafEnv::NewInfoMsgWinL(CCoeEnv& aEnv, RWindowGroup& aGroup)
       
   877     {
       
   878     CAknInfoMsgWin* self = new(ELeave) CAknInfoMsgWin( static_cast<CEikonEnv&>(aEnv ));
       
   879     CleanupStack::PushL( self );
       
   880     self->ConstructL( aGroup, 0);
       
   881     CleanupStack::Pop();//self
       
   882     return self;
       
   883     }
       
   884 
       
   885 EXPORT_C MEikInfoMsgWin* LafEnv::NewInfoMsgWinL(CCoeEnv& aEnv )
       
   886     {
       
   887     CAknInfoMsgWin* self = new(ELeave) CAknInfoMsgWin( static_cast<CEikonEnv&>(aEnv ));
       
   888     CleanupStack::PushL( self );
       
   889     self->ConstructL( aEnv.RootWin(), 0 );
       
   890     CleanupStack::Pop();//self
       
   891     return self;
       
   892     }
       
   893 
       
   894 /* Return the name of the clock dll */
       
   895 EXPORT_C const TDesC& LafEnv::ClockDllName()
       
   896     {
       
   897 #if defined(__WINS__)
       
   898 		_LIT(KClockDllName,"CLOCKA.DLL");
       
   899 #else
       
   900 		_LIT(KClockDllName,"Z:\\SYSTEM\\LIBS\\CLOCKA.DLL");
       
   901 #endif
       
   902     return KClockDllName;
       
   903     }