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