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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.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__)
32 /** Draws a border around a control.
34 The rectangular areas enclosed by borders are typically working areas of the
35 graphics context so the class supplies a number of methods which describe
36 how it occupies the area.
38 A distinction between descriptive and logical borders is made. For descriptive
39 borders the appearance of the border is known and fixed. The type of border
40 drawn is determined by flags which describe how it is to be constructed. These
41 flags can be combined to achieve many different effects, and standard combinations
42 have been supplied (see the TBorderType enumeration). For logical borders
43 the use of the border is known and fixed but the appearance is not specified.
44 The appearance and sizing functions must be supplied in custom written code.
50 /** Represents the colours used within the border and for the optional single pixel
53 These colours are stored using TRgb values.
55 An object of this type can be populated using ColorUtils::GetRgbDerivedBorderColors().
57 The colours used inside the border are derived from iBack, the border's background
58 colour, so that border colours can be lighter or darker shades of the colour
59 used in the main body of the control they enclose. Different combinations
60 of light and dark shades are used to draw opposite border sides, to achieve
61 a raised or sunken effect. */
68 This is the colour used to draw the outlines on either side of the border.
69 Not all border types have an outline. By default, KRgbBlack. */
71 /** The background colour for the border.
73 The other colours used in the border are derived from this.
75 By default, KRgbWhite. */
77 /** The lightest colour.
79 By default, KRgbWhite. */
81 /** The mid light colour.
83 This colour is midway between iBack and iLight. By default, KRgbWhite. */
85 /** The mid dark colour.
87 This colour is midway between iBack and iDark. By default, KRgbDarkGray. */
89 /** The darkest colour.
91 By default, KRgbDarkGray. */
98 /** Defines the border outline style.
100 Note that not all border types have an outline. */
103 /** The border has a single pixel outline, either solid (by default) or dotted. */
105 /** The border outline is drawn using a dotted pen. */
109 /** Defines whether or not the border has a single pixel interior border.
111 By default it does not. */
114 /** The border has an interior border. */
118 /** Defines the 3D border style. */
121 /** A flat border. */
123 /** A 3D effect sunken border. */
125 /** A 3D effect raised border. */
129 /** Defines the border's construction style. */
130 enum TConstructionStyle
132 /** One step border construction.
134 This type of border is drawn using the mid light and mid dark colours on opposite
135 sides of the border. */
137 /** Two step border construction.
139 This type of border uses light and dark colours for the main border frame
140 (or mid light for the flat border), and an additional half frame using mid
141 light or mid dark colours. */
143 /** Three step border construction.
145 This type of border is drawn with an outer frame, a repeating one pixel band
146 in mid tones, and an inner frame. */
148 /** Inverted two step border construction.
150 This is the same as ETwoStep except that for raised and sunken borders, the
151 additional half frame is drawn on the opposite side to that used in ETwoStep. */
152 EInvertedTwoStep=0x800
155 /** Defines the number of pixels to add to the border thickness.
157 The border thickness is the central part of the border, coloured in the mid-tone
158 highlights and lowlights.
160 For two step-constructed borders, the additional pixels are only added to
161 either the top left or bottom right hand sides. */
164 /** The border has one extra pixel. */
166 /** The border has two extra pixels. */
167 EAddTwoPixels=0x2000,
168 /** The border has four extra pixels. */
169 EAddFourPixels=0x4000
172 /** Defines the number of pixels that are removed to produce rounded corners. */
175 /** Border rounded by removing one extra pixel. */
176 EAddOneRoundingPixel=0x10000,
177 /** Border rounded by removing two extra pixels. */
178 EAddTwoRoundingPixels=0x20000,
179 /** Border rounded by by removing four extra pixels. */
180 EAddFourRoundingPixels=0x40000
190 EShallow=EAddOnePixel,
192 EThick=EAddFourPixels,
193 EHorizontal=0x100000,
194 EWithOverlap=0x200000,
204 /** For logical borders, defines whether the border encloses a window, a container
205 control or a control. */
208 /** Logical border around a window. */
209 EWindowFamily=ELogical|0x1,
210 /** Logical border around a container. */
211 EContainerFamily=ELogical|0x2,
212 /** Logical border around a control. */
213 EControlFamily=ELogical|0x3
216 /** Defines the descriptive border types. */
221 /** Border is a 1 pixel wide grey outline. */
222 ESingleGray=EWithOutline|EGray,
223 /** Border is a 1 pixel wide black outline. */
224 ESingleBlack=EWithOutline|EBlack,
225 /** Border is a 1 pixel wide dotted outline. */
226 ESingleDotted=EWithOutline|EDottedOutline,
227 /** A 3D raised border, with 1 pixel thickness. */
228 EShallowRaised=ERaised|EOneStep|EAddOnePixel,
229 /** A 3D sunken border, with 1 pixel thickness. */
230 EShallowSunken=ESunken|EOneStep|EAddOnePixel,
231 /** A 3D raised border, with outline, and 2 pixel thickness. */
232 EDeepRaised=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
233 /** The same as EDeepRaised. */
234 EDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
235 /** A 3D sunken border, with outline, and 2 pixel thickness. */
236 EDeepSunken=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
237 /** The same as EDeepSunken. */
238 EDeepSunkenWithOutline=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
239 /** A 3D raised border, with outline, and 3 pixel thickness. */
240 EThickDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddOnePixel|EAddTwoPixels,
241 /** A 3D raised border, with 2 pixels thickness and no outline on the left and
243 EVerticalBar=ERaised|EOneStep|EAddTwoPixels|EWithOverlap,
244 /** A 3D raised border, with 2 pixels thickness and no outline on the top and bottom. */
245 EHorizontalBar=ERaised|EOneStep|EAddTwoPixels|EHorizontal|EWithOverlap
248 /** Defines the logical border types. */
252 /** Raised border around a window. */
253 EWindow=EWindowFamily|ERaised,
255 /** Flat border around a container. */
256 EFlatContainer=EContainerFamily|EFlat,
257 /** Raised border around a container. */
258 ERaisedContainer=EContainerFamily|ERaised,
259 /** Sunken border around a container. */
260 ESunkenContainer=EContainerFamily|ESunken,
262 /** Flat border around a control. */
263 EFlatControl=EControlFamily|EFlat,
264 /** Raised border around a control. */
265 ERaisedControl=EControlFamily|ERaised,
266 /** Sunken border around a control. */
267 ESunkenControl=EControlFamily|ESunken,
268 /** Raised border around a control with focus. */
269 EFocusedRaisedControl=EControlFamily|ERaised|0x100,
270 /** Sunken border around a control with focus. */
271 EFocusedSunkenControl=EControlFamily|ESunken|0x100
275 IMPORT_C TGulBorder();
276 IMPORT_C TGulBorder(TBorderType aType);
277 IMPORT_C TGulBorder(TBorderType aType,TGulAdjacent aAdjacent);
278 IMPORT_C TGulBorder(TInt aType);
279 IMPORT_C TGulBorder(TInt aType,TGulAdjacent aAdjacent);
280 IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect,const TColors& aBorderColors) const;
281 IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect) const;
282 IMPORT_C TRect InnerRect(const TRect& aOuterRect) const;
283 IMPORT_C TRect OuterRect(const TRect& aInnerRect) const;
284 IMPORT_C void SetType(TInt aType);
285 IMPORT_C void SetAdjacent(TInt aAdjacent);
286 IMPORT_C TSize SizeDelta() const;
287 IMPORT_C TMargins Margins() const;
288 IMPORT_C TBool HasBorder() const;
289 IMPORT_C TInt Adjacent() const;
290 IMPORT_C TInt Type() const;
291 public: // Internal to Symbian
292 IMPORT_C TInt Thickness() const;
293 IMPORT_C TInt Rounding() const;
295 TBool IsSunken() const;
297 void DrawOutline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
298 void DrawRectOutline(CGraphicsContext& aGc,const TRect& aRect) const;
299 void DrawInline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
300 TMargins OutlineMargins() const;
301 TMargins BorderMargins() const;
302 TMargins InlineMargins() const;
303 TRect OutlineInnerRect(const TRect& aOuterRect) const;
304 TRect BorderInnerRect(const TRect& aOuterRect) const;
305 TInt BorderRounding() const;
306 TInt InlineRounding() const;
307 void DrawOneStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aMidlight,TRgb aMid) const;
308 void DrawTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
309 void DrawInvertedTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
310 void DrawThreeStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aBack,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
311 void DrawTopLeft(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
312 void DrawRoundedTopLeft(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
313 void DrawBottomRight(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
314 void DrawRoundedBottomRight(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
315 void DrawRoundedCorner(CGraphicsContext& aGc,const TPoint& aStart,const TInt aRoundedLength, const TBool aUp, const TBool aRight) const;
316 TInt RoundingMargin(const TInt aRoundedLength) const;
317 inline TInt InternalType() const;
318 void TranslateLegacyTypes();
323 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
324 #include <graphics/uigraphicsutils/gullogicalborder.h>