sl@0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <gdi.h>
|
sl@0
|
17 |
#include <bidi.h>
|
sl@0
|
18 |
#include "GDIPANIC.h"
|
sl@0
|
19 |
#include "gdistructs.h"
|
sl@0
|
20 |
#include "gdiconsts.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
// Global panic function
|
sl@0
|
24 |
|
sl@0
|
25 |
_LIT(KGdiPanicCategory,"GDI");
|
sl@0
|
26 |
|
sl@0
|
27 |
void Panic(TGdiPanic aError)
|
sl@0
|
28 |
{
|
sl@0
|
29 |
User::Panic(KGdiPanicCategory,aError);
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
_LIT(KGDIPanicDesc1, "Gdi internal Panic %S, in file %S @ line %i");
|
sl@0
|
33 |
_LIT(KGDIPanicDesc2, "Assert condition = \"%S\"");
|
sl@0
|
34 |
_LIT(KGDIPanicDesc3, "Gdi internal %S, in file %S @ line %i");
|
sl@0
|
35 |
|
sl@0
|
36 |
void PanicWithCondAndInfo(TGdiPanic aError, const TDesC& aCondition, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine)
|
sl@0
|
37 |
{
|
sl@0
|
38 |
TBuf<256> buf;
|
sl@0
|
39 |
buf.Format(KGDIPanicDesc1, &aPanicName, &aFileName, aLine);
|
sl@0
|
40 |
RDebug::Print(buf);
|
sl@0
|
41 |
|
sl@0
|
42 |
buf.Format(KGDIPanicDesc2, &aCondition);
|
sl@0
|
43 |
RDebug::Print(buf);
|
sl@0
|
44 |
Panic(aError);
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
void PanicLogWithInfo(const TDesC& aCommand, const TDesC& aCondition, const TDesC& aFileName, TInt aLine)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
TBuf<256> buf;
|
sl@0
|
50 |
buf.Format(KGDIPanicDesc3, &aCommand, &aFileName, aLine);
|
sl@0
|
51 |
RDebug::Print(buf);
|
sl@0
|
52 |
|
sl@0
|
53 |
buf.Format(KGDIPanicDesc2, &aCondition);
|
sl@0
|
54 |
RDebug::Print(buf);
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
|
sl@0
|
58 |
//
|
sl@0
|
59 |
// MGraphicsDeviceMap
|
sl@0
|
60 |
//
|
sl@0
|
61 |
|
sl@0
|
62 |
|
sl@0
|
63 |
EXPORT_C MGraphicsDeviceMap::MGraphicsDeviceMap()
|
sl@0
|
64 |
/** Default constructor. */
|
sl@0
|
65 |
{}
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
EXPORT_C MGraphicsDeviceMap::~MGraphicsDeviceMap()
|
sl@0
|
69 |
/** Destructor. */
|
sl@0
|
70 |
{}
|
sl@0
|
71 |
|
sl@0
|
72 |
|
sl@0
|
73 |
EXPORT_C TPoint MGraphicsDeviceMap::TwipsToPixels(const TPoint& aTwipPoint) const
|
sl@0
|
74 |
/** Converts a point in twips to a point in pixels.
|
sl@0
|
75 |
|
sl@0
|
76 |
@param aTwipPoint A point on the graphics device in twips.
|
sl@0
|
77 |
@return A point on the graphics device in pixels. */
|
sl@0
|
78 |
{
|
sl@0
|
79 |
return TPoint(HorizontalTwipsToPixels(aTwipPoint.iX),VerticalTwipsToPixels(aTwipPoint.iY));
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
|
sl@0
|
83 |
EXPORT_C TRect MGraphicsDeviceMap::TwipsToPixels(const TRect& aTwipRect) const
|
sl@0
|
84 |
/** Converts a rectangle in twips to a rectangle in pixels.
|
sl@0
|
85 |
|
sl@0
|
86 |
@param aTwipRect A rectangle on the graphics device in twips
|
sl@0
|
87 |
@return A rectangle on the graphics device in pixels. */
|
sl@0
|
88 |
{
|
sl@0
|
89 |
return TRect(TwipsToPixels(aTwipRect.iTl),TwipsToPixels(aTwipRect.iBr));
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
|
sl@0
|
93 |
EXPORT_C TPoint MGraphicsDeviceMap::PixelsToTwips(const TPoint& aPixelPoint) const
|
sl@0
|
94 |
/** Converts a point in pixels to a point in twips.
|
sl@0
|
95 |
|
sl@0
|
96 |
@param aPixelPoint A point on the graphics device in pixels.
|
sl@0
|
97 |
@return A point on the graphics device in twips. */
|
sl@0
|
98 |
{
|
sl@0
|
99 |
return TPoint(HorizontalPixelsToTwips(aPixelPoint.iX),VerticalPixelsToTwips(aPixelPoint.iY));
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
|
sl@0
|
103 |
EXPORT_C TRect MGraphicsDeviceMap::PixelsToTwips(const TRect& aPixelRect) const
|
sl@0
|
104 |
/** Converts a rectangle in pixels to a rectangle in twips.
|
sl@0
|
105 |
|
sl@0
|
106 |
@param aPixelRect A rectangle on the graphics device in pixels.
|
sl@0
|
107 |
@return A rectangle on the graphics device in twips. */
|
sl@0
|
108 |
{
|
sl@0
|
109 |
return TRect(PixelsToTwips(aPixelRect.iTl),PixelsToTwips(aPixelRect.iBr));
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
//
|
sl@0
|
113 |
// CGraphicsContext
|
sl@0
|
114 |
//
|
sl@0
|
115 |
|
sl@0
|
116 |
EXPORT_C TInt CGraphicsContext::JustificationInPixels(TInt aExcessPixels,TInt aTotalUnits,TInt aFirstUnit,TInt aNumUnits)
|
sl@0
|
117 |
/** Gets the amount of space in pixels by which to adjust letter or word spacing,
|
sl@0
|
118 |
given the total number of words and spaces, a start space, and the number
|
sl@0
|
119 |
of units to be adjusted.
|
sl@0
|
120 |
|
sl@0
|
121 |
The first two arguments are the number of pixels (character groups) and the
|
sl@0
|
122 |
number of units (word spaces) over which justification is to occur. The third
|
sl@0
|
123 |
argument specifies the current character group or word space, while the final
|
sl@0
|
124 |
argument specifies the number of units that are to be adjusted.
|
sl@0
|
125 |
|
sl@0
|
126 |
A panic occurs if aExcessPixels is 0, aTotalUnits is not greater than 0, or
|
sl@0
|
127 |
aFirstUnit is not less than aTotalUnits.
|
sl@0
|
128 |
|
sl@0
|
129 |
@param aExcessPixels The number of pixels by which the width of the text is
|
sl@0
|
130 |
to be changed. It may be positive, in which case the text is stretched, or
|
sl@0
|
131 |
negative, in which case it is shrunk.
|
sl@0
|
132 |
@param aTotalUnits The number of word spaces over which the change in width
|
sl@0
|
133 |
is to be distributed.
|
sl@0
|
134 |
@param aFirstUnit The current unit — the character group or word space we
|
sl@0
|
135 |
are 'on'.
|
sl@0
|
136 |
@param aNumUnits The number of units that are to be adjusted — starting
|
sl@0
|
137 |
at aFirstUnit.
|
sl@0
|
138 |
@return The number of pixels to be added to the width of the current unit.
|
sl@0
|
139 |
@see SetWordJustification()
|
sl@0
|
140 |
@see SetCharJustification() */
|
sl@0
|
141 |
{
|
sl@0
|
142 |
if(aExcessPixels==0 || aTotalUnits<=0 || aFirstUnit>=aTotalUnits)
|
sl@0
|
143 |
return(0);
|
sl@0
|
144 |
TInt noExtra=Abs(aExcessPixels%aTotalUnits);
|
sl@0
|
145 |
TInt extraPixel=aExcessPixels/Abs(aExcessPixels);
|
sl@0
|
146 |
GDI_ASSERT_DEBUG_GENERAL( aFirstUnit>=0 , User::Panic(KGdiPanicCategory,KErrArgument) ) ;
|
sl@0
|
147 |
GDI_ASSERT_DEBUG_GENERAL( aNumUnits>=0 , User::Panic(KGdiPanicCategory,KErrArgument) ) ;
|
sl@0
|
148 |
if(aFirstUnit+aNumUnits>aTotalUnits)
|
sl@0
|
149 |
aNumUnits=aTotalUnits-aFirstUnit;
|
sl@0
|
150 |
TInt clip=aNumUnits*(aExcessPixels/aTotalUnits);
|
sl@0
|
151 |
if(aFirstUnit>=noExtra)
|
sl@0
|
152 |
return(clip);
|
sl@0
|
153 |
if(aFirstUnit+aNumUnits>noExtra)
|
sl@0
|
154 |
aNumUnits=noExtra-aFirstUnit;
|
sl@0
|
155 |
return(clip+aNumUnits*extraPixel);
|
sl@0
|
156 |
}
|
sl@0
|
157 |
|
sl@0
|
158 |
|
sl@0
|
159 |
EXPORT_C TInt CGraphicsContext::JustificationInPixels(TInt& aExcessPixels,TInt& aTotalUnits)
|
sl@0
|
160 |
/** Gets the amount of space in pixels by which to adjust the current letter or
|
sl@0
|
161 |
word spacing, and also retrieves the number of excess pixels and word spaces
|
sl@0
|
162 |
remaining after the adjustment is performed.
|
sl@0
|
163 |
|
sl@0
|
164 |
The arguments are the number of remaining pixels (character groups) and units
|
sl@0
|
165 |
(word spaces) over which justification is to occur. The function can be called
|
sl@0
|
166 |
repetitively until the number of units is zero, and hence justification is
|
sl@0
|
167 |
complete. A panic occurs if the number of units is less than one or the amount
|
sl@0
|
168 |
of pixels is zero.
|
sl@0
|
169 |
|
sl@0
|
170 |
@param aExcessPixels The number of pixels by which the width of the text is
|
sl@0
|
171 |
to be changed. It may be positive, in which case the text is stretched, or
|
sl@0
|
172 |
negative, in which case it is shrunk. On return, this is equal to its old
|
sl@0
|
173 |
value minus the return value.
|
sl@0
|
174 |
@param aTotalUnits The number of word spaces over which the change in width
|
sl@0
|
175 |
is to be distributed. On return, this is reduced by one.
|
sl@0
|
176 |
@return The number of pixels to be added to the width of the current unit.
|
sl@0
|
177 |
@see SetWordJustification()
|
sl@0
|
178 |
@see SetCharJustification() */
|
sl@0
|
179 |
{
|
sl@0
|
180 |
GDI_ASSERT_DEBUG_GENERAL(aExcessPixels!=0,User::Panic(KGdiPanicCategory,KErrArgument));
|
sl@0
|
181 |
GDI_ASSERT_DEBUG_GENERAL(aTotalUnits>0,User::Panic(KGdiPanicCategory,KErrArgument));
|
sl@0
|
182 |
TInt justification=aExcessPixels/aTotalUnits;
|
sl@0
|
183 |
if(aExcessPixels%aTotalUnits)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
if(aExcessPixels>0)
|
sl@0
|
186 |
justification++;
|
sl@0
|
187 |
else
|
sl@0
|
188 |
justification--;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
aTotalUnits--;
|
sl@0
|
191 |
aExcessPixels-=justification;
|
sl@0
|
192 |
return(justification);
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
|
sl@0
|
196 |
EXPORT_C TInt CGraphicsContext::DrawTextExtended(const TDesC& aText,const TPoint& aPosition,
|
sl@0
|
197 |
const TDrawTextExtendedParam& aParam)
|
sl@0
|
198 |
/** Draws text, optionally changing its direction (right-to-left / left-to-right).
|
sl@0
|
199 |
|
sl@0
|
200 |
Apart from reordering the text, the function is the same as the two parameter
|
sl@0
|
201 |
variant of DrawText(), described above.
|
sl@0
|
202 |
|
sl@0
|
203 |
@param aText The text string to be drawn, optionally changing its direction
|
sl@0
|
204 |
(right-to-left / left-to-right).
|
sl@0
|
205 |
@param aPosition A point specifying the position of the left end of the text.
|
sl@0
|
206 |
@param aParam Indicates whether the text should be drawn from right-to-left
|
sl@0
|
207 |
(for scripts like Arabic and Hebrew) or left-to-right.
|
sl@0
|
208 |
@return KErrNoMemory indicates there was an OOM error when reordering the text;
|
sl@0
|
209 |
KErrNone if the reordering was successful. */
|
sl@0
|
210 |
{
|
sl@0
|
211 |
// Reorder the text bidirectionally.
|
sl@0
|
212 |
TText* reordered_text = NULL;
|
sl@0
|
213 |
int error = TBidirectionalState::ReorderText(aText.Ptr(),aText.Length(),aParam.iParRightToLeft,reordered_text);
|
sl@0
|
214 |
TPtrC p(reordered_text,aText.Length());
|
sl@0
|
215 |
DrawText(p,aPosition,aParam);
|
sl@0
|
216 |
if (reordered_text != aText.Ptr())
|
sl@0
|
217 |
delete [] reordered_text;
|
sl@0
|
218 |
return error;
|
sl@0
|
219 |
}
|
sl@0
|
220 |
|
sl@0
|
221 |
|
sl@0
|
222 |
EXPORT_C void CGraphicsContext::DrawText(const TDesC& aText,const TPoint& aPosition,const TDrawTextParam& /*aParam*/)
|
sl@0
|
223 |
/** Draws the specified text at the given position using the parameters supplied.
|
sl@0
|
224 |
|
sl@0
|
225 |
@param aText The text to be drawn.
|
sl@0
|
226 |
@param aPosition The position to draw the text at.
|
sl@0
|
227 |
@param aParam Parameters to use for text drawing. */
|
sl@0
|
228 |
{
|
sl@0
|
229 |
DrawText(aText,aPosition);
|
sl@0
|
230 |
}
|
sl@0
|
231 |
|
sl@0
|
232 |
/*
|
sl@0
|
233 |
Can be used to find out the top and bottom of an underline for the active font.
|
sl@0
|
234 |
This allows correct calculation of the area required in which to draw text with underline.
|
sl@0
|
235 |
|
sl@0
|
236 |
@param TInt& aTop The top of the underline position
|
sl@0
|
237 |
@param TInt& aBottom The bottom of the underline position
|
sl@0
|
238 |
@return TInt KErrNone if successful, else a standard system wide error value.
|
sl@0
|
239 |
*/
|
sl@0
|
240 |
EXPORT_C TInt CGraphicsContext::GetUnderlineMetrics(TInt& aTop,TInt& aBottom)
|
sl@0
|
241 |
{
|
sl@0
|
242 |
|
sl@0
|
243 |
TTwoTInt outputPackage;
|
sl@0
|
244 |
TTwoTInt* outputPtr = &outputPackage;
|
sl@0
|
245 |
TInt err = APIExtension(KGetUnderlineMetrics, (TAny*&) outputPtr, NULL);
|
sl@0
|
246 |
aTop = outputPackage.iTop;
|
sl@0
|
247 |
aBottom = outputPackage.iBottom;
|
sl@0
|
248 |
return err;
|
sl@0
|
249 |
}
|
sl@0
|
250 |
|
sl@0
|
251 |
EXPORT_C TInt CGraphicsContext::SetShadowColor(const TRgb& aShadowColor)
|
sl@0
|
252 |
{
|
sl@0
|
253 |
TRgb shadowColor = aShadowColor;
|
sl@0
|
254 |
TInt *dummy = NULL;
|
sl@0
|
255 |
return APIExtension(KSetShadowColor, (TAny*&)dummy, (TAny*)&shadowColor);
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
EXPORT_C TInt CGraphicsContext::GetShadowColor(TRgb& aShadowColor)
|
sl@0
|
259 |
{
|
sl@0
|
260 |
TRgb* shadowColor = &aShadowColor;
|
sl@0
|
261 |
return APIExtension(KGetShadowColor, (TAny*&)shadowColor, NULL);
|
sl@0
|
262 |
}
|
sl@0
|
263 |
|
sl@0
|
264 |
EXPORT_C TBool CGraphicsContext::IsFbsBitGc() const
|
sl@0
|
265 |
{
|
sl@0
|
266 |
TBool isFbsBitGc=EFalse;
|
sl@0
|
267 |
TBool* isFbsBitGcPtr=&isFbsBitGc;
|
sl@0
|
268 |
|
sl@0
|
269 |
//Have a non const this since want the published API to be const
|
sl@0
|
270 |
CGraphicsContext *nonConstThis = const_cast<CGraphicsContext*>(this);
|
sl@0
|
271 |
|
sl@0
|
272 |
//The API extension function is non-const, and this is const function
|
sl@0
|
273 |
TInt err= nonConstThis->APIExtension(KUidIsFbsBitmapGc, (TAny*&)isFbsBitGcPtr, NULL);
|
sl@0
|
274 |
|
sl@0
|
275 |
//on error, return EFalse
|
sl@0
|
276 |
return (!err ? isFbsBitGc : EFalse);
|
sl@0
|
277 |
}
|
sl@0
|
278 |
|
sl@0
|
279 |
EXPORT_C void CGraphicsContext::DrawText(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition)
|
sl@0
|
280 |
{
|
sl@0
|
281 |
TInt *dummy = NULL;
|
sl@0
|
282 |
|
sl@0
|
283 |
TDrawTextInContextInternal context;
|
sl@0
|
284 |
TDrawTextInContextInternal* contextPtr = &context;
|
sl@0
|
285 |
contextPtr->iText.Set(aText);
|
sl@0
|
286 |
contextPtr->iPosition.SetXY(0,0);
|
sl@0
|
287 |
contextPtr->iPosition += aPosition;
|
sl@0
|
288 |
contextPtr->iParam.iStart = iParam->iStart;
|
sl@0
|
289 |
contextPtr->iParam.iEnd = iParam->iEnd;
|
sl@0
|
290 |
if (KErrNotSupported == APIExtension(KDrawTextInContextUid, (TAny*&)dummy, (TAny*)contextPtr))
|
sl@0
|
291 |
{
|
sl@0
|
292 |
DrawText(aText,aPosition);
|
sl@0
|
293 |
}
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
EXPORT_C void CGraphicsContext::DrawText(const TDesC& aText,const TTextParameters* iParam,const TRect& aBox,TInt aBaselineOffset,TTextAlign aHrz,TInt aMargin)
|
sl@0
|
297 |
{
|
sl@0
|
298 |
TInt *dummy = NULL;
|
sl@0
|
299 |
|
sl@0
|
300 |
TDrawTextInContextInternal context;
|
sl@0
|
301 |
TDrawTextInContextInternal* contextPtr = &context;
|
sl@0
|
302 |
contextPtr->iText.Set(aText);
|
sl@0
|
303 |
contextPtr->iBox.SetRect(aBox.iTl, aBox.iBr);
|
sl@0
|
304 |
contextPtr->iBaselineOffset = aBaselineOffset;
|
sl@0
|
305 |
contextPtr->iAlign = aHrz;
|
sl@0
|
306 |
contextPtr->iMargin = aMargin;
|
sl@0
|
307 |
contextPtr->iParam.iStart = iParam->iStart;
|
sl@0
|
308 |
contextPtr->iParam.iEnd = iParam->iEnd;
|
sl@0
|
309 |
if (KErrNotSupported == APIExtension(KDrawBoxTextInContextUid, (TAny*&)dummy, (TAny*)contextPtr))
|
sl@0
|
310 |
{
|
sl@0
|
311 |
DrawText(aText,aBox,aBaselineOffset,aHrz,aMargin);
|
sl@0
|
312 |
}
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
EXPORT_C void CGraphicsContext::DrawText(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition,const TDrawTextParam& /*aParam*/)
|
sl@0
|
316 |
{
|
sl@0
|
317 |
TInt *dummy = NULL;
|
sl@0
|
318 |
|
sl@0
|
319 |
TDrawTextInContextInternal context;
|
sl@0
|
320 |
TDrawTextInContextInternal* contextPtr = &context;
|
sl@0
|
321 |
contextPtr->iText.Set(aText);
|
sl@0
|
322 |
contextPtr->iPosition.SetXY(0,0);
|
sl@0
|
323 |
contextPtr->iPosition += aPosition;
|
sl@0
|
324 |
contextPtr->iParam.iStart = iParam->iStart;
|
sl@0
|
325 |
contextPtr->iParam.iEnd = iParam->iEnd;
|
sl@0
|
326 |
if (KErrNotSupported == APIExtension(KDrawTextInContextUid, (TAny*&)dummy, (TAny*)contextPtr))
|
sl@0
|
327 |
{
|
sl@0
|
328 |
DrawText(aText,aPosition);
|
sl@0
|
329 |
}
|
sl@0
|
330 |
}
|
sl@0
|
331 |
|
sl@0
|
332 |
EXPORT_C void CGraphicsContext::DrawTextVertical(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPos,TBool aUp)
|
sl@0
|
333 |
{
|
sl@0
|
334 |
TInt *dummy = NULL;
|
sl@0
|
335 |
|
sl@0
|
336 |
TDrawTextInContextInternal context;
|
sl@0
|
337 |
TDrawTextInContextInternal* contextPtr = &context;
|
sl@0
|
338 |
contextPtr->iText.Set(aText);
|
sl@0
|
339 |
contextPtr->iPosition.SetXY(0,0);
|
sl@0
|
340 |
contextPtr->iPosition += aPos;
|
sl@0
|
341 |
contextPtr->iUp = aUp;
|
sl@0
|
342 |
contextPtr->iParam.iStart = iParam->iStart;
|
sl@0
|
343 |
contextPtr->iParam.iEnd = iParam->iEnd;
|
sl@0
|
344 |
if (KErrNotSupported == APIExtension(KDrawTextInContextVerticalUid, (TAny*&)dummy, (TAny*)contextPtr))
|
sl@0
|
345 |
{
|
sl@0
|
346 |
DrawTextVertical(aText,aPos,aUp);
|
sl@0
|
347 |
}
|
sl@0
|
348 |
}
|
sl@0
|
349 |
|
sl@0
|
350 |
EXPORT_C void CGraphicsContext::DrawTextVertical(const TDesC& aText,const TTextParameters* iParam,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert,TInt aMargin)
|
sl@0
|
351 |
{
|
sl@0
|
352 |
TInt *dummy = NULL;
|
sl@0
|
353 |
|
sl@0
|
354 |
TDrawTextInContextInternal context;
|
sl@0
|
355 |
TDrawTextInContextInternal* contextPtr = &context;
|
sl@0
|
356 |
contextPtr->iText.Set(aText);
|
sl@0
|
357 |
contextPtr->iBox.SetRect(aBox.iTl, aBox.iBr);
|
sl@0
|
358 |
contextPtr->iBaselineOffset = aBaselineOffset;
|
sl@0
|
359 |
contextPtr->iAlign = aVert;
|
sl@0
|
360 |
contextPtr->iMargin = aMargin;
|
sl@0
|
361 |
contextPtr->iUp = aUp;
|
sl@0
|
362 |
contextPtr->iParam.iStart = iParam->iStart;
|
sl@0
|
363 |
contextPtr->iParam.iEnd = iParam->iEnd;
|
sl@0
|
364 |
if (KErrNotSupported == APIExtension(KDrawBoxTextInContextVerticalUid, (TAny*&)dummy, (TAny*)contextPtr))
|
sl@0
|
365 |
{
|
sl@0
|
366 |
DrawTextVertical(aText,aBox,aBaselineOffset,aUp,aVert,aMargin);
|
sl@0
|
367 |
}
|
sl@0
|
368 |
}
|
sl@0
|
369 |
|
sl@0
|
370 |
EXPORT_C TInt CGraphicsContext::DrawTextExtended(const TDesC& aText,const TTextParameters* aTextParam,const TPoint& aPosition,
|
sl@0
|
371 |
const TDrawTextExtendedParam& aParam)
|
sl@0
|
372 |
/** Draws text, optionally changing its direction (right-to-left / left-to-right).
|
sl@0
|
373 |
|
sl@0
|
374 |
Apart from reordering the text, the function is the same as the two parameter
|
sl@0
|
375 |
variant of DrawText(), described above.
|
sl@0
|
376 |
|
sl@0
|
377 |
@param aText The text string to be drawn, optionally changing its direction
|
sl@0
|
378 |
(right-to-left / left-to-right).
|
sl@0
|
379 |
@param aPosition A point specifying the position of the left end of the text.
|
sl@0
|
380 |
@param aParam Indicates whether the text should be drawn from right-to-left
|
sl@0
|
381 |
(for scripts like Arabic and Hebrew) or left-to-right.
|
sl@0
|
382 |
@return KErrNoMemory indicates there was an OOM error when reordering the text;
|
sl@0
|
383 |
KErrNone if the reordering was successful. */
|
sl@0
|
384 |
{
|
sl@0
|
385 |
// Reorder the text bidirectionally.
|
sl@0
|
386 |
TText* reordered_text = NULL;
|
sl@0
|
387 |
int error = TBidirectionalState::ReorderText(aText.Ptr(),aText.Length(),aParam.iParRightToLeft,reordered_text);
|
sl@0
|
388 |
TPtrC p(reordered_text,aText.Length());
|
sl@0
|
389 |
DrawText(p,aTextParam,aPosition,aParam);
|
sl@0
|
390 |
if (reordered_text != aText.Ptr())
|
sl@0
|
391 |
delete [] reordered_text;
|
sl@0
|
392 |
return error;
|
sl@0
|
393 |
}
|
sl@0
|
394 |
EXPORT_C void CGraphicsContext::Reserved()
|
sl@0
|
395 |
/**Reserved function for future use. */
|
sl@0
|
396 |
{
|
sl@0
|
397 |
}
|
sl@0
|
398 |
|
sl@0
|
399 |
/**
|
sl@0
|
400 |
An API extension for CGraphics context replacing a reserved virtual method.
|
sl@0
|
401 |
Effectively allows multiple methods to use just one ordinal number.
|
sl@0
|
402 |
|
sl@0
|
403 |
@param TUid aUid A unique identifier for the internal method required
|
sl@0
|
404 |
@param TAny*& aOutput The output parameter
|
sl@0
|
405 |
@param TAny* aInput The input argument. Notably not const.
|
sl@0
|
406 |
@return KErrNone If a successful derived function is found, if the
|
sl@0
|
407 |
default is used then KErrNotSupported is returned.
|
sl@0
|
408 |
*/
|
sl@0
|
409 |
EXPORT_C TInt CGraphicsContext::APIExtension(TUid /*aUid*/, TAny*& /*aOutput*/, TAny* /*aInput*/)
|
sl@0
|
410 |
{
|
sl@0
|
411 |
return KErrNotSupported;
|
sl@0
|
412 |
}
|
sl@0
|
413 |
|
sl@0
|
414 |
//Default implementation of reserved virtual
|
sl@0
|
415 |
EXPORT_C void CGraphicsContext::Reserved_CGraphicsContext_2()
|
sl@0
|
416 |
{
|
sl@0
|
417 |
}
|
sl@0
|
418 |
|
sl@0
|
419 |
EXPORT_C TInt CBitmapContext::APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput)
|
sl@0
|
420 |
{
|
sl@0
|
421 |
return CGraphicsContext::APIExtension(aUid, aOutput, aInput);
|
sl@0
|
422 |
}
|
sl@0
|
423 |
|
sl@0
|
424 |
//Default implementation of reserved virtual
|
sl@0
|
425 |
EXPORT_C void CBitmapContext::Reserved_CGraphicsContext_2()
|
sl@0
|
426 |
{
|
sl@0
|
427 |
CGraphicsContext::Reserved_CGraphicsContext_2();
|
sl@0
|
428 |
}
|
sl@0
|
429 |
|
sl@0
|
430 |
//Default implementation of reserved virtual
|
sl@0
|
431 |
EXPORT_C void CBitmapContext::Reserved_CBitmapContext_1()
|
sl@0
|
432 |
{
|
sl@0
|
433 |
}
|
sl@0
|
434 |
|
sl@0
|
435 |
//Default implementation of reserved virtual
|
sl@0
|
436 |
EXPORT_C void CBitmapContext::Reserved_CBitmapContext_2()
|
sl@0
|
437 |
{
|
sl@0
|
438 |
}
|
sl@0
|
439 |
|
sl@0
|
440 |
//Default implementation of reserved virtual
|
sl@0
|
441 |
EXPORT_C void CBitmapContext::Reserved_CBitmapContext_3()
|
sl@0
|
442 |
{
|
sl@0
|
443 |
}
|
sl@0
|
444 |
|