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 |
// TRgb
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
inline TRgb::TRgb():
|
sl@0
|
20 |
iValue(0xffffffff)
|
sl@0
|
21 |
/** Constructs a TRgb initialised to KRgbWhite.*/
|
sl@0
|
22 |
{}
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
inline TRgb::TRgb(TUint32 aValue):
|
sl@0
|
26 |
iValue(((aValue & 0xff0000) >> 16) | (aValue & 0x00ff00) | ((aValue & 0x0000ff) << 16) | (0xff000000 - (aValue & 0xff000000)))
|
sl@0
|
27 |
/** Constructs a TRgb directly from a single 32-bit integer.
|
sl@0
|
28 |
|
sl@0
|
29 |
The integer is of the form 0xaabbggrr, where bb is the hex number for blue,
|
sl@0
|
30 |
gg is the hex number for green, rr is the hex number for red, and aa is the hex number for
|
sl@0
|
31 |
"transparency" alpha (0 means opaque, 255 means transparent).
|
sl@0
|
32 |
|
sl@0
|
33 |
This constructor is deprecated. The byte order of Red ,Green and Blue
|
sl@0
|
34 |
does not match other constructors and methods in this class,
|
sl@0
|
35 |
and the meaning of alpha is reversed compared to current convention.
|
sl@0
|
36 |
|
sl@0
|
37 |
For example, TRgb(0x00080402) using this constructor
|
sl@0
|
38 |
can be replaced with the 3 colour constructor TRgb(2,4,8).
|
sl@0
|
39 |
The equivalent explicit alpha constructors are TRgb(0x020408,0xff) and TRgb(2,4,8,255).
|
sl@0
|
40 |
The equivalent call to SetInternal is SetInternal(0xff020408).
|
sl@0
|
41 |
|
sl@0
|
42 |
This constructor is deprecated. Use other constructors or SetInternal() instead.
|
sl@0
|
43 |
|
sl@0
|
44 |
@param aValue Integer representing colour value. Takes form 0x00bbggrr.
|
sl@0
|
45 |
@deprecated */
|
sl@0
|
46 |
{}
|
sl@0
|
47 |
|
sl@0
|
48 |
inline TRgb::TRgb(TUint32 aInternalValue, TInt aAlpha) :
|
sl@0
|
49 |
iValue((aInternalValue & 0x00ffffff) | (aAlpha << 24))
|
sl@0
|
50 |
/** Constructs a TRgb from a 32-bit integer (which corresponds to a colour) and from an alpha value.
|
sl@0
|
51 |
|
sl@0
|
52 |
The first parameter is of the form 0x00rrggbb, where rr is the hex number for red,
|
sl@0
|
53 |
gg is the hex number for green, and bb is the hex number for blue.
|
sl@0
|
54 |
|
sl@0
|
55 |
The second parameter corresponds to an alpha channel (0 means transparent, 255 means opaque).
|
sl@0
|
56 |
|
sl@0
|
57 |
For example, TRgb(2,4,8,255) using the 3 colour+alpha constructor is equal to TRgb(0x00020408, 255) using
|
sl@0
|
58 |
this constructor.
|
sl@0
|
59 |
|
sl@0
|
60 |
This constructor, which implements alpha in the conventional way,
|
sl@0
|
61 |
replaces TRgb( TUint32 aValue ) which is deprecated.
|
sl@0
|
62 |
|
sl@0
|
63 |
@param aInternalValue Integer representing a colour value, which takes the form 0x00rrggbb.
|
sl@0
|
64 |
@param aAlpha Alpha component of the colour (0 - 255).*/
|
sl@0
|
65 |
{
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
inline TRgb::TRgb(TInt aRed,TInt aGreen,TInt aBlue):
|
sl@0
|
69 |
iValue(aRed<<16|aGreen<<8|aBlue|0xff000000)
|
sl@0
|
70 |
/** Constructs a TRgb from its three component colours.
|
sl@0
|
71 |
|
sl@0
|
72 |
Each colour has a value between 0 and 255.
|
sl@0
|
73 |
The alpha component is always set to opaque (255)
|
sl@0
|
74 |
|
sl@0
|
75 |
@param aRed Red component of the colour (0 - 255).
|
sl@0
|
76 |
@param aGreen Green component of the colour (0 - 255).
|
sl@0
|
77 |
@param aBlue Blue component of the colour (0 - 255). */
|
sl@0
|
78 |
{}
|
sl@0
|
79 |
|
sl@0
|
80 |
/** Constructs a TRgb from its three colour components and alpha component.
|
sl@0
|
81 |
|
sl@0
|
82 |
Each component has a value between 0 and 255.
|
sl@0
|
83 |
The fourth parameter corresponds to an alpha channel (0 means transparent, 255 means opaque).
|
sl@0
|
84 |
|
sl@0
|
85 |
This constructor, which implements alpha in the conventional way,
|
sl@0
|
86 |
replaces TRgb( TUint32 aValue ) which is deprecated.
|
sl@0
|
87 |
|
sl@0
|
88 |
@param aRed Red component of the colour (0 - 255).
|
sl@0
|
89 |
@param aGreen Green component of the colour (0 - 255).
|
sl@0
|
90 |
@param aBlue Blue component of the colour (0 - 255).
|
sl@0
|
91 |
@param aAlpha Alpha component of the colour (0 - 255).*/
|
sl@0
|
92 |
inline TRgb::TRgb(TInt aRed,TInt aGreen,TInt aBlue, TInt aAlpha):
|
sl@0
|
93 |
iValue(aRed<<16|aGreen<<8|aBlue|aAlpha<<24)
|
sl@0
|
94 |
{}
|
sl@0
|
95 |
|
sl@0
|
96 |
|
sl@0
|
97 |
inline TInt TRgb::Red() const
|
sl@0
|
98 |
/** Gets the red component.
|
sl@0
|
99 |
|
sl@0
|
100 |
@return The red component (0 - 255). */
|
sl@0
|
101 |
{return((iValue&0xff0000)>>16);}
|
sl@0
|
102 |
|
sl@0
|
103 |
|
sl@0
|
104 |
inline TInt TRgb::Green() const
|
sl@0
|
105 |
/** Gets the green component.
|
sl@0
|
106 |
|
sl@0
|
107 |
@return The green component (0 - 255). */
|
sl@0
|
108 |
{return((iValue&0xff00)>>8);}
|
sl@0
|
109 |
|
sl@0
|
110 |
|
sl@0
|
111 |
inline TInt TRgb::Blue() const
|
sl@0
|
112 |
/** Gets the blue component.
|
sl@0
|
113 |
|
sl@0
|
114 |
@return The blue component (0 - 255). */
|
sl@0
|
115 |
{return(iValue&0xff);}
|
sl@0
|
116 |
|
sl@0
|
117 |
|
sl@0
|
118 |
inline TBool TRgb::operator==(const TRgb& aColor) const
|
sl@0
|
119 |
/** Compares this colour with the specified colour for equality.
|
sl@0
|
120 |
|
sl@0
|
121 |
For two colours to be equal, their red, green and blue components must all
|
sl@0
|
122 |
be equal.
|
sl@0
|
123 |
|
sl@0
|
124 |
@param aColor Colour to be compared.
|
sl@0
|
125 |
@return ETrue. if the colours are equal; EFalse, otherwise. */
|
sl@0
|
126 |
|
sl@0
|
127 |
{return(iValue==aColor.iValue);}
|
sl@0
|
128 |
|
sl@0
|
129 |
|
sl@0
|
130 |
inline TBool TRgb::operator!=(const TRgb& aColor) const
|
sl@0
|
131 |
/** Compares this colour with the specified colour for inequality.
|
sl@0
|
132 |
|
sl@0
|
133 |
Two colours are unequal if one at least one of their red, green and blue components
|
sl@0
|
134 |
are unequal.
|
sl@0
|
135 |
|
sl@0
|
136 |
@param aColor Colour to be compared.
|
sl@0
|
137 |
@return ETrue, if the colours are not equal; EFalse, otherwise.
|
sl@0
|
138 |
*/
|
sl@0
|
139 |
{return(!(*this==aColor));}
|
sl@0
|
140 |
|
sl@0
|
141 |
inline TRgb& TRgb::operator&=(const TRgb& aColor)
|
sl@0
|
142 |
/** Logical AND assignment operator.
|
sl@0
|
143 |
|
sl@0
|
144 |
The operator ANDs the first operand with the second and then assigns the result
|
sl@0
|
145 |
back to the first operand.
|
sl@0
|
146 |
|
sl@0
|
147 |
Note:
|
sl@0
|
148 |
|
sl@0
|
149 |
This operates in the TRgb domain. Graphics defines logical operations for
|
sl@0
|
150 |
drawing primitives which operate in the device colour domain.
|
sl@0
|
151 |
|
sl@0
|
152 |
@param aColor Colour to be compared.
|
sl@0
|
153 |
@return First operand-contains result of logical AND. */
|
sl@0
|
154 |
{iValue&=aColor.iValue;return(*this);}
|
sl@0
|
155 |
|
sl@0
|
156 |
inline TRgb& TRgb::operator|=(const TRgb& aColor)
|
sl@0
|
157 |
/** Logical OR assignment operator.
|
sl@0
|
158 |
|
sl@0
|
159 |
The operator ORs the first operand with the second and then assigns the result
|
sl@0
|
160 |
back to the first operand.
|
sl@0
|
161 |
|
sl@0
|
162 |
Note:
|
sl@0
|
163 |
|
sl@0
|
164 |
This operates in the TRgb domain. Graphics defines logical operations for
|
sl@0
|
165 |
drawing primitives which operate in the device colour domain.
|
sl@0
|
166 |
|
sl@0
|
167 |
@param aColor Colour to be compared.
|
sl@0
|
168 |
@return First operand- contains result of logical OR. */
|
sl@0
|
169 |
{iValue|=aColor.iValue;return(*this);}
|
sl@0
|
170 |
|
sl@0
|
171 |
|
sl@0
|
172 |
inline TRgb& TRgb::operator^=(const TRgb& aColor)
|
sl@0
|
173 |
/** Logical EXCLUSIVE OR assignment operator.
|
sl@0
|
174 |
|
sl@0
|
175 |
The operator Exclusive ORs the first operand with the second and then assigns
|
sl@0
|
176 |
the result back to the first operand.
|
sl@0
|
177 |
|
sl@0
|
178 |
Note:
|
sl@0
|
179 |
|
sl@0
|
180 |
This operates in the TRgb domain. Graphics defines logical operations for
|
sl@0
|
181 |
drawing primitives which operate in the device colour domain.
|
sl@0
|
182 |
|
sl@0
|
183 |
@param aColor Colour to be compared.
|
sl@0
|
184 |
@return First operand contains result of logical Exclusive OR. */
|
sl@0
|
185 |
{iValue^=aColor.iValue;iValue^=0xff000000; return(*this);}
|
sl@0
|
186 |
|
sl@0
|
187 |
|
sl@0
|
188 |
inline TUint32 TRgb::Value() const
|
sl@0
|
189 |
/** Gets the 32-bit value of the TRgb as an integer.
|
sl@0
|
190 |
This function is deprecated. Use Internal() instead.
|
sl@0
|
191 |
Note: the order of Red, Green and Blue components returned by this method
|
sl@0
|
192 |
is reversed compared to all other methods. The alpha value is also reversed in meaning
|
sl@0
|
193 |
compared to current convention, such that 0 represents opaque and 0xff represents transparent.
|
sl@0
|
194 |
|
sl@0
|
195 |
@return The 32 bit value of the TRgb. Has the form 0xaabbggrr, where bb is the hex number for blue,
|
sl@0
|
196 |
gg is the hex number for green, rr is the hex number for red, and aa is the hex number for
|
sl@0
|
197 |
"transparency" alpha (0 means opaque, 255 means transparent).
|
sl@0
|
198 |
@deprecated */
|
sl@0
|
199 |
// rr gg bb aa
|
sl@0
|
200 |
{return (((iValue & 0xff0000) >> 16) | (iValue & 0x00ff00) | ((iValue & 0x0000ff) << 16) | (0xff000000 - (iValue & 0xff000000)));}
|
sl@0
|
201 |
|
sl@0
|
202 |
inline TUint32 TRgb::Internal() const
|
sl@0
|
203 |
/** Gets the 32-bit value of the TRgb as an integer.
|
sl@0
|
204 |
|
sl@0
|
205 |
@return The 32 bit value of the TRgb. Has the form 0xaarrggbb. */
|
sl@0
|
206 |
{return (iValue);}
|
sl@0
|
207 |
|
sl@0
|
208 |
inline void TRgb::SetInternal(TUint32 aInternal)
|
sl@0
|
209 |
/** Sets the 32-bit value of the TRgb as a 32-bit integer.
|
sl@0
|
210 |
@param aInternal Colour internal representation. Has the form 0xaarrggbb.
|
sl@0
|
211 |
*/
|
sl@0
|
212 |
{iValue = aInternal;}
|
sl@0
|
213 |
|
sl@0
|
214 |
inline TRgb TRgb::operator~() const
|
sl@0
|
215 |
/** Bitwise logical inversion operator.
|
sl@0
|
216 |
|
sl@0
|
217 |
@return Contains results of logical inversion. */
|
sl@0
|
218 |
{TRgb rgb; rgb.SetInternal(iValue^0x00ffffff); return rgb;}
|
sl@0
|
219 |
|
sl@0
|
220 |
|
sl@0
|
221 |
inline TRgb TRgb::operator&(const TRgb& aColor)
|
sl@0
|
222 |
/** Bitwise logical AND operator.
|
sl@0
|
223 |
|
sl@0
|
224 |
@param aColor Colour to be compared.
|
sl@0
|
225 |
@return Contains results of logical AND. */
|
sl@0
|
226 |
{TRgb rgb; rgb.SetInternal(iValue&aColor.iValue); return rgb;}
|
sl@0
|
227 |
|
sl@0
|
228 |
|
sl@0
|
229 |
inline TRgb TRgb::operator|(const TRgb& aColor)
|
sl@0
|
230 |
/** Bitwise logical OR operator.
|
sl@0
|
231 |
|
sl@0
|
232 |
@param aColor Colour to be compared.
|
sl@0
|
233 |
@return Contains results of logical OR. */
|
sl@0
|
234 |
{TRgb rgb; rgb.SetInternal(iValue|aColor.iValue); return rgb;}
|
sl@0
|
235 |
|
sl@0
|
236 |
|
sl@0
|
237 |
inline TRgb TRgb::operator^(const TRgb& aColor)
|
sl@0
|
238 |
/** Bitwise EXCLUSIVE OR operator
|
sl@0
|
239 |
|
sl@0
|
240 |
@param aColor Colour to be compared.
|
sl@0
|
241 |
@return Contains results of logical EXCLUSIVE OR. */
|
sl@0
|
242 |
{TRgb rgb; rgb.SetInternal(iValue^aColor.iValue); return rgb;}
|
sl@0
|
243 |
|
sl@0
|
244 |
|
sl@0
|
245 |
/** Gets TRgb from 2 level grayscale.
|
sl@0
|
246 |
|
sl@0
|
247 |
The function takes a grayscale argument and return a TRgb whose red, green
|
sl@0
|
248 |
and blue values are set to an appropriate level.
|
sl@0
|
249 |
|
sl@0
|
250 |
@param aGray2 Grayscale value to be converted.
|
sl@0
|
251 |
@return Equivalent 24 bit colour. Gray2 has only 2 levels (black and white),
|
sl@0
|
252 |
the function returns r=g=b=0 or r=g=b=255. */
|
sl@0
|
253 |
inline TRgb TRgb::_Gray2(TInt aGray2)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
if(aGray2) return(TRgb(0xffffff, 0xff));
|
sl@0
|
256 |
return(TRgb(0, 0xff));
|
sl@0
|
257 |
}
|
sl@0
|
258 |
|
sl@0
|
259 |
/** Gets TRgb from 4 level grayscale.
|
sl@0
|
260 |
|
sl@0
|
261 |
The function takes a grayscale argument and return a TRgb whose red, green
|
sl@0
|
262 |
and blue values are set to an appropriate level.
|
sl@0
|
263 |
|
sl@0
|
264 |
@param aGray4 Grayscale value to be converted.
|
sl@0
|
265 |
@return Equivalent 24 bit colour. Gray4 has 4 levels- the function returns
|
sl@0
|
266 |
r=g=b=85*c, where c=0,1,2, or 3. */
|
sl@0
|
267 |
inline TRgb TRgb::_Gray4(TInt aGray4)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
aGray4&=3;
|
sl@0
|
270 |
aGray4|=aGray4<<2;
|
sl@0
|
271 |
aGray4|=aGray4<<4;
|
sl@0
|
272 |
return(TRgb(aGray4,aGray4,aGray4));
|
sl@0
|
273 |
}
|
sl@0
|
274 |
|
sl@0
|
275 |
/** Gets TRgb from 16 level grayscale.
|
sl@0
|
276 |
|
sl@0
|
277 |
The function takes a grayscale argument and return a TRgb whose red, green
|
sl@0
|
278 |
and blue values are set to an appropriate level.
|
sl@0
|
279 |
|
sl@0
|
280 |
@param aGray16 Grayscale value to be converted.
|
sl@0
|
281 |
@return Equivalent 24 bit colour. Gray16 has 16 levels - the function returns
|
sl@0
|
282 |
r=g=b=17*c, where c=0, 1, ... 15. */
|
sl@0
|
283 |
inline TRgb TRgb::_Gray16(TInt aGray16)
|
sl@0
|
284 |
{
|
sl@0
|
285 |
aGray16&=0xf;
|
sl@0
|
286 |
aGray16|=aGray16<<4;
|
sl@0
|
287 |
return(TRgb(aGray16,aGray16,aGray16));
|
sl@0
|
288 |
}
|
sl@0
|
289 |
|
sl@0
|
290 |
/** Gets TRgb from 256 level grayscale.
|
sl@0
|
291 |
|
sl@0
|
292 |
The function takes a grayscale argument and return a TRgb whose red, green
|
sl@0
|
293 |
and blue values are set to an appropriate level.
|
sl@0
|
294 |
|
sl@0
|
295 |
@param aGray256 Grayscale value to be converted.
|
sl@0
|
296 |
@return Equivalent 24 bit colour. Gray256 has 256 levels- the function
|
sl@0
|
297 |
returns r=g=b=c, where c=0, 1, ... 255. */
|
sl@0
|
298 |
inline TRgb TRgb::_Gray256(TInt aGray256)
|
sl@0
|
299 |
{
|
sl@0
|
300 |
aGray256&=0xff;
|
sl@0
|
301 |
return(TRgb(aGray256,aGray256,aGray256));
|
sl@0
|
302 |
}
|
sl@0
|
303 |
|
sl@0
|
304 |
/** Gets TRgb from 4K colour index.
|
sl@0
|
305 |
|
sl@0
|
306 |
The function takes a 12 bit index into a colour palette and returns a TRgb
|
sl@0
|
307 |
whose red, green and blue values are set to an appropriate level.
|
sl@0
|
308 |
|
sl@0
|
309 |
@param aColor4K 12 bit index into a colour palette
|
sl@0
|
310 |
@return Equivalent 24 bit colour. */
|
sl@0
|
311 |
inline TRgb TRgb::_Color4K(TInt aColor4K)
|
sl@0
|
312 |
{
|
sl@0
|
313 |
TUint32 value = (aColor4K & 0xf00) << 8;
|
sl@0
|
314 |
value |= (aColor4K & 0x0f0) << 4;
|
sl@0
|
315 |
value |= (aColor4K & 0x00f);
|
sl@0
|
316 |
return TRgb(value | (value << 4), 0xff);
|
sl@0
|
317 |
}
|
sl@0
|
318 |
|
sl@0
|
319 |
/** Gets TRgb from 64K colour index.
|
sl@0
|
320 |
|
sl@0
|
321 |
The function takes a 16 bit index into a colour palette and returns a TRgb
|
sl@0
|
322 |
whose red, green and blue values are set to an appropriate level.
|
sl@0
|
323 |
|
sl@0
|
324 |
@param aColor64K 16 bit index into a colour palette
|
sl@0
|
325 |
@return Equivalent 24 bit colour. */
|
sl@0
|
326 |
inline TRgb TRgb::_Color64K(TInt aColor64K)
|
sl@0
|
327 |
{
|
sl@0
|
328 |
TInt red = (aColor64K&0xF800)>>8;
|
sl@0
|
329 |
red += red>>5;
|
sl@0
|
330 |
TInt green = (aColor64K&0x07E0)>>3;
|
sl@0
|
331 |
green += green>>6;
|
sl@0
|
332 |
TInt blue = (aColor64K&0x001F)<<3;
|
sl@0
|
333 |
blue += blue>>5;
|
sl@0
|
334 |
return TRgb(red,green,blue);
|
sl@0
|
335 |
}
|
sl@0
|
336 |
|
sl@0
|
337 |
/** Gets TRgb from 16M colour index.
|
sl@0
|
338 |
|
sl@0
|
339 |
The function takes a 24 bit index into a colour palette and returns the TRgb
|
sl@0
|
340 |
whose red, green and blue values represent it exactly.
|
sl@0
|
341 |
|
sl@0
|
342 |
@param a0RGB 24 bit index into a colour palette
|
sl@0
|
343 |
@return The TRgb which represents the index exactly. */
|
sl@0
|
344 |
inline TRgb TRgb::_Color16M(TInt a0RGB)
|
sl@0
|
345 |
{
|
sl@0
|
346 |
return TRgb(a0RGB, 0xff);
|
sl@0
|
347 |
}
|
sl@0
|
348 |
|
sl@0
|
349 |
/** Gets TRgb from 16MU colour index.
|
sl@0
|
350 |
The function takes a 24 bit colour value with eight bits for each
|
sl@0
|
351 |
component, blue in the low byte, and returns the TRgb
|
sl@0
|
352 |
whose red, green and blue values represent it exactly.
|
sl@0
|
353 |
@param a0RGB The color - 0, R, G, B bytes. / BGR0 - little endian format /
|
sl@0
|
354 |
@return The TRgb which represents the index exactly. */
|
sl@0
|
355 |
inline TRgb TRgb::_Color16MU(TInt a0RGB)
|
sl@0
|
356 |
{
|
sl@0
|
357 |
return TRgb(a0RGB, 0xff);
|
sl@0
|
358 |
}
|
sl@0
|
359 |
|
sl@0
|
360 |
/** Gets the index of the closest TRgb value to this,
|
sl@0
|
361 |
based on the matching display mode.
|
sl@0
|
362 |
|
sl@0
|
363 |
@return The index (0 - 1) representing the nearest TRgb. */
|
sl@0
|
364 |
inline TInt TRgb::_Gray2() const
|
sl@0
|
365 |
{
|
sl@0
|
366 |
return(Gray256()>>7);
|
sl@0
|
367 |
}
|
sl@0
|
368 |
|
sl@0
|
369 |
/**Gets the index of the closest TRgb value to this,
|
sl@0
|
370 |
based on the matching display mode.
|
sl@0
|
371 |
|
sl@0
|
372 |
@return The index (0 - 3) representing the nearest TRgb. */
|
sl@0
|
373 |
inline TInt TRgb::_Gray4() const
|
sl@0
|
374 |
{
|
sl@0
|
375 |
return(Gray256()>>6);
|
sl@0
|
376 |
}
|
sl@0
|
377 |
|
sl@0
|
378 |
/** Gets the index of the closest TRgb value to this,
|
sl@0
|
379 |
based on the matching display mode.
|
sl@0
|
380 |
|
sl@0
|
381 |
@return The index (0 - 15) representing the nearest TRgb.*/
|
sl@0
|
382 |
inline TInt TRgb::_Gray16() const
|
sl@0
|
383 |
{
|
sl@0
|
384 |
return(Gray256()>>4);
|
sl@0
|
385 |
}
|
sl@0
|
386 |
|
sl@0
|
387 |
/** Gets the index of the closest TRgb value to this,
|
sl@0
|
388 |
based on the matching display mode.
|
sl@0
|
389 |
|
sl@0
|
390 |
@return The index (0 - 255) representing the nearest TRgb.*/
|
sl@0
|
391 |
inline TInt TRgb::_Gray256() const
|
sl@0
|
392 |
{
|
sl@0
|
393 |
return(((Red()<<1)+Green()+(Green()<<2)+Blue())>>3);
|
sl@0
|
394 |
}
|
sl@0
|
395 |
|
sl@0
|
396 |
/** Gets the index of the closest TRgb value to this,
|
sl@0
|
397 |
based on the matching display mode.
|
sl@0
|
398 |
|
sl@0
|
399 |
@return The index (0 - 4095) representing the nearest TRgb. */
|
sl@0
|
400 |
inline TInt TRgb::_Color4K() const
|
sl@0
|
401 |
{
|
sl@0
|
402 |
TInt color4K = (iValue & 0x0000f0) >> 4;
|
sl@0
|
403 |
color4K |= (iValue & 0x00f000) >> 8;
|
sl@0
|
404 |
color4K |= (iValue & 0xf00000) >> 12;
|
sl@0
|
405 |
return color4K;
|
sl@0
|
406 |
} //0RGB
|
sl@0
|
407 |
|
sl@0
|
408 |
/** Gets the index of the closest TRgb value to this,
|
sl@0
|
409 |
based on the matching display mode.
|
sl@0
|
410 |
|
sl@0
|
411 |
@return The index (0 - 65535) representing the nearest TRgb.*/
|
sl@0
|
412 |
inline TInt TRgb::_Color64K() const
|
sl@0
|
413 |
{
|
sl@0
|
414 |
TInt color64K = (iValue & 0x0000f8) >> 3;
|
sl@0
|
415 |
color64K |= (iValue & 0x00fc00) >> 5;
|
sl@0
|
416 |
color64K |= (iValue & 0xf80000) >> 8;
|
sl@0
|
417 |
return color64K;
|
sl@0
|
418 |
}
|
sl@0
|
419 |
|
sl@0
|
420 |
/** Gets the index of the closest TRgb value to this,
|
sl@0
|
421 |
based on the matching display mode.
|
sl@0
|
422 |
|
sl@0
|
423 |
@return The index (0 - 16777215) representing the nearest TRgb.*/
|
sl@0
|
424 |
inline TInt TRgb::_Color16M() const
|
sl@0
|
425 |
{
|
sl@0
|
426 |
return (iValue & 0xffffff);
|
sl@0
|
427 |
// 0RGB
|
sl@0
|
428 |
}
|
sl@0
|
429 |
|
sl@0
|
430 |
/** Gets the index of the closest TRgb value to this, based on the matching display mode.
|
sl@0
|
431 |
@return The index (0 - 16777215) representing the nearest TRgb. */
|
sl@0
|
432 |
inline TInt TRgb::_Color16MU() const
|
sl@0
|
433 |
{
|
sl@0
|
434 |
return (iValue & 0xffffff);
|
sl@0
|
435 |
// 0RGB
|
sl@0
|
436 |
}
|
sl@0
|
437 |
|
sl@0
|
438 |
|
sl@0
|
439 |
/** Gets the alpha component.
|
sl@0
|
440 |
@return The alpha component (0 - 255). */
|
sl@0
|
441 |
inline TInt TRgb::Alpha() const
|
sl@0
|
442 |
{return (iValue >> 24);}
|
sl@0
|
443 |
|
sl@0
|
444 |
|
sl@0
|
445 |
/** Gets TRgb from 16MA colour index.
|
sl@0
|
446 |
The function takes a 32 bit colour value with eight bits for each
|
sl@0
|
447 |
component, blue in the low byte, and returns the TRgb
|
sl@0
|
448 |
whose red, green, blue and alpha values represent it exactly.
|
sl@0
|
449 |
@param aARGB The color - A, R, G, B bytes. / BGR0 - little endian format /
|
sl@0
|
450 |
@return The TRgb which represents the index exactly. */
|
sl@0
|
451 |
inline TRgb TRgb::_Color16MA(TUint aARGB)
|
sl@0
|
452 |
{
|
sl@0
|
453 |
TRgb col; col.SetInternal(aARGB);
|
sl@0
|
454 |
return col;
|
sl@0
|
455 |
}
|
sl@0
|
456 |
|
sl@0
|
457 |
/** Gets the index of the closest TRgb value to this, based on the matching display mode.
|
sl@0
|
458 |
@return The index (0 - 16777215) representing the nearest TRgb. */
|
sl@0
|
459 |
inline TUint TRgb::_Color16MA() const
|
sl@0
|
460 |
{
|
sl@0
|
461 |
return (iValue);
|
sl@0
|
462 |
// ARGB
|
sl@0
|
463 |
}
|
sl@0
|
464 |
//
|
sl@0
|
465 |
// CPalette
|
sl@0
|
466 |
//
|
sl@0
|
467 |
|
sl@0
|
468 |
|
sl@0
|
469 |
inline TInt CPalette::Entries() const
|
sl@0
|
470 |
/** Gets the number of entries in the palette
|
sl@0
|
471 |
|
sl@0
|
472 |
@return The number of entries in the palette. */
|
sl@0
|
473 |
{return(iNumEntries);}
|
sl@0
|
474 |
|
sl@0
|
475 |
//
|
sl@0
|
476 |
// TColor256Utils
|
sl@0
|
477 |
//
|
sl@0
|
478 |
|
sl@0
|
479 |
|
sl@0
|
480 |
inline TRgb TColor256Util::Color256(TInt aColor256) const
|
sl@0
|
481 |
/** Gets the TRgb value of the entry at the specified index in the colour lookup
|
sl@0
|
482 |
table.
|
sl@0
|
483 |
|
sl@0
|
484 |
@param aColor256 The index into the colour lookup table.
|
sl@0
|
485 |
@return The TRgb value of the entry at the specified index. */
|
sl@0
|
486 |
{ return TRgb(iColorTable[aColor256]); }
|
sl@0
|
487 |
|
sl@0
|
488 |
//
|
sl@0
|
489 |
// TFontStyle
|
sl@0
|
490 |
//
|
sl@0
|
491 |
inline TGlyphBitmapType TFontStyle::BitmapType() const
|
sl@0
|
492 |
/** Gets the anti-aliasing setting for the font, as set by SetBitmapType().
|
sl@0
|
493 |
|
sl@0
|
494 |
@return Indicates whether or not this font should be drawn using anti-aliasing. */
|
sl@0
|
495 |
{
|
sl@0
|
496 |
return (TGlyphBitmapType)(iFlags >> 16);
|
sl@0
|
497 |
}
|
sl@0
|
498 |
|
sl@0
|
499 |
|
sl@0
|
500 |
inline void TFontStyle::SetBitmapType(TGlyphBitmapType aBitmapType)
|
sl@0
|
501 |
/** Sets whether the font should be drawn using anti-aliasing. If set, this value
|
sl@0
|
502 |
overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType())
|
sl@0
|
503 |
for this font.
|
sl@0
|
504 |
|
sl@0
|
505 |
Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing
|
sl@0
|
506 |
support for bitmapped fonts.
|
sl@0
|
507 |
|
sl@0
|
508 |
@param aBitmapType Indicates whether or not this font should be drawn using
|
sl@0
|
509 |
anti-aliasing. */
|
sl@0
|
510 |
{
|
sl@0
|
511 |
iFlags &= 0xFFFF;
|
sl@0
|
512 |
iFlags |= (aBitmapType << 16);
|
sl@0
|
513 |
}
|
sl@0
|
514 |
|
sl@0
|
515 |
//
|
sl@0
|
516 |
// CBitmapDevice
|
sl@0
|
517 |
//
|
sl@0
|
518 |
|
sl@0
|
519 |
|
sl@0
|
520 |
inline TInt CBitmapDevice::CreateBitmapContext(CBitmapContext*& aGC)
|
sl@0
|
521 |
/** Creates a bitmap context for this bitmap device.
|
sl@0
|
522 |
|
sl@0
|
523 |
@param aGC On return, holds a pointer to the created bitmap context.
|
sl@0
|
524 |
@return KErrNone, if successful; otherwise, another of the system-wide error
|
sl@0
|
525 |
codes. */
|
sl@0
|
526 |
{return(CreateContext((CGraphicsContext*&)aGC));} // relies on CBitmapContext deriving _only_ from CGraphicsContext
|
sl@0
|
527 |
|
sl@0
|
528 |
//
|
sl@0
|
529 |
// TPictureCapability
|
sl@0
|
530 |
//
|
sl@0
|
531 |
|
sl@0
|
532 |
inline TPictureCapability::TPictureCapability(TScalingType aScalingType,TBool aCroppable):
|
sl@0
|
533 |
iScalingType(aScalingType),iIsCroppable(aCroppable)
|
sl@0
|
534 |
/** Constructs the object setting the scaling-type and croppability properties.
|
sl@0
|
535 |
|
sl@0
|
536 |
@param aScalingType Whether or not the picture is scalable.
|
sl@0
|
537 |
@param aCroppable Whether or not the picture is croppable. */
|
sl@0
|
538 |
{}
|
sl@0
|
539 |
|
sl@0
|
540 |
//
|
sl@0
|
541 |
// TZoomFactor
|
sl@0
|
542 |
//
|
sl@0
|
543 |
|
sl@0
|
544 |
|
sl@0
|
545 |
inline TZoomFactor::TZoomFactor(const MGraphicsDeviceMap* aDevice):
|
sl@0
|
546 |
iZoomFactor(TZoomFactor::EZoomOneToOne),
|
sl@0
|
547 |
iDevice(aDevice)
|
sl@0
|
548 |
/** Constructs a zoom factor object for a specific graphics device map.
|
sl@0
|
549 |
|
sl@0
|
550 |
The graphics map is either directly associated with a particular graphics
|
sl@0
|
551 |
device itself, or is associated with a hierarchy of device maps whose root
|
sl@0
|
552 |
map is associated with a particular graphics device.
|
sl@0
|
553 |
|
sl@0
|
554 |
@param aDevice The graphics device map with which the zoom factor is associated. */
|
sl@0
|
555 |
{}
|
sl@0
|
556 |
|
sl@0
|
557 |
inline TZoomFactor::TZoomFactor(const TZoomFactor* aDevice):
|
sl@0
|
558 |
iDevice(aDevice)
|
sl@0
|
559 |
{
|
sl@0
|
560 |
iZoomFactor=aDevice->iZoomFactor;
|
sl@0
|
561 |
}
|
sl@0
|
562 |
|
sl@0
|
563 |
|
sl@0
|
564 |
inline void TZoomFactor::SetGraphicsDeviceMap(const MGraphicsDeviceMap* aDevice)
|
sl@0
|
565 |
/** Sets the graphics device map for this zoom factor object.
|
sl@0
|
566 |
|
sl@0
|
567 |
@param aDevice The graphics device map for this TZoomFactor. */
|
sl@0
|
568 |
{iDevice=aDevice;}
|
sl@0
|
569 |
|
sl@0
|
570 |
|
sl@0
|
571 |
inline const MGraphicsDeviceMap* TZoomFactor::GraphicsDeviceMap() const
|
sl@0
|
572 |
/** Gets the graphics device map of this zoom factor object.
|
sl@0
|
573 |
|
sl@0
|
574 |
@return The graphics device map of the TZoomFactor. */
|
sl@0
|
575 |
{return(iDevice);}
|
sl@0
|
576 |
|
sl@0
|
577 |
|
sl@0
|
578 |
|
sl@0
|
579 |
/** Gets the ascent of an ANSI capital letter in the font whether or not
|
sl@0
|
580 |
there are any ANSI capitals in the font.
|
sl@0
|
581 |
@return The positive distance from the font baseline to the top of a
|
sl@0
|
582 |
standard ANSI capital letter
|
sl@0
|
583 |
@publishedAll
|
sl@0
|
584 |
@released
|
sl@0
|
585 |
*/
|
sl@0
|
586 |
inline TInt CFont::FontCapitalAscent() const
|
sl@0
|
587 |
{
|
sl@0
|
588 |
return ExtendedFunction(KFontCapitalAscent);
|
sl@0
|
589 |
}
|
sl@0
|
590 |
|
sl@0
|
591 |
/** Gets the max ascent of any pre-composed glyph in the font. This will
|
sl@0
|
592 |
include accents or diacritics that form part of pre-composed glyphs. It is
|
sl@0
|
593 |
not guaranteed to cover the max ascent of composite glyphs that have to be
|
sl@0
|
594 |
created by a layout engine. This is also the recommended distance between
|
sl@0
|
595 |
the top of a text box and the baseline of the first line of text.
|
sl@0
|
596 |
@return The positive distance from the font baseline to the top of the
|
sl@0
|
597 |
highest pre-composed glyph (including accents) above the baseline
|
sl@0
|
598 |
@publishedAll
|
sl@0
|
599 |
@released
|
sl@0
|
600 |
*/
|
sl@0
|
601 |
inline TInt CFont::FontMaxAscent() const
|
sl@0
|
602 |
{
|
sl@0
|
603 |
return ExtendedFunction(KFontMaxAscent);
|
sl@0
|
604 |
}
|
sl@0
|
605 |
|
sl@0
|
606 |
/** Gets the descent of an ANSI descending character in the font.
|
sl@0
|
607 |
Whether or not there are any ANSI descenders in the font.
|
sl@0
|
608 |
@return The positive distance from the font baseline to the bottom of the
|
sl@0
|
609 |
lowest ANSI descender
|
sl@0
|
610 |
@publishedAll
|
sl@0
|
611 |
@released
|
sl@0
|
612 |
*/
|
sl@0
|
613 |
inline TInt CFont::FontStandardDescent() const
|
sl@0
|
614 |
{
|
sl@0
|
615 |
return ExtendedFunction(KFontStandardDescent);
|
sl@0
|
616 |
}
|
sl@0
|
617 |
|
sl@0
|
618 |
/** Gets the max descent of any pre-composed glyph in the font. This will
|
sl@0
|
619 |
include accents or diacritics that form part of pre-composed glyphs. It is
|
sl@0
|
620 |
not guaranteed to cover the max descent of composite glyphs that have to be
|
sl@0
|
621 |
created by a layout engine.
|
sl@0
|
622 |
@return The positive distance from the font baseline to the bottom of the
|
sl@0
|
623 |
lowest pre-composed glyph (including accents) below the baseline
|
sl@0
|
624 |
@publishedAll
|
sl@0
|
625 |
@released
|
sl@0
|
626 |
*/
|
sl@0
|
627 |
inline TInt CFont::FontMaxDescent() const
|
sl@0
|
628 |
{
|
sl@0
|
629 |
return ExtendedFunction(KFontMaxDescent);
|
sl@0
|
630 |
}
|
sl@0
|
631 |
|
sl@0
|
632 |
/** Gets the suggested line gap for the font. This is the recommended
|
sl@0
|
633 |
baseline to baseline distance between successive lines of text in the font.
|
sl@0
|
634 |
@return The positive recommended gap between successive lines
|
sl@0
|
635 |
@publishedAll
|
sl@0
|
636 |
@released
|
sl@0
|
637 |
*/
|
sl@0
|
638 |
inline TInt CFont::FontLineGap() const
|
sl@0
|
639 |
{
|
sl@0
|
640 |
return ExtendedFunction(KFontLineGap);
|
sl@0
|
641 |
}
|
sl@0
|
642 |
|
sl@0
|
643 |
/**
|
sl@0
|
644 |
Gets the (positive) maximum height in pixels of the font.
|
sl@0
|
645 |
This may differ from the design height.
|
sl@0
|
646 |
|
sl@0
|
647 |
@return The maximum height of the font.
|
sl@0
|
648 |
@publishedAll
|
sl@0
|
649 |
@released
|
sl@0
|
650 |
*/
|
sl@0
|
651 |
inline TInt CFont::FontMaxHeight() const
|
sl@0
|
652 |
{
|
sl@0
|
653 |
return FontMaxAscent() + FontMaxDescent();
|
sl@0
|
654 |
}
|
sl@0
|
655 |
|