Example #1
0
EXPORT_C TInt FontUtils::GetAvailableHeightsInTwipsAndPointsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,CArrayFix<TInt>& aTwipsList,CDesCArray& aPointsList)
/** Gets a list of all heights in twips, available for the named typeface and the 
graphics device specified.

Also gets a list of heights in points, represented as character strings.

@param aDevice The graphics device.
@param aTypefaceName The name of the typeface.
@param aTwipsList On return, contains all available heights for the typeface, 
in twips.
@param aPointsList On return, the heights in points, represented as character 
strings.
@return KErrNotSupported if the named typeface is not supported by the graphics 
device, otherwise KErrNone. */
	{ // static
	aTwipsList.Reset();
	aPointsList.Reset();
	TInt err=GetAvailableHeightsInTwipsL(aDevice,aTypefaceName,aTwipsList);
	if (err==KErrNotSupported)
		return err;
	const TInt count=aTwipsList.Count();
	for (TInt ii=0;ii<count;ii++)
		{
		const TInt points=PointsFromTwips(aTwipsList[ii]);
		if (points<EMinFontHeight)
			continue;
		TBuf<8> num;
		num.Num(points);
		aPointsList.AppendL(num);
		}
	return KErrNone;
	}
Example #2
0
EXPORT_C TInt FontUtils::GetAvailableHeightsInTwipsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,CArrayFix<TInt>& aHeightList)
/** Gets a list of all heights in twips, available for the named typeface and the 
graphics device specified.

@param aDevice The graphics device.
@param aTypefaceName The name of the typeface.
@param aHeightList On return, contains all available heights for the typeface, 
in twips. 
@return KErrNotSupported if the named typeface is not supported by the graphics 
device, otherwise KErrNone. */
	{ // static
	aHeightList.Reset();
	const TInt numTypefaces=aDevice.NumTypefaces();
	TInt fontIndex;
	for (fontIndex=0;fontIndex<numTypefaces;fontIndex++)
		{
    	TTypefaceSupport typefaceInfo;
		aDevice.TypefaceSupport(typefaceInfo,fontIndex);
		if (typefaceInfo.iTypeface.iName==aTypefaceName)
			break;
		}
	if (fontIndex>=numTypefaces)
		return KErrNotSupported;
	TTypefaceSupport typefaceInfo;
	aDevice.TypefaceSupport(typefaceInfo,fontIndex);
	const TInt numHeights=typefaceInfo.iNumHeights;
	for (TInt ii=0;ii<numHeights;ii++)
		{
		const TInt height=aDevice.FontHeightInTwips(fontIndex,ii);
		if (PointsFromTwips(height)>=EMinFontHeight)
			aHeightList.AppendL(height);
		}
	return KErrNone;
	}
Example #3
0
TBool CDataWrapperBase::GetPointListFromConfigL(const TDesC& aSectName, const TDesC& aKeyName, CArrayFix<TPoint>& aResult)
	{
	TBuf<KMaxTestExecuteCommandLength>	tempStore;
	TPoint								point;

	aResult.Reset();
	TBool	ok=ETrue;
	for ( TInt index=0; ok; )
		{
		tempStore.Format(KFormatFieldNumber, &aKeyName, ++index);
		ok=GetPointFromConfig(aSectName, tempStore, point);
		if ( ok )
			{
			aResult.AppendL(point);
			}
		}

	return aResult.Count()>0;
	}
Example #4
0
LOCAL_C void testFix(CArrayFix<TBuf<0x10> >& aFix)
//
// Test all methods
//
	{
	test.Next(_L("Test all methods"));
	test(aFix.Count()==0);
	test(aFix.Length()==sizeof(TBuf<0x10>));
	aFix.Compress();
	test(TRUE);
	aFix.Reset();
	test(TRUE);
	TKeyArrayFix kk(0,ECmpNormal,0x10);
	test(TRUE);
	aFix.Sort(kk);
	test(TRUE);
	TBuf<0x10> aa(_L("aaaaa"));
	aFix.InsertL(0,aa);
	test(TRUE);
	aFix[0].Fill(' ');
	test(TRUE);
	TBuf<0x10> z(aFix[0]);
    z.Length();
	test(TRUE);
	aFix[0].Fill('a');
	test(TRUE);
	TInt pp;
	test(aFix.Find(aa,kk,pp)==0);
	test(pp==0);
	aFix.Delete(0);
	TBuf<0x10> bb(_L("bbbbb"));
	aFix.AppendL(bb);
	test(aFix.Count()==1);
	test(aFix.InsertIsqAllowDuplicatesL(aa,kk)==0);
	test(aFix.InsertIsqAllowDuplicatesL(bb,kk)==2);
	test(aFix.FindIsq(aa,kk,pp)==0);
	test(pp==0);
	aFix.Reset();
	for(TInt index=0;index<KTestGranularity*7/2;index++)
		aFix.AppendL(aa);
	const TBuf<0x10> *end=NULL;
	const TBuf<0x10> *ptr=NULL;
	for(TInt index2=0;index2<KTestGranularity*7/2;index2++)
		{
		if (end==ptr)
			{
			end=aFix.End(index2);
			ptr=&aFix[index2];
			TInt seglen=end-ptr;
			test(seglen==KTestGranularity || seglen==(aFix.Count()-index2));
			}
		test(&aFix[index2]==ptr++);
		}
	const TBuf<0x10> *bak=NULL;
	ptr=NULL;
	for(TInt index3=KTestGranularity*7/2;index3>0;index3--)
		{
		if (bak==ptr)
			{
			bak=aFix.Back(index3);
			ptr=&aFix[index3-1]+1;
			TInt seglen=ptr-bak;
			test(seglen==KTestGranularity || seglen==index3 || seglen==index3%KTestGranularity);
			}
		test(&aFix[index3-1]==--ptr);
		}
	
	//Test ExpandL
	//Expand array in slot 1
	TBuf16<0x10> exp;
	exp=_L("abc AbC");
	aFix.InsertL(0,exp);
	aFix.InsertL(1,exp);
	aFix.InsertL(2,exp);
	exp=aFix.ExpandL(1);
	test(aFix[0]==_L("abc AbC"));
	test(aFix[1]==_L(""));
	test(aFix[2]==_L("abc AbC"));
	test(aFix[3]==_L("abc AbC"));
	
	//Test ResizeL and InsertReplL
	//Resize the array to containing 20 records,
	//copying a record into any new slots.
	TBuf<0x10> res(_L("bbbbb"));
	aFix.Reset();
	aFix.ResizeL(20,res);
	for(TInt i=0;i<20;i++)
	    {
        test(aFix[1]==_L("bbbbb"));
	    }
	}
Example #5
0
LOCAL_C void test2(CArrayFix<TArr<TText,4> >& aFix)
//
	{
	test(aFix.Length()==sizeof(TArr<TText,4>));
	test.Next(_L("AppendL and insert strings of length 4"));
	TPtrC des1=_L("abcd");
	TPtrC des2=_L("efgh");
	aFix.AppendL(*(const TArr<TText,4>*)des1.Ptr());
	aFix.AppendL(*(const TArr<TText,4>*)des2.Ptr());
	test(aFix.Count()==2);
	TPtrC des3(&aFix[0][0],4);
	TPtrC des4(&aFix[1][0],4);
	test(des3==_L("abcd"));
	test(des4==_L("efgh"));
	aFix.InsertL(1,*(const TArr<TText,4>*)_S("ijkl"));
	test(aFix.Count()==3);	
	TPtrC des5(&aFix[2][0],4);
	test(des3==_L("abcd"));
	test(des4==_L("ijkl"));
	test(des5==_L("efgh"));

	test.Next(_L("Reset and Compress"));
	aFix.Reset();
	TBuf<0x10> buf1=_L("abcdefgh");
	aFix.AppendL((const TArr<TText,4>*)buf1.Ptr(),2);
	aFix.Compress();
	TPtrC des6(&aFix[0][0],4);
	test(des6==_L("abcd"));
	TPtrC des7(&aFix[1][0],4);
	test(des7==_L("efgh"));
	buf1=_L("ghighhxy");
	aFix.InsertL(1,(const TArr<TText,4>*)buf1.Ptr(),2);
	aFix.Compress();
	TPtrC des8(&aFix[0][0],4);
	test(des8==_L("abcd"));
	TPtrC des9(&aFix[1][0],4);
	test(des9==_L("ghig"));
	TPtrC des10(&aFix[2][0],4);
	test(des10==_L("hhxy"));
	TPtrC des11(&aFix[3][0],4);
	test(des11==_L("efgh"));

	test.Next(_L("Sort strings"));
	TKeyArrayFix kk(0,ECmpNormal,0x04);
	aFix.Sort(kk);
	TPtrC des12(&aFix[0][0],4);
	test(des12==_L("abcd"));
	TPtrC des13(&aFix[1][0],4);
	test(des13==_L("efgh"));
	TPtrC des14(&aFix[2][0],4);
	test(des14==_L("ghig"));
	TPtrC des15(&aFix[3][0],4);
	test(des15==_L("hhxy"));
	
	test.Next(_L("Find and FindIsq"));
	aFix.Compress();
	test(aFix.InsertIsqL(*(const TArr<TText,4>*)_S("ffff"),kk)==2);
	aFix.Compress();
	test(aFix.InsertIsqAllowDuplicatesL(*(const TArr<TText,4>*)_S("ffff"),kk)==3);
	aFix.Compress();
	TRAPD(r,aFix.InsertIsqL(*(const TArr<TText,4>*)_S("ffff"),kk))
	test(r==KErrAlreadyExists);
	TInt aPos=0;
	test(aFix.Find(*(const TArr<TText,4>*)_S("xxxx"),kk,aPos)==1);
	test(aPos==6);
	test(aFix.Find(*(const TArr<TText,4>*)_S("abcd"),kk,aPos)==0);
	test(aPos==0);
	test(aFix.Find(*(const TArr<TText,4>*)_S("ghig"),kk,aPos)==0);
	test(aPos==4);
	test(aFix.Find(*(const TArr<TText,4>*)_S("ffff"),kk,aPos)==0);
	test(aPos==2);
	test(aFix.Find(*(const TArr<TText,4>*)_S("hhxy"),kk,aPos)==0);
	test(aPos==5);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("bbbb"),kk,aPos)!=0);
	test(aPos==1);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("abcd"),kk,aPos)==0);
	test(aPos==0);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("ghig"),kk,aPos)==0);
	test(aPos==4);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("ffff"),kk,aPos)==0);
	test(aPos==2);
	test(aFix.InsertIsqL(*(const TArr<TText,4>*)_S("fghz"),kk)==4);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("fghz"),kk,aPos)==0);
	test(aPos==4);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("hhxy"),kk,aPos)==0);
	test(aPos==6);
	}