epoc32/include/mw/gulutil.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/gulutil.h@2fe1408b6811
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) 1997-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
//
williamr@2
    15
williamr@2
    16
#if !defined(__GULUTIL_H__)
williamr@2
    17
#define __GULUTIL_H__
williamr@2
    18
williamr@2
    19
#include <e32std.h>
williamr@2
    20
#include <badesca.h>
williamr@2
    21
#include <gdi.h>
williamr@2
    22
#include <gulbordr.h>
williamr@2
    23
#include <gulftflg.hrh>
williamr@2
    24
williamr@2
    25
/** 
williamr@2
    26
@publishedAll 
williamr@2
    27
@released 
williamr@2
    28
*/
williamr@2
    29
const TUint KTextUtilClipEndChar=0x2026;
williamr@2
    30
williamr@2
    31
/**
williamr@2
    32
@publishedAll 
williamr@2
    33
@released 
williamr@2
    34
*/
williamr@2
    35
const TUint KColumnListSeparator='\t';
williamr@2
    36
williamr@2
    37
class CFont;
williamr@2
    38
class CFbsFont;
williamr@2
    39
class CWsScreenDevice;
williamr@2
    40
class TResourceReader;
williamr@2
    41
class CColorArray;
williamr@2
    42
class CGraphicsDevice;
williamr@2
    43
class RWsSession;
williamr@2
    44
class CColorList;
williamr@2
    45
template <class T> class CArrayFix;
williamr@2
    46
williamr@2
    47
williamr@2
    48
class TMargins8
williamr@2
    49
/** A set of margins stored as 8 bit integer values which can represent 
williamr@2
    50
either pixels or twips between -128 and +127.
williamr@2
    51
williamr@2
    52
@publishedAll 
williamr@2
    53
@released */
williamr@2
    54
	{
williamr@2
    55
public :
williamr@2
    56
	/** Left margin in twips or pixels. */
williamr@2
    57
	TInt8 iLeft;
williamr@2
    58
	/** Right margin in twips or pixels. */
williamr@2
    59
	TInt8 iRight;
williamr@2
    60
	/** Top margin in twips or pixels. */
williamr@2
    61
	TInt8 iTop;
williamr@2
    62
	/** Bottom margin in twips or pixels. */
williamr@2
    63
	TInt8 iBottom;
williamr@2
    64
public :
williamr@2
    65
	IMPORT_C TMargins8();
williamr@2
    66
	IMPORT_C TMargins8(TInt8 aLeft, TInt8 aTop, TInt8 aRight, TInt8 aBottom);
williamr@2
    67
	IMPORT_C void SetAllValuesTo(TInt aCommonValue);
williamr@2
    68
    IMPORT_C TRect InnerRect(const TRect& aOuterRect) const;
williamr@2
    69
    IMPORT_C TRect OuterRect(const TRect& aInnerRect) const;
williamr@2
    70
	IMPORT_C TSize SizeDelta() const;
williamr@2
    71
	};
williamr@2
    72
williamr@2
    73
williamr@2
    74
class DrawUtils
williamr@2
    75
/** Provides static functions for drawing text in a rectangle. 
williamr@2
    76
williamr@2
    77
@publishedAll 
williamr@2
    78
@released */
williamr@2
    79
	{
williamr@2
    80
public:
williamr@2
    81
	IMPORT_C static void DrawText(CGraphicsContext& aGc,const TDesC& aString,const TRect& aBox,TInt aBaseLineOffset,
williamr@2
    82
									CGraphicsContext::TTextAlign aHoriz,TInt aMargin,const CFont* aFont);
williamr@2
    83
    IMPORT_C static void DrawBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect);
williamr@2
    84
    IMPORT_C static void ClearBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect);
williamr@2
    85
	};
williamr@2
    86
williamr@2
    87
williamr@2
    88
class TextUtils
williamr@2
    89
/** Provides static functions for truncating and aligning text strings. 
williamr@2
    90
williamr@2
    91
@publishedAll 
williamr@2
    92
@released */
williamr@2
    93
	{
williamr@2
    94
public:
williamr@2
    95
	IMPORT_C static void ClipToFit(TDes& aBuffer,const CFont& aFont,TInt aMaxWidthInPixels,TChar aAlternativeEnd=KTextUtilClipEndChar);
williamr@2
    96
	IMPORT_C static TInt ColumnText(TPtrC& aColumnText,TInt aColumn,const TDesC* aSourceText,TChar aColumnSeparator=KColumnListSeparator);
williamr@2
    97
	IMPORT_C static void TruncateToNumChars(TDes& aBuffer, TInt numChars);
williamr@2
    98
	};
williamr@2
    99
williamr@2
   100
class FontUtils
williamr@2
   101
/** Provides static functions for getting information about the fonts supported by a graphics 
williamr@2
   102
device. 
williamr@2
   103
williamr@2
   104
@publishedAll 
williamr@2
   105
@released */
williamr@2
   106
	{
williamr@2
   107
public:
williamr@2
   108
	IMPORT_C static void GetAvailableFontsL(const CGraphicsDevice& aDevice,CDesCArray& aFontNameList,
williamr@2
   109
											TInt aFonts=EGulNoSymbolFonts);
williamr@2
   110
	IMPORT_C static TInt TypefaceAttributes(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName);
williamr@2
   111
	IMPORT_C static TInt GetAvailableHeightsInTwipsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,
williamr@2
   112
													CArrayFix<TInt>& aHeightList);
williamr@2
   113
	IMPORT_C static TInt GetAvailableHeightsInTwipsAndPointsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,
williamr@2
   114
															CArrayFix<TInt>& aTwipsList,CDesCArray& aPointsList);
williamr@2
   115
	IMPORT_C static TInt PointsFromTwips(TInt aTwips);
williamr@2
   116
	IMPORT_C static TInt TwipsFromPoints(TInt aPoints);
williamr@2
   117
	IMPORT_C static TInt TwipsFromPoints(const TDesC& aPoints);
williamr@2
   118
	IMPORT_C static TInt IndexOfNearestHeight(CArrayFix<TInt>& aTwipsList,TInt aHeight);
williamr@2
   119
	};
williamr@2
   120
williamr@2
   121
williamr@2
   122
class ResourceUtils
williamr@2
   123
/** Provides static functions for resource reading.
williamr@2
   124
williamr@2
   125
All functions use pre-initialised resource reader objects to read information 
williamr@2
   126
from resource files.
williamr@2
   127
williamr@2
   128
@publishedAll 
williamr@2
   129
@released 
williamr@2
   130
@see CCoeEnv::CreateResourceReaderLC() */
williamr@2
   131
	{
williamr@2
   132
public:
williamr@2
   133
	IMPORT_C static CFbsFont* CreateNamedScreenFontL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice);
williamr@2
   134
	IMPORT_C static CFbsFont* CreateNamedScreenFontInPixelsL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice);
williamr@2
   135
	IMPORT_C static CFbsFont* CreateScreenFontL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice);
williamr@2
   136
	inline static TInt8 ReadTInt8L(TResourceReader& aReader);
williamr@2
   137
	inline static TInt16 ReadTInt16L(TResourceReader& aReader);
williamr@2
   138
	inline static TInt32 ReadTInt32L(TResourceReader& aReader);
williamr@2
   139
	IMPORT_C static void PopulateColorArrayL(CColorArray& aColors,TResourceReader& aReader);
williamr@2
   140
private:
williamr@2
   141
	enum TResourceTypeInt { EResourceInt8,EResourceInt16,EResourceInt32 };
williamr@2
   142
private:
williamr@2
   143
	IMPORT_C static TInt32 ReadResourceIntL(TResourceReader& aReader,TResourceTypeInt aSize);
williamr@2
   144
	};
williamr@2
   145
williamr@2
   146
class ColorUtils
williamr@2
   147
/** Provides static functions for manipulating colours.
williamr@2
   148
williamr@2
   149
@publishedAll 
williamr@2
   150
@released 
williamr@2
   151
@see TDisplayMode */
williamr@2
   152
	{
williamr@2
   153
public:
williamr@2
   154
	/** The orientation of a bitmap. */
williamr@2
   155
    enum TBitmapOrientation
williamr@2
   156
	    {
williamr@2
   157
		/** The bitmap is vertical. */
williamr@2
   158
	    EBitmapOrientationVertical,
williamr@2
   159
		/** The bitmap is horizontal. */
williamr@2
   160
	    EBitmapOrientationHorizontal
williamr@2
   161
	    };
williamr@2
   162
public:
williamr@2
   163
	IMPORT_C static TRgb ColorAdjust(TRgb aColor,TInt aPercentage);
williamr@2
   164
    IMPORT_C static void CreateGradientBitmapL(CFbsBitmap& aBitmap, const RWsSession& aWs, TInt aBreadth,
williamr@2
   165
                                       TBitmapOrientation aOrientation, TRgb aStartColor, TRgb aEndColor);
williamr@2
   166
	IMPORT_C static CColorList* CreateSystemColorListL(RFs& aFs);
williamr@2
   167
	IMPORT_C static CColorList* CreateSystemColorListL(RFs& aFs,const CColorList& aColorList);
williamr@2
   168
	IMPORT_C static void UpdateSystemColorListL(RFs& aFs,CColorList& aColorList);
williamr@2
   169
	IMPORT_C static void GetRgbDerivedBorderColors(TGulBorder::TColors& aBorderColors,TRgb aBackgroundColor,TDisplayMode aMode);
williamr@2
   170
	IMPORT_C static TRgb RgbDarkerColor(TRgb aRgb,TDisplayMode aMode);
williamr@2
   171
	IMPORT_C static TRgb RgbMidDarkerColor(TRgb aRgb,TDisplayMode aMode);
williamr@2
   172
	IMPORT_C static TRgb RgbLighterColor(TRgb aRgb,TDisplayMode aMode);
williamr@2
   173
	};
williamr@2
   174
williamr@2
   175
williamr@2
   176
class TFindWidthOfWidestTextItem
williamr@2
   177
/** Finds the width in pixels of the widest item in a range of indexed text items.
williamr@2
   178
williamr@2
   179
This is the base class for several classes used to get the maximum width for 
williamr@2
   180
date and time components.
williamr@2
   181
williamr@2
   182
Derived classes should override the pure virtual methods to supply an appropriate 
williamr@2
   183
range of items. 
williamr@2
   184
williamr@2
   185
@publishedAll 
williamr@2
   186
@released */
williamr@2
   187
	{
williamr@2
   188
protected:
williamr@2
   189
	/** Default constructor. */
williamr@2
   190
	inline TFindWidthOfWidestTextItem() {}
williamr@2
   191
public:
williamr@2
   192
	IMPORT_C TInt MaximumWidthInPixels(const CFont& aFont) const;
williamr@2
   193
private:
williamr@2
   194
	/** Gets the first and last index in the range of items.
williamr@2
   195
	
williamr@2
   196
	@param aFirstIndex On return, the first index.
williamr@2
   197
	@param aLastIndex On return, the last index. 
williamr@2
   198
	@publishedAll
williamr@2
   199
	@released */
williamr@2
   200
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const=0;
williamr@2
   201
	/** Gets the text item at the specfied index.
williamr@2
   202
	
williamr@2
   203
	@param aText On return, the indexed text item.
williamr@2
   204
	@param aIndex The index. 
williamr@2
   205
	@publishedAll 
williamr@2
   206
	@released */
williamr@2
   207
	virtual void GetTextItem(TDes& aText, TInt aIndex) const=0;
williamr@2
   208
	};
williamr@2
   209
williamr@2
   210
williamr@2
   211
class TFindWidthOfWidestDigit : public TFindWidthOfWidestTextItem
williamr@2
   212
/** Finds the width in pixels of the widest digit, when displayed in a specified 
williamr@2
   213
font.
williamr@2
   214
williamr@2
   215
After construction, call MaximumWidthInPixels(), defined in the base class, 
williamr@2
   216
specifying the font. 
williamr@2
   217
williamr@2
   218
@publishedAll
williamr@2
   219
@released */
williamr@2
   220
	{
williamr@2
   221
public:
williamr@2
   222
	IMPORT_C TFindWidthOfWidestDigit();
williamr@2
   223
private:
williamr@2
   224
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
williamr@2
   225
	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
williamr@2
   226
	};
williamr@2
   227
williamr@2
   228
class TFindWidthOfWidestDigitType : public TFindWidthOfWidestTextItem
williamr@2
   229
/**
williamr@2
   230
@publishedAll
williamr@2
   231
@released
williamr@2
   232
*/
williamr@2
   233
	{
williamr@2
   234
public:
williamr@2
   235
	IMPORT_C TFindWidthOfWidestDigitType(TDigitType aDigitType);
williamr@2
   236
private:
williamr@2
   237
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
williamr@2
   238
	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
williamr@2
   239
williamr@2
   240
private:
williamr@2
   241
	TDigitType iDigitType;
williamr@2
   242
	};
williamr@2
   243
williamr@2
   244
class TFindWidthOfWidestAmPmName : public TFindWidthOfWidestTextItem
williamr@2
   245
/** Finds the width in pixels of the widest Am or Pm text, when displayed in a specified 
williamr@2
   246
font.
williamr@2
   247
williamr@2
   248
After construction, call MaximumWidthInPixels(), defined in the base class, 
williamr@2
   249
specifying the font.
williamr@2
   250
williamr@2
   251
@publishedAll
williamr@2
   252
@released 
williamr@2
   253
@see TAmPmName */
williamr@2
   254
	{
williamr@2
   255
public:
williamr@2
   256
	IMPORT_C TFindWidthOfWidestAmPmName();
williamr@2
   257
private:
williamr@2
   258
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
williamr@2
   259
	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
williamr@2
   260
	};
williamr@2
   261
williamr@2
   262
class TFindWidthOfWidestAbbreviatedDayName : public TFindWidthOfWidestTextItem
williamr@2
   263
/** Finds the width in pixels of the widest abbreviated day name (for instance Mon, Tue) 
williamr@2
   264
when displayed in a specified font.
williamr@2
   265
williamr@2
   266
After construction, call MaximumWidthInPixels(), defined in the base class, 
williamr@2
   267
specifying the font.
williamr@2
   268
williamr@2
   269
@publishedAll
williamr@2
   270
@released 
williamr@2
   271
@see TDayNameAbb */
williamr@2
   272
	{
williamr@2
   273
public:
williamr@2
   274
	IMPORT_C TFindWidthOfWidestAbbreviatedDayName();
williamr@2
   275
private:
williamr@2
   276
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
williamr@2
   277
	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
williamr@2
   278
	};
williamr@2
   279
williamr@2
   280
williamr@2
   281
class TFindWidthOfWidestDayName : public TFindWidthOfWidestTextItem
williamr@2
   282
/** Finds the width in pixels of the widest day name, when displayed in a specified 
williamr@2
   283
font.
williamr@2
   284
williamr@2
   285
After construction, call MaximumWidthInPixels(), defined in the base class, 
williamr@2
   286
specifying the font. 
williamr@2
   287
williamr@2
   288
@publishedAll 
williamr@2
   289
@released */
williamr@2
   290
	{
williamr@2
   291
public:
williamr@2
   292
	IMPORT_C TFindWidthOfWidestDayName();
williamr@2
   293
private:
williamr@2
   294
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
williamr@2
   295
	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
williamr@2
   296
	};
williamr@2
   297
williamr@2
   298
williamr@2
   299
class TFindWidthOfWidestAbbreviatedMonthName : public TFindWidthOfWidestTextItem
williamr@2
   300
/** Finds the width in pixels of the widest abbreviated month name (for instance Jan, Feb), 
williamr@2
   301
when displayed in a specified font.
williamr@2
   302
williamr@2
   303
After construction, call MaximumWidthInPixels(), defined in the base class, 
williamr@2
   304
specifying the font. 
williamr@2
   305
williamr@2
   306
@publishedAll 
williamr@2
   307
@released */
williamr@2
   308
	{
williamr@2
   309
public:
williamr@2
   310
	IMPORT_C TFindWidthOfWidestAbbreviatedMonthName();
williamr@2
   311
private:
williamr@2
   312
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
williamr@2
   313
	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
williamr@2
   314
	};
williamr@2
   315
williamr@2
   316
class TFindWidthOfWidestMonthName : public TFindWidthOfWidestTextItem
williamr@2
   317
/** Finds the width in pixels of the widest month name, when displayed in a specified 
williamr@2
   318
font.
williamr@2
   319
williamr@2
   320
After construction, call MaximumWidthInPixels(), defined in the base class, 
williamr@2
   321
specifying the font. 
williamr@2
   322
williamr@2
   323
@publishedAll 
williamr@2
   324
@released */
williamr@2
   325
	{
williamr@2
   326
public:
williamr@2
   327
	IMPORT_C TFindWidthOfWidestMonthName();
williamr@2
   328
private:
williamr@2
   329
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
williamr@2
   330
	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
williamr@2
   331
	};
williamr@2
   332
williamr@2
   333
class TFindWidthOfWidestDateSuffix : public TFindWidthOfWidestTextItem
williamr@2
   334
/** Finds the width in pixels of the widest date suffix (for instance st, nd), 
williamr@2
   335
when displayed in a specified font.
williamr@2
   336
williamr@2
   337
After construction, call MaximumWidthInPixels(), defined in the base class, 
williamr@2
   338
specifying the font. 
williamr@2
   339
williamr@2
   340
@publishedAll 
williamr@2
   341
@released */
williamr@2
   342
	{
williamr@2
   343
public:
williamr@2
   344
	IMPORT_C TFindWidthOfWidestDateSuffix();
williamr@2
   345
private:
williamr@2
   346
	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
williamr@2
   347
	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
williamr@2
   348
	};
williamr@2
   349
williamr@2
   350
//	class ResourceUtils
williamr@2
   351
inline TInt8 ResourceUtils::ReadTInt8L(TResourceReader& aReader)
williamr@2
   352
/** Reads an 8 bit signed integer from a resource.
williamr@2
   353
williamr@2
   354
@param aReader Resource reader to use to read the integer.
williamr@2
   355
@return The 8 bit signed integer. */
williamr@2
   356
	{ return((TInt8)ReadResourceIntL(aReader,EResourceInt8)); }
williamr@2
   357
inline TInt16 ResourceUtils::ReadTInt16L(TResourceReader& aReader)
williamr@2
   358
/** Reads a 16 bit signed integer from a resource.
williamr@2
   359
williamr@2
   360
@param aReader Resource reader to use to read the integer.
williamr@2
   361
@return The 16 bit signed integer. */
williamr@2
   362
	{ return((TInt16)ReadResourceIntL(aReader,EResourceInt16)); }
williamr@2
   363
inline TInt32 ResourceUtils::ReadTInt32L(TResourceReader& aReader)
williamr@2
   364
/** Reads a 32 bit signed integer from a resource.
williamr@2
   365
williamr@2
   366
@param aReader Resource reader to use to read the integer.
williamr@2
   367
@return The 32 bit signed integer. */
williamr@2
   368
	{ return((TInt32)ReadResourceIntL(aReader,EResourceInt32)); }
williamr@2
   369
williamr@2
   370
#endif