epoc32/include/mw/gulbordr.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/gulbordr.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(__GULBORDR_H__)
williamr@2
    17
#define __GULBORDR_H__
williamr@2
    18
williamr@2
    19
#if !defined(__E32DEF_H__)
williamr@2
    20
#include <e32def.h>
williamr@2
    21
#endif
williamr@2
    22
williamr@2
    23
#if !defined(__GULDEF_H__)
williamr@2
    24
#include <guldef.h>
williamr@2
    25
#endif
williamr@2
    26
williamr@2
    27
#if !defined(__GDI_H__)
williamr@2
    28
#include <gdi.h>
williamr@2
    29
#endif
williamr@2
    30
williamr@2
    31
williamr@2
    32
class TGulBorder
williamr@2
    33
/** Draws a border around a control.
williamr@2
    34
williamr@2
    35
The rectangular areas enclosed by borders are typically working areas of the 
williamr@2
    36
graphics context so the class supplies a number of methods which describe 
williamr@2
    37
how it occupies the area.
williamr@2
    38
williamr@2
    39
A distinction between descriptive and logical borders is made. For descriptive 
williamr@2
    40
borders the appearance of the border is known and fixed. The type of border 
williamr@2
    41
drawn is determined by flags which describe how it is to be constructed. These 
williamr@2
    42
flags can be combined to achieve many different effects, and standard combinations 
williamr@2
    43
have been supplied (see the TBorderType enumeration). For logical borders 
williamr@2
    44
the use of the border is known and fixed but the appearance is not specified. 
williamr@2
    45
The appearance and sizing functions must be supplied in custom written code. 
williamr@2
    46
@publishedAll
williamr@2
    47
@released*/
williamr@2
    48
    {
williamr@2
    49
public:
williamr@2
    50
	class TColors
williamr@2
    51
	/** Represents the colours used within the border and for the optional single pixel 
williamr@2
    52
	border outlines.
williamr@2
    53
williamr@2
    54
	These colours are stored using TRgb values.
williamr@2
    55
williamr@2
    56
	An object of this type can be populated using ColorUtils::GetRgbDerivedBorderColors().
williamr@2
    57
williamr@2
    58
	The colours used inside the border are derived from iBack, the border's background 
williamr@2
    59
	colour, so that border colours can be lighter or darker shades of the colour 
williamr@2
    60
	used in the main body of the control they enclose. Different combinations 
williamr@2
    61
	of light and dark shades are used to draw opposite border sides, to achieve 
williamr@2
    62
	a raised or sunken effect. */
williamr@2
    63
		{
williamr@2
    64
	public:
williamr@2
    65
		IMPORT_C TColors();
williamr@2
    66
	public:	
williamr@2
    67
		/** The line colour.
williamr@2
    68
	
williamr@2
    69
		This is the colour used to draw the outlines on either side of the border. 
williamr@2
    70
		Not all border types have an outline. By default, KRgbBlack. */
williamr@2
    71
		TRgb iLine;
williamr@2
    72
		/** The background colour for the border. 
williamr@2
    73
	
williamr@2
    74
		The other colours used in the border are derived from this.
williamr@2
    75
	
williamr@2
    76
		By default, KRgbWhite. */
williamr@2
    77
		TRgb iBack;
williamr@2
    78
		/** The lightest colour. 
williamr@2
    79
	
williamr@2
    80
		By default, KRgbWhite. */
williamr@2
    81
		TRgb iLight;
williamr@2
    82
		/** The mid light colour. 
williamr@2
    83
	
williamr@2
    84
		This colour is midway between iBack and iLight. By default, KRgbWhite. */
williamr@2
    85
		TRgb iMidlight;
williamr@2
    86
		/** The mid dark colour. 
williamr@2
    87
	
williamr@2
    88
		This colour is midway between iBack and iDark. By default, KRgbDarkGray. */
williamr@2
    89
		TRgb iMid;
williamr@2
    90
		/** The darkest colour.
williamr@2
    91
	
williamr@2
    92
		By default, KRgbDarkGray. */
williamr@2
    93
		TRgb iDark;
williamr@2
    94
		/** Not used. */
williamr@2
    95
		TRgb iInternalBack;
williamr@2
    96
		};
williamr@2
    97
williamr@2
    98
public:
williamr@2
    99
	/** Defines the border outline style. 
williamr@2
   100
williamr@2
   101
	Note that not all border types have an outline. */
williamr@2
   102
	enum TOutlineStyle
williamr@2
   103
		{
williamr@2
   104
		/** The border has a single pixel outline, either solid (by default) or dotted. */
williamr@2
   105
		EWithOutline=0x01,
williamr@2
   106
		/** The border outline is drawn using a dotted pen. */
williamr@2
   107
		EDottedOutline=0x02
williamr@2
   108
		};
williamr@2
   109
williamr@2
   110
	/** Defines whether or not the border has a single pixel interior border. 
williamr@2
   111
williamr@2
   112
	By default it does not. */
williamr@2
   113
	enum TInlineStyle
williamr@2
   114
		{
williamr@2
   115
		/** The border has an interior border. */
williamr@2
   116
		EWithInline=0x04
williamr@2
   117
		};
williamr@2
   118
williamr@2
   119
	/** Defines the 3D border style. */
williamr@2
   120
	enum T3DStyle
williamr@2
   121
		{
williamr@2
   122
		/** A flat border. */
williamr@2
   123
		EFlat=0x10,
williamr@2
   124
		/** A 3D effect sunken border. */
williamr@2
   125
		ESunken=0x20,
williamr@2
   126
		/** A 3D effect raised border. */
williamr@2
   127
		ERaised=0x40
williamr@2
   128
		};
williamr@2
   129
williamr@2
   130
	/** Defines the border's construction style. */
williamr@2
   131
	enum TConstructionStyle
williamr@2
   132
		{
williamr@2
   133
		/** One step border construction. 
williamr@2
   134
	
williamr@2
   135
		This type of border is drawn using the mid light and mid dark colours on opposite 
williamr@2
   136
		sides of the border. */
williamr@2
   137
		EOneStep=0x100,
williamr@2
   138
		/** Two step border construction.
williamr@2
   139
	
williamr@2
   140
		This type of border uses light and dark colours for the main border frame 
williamr@2
   141
		(or mid light for the flat border), and an additional half frame using mid 
williamr@2
   142
		light or mid dark colours. */
williamr@2
   143
		ETwoStep=0x200,
williamr@2
   144
		/** Three step border construction. 
williamr@2
   145
	
williamr@2
   146
		This type of border is drawn with an outer frame, a repeating one pixel band 
williamr@2
   147
		in mid tones, and an inner frame. */
williamr@2
   148
		EThreeStep=0x400,
williamr@2
   149
		/** Inverted two step border construction. 
williamr@2
   150
	
williamr@2
   151
		This is the same as ETwoStep except that for raised and sunken borders, the 
williamr@2
   152
		additional half frame is drawn on the opposite side to that used in ETwoStep. */
williamr@2
   153
		EInvertedTwoStep=0x800
williamr@2
   154
		};
williamr@2
   155
williamr@2
   156
	/** Defines the number of pixels to add to the border thickness.
williamr@2
   157
williamr@2
   158
	The border thickness is the central part of the border, coloured in the mid-tone 
williamr@2
   159
	highlights and lowlights.
williamr@2
   160
williamr@2
   161
	For two step-constructed borders, the additional pixels are only added to 
williamr@2
   162
	either the top left or bottom right hand sides. */
williamr@2
   163
	enum TThickness
williamr@2
   164
		{
williamr@2
   165
		/** The border has one extra pixel. */
williamr@2
   166
		EAddOnePixel=0x1000,
williamr@2
   167
		/** The border has two extra pixels. */
williamr@2
   168
		EAddTwoPixels=0x2000,
williamr@2
   169
		/** The border has four extra pixels. */
williamr@2
   170
		EAddFourPixels=0x4000
williamr@2
   171
		};
williamr@2
   172
williamr@2
   173
	/** Defines the number of pixels that are removed to produce rounded corners. */
williamr@2
   174
	enum TRounding
williamr@2
   175
		{
williamr@2
   176
		/** Border rounded by removing one extra pixel. */
williamr@2
   177
		EAddOneRoundingPixel=0x10000,
williamr@2
   178
		/** Border rounded by removing two extra pixels. */
williamr@2
   179
		EAddTwoRoundingPixels=0x20000,
williamr@2
   180
		/** Border rounded by by removing four extra pixels. */
williamr@2
   181
		EAddFourRoundingPixels=0x40000
williamr@2
   182
		};
williamr@2
   183
private:
williamr@2
   184
	enum TNull
williamr@2
   185
		{
williamr@2
   186
		ENoBorder=0x00
williamr@2
   187
		};
williamr@2
   188
williamr@2
   189
	enum TLegacyStyle
williamr@2
   190
		{
williamr@2
   191
		EShallow=EAddOnePixel,
williamr@2
   192
		EDeep=EAddTwoPixels,
williamr@2
   193
		EThick=EAddFourPixels,
williamr@2
   194
		EHorizontal=0x100000,
williamr@2
   195
		EWithOverlap=0x200000,
williamr@2
   196
		EGray=0x400000,
williamr@2
   197
		EBlack=0x80000
williamr@2
   198
		};
williamr@2
   199
williamr@2
   200
	enum TLogicalStyle
williamr@2
   201
		{
williamr@2
   202
		ELogical=0x800000
williamr@2
   203
		};
williamr@2
   204
public:
williamr@2
   205
	/** For logical borders, defines whether the border encloses a window, a container 
williamr@2
   206
	control or a control. */
williamr@2
   207
	enum TLogicalFamily
williamr@2
   208
		{
williamr@2
   209
		/** Logical border around a window. */
williamr@2
   210
		EWindowFamily=ELogical|0x1,
williamr@2
   211
		/** Logical border around a container. */
williamr@2
   212
		EContainerFamily=ELogical|0x2,
williamr@2
   213
		/** Logical border around a control. */
williamr@2
   214
		EControlFamily=ELogical|0x3
williamr@2
   215
		};
williamr@2
   216
public:
williamr@2
   217
	/** Defines the descriptive border types. */
williamr@2
   218
	enum TBorderType
williamr@2
   219
		{
williamr@2
   220
		/** No border. */
williamr@2
   221
		ENone=ENoBorder,
williamr@2
   222
		/** Border is a 1 pixel wide grey outline. */
williamr@2
   223
		ESingleGray=EWithOutline|EGray,
williamr@2
   224
		/** Border is a 1 pixel wide black outline. */
williamr@2
   225
		ESingleBlack=EWithOutline|EBlack,
williamr@2
   226
		/** Border is a 1 pixel wide dotted outline. */
williamr@2
   227
		ESingleDotted=EWithOutline|EDottedOutline,
williamr@2
   228
		/** A 3D raised border, with 1 pixel thickness. */
williamr@2
   229
		EShallowRaised=ERaised|EOneStep|EAddOnePixel,
williamr@2
   230
		/** A 3D sunken border, with 1 pixel thickness. */
williamr@2
   231
		EShallowSunken=ESunken|EOneStep|EAddOnePixel,
williamr@2
   232
		/** A 3D raised border, with outline, and 2 pixel thickness. */
williamr@2
   233
		EDeepRaised=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
williamr@2
   234
		/** The same as EDeepRaised. */
williamr@2
   235
		EDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
williamr@2
   236
		/** A 3D sunken border, with outline, and 2 pixel thickness. */
williamr@2
   237
		EDeepSunken=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
williamr@2
   238
		/** The same as EDeepSunken. */
williamr@2
   239
		EDeepSunkenWithOutline=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
williamr@2
   240
		/** A 3D raised border, with outline, and 3 pixel thickness. */
williamr@2
   241
		EThickDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddOnePixel|EAddTwoPixels, 
williamr@2
   242
		/** A 3D raised border, with 2 pixels thickness and no outline on the left and 
williamr@2
   243
		right hand sides. */
williamr@2
   244
		EVerticalBar=ERaised|EOneStep|EAddTwoPixels|EWithOverlap,
williamr@2
   245
		/** A 3D raised border, with 2 pixels thickness and no outline on the top and bottom. */
williamr@2
   246
		EHorizontalBar=ERaised|EOneStep|EAddTwoPixels|EHorizontal|EWithOverlap
williamr@2
   247
		};
williamr@2
   248
williamr@2
   249
	/** Defines the logical border types. */
williamr@2
   250
	enum TLogicalType
williamr@2
   251
		{
williamr@2
   252
		// Window family
williamr@2
   253
		/** Raised border around a window. */
williamr@2
   254
		EWindow=EWindowFamily|ERaised,
williamr@2
   255
		// Container family
williamr@2
   256
		/** Flat border around a container. */
williamr@2
   257
		EFlatContainer=EContainerFamily|EFlat,
williamr@2
   258
		/** Raised border around a container. */
williamr@2
   259
		ERaisedContainer=EContainerFamily|ERaised,
williamr@2
   260
		/** Sunken border around a container. */
williamr@2
   261
		ESunkenContainer=EContainerFamily|ESunken,
williamr@2
   262
		// Control Family
williamr@2
   263
		/** Flat border around a control. */
williamr@2
   264
		EFlatControl=EControlFamily|EFlat,
williamr@2
   265
		/** Raised border around a control. */
williamr@2
   266
		ERaisedControl=EControlFamily|ERaised,
williamr@2
   267
		/** Sunken border around a control. */
williamr@2
   268
		ESunkenControl=EControlFamily|ESunken,
williamr@2
   269
		/** Raised border around a control with focus. */
williamr@2
   270
		EFocusedRaisedControl=EControlFamily|ERaised|0x100,
williamr@2
   271
		/** Sunken border around a control with focus. */
williamr@2
   272
		EFocusedSunkenControl=EControlFamily|ESunken|0x100
williamr@2
   273
		};
williamr@2
   274
williamr@2
   275
public:
williamr@2
   276
    IMPORT_C TGulBorder();
williamr@2
   277
    IMPORT_C TGulBorder(TBorderType aType);
williamr@2
   278
    IMPORT_C TGulBorder(TBorderType aType,TGulAdjacent aAdjacent);
williamr@2
   279
	IMPORT_C TGulBorder(TInt aType);
williamr@2
   280
    IMPORT_C TGulBorder(TInt aType,TGulAdjacent aAdjacent);
williamr@2
   281
	IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect,const TColors& aBorderColors) const;
williamr@2
   282
   	IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect) const;
williamr@2
   283
	IMPORT_C TRect InnerRect(const TRect& aOuterRect) const;
williamr@2
   284
   	IMPORT_C TRect OuterRect(const TRect& aInnerRect) const;
williamr@2
   285
	IMPORT_C void SetType(TInt aType);
williamr@2
   286
	IMPORT_C void SetAdjacent(TInt aAdjacent);
williamr@2
   287
	IMPORT_C TSize SizeDelta() const;
williamr@2
   288
   	IMPORT_C TMargins Margins() const;
williamr@2
   289
	IMPORT_C TBool HasBorder() const;
williamr@2
   290
	IMPORT_C TInt Adjacent() const;	
williamr@2
   291
	IMPORT_C TInt Type() const;
williamr@2
   292
public:	// Internal to Symbian
williamr@2
   293
	IMPORT_C TInt Thickness() const;
williamr@2
   294
	IMPORT_C TInt Rounding() const;
williamr@2
   295
private:
williamr@2
   296
	TBool IsSunken() const;
williamr@2
   297
	TInt Depth() const;
williamr@2
   298
	void DrawOutline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
williamr@2
   299
	void DrawRectOutline(CGraphicsContext& aGc,const TRect& aRect) const;
williamr@2
   300
	void DrawInline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
williamr@2
   301
	TMargins OutlineMargins() const;
williamr@2
   302
	TMargins BorderMargins() const;
williamr@2
   303
	TMargins InlineMargins() const;
williamr@2
   304
	TRect OutlineInnerRect(const TRect& aOuterRect) const;
williamr@2
   305
	TRect BorderInnerRect(const TRect& aOuterRect) const;
williamr@2
   306
	TInt BorderRounding() const;
williamr@2
   307
	TInt InlineRounding() const;
williamr@2
   308
	void DrawOneStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aMidlight,TRgb aMid) const;
williamr@2
   309
	void DrawTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
williamr@2
   310
	void DrawInvertedTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
williamr@2
   311
	void DrawThreeStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aBack,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
williamr@2
   312
	void DrawTopLeft(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
williamr@2
   313
	void DrawRoundedTopLeft(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
williamr@2
   314
	void DrawBottomRight(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
williamr@2
   315
	void DrawRoundedBottomRight(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
williamr@2
   316
	void DrawRoundedCorner(CGraphicsContext& aGc,const TPoint& aStart,const TInt aRoundedLength, const TBool aUp, const TBool aRight) const;
williamr@2
   317
	TInt RoundingMargin(const TInt aRoundedLength) const;
williamr@2
   318
	inline TInt InternalType() const;
williamr@2
   319
	void TranslateLegacyTypes();
williamr@2
   320
private:
williamr@2
   321
    TInt iType;
williamr@2
   322
    };
williamr@2
   323
williamr@2
   324
/**
williamr@2
   325
The MGulLogicalBorder class specifices an interface for logical borders.
williamr@2
   326
williamr@2
   327
@internalTechnology*/
williamr@2
   328
class MGulLogicalBorder
williamr@2
   329
	{
williamr@2
   330
public:
williamr@2
   331
	virtual void Draw(const TGulBorder& aBorder,CGraphicsContext& aGc, const TRect& aRect, const TGulBorder::TColors& aBorderColors) const=0;
williamr@2
   332
	virtual TMargins Margins(const TGulBorder& aBorder) const=0;
williamr@2
   333
private:
williamr@2
   334
	IMPORT_C virtual void MGulLogicalBorderReserved();
williamr@2
   335
	};
williamr@2
   336
williamr@2
   337
/**
williamr@2
   338
The GulTls class sets and gets the thread local storage for EGul.
williamr@2
   339
 
williamr@2
   340
@internalTechnology*/
williamr@2
   341
class GulTls
williamr@2
   342
	{
williamr@2
   343
public:
williamr@2
   344
	IMPORT_C static void SetLogicalBorder(MGulLogicalBorder* aLogicalBorder);
williamr@2
   345
	IMPORT_C static const MGulLogicalBorder* LogicalBorder();
williamr@2
   346
	};
williamr@2
   347
williamr@2
   348
#endif