lafagnosticuifoundation/uigraphicsutils/gulsrc/GULUTIL.CPP
changeset 0 2f259fa3e83a
child 16 71dd06cfe933
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <s32file.h>
       
    17 #include <s32std.h>
       
    18 #include <badesca.h>
       
    19 #include <barsread.h>
       
    20 #include <bautils.h>
       
    21 #include <gdi.h>
       
    22 #include <w32std.h>
       
    23 #include <gulutil.h>
       
    24 #include <gulcolor.h>
       
    25 #include "GULSTD.H"
       
    26 #include "GULLU.H"
       
    27 #include <gulfont.hrh>
       
    28 #include <gulftflg.hrh>
       
    29 #include <numberconversion.h>
       
    30 
       
    31 //
       
    32 // TMargins8
       
    33 //
       
    34 
       
    35 EXPORT_C TMargins8::TMargins8()
       
    36 /** The constructor initialises all four margins to zero. */
       
    37 	{
       
    38 	iLeft=iRight=iTop=iBottom=(TInt8)0;
       
    39 	}
       
    40 
       
    41 /**
       
    42 Constructor setting the left, top, right, and bottom margins.
       
    43 
       
    44 @param aLeft Left margin (between -128 and +127)
       
    45 @param aTop Top margin (between -128 and +127)
       
    46 @param aRight Right margin (between -128 and +127)
       
    47 @param aBottom Bottom margin (between -128 and +127)
       
    48 */
       
    49 EXPORT_C TMargins8::TMargins8(TInt8 aLeft, TInt8 aTop, TInt8 aRight, TInt8 aBottom) 
       
    50  : iLeft(aLeft), iRight(aRight), iTop(aTop), iBottom(aBottom)
       
    51 	{
       
    52 	}
       
    53 
       
    54 EXPORT_C void TMargins8::SetAllValuesTo(TInt aCommonValue)
       
    55 /** Sets all four margins to a common value (between -128 and +127).
       
    56 
       
    57 @param aCommonValue The new value for all margins. */
       
    58 	{
       
    59 	iLeft=iRight=iTop=iBottom=(TInt8)aCommonValue;
       
    60 	}
       
    61 
       
    62 EXPORT_C TRect TMargins8::InnerRect(const TRect& aOuterRect) const
       
    63 /** Calculates and returns an inner rectangle by applying the margins 
       
    64 to the specified outer rectangle.
       
    65 
       
    66 @param aOuterRect The coordinates of the outer rectangle from which 
       
    67 the inner rectangle is calculated.
       
    68 @return Inner rectangle. */
       
    69 	{
       
    70     TRect inner=aOuterRect;
       
    71     inner.iTl.iX+=iLeft;
       
    72     inner.iTl.iY+=iTop;
       
    73     inner.iBr.iX-=iRight;
       
    74     inner.iBr.iY-=iBottom;
       
    75     return inner;
       
    76 	}
       
    77 
       
    78 EXPORT_C TRect TMargins8::OuterRect(const TRect& aInnerRect) const
       
    79 /** Calculates and returns an outer rectangle by applying the margins 
       
    80 to the specified inner rectangle.
       
    81 
       
    82 @param aInnerRect The coordinates of the inner rectangle from which 
       
    83 the outer rectangle is calculated.
       
    84 @return Outer rectangle. */
       
    85 	{
       
    86     TRect outer=aInnerRect;
       
    87     outer.iTl.iX-=iLeft;
       
    88     outer.iTl.iY-=iTop;
       
    89     outer.iBr.iX+=iRight;
       
    90     outer.iBr.iY+=iBottom;
       
    91     return outer;
       
    92 	}
       
    93 
       
    94 EXPORT_C TSize TMargins8::SizeDelta() const
       
    95 /** Calculates and returns the difference in size between the outer 
       
    96 and inner rectangles.
       
    97 
       
    98 @return Size difference between outer and inner rectangles. */
       
    99 	{
       
   100 	return TSize(iLeft+iRight,iTop+iBottom);
       
   101 	}
       
   102 
       
   103 //
       
   104 // class DrawUtils
       
   105 //
       
   106 
       
   107 EXPORT_C void DrawUtils::DrawText(CGraphicsContext& aGc,const TDesC& aString,const TRect& aBox,TInt aBaseLineOffset,
       
   108 									 CGraphicsContext::TTextAlign aHoriz,TInt aMargin,const CFont* aFont)
       
   109 /** Draws text inside a rectangle. 
       
   110 
       
   111 @param aGc The graphics context.
       
   112 @param aString The text string to draw. 
       
   113 @param aBox The rectangle to draw the text in. 
       
   114 @param aBaseLineOffset An offset from the top of the box to the text baseline. 
       
   115 @param aHoriz The horizontal text alignment.
       
   116 @param aMargin The margin around the text.
       
   117 @param aFont The font to use. */
       
   118 	{ // static
       
   119 	if (aHoriz!=CGraphicsContext::ELeft)
       
   120         {
       
   121 		const TInt extraWidth=aBox.Width()-aFont->TextWidthInPixels(aString)-aMargin;
       
   122         if (aHoriz==CGraphicsContext::ECenter)
       
   123             aMargin+=extraWidth/2;
       
   124 		else
       
   125 			aMargin=extraWidth;
       
   126         }
       
   127 	aGc.DrawText(aString,aBox,aBaseLineOffset,CGraphicsContext::ELeft,aMargin);
       
   128 	}
       
   129 
       
   130 EXPORT_C void DrawUtils::ClearBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect)
       
   131 /** Clears between two rectangles, using a solid brush style and no pen.
       
   132 
       
   133 @param aGc The graphics context.
       
   134 @param aOuterRect The outer rectangle.
       
   135 @param aInnerRect The inner rectangle. */
       
   136     { // static
       
   137     aGc.SetPenStyle(CGraphicsContext::ENullPen);
       
   138     aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   139     DrawBetweenRects(aGc,aOuterRect,aInnerRect);
       
   140     aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   141     aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   142     }
       
   143 
       
   144 EXPORT_C void DrawUtils::DrawBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect)
       
   145 /** Draws between two rectangles.
       
   146 
       
   147 The pen and brush settings are used as specified in the graphics context.
       
   148 
       
   149 @param aGc The graphics context.
       
   150 @param aOuterRect The outer rectangle to be drawn.
       
   151 @param aInnerRect The inner rectangle to be drawn. */
       
   152     { // static
       
   153     TRect rect=aOuterRect;
       
   154     rect.iBr.iY=aInnerRect.iTl.iY;
       
   155     aGc.DrawRect(rect);
       
   156     rect.iBr.iY=aOuterRect.iBr.iY;
       
   157     rect.iTl.iY=aInnerRect.iBr.iY;
       
   158     aGc.DrawRect(rect);
       
   159     rect=aInnerRect;
       
   160     rect.iTl.iX=aOuterRect.iTl.iX;
       
   161     rect.iBr.iX=aInnerRect.iTl.iX;
       
   162     aGc.DrawRect(rect);
       
   163     rect.iTl.iX=aInnerRect.iBr.iX;
       
   164     rect.iBr.iX=aOuterRect.iBr.iX;
       
   165     aGc.DrawRect(rect);
       
   166     }
       
   167 
       
   168 //
       
   169 // class TextUtils
       
   170 //	
       
   171 
       
   172 EXPORT_C void TextUtils::ClipToFit(TDes& aBuffer,const CFont& aFont,TInt aMaxWidthInPixels,TChar aAlternativeEnd)
       
   173 /** Clips text to fit into a maximum width.
       
   174 
       
   175 If the text is too wide to fit in the width when displayed in aFont, 
       
   176 it is truncated and the specified character (by default, 
       
   177 a horizontal ellipsis) is appended to it.
       
   178 
       
   179 @param aBuffer A buffer containing the text to clip.
       
   180 @param aFont The font.
       
   181 @param aMaxWidthInPixels The maximum width in pixels.
       
   182 @param aAlternativeEnd The Unicode character to append to the buffer if truncated. 
       
   183 By default, this is the horizontal ellipsis. */
       
   184 	{
       
   185 	TInt textWidth=aFont.TextWidthInPixels(aBuffer);
       
   186 	if (textWidth<=aMaxWidthInPixels)
       
   187 		return;
       
   188 	TBuf<1> ellipse;
       
   189 	ellipse.Append(aAlternativeEnd);
       
   190 	TInt extraWidth=aFont.TextWidthInPixels(ellipse);
       
   191 	TInt cutOff=aFont.TextCount(aBuffer,aMaxWidthInPixels-extraWidth);
       
   192 	aBuffer.SetLength(cutOff);
       
   193 	aBuffer.Append(ellipse);
       
   194 	}
       
   195 
       
   196 EXPORT_C TInt TextUtils::ColumnText(TPtrC& aColumnText,TInt aColumn,const TDesC* aSourceText,TChar aColumnSeparator)
       
   197 /** Gets a portion of text from a descriptor, corresponding to a requested column.
       
   198 
       
   199 @param aColumnText On return, set to the portion of aSourceText that corresponds 
       
   200 to the column aColumn.
       
   201 @param aColumn The column to extract. The first column is numbered zero.
       
   202 @param aSourceText The source text string that contains one or more column 
       
   203 separators.
       
   204 @param aColumnSeparator The character used in aSourceText to separate the columns. 
       
   205 By default, a tab character.
       
   206 @return KErrNotFound if the column number is invalid, otherwise KErrNone. */
       
   207 	{
       
   208 	aColumnText.Set(TPtrC());
       
   209 	TInt end=0;
       
   210 	TInt column=0;
       
   211 	TPtrC text;
       
   212 	if (aSourceText)
       
   213 		text.Set(*aSourceText);
       
   214 	while (text.Length())
       
   215 		{
       
   216 		end=text.Locate(aColumnSeparator);
       
   217 		if (end==KErrNotFound)
       
   218 			end=text.Length();
       
   219 		if (column==aColumn)
       
   220 			{
       
   221 			aColumnText.Set(text.Left(end));
       
   222 			return(KErrNone);
       
   223 			}
       
   224 		else if (++column>aColumn)
       
   225 			break;
       
   226 		if (end<text.Length())
       
   227 			++end;
       
   228 		text.Set(text.Mid(end));
       
   229 		}
       
   230 	return(KErrNotFound);
       
   231 	}
       
   232 
       
   233 EXPORT_C void TextUtils::TruncateToNumChars(TDes& aBuffer, TInt numChars)
       
   234 /** Truncates text to a number of characters.
       
   235 
       
   236 If truncation is required (because aBuffer contains more than numChars 
       
   237 characters), an ellipsis is added to the text as the last character.
       
   238 
       
   239 @param aBuffer On return, contains the truncated text.
       
   240 @param numChars The number of characters. */
       
   241 	{
       
   242 	if (aBuffer.Length() <= numChars)
       
   243 		return;
       
   244 	aBuffer.SetLength(numChars-1);
       
   245 	aBuffer.Append(KTextUtilClipEndChar);
       
   246 	}
       
   247 
       
   248 //
       
   249 // class FontUtils
       
   250 //
       
   251 
       
   252 enum { EMinFontHeight=4 };
       
   253 
       
   254 EXPORT_C void FontUtils::GetAvailableFontsL(const CGraphicsDevice& aDevice, CDesCArray& aFontNameList,TInt aFonts)
       
   255 /** Gets the list of typeface names available for the graphics device.
       
   256 
       
   257 @param aDevice The graphics device.
       
   258 @param aFontNameList On return, contains the list of typeface names.
       
   259 @param aFonts Can be used to specify which sorts of typefaces are required. 
       
   260 For possible values, see the flags defined in gulftflg.hrh 
       
   261 beginning with EGulAllFonts. */
       
   262 	{ // static
       
   263 	aFontNameList.Reset();
       
   264 	const TInt numTypefaces=aDevice.NumTypefaces();
       
   265 	TTypefaceSupport typefaceInfo;
       
   266 	for (TInt ii=0;ii<numTypefaces;ii++)
       
   267 		{
       
   268 		aDevice.TypefaceSupport(typefaceInfo,ii);
       
   269 		if (typefaceInfo.iTypeface.IsProportional())
       
   270 			{
       
   271 			if (aFonts==EGulMonospaceFontsOnly)
       
   272 				continue;
       
   273 			}
       
   274 		else if (aFonts==EGulNoMonospaceFonts || aFonts==EGulNoMonospaceOrSymbolFonts)
       
   275 			continue;
       
   276 		if (typefaceInfo.iTypeface.IsSymbol())
       
   277 			{
       
   278 			if (aFonts==EGulNoSymbolFonts || aFonts==EGulNoMonospaceOrSymbolFonts || aFonts==EGulMonospaceFontsOnly)
       
   279 				continue;
       
   280 			}
       
   281 		else if (aFonts==EGulSymbolFontsOnly)
       
   282 			continue;
       
   283 		aFontNameList.AppendL(typefaceInfo.iTypeface.iName);
       
   284 		}
       
   285 	}
       
   286 
       
   287 EXPORT_C TInt FontUtils::TypefaceAttributes(const CGraphicsDevice& aDevice, const TDesC& aTypefaceName)
       
   288 /** Gets the attributes of a named typeface, if supported by the graphics device.
       
   289 
       
   290 @param aDevice The graphics device.
       
   291 @param aTypefaceName The name of the typeface.
       
   292 @return The typeface attributes. Attributes are zero if the typeface is not 
       
   293 supported by the graphics device. Attribute values are defined in TTypeface. */
       
   294 	{
       
   295 	const TInt numTypefaces=aDevice.NumTypefaces();
       
   296 	TInt fontIndex;
       
   297 	for (fontIndex=0;fontIndex<numTypefaces;fontIndex++)
       
   298 		{
       
   299     	TTypefaceSupport typefaceInfo;
       
   300 		aDevice.TypefaceSupport(typefaceInfo,fontIndex);
       
   301 		if (typefaceInfo.iTypeface.iName==aTypefaceName)
       
   302 			return(typefaceInfo.iTypeface.Attributes());
       
   303 		}	
       
   304 	return(0);
       
   305 	}
       
   306 
       
   307 EXPORT_C TInt FontUtils::GetAvailableHeightsInTwipsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,CArrayFix<TInt>& aHeightList)
       
   308 /** Gets a list of all heights in twips, available for the named typeface and the 
       
   309 graphics device specified.
       
   310 
       
   311 @param aDevice The graphics device.
       
   312 @param aTypefaceName The name of the typeface.
       
   313 @param aHeightList On return, contains all available heights for the typeface, 
       
   314 in twips. 
       
   315 @return KErrNotSupported if the named typeface is not supported by the graphics 
       
   316 device, otherwise KErrNone. */
       
   317 	{ // static
       
   318 	aHeightList.Reset();
       
   319 	const TInt numTypefaces=aDevice.NumTypefaces();
       
   320 	TInt fontIndex;
       
   321 	for (fontIndex=0;fontIndex<numTypefaces;fontIndex++)
       
   322 		{
       
   323     	TTypefaceSupport typefaceInfo;
       
   324 		aDevice.TypefaceSupport(typefaceInfo,fontIndex);
       
   325 		if (typefaceInfo.iTypeface.iName==aTypefaceName)
       
   326 			break;
       
   327 		}
       
   328 	if (fontIndex>=numTypefaces)
       
   329 		return KErrNotSupported;
       
   330 	TTypefaceSupport typefaceInfo;
       
   331 	aDevice.TypefaceSupport(typefaceInfo,fontIndex);
       
   332 	const TInt numHeights=typefaceInfo.iNumHeights;
       
   333 	for (TInt ii=0;ii<numHeights;ii++)
       
   334 		{
       
   335 		const TInt height=aDevice.FontHeightInTwips(fontIndex,ii);
       
   336 		if (PointsFromTwips(height)>=EMinFontHeight)
       
   337 			aHeightList.AppendL(height);
       
   338 		}
       
   339 	return KErrNone;
       
   340 	}
       
   341 
       
   342 EXPORT_C TInt FontUtils::GetAvailableHeightsInTwipsAndPointsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,CArrayFix<TInt>& aTwipsList,CDesCArray& aPointsList)
       
   343 /** Gets a list of all heights in twips, available for the named typeface and the 
       
   344 graphics device specified.
       
   345 
       
   346 Also gets a list of heights in points, represented as character strings.
       
   347 
       
   348 @param aDevice The graphics device.
       
   349 @param aTypefaceName The name of the typeface.
       
   350 @param aTwipsList On return, contains all available heights for the typeface, 
       
   351 in twips.
       
   352 @param aPointsList On return, the heights in points, represented as character 
       
   353 strings.
       
   354 @return KErrNotSupported if the named typeface is not supported by the graphics 
       
   355 device, otherwise KErrNone. */
       
   356 	{ // static
       
   357 	aTwipsList.Reset();
       
   358 	aPointsList.Reset();
       
   359 	TInt err=GetAvailableHeightsInTwipsL(aDevice,aTypefaceName,aTwipsList);
       
   360 	if (err==KErrNotSupported)
       
   361 		return err;
       
   362 	const TInt count=aTwipsList.Count();
       
   363 	for (TInt ii=0;ii<count;ii++)
       
   364 		{
       
   365 		const TInt points=PointsFromTwips(aTwipsList[ii]);
       
   366 		if (points<EMinFontHeight)
       
   367 			continue;
       
   368 		TBuf<8> num;
       
   369 		num.Num(points);
       
   370 		aPointsList.AppendL(num);
       
   371 		}
       
   372 	return KErrNone;
       
   373 	}
       
   374 
       
   375 EXPORT_C TInt FontUtils::PointsFromTwips(TInt aTwips)
       
   376 /** Converts a number of twips to points. 
       
   377 
       
   378 @param aTwips A number of twips.
       
   379 @return A number of points. */
       
   380 	{ // static
       
   381 	//one point=20 twips
       
   382 	return (aTwips+10)/20;
       
   383 	}
       
   384 
       
   385 EXPORT_C TInt FontUtils::TwipsFromPoints(TInt aPoints)
       
   386 /** Converts a number of points into twips.
       
   387 
       
   388 @param aPoints A number of points.
       
   389 @return A number of twips. */
       
   390 	{ // static
       
   391 	//one point=20 twips
       
   392 	return (aPoints*20);
       
   393 	}
       
   394 
       
   395 EXPORT_C TInt FontUtils::TwipsFromPoints(const TDesC& aPoints)
       
   396 /** Converts a number of points held as text to twips.
       
   397 
       
   398 @param aPoints A number of points as text.
       
   399 @return A number of twips. */
       
   400 	{ // static
       
   401 	TInt digits=aPoints.Length();
       
   402 	TInt num=aPoints[--digits];
       
   403 	TInt count=0;
       
   404 	while (digits)
       
   405 		num+=aPoints[--digits]*(++count*10);
       
   406 	return TwipsFromPoints(num);
       
   407 	}
       
   408 
       
   409 EXPORT_C TInt FontUtils::IndexOfNearestHeight(CArrayFix<TInt>& aTwipsList,TInt aHeight)
       
   410 /** Gets the index into the supplied list of font heights of the closest  
       
   411 match to the font height specified.
       
   412 
       
   413 @param aTwipsList The twips list.
       
   414 @param aHeight The requested font height. This may be generated by a call to GetAvailableHeightsInTwipsL() 
       
   415 or GetAvailableHeightsInTwipsAndPointsL().
       
   416 @return The index into the list of the closest font height to aHeight. */
       
   417 	{ // static
       
   418 	TInt pos=0;
       
   419 	const TInt count=aTwipsList.Count();
       
   420 	for (TInt ii=0; ii<count; ii++)
       
   421 		{
       
   422 		if (aTwipsList[ii]>aHeight)
       
   423 			break;
       
   424 		pos=ii;
       
   425 		}
       
   426 	return pos;
       
   427 	}
       
   428 
       
   429 //
       
   430 // class ResourceUtils
       
   431 //
       
   432 
       
   433 EXPORT_C CFbsFont* ResourceUtils::CreateNamedScreenFontL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice)
       
   434 /** Creates and returns a named screen font from a NAMED_FONT resource.
       
   435 
       
   436 @param aResourceReader Resource reader to use to read the font information. 
       
   437 @param aScreenDevice The screen device for which the font will be created. 
       
   438 @return The screen font, whose size is in twips. The caller takes ownership. */
       
   439 	{
       
   440 	TFontSpec fontSpec;
       
   441 	fontSpec.iTypeface.iName=aResourceReader.ReadTPtrC();
       
   442 	fontSpec.iHeight=aResourceReader.ReadInt16();
       
   443 
       
   444 	TUint flags=aResourceReader.ReadUint16(); // a combination of EGulFontFlagXxxxs
       
   445 
       
   446 	fontSpec.iTypeface.SetIsProportional( !(flags&EGulFontFlagMono) );
       
   447 	
       
   448 	if (flags&EGulFontFlagBold)
       
   449 		fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold );
       
   450 
       
   451 	if (flags&EGulFontFlagItalic)
       
   452 		fontSpec.iFontStyle.SetPosture(EPostureItalic);
       
   453 
       
   454 	CFbsFont* font;
       
   455 	User::LeaveIfError(aScreenDevice.GetNearestFontInTwips((CFont*&)font,fontSpec));
       
   456 	return(font);
       
   457 	}
       
   458 
       
   459 EXPORT_C CFbsFont* ResourceUtils::CreateNamedScreenFontInPixelsL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice)
       
   460 /** Creates a named screen font in pixels from a NAMED_FONT resource.
       
   461 
       
   462 @param aResourceReader Resource reader to use to read the font information. 
       
   463 @param aScreenDevice The screen device for which the font will be created. 
       
   464 @return The screen font, whose size is in pixels. The caller takes ownership. */
       
   465 	{
       
   466 	TFontSpec fontSpec;
       
   467 	fontSpec.iTypeface.iName=aResourceReader.ReadTPtrC();
       
   468 	fontSpec.iHeight=aResourceReader.ReadInt16();
       
   469 
       
   470 	TUint flags=aResourceReader.ReadUint16(); // a combination of EGulFontFlagXxxxs
       
   471 
       
   472 	fontSpec.iTypeface.SetIsProportional( !(flags&EGulFontFlagMono) );
       
   473 	
       
   474 	if (flags&EGulFontFlagBold)
       
   475 		fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold );
       
   476 
       
   477 	if (flags&EGulFontFlagItalic)
       
   478 		fontSpec.iFontStyle.SetPosture(EPostureItalic);
       
   479 
       
   480 	CFbsFont* font;
       
   481 	User::LeaveIfError(aScreenDevice.GetNearestFontInPixels((CFont*&)font,fontSpec));
       
   482 	return(font);
       
   483 	}
       
   484 
       
   485 EXPORT_C CFbsFont* ResourceUtils::CreateScreenFontL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice)
       
   486 /** Creates a screen font from a FONT resource.
       
   487 
       
   488 @param aResourceReader Resource reader to use to read the font UID and flags. 
       
   489 @param aScreenDevice The screen device for which the font will be created. 
       
   490 @return The screen font. The caller takes ownership. */
       
   491 	{
       
   492 	TUid fontId;
       
   493 	fontId.iUid=aResourceReader.ReadInt32();
       
   494 	TUint flags=aResourceReader.ReadUint16(); // a combination of EGulFontFlagXxxxs
       
   495 	TAlgStyle algStyle;
       
   496 	algStyle.SetIsBold(flags&EGulFontFlagBold);
       
   497 	algStyle.SetIsItalic(flags&EGulFontFlagItalic);
       
   498 	algStyle.SetIsMono(flags&EGulFontFlagMono);
       
   499 	algStyle.SetWidthFactor((flags&EGulFontFlagDoubleWidth)? 2: 1); 
       
   500 	algStyle.SetHeightFactor((flags&EGulFontFlagDoubleHeight)? 2: 1);
       
   501 	CFbsFont* font;
       
   502 	User::LeaveIfError(aScreenDevice.GetFontById((CFont*&)font,fontId,algStyle));
       
   503 	return(font);
       
   504 	}
       
   505 
       
   506 EXPORT_C TInt32 ResourceUtils::ReadResourceIntL(TResourceReader& aReader,TResourceTypeInt aSize)
       
   507 //
       
   508 //	Read a resource specifying a number
       
   509 //
       
   510 	{
       
   511 	TInt32 value=0;
       
   512 	switch(aSize)
       
   513 		{
       
   514 	case EResourceInt8:
       
   515 		value=aReader.ReadInt8();
       
   516 		break;
       
   517 	case EResourceInt16:
       
   518 		value=aReader.ReadInt16();
       
   519 		break;
       
   520 	case EResourceInt32:
       
   521 		value=aReader.ReadInt32();
       
   522 		break;
       
   523 	default:
       
   524 		Panic(EEgulPanicResourceInvalidNumberType);
       
   525 		}
       
   526 	return(value);
       
   527 	}
       
   528 
       
   529 EXPORT_C void ResourceUtils::PopulateColorArrayL(CColorArray& aColors,TResourceReader& aReader)
       
   530 /** Populates an array of logical colours using a pre-initialised resource 
       
   531 reader from an array of CTRL_COLOR resources.
       
   532 
       
   533 @param aColors On return, contains the colour array read from the resource. 
       
   534 @param aReader Resource reader to use to read the colour array. */
       
   535 	{ // static
       
   536 	const TInt count=aReader.ReadInt16();
       
   537 	for (TInt ii=0;ii<count;ii++)
       
   538 		{
       
   539 		TInt logicalColor=aReader.ReadInt16();
       
   540 		TInt red=aReader.ReadUint8();
       
   541 		TInt green=aReader.ReadUint8();
       
   542 		TRgb color(red,green,aReader.ReadUint8());
       
   543 		aColors.AddL(logicalColor,color);
       
   544 		}
       
   545 	}
       
   546 
       
   547 
       
   548 //
       
   549 // class ColorUtils
       
   550 //
       
   551 
       
   552 EXPORT_C TRgb ColorUtils::ColorAdjust(TRgb aColor,TInt aPercentage)
       
   553 /** Brightens or darkens a 24-bit colour by a percentage. 
       
   554 
       
   555 If the percentage given is less than 100%, a darker colour will be returned. 
       
   556 The algorithm brightens or darkens each of the R, G and B channels equally.
       
   557 
       
   558 @param aColor Input colour. 
       
   559 @param aPercentage Percentage by which to adjust the input colour. 
       
   560 @return The adjusted colour. */
       
   561 	{
       
   562 	// Poor algorithm for the moment, but it can improve and all apps that
       
   563 	// use this will benefit. (I don't think the accuracy for a 16/256 color system
       
   564 	// is really relevant anyway)
       
   565 	TInt red=aColor.Red();
       
   566 	TInt green=aColor.Green();
       
   567 	TInt blue=aColor.Blue();
       
   568 	TInt alpha=aColor.Alpha();
       
   569 	if (aPercentage<=100)
       
   570 		{
       
   571 		red=(red * aPercentage)/100;
       
   572 		green=(green * aPercentage)/100;
       
   573 		blue=(blue * aPercentage)/100;
       
   574 		}
       
   575 	else
       
   576 		{
       
   577 		red = 255 - (((255 - red) * 100) / aPercentage);
       
   578 		green = 255 - (((255 - green) * 100) / aPercentage);
       
   579 		blue = 255 - (((255 - blue) * 100) / aPercentage);
       
   580 		}
       
   581 	return TRgb(red,green,blue,alpha);
       
   582 	}
       
   583 
       
   584 const TInt KDarkRgbSubtractor = 85;
       
   585 
       
   586 EXPORT_C TRgb ColorUtils::RgbDarkerColor(TRgb aRgb, TDisplayMode aMode)
       
   587 /** Creates a darker color.
       
   588 
       
   589 @param aRgb The RGB color.
       
   590 @param aMode The display mode, which indicates the screen output of the colour 
       
   591 e.g. 256 colour display mode (8 bpp).
       
   592 @return The darker colour. */
       
   593 	{
       
   594 	switch (aMode)
       
   595 		{
       
   596 	case EColor256:
       
   597 		return TRgb::Color256(color256darklutab[aRgb.Color256()]);
       
   598 	default:
       
   599 		TInt value = aRgb.Internal();
       
   600 		TInt b = Max( 0, ((value & 0x000000ff)  ) - KDarkRgbSubtractor );
       
   601 		TInt g = Max( 0, ((value & 0x0000ff00)  >> 8) - KDarkRgbSubtractor );
       
   602 		TInt r = Max( 0, ((value & 0x00ff0000)  >> 16) - KDarkRgbSubtractor );
       
   603 		return TRgb(r,g,b,aRgb.Alpha());
       
   604 		}
       
   605 	}
       
   606 
       
   607 const TInt KLightRgbAdder = 30;
       
   608 
       
   609 EXPORT_C TRgb ColorUtils::RgbLighterColor(TRgb aRgb, TDisplayMode aMode)
       
   610 /** Creates a lighter colour.
       
   611 
       
   612 @param aRgb The Rgb colour.
       
   613 @param aMode The display mode, which indicates the screen output of the colour 
       
   614 e.g. 256 colour display mode (8 bpp).
       
   615 @return The lighter colour. */
       
   616 	{
       
   617 	switch (aMode)
       
   618 		{
       
   619 	case EColor256:
       
   620 		return TRgb::Color256(color256lightlutab[aRgb.Color256()]);
       
   621 	default:
       
   622 		TInt value = aRgb.Internal();
       
   623 		TInt b = Min( 255, ((value & 0x000000ff)  ) + KLightRgbAdder );
       
   624 		TInt g = Min( 255, ((value & 0x0000ff00)  >> 8) + KLightRgbAdder );
       
   625 		TInt r = Min( 255, ((value & 0x00ff0000)  >> 16) + KLightRgbAdder );
       
   626 		return TRgb(r,g,b,aRgb.Alpha());
       
   627 		}
       
   628 	}
       
   629 
       
   630 const TInt KMidDarkRgbSubtractor = 42;
       
   631 
       
   632 EXPORT_C TRgb ColorUtils::RgbMidDarkerColor(TRgb aRgb, TDisplayMode aMode)
       
   633 /** Creates a medium dark version of the colour.
       
   634 
       
   635 This function darkens the colour 50% less than RgbDarkerColor().
       
   636 
       
   637 @param aRgb The Rgb color. 
       
   638 @param aMode The display mode, which indicates the screen output of the colour 
       
   639 e.g. 256 colour display mode (8 bpp).
       
   640 @return The medium dark colour. */
       
   641 	{
       
   642 	switch (aMode)
       
   643 		{
       
   644 	case EColor256:
       
   645 		return TRgb::Color256(color256middarklutab[aRgb.Color256()]);
       
   646 	default:
       
   647 		TInt value = aRgb.Internal();
       
   648 		TInt b = Max( 0, ((value & 0x000000ff)  ) - KMidDarkRgbSubtractor );
       
   649 		TInt g = Max( 0, ((value & 0x0000ff00)  >> 8) - KMidDarkRgbSubtractor );
       
   650 		TInt r = Max( 0, ((value & 0x00ff0000)  >> 16) - KMidDarkRgbSubtractor );
       
   651 		return TRgb(r,g,b,aRgb.Alpha());
       
   652 		}
       
   653 	}
       
   654 
       
   655 EXPORT_C void ColorUtils::GetRgbDerivedBorderColors(TGulBorder::TColors& aBorderColors,TRgb aBackgroundColor,TDisplayMode aMode)
       
   656 /** Gets the colours to use for a control's border.
       
   657 
       
   658 Lighter and darker tones in the border are derived from the specified TRgb 
       
   659 background colour using an algorithm operating on the RGB value of this color 
       
   660 or a lookup table, depending on the display mode aMode. It sets the values 
       
   661 of the aBorderColors members iBack, iLight, iMidlight, iMid, and iDark.
       
   662 
       
   663 @param aBorderColors On return, the derived border colours.
       
   664 @param aBackgroundColor The control's background colour. 
       
   665 @param aMode The display mode. */
       
   666 	{
       
   667 	aBorderColors.iBack = aBackgroundColor;
       
   668 	aBorderColors.iMid = RgbDarkerColor( aBorderColors.iBack, aMode );
       
   669 	aBorderColors.iDark = RgbDarkerColor( aBorderColors.iMid, aMode );
       
   670 	aBorderColors.iMidlight = RgbLighterColor( aBorderColors.iBack, aMode );
       
   671 	aBorderColors.iLight = RgbLighterColor( aBorderColors.iMidlight, aMode );
       
   672 	}
       
   673 
       
   674 //
       
   675 // The TGradientFill class is a private utility class that is used by the ColorUtils::CreateGradientBitmapL method
       
   676 //
       
   677 
       
   678 NONSHARABLE_CLASS(TGradientFill)
       
   679 	{
       
   680 public:
       
   681 	TGradientFill(CFbsBitmap& aBitmap,ColorUtils::TBitmapOrientation aOrientation,TRgb aStartColor,TRgb aEndColor);
       
   682 	void DrawBitmap();
       
   683 private:
       
   684 	void Calculate();
       
   685 	TRgb ColorAt(TInt aPos) const;
       
   686 	TRgb Map(const TRgb aRgb) const;
       
   687 	TInt Index(const TRgb aRgb) const;
       
   688 private:
       
   689 	CFbsBitmap& iBitmap;
       
   690 	ColorUtils::TBitmapOrientation iOrientation;
       
   691 	TRgb iStartColor;
       
   692 	TRgb iEndColor;
       
   693 	TDisplayMode iMode;
       
   694 	TInt iBitmapLength;
       
   695 	TUint32 iStartColRed;
       
   696 	TInt32 iDiffRed;
       
   697     TInt iRoundingRed;
       
   698 	TUint32 iStartColGreen;
       
   699 	TInt32 iDiffGreen;
       
   700     TInt iRoundingGreen;
       
   701 	TUint32 iStartColBlue;
       
   702 	TInt32 iDiffBlue;
       
   703     TInt iRoundingBlue;
       
   704 	};
       
   705 
       
   706 TGradientFill::TGradientFill(CFbsBitmap& aBitmap, ColorUtils::TBitmapOrientation aOrientation,
       
   707 							TRgb aStartColor,TRgb aEndColor) 
       
   708 : iBitmap(aBitmap), 
       
   709   iOrientation(aOrientation),
       
   710   iStartColor(aStartColor), 
       
   711   iEndColor(aEndColor), 
       
   712   iMode(aBitmap.DisplayMode()) 
       
   713 	{
       
   714 	}
       
   715 
       
   716 void TGradientFill::DrawBitmap()
       
   717 	{
       
   718     TBitmapUtil bitmapUtil(&iBitmap);
       
   719     bitmapUtil.Begin(TPoint(0,0)); 
       
   720     bitmapUtil.SetPos(TPoint(0,0));
       
   721 
       
   722 	Calculate();
       
   723 
       
   724 	TBool toggleDither = ETrue;
       
   725 
       
   726 	// Initialise the colors
       
   727 	TRgb thisMapped = Map(ColorAt(0));
       
   728 	TInt thisIndex = 0;
       
   729 	TRgb nextMapped = thisMapped;
       
   730 	TInt nextIndex = 0;
       
   731 
       
   732     for (TInt i=0;i<iBitmapLength;i++)
       
   733         {
       
   734 		// Update colors if necessary
       
   735 		thisMapped = Map(ColorAt(i));
       
   736 		TInt lookAhead=i;
       
   737 
       
   738 		FOREVER
       
   739 			{
       
   740 			if (lookAhead == (iBitmapLength-1))
       
   741 				{
       
   742 				break; // Reached end of gradient
       
   743 				}
       
   744 			TRgb testNext = ColorAt(++lookAhead);
       
   745 			TRgb testMapped = Map(testNext);
       
   746 			if (testMapped != thisMapped)
       
   747 				{
       
   748 				if (testMapped != nextMapped)
       
   749 					{
       
   750 					thisIndex = nextIndex;
       
   751 					nextMapped = testMapped;
       
   752 					nextIndex = lookAhead;
       
   753 					}
       
   754 				break;
       
   755 				}
       
   756 			}
       
   757 
       
   758 		TRgb pixelOne;
       
   759 		TRgb pixelTwo;
       
   760 		TInt range = nextIndex - thisIndex;
       
   761 
       
   762 		if ( (4*i) < ( (4*thisIndex)+range ) )
       
   763 			{
       
   764 			pixelOne = pixelTwo = thisMapped;
       
   765 			}
       
   766 		else if ( (4*i) < ( (4*thisIndex)+(3*range) ) )
       
   767 			{
       
   768 			pixelOne = thisMapped;
       
   769 			pixelTwo = nextMapped;
       
   770 			}
       
   771 		else 
       
   772 			{
       
   773 			pixelOne = pixelTwo = nextMapped;
       
   774 			}
       
   775 
       
   776 		if (toggleDither)
       
   777 			{
       
   778 			TRgb temp = pixelOne;
       
   779 			pixelOne = pixelTwo;
       
   780 			pixelTwo = temp;
       
   781 			}
       
   782 
       
   783 		toggleDither = !toggleDither;
       
   784 		
       
   785 		// Write out the pixels
       
   786 		bitmapUtil.SetPixel(Index(pixelOne));
       
   787         if(iOrientation==ColorUtils::EBitmapOrientationHorizontal)
       
   788             {
       
   789 			bitmapUtil.IncYPos();
       
   790 			bitmapUtil.SetPixel(Index(pixelTwo));
       
   791 			bitmapUtil.DecYPos();			
       
   792 			bitmapUtil.IncXPos();
       
   793             }
       
   794         else
       
   795 			{
       
   796             bitmapUtil.IncXPos();
       
   797 			bitmapUtil.SetPixel(Index(pixelTwo));
       
   798 			bitmapUtil.DecXPos();			
       
   799             bitmapUtil.IncYPos();
       
   800 			}
       
   801 		}
       
   802     bitmapUtil.End();
       
   803     }
       
   804 
       
   805 void TGradientFill::Calculate()
       
   806 	{
       
   807 	if (iOrientation==ColorUtils::EBitmapOrientationVertical)
       
   808 		iBitmapLength = iBitmap.SizeInPixels().iHeight; 
       
   809 	else
       
   810 		iBitmapLength = iBitmap.SizeInPixels().iWidth; 
       
   811 
       
   812 	const TUint32 rounding=(iBitmapLength+1)>>1;
       
   813 
       
   814 	iStartColRed=iStartColor.Red();
       
   815 	iDiffRed=iEndColor.Red()-iStartColRed;
       
   816     iRoundingRed=0;
       
   817     if (iDiffRed>0)
       
   818 		iRoundingRed+=rounding;
       
   819 	else
       
   820 		iRoundingRed-=rounding;
       
   821 
       
   822 	iStartColGreen=iStartColor.Green();
       
   823 	iDiffGreen=iEndColor.Green()-iStartColGreen;
       
   824     iRoundingGreen=0;
       
   825 	if (iDiffGreen>0)
       
   826 		iRoundingGreen+=rounding;
       
   827 	else
       
   828 		iRoundingGreen-=rounding;
       
   829 
       
   830 	iStartColBlue=iStartColor.Blue();
       
   831 	iDiffBlue=iEndColor.Blue()-iStartColBlue;
       
   832     iRoundingBlue=0;
       
   833 	if (iDiffBlue>0)
       
   834 		iRoundingBlue+=rounding;
       
   835 	else
       
   836 		iRoundingBlue-=rounding;
       
   837 	}
       
   838 
       
   839 TRgb TGradientFill::ColorAt(TInt aPos) const
       
   840 	{
       
   841 	TUint32 redCurrentVal = iStartColRed+((aPos*iDiffRed+iRoundingRed)/(iBitmapLength-1));
       
   842 	TUint32 greenCurrentVal = iStartColGreen+((aPos*iDiffGreen+iRoundingGreen)/(iBitmapLength-1));
       
   843 	TUint32 blueCurrentVal = iStartColBlue+((aPos*iDiffBlue+iRoundingBlue)/(iBitmapLength-1));
       
   844 	return TRgb(redCurrentVal,greenCurrentVal,blueCurrentVal);
       
   845 	}
       
   846 
       
   847 TRgb TGradientFill::Map(const TRgb aRgb) const
       
   848 	{
       
   849 	switch (iMode)
       
   850 		{
       
   851 	case EGray2:
       
   852 		return TRgb::Gray2(aRgb.Gray2());
       
   853 	case EGray4:
       
   854 		return TRgb::Gray4(aRgb.Gray4());
       
   855 	case EGray16:
       
   856 		return TRgb::Gray16(aRgb.Gray16());
       
   857 	case EGray256:
       
   858 		return TRgb::Gray256(aRgb.Gray256());
       
   859 	case EColor16:
       
   860 		return TRgb::Color16(aRgb.Color16());
       
   861 	case EColor256:
       
   862 		return TRgb::Color256(aRgb.Color256());
       
   863 	case EColor64K:
       
   864 		return TRgb::Color64K(aRgb.Color64K());
       
   865 	case EColor16M:
       
   866 		return TRgb::Color16M(aRgb.Color16M());
       
   867 	case EColor4K:
       
   868 		return TRgb::Color4K(aRgb.Color4K());
       
   869 	default:
       
   870 		return aRgb;
       
   871 		}
       
   872 	}
       
   873 
       
   874 TInt TGradientFill::Index(const TRgb aRgb) const
       
   875 	{
       
   876 	switch (iMode)
       
   877 		{
       
   878 	case EGray2:
       
   879 		return aRgb.Gray2();
       
   880 	case EGray4:
       
   881 		return aRgb.Gray4();
       
   882 	case EGray16:
       
   883 		return aRgb.Gray16();
       
   884 	case EGray256:
       
   885 		return aRgb.Gray256();
       
   886 	case EColor16:
       
   887 		return aRgb.Color16();
       
   888 	case EColor256:
       
   889 		return aRgb.Color256();
       
   890 	case EColor64K:
       
   891 		return aRgb.Color64K();
       
   892 	case EColor16M:
       
   893 		return aRgb.Color16M();
       
   894 	case EColor4K:
       
   895 		return aRgb.Color4K();
       
   896 	default:
       
   897 		return aRgb.Color16M();
       
   898 		}
       
   899 	}
       
   900 
       
   901 const TInt KBitmapBreadthPixels=2;
       
   902 
       
   903 EXPORT_C void ColorUtils::CreateGradientBitmapL(CFbsBitmap& aBitmap,  const RWsSession& aWs, TInt aBreadth,
       
   904 											   TBitmapOrientation aOrientation,TRgb aStartColor,TRgb aEndColor)
       
   905 /** Creates a CFbsBitmap containing a colour gradient.
       
   906 
       
   907 To create a gradient, the end colour aEndColor must be different to the 
       
   908 start colour aStartingColor.
       
   909 
       
   910 @param aBitmap Bitmap which on return contains the colour gradient.
       
   911 @param aWs Handle to a window server session. 
       
   912 @param aBreadth The width or the height of the bitmap, depending on the orientation.
       
   913 @param aOrientation The bitmap's orientation (vertical or horizontal).
       
   914 @param aStartColor The start color.
       
   915 @param aEndColor The end color. */
       
   916     { // static
       
   917     TInt grayscaleCapabilities;
       
   918 	TInt colorCapabilities;
       
   919     TDisplayMode displayMode=aWs.GetDefModeMaxNumColors(colorCapabilities,grayscaleCapabilities);
       
   920 	const TSize bmpSize=(aOrientation==EBitmapOrientationVertical?
       
   921 		TSize(KBitmapBreadthPixels,aBreadth) : TSize(aBreadth,KBitmapBreadthPixels));
       
   922 	User::LeaveIfError(aBitmap.Create(bmpSize,displayMode));
       
   923 	TGradientFill filler(aBitmap,aOrientation,aStartColor,aEndColor);
       
   924 	filler.DrawBitmap();
       
   925     }
       
   926 
       
   927 //
       
   928 // TFindWidthOfWidestTextItem
       
   929 //
       
   930 
       
   931 EXPORT_C TInt TFindWidthOfWidestTextItem::MaximumWidthInPixels(const CFont& aFont) const
       
   932 /** Gets the width in pixels of the widest item in the range, using the specified 
       
   933 font.
       
   934 
       
   935 @param aFont The font.
       
   936 @return The maximum width. */
       
   937 	{
       
   938 	TInt widthOfWidestTextItem=0;
       
   939 	TBuf<256> textItem;
       
   940 	TInt firstIndex;
       
   941 	TInt lastIndex;
       
   942 	GetFirstAndLastIndex(firstIndex, lastIndex);
       
   943 	for (TInt i=firstIndex; i<=lastIndex; ++i)
       
   944 		{
       
   945 		GetTextItem(textItem, i);
       
   946 		TInt widthOfTextItem=aFont.TextWidthInPixels(textItem);
       
   947 		if (widthOfWidestTextItem<widthOfTextItem)
       
   948 			widthOfWidestTextItem=widthOfTextItem;
       
   949 		}
       
   950 	return widthOfWidestTextItem;
       
   951 	}
       
   952 
       
   953 //
       
   954 // class TFindWidthOfWidestDigit
       
   955 //
       
   956 
       
   957 EXPORT_C TFindWidthOfWidestDigit::TFindWidthOfWidestDigit()
       
   958 /** Default constructor. */
       
   959 	{
       
   960 	}
       
   961 
       
   962 void TFindWidthOfWidestDigit::GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const
       
   963 	{
       
   964 	aFirstIndex='0';
       
   965 	aLastIndex='9';
       
   966 	}
       
   967 
       
   968 void TFindWidthOfWidestDigit::GetTextItem(TDes& aText, TInt aIndex) const
       
   969 	{
       
   970 	aText.SetLength(0);
       
   971 	aText.Append(aIndex);
       
   972 	}
       
   973 
       
   974 //
       
   975 // class TFindWidthOfWidestDigitType
       
   976 //
       
   977 
       
   978 EXPORT_C TFindWidthOfWidestDigitType::TFindWidthOfWidestDigitType(TDigitType aDigitType):
       
   979 	iDigitType(aDigitType)
       
   980 	{
       
   981 	__ASSERT_DEBUG(aDigitType != EDigitTypeUnknown, Panic(EEgulPanicInvalidDigitType));
       
   982 	__ASSERT_DEBUG(aDigitType != EDigitTypeAllTypes, Panic(EEgulPanicInvalidDigitType));
       
   983 	}
       
   984 
       
   985 void TFindWidthOfWidestDigitType::GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const
       
   986 	{
       
   987 	aFirstIndex='0';
       
   988 	aLastIndex='9';
       
   989 	}
       
   990 
       
   991 void TFindWidthOfWidestDigitType::GetTextItem(TDes& aText, TInt aIndex) const
       
   992 	{
       
   993 	aText.SetLength(0);
       
   994 	aText.Append(aIndex);
       
   995 	NumberConversion::ConvertDigits(aText, iDigitType);
       
   996 	}
       
   997 
       
   998 //
       
   999 // class TFindWidthOfWidestAmPmName
       
  1000 //
       
  1001 
       
  1002 EXPORT_C TFindWidthOfWidestAmPmName::TFindWidthOfWidestAmPmName()
       
  1003 /** Default constructor. */
       
  1004 	{
       
  1005 	}
       
  1006 
       
  1007 void TFindWidthOfWidestAmPmName::GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const
       
  1008 	{
       
  1009 	aFirstIndex=EAm;
       
  1010 	aLastIndex=EPm;
       
  1011 	}
       
  1012 
       
  1013 void TFindWidthOfWidestAmPmName::GetTextItem(TDes& aText, TInt aIndex) const
       
  1014 	{
       
  1015 	aText=TAmPmName((TAmPm)aIndex);
       
  1016 	}
       
  1017 
       
  1018 //
       
  1019 // TFindWidthOfWidestAbbreviatedDayName
       
  1020 //
       
  1021 
       
  1022 EXPORT_C TFindWidthOfWidestAbbreviatedDayName::TFindWidthOfWidestAbbreviatedDayName()
       
  1023 /** Default constructor. */
       
  1024 	{
       
  1025 	}
       
  1026 
       
  1027 void TFindWidthOfWidestAbbreviatedDayName::GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const
       
  1028 	{
       
  1029 	aFirstIndex=0;
       
  1030 	aLastIndex=6;
       
  1031 	}
       
  1032 
       
  1033 void TFindWidthOfWidestAbbreviatedDayName::GetTextItem(TDes& aText, TInt aIndex) const
       
  1034 	{
       
  1035 	aText=TDayNameAbb((TDay)aIndex);
       
  1036 	}
       
  1037 
       
  1038 //
       
  1039 // TFindWidthOfWidestDayName
       
  1040 //
       
  1041 
       
  1042 EXPORT_C TFindWidthOfWidestDayName::TFindWidthOfWidestDayName()
       
  1043 /** Default constructor. */
       
  1044 	{
       
  1045 	}
       
  1046 
       
  1047 void TFindWidthOfWidestDayName::GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const
       
  1048 	{
       
  1049 	aFirstIndex=0;
       
  1050 	aLastIndex=6;
       
  1051 	}
       
  1052 
       
  1053 void TFindWidthOfWidestDayName::GetTextItem(TDes& aText, TInt aIndex) const
       
  1054 	{
       
  1055 	aText=TDayName((TDay)aIndex);
       
  1056 	}
       
  1057 
       
  1058 //
       
  1059 // TFindWidthOfWidestAbbreviatedMonthName
       
  1060 
       
  1061 EXPORT_C TFindWidthOfWidestAbbreviatedMonthName::TFindWidthOfWidestAbbreviatedMonthName()
       
  1062 /** Default constructor. */
       
  1063 	{
       
  1064 	}
       
  1065 
       
  1066 void TFindWidthOfWidestAbbreviatedMonthName::GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const
       
  1067 	{
       
  1068 	aFirstIndex=0;
       
  1069 	aLastIndex=11;
       
  1070 	}
       
  1071 
       
  1072 void TFindWidthOfWidestAbbreviatedMonthName::GetTextItem(TDes& aText, TInt aIndex) const
       
  1073 	{
       
  1074 	aText=TMonthNameAbb((TMonth)aIndex);
       
  1075 	}
       
  1076 
       
  1077 //
       
  1078 // TFindWidthOfWidestMonthName
       
  1079 //
       
  1080 
       
  1081 EXPORT_C TFindWidthOfWidestMonthName::TFindWidthOfWidestMonthName()
       
  1082 /** Default constructor. */
       
  1083 	{
       
  1084 	}
       
  1085 
       
  1086 void TFindWidthOfWidestMonthName::GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const
       
  1087 	{
       
  1088 	aFirstIndex=0;
       
  1089 	aLastIndex=11;
       
  1090 	}
       
  1091 
       
  1092 void TFindWidthOfWidestMonthName::GetTextItem(TDes& aText, TInt aIndex) const
       
  1093 	{
       
  1094 	aText=TMonthName((TMonth)aIndex);
       
  1095 	}
       
  1096 
       
  1097 //
       
  1098 // TFindWidthOfWidestDateSuffix
       
  1099 //
       
  1100 
       
  1101 EXPORT_C TFindWidthOfWidestDateSuffix::TFindWidthOfWidestDateSuffix()
       
  1102 /** Default constructor. */
       
  1103 	{
       
  1104 	}
       
  1105 
       
  1106 void TFindWidthOfWidestDateSuffix::GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const
       
  1107 	{
       
  1108 	aFirstIndex=0;
       
  1109 	aLastIndex=30;
       
  1110 	}
       
  1111 
       
  1112 void TFindWidthOfWidestDateSuffix::GetTextItem(TDes& aText, TInt aIndex) const
       
  1113 	{
       
  1114 	aText=TDateSuffix(aIndex);
       
  1115 	}
       
  1116 
       
  1117