1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
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 |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
19 inline TRgb::TRgb(): |
19 inline TRgb::TRgb(): |
20 iValue(0xffffffff) |
20 iValue(0xffffffff) |
21 /** Constructs a TRgb initialised to KRgbWhite.*/ |
21 /** Constructs a TRgb initialised to KRgbWhite.*/ |
22 {} |
22 {} |
23 |
23 |
24 |
24 |
25 inline TRgb::TRgb(TUint32 aValue): |
25 inline TRgb::TRgb(TUint32 aValue): |
26 iValue(((aValue & 0xff0000) >> 16) | (aValue & 0x00ff00) | ((aValue & 0x0000ff) << 16) | (0xff000000 - (aValue & 0xff000000))) |
26 iValue(((aValue & 0xff0000) >> 16) | (aValue & 0x00ff00) | ((aValue & 0x0000ff) << 16) | (0xff000000 - (aValue & 0xff000000))) |
27 /** Constructs a TRgb directly from a single 32-bit integer. |
27 /** Constructs a TRgb directly from a single 32-bit integer. |
28 |
28 |
29 The integer is of the form 0xaabbggrr, where bb is the hex number of blue, |
29 The integer is of the form 0xaabbggrr, where bb is the hex number for blue, |
30 gg is the hex number for green, and rr is the hex number for red, aa is the hex number of |
30 gg is the hex number for green, rr is the hex number for red, and aa is the hex number for |
31 alpha (0 means opaque, 255 means transparent). |
31 "transparency" alpha (0 means opaque, 255 means transparent). |
32 |
32 |
33 For example, TRgb(2,4,8) using the 3 colour constructor is equal to TRgb(0x00080402) using |
33 This constructor is deprecated. The byte order of Red ,Green and Blue |
34 this constructor. |
34 does not match other constructors and methods in this class, |
35 |
35 and the meaning of alpha is reversed compared to current convention. |
36 The constructor is deprecated. Use others constructor or SetInternal() instead. |
36 |
37 |
37 For example, TRgb(0x00080402) using this constructor |
38 @param aValue Integer representing colour value. Takes form 0x00bbggrr. |
38 can be replaced with the 3 colour constructor TRgb(2,4,8). |
|
39 The equivalent explicit alpha constructors are TRgb(0x020408,0xff) and TRgb(2,4,8,255). |
|
40 The equivalent call to SetInternal is SetInternal(0xff020408). |
|
41 |
|
42 This constructor is deprecated. Use other constructors or SetInternal() instead. |
|
43 |
|
44 @param aValue Integer representing colour value. Takes form 0x00bbggrr. |
39 @deprecated */ |
45 @deprecated */ |
40 {} |
46 {} |
41 |
47 |
42 inline TRgb::TRgb(TUint32 aInternalValue, TInt aAlpha) : |
48 inline TRgb::TRgb(TUint32 aInternalValue, TInt aAlpha) : |
43 iValue((aInternalValue & 0x00ffffff) | (aAlpha << 24)) |
49 iValue((aInternalValue & 0x00ffffff) | (aAlpha << 24)) |
44 /** Constructs a TRgb from a 32-bit integer (which corresponds to a colour) and from an alpha value. |
50 /** Constructs a TRgb from a 32-bit integer (which corresponds to a colour) and from an alpha value. |
45 |
51 |
46 The first parameter is of the form 0x00rrggbb, where rr is the hex number for red, |
52 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. |
53 gg is the hex number for green, and bb is the hex number for blue. |
48 |
54 |
49 The second parameter corresponds to an alpha channel (0 means transparent, 255 means opaque). |
55 The second parameter corresponds to an alpha channel (0 means transparent, 255 means opaque). |
50 |
56 |
51 For example, TRgb(2,4,8,255) using the 3 colour constructor is equal to TRgb(0x00020408, 255) using |
57 For example, TRgb(2,4,8,255) using the 3 colour+alpha constructor is equal to TRgb(0x00020408, 255) using |
52 this constructor. |
58 this constructor. |
53 |
59 |
54 The constructor is a replacement for TRgb(TUint32 aValue). |
60 This constructor, which implements alpha in the conventional way, |
|
61 replaces TRgb( TUint32 aValue ) which is deprecated. |
55 |
62 |
56 @param aInternalValue Integer representing a colour value, which takes the form 0x00rrggbb. |
63 @param aInternalValue Integer representing a colour value, which takes the form 0x00rrggbb. |
57 @param aAlpha Alpha component of the colour (0 - 255).*/ |
64 @param aAlpha Alpha component of the colour (0 - 255).*/ |
58 { |
65 { |
59 } |
66 } |
61 inline TRgb::TRgb(TInt aRed,TInt aGreen,TInt aBlue): |
68 inline TRgb::TRgb(TInt aRed,TInt aGreen,TInt aBlue): |
62 iValue(aRed<<16|aGreen<<8|aBlue|0xff000000) |
69 iValue(aRed<<16|aGreen<<8|aBlue|0xff000000) |
63 /** Constructs a TRgb from its three component colours. |
70 /** Constructs a TRgb from its three component colours. |
64 |
71 |
65 Each colour has a value between 0 and 255. |
72 Each colour has a value between 0 and 255. |
66 |
73 The alpha component is always set to opaque (255) |
67 @param aRed Red component of the colour (0 - 255). |
74 |
68 @param aGreen Green component of the colour (0 - 255). |
75 @param aRed Red component of the colour (0 - 255). |
|
76 @param aGreen Green component of the colour (0 - 255). |
69 @param aBlue Blue component of the colour (0 - 255). */ |
77 @param aBlue Blue component of the colour (0 - 255). */ |
70 {} |
78 {} |
71 |
79 |
72 /** Constructs a TRgb from its three colour components and alpha component. |
80 /** Constructs a TRgb from its three colour components and alpha component. |
73 |
81 |
74 Each component has a value between 0 and 255. |
82 Each component has a value between 0 and 255. |
75 The fourth parameter corresponds to an alpha channel (0 means transparent, 255 means opaque). |
83 The fourth parameter corresponds to an alpha channel (0 means transparent, 255 means opaque). |
|
84 |
|
85 This constructor, which implements alpha in the conventional way, |
|
86 replaces TRgb( TUint32 aValue ) which is deprecated. |
76 |
87 |
77 @param aRed Red component of the colour (0 - 255). |
88 @param aRed Red component of the colour (0 - 255). |
78 @param aGreen Green component of the colour (0 - 255). |
89 @param aGreen Green component of the colour (0 - 255). |
79 @param aBlue Blue component of the colour (0 - 255). |
90 @param aBlue Blue component of the colour (0 - 255). |
80 @param aAlpha Alpha component of the colour (0 - 255).*/ |
91 @param aAlpha Alpha component of the colour (0 - 255).*/ |
171 |
182 |
172 @param aColor Colour to be compared. |
183 @param aColor Colour to be compared. |
173 @return First operand contains result of logical Exclusive OR. */ |
184 @return First operand contains result of logical Exclusive OR. */ |
174 {iValue^=aColor.iValue;iValue^=0xff000000; return(*this);} |
185 {iValue^=aColor.iValue;iValue^=0xff000000; return(*this);} |
175 |
186 |
176 |
187 |
177 inline TUint32 TRgb::Value() const |
188 inline TUint32 TRgb::Value() const |
178 /** Gets the 32-bit value of the TRgb as an integer. |
189 /** Gets the 32-bit value of the TRgb as an integer. |
179 This function is deprecated. Use Internal() instead. |
190 This function is deprecated. Use Internal() instead. |
180 |
191 Note: the order of Red, Green and Blue components returned by this method |
181 @return The 32 bit value of the TRgb. Has the form 0xaabbggrr, where bb is the hex number of blue, |
192 is reversed compared to all other methods. The alpha value is also reversed in meaning |
182 gg is the hex number for green, rr is the hex number for red and aa is the hex number of |
193 compared to current convention, such that 0 represents opaque and 0xff represents transparent. |
183 alpha (0 means opaque, 255 means transparent). |
194 |
184 @deprecated */ |
195 @return The 32 bit value of the TRgb. Has the form 0xaabbggrr, where bb is the hex number for blue, |
|
196 gg is the hex number for green, rr is the hex number for red, and aa is the hex number for |
|
197 "transparency" alpha (0 means opaque, 255 means transparent). |
|
198 @deprecated */ |
185 // rr gg bb aa |
199 // rr gg bb aa |
186 {return (((iValue & 0xff0000) >> 16) | (iValue & 0x00ff00) | ((iValue & 0x0000ff) << 16) | (0xff000000 - (iValue & 0xff000000)));} |
200 {return (((iValue & 0xff0000) >> 16) | (iValue & 0x00ff00) | ((iValue & 0x0000ff) << 16) | (0xff000000 - (iValue & 0xff000000)));} |
187 |
201 |
188 inline TUint32 TRgb::Internal() const |
202 inline TUint32 TRgb::Internal() const |
189 /** Gets the 32-bit value of the TRgb as an integer. |
203 /** Gets the 32-bit value of the TRgb as an integer. |
190 |
204 |
191 @return The 32 bit value of the TRgb. Has the form 0xaarrggbb. */ |
205 @return The 32 bit value of the TRgb. Has the form 0xaarrggbb. */ |
192 {return (iValue);} |
206 {return (iValue);} |
193 |
207 |
194 inline void TRgb::SetInternal(TUint32 aInternal) |
208 inline void TRgb::SetInternal(TUint32 aInternal) |
195 /** Sets the 32-bit value of the TRgb as a 32-bit integer. |
209 /** Sets the 32-bit value of the TRgb as a 32-bit integer. |
196 @param aInternal Colour internal representation. Has the form 0xaarrggbb. |
210 @param aInternal Colour internal representation. Has the form 0xaarrggbb. |
197 */ |
211 */ |
198 {iValue = aInternal;} |
212 {iValue = aInternal;} |
199 |
213 |
200 inline TRgb TRgb::operator~() const |
214 inline TRgb TRgb::operator~() const |
201 /** Bitwise logical inversion operator. |
215 /** Bitwise logical inversion operator. |
202 |
216 |
203 @return Contains results of logical inversion. */ |
217 @return Contains results of logical inversion. */ |
204 {TRgb rgb; rgb.SetInternal(iValue^0x00ffffff); return rgb;} |
218 {TRgb rgb; rgb.SetInternal(iValue^0x00ffffff); return rgb;} |
636 */ |
650 */ |
637 inline TInt CFont::FontMaxHeight() const |
651 inline TInt CFont::FontMaxHeight() const |
638 { |
652 { |
639 return FontMaxAscent() + FontMaxDescent(); |
653 return FontMaxAscent() + FontMaxDescent(); |
640 } |
654 } |
641 |
655 |
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. |
|
645 @internalTechnology |
|
646 @released |
|
647 */ |
|
648 inline TBool IsAlphaChannel(TDisplayMode aDisplayMode) |
|
649 { |
|
650 if(aDisplayMode == EColor16MAP || aDisplayMode == EColor16MA) |
|
651 return ETrue; |
|
652 else |
|
653 return EFalse; |
|
654 } |
|
655 |
|
656 /** |
|
657 @internalTechnology |
|
658 @released |
|
659 */ |
|
660 inline TUint QuoteOrBracketPair(TUint code) |
|
661 { |
|
662 // given the opening/closing quote or bracket, return the corresponding closing/opening quote or bracket |
|
663 switch(code) |
|
664 { |
|
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 |
|
680 |
|
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 |
|
692 |
|
693 default: return 0; |
|
694 } |
|
695 } |
|
696 |
|
697 /** |
|
698 @internalTechnology |
|
699 @released |
|
700 */ |
|
701 inline TBool IsIgnoredCharacterForLocalisedProcFunc(TChar aCode) |
|
702 { |
|
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) |
|
707 return ETrue; |
|
708 |
|
709 TChar::TBdCategory cat = aCode.GetBdCategory(); |
|
710 |
|
711 if ((cat == TChar::ELeftToRight || |
|
712 cat == TChar::ERightToLeft || |
|
713 cat == TChar::ERightToLeftArabic)) |
|
714 return EFalse; |
|
715 |
|
716 return ETrue; |
|
717 |
|
718 } |
|