sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "TGraphicsContext.h"
|
sl@0
|
20 |
#include <e32std.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
sl@0
|
23 |
#include <graphics/gdi/gdiconsts.h>
|
sl@0
|
24 |
#include <graphics/gdi/gdistructs.h>
|
sl@0
|
25 |
#endif
|
sl@0
|
26 |
|
sl@0
|
27 |
_LIT(KTestFontName, "Non Functional Test Font");
|
sl@0
|
28 |
|
sl@0
|
29 |
|
sl@0
|
30 |
// Utility functions to show contents of test data using test.Printf
|
sl@0
|
31 |
|
sl@0
|
32 |
extern void PrintTestData (const TDesC& aTitle , const TDesC16& aDataBuffer);
|
sl@0
|
33 |
|
sl@0
|
34 |
extern void PrintTestData(const TDesC& aTitle, const TText16* aDataBuffer, const TInt aSize);
|
sl@0
|
35 |
|
sl@0
|
36 |
//
|
sl@0
|
37 |
//
|
sl@0
|
38 |
// CLineArray
|
sl@0
|
39 |
//
|
sl@0
|
40 |
//
|
sl@0
|
41 |
CLineArray::CLineArray() : iArrayIsEnabled(ETrue), iArray(0)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
iPrev = iNext = this;
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
void CLineArray::Null()
|
sl@0
|
47 |
{
|
sl@0
|
48 |
if (iNext == this && iArray)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
iArray->Close();
|
sl@0
|
51 |
delete iArray;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
iArray = 0;
|
sl@0
|
54 |
iPrev->iNext = iNext;
|
sl@0
|
55 |
iNext->iPrev = iPrev;
|
sl@0
|
56 |
iNext = iPrev = this;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
CLineArray::~CLineArray()
|
sl@0
|
60 |
{
|
sl@0
|
61 |
Null();
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
void CLineArray::ConstructL(TInt aGranularity)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
CLineArray::Null();
|
sl@0
|
67 |
iArray = new (ELeave) RArray<TTestGCDisplayLine>(aGranularity);
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
void CLineArray::Copy(const CLineArray& aOther)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
CLineArray::Null();
|
sl@0
|
73 |
iNext = &aOther;
|
sl@0
|
74 |
iPrev = aOther.iPrev;
|
sl@0
|
75 |
iPrev->iNext = this;
|
sl@0
|
76 |
aOther.iPrev = this;
|
sl@0
|
77 |
iArray = aOther.iArray;
|
sl@0
|
78 |
iArrayIsEnabled = aOther.iArrayIsEnabled;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
void CLineArray::ResetLineArray()
|
sl@0
|
82 |
{
|
sl@0
|
83 |
iArray->Reset();
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
const TTestGCDisplayLine& CLineArray::Line(TInt aIndex)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
return (*iArray)[aIndex];
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
const TTestGCDisplayLine* CLineArray::Find(const TDesC& aText)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
TInt count = LinesPresent();
|
sl@0
|
94 |
for (TInt i = 0; i != count; ++i)
|
sl@0
|
95 |
{
|
sl@0
|
96 |
const TTestGCDisplayLine& line = Line(i);
|
sl@0
|
97 |
if (line.iLineData.Find(aText) != KErrNotFound)
|
sl@0
|
98 |
return &line;
|
sl@0
|
99 |
}
|
sl@0
|
100 |
return 0;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
void CLineArray::AddLineL(TTestGCDisplayLine& aLine)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
if (iArrayIsEnabled)
|
sl@0
|
106 |
User::LeaveIfError(iArray->Append(aLine));
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
TInt CLineArray::LinesPresent()
|
sl@0
|
110 |
{
|
sl@0
|
111 |
return iArray->Count();
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
//
|
sl@0
|
115 |
//
|
sl@0
|
116 |
// CTestGraphicsDevice
|
sl@0
|
117 |
//
|
sl@0
|
118 |
//
|
sl@0
|
119 |
CTestGraphicsDevice* CTestGraphicsDevice::NewL(TSize aSizeInPixels, RWsSession* aWsSession)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
CTestGraphicsDevice* r = aWsSession?
|
sl@0
|
122 |
new (ELeave) CTestGraphicsDevice(aSizeInPixels, aWsSession)
|
sl@0
|
123 |
: new (ELeave) CTestGraphicsDevice(aSizeInPixels);
|
sl@0
|
124 |
r->iLineArray.ConstructL(4);
|
sl@0
|
125 |
if (aWsSession && KErrNone != r->Construct())
|
sl@0
|
126 |
{
|
sl@0
|
127 |
delete r;
|
sl@0
|
128 |
return 0;
|
sl@0
|
129 |
}
|
sl@0
|
130 |
return r;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
|
sl@0
|
133 |
CTestGraphicsDevice::CTestGraphicsDevice(TSize aSizeInPixels, RWsSession* aWsSession)
|
sl@0
|
134 |
: CWsScreenDevice(*aWsSession)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
Set(aSizeInPixels);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
CTestGraphicsDevice::CTestGraphicsDevice(TSize aSizeInPixels)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
Set(aSizeInPixels);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
void CTestGraphicsDevice::Set(TSize aSizeInPixels)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
iSize = aSizeInPixels;
|
sl@0
|
147 |
iHorizontalTwipsToPixels = 40;
|
sl@0
|
148 |
iVerticalTwipsToPixels = 40;
|
sl@0
|
149 |
iPalette.SetEntry(0, KRgbBlack);
|
sl@0
|
150 |
iPalette.SetEntry(1, KRgbWhite);
|
sl@0
|
151 |
iPalette.SetEntry(2, KRgbMagenta);
|
sl@0
|
152 |
iPalette.SetEntry(3, KRgbCyan);
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
void CTestGraphicsDevice::SetHorizontalTwipsToPixels(TInt aTwipsToPixels)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
iHorizontalTwipsToPixels = aTwipsToPixels;
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
void CTestGraphicsDevice::SetVerticalTwipsToPixels(TInt aTwipsToPixels)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
iVerticalTwipsToPixels = aTwipsToPixels;
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
TDisplayMode CTestGraphicsDevice::DisplayMode() const
|
sl@0
|
166 |
{
|
sl@0
|
167 |
return EColor16M;
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
TSize CTestGraphicsDevice::SizeInPixels() const
|
sl@0
|
171 |
{
|
sl@0
|
172 |
return iSize;
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
TSize CTestGraphicsDevice::SizeInTwips() const
|
sl@0
|
176 |
{
|
sl@0
|
177 |
return TSize(iSize.iWidth * iHorizontalTwipsToPixels,
|
sl@0
|
178 |
iSize.iHeight * iVerticalTwipsToPixels);
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
TInt CTestGraphicsDevice::CreateContext(CWindowGc*& aGC)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
CTestGraphicsContext* r = new CTestGraphicsContext(this);
|
sl@0
|
184 |
if (!r)
|
sl@0
|
185 |
return KErrNoMemory;
|
sl@0
|
186 |
// only contruct if it is a fully-fledged Window Server thing
|
sl@0
|
187 |
if (iBuffer)
|
sl@0
|
188 |
r->Construct();
|
sl@0
|
189 |
aGC = r;
|
sl@0
|
190 |
return KErrNone;
|
sl@0
|
191 |
}
|
sl@0
|
192 |
|
sl@0
|
193 |
TInt CTestGraphicsDevice::CreateContext(CGraphicsContext*& aGC)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
CWindowGc* p;
|
sl@0
|
196 |
TInt r = CreateContext(p);
|
sl@0
|
197 |
aGC = p;
|
sl@0
|
198 |
return r;
|
sl@0
|
199 |
}
|
sl@0
|
200 |
|
sl@0
|
201 |
TInt CTestGraphicsDevice::NumTypefaces() const
|
sl@0
|
202 |
{
|
sl@0
|
203 |
return 1;
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
void CTestGraphicsDevice::TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const
|
sl@0
|
207 |
{
|
sl@0
|
208 |
// The only font we have at the moment is 10 pixels * 12 pixels for every character
|
sl@0
|
209 |
__ASSERT_ALWAYS(aTypefaceIndex == 0,
|
sl@0
|
210 |
CTestGraphicsContext::Panic(CTestGraphicsContext::ETypefaceIndexOutOfRange));
|
sl@0
|
211 |
aTypefaceSupport.iIsScalable = EFalse;
|
sl@0
|
212 |
aTypefaceSupport.iMaxHeightInTwips = iVerticalTwipsToPixels * 12;
|
sl@0
|
213 |
aTypefaceSupport.iMinHeightInTwips = iVerticalTwipsToPixels * 10;
|
sl@0
|
214 |
aTypefaceSupport.iNumHeights = 1;
|
sl@0
|
215 |
aTypefaceSupport.iTypeface.iName = KTestFontName;
|
sl@0
|
216 |
aTypefaceSupport.iTypeface.SetIsProportional(ETrue); // a bit of a lie
|
sl@0
|
217 |
aTypefaceSupport.iTypeface.SetIsSerif(EFalse);
|
sl@0
|
218 |
aTypefaceSupport.iTypeface.SetIsSymbol(EFalse);
|
sl@0
|
219 |
}
|
sl@0
|
220 |
|
sl@0
|
221 |
TInt CTestGraphicsDevice::FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const
|
sl@0
|
222 |
{
|
sl@0
|
223 |
// The only font we have at the moment is 10 pixels * 12 pixels for every character
|
sl@0
|
224 |
__ASSERT_ALWAYS(aTypefaceIndex == 0,
|
sl@0
|
225 |
CTestGraphicsContext::Panic(CTestGraphicsContext::ETypefaceIndexOutOfRange));
|
sl@0
|
226 |
return iVerticalTwipsToPixels * FontHeightInPixels(aTypefaceIndex, aHeightIndex);
|
sl@0
|
227 |
}
|
sl@0
|
228 |
|
sl@0
|
229 |
void CTestGraphicsDevice::PaletteAttributes(TBool& aModifiable, TInt& aNumEntries) const
|
sl@0
|
230 |
{
|
sl@0
|
231 |
aModifiable = ETrue;
|
sl@0
|
232 |
aNumEntries = 4;
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
void CTestGraphicsDevice::SetPalette(CPalette* aPalette)
|
sl@0
|
236 |
{
|
sl@0
|
237 |
for (TInt i = 0; i != CTestPalette::KNumEntries; ++i)
|
sl@0
|
238 |
{
|
sl@0
|
239 |
TRgb col = aPalette->GetEntry(i);
|
sl@0
|
240 |
iPalette.SetEntry(i, col);
|
sl@0
|
241 |
}
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
TInt CTestGraphicsDevice::GetPalette(CPalette*& aPalette) const
|
sl@0
|
245 |
{
|
sl@0
|
246 |
aPalette = const_cast<CTestPalette*>(&iPalette);
|
sl@0
|
247 |
return KErrNone;
|
sl@0
|
248 |
}
|
sl@0
|
249 |
|
sl@0
|
250 |
void CTestGraphicsDevice::GetPixel(TRgb& aColor, const TPoint&) const
|
sl@0
|
251 |
{
|
sl@0
|
252 |
aColor = KRgbWhite;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
void CTestGraphicsDevice::GetScanLine(TDes8&, const TPoint&, TInt, TDisplayMode) const
|
sl@0
|
256 |
{
|
sl@0
|
257 |
__ASSERT_DEBUG(0, CTestGraphicsContext::Panic(CTestGraphicsContext::EUnimplemented));
|
sl@0
|
258 |
}
|
sl@0
|
259 |
|
sl@0
|
260 |
TInt CTestGraphicsDevice::AddFile(const TDesC&, TInt&)
|
sl@0
|
261 |
{
|
sl@0
|
262 |
return KErrNotSupported;
|
sl@0
|
263 |
}
|
sl@0
|
264 |
|
sl@0
|
265 |
void CTestGraphicsDevice::RemoveFile(TInt)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
}
|
sl@0
|
268 |
|
sl@0
|
269 |
TInt CTestGraphicsDevice::GetNearestFontInPixels(CFont*& aFont, const TFontSpec&)
|
sl@0
|
270 |
{
|
sl@0
|
271 |
CTestFont* font = new CTestFont();
|
sl@0
|
272 |
if (!font)
|
sl@0
|
273 |
return KErrNoMemory;
|
sl@0
|
274 |
aFont = font;
|
sl@0
|
275 |
return KErrNone;
|
sl@0
|
276 |
}
|
sl@0
|
277 |
|
sl@0
|
278 |
TInt CTestGraphicsDevice::FontHeightInPixels(TInt, TInt) const
|
sl@0
|
279 |
{
|
sl@0
|
280 |
return 12;
|
sl@0
|
281 |
}
|
sl@0
|
282 |
|
sl@0
|
283 |
TInt CTestGraphicsDevice::HorizontalTwipsToPixels(TInt aTwips) const
|
sl@0
|
284 |
{
|
sl@0
|
285 |
return aTwips / iHorizontalTwipsToPixels;
|
sl@0
|
286 |
}
|
sl@0
|
287 |
|
sl@0
|
288 |
TInt CTestGraphicsDevice::VerticalTwipsToPixels(TInt aTwips) const
|
sl@0
|
289 |
{
|
sl@0
|
290 |
return aTwips / iVerticalTwipsToPixels;
|
sl@0
|
291 |
}
|
sl@0
|
292 |
|
sl@0
|
293 |
TInt CTestGraphicsDevice::HorizontalPixelsToTwips(TInt aPixels) const
|
sl@0
|
294 |
{
|
sl@0
|
295 |
return aPixels * iHorizontalTwipsToPixels;
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|
sl@0
|
298 |
TInt CTestGraphicsDevice::VerticalPixelsToTwips(TInt aPixels) const
|
sl@0
|
299 |
{
|
sl@0
|
300 |
return aPixels * iVerticalTwipsToPixels;
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
TInt CTestGraphicsDevice::GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
|
sl@0
|
304 |
{
|
sl@0
|
305 |
TFontSpec fontSpec = aFontSpec;
|
sl@0
|
306 |
fontSpec.iHeight = VerticalTwipsToPixels(fontSpec.iHeight);
|
sl@0
|
307 |
return GetNearestFontInPixels(aFont, fontSpec);
|
sl@0
|
308 |
}
|
sl@0
|
309 |
|
sl@0
|
310 |
void CTestGraphicsDevice::ReleaseFont(CFont* aFont)
|
sl@0
|
311 |
{
|
sl@0
|
312 |
__ASSERT_ALWAYS(aFont->TypeUid() == TUid::Uid(12345),
|
sl@0
|
313 |
CTestGraphicsContext::Panic(CTestGraphicsContext::EUnknownFont));
|
sl@0
|
314 |
delete static_cast<CTestFont*>(aFont);
|
sl@0
|
315 |
}
|
sl@0
|
316 |
|
sl@0
|
317 |
void CTestGraphicsDevice::AddRectToDrawnArea(const TRect& aRect, TBool aCondition)
|
sl@0
|
318 |
{
|
sl@0
|
319 |
// check if the drawing is on testing area
|
sl@0
|
320 |
if (!(iTestingArea.IsEmpty()) && // if testing area has been set
|
sl@0
|
321 |
!iHasDrawnOnTestingArea) // and nothing hasn't been drawn on it so far
|
sl@0
|
322 |
iHasDrawnOnTestingArea = iTestingArea.Intersects(aRect);
|
sl@0
|
323 |
|
sl@0
|
324 |
if (iDrawnArea.IsEmpty())
|
sl@0
|
325 |
iDrawnArea = aRect;
|
sl@0
|
326 |
else
|
sl@0
|
327 |
iDrawnArea.BoundingRect(aRect);
|
sl@0
|
328 |
// only one condition at the moment
|
sl@0
|
329 |
if (aCondition)
|
sl@0
|
330 |
{
|
sl@0
|
331 |
if (iAreaDrawnWithCondition.IsEmpty())
|
sl@0
|
332 |
iAreaDrawnWithCondition = aRect;
|
sl@0
|
333 |
else
|
sl@0
|
334 |
iAreaDrawnWithCondition.BoundingRect(aRect);
|
sl@0
|
335 |
}
|
sl@0
|
336 |
}
|
sl@0
|
337 |
|
sl@0
|
338 |
void CTestGraphicsDevice::SetTestingArea(TRect& aTestingArea)
|
sl@0
|
339 |
{
|
sl@0
|
340 |
iTestingArea = aTestingArea;
|
sl@0
|
341 |
}
|
sl@0
|
342 |
|
sl@0
|
343 |
void CTestGraphicsDevice::AddTestingArea(TRect& moreTestingArea)
|
sl@0
|
344 |
{
|
sl@0
|
345 |
if (iTestingArea.IsEmpty())
|
sl@0
|
346 |
iTestingArea = moreTestingArea;
|
sl@0
|
347 |
else
|
sl@0
|
348 |
iTestingArea.BoundingRect(moreTestingArea);
|
sl@0
|
349 |
}
|
sl@0
|
350 |
|
sl@0
|
351 |
//
|
sl@0
|
352 |
//
|
sl@0
|
353 |
// CTestGraphicsContext
|
sl@0
|
354 |
//
|
sl@0
|
355 |
//
|
sl@0
|
356 |
void CTestGraphicsContext::Panic(TInt aReason)
|
sl@0
|
357 |
{
|
sl@0
|
358 |
User::Panic(_L("CTestGC"), aReason);
|
sl@0
|
359 |
}
|
sl@0
|
360 |
|
sl@0
|
361 |
CTestGraphicsContext::CTestGraphicsContext(CTestGraphicsDevice* aGd)
|
sl@0
|
362 |
: CWindowGc(aGd), iGd(aGd), iDrawMode(EDrawModePEN), iPenSize(1,1)
|
sl@0
|
363 |
{
|
sl@0
|
364 |
iLineArray.Copy(aGd->LineArray());
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
TInt CTestGraphicsContext::Construct()
|
sl@0
|
368 |
{
|
sl@0
|
369 |
return CWindowGc::Construct();
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
void CTestGraphicsContext::AddRectToDrawnArea(const TRect& aRect)
|
sl@0
|
373 |
{
|
sl@0
|
374 |
TRect drawnRect = aRect;
|
sl@0
|
375 |
drawnRect.Grow(iPenSize);
|
sl@0
|
376 |
iGd->AddRectToDrawnArea(drawnRect,
|
sl@0
|
377 |
iDrawMode == EDrawModeXOR || iDrawMode == EDrawModeNOTSCREEN);
|
sl@0
|
378 |
}
|
sl@0
|
379 |
|
sl@0
|
380 |
void CTestGraphicsContext::AddPointToDrawnArea(const TPoint& aPoint)
|
sl@0
|
381 |
{
|
sl@0
|
382 |
AddRectToDrawnArea(TRect(aPoint, iPenSize));
|
sl@0
|
383 |
}
|
sl@0
|
384 |
|
sl@0
|
385 |
CGraphicsDevice* CTestGraphicsContext::Device() const
|
sl@0
|
386 |
{
|
sl@0
|
387 |
return iGd;
|
sl@0
|
388 |
}
|
sl@0
|
389 |
|
sl@0
|
390 |
void CTestGraphicsContext::SetOrigin(const TPoint& aPos)
|
sl@0
|
391 |
{
|
sl@0
|
392 |
iOrigin = aPos;
|
sl@0
|
393 |
}
|
sl@0
|
394 |
|
sl@0
|
395 |
void CTestGraphicsContext::SetDrawMode(TDrawMode aDrawingMode)
|
sl@0
|
396 |
{
|
sl@0
|
397 |
iDrawMode = aDrawingMode;
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
void CTestGraphicsContext::SetClippingRect(const TRect& /*aRect*/)
|
sl@0
|
401 |
{
|
sl@0
|
402 |
}
|
sl@0
|
403 |
|
sl@0
|
404 |
void CTestGraphicsContext::CancelClippingRect()
|
sl@0
|
405 |
{
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
TInt CTestGraphicsContext::SetClippingRegion(const TRegion& /*aRegion*/)
|
sl@0
|
409 |
{
|
sl@0
|
410 |
return KErrNone;
|
sl@0
|
411 |
}
|
sl@0
|
412 |
|
sl@0
|
413 |
void CTestGraphicsContext::CancelClippingRegion()
|
sl@0
|
414 |
{
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
void CTestGraphicsContext::Reset()
|
sl@0
|
418 |
{
|
sl@0
|
419 |
iDrawMode = EDrawModePEN;
|
sl@0
|
420 |
iFont = 0;
|
sl@0
|
421 |
iPenSize.iWidth = 1;
|
sl@0
|
422 |
iPenSize.iHeight = 1;
|
sl@0
|
423 |
}
|
sl@0
|
424 |
|
sl@0
|
425 |
void CTestGraphicsContext::UseFont(const CFont* aFont)
|
sl@0
|
426 |
{
|
sl@0
|
427 |
iFont = aFont;
|
sl@0
|
428 |
}
|
sl@0
|
429 |
|
sl@0
|
430 |
void CTestGraphicsContext::DiscardFont()
|
sl@0
|
431 |
{
|
sl@0
|
432 |
iFont = 0;
|
sl@0
|
433 |
}
|
sl@0
|
434 |
|
sl@0
|
435 |
void CTestGraphicsContext::SetUnderlineStyle(TFontUnderline /*UnderlineStyle*/)
|
sl@0
|
436 |
{
|
sl@0
|
437 |
}
|
sl@0
|
438 |
|
sl@0
|
439 |
void CTestGraphicsContext::SetStrikethroughStyle(TFontStrikethrough /*aStrikethroughStyle*/)
|
sl@0
|
440 |
{
|
sl@0
|
441 |
}
|
sl@0
|
442 |
|
sl@0
|
443 |
void CTestGraphicsContext::SetWordJustification(TInt /*aExcessWidth*/,TInt /*aNumGaps*/)
|
sl@0
|
444 |
{
|
sl@0
|
445 |
}
|
sl@0
|
446 |
|
sl@0
|
447 |
void CTestGraphicsContext::SetCharJustification(TInt /*aExcessWidth*/,TInt /*aNumChars*/)
|
sl@0
|
448 |
{
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
void CTestGraphicsContext::SetPenColor(const TRgb& aColor)
|
sl@0
|
452 |
{
|
sl@0
|
453 |
CPalette* palette;
|
sl@0
|
454 |
iGd->GetPalette(palette);
|
sl@0
|
455 |
iPenColorIndex = palette->NearestIndex(aColor);
|
sl@0
|
456 |
}
|
sl@0
|
457 |
|
sl@0
|
458 |
void CTestGraphicsContext::SetPenStyle(TPenStyle /*aPenStyle*/)
|
sl@0
|
459 |
{
|
sl@0
|
460 |
}
|
sl@0
|
461 |
|
sl@0
|
462 |
void CTestGraphicsContext::SetPenSize(const TSize& aSize)
|
sl@0
|
463 |
{
|
sl@0
|
464 |
iPenSize = aSize;
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|
sl@0
|
467 |
void CTestGraphicsContext::SetBrushColor(const TRgb& /*aColor*/)
|
sl@0
|
468 |
{
|
sl@0
|
469 |
}
|
sl@0
|
470 |
|
sl@0
|
471 |
void CTestGraphicsContext::SetBrushStyle(TBrushStyle /*aBrushStyle*/)
|
sl@0
|
472 |
{
|
sl@0
|
473 |
}
|
sl@0
|
474 |
|
sl@0
|
475 |
void CTestGraphicsContext::SetBrushOrigin(const TPoint& /*aOrigin*/)
|
sl@0
|
476 |
{
|
sl@0
|
477 |
}
|
sl@0
|
478 |
|
sl@0
|
479 |
void CTestGraphicsContext::UseBrushPattern(const CFbsBitmap* /*aBitmap*/)
|
sl@0
|
480 |
{
|
sl@0
|
481 |
}
|
sl@0
|
482 |
|
sl@0
|
483 |
void CTestGraphicsContext::DiscardBrushPattern()
|
sl@0
|
484 |
{
|
sl@0
|
485 |
}
|
sl@0
|
486 |
|
sl@0
|
487 |
void CTestGraphicsContext::MoveTo(const TPoint& aPoint)
|
sl@0
|
488 |
{
|
sl@0
|
489 |
iCurrentPos = iOrigin + aPoint;
|
sl@0
|
490 |
}
|
sl@0
|
491 |
|
sl@0
|
492 |
void CTestGraphicsContext::MoveBy(const TPoint& aVector)
|
sl@0
|
493 |
{
|
sl@0
|
494 |
iCurrentPos += aVector;
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
void CTestGraphicsContext::Plot(const TPoint& aPoint)
|
sl@0
|
498 |
{
|
sl@0
|
499 |
iCurrentPos = iOrigin + aPoint;
|
sl@0
|
500 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
501 |
}
|
sl@0
|
502 |
|
sl@0
|
503 |
void CTestGraphicsContext::DrawArc(const TRect& aRect,const TPoint& /*aStart*/,const TPoint& aEnd)
|
sl@0
|
504 |
{
|
sl@0
|
505 |
TRect r = aRect;
|
sl@0
|
506 |
r.Move(iOrigin);
|
sl@0
|
507 |
AddRectToDrawnArea(r);
|
sl@0
|
508 |
iCurrentPos = iOrigin + aEnd;
|
sl@0
|
509 |
}
|
sl@0
|
510 |
|
sl@0
|
511 |
void CTestGraphicsContext::DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)
|
sl@0
|
512 |
{
|
sl@0
|
513 |
AddPointToDrawnArea(iOrigin + aPoint1);
|
sl@0
|
514 |
iCurrentPos = iOrigin + aPoint2;
|
sl@0
|
515 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
516 |
}
|
sl@0
|
517 |
|
sl@0
|
518 |
void CTestGraphicsContext::DrawLineTo(const TPoint& aPoint)
|
sl@0
|
519 |
{
|
sl@0
|
520 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
521 |
iCurrentPos = iOrigin + aPoint;
|
sl@0
|
522 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
523 |
}
|
sl@0
|
524 |
|
sl@0
|
525 |
void CTestGraphicsContext::DrawLineBy(const TPoint& aVector)
|
sl@0
|
526 |
{
|
sl@0
|
527 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
528 |
iCurrentPos += aVector;
|
sl@0
|
529 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
530 |
}
|
sl@0
|
531 |
|
sl@0
|
532 |
void CTestGraphicsContext::DrawPolyLine(const CArrayFix<TPoint>* aPointList)
|
sl@0
|
533 |
{
|
sl@0
|
534 |
TInt num = aPointList->Count();
|
sl@0
|
535 |
while (num--)
|
sl@0
|
536 |
{
|
sl@0
|
537 |
iCurrentPos = iOrigin + (*aPointList)[num - 1];
|
sl@0
|
538 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
539 |
}
|
sl@0
|
540 |
}
|
sl@0
|
541 |
|
sl@0
|
542 |
void CTestGraphicsContext::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)
|
sl@0
|
543 |
{
|
sl@0
|
544 |
while (aNumPoints--)
|
sl@0
|
545 |
{
|
sl@0
|
546 |
iCurrentPos = iOrigin + aPointList[aNumPoints - 1];
|
sl@0
|
547 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
548 |
}
|
sl@0
|
549 |
}
|
sl@0
|
550 |
|
sl@0
|
551 |
void CTestGraphicsContext::DrawPie(const TRect& aRect,
|
sl@0
|
552 |
const TPoint& /*aStart*/, const TPoint& aEnd)
|
sl@0
|
553 |
{
|
sl@0
|
554 |
TRect r = aRect;
|
sl@0
|
555 |
r.Move(iOrigin);
|
sl@0
|
556 |
AddRectToDrawnArea(r);
|
sl@0
|
557 |
iCurrentPos = iOrigin + aEnd;
|
sl@0
|
558 |
}
|
sl@0
|
559 |
|
sl@0
|
560 |
void CTestGraphicsContext::DrawEllipse(const TRect& aRect)
|
sl@0
|
561 |
{
|
sl@0
|
562 |
TRect r = aRect;
|
sl@0
|
563 |
r.Move(iOrigin);
|
sl@0
|
564 |
AddRectToDrawnArea(r);
|
sl@0
|
565 |
}
|
sl@0
|
566 |
|
sl@0
|
567 |
void CTestGraphicsContext::DrawRect(const TRect& aRect)
|
sl@0
|
568 |
{
|
sl@0
|
569 |
TRect r = aRect;
|
sl@0
|
570 |
r.Move(iOrigin);
|
sl@0
|
571 |
AddRectToDrawnArea(r);
|
sl@0
|
572 |
}
|
sl@0
|
573 |
|
sl@0
|
574 |
void CTestGraphicsContext::DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)
|
sl@0
|
575 |
{
|
sl@0
|
576 |
TRect r = aRect;
|
sl@0
|
577 |
r.Move(iOrigin);
|
sl@0
|
578 |
r.Grow(aCornerSize);
|
sl@0
|
579 |
AddRectToDrawnArea(r);
|
sl@0
|
580 |
}
|
sl@0
|
581 |
|
sl@0
|
582 |
TInt CTestGraphicsContext::DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule /*aFillRule*/)
|
sl@0
|
583 |
{
|
sl@0
|
584 |
TInt num = aPointList->Count();
|
sl@0
|
585 |
while (num--)
|
sl@0
|
586 |
{
|
sl@0
|
587 |
iCurrentPos = iOrigin + (*aPointList)[num - 1];
|
sl@0
|
588 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
589 |
}
|
sl@0
|
590 |
return KErrNone;
|
sl@0
|
591 |
}
|
sl@0
|
592 |
|
sl@0
|
593 |
TInt CTestGraphicsContext::DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule /*aFillRule*/)
|
sl@0
|
594 |
{
|
sl@0
|
595 |
while (aNumPoints--)
|
sl@0
|
596 |
{
|
sl@0
|
597 |
iCurrentPos = iOrigin + aPointList[aNumPoints - 1];
|
sl@0
|
598 |
AddPointToDrawnArea(iCurrentPos);
|
sl@0
|
599 |
}
|
sl@0
|
600 |
return KErrNone;
|
sl@0
|
601 |
}
|
sl@0
|
602 |
|
sl@0
|
603 |
void CTestGraphicsContext::DrawBitmap(const TPoint& /*aTopLeft*/,const CFbsBitmap* /*aSource*/)
|
sl@0
|
604 |
{
|
sl@0
|
605 |
}
|
sl@0
|
606 |
|
sl@0
|
607 |
void CTestGraphicsContext::DrawBitmap(const TRect& /*aDestRect*/,const CFbsBitmap* /*aSource*/)
|
sl@0
|
608 |
{
|
sl@0
|
609 |
}
|
sl@0
|
610 |
|
sl@0
|
611 |
void CTestGraphicsContext::DrawBitmap(const TRect& /*aDestRect*/,const CFbsBitmap* /*aSource*/,const TRect& /*aSourceRect*/)
|
sl@0
|
612 |
{
|
sl@0
|
613 |
}
|
sl@0
|
614 |
|
sl@0
|
615 |
void CTestGraphicsContext::DrawText(const TDesC& aText, const TPoint& aPosition)
|
sl@0
|
616 |
{
|
sl@0
|
617 |
#ifdef PRINT_DRAWTEXT_LINES
|
sl@0
|
618 |
|
sl@0
|
619 |
_LIT(KDrawTextTitle, "Text being drawn");
|
sl@0
|
620 |
PrintTestData(KDrawTextTitle, aText);
|
sl@0
|
621 |
|
sl@0
|
622 |
#endif /* PRINT_DRAWTEXT_LINES */
|
sl@0
|
623 |
|
sl@0
|
624 |
TTestGCDisplayLine thisLine;
|
sl@0
|
625 |
thisLine.Set(aPosition, aText);
|
sl@0
|
626 |
iLineArray.AddLineL(thisLine);
|
sl@0
|
627 |
}
|
sl@0
|
628 |
|
sl@0
|
629 |
void CTestGraphicsContext::DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,
|
sl@0
|
630 |
TTextAlign /*aAlignment*/, TInt aLeftMargin)
|
sl@0
|
631 |
{
|
sl@0
|
632 |
TPoint pos(aBox.iBr.iX + aLeftMargin, aBox.iTl.iY + aBaselineOffset);
|
sl@0
|
633 |
pos += iOrigin;
|
sl@0
|
634 |
DrawText(aText, pos);
|
sl@0
|
635 |
}
|
sl@0
|
636 |
|
sl@0
|
637 |
void CTestGraphicsContext::DrawText(const TDesC& aText,TTextParameters* aParam, const TPoint& aPosition)
|
sl@0
|
638 |
{
|
sl@0
|
639 |
#ifdef PRINT_DRAWTEXT_LINES
|
sl@0
|
640 |
|
sl@0
|
641 |
_LIT(KDrawTextTitle, "Text being drawn");
|
sl@0
|
642 |
PrintTestData(KDrawTextTitle, aText);
|
sl@0
|
643 |
|
sl@0
|
644 |
#endif /* PRINT_DRAWTEXT_LINES */
|
sl@0
|
645 |
|
sl@0
|
646 |
//Avoid crash by ASSERT in BitGdi DrawText function
|
sl@0
|
647 |
__ASSERT_ALWAYS(aParam->iStart < aParam->iEnd,
|
sl@0
|
648 |
CTestGraphicsContext::Panic(CTestGraphicsContext::EErrorParameter));
|
sl@0
|
649 |
|
sl@0
|
650 |
TTestGCDisplayLine thisLine;
|
sl@0
|
651 |
TPtrC actualText = aText.Mid(aParam->iStart,aParam->iEnd - aParam->iStart + 1);
|
sl@0
|
652 |
thisLine.Set(aPosition, actualText);
|
sl@0
|
653 |
iLineArray.AddLineL(thisLine);
|
sl@0
|
654 |
}
|
sl@0
|
655 |
|
sl@0
|
656 |
void CTestGraphicsContext::DrawText(const TDesC& aText,TTextParameters* aParam,const TRect& aBox,TInt aBaselineOffset,
|
sl@0
|
657 |
TTextAlign /*aAlignment*/, TInt aLeftMargin)
|
sl@0
|
658 |
{
|
sl@0
|
659 |
TPoint pos(aBox.iBr.iX + aLeftMargin, aBox.iTl.iY + aBaselineOffset);
|
sl@0
|
660 |
pos += iOrigin;
|
sl@0
|
661 |
DrawText(aText,aParam, pos);
|
sl@0
|
662 |
}
|
sl@0
|
663 |
|
sl@0
|
664 |
TInt CTestGraphicsContext::APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput)
|
sl@0
|
665 |
{
|
sl@0
|
666 |
if (aUid == KDrawTextInContextUid)
|
sl@0
|
667 |
{
|
sl@0
|
668 |
TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput;
|
sl@0
|
669 |
DrawText(contextParam->iText, &contextParam->iParam, contextParam->iPosition);
|
sl@0
|
670 |
return KErrNone;
|
sl@0
|
671 |
}
|
sl@0
|
672 |
else if (aUid == KDrawBoxTextInContextUid)
|
sl@0
|
673 |
{
|
sl@0
|
674 |
TDrawTextInContextInternal* contextParam = (TDrawTextInContextInternal*)aInput;
|
sl@0
|
675 |
DrawText(contextParam->iText,&contextParam->iParam,contextParam->iBox,contextParam->iBaselineOffset,contextParam->iAlign,contextParam->iMargin);
|
sl@0
|
676 |
return KErrNone;
|
sl@0
|
677 |
}
|
sl@0
|
678 |
// Future cases may be placed here later
|
sl@0
|
679 |
else
|
sl@0
|
680 |
return CWindowGc::APIExtension(aUid, aOutput, aInput);
|
sl@0
|
681 |
}
|
sl@0
|
682 |
|
sl@0
|
683 |
|
sl@0
|
684 |
void CTestGraphicsContext::Clear()
|
sl@0
|
685 |
{
|
sl@0
|
686 |
}
|
sl@0
|
687 |
|
sl@0
|
688 |
void CTestGraphicsContext::Clear(const TRect& /*aRect*/)
|
sl@0
|
689 |
{
|
sl@0
|
690 |
}
|
sl@0
|
691 |
|
sl@0
|
692 |
void CTestGraphicsContext::CopyRect(const TPoint& /*aOffset*/, const TRect& /*aRect*/)
|
sl@0
|
693 |
{
|
sl@0
|
694 |
}
|
sl@0
|
695 |
|
sl@0
|
696 |
void CTestGraphicsContext::BitBlt(const TPoint& /*aPoint*/, const CFbsBitmap* /*aBitmap*/)
|
sl@0
|
697 |
{
|
sl@0
|
698 |
}
|
sl@0
|
699 |
|
sl@0
|
700 |
void CTestGraphicsContext::BitBlt(const TPoint& /*aPoint*/, const CFbsBitmap* /*aBitmap*/,
|
sl@0
|
701 |
const TRect& /*aRect*/)
|
sl@0
|
702 |
{
|
sl@0
|
703 |
}
|
sl@0
|
704 |
|
sl@0
|
705 |
void CTestGraphicsContext::BitBltMasked(const TPoint& /*aPoint*/, const CFbsBitmap* /*aBitmap*/,
|
sl@0
|
706 |
const TRect& /*aSourceRect*/, const CFbsBitmap* /*aMaskBitmap*/, TBool /*aInvertMask*/)
|
sl@0
|
707 |
{
|
sl@0
|
708 |
}
|
sl@0
|
709 |
|
sl@0
|
710 |
void CTestGraphicsContext::SetFaded(TBool)
|
sl@0
|
711 |
{
|
sl@0
|
712 |
}
|
sl@0
|
713 |
|
sl@0
|
714 |
void CTestGraphicsContext::SetFadingParameters(TUint8,TUint8)
|
sl@0
|
715 |
{
|
sl@0
|
716 |
}
|
sl@0
|
717 |
|
sl@0
|
718 |
//
|
sl@0
|
719 |
//
|
sl@0
|
720 |
// CTestFont
|
sl@0
|
721 |
//
|
sl@0
|
722 |
//
|
sl@0
|
723 |
inline TBool IsSurrogate(TText a) { return 0xD800 == (a & 0xF800); }
|
sl@0
|
724 |
inline TBool IsHighSurrogate(TText a) { return 0xD800 == (a & 0xFC00); }
|
sl@0
|
725 |
inline TBool IsLowSurrogate(TText a) { return 0xDC00 == (a & 0xFC00); }
|
sl@0
|
726 |
inline TChar PairSurrogates(TText aHigh, TText aLow)
|
sl@0
|
727 |
{
|
sl@0
|
728 |
return ((aHigh - 0xd7f7) << 10) + aLow;
|
sl@0
|
729 |
}
|
sl@0
|
730 |
|
sl@0
|
731 |
TUid CTestFont::DoTypeUid() const
|
sl@0
|
732 |
{
|
sl@0
|
733 |
return TUid::Uid(12345);
|
sl@0
|
734 |
}
|
sl@0
|
735 |
|
sl@0
|
736 |
TInt CTestFont::DoHeightInPixels() const
|
sl@0
|
737 |
{
|
sl@0
|
738 |
return 12;
|
sl@0
|
739 |
}
|
sl@0
|
740 |
|
sl@0
|
741 |
TInt CTestFont::DoAscentInPixels() const
|
sl@0
|
742 |
{
|
sl@0
|
743 |
return 10;
|
sl@0
|
744 |
}
|
sl@0
|
745 |
|
sl@0
|
746 |
struct TSpecialSizes
|
sl@0
|
747 |
{
|
sl@0
|
748 |
TInt iCharacter;
|
sl@0
|
749 |
TInt iWidth;
|
sl@0
|
750 |
};
|
sl@0
|
751 |
|
sl@0
|
752 |
static const TSpecialSizes KSpecialSizes[] =
|
sl@0
|
753 |
{
|
sl@0
|
754 |
{ CTestFont::KThreePerEmSpace, 3 },
|
sl@0
|
755 |
{ CTestFont::KThinSpace, 2 },
|
sl@0
|
756 |
{ CTestFont::KHairSpace, 1 },
|
sl@0
|
757 |
{ CTestFont::KZeroWidthSpace, 0 },
|
sl@0
|
758 |
{ CTestFont::KZeroWidthNoBreakSpace, 0 },
|
sl@0
|
759 |
};
|
sl@0
|
760 |
|
sl@0
|
761 |
TInt CTestFont::DoCharWidthInPixels(TChar aChar) const
|
sl@0
|
762 |
{
|
sl@0
|
763 |
TInt cn = aChar;
|
sl@0
|
764 |
// non-characters 0x??FFFE and 0x??FFFF
|
sl@0
|
765 |
if ((cn & 0xFFFE) == 0xFFFE)
|
sl@0
|
766 |
return 0;
|
sl@0
|
767 |
|
sl@0
|
768 |
// Find character in the special sizes table
|
sl@0
|
769 |
TInt first = 0;
|
sl@0
|
770 |
TInt last = sizeof(KSpecialSizes)/sizeof(KSpecialSizes[0]);
|
sl@0
|
771 |
while (first != last)
|
sl@0
|
772 |
{
|
sl@0
|
773 |
TInt c = static_cast<TInt>(aChar);
|
sl@0
|
774 |
TInt mid = (first + last) >> 1;
|
sl@0
|
775 |
if (c < KSpecialSizes[mid].iCharacter)
|
sl@0
|
776 |
last = mid;
|
sl@0
|
777 |
else if (KSpecialSizes[mid].iCharacter < c)
|
sl@0
|
778 |
first = mid + 1;
|
sl@0
|
779 |
else
|
sl@0
|
780 |
return KSpecialSizes[mid].iWidth;
|
sl@0
|
781 |
}
|
sl@0
|
782 |
|
sl@0
|
783 |
return 10;
|
sl@0
|
784 |
}
|
sl@0
|
785 |
|
sl@0
|
786 |
TInt CTestFont::DoTextCount(const TDesC& aText, TInt aWidthInPixels,
|
sl@0
|
787 |
TInt& aExcessWidthInPixels) const
|
sl@0
|
788 |
{
|
sl@0
|
789 |
const TText* p = &aText[0];
|
sl@0
|
790 |
const TText* pEnd = p + aText.Length();
|
sl@0
|
791 |
TInt total = 0;
|
sl@0
|
792 |
TInt prevSurrogate = 0;
|
sl@0
|
793 |
TInt charactersThatFit = 0;
|
sl@0
|
794 |
while (p != pEnd)
|
sl@0
|
795 |
{
|
sl@0
|
796 |
TChar c = *p;
|
sl@0
|
797 |
if (IsSurrogate(*p))
|
sl@0
|
798 |
{
|
sl@0
|
799 |
c = 0xFFFF;
|
sl@0
|
800 |
if (IsHighSurrogate(*p))
|
sl@0
|
801 |
prevSurrogate = *p;
|
sl@0
|
802 |
else if (prevSurrogate != 0)
|
sl@0
|
803 |
{
|
sl@0
|
804 |
c = PairSurrogates(static_cast<TText>(prevSurrogate), *p);
|
sl@0
|
805 |
prevSurrogate = 0;
|
sl@0
|
806 |
}
|
sl@0
|
807 |
}
|
sl@0
|
808 |
else
|
sl@0
|
809 |
prevSurrogate = 0;
|
sl@0
|
810 |
total += CharWidthInPixels(c);
|
sl@0
|
811 |
if (total <= aWidthInPixels)
|
sl@0
|
812 |
++charactersThatFit;
|
sl@0
|
813 |
++p;
|
sl@0
|
814 |
}
|
sl@0
|
815 |
aExcessWidthInPixels = total - aWidthInPixels;
|
sl@0
|
816 |
return charactersThatFit;
|
sl@0
|
817 |
}
|
sl@0
|
818 |
|
sl@0
|
819 |
TInt CTestFont::DoTextWidthInPixels(const TDesC& aText) const
|
sl@0
|
820 |
{
|
sl@0
|
821 |
TInt excess;
|
sl@0
|
822 |
TextCount(aText, 0, excess);
|
sl@0
|
823 |
return excess;
|
sl@0
|
824 |
}
|
sl@0
|
825 |
|
sl@0
|
826 |
TInt CTestFont::DoBaselineOffsetInPixels() const
|
sl@0
|
827 |
{
|
sl@0
|
828 |
return 10;
|
sl@0
|
829 |
}
|
sl@0
|
830 |
|
sl@0
|
831 |
TInt CTestFont::DoTextCount(const TDesC& aText,TInt aWidthInPixels) const
|
sl@0
|
832 |
{
|
sl@0
|
833 |
TInt excess;
|
sl@0
|
834 |
return TextCount(aText, aWidthInPixels, excess);
|
sl@0
|
835 |
}
|
sl@0
|
836 |
|
sl@0
|
837 |
TInt CTestFont::DoMaxCharWidthInPixels() const
|
sl@0
|
838 |
{
|
sl@0
|
839 |
return 10;
|
sl@0
|
840 |
}
|
sl@0
|
841 |
|
sl@0
|
842 |
TInt CTestFont::DoMaxNormalCharWidthInPixels() const
|
sl@0
|
843 |
{
|
sl@0
|
844 |
return 10;
|
sl@0
|
845 |
}
|
sl@0
|
846 |
|
sl@0
|
847 |
TFontSpec CTestFont::DoFontSpecInTwips() const
|
sl@0
|
848 |
{
|
sl@0
|
849 |
return TFontSpec(KTestFontName, 12);
|
sl@0
|
850 |
}
|
sl@0
|
851 |
|
sl@0
|
852 |
CFont::TCharacterDataAvailability
|
sl@0
|
853 |
CTestFont::DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,
|
sl@0
|
854 |
const TUint8*& aBitmap, TSize& aBitmapSize) const
|
sl@0
|
855 |
{
|
sl@0
|
856 |
TInt width;
|
sl@0
|
857 |
switch (aCode)
|
sl@0
|
858 |
{
|
sl@0
|
859 |
case 0x001B:
|
sl@0
|
860 |
// ESC character should cause this fault; no character data available.
|
sl@0
|
861 |
return CFont::ENoCharacterData;
|
sl@0
|
862 |
case 'W':
|
sl@0
|
863 |
// We want 'W' to have side-bearings
|
sl@0
|
864 |
CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
|
sl@0
|
865 |
width = aMetrics.Width();
|
sl@0
|
866 |
aMetrics.SetHorizBearingX(-1);
|
sl@0
|
867 |
aMetrics.SetWidth(width + 2);
|
sl@0
|
868 |
return CFont::ECharacterWidthOnly ;
|
sl@0
|
869 |
case '/':
|
sl@0
|
870 |
// We want / to have a left side-bearing
|
sl@0
|
871 |
CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
|
sl@0
|
872 |
width = aMetrics.Width();
|
sl@0
|
873 |
aMetrics.SetHorizBearingX(-1);
|
sl@0
|
874 |
aMetrics.SetWidth(width + 1);
|
sl@0
|
875 |
return CFont::ECharacterWidthOnly ;
|
sl@0
|
876 |
case 'D':
|
sl@0
|
877 |
// We want 'D' to have a left side-bearing only
|
sl@0
|
878 |
CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
|
sl@0
|
879 |
aMetrics.SetHorizBearingX(-1);
|
sl@0
|
880 |
return CFont::ECharacterWidthOnly ;
|
sl@0
|
881 |
case KTav:
|
sl@0
|
882 |
// We want Hebrew Tav to have a +ve left side-bearing
|
sl@0
|
883 |
CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
|
sl@0
|
884 |
aMetrics.SetHorizBearingX(1);
|
sl@0
|
885 |
return CFont::ECharacterWidthOnly ;
|
sl@0
|
886 |
case KFullWidthSolidus:
|
sl@0
|
887 |
// We want fw/ to have a right side-bearing
|
sl@0
|
888 |
CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
|
sl@0
|
889 |
width = aMetrics.Width();
|
sl@0
|
890 |
aMetrics.SetWidth(width + 1);
|
sl@0
|
891 |
return CFont::ECharacterWidthOnly ;
|
sl@0
|
892 |
case KArabicWaw:
|
sl@0
|
893 |
// Arabic Waw-- has massive left side-bearing
|
sl@0
|
894 |
CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
|
sl@0
|
895 |
width = aMetrics.Width();
|
sl@0
|
896 |
aMetrics.SetHorizBearingX(-5);
|
sl@0
|
897 |
aMetrics.SetWidth(width + 5);
|
sl@0
|
898 |
return CFont::ECharacterWidthOnly ;
|
sl@0
|
899 |
default:
|
sl@0
|
900 |
return CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
|
sl@0
|
901 |
}
|
sl@0
|
902 |
}
|
sl@0
|
903 |
|