os/textandloc/textrendering/textformatting/test/src/TestPicture.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * TestPicture.cpp test picture.
    16 *
    17 */
    18 
    19 
    20 #include "TestPicture.h"
    21 
    22 CTestPicture::CTestPicture()
    23 	{
    24 	iLineBreaksAllowed[0] = ETrue;
    25 	iLineBreaksAllowed[1] = ETrue;
    26 	iLineBreaksAllowed[2] = ETrue;
    27 	iLineBreaksAllowed[3] = ETrue;
    28 	iSizeInTwips.iWidth = 100;
    29 	iSizeInTwips.iHeight = 100;
    30 	}
    31 
    32 //draw a red square
    33 void CTestPicture::Draw(CGraphicsContext& aGc, const TPoint& aTopLeft,
    34 	const TRect& aClipRect, MGraphicsDeviceMap* aMap) const
    35 	{
    36 	aGc.Reset();
    37 	aGc.SetClippingRect(aClipRect);
    38 	TSize size;  
    39 	GetSizeInPixels(aMap,size);
    40 	TRect box;  
    41 	box.iTl=aTopLeft;
    42 	box.iBr.iX=aTopLeft.iX+size.iWidth;
    43 	box.iBr.iY=aTopLeft.iY+size.iHeight;
    44 	TRgb red(255,0,0);
    45 	aGc.SetBrushColor(red);
    46 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    47 	aGc.DrawRect(box);
    48 	}
    49 
    50 /**
    51 Does nothing.
    52 @param aStream No effect.
    53 @internalComponent
    54 */
    55 void CTestPicture::ExternalizeL(RWriteStream& /*aStream*/) const
    56 	{
    57 	}
    58 
    59 /**
    60 Returns size of picture.
    61 @param aSize
    62 	Returns size of picture.
    63 @internalComponent
    64 */
    65 void CTestPicture::GetOriginalSizeInTwips(TSize& aSize) const
    66 	{
    67 	aSize = iSizeInTwips;
    68 	}
    69 
    70 /**
    71 Returns information supplied by SetLineBreaksAllowed.
    72 @param aClass
    73 	Not used.
    74 @param aBeforePicture As CPicture.
    75 @param aHaveSpaces As CPicture.
    76 @return TBool if line breaks are allowed.
    77 @internalComponent
    78 */
    79 TBool CTestPicture::LineBreakPossible(TUint /*aClass*/,
    80 	TBool aBeforePicture, TBool aHaveSpaces) const
    81 	{
    82 	TInt index = aBeforePicture? 0 : 2;
    83 	index += aHaveSpaces? 1 : 0;
    84 	return iLineBreaksAllowed[index];
    85 	}
    86 
    87 /**
    88 Set whether LineBreakPossible should return ETrue.
    89 @param aBeforeWithoutSpaces
    90 	Sets the result of LineBreakPossible(*, ETrue, EFalse);
    91 @param aBeforeWithSpaces
    92 	Sets the result of LineBreakPossible(*, ETrue, ETrue);
    93 @param aAfterWithoutSpaces
    94 	Sets the result of LineBreakPossible(*, EFalse, EFalse);
    95 @param aAfterWithSpaces
    96 	Sets the result of LineBreakPossible(*, EFalse, ETrue);
    97 @internalComponent
    98 */
    99 void CTestPicture::SetLineBreaksAllowed(
   100 	TBool aBeforeWithoutSpaces,
   101 	TBool aBeforeWithSpaces,
   102 	TBool aAfterWithoutSpaces,
   103 	TBool aAfterWithSpaces)
   104 	{
   105 	iLineBreaksAllowed[0] = aBeforeWithoutSpaces;
   106 	iLineBreaksAllowed[1] = aBeforeWithSpaces;
   107 	iLineBreaksAllowed[2] = aAfterWithoutSpaces;
   108 	iLineBreaksAllowed[3] = aAfterWithSpaces;
   109 	}
   110 
   111 /**
   112 Sets the picture size.
   113 @param aSize
   114 	The size to set.
   115 @internalComponent
   116 */
   117 void CTestPicture::SetSizeInTwips(TSize aSize)
   118 	{
   119 	iSizeInTwips = aSize;
   120 	}
   121 
   122 /**
   123 Sets the picture size so that the graphics device map aMap will convert to
   124 the size specified.
   125 @param aSize The size to set.
   126 @param aMap The graphics device in which aSize should be the size in pixels.
   127 @internalComponent
   128 */
   129 void CTestPicture::SetSizeInPixels(TSize aSize, const MGraphicsDeviceMap& aMap)
   130 	{
   131 	iSizeInTwips.iWidth = aMap.HorizontalTwipsToPixels(aSize.iWidth);
   132 	iSizeInTwips.iHeight = aMap.VerticalTwipsToPixels(aSize.iHeight);
   133 	}