1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
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
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__GULBORDR_H__)
17 #define __GULBORDR_H__
19 #if !defined(__E32DEF_H__)
23 #if !defined(__GULDEF_H__)
27 #if !defined(__GDI_H__)
33 /** Draws a border around a control.
35 The rectangular areas enclosed by borders are typically working areas of the
36 graphics context so the class supplies a number of methods which describe
37 how it occupies the area.
39 A distinction between descriptive and logical borders is made. For descriptive
40 borders the appearance of the border is known and fixed. The type of border
41 drawn is determined by flags which describe how it is to be constructed. These
42 flags can be combined to achieve many different effects, and standard combinations
43 have been supplied (see the TBorderType enumeration). For logical borders
44 the use of the border is known and fixed but the appearance is not specified.
45 The appearance and sizing functions must be supplied in custom written code.
51 /** Represents the colours used within the border and for the optional single pixel
54 These colours are stored using TRgb values.
56 An object of this type can be populated using ColorUtils::GetRgbDerivedBorderColors().
58 The colours used inside the border are derived from iBack, the border's background
59 colour, so that border colours can be lighter or darker shades of the colour
60 used in the main body of the control they enclose. Different combinations
61 of light and dark shades are used to draw opposite border sides, to achieve
62 a raised or sunken effect. */
69 This is the colour used to draw the outlines on either side of the border.
70 Not all border types have an outline. By default, KRgbBlack. */
72 /** The background colour for the border.
74 The other colours used in the border are derived from this.
76 By default, KRgbWhite. */
78 /** The lightest colour.
80 By default, KRgbWhite. */
82 /** The mid light colour.
84 This colour is midway between iBack and iLight. By default, KRgbWhite. */
86 /** The mid dark colour.
88 This colour is midway between iBack and iDark. By default, KRgbDarkGray. */
90 /** The darkest colour.
92 By default, KRgbDarkGray. */
99 /** Defines the border outline style.
101 Note that not all border types have an outline. */
104 /** The border has a single pixel outline, either solid (by default) or dotted. */
106 /** The border outline is drawn using a dotted pen. */
110 /** Defines whether or not the border has a single pixel interior border.
112 By default it does not. */
115 /** The border has an interior border. */
119 /** Defines the 3D border style. */
122 /** A flat border. */
124 /** A 3D effect sunken border. */
126 /** A 3D effect raised border. */
130 /** Defines the border's construction style. */
131 enum TConstructionStyle
133 /** One step border construction.
135 This type of border is drawn using the mid light and mid dark colours on opposite
136 sides of the border. */
138 /** Two step border construction.
140 This type of border uses light and dark colours for the main border frame
141 (or mid light for the flat border), and an additional half frame using mid
142 light or mid dark colours. */
144 /** Three step border construction.
146 This type of border is drawn with an outer frame, a repeating one pixel band
147 in mid tones, and an inner frame. */
149 /** Inverted two step border construction.
151 This is the same as ETwoStep except that for raised and sunken borders, the
152 additional half frame is drawn on the opposite side to that used in ETwoStep. */
153 EInvertedTwoStep=0x800
156 /** Defines the number of pixels to add to the border thickness.
158 The border thickness is the central part of the border, coloured in the mid-tone
159 highlights and lowlights.
161 For two step-constructed borders, the additional pixels are only added to
162 either the top left or bottom right hand sides. */
165 /** The border has one extra pixel. */
167 /** The border has two extra pixels. */
168 EAddTwoPixels=0x2000,
169 /** The border has four extra pixels. */
170 EAddFourPixels=0x4000
173 /** Defines the number of pixels that are removed to produce rounded corners. */
176 /** Border rounded by removing one extra pixel. */
177 EAddOneRoundingPixel=0x10000,
178 /** Border rounded by removing two extra pixels. */
179 EAddTwoRoundingPixels=0x20000,
180 /** Border rounded by by removing four extra pixels. */
181 EAddFourRoundingPixels=0x40000
191 EShallow=EAddOnePixel,
193 EThick=EAddFourPixels,
194 EHorizontal=0x100000,
195 EWithOverlap=0x200000,
205 /** For logical borders, defines whether the border encloses a window, a container
206 control or a control. */
209 /** Logical border around a window. */
210 EWindowFamily=ELogical|0x1,
211 /** Logical border around a container. */
212 EContainerFamily=ELogical|0x2,
213 /** Logical border around a control. */
214 EControlFamily=ELogical|0x3
217 /** Defines the descriptive border types. */
222 /** Border is a 1 pixel wide grey outline. */
223 ESingleGray=EWithOutline|EGray,
224 /** Border is a 1 pixel wide black outline. */
225 ESingleBlack=EWithOutline|EBlack,
226 /** Border is a 1 pixel wide dotted outline. */
227 ESingleDotted=EWithOutline|EDottedOutline,
228 /** A 3D raised border, with 1 pixel thickness. */
229 EShallowRaised=ERaised|EOneStep|EAddOnePixel,
230 /** A 3D sunken border, with 1 pixel thickness. */
231 EShallowSunken=ESunken|EOneStep|EAddOnePixel,
232 /** A 3D raised border, with outline, and 2 pixel thickness. */
233 EDeepRaised=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
234 /** The same as EDeepRaised. */
235 EDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
236 /** A 3D sunken border, with outline, and 2 pixel thickness. */
237 EDeepSunken=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
238 /** The same as EDeepSunken. */
239 EDeepSunkenWithOutline=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
240 /** A 3D raised border, with outline, and 3 pixel thickness. */
241 EThickDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddOnePixel|EAddTwoPixels,
242 /** A 3D raised border, with 2 pixels thickness and no outline on the left and
244 EVerticalBar=ERaised|EOneStep|EAddTwoPixels|EWithOverlap,
245 /** A 3D raised border, with 2 pixels thickness and no outline on the top and bottom. */
246 EHorizontalBar=ERaised|EOneStep|EAddTwoPixels|EHorizontal|EWithOverlap
249 /** Defines the logical border types. */
253 /** Raised border around a window. */
254 EWindow=EWindowFamily|ERaised,
256 /** Flat border around a container. */
257 EFlatContainer=EContainerFamily|EFlat,
258 /** Raised border around a container. */
259 ERaisedContainer=EContainerFamily|ERaised,
260 /** Sunken border around a container. */
261 ESunkenContainer=EContainerFamily|ESunken,
263 /** Flat border around a control. */
264 EFlatControl=EControlFamily|EFlat,
265 /** Raised border around a control. */
266 ERaisedControl=EControlFamily|ERaised,
267 /** Sunken border around a control. */
268 ESunkenControl=EControlFamily|ESunken,
269 /** Raised border around a control with focus. */
270 EFocusedRaisedControl=EControlFamily|ERaised|0x100,
271 /** Sunken border around a control with focus. */
272 EFocusedSunkenControl=EControlFamily|ESunken|0x100
276 IMPORT_C TGulBorder();
277 IMPORT_C TGulBorder(TBorderType aType);
278 IMPORT_C TGulBorder(TBorderType aType,TGulAdjacent aAdjacent);
279 IMPORT_C TGulBorder(TInt aType);
280 IMPORT_C TGulBorder(TInt aType,TGulAdjacent aAdjacent);
281 IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect,const TColors& aBorderColors) const;
282 IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect) const;
283 IMPORT_C TRect InnerRect(const TRect& aOuterRect) const;
284 IMPORT_C TRect OuterRect(const TRect& aInnerRect) const;
285 IMPORT_C void SetType(TInt aType);
286 IMPORT_C void SetAdjacent(TInt aAdjacent);
287 IMPORT_C TSize SizeDelta() const;
288 IMPORT_C TMargins Margins() const;
289 IMPORT_C TBool HasBorder() const;
290 IMPORT_C TInt Adjacent() const;
291 IMPORT_C TInt Type() const;
292 public: // Internal to Symbian
293 IMPORT_C TInt Thickness() const;
294 IMPORT_C TInt Rounding() const;
296 TBool IsSunken() const;
298 void DrawOutline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
299 void DrawRectOutline(CGraphicsContext& aGc,const TRect& aRect) const;
300 void DrawInline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
301 TMargins OutlineMargins() const;
302 TMargins BorderMargins() const;
303 TMargins InlineMargins() const;
304 TRect OutlineInnerRect(const TRect& aOuterRect) const;
305 TRect BorderInnerRect(const TRect& aOuterRect) const;
306 TInt BorderRounding() const;
307 TInt InlineRounding() const;
308 void DrawOneStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aMidlight,TRgb aMid) const;
309 void DrawTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
310 void DrawInvertedTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
311 void DrawThreeStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aBack,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
312 void DrawTopLeft(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
313 void DrawRoundedTopLeft(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
314 void DrawBottomRight(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
315 void DrawRoundedBottomRight(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
316 void DrawRoundedCorner(CGraphicsContext& aGc,const TPoint& aStart,const TInt aRoundedLength, const TBool aUp, const TBool aRight) const;
317 TInt RoundingMargin(const TInt aRoundedLength) const;
318 inline TInt InternalType() const;
319 void TranslateLegacyTypes();
325 The MGulLogicalBorder class specifices an interface for logical borders.
327 @internalTechnology*/
328 class MGulLogicalBorder
331 virtual void Draw(const TGulBorder& aBorder,CGraphicsContext& aGc, const TRect& aRect, const TGulBorder::TColors& aBorderColors) const=0;
332 virtual TMargins Margins(const TGulBorder& aBorder) const=0;
334 IMPORT_C virtual void MGulLogicalBorderReserved();
338 The GulTls class sets and gets the thread local storage for EGul.
340 @internalTechnology*/
344 IMPORT_C static void SetLogicalBorder(MGulLogicalBorder* aLogicalBorder);
345 IMPORT_C static const MGulLogicalBorder* LogicalBorder();