1.1 --- a/epoc32/include/gulbordr.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/gulbordr.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,348 @@
1.4 -gulbordr.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(__GULBORDR_H__)
1.21 +#define __GULBORDR_H__
1.22 +
1.23 +#if !defined(__E32DEF_H__)
1.24 +#include <e32def.h>
1.25 +#endif
1.26 +
1.27 +#if !defined(__GULDEF_H__)
1.28 +#include <guldef.h>
1.29 +#endif
1.30 +
1.31 +#if !defined(__GDI_H__)
1.32 +#include <gdi.h>
1.33 +#endif
1.34 +
1.35 +
1.36 +class TGulBorder
1.37 +/** Draws a border around a control.
1.38 +
1.39 +The rectangular areas enclosed by borders are typically working areas of the
1.40 +graphics context so the class supplies a number of methods which describe
1.41 +how it occupies the area.
1.42 +
1.43 +A distinction between descriptive and logical borders is made. For descriptive
1.44 +borders the appearance of the border is known and fixed. The type of border
1.45 +drawn is determined by flags which describe how it is to be constructed. These
1.46 +flags can be combined to achieve many different effects, and standard combinations
1.47 +have been supplied (see the TBorderType enumeration). For logical borders
1.48 +the use of the border is known and fixed but the appearance is not specified.
1.49 +The appearance and sizing functions must be supplied in custom written code.
1.50 +@publishedAll
1.51 +@released*/
1.52 + {
1.53 +public:
1.54 + class TColors
1.55 + /** Represents the colours used within the border and for the optional single pixel
1.56 + border outlines.
1.57 +
1.58 + These colours are stored using TRgb values.
1.59 +
1.60 + An object of this type can be populated using ColorUtils::GetRgbDerivedBorderColors().
1.61 +
1.62 + The colours used inside the border are derived from iBack, the border's background
1.63 + colour, so that border colours can be lighter or darker shades of the colour
1.64 + used in the main body of the control they enclose. Different combinations
1.65 + of light and dark shades are used to draw opposite border sides, to achieve
1.66 + a raised or sunken effect. */
1.67 + {
1.68 + public:
1.69 + IMPORT_C TColors();
1.70 + public:
1.71 + /** The line colour.
1.72 +
1.73 + This is the colour used to draw the outlines on either side of the border.
1.74 + Not all border types have an outline. By default, KRgbBlack. */
1.75 + TRgb iLine;
1.76 + /** The background colour for the border.
1.77 +
1.78 + The other colours used in the border are derived from this.
1.79 +
1.80 + By default, KRgbWhite. */
1.81 + TRgb iBack;
1.82 + /** The lightest colour.
1.83 +
1.84 + By default, KRgbWhite. */
1.85 + TRgb iLight;
1.86 + /** The mid light colour.
1.87 +
1.88 + This colour is midway between iBack and iLight. By default, KRgbWhite. */
1.89 + TRgb iMidlight;
1.90 + /** The mid dark colour.
1.91 +
1.92 + This colour is midway between iBack and iDark. By default, KRgbDarkGray. */
1.93 + TRgb iMid;
1.94 + /** The darkest colour.
1.95 +
1.96 + By default, KRgbDarkGray. */
1.97 + TRgb iDark;
1.98 + /** Not used. */
1.99 + TRgb iInternalBack;
1.100 + };
1.101 +
1.102 +public:
1.103 + /** Defines the border outline style.
1.104 +
1.105 + Note that not all border types have an outline. */
1.106 + enum TOutlineStyle
1.107 + {
1.108 + /** The border has a single pixel outline, either solid (by default) or dotted. */
1.109 + EWithOutline=0x01,
1.110 + /** The border outline is drawn using a dotted pen. */
1.111 + EDottedOutline=0x02
1.112 + };
1.113 +
1.114 + /** Defines whether or not the border has a single pixel interior border.
1.115 +
1.116 + By default it does not. */
1.117 + enum TInlineStyle
1.118 + {
1.119 + /** The border has an interior border. */
1.120 + EWithInline=0x04
1.121 + };
1.122 +
1.123 + /** Defines the 3D border style. */
1.124 + enum T3DStyle
1.125 + {
1.126 + /** A flat border. */
1.127 + EFlat=0x10,
1.128 + /** A 3D effect sunken border. */
1.129 + ESunken=0x20,
1.130 + /** A 3D effect raised border. */
1.131 + ERaised=0x40
1.132 + };
1.133 +
1.134 + /** Defines the border's construction style. */
1.135 + enum TConstructionStyle
1.136 + {
1.137 + /** One step border construction.
1.138 +
1.139 + This type of border is drawn using the mid light and mid dark colours on opposite
1.140 + sides of the border. */
1.141 + EOneStep=0x100,
1.142 + /** Two step border construction.
1.143 +
1.144 + This type of border uses light and dark colours for the main border frame
1.145 + (or mid light for the flat border), and an additional half frame using mid
1.146 + light or mid dark colours. */
1.147 + ETwoStep=0x200,
1.148 + /** Three step border construction.
1.149 +
1.150 + This type of border is drawn with an outer frame, a repeating one pixel band
1.151 + in mid tones, and an inner frame. */
1.152 + EThreeStep=0x400,
1.153 + /** Inverted two step border construction.
1.154 +
1.155 + This is the same as ETwoStep except that for raised and sunken borders, the
1.156 + additional half frame is drawn on the opposite side to that used in ETwoStep. */
1.157 + EInvertedTwoStep=0x800
1.158 + };
1.159 +
1.160 + /** Defines the number of pixels to add to the border thickness.
1.161 +
1.162 + The border thickness is the central part of the border, coloured in the mid-tone
1.163 + highlights and lowlights.
1.164 +
1.165 + For two step-constructed borders, the additional pixels are only added to
1.166 + either the top left or bottom right hand sides. */
1.167 + enum TThickness
1.168 + {
1.169 + /** The border has one extra pixel. */
1.170 + EAddOnePixel=0x1000,
1.171 + /** The border has two extra pixels. */
1.172 + EAddTwoPixels=0x2000,
1.173 + /** The border has four extra pixels. */
1.174 + EAddFourPixels=0x4000
1.175 + };
1.176 +
1.177 + /** Defines the number of pixels that are removed to produce rounded corners. */
1.178 + enum TRounding
1.179 + {
1.180 + /** Border rounded by removing one extra pixel. */
1.181 + EAddOneRoundingPixel=0x10000,
1.182 + /** Border rounded by removing two extra pixels. */
1.183 + EAddTwoRoundingPixels=0x20000,
1.184 + /** Border rounded by by removing four extra pixels. */
1.185 + EAddFourRoundingPixels=0x40000
1.186 + };
1.187 +private:
1.188 + enum TNull
1.189 + {
1.190 + ENoBorder=0x00
1.191 + };
1.192 +
1.193 + enum TLegacyStyle
1.194 + {
1.195 + EShallow=EAddOnePixel,
1.196 + EDeep=EAddTwoPixels,
1.197 + EThick=EAddFourPixels,
1.198 + EHorizontal=0x100000,
1.199 + EWithOverlap=0x200000,
1.200 + EGray=0x400000,
1.201 + EBlack=0x80000
1.202 + };
1.203 +
1.204 + enum TLogicalStyle
1.205 + {
1.206 + ELogical=0x800000
1.207 + };
1.208 +public:
1.209 + /** For logical borders, defines whether the border encloses a window, a container
1.210 + control or a control. */
1.211 + enum TLogicalFamily
1.212 + {
1.213 + /** Logical border around a window. */
1.214 + EWindowFamily=ELogical|0x1,
1.215 + /** Logical border around a container. */
1.216 + EContainerFamily=ELogical|0x2,
1.217 + /** Logical border around a control. */
1.218 + EControlFamily=ELogical|0x3
1.219 + };
1.220 +public:
1.221 + /** Defines the descriptive border types. */
1.222 + enum TBorderType
1.223 + {
1.224 + /** No border. */
1.225 + ENone=ENoBorder,
1.226 + /** Border is a 1 pixel wide grey outline. */
1.227 + ESingleGray=EWithOutline|EGray,
1.228 + /** Border is a 1 pixel wide black outline. */
1.229 + ESingleBlack=EWithOutline|EBlack,
1.230 + /** Border is a 1 pixel wide dotted outline. */
1.231 + ESingleDotted=EWithOutline|EDottedOutline,
1.232 + /** A 3D raised border, with 1 pixel thickness. */
1.233 + EShallowRaised=ERaised|EOneStep|EAddOnePixel,
1.234 + /** A 3D sunken border, with 1 pixel thickness. */
1.235 + EShallowSunken=ESunken|EOneStep|EAddOnePixel,
1.236 + /** A 3D raised border, with outline, and 2 pixel thickness. */
1.237 + EDeepRaised=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
1.238 + /** The same as EDeepRaised. */
1.239 + EDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
1.240 + /** A 3D sunken border, with outline, and 2 pixel thickness. */
1.241 + EDeepSunken=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
1.242 + /** The same as EDeepSunken. */
1.243 + EDeepSunkenWithOutline=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
1.244 + /** A 3D raised border, with outline, and 3 pixel thickness. */
1.245 + EThickDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddOnePixel|EAddTwoPixels,
1.246 + /** A 3D raised border, with 2 pixels thickness and no outline on the left and
1.247 + right hand sides. */
1.248 + EVerticalBar=ERaised|EOneStep|EAddTwoPixels|EWithOverlap,
1.249 + /** A 3D raised border, with 2 pixels thickness and no outline on the top and bottom. */
1.250 + EHorizontalBar=ERaised|EOneStep|EAddTwoPixels|EHorizontal|EWithOverlap
1.251 + };
1.252 +
1.253 + /** Defines the logical border types. */
1.254 + enum TLogicalType
1.255 + {
1.256 + // Window family
1.257 + /** Raised border around a window. */
1.258 + EWindow=EWindowFamily|ERaised,
1.259 + // Container family
1.260 + /** Flat border around a container. */
1.261 + EFlatContainer=EContainerFamily|EFlat,
1.262 + /** Raised border around a container. */
1.263 + ERaisedContainer=EContainerFamily|ERaised,
1.264 + /** Sunken border around a container. */
1.265 + ESunkenContainer=EContainerFamily|ESunken,
1.266 + // Control Family
1.267 + /** Flat border around a control. */
1.268 + EFlatControl=EControlFamily|EFlat,
1.269 + /** Raised border around a control. */
1.270 + ERaisedControl=EControlFamily|ERaised,
1.271 + /** Sunken border around a control. */
1.272 + ESunkenControl=EControlFamily|ESunken,
1.273 + /** Raised border around a control with focus. */
1.274 + EFocusedRaisedControl=EControlFamily|ERaised|0x100,
1.275 + /** Sunken border around a control with focus. */
1.276 + EFocusedSunkenControl=EControlFamily|ESunken|0x100
1.277 + };
1.278 +
1.279 +public:
1.280 + IMPORT_C TGulBorder();
1.281 + IMPORT_C TGulBorder(TBorderType aType);
1.282 + IMPORT_C TGulBorder(TBorderType aType,TGulAdjacent aAdjacent);
1.283 + IMPORT_C TGulBorder(TInt aType);
1.284 + IMPORT_C TGulBorder(TInt aType,TGulAdjacent aAdjacent);
1.285 + IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect,const TColors& aBorderColors) const;
1.286 + IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect) const;
1.287 + IMPORT_C TRect InnerRect(const TRect& aOuterRect) const;
1.288 + IMPORT_C TRect OuterRect(const TRect& aInnerRect) const;
1.289 + IMPORT_C void SetType(TInt aType);
1.290 + IMPORT_C void SetAdjacent(TInt aAdjacent);
1.291 + IMPORT_C TSize SizeDelta() const;
1.292 + IMPORT_C TMargins Margins() const;
1.293 + IMPORT_C TBool HasBorder() const;
1.294 + IMPORT_C TInt Adjacent() const;
1.295 + IMPORT_C TInt Type() const;
1.296 +public: // Internal to Symbian
1.297 + IMPORT_C TInt Thickness() const;
1.298 + IMPORT_C TInt Rounding() const;
1.299 +private:
1.300 + TBool IsSunken() const;
1.301 + TInt Depth() const;
1.302 + void DrawOutline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
1.303 + void DrawRectOutline(CGraphicsContext& aGc,const TRect& aRect) const;
1.304 + void DrawInline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
1.305 + TMargins OutlineMargins() const;
1.306 + TMargins BorderMargins() const;
1.307 + TMargins InlineMargins() const;
1.308 + TRect OutlineInnerRect(const TRect& aOuterRect) const;
1.309 + TRect BorderInnerRect(const TRect& aOuterRect) const;
1.310 + TInt BorderRounding() const;
1.311 + TInt InlineRounding() const;
1.312 + void DrawOneStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aMidlight,TRgb aMid) const;
1.313 + void DrawTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
1.314 + void DrawInvertedTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
1.315 + void DrawThreeStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aBack,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
1.316 + void DrawTopLeft(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
1.317 + void DrawRoundedTopLeft(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
1.318 + void DrawBottomRight(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
1.319 + void DrawRoundedBottomRight(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
1.320 + void DrawRoundedCorner(CGraphicsContext& aGc,const TPoint& aStart,const TInt aRoundedLength, const TBool aUp, const TBool aRight) const;
1.321 + TInt RoundingMargin(const TInt aRoundedLength) const;
1.322 + inline TInt InternalType() const;
1.323 + void TranslateLegacyTypes();
1.324 +private:
1.325 + TInt iType;
1.326 + };
1.327 +
1.328 +/**
1.329 +The MGulLogicalBorder class specifices an interface for logical borders.
1.330 +
1.331 +@internalTechnology*/
1.332 +class MGulLogicalBorder
1.333 + {
1.334 +public:
1.335 + virtual void Draw(const TGulBorder& aBorder,CGraphicsContext& aGc, const TRect& aRect, const TGulBorder::TColors& aBorderColors) const=0;
1.336 + virtual TMargins Margins(const TGulBorder& aBorder) const=0;
1.337 +private:
1.338 + IMPORT_C virtual void MGulLogicalBorderReserved();
1.339 + };
1.340 +
1.341 +/**
1.342 +The GulTls class sets and gets the thread local storage for EGul.
1.343 +
1.344 +@internalTechnology*/
1.345 +class GulTls
1.346 + {
1.347 +public:
1.348 + IMPORT_C static void SetLogicalBorder(MGulLogicalBorder* aLogicalBorder);
1.349 + IMPORT_C static const MGulLogicalBorder* LogicalBorder();
1.350 + };
1.351 +
1.352 +#endif