epoc32/include/gulutil.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/gulutil.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/gulutil.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,370 @@
     1.4 -gulutil.h
     1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +//
    1.19 +
    1.20 +#if !defined(__GULUTIL_H__)
    1.21 +#define __GULUTIL_H__
    1.22 +
    1.23 +#include <e32std.h>
    1.24 +#include <badesca.h>
    1.25 +#include <gdi.h>
    1.26 +#include <gulbordr.h>
    1.27 +#include <gulftflg.hrh>
    1.28 +
    1.29 +/** 
    1.30 +@publishedAll 
    1.31 +@released 
    1.32 +*/
    1.33 +const TUint KTextUtilClipEndChar=0x2026;
    1.34 +
    1.35 +/**
    1.36 +@publishedAll 
    1.37 +@released 
    1.38 +*/
    1.39 +const TUint KColumnListSeparator='\t';
    1.40 +
    1.41 +class CFont;
    1.42 +class CFbsFont;
    1.43 +class CWsScreenDevice;
    1.44 +class TResourceReader;
    1.45 +class CColorArray;
    1.46 +class CGraphicsDevice;
    1.47 +class RWsSession;
    1.48 +class CColorList;
    1.49 +template <class T> class CArrayFix;
    1.50 +
    1.51 +
    1.52 +class TMargins8
    1.53 +/** A set of margins stored as 8 bit integer values which can represent 
    1.54 +either pixels or twips between -128 and +127.
    1.55 +
    1.56 +@publishedAll 
    1.57 +@released */
    1.58 +	{
    1.59 +public :
    1.60 +	/** Left margin in twips or pixels. */
    1.61 +	TInt8 iLeft;
    1.62 +	/** Right margin in twips or pixels. */
    1.63 +	TInt8 iRight;
    1.64 +	/** Top margin in twips or pixels. */
    1.65 +	TInt8 iTop;
    1.66 +	/** Bottom margin in twips or pixels. */
    1.67 +	TInt8 iBottom;
    1.68 +public :
    1.69 +	IMPORT_C TMargins8();
    1.70 +	IMPORT_C TMargins8(TInt8 aLeft, TInt8 aTop, TInt8 aRight, TInt8 aBottom);
    1.71 +	IMPORT_C void SetAllValuesTo(TInt aCommonValue);
    1.72 +    IMPORT_C TRect InnerRect(const TRect& aOuterRect) const;
    1.73 +    IMPORT_C TRect OuterRect(const TRect& aInnerRect) const;
    1.74 +	IMPORT_C TSize SizeDelta() const;
    1.75 +	};
    1.76 +
    1.77 +
    1.78 +class DrawUtils
    1.79 +/** Provides static functions for drawing text in a rectangle. 
    1.80 +
    1.81 +@publishedAll 
    1.82 +@released */
    1.83 +	{
    1.84 +public:
    1.85 +	IMPORT_C static void DrawText(CGraphicsContext& aGc,const TDesC& aString,const TRect& aBox,TInt aBaseLineOffset,
    1.86 +									CGraphicsContext::TTextAlign aHoriz,TInt aMargin,const CFont* aFont);
    1.87 +    IMPORT_C static void DrawBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect);
    1.88 +    IMPORT_C static void ClearBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect);
    1.89 +	};
    1.90 +
    1.91 +
    1.92 +class TextUtils
    1.93 +/** Provides static functions for truncating and aligning text strings. 
    1.94 +
    1.95 +@publishedAll 
    1.96 +@released */
    1.97 +	{
    1.98 +public:
    1.99 +	IMPORT_C static void ClipToFit(TDes& aBuffer,const CFont& aFont,TInt aMaxWidthInPixels,TChar aAlternativeEnd=KTextUtilClipEndChar);
   1.100 +	IMPORT_C static TInt ColumnText(TPtrC& aColumnText,TInt aColumn,const TDesC* aSourceText,TChar aColumnSeparator=KColumnListSeparator);
   1.101 +	IMPORT_C static void TruncateToNumChars(TDes& aBuffer, TInt numChars);
   1.102 +	};
   1.103 +
   1.104 +class FontUtils
   1.105 +/** Provides static functions for getting information about the fonts supported by a graphics 
   1.106 +device. 
   1.107 +
   1.108 +@publishedAll 
   1.109 +@released */
   1.110 +	{
   1.111 +public:
   1.112 +	IMPORT_C static void GetAvailableFontsL(const CGraphicsDevice& aDevice,CDesCArray& aFontNameList,
   1.113 +											TInt aFonts=EGulNoSymbolFonts);
   1.114 +	IMPORT_C static TInt TypefaceAttributes(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName);
   1.115 +	IMPORT_C static TInt GetAvailableHeightsInTwipsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,
   1.116 +													CArrayFix<TInt>& aHeightList);
   1.117 +	IMPORT_C static TInt GetAvailableHeightsInTwipsAndPointsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,
   1.118 +															CArrayFix<TInt>& aTwipsList,CDesCArray& aPointsList);
   1.119 +	IMPORT_C static TInt PointsFromTwips(TInt aTwips);
   1.120 +	IMPORT_C static TInt TwipsFromPoints(TInt aPoints);
   1.121 +	IMPORT_C static TInt TwipsFromPoints(const TDesC& aPoints);
   1.122 +	IMPORT_C static TInt IndexOfNearestHeight(CArrayFix<TInt>& aTwipsList,TInt aHeight);
   1.123 +	};
   1.124 +
   1.125 +
   1.126 +class ResourceUtils
   1.127 +/** Provides static functions for resource reading.
   1.128 +
   1.129 +All functions use pre-initialised resource reader objects to read information 
   1.130 +from resource files.
   1.131 +
   1.132 +@publishedAll 
   1.133 +@released 
   1.134 +@see CCoeEnv::CreateResourceReaderLC() */
   1.135 +	{
   1.136 +public:
   1.137 +	IMPORT_C static CFbsFont* CreateNamedScreenFontL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice);
   1.138 +	IMPORT_C static CFbsFont* CreateNamedScreenFontInPixelsL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice);
   1.139 +	IMPORT_C static CFbsFont* CreateScreenFontL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice);
   1.140 +	inline static TInt8 ReadTInt8L(TResourceReader& aReader);
   1.141 +	inline static TInt16 ReadTInt16L(TResourceReader& aReader);
   1.142 +	inline static TInt32 ReadTInt32L(TResourceReader& aReader);
   1.143 +	IMPORT_C static void PopulateColorArrayL(CColorArray& aColors,TResourceReader& aReader);
   1.144 +private:
   1.145 +	enum TResourceTypeInt { EResourceInt8,EResourceInt16,EResourceInt32 };
   1.146 +private:
   1.147 +	IMPORT_C static TInt32 ReadResourceIntL(TResourceReader& aReader,TResourceTypeInt aSize);
   1.148 +	};
   1.149 +
   1.150 +class ColorUtils
   1.151 +/** Provides static functions for manipulating colours.
   1.152 +
   1.153 +@publishedAll 
   1.154 +@released 
   1.155 +@see TDisplayMode */
   1.156 +	{
   1.157 +public:
   1.158 +	/** The orientation of a bitmap. */
   1.159 +    enum TBitmapOrientation
   1.160 +	    {
   1.161 +		/** The bitmap is vertical. */
   1.162 +	    EBitmapOrientationVertical,
   1.163 +		/** The bitmap is horizontal. */
   1.164 +	    EBitmapOrientationHorizontal
   1.165 +	    };
   1.166 +public:
   1.167 +	IMPORT_C static TRgb ColorAdjust(TRgb aColor,TInt aPercentage);
   1.168 +    IMPORT_C static void CreateGradientBitmapL(CFbsBitmap& aBitmap, const RWsSession& aWs, TInt aBreadth,
   1.169 +                                       TBitmapOrientation aOrientation, TRgb aStartColor, TRgb aEndColor);
   1.170 +	IMPORT_C static CColorList* CreateSystemColorListL(RFs& aFs);
   1.171 +	IMPORT_C static CColorList* CreateSystemColorListL(RFs& aFs,const CColorList& aColorList);
   1.172 +	IMPORT_C static void UpdateSystemColorListL(RFs& aFs,CColorList& aColorList);
   1.173 +	IMPORT_C static void GetRgbDerivedBorderColors(TGulBorder::TColors& aBorderColors,TRgb aBackgroundColor,TDisplayMode aMode);
   1.174 +	IMPORT_C static TRgb RgbDarkerColor(TRgb aRgb,TDisplayMode aMode);
   1.175 +	IMPORT_C static TRgb RgbMidDarkerColor(TRgb aRgb,TDisplayMode aMode);
   1.176 +	IMPORT_C static TRgb RgbLighterColor(TRgb aRgb,TDisplayMode aMode);
   1.177 +	};
   1.178 +
   1.179 +
   1.180 +class TFindWidthOfWidestTextItem
   1.181 +/** Finds the width in pixels of the widest item in a range of indexed text items.
   1.182 +
   1.183 +This is the base class for several classes used to get the maximum width for 
   1.184 +date and time components.
   1.185 +
   1.186 +Derived classes should override the pure virtual methods to supply an appropriate 
   1.187 +range of items. 
   1.188 +
   1.189 +@publishedAll 
   1.190 +@released */
   1.191 +	{
   1.192 +protected:
   1.193 +	/** Default constructor. */
   1.194 +	inline TFindWidthOfWidestTextItem() {}
   1.195 +public:
   1.196 +	IMPORT_C TInt MaximumWidthInPixels(const CFont& aFont) const;
   1.197 +private:
   1.198 +	/** Gets the first and last index in the range of items.
   1.199 +	
   1.200 +	@param aFirstIndex On return, the first index.
   1.201 +	@param aLastIndex On return, the last index. 
   1.202 +	@publishedAll
   1.203 +	@released */
   1.204 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const=0;
   1.205 +	/** Gets the text item at the specfied index.
   1.206 +	
   1.207 +	@param aText On return, the indexed text item.
   1.208 +	@param aIndex The index. 
   1.209 +	@publishedAll 
   1.210 +	@released */
   1.211 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const=0;
   1.212 +	};
   1.213 +
   1.214 +
   1.215 +class TFindWidthOfWidestDigit : public TFindWidthOfWidestTextItem
   1.216 +/** Finds the width in pixels of the widest digit, when displayed in a specified 
   1.217 +font.
   1.218 +
   1.219 +After construction, call MaximumWidthInPixels(), defined in the base class, 
   1.220 +specifying the font. 
   1.221 +
   1.222 +@publishedAll
   1.223 +@released */
   1.224 +	{
   1.225 +public:
   1.226 +	IMPORT_C TFindWidthOfWidestDigit();
   1.227 +private:
   1.228 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
   1.229 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
   1.230 +	};
   1.231 +
   1.232 +class TFindWidthOfWidestDigitType : public TFindWidthOfWidestTextItem
   1.233 +/**
   1.234 +@publishedAll
   1.235 +@released
   1.236 +*/
   1.237 +	{
   1.238 +public:
   1.239 +	IMPORT_C TFindWidthOfWidestDigitType(TDigitType aDigitType);
   1.240 +private:
   1.241 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
   1.242 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
   1.243 +
   1.244 +private:
   1.245 +	TDigitType iDigitType;
   1.246 +	};
   1.247 +
   1.248 +class TFindWidthOfWidestAmPmName : public TFindWidthOfWidestTextItem
   1.249 +/** Finds the width in pixels of the widest Am or Pm text, when displayed in a specified 
   1.250 +font.
   1.251 +
   1.252 +After construction, call MaximumWidthInPixels(), defined in the base class, 
   1.253 +specifying the font.
   1.254 +
   1.255 +@publishedAll
   1.256 +@released 
   1.257 +@see TAmPmName */
   1.258 +	{
   1.259 +public:
   1.260 +	IMPORT_C TFindWidthOfWidestAmPmName();
   1.261 +private:
   1.262 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
   1.263 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
   1.264 +	};
   1.265 +
   1.266 +class TFindWidthOfWidestAbbreviatedDayName : public TFindWidthOfWidestTextItem
   1.267 +/** Finds the width in pixels of the widest abbreviated day name (for instance Mon, Tue) 
   1.268 +when displayed in a specified font.
   1.269 +
   1.270 +After construction, call MaximumWidthInPixels(), defined in the base class, 
   1.271 +specifying the font.
   1.272 +
   1.273 +@publishedAll
   1.274 +@released 
   1.275 +@see TDayNameAbb */
   1.276 +	{
   1.277 +public:
   1.278 +	IMPORT_C TFindWidthOfWidestAbbreviatedDayName();
   1.279 +private:
   1.280 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
   1.281 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
   1.282 +	};
   1.283 +
   1.284 +
   1.285 +class TFindWidthOfWidestDayName : public TFindWidthOfWidestTextItem
   1.286 +/** Finds the width in pixels of the widest day name, when displayed in a specified 
   1.287 +font.
   1.288 +
   1.289 +After construction, call MaximumWidthInPixels(), defined in the base class, 
   1.290 +specifying the font. 
   1.291 +
   1.292 +@publishedAll 
   1.293 +@released */
   1.294 +	{
   1.295 +public:
   1.296 +	IMPORT_C TFindWidthOfWidestDayName();
   1.297 +private:
   1.298 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
   1.299 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
   1.300 +	};
   1.301 +
   1.302 +
   1.303 +class TFindWidthOfWidestAbbreviatedMonthName : public TFindWidthOfWidestTextItem
   1.304 +/** Finds the width in pixels of the widest abbreviated month name (for instance Jan, Feb), 
   1.305 +when displayed in a specified font.
   1.306 +
   1.307 +After construction, call MaximumWidthInPixels(), defined in the base class, 
   1.308 +specifying the font. 
   1.309 +
   1.310 +@publishedAll 
   1.311 +@released */
   1.312 +	{
   1.313 +public:
   1.314 +	IMPORT_C TFindWidthOfWidestAbbreviatedMonthName();
   1.315 +private:
   1.316 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
   1.317 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
   1.318 +	};
   1.319 +
   1.320 +class TFindWidthOfWidestMonthName : public TFindWidthOfWidestTextItem
   1.321 +/** Finds the width in pixels of the widest month name, when displayed in a specified 
   1.322 +font.
   1.323 +
   1.324 +After construction, call MaximumWidthInPixels(), defined in the base class, 
   1.325 +specifying the font. 
   1.326 +
   1.327 +@publishedAll 
   1.328 +@released */
   1.329 +	{
   1.330 +public:
   1.331 +	IMPORT_C TFindWidthOfWidestMonthName();
   1.332 +private:
   1.333 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
   1.334 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
   1.335 +	};
   1.336 +
   1.337 +class TFindWidthOfWidestDateSuffix : public TFindWidthOfWidestTextItem
   1.338 +/** Finds the width in pixels of the widest date suffix (for instance st, nd), 
   1.339 +when displayed in a specified font.
   1.340 +
   1.341 +After construction, call MaximumWidthInPixels(), defined in the base class, 
   1.342 +specifying the font. 
   1.343 +
   1.344 +@publishedAll 
   1.345 +@released */
   1.346 +	{
   1.347 +public:
   1.348 +	IMPORT_C TFindWidthOfWidestDateSuffix();
   1.349 +private:
   1.350 +	virtual void GetFirstAndLastIndex(TInt& aFirstIndex, TInt& aLastIndex) const;
   1.351 +	virtual void GetTextItem(TDes& aText, TInt aIndex) const;
   1.352 +	};
   1.353 +
   1.354 +//	class ResourceUtils
   1.355 +inline TInt8 ResourceUtils::ReadTInt8L(TResourceReader& aReader)
   1.356 +/** Reads an 8 bit signed integer from a resource.
   1.357 +
   1.358 +@param aReader Resource reader to use to read the integer.
   1.359 +@return The 8 bit signed integer. */
   1.360 +	{ return((TInt8)ReadResourceIntL(aReader,EResourceInt8)); }
   1.361 +inline TInt16 ResourceUtils::ReadTInt16L(TResourceReader& aReader)
   1.362 +/** Reads a 16 bit signed integer from a resource.
   1.363 +
   1.364 +@param aReader Resource reader to use to read the integer.
   1.365 +@return The 16 bit signed integer. */
   1.366 +	{ return((TInt16)ReadResourceIntL(aReader,EResourceInt16)); }
   1.367 +inline TInt32 ResourceUtils::ReadTInt32L(TResourceReader& aReader)
   1.368 +/** Reads a 32 bit signed integer from a resource.
   1.369 +
   1.370 +@param aReader Resource reader to use to read the integer.
   1.371 +@return The 32 bit signed integer. */
   1.372 +	{ return((TInt32)ReadResourceIntL(aReader,EResourceInt32)); }
   1.373 +
   1.374 +#endif