Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 /** Constructs a TRgb initialised to KRgbWhite.*/
25 inline TRgb::TRgb(TUint32 aValue):
26 iValue(((aValue & 0xff0000) >> 16) | (aValue & 0x00ff00) | ((aValue & 0x0000ff) << 16) | (0xff000000 - (aValue & 0xff000000)))
27 /** Constructs a TRgb directly from a single 32-bit integer.
29 The integer is of the form 0xaabbggrr, where bb is the hex number of blue,
30 gg is the hex number for green, and rr is the hex number for red, aa is the hex number of
31 alpha (0 means opaque, 255 means transparent).
33 For example, TRgb(2,4,8) using the 3 colour constructor is equal to TRgb(0x00080402) using
36 The constructor is deprecated. Use others constructor or SetInternal() instead.
38 @param aValue Integer representing colour value. Takes form 0x00bbggrr.
42 inline TRgb::TRgb(TUint32 aInternalValue, TInt aAlpha) :
43 iValue((aInternalValue & 0x00ffffff) | (aAlpha << 24))
44 /** Constructs a TRgb from a 32-bit integer (which corresponds to a colour) and from an alpha value.
46 The first parameter is of the form 0x00rrggbb, where rr is the hex number for red,
47 gg is the hex number for green, and bb is the hex number of blue.
49 The second parameter corresponds to an alpha channel (0 means transparent, 255 means opaque).
51 For example, TRgb(2,4,8,255) using the 3 colour constructor is equal to TRgb(0x00020408, 255) using
54 The constructor is a replacement for TRgb(TUint32 aValue).
56 @param aInternalValue Integer representing a colour value, which takes the form 0x00rrggbb.
57 @param aAlpha Alpha component of the colour (0 - 255).*/
61 inline TRgb::TRgb(TInt aRed,TInt aGreen,TInt aBlue):
62 iValue(aRed<<16|aGreen<<8|aBlue|0xff000000)
63 /** Constructs a TRgb from its three component colours.
65 Each colour has a value between 0 and 255.
67 @param aRed Red component of the colour (0 - 255).
68 @param aGreen Green component of the colour (0 - 255).
69 @param aBlue Blue component of the colour (0 - 255). */
72 /** Constructs a TRgb from its three colour components and alpha component.
74 Each component has a value between 0 and 255.
75 The fourth parameter corresponds to an alpha channel (0 means transparent, 255 means opaque).
77 @param aRed Red component of the colour (0 - 255).
78 @param aGreen Green component of the colour (0 - 255).
79 @param aBlue Blue component of the colour (0 - 255).
80 @param aAlpha Alpha component of the colour (0 - 255).*/
81 inline TRgb::TRgb(TInt aRed,TInt aGreen,TInt aBlue, TInt aAlpha):
82 iValue(aRed<<16|aGreen<<8|aBlue|aAlpha<<24)
86 inline TInt TRgb::Red() const
87 /** Gets the red component.
89 @return The red component (0 - 255). */
90 {return((iValue&0xff0000)>>16);}
93 inline TInt TRgb::Green() const
94 /** Gets the green component.
96 @return The green component (0 - 255). */
97 {return((iValue&0xff00)>>8);}
100 inline TInt TRgb::Blue() const
101 /** Gets the blue component.
103 @return The blue component (0 - 255). */
104 {return(iValue&0xff);}
107 inline TBool TRgb::operator==(const TRgb& aColor) const
108 /** Compares this colour with the specified colour for equality.
110 For two colours to be equal, their red, green and blue components must all
113 @param aColor Colour to be compared.
114 @return ETrue. if the colours are equal; EFalse, otherwise. */
116 {return(iValue==aColor.iValue);}
119 inline TBool TRgb::operator!=(const TRgb& aColor) const
120 /** Compares this colour with the specified colour for inequality.
122 Two colours are unequal if one at least one of their red, green and blue components
125 @param aColor Colour to be compared.
126 @return ETrue, if the colours are not equal; EFalse, otherwise.
128 {return(!(*this==aColor));}
130 inline TRgb& TRgb::operator&=(const TRgb& aColor)
131 /** Logical AND assignment operator.
133 The operator ANDs the first operand with the second and then assigns the result
134 back to the first operand.
138 This operates in the TRgb domain. Graphics defines logical operations for
139 drawing primitives which operate in the device colour domain.
141 @param aColor Colour to be compared.
142 @return First operand-contains result of logical AND. */
143 {iValue&=aColor.iValue;return(*this);}
145 inline TRgb& TRgb::operator|=(const TRgb& aColor)
146 /** Logical OR assignment operator.
148 The operator ORs the first operand with the second and then assigns the result
149 back to the first operand.
153 This operates in the TRgb domain. Graphics defines logical operations for
154 drawing primitives which operate in the device colour domain.
156 @param aColor Colour to be compared.
157 @return First operand- contains result of logical OR. */
158 {iValue|=aColor.iValue;return(*this);}
161 inline TRgb& TRgb::operator^=(const TRgb& aColor)
162 /** Logical EXCLUSIVE OR assignment operator.
164 The operator Exclusive ORs the first operand with the second and then assigns
165 the result back to the first operand.
169 This operates in the TRgb domain. Graphics defines logical operations for
170 drawing primitives which operate in the device colour domain.
172 @param aColor Colour to be compared.
173 @return First operand contains result of logical Exclusive OR. */
174 {iValue^=aColor.iValue;iValue^=0xff000000; return(*this);}
177 inline TUint32 TRgb::Value() const
178 /** Gets the 32-bit value of the TRgb as an integer.
179 This function is deprecated. Use Internal() instead.
181 @return The 32 bit value of the TRgb. Has the form 0xaabbggrr, where bb is the hex number of blue,
182 gg is the hex number for green, rr is the hex number for red and aa is the hex number of
183 alpha (0 means opaque, 255 means transparent).
186 {return (((iValue & 0xff0000) >> 16) | (iValue & 0x00ff00) | ((iValue & 0x0000ff) << 16) | (0xff000000 - (iValue & 0xff000000)));}
188 inline TUint32 TRgb::Internal() const
189 /** Gets the 32-bit value of the TRgb as an integer.
191 @return The 32 bit value of the TRgb. Has the form 0xaarrggbb. */
194 inline void TRgb::SetInternal(TUint32 aInternal)
195 /** Sets the 32-bit value of the TRgb as a 32-bit integer.
196 @param aInternal Colour internal representation. Has the form 0xaarrggbb.
198 {iValue = aInternal;}
200 inline TRgb TRgb::operator~() const
201 /** Bitwise logical inversion operator.
203 @return Contains results of logical inversion. */
204 {TRgb rgb; rgb.SetInternal(iValue^0x00ffffff); return rgb;}
207 inline TRgb TRgb::operator&(const TRgb& aColor)
208 /** Bitwise logical AND operator.
210 @param aColor Colour to be compared.
211 @return Contains results of logical AND. */
212 {TRgb rgb; rgb.SetInternal(iValue&aColor.iValue); return rgb;}
215 inline TRgb TRgb::operator|(const TRgb& aColor)
216 /** Bitwise logical OR operator.
218 @param aColor Colour to be compared.
219 @return Contains results of logical OR. */
220 {TRgb rgb; rgb.SetInternal(iValue|aColor.iValue); return rgb;}
223 inline TRgb TRgb::operator^(const TRgb& aColor)
224 /** Bitwise EXCLUSIVE OR operator
226 @param aColor Colour to be compared.
227 @return Contains results of logical EXCLUSIVE OR. */
228 {TRgb rgb; rgb.SetInternal(iValue^aColor.iValue); return rgb;}
231 /** Gets TRgb from 2 level grayscale.
233 The function takes a grayscale argument and return a TRgb whose red, green
234 and blue values are set to an appropriate level.
236 @param aGray2 Grayscale value to be converted.
237 @return Equivalent 24 bit colour. Gray2 has only 2 levels (black and white),
238 the function returns r=g=b=0 or r=g=b=255. */
239 inline TRgb TRgb::_Gray2(TInt aGray2)
241 if(aGray2) return(TRgb(0xffffff, 0xff));
242 return(TRgb(0, 0xff));
245 /** Gets TRgb from 4 level grayscale.
247 The function takes a grayscale argument and return a TRgb whose red, green
248 and blue values are set to an appropriate level.
250 @param aGray4 Grayscale value to be converted.
251 @return Equivalent 24 bit colour. Gray4 has 4 levels- the function returns
252 r=g=b=85*c, where c=0,1,2, or 3. */
253 inline TRgb TRgb::_Gray4(TInt aGray4)
258 return(TRgb(aGray4,aGray4,aGray4));
261 /** Gets TRgb from 16 level grayscale.
263 The function takes a grayscale argument and return a TRgb whose red, green
264 and blue values are set to an appropriate level.
266 @param aGray16 Grayscale value to be converted.
267 @return Equivalent 24 bit colour. Gray16 has 16 levels - the function returns
268 r=g=b=17*c, where c=0, 1, ... 15. */
269 inline TRgb TRgb::_Gray16(TInt aGray16)
273 return(TRgb(aGray16,aGray16,aGray16));
276 /** Gets TRgb from 256 level grayscale.
278 The function takes a grayscale argument and return a TRgb whose red, green
279 and blue values are set to an appropriate level.
281 @param aGray256 Grayscale value to be converted.
282 @return Equivalent 24 bit colour. Gray256 has 256 levels- the function
283 returns r=g=b=c, where c=0, 1, ... 255. */
284 inline TRgb TRgb::_Gray256(TInt aGray256)
287 return(TRgb(aGray256,aGray256,aGray256));
290 /** Gets TRgb from 4K colour index.
292 The function takes a 12 bit index into a colour palette and returns a TRgb
293 whose red, green and blue values are set to an appropriate level.
295 @param aColor4K 12 bit index into a colour palette
296 @return Equivalent 24 bit colour. */
297 inline TRgb TRgb::_Color4K(TInt aColor4K)
299 TUint32 value = (aColor4K & 0xf00) << 8;
300 value |= (aColor4K & 0x0f0) << 4;
301 value |= (aColor4K & 0x00f);
302 return TRgb(value | (value << 4), 0xff);
305 /** Gets TRgb from 64K colour index.
307 The function takes a 16 bit index into a colour palette and returns a TRgb
308 whose red, green and blue values are set to an appropriate level.
310 @param aColor64K 16 bit index into a colour palette
311 @return Equivalent 24 bit colour. */
312 inline TRgb TRgb::_Color64K(TInt aColor64K)
314 TInt red = (aColor64K&0xF800)>>8;
316 TInt green = (aColor64K&0x07E0)>>3;
318 TInt blue = (aColor64K&0x001F)<<3;
320 return TRgb(red,green,blue);
323 /** Gets TRgb from 16M colour index.
325 The function takes a 24 bit index into a colour palette and returns the TRgb
326 whose red, green and blue values represent it exactly.
328 @param a0RGB 24 bit index into a colour palette
329 @return The TRgb which represents the index exactly. */
330 inline TRgb TRgb::_Color16M(TInt a0RGB)
332 return TRgb(a0RGB, 0xff);
335 /** Gets TRgb from 16MU colour index.
336 The function takes a 24 bit colour value with eight bits for each
337 component, blue in the low byte, and returns the TRgb
338 whose red, green and blue values represent it exactly.
339 @param a0RGB The color - 0, R, G, B bytes. / BGR0 - little endian format /
340 @return The TRgb which represents the index exactly. */
341 inline TRgb TRgb::_Color16MU(TInt a0RGB)
343 return TRgb(a0RGB, 0xff);
346 /** Gets the index of the closest TRgb value to this,
347 based on the matching display mode.
349 @return The index (0 - 1) representing the nearest TRgb. */
350 inline TInt TRgb::_Gray2() const
352 return(Gray256()>>7);
355 /**Gets the index of the closest TRgb value to this,
356 based on the matching display mode.
358 @return The index (0 - 3) representing the nearest TRgb. */
359 inline TInt TRgb::_Gray4() const
361 return(Gray256()>>6);
364 /** Gets the index of the closest TRgb value to this,
365 based on the matching display mode.
367 @return The index (0 - 15) representing the nearest TRgb.*/
368 inline TInt TRgb::_Gray16() const
370 return(Gray256()>>4);
373 /** Gets the index of the closest TRgb value to this,
374 based on the matching display mode.
376 @return The index (0 - 255) representing the nearest TRgb.*/
377 inline TInt TRgb::_Gray256() const
379 return(((Red()<<1)+Green()+(Green()<<2)+Blue())>>3);
382 /** Gets the index of the closest TRgb value to this,
383 based on the matching display mode.
385 @return The index (0 - 4095) representing the nearest TRgb. */
386 inline TInt TRgb::_Color4K() const
388 TInt color4K = (iValue & 0x0000f0) >> 4;
389 color4K |= (iValue & 0x00f000) >> 8;
390 color4K |= (iValue & 0xf00000) >> 12;
394 /** Gets the index of the closest TRgb value to this,
395 based on the matching display mode.
397 @return The index (0 - 65535) representing the nearest TRgb.*/
398 inline TInt TRgb::_Color64K() const
400 TInt color64K = (iValue & 0x0000f8) >> 3;
401 color64K |= (iValue & 0x00fc00) >> 5;
402 color64K |= (iValue & 0xf80000) >> 8;
406 /** Gets the index of the closest TRgb value to this,
407 based on the matching display mode.
409 @return The index (0 - 16777215) representing the nearest TRgb.*/
410 inline TInt TRgb::_Color16M() const
412 return (iValue & 0xffffff);
416 /** Gets the index of the closest TRgb value to this, based on the matching display mode.
417 @return The index (0 - 16777215) representing the nearest TRgb. */
418 inline TInt TRgb::_Color16MU() const
420 return (iValue & 0xffffff);
425 /** Gets the alpha component.
426 @return The alpha component (0 - 255). */
427 inline TInt TRgb::Alpha() const
428 {return (iValue >> 24);}
431 /** Gets TRgb from 16MA colour index.
432 The function takes a 32 bit colour value with eight bits for each
433 component, blue in the low byte, and returns the TRgb
434 whose red, green, blue and alpha values represent it exactly.
435 @param aARGB The color - A, R, G, B bytes. / BGR0 - little endian format /
436 @return The TRgb which represents the index exactly. */
437 inline TRgb TRgb::_Color16MA(TUint aARGB)
439 TRgb col; col.SetInternal(aARGB);
443 /** Gets the index of the closest TRgb value to this, based on the matching display mode.
444 @return The index (0 - 16777215) representing the nearest TRgb. */
445 inline TUint TRgb::_Color16MA() const
455 inline TInt CPalette::Entries() const
456 /** Gets the number of entries in the palette
458 @return The number of entries in the palette. */
459 {return(iNumEntries);}
466 inline TRgb TColor256Util::Color256(TInt aColor256) const
467 /** Gets the TRgb value of the entry at the specified index in the colour lookup
470 @param aColor256 The index into the colour lookup table.
471 @return The TRgb value of the entry at the specified index. */
472 { return TRgb(iColorTable[aColor256]); }
477 inline TGlyphBitmapType TFontStyle::BitmapType() const
478 /** Gets the anti-aliasing setting for the font, as set by SetBitmapType().
480 @return Indicates whether or not this font should be drawn using anti-aliasing. */
482 return (TGlyphBitmapType)(iFlags >> 16);
486 inline void TFontStyle::SetBitmapType(TGlyphBitmapType aBitmapType)
487 /** Sets whether the font should be drawn using anti-aliasing. If set, this value
488 overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType())
491 Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing
492 support for bitmapped fonts.
494 @param aBitmapType Indicates whether or not this font should be drawn using
498 iFlags |= (aBitmapType << 16);
506 inline TInt CBitmapDevice::CreateBitmapContext(CBitmapContext*& aGC)
507 /** Creates a bitmap context for this bitmap device.
509 @param aGC On return, holds a pointer to the created bitmap context.
510 @return KErrNone, if successful; otherwise, another of the system-wide error
512 {return(CreateContext((CGraphicsContext*&)aGC));} // relies on CBitmapContext deriving _only_ from CGraphicsContext
515 // TPictureCapability
518 inline TPictureCapability::TPictureCapability(TScalingType aScalingType,TBool aCroppable):
519 iScalingType(aScalingType),iIsCroppable(aCroppable)
520 /** Constructs the object setting the scaling-type and croppability properties.
522 @param aScalingType Whether or not the picture is scalable.
523 @param aCroppable Whether or not the picture is croppable. */
531 inline TZoomFactor::TZoomFactor(const MGraphicsDeviceMap* aDevice):
532 iZoomFactor(TZoomFactor::EZoomOneToOne),
534 /** Constructs a zoom factor object for a specific graphics device map.
536 The graphics map is either directly associated with a particular graphics
537 device itself, or is associated with a hierarchy of device maps whose root
538 map is associated with a particular graphics device.
540 @param aDevice The graphics device map with which the zoom factor is associated. */
543 inline TZoomFactor::TZoomFactor(const TZoomFactor* aDevice):
546 iZoomFactor=aDevice->iZoomFactor;
550 inline void TZoomFactor::SetGraphicsDeviceMap(const MGraphicsDeviceMap* aDevice)
551 /** Sets the graphics device map for this zoom factor object.
553 @param aDevice The graphics device map for this TZoomFactor. */
557 inline const MGraphicsDeviceMap* TZoomFactor::GraphicsDeviceMap() const
558 /** Gets the graphics device map of this zoom factor object.
560 @return The graphics device map of the TZoomFactor. */
565 /** Gets the ascent of an ANSI capital letter in the font whether or not
566 there are any ANSI capitals in the font.
567 @return The positive distance from the font baseline to the top of a
568 standard ANSI capital letter
572 inline TInt CFont::FontCapitalAscent() const
574 return ExtendedFunction(KFontCapitalAscent);
577 /** Gets the max ascent of any pre-composed glyph in the font. This will
578 include accents or diacritics that form part of pre-composed glyphs. It is
579 not guaranteed to cover the max ascent of composite glyphs that have to be
580 created by a layout engine. This is also the recommended distance between
581 the top of a text box and the baseline of the first line of text.
582 @return The positive distance from the font baseline to the top of the
583 highest pre-composed glyph (including accents) above the baseline
587 inline TInt CFont::FontMaxAscent() const
589 return ExtendedFunction(KFontMaxAscent);
592 /** Gets the descent of an ANSI descending character in the font.
593 Whether or not there are any ANSI descenders in the font.
594 @return The positive distance from the font baseline to the bottom of the
595 lowest ANSI descender
599 inline TInt CFont::FontStandardDescent() const
601 return ExtendedFunction(KFontStandardDescent);
604 /** Gets the max descent of any pre-composed glyph in the font. This will
605 include accents or diacritics that form part of pre-composed glyphs. It is
606 not guaranteed to cover the max descent of composite glyphs that have to be
607 created by a layout engine.
608 @return The positive distance from the font baseline to the bottom of the
609 lowest pre-composed glyph (including accents) below the baseline
613 inline TInt CFont::FontMaxDescent() const
615 return ExtendedFunction(KFontMaxDescent);
618 /** Gets the suggested line gap for the font. This is the recommended
619 baseline to baseline distance between successive lines of text in the font.
620 @return The positive recommended gap between successive lines
624 inline TInt CFont::FontLineGap() const
626 return ExtendedFunction(KFontLineGap);
630 Gets the (positive) maximum height in pixels of the font.
631 This may differ from the design height.
633 @return The maximum height of the font.
637 inline TInt CFont::FontMaxHeight() const
639 return FontMaxAscent() + FontMaxDescent();
642 /** Utility function to check if a display mode has Alpha channel information
643 @param aDisplayMode - the display mode being queried
644 @return ETrue if display mode contains Alpha information.
648 inline TBool IsAlphaChannel(TDisplayMode aDisplayMode)
650 if(aDisplayMode == EColor16MAP || aDisplayMode == EColor16MA)
660 inline TUint QuoteOrBracketPair(TUint code)
662 // given the opening/closing quote or bracket, return the corresponding closing/opening quote or bracket
665 case 0x0022: return 0x0022; // "..."
666 case 0x0027: return 0x0027; // '...'
667 case 0x0028: return 0x0029; // (...)
668 case 0x003c: return 0x003e; // <...>
669 case 0x005b: return 0x005d; // [...]
670 case 0x007b: return 0x007d; // {...}
671 case 0x2018: return 0x2019; // Single quotation marks
672 case 0x201b: return 0x2019; // Single high-reversed-9 quotation mark
673 case 0x201c: return 0x201d; // Double quotation marks
674 case 0x201f: return 0x201d; // Double high-reversed-9 quotation mark
675 case 0x2035: return 0x2032; // Single primes
676 case 0x2036: return 0x2033; // Double primes
677 case 0x2037: return 0x2034; // Triple primes
678 case 0x2039: return 0x203a; // Single left/right-pointing angle quotation marks
679 case 0x2045: return 0x2046; // Square brackets with quill
681 case 0x0029: return 0x0028; // (...)
682 case 0x003e: return 0x003c; // <...>
683 case 0x005d: return 0x005b; // [...]
684 case 0x007d: return 0x007b; // {...}
685 case 0x2019: return 0x2018; // Single quotation marks
686 case 0x201d: return 0x201c; // Double quotation marks
687 case 0x2032: return 0x2035; // Single primes
688 case 0x2033: return 0x2036; // Double primes
689 case 0x2034: return 0x2037; // Triple primes
690 case 0x203a: return 0x2039; // Single left/right-pointing angle quotation marks
691 case 0x2046: return 0x2045; // Square brackets with quill
701 inline TBool IsIgnoredCharacterForLocalisedProcFunc(TChar aCode)
703 // All Devanagari characters should be ignored until DrawTextWithContext is implemented
704 // The current GDI only implementation for localised punctuation only works for some
705 // Devanagari characters. Hence this function 'blocks' all Devanagari characters, for now.
706 if (aCode >= 0x0900 && aCode <= 0x0965)
709 TChar::TBdCategory cat = aCode.GetBdCategory();
711 if ((cat == TChar::ELeftToRight ||
712 cat == TChar::ERightToLeft ||
713 cat == TChar::ERightToLeftArabic))