williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #if !defined(__GULBORDR_H__) williamr@2: #define __GULBORDR_H__ williamr@2: williamr@2: #if !defined(__E32DEF_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__GULDEF_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__GDI_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: williamr@2: class TGulBorder williamr@2: /** Draws a border around a control. williamr@2: williamr@2: The rectangular areas enclosed by borders are typically working areas of the williamr@2: graphics context so the class supplies a number of methods which describe williamr@2: how it occupies the area. williamr@2: williamr@2: A distinction between descriptive and logical borders is made. For descriptive williamr@2: borders the appearance of the border is known and fixed. The type of border williamr@2: drawn is determined by flags which describe how it is to be constructed. These williamr@2: flags can be combined to achieve many different effects, and standard combinations williamr@2: have been supplied (see the TBorderType enumeration). For logical borders williamr@2: the use of the border is known and fixed but the appearance is not specified. williamr@2: The appearance and sizing functions must be supplied in custom written code. williamr@2: @publishedAll williamr@2: @released*/ williamr@2: { williamr@2: public: williamr@2: class TColors williamr@2: /** Represents the colours used within the border and for the optional single pixel williamr@2: border outlines. williamr@2: williamr@2: These colours are stored using TRgb values. williamr@2: williamr@2: An object of this type can be populated using ColorUtils::GetRgbDerivedBorderColors(). williamr@2: williamr@2: The colours used inside the border are derived from iBack, the border's background williamr@2: colour, so that border colours can be lighter or darker shades of the colour williamr@2: used in the main body of the control they enclose. Different combinations williamr@2: of light and dark shades are used to draw opposite border sides, to achieve williamr@2: a raised or sunken effect. */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TColors(); williamr@2: public: williamr@2: /** The line colour. williamr@2: williamr@2: This is the colour used to draw the outlines on either side of the border. williamr@2: Not all border types have an outline. By default, KRgbBlack. */ williamr@2: TRgb iLine; williamr@2: /** The background colour for the border. williamr@2: williamr@2: The other colours used in the border are derived from this. williamr@2: williamr@2: By default, KRgbWhite. */ williamr@2: TRgb iBack; williamr@2: /** The lightest colour. williamr@2: williamr@2: By default, KRgbWhite. */ williamr@2: TRgb iLight; williamr@2: /** The mid light colour. williamr@2: williamr@2: This colour is midway between iBack and iLight. By default, KRgbWhite. */ williamr@2: TRgb iMidlight; williamr@2: /** The mid dark colour. williamr@2: williamr@2: This colour is midway between iBack and iDark. By default, KRgbDarkGray. */ williamr@2: TRgb iMid; williamr@2: /** The darkest colour. williamr@2: williamr@2: By default, KRgbDarkGray. */ williamr@2: TRgb iDark; williamr@2: /** Not used. */ williamr@2: TRgb iInternalBack; williamr@2: }; williamr@2: williamr@2: public: williamr@2: /** Defines the border outline style. williamr@2: williamr@2: Note that not all border types have an outline. */ williamr@2: enum TOutlineStyle williamr@2: { williamr@2: /** The border has a single pixel outline, either solid (by default) or dotted. */ williamr@2: EWithOutline=0x01, williamr@2: /** The border outline is drawn using a dotted pen. */ williamr@2: EDottedOutline=0x02 williamr@2: }; williamr@2: williamr@2: /** Defines whether or not the border has a single pixel interior border. williamr@2: williamr@2: By default it does not. */ williamr@2: enum TInlineStyle williamr@2: { williamr@2: /** The border has an interior border. */ williamr@2: EWithInline=0x04 williamr@2: }; williamr@2: williamr@2: /** Defines the 3D border style. */ williamr@2: enum T3DStyle williamr@2: { williamr@2: /** A flat border. */ williamr@2: EFlat=0x10, williamr@2: /** A 3D effect sunken border. */ williamr@2: ESunken=0x20, williamr@2: /** A 3D effect raised border. */ williamr@2: ERaised=0x40 williamr@2: }; williamr@2: williamr@2: /** Defines the border's construction style. */ williamr@2: enum TConstructionStyle williamr@2: { williamr@2: /** One step border construction. williamr@2: williamr@2: This type of border is drawn using the mid light and mid dark colours on opposite williamr@2: sides of the border. */ williamr@2: EOneStep=0x100, williamr@2: /** Two step border construction. williamr@2: williamr@2: This type of border uses light and dark colours for the main border frame williamr@2: (or mid light for the flat border), and an additional half frame using mid williamr@2: light or mid dark colours. */ williamr@2: ETwoStep=0x200, williamr@2: /** Three step border construction. williamr@2: williamr@2: This type of border is drawn with an outer frame, a repeating one pixel band williamr@2: in mid tones, and an inner frame. */ williamr@2: EThreeStep=0x400, williamr@2: /** Inverted two step border construction. williamr@2: williamr@2: This is the same as ETwoStep except that for raised and sunken borders, the williamr@2: additional half frame is drawn on the opposite side to that used in ETwoStep. */ williamr@2: EInvertedTwoStep=0x800 williamr@2: }; williamr@2: williamr@2: /** Defines the number of pixels to add to the border thickness. williamr@2: williamr@2: The border thickness is the central part of the border, coloured in the mid-tone williamr@2: highlights and lowlights. williamr@2: williamr@2: For two step-constructed borders, the additional pixels are only added to williamr@2: either the top left or bottom right hand sides. */ williamr@2: enum TThickness williamr@2: { williamr@2: /** The border has one extra pixel. */ williamr@2: EAddOnePixel=0x1000, williamr@2: /** The border has two extra pixels. */ williamr@2: EAddTwoPixels=0x2000, williamr@2: /** The border has four extra pixels. */ williamr@2: EAddFourPixels=0x4000 williamr@2: }; williamr@2: williamr@2: /** Defines the number of pixels that are removed to produce rounded corners. */ williamr@2: enum TRounding williamr@2: { williamr@2: /** Border rounded by removing one extra pixel. */ williamr@2: EAddOneRoundingPixel=0x10000, williamr@2: /** Border rounded by removing two extra pixels. */ williamr@2: EAddTwoRoundingPixels=0x20000, williamr@2: /** Border rounded by by removing four extra pixels. */ williamr@2: EAddFourRoundingPixels=0x40000 williamr@2: }; williamr@2: private: williamr@2: enum TNull williamr@2: { williamr@2: ENoBorder=0x00 williamr@2: }; williamr@2: williamr@2: enum TLegacyStyle williamr@2: { williamr@2: EShallow=EAddOnePixel, williamr@2: EDeep=EAddTwoPixels, williamr@2: EThick=EAddFourPixels, williamr@2: EHorizontal=0x100000, williamr@2: EWithOverlap=0x200000, williamr@2: EGray=0x400000, williamr@2: EBlack=0x80000 williamr@2: }; williamr@2: williamr@2: enum TLogicalStyle williamr@2: { williamr@2: ELogical=0x800000 williamr@2: }; williamr@2: public: williamr@2: /** For logical borders, defines whether the border encloses a window, a container williamr@2: control or a control. */ williamr@2: enum TLogicalFamily williamr@2: { williamr@2: /** Logical border around a window. */ williamr@2: EWindowFamily=ELogical|0x1, williamr@2: /** Logical border around a container. */ williamr@2: EContainerFamily=ELogical|0x2, williamr@2: /** Logical border around a control. */ williamr@2: EControlFamily=ELogical|0x3 williamr@2: }; williamr@2: public: williamr@2: /** Defines the descriptive border types. */ williamr@2: enum TBorderType williamr@2: { williamr@2: /** No border. */ williamr@2: ENone=ENoBorder, williamr@2: /** Border is a 1 pixel wide grey outline. */ williamr@2: ESingleGray=EWithOutline|EGray, williamr@2: /** Border is a 1 pixel wide black outline. */ williamr@2: ESingleBlack=EWithOutline|EBlack, williamr@2: /** Border is a 1 pixel wide dotted outline. */ williamr@2: ESingleDotted=EWithOutline|EDottedOutline, williamr@2: /** A 3D raised border, with 1 pixel thickness. */ williamr@2: EShallowRaised=ERaised|EOneStep|EAddOnePixel, williamr@2: /** A 3D sunken border, with 1 pixel thickness. */ williamr@2: EShallowSunken=ESunken|EOneStep|EAddOnePixel, williamr@2: /** A 3D raised border, with outline, and 2 pixel thickness. */ williamr@2: EDeepRaised=EWithOutline|ERaised|EOneStep|EAddTwoPixels, williamr@2: /** The same as EDeepRaised. */ williamr@2: EDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddTwoPixels, williamr@2: /** A 3D sunken border, with outline, and 2 pixel thickness. */ williamr@2: EDeepSunken=EWithOutline|ESunken|EOneStep|EAddTwoPixels, williamr@2: /** The same as EDeepSunken. */ williamr@2: EDeepSunkenWithOutline=EWithOutline|ESunken|EOneStep|EAddTwoPixels, williamr@2: /** A 3D raised border, with outline, and 3 pixel thickness. */ williamr@2: EThickDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddOnePixel|EAddTwoPixels, williamr@2: /** A 3D raised border, with 2 pixels thickness and no outline on the left and williamr@2: right hand sides. */ williamr@2: EVerticalBar=ERaised|EOneStep|EAddTwoPixels|EWithOverlap, williamr@2: /** A 3D raised border, with 2 pixels thickness and no outline on the top and bottom. */ williamr@2: EHorizontalBar=ERaised|EOneStep|EAddTwoPixels|EHorizontal|EWithOverlap williamr@2: }; williamr@2: williamr@2: /** Defines the logical border types. */ williamr@2: enum TLogicalType williamr@2: { williamr@2: // Window family williamr@2: /** Raised border around a window. */ williamr@2: EWindow=EWindowFamily|ERaised, williamr@2: // Container family williamr@2: /** Flat border around a container. */ williamr@2: EFlatContainer=EContainerFamily|EFlat, williamr@2: /** Raised border around a container. */ williamr@2: ERaisedContainer=EContainerFamily|ERaised, williamr@2: /** Sunken border around a container. */ williamr@2: ESunkenContainer=EContainerFamily|ESunken, williamr@2: // Control Family williamr@2: /** Flat border around a control. */ williamr@2: EFlatControl=EControlFamily|EFlat, williamr@2: /** Raised border around a control. */ williamr@2: ERaisedControl=EControlFamily|ERaised, williamr@2: /** Sunken border around a control. */ williamr@2: ESunkenControl=EControlFamily|ESunken, williamr@2: /** Raised border around a control with focus. */ williamr@2: EFocusedRaisedControl=EControlFamily|ERaised|0x100, williamr@2: /** Sunken border around a control with focus. */ williamr@2: EFocusedSunkenControl=EControlFamily|ESunken|0x100 williamr@2: }; williamr@2: williamr@2: public: williamr@2: IMPORT_C TGulBorder(); williamr@2: IMPORT_C TGulBorder(TBorderType aType); williamr@2: IMPORT_C TGulBorder(TBorderType aType,TGulAdjacent aAdjacent); williamr@2: IMPORT_C TGulBorder(TInt aType); williamr@2: IMPORT_C TGulBorder(TInt aType,TGulAdjacent aAdjacent); williamr@2: IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect,const TColors& aBorderColors) const; williamr@2: IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect) const; williamr@2: IMPORT_C TRect InnerRect(const TRect& aOuterRect) const; williamr@2: IMPORT_C TRect OuterRect(const TRect& aInnerRect) const; williamr@2: IMPORT_C void SetType(TInt aType); williamr@2: IMPORT_C void SetAdjacent(TInt aAdjacent); williamr@2: IMPORT_C TSize SizeDelta() const; williamr@2: IMPORT_C TMargins Margins() const; williamr@2: IMPORT_C TBool HasBorder() const; williamr@2: IMPORT_C TInt Adjacent() const; williamr@2: IMPORT_C TInt Type() const; williamr@2: public: // Internal to Symbian williamr@2: IMPORT_C TInt Thickness() const; williamr@2: IMPORT_C TInt Rounding() const; williamr@2: private: williamr@2: TBool IsSunken() const; williamr@2: TInt Depth() const; williamr@2: void DrawOutline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const; williamr@2: void DrawRectOutline(CGraphicsContext& aGc,const TRect& aRect) const; williamr@2: void DrawInline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const; williamr@2: TMargins OutlineMargins() const; williamr@2: TMargins BorderMargins() const; williamr@2: TMargins InlineMargins() const; williamr@2: TRect OutlineInnerRect(const TRect& aOuterRect) const; williamr@2: TRect BorderInnerRect(const TRect& aOuterRect) const; williamr@2: TInt BorderRounding() const; williamr@2: TInt InlineRounding() const; williamr@2: void DrawOneStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aMidlight,TRgb aMid) const; williamr@2: void DrawTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const; williamr@2: void DrawInvertedTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const; williamr@2: void DrawThreeStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aBack,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const; williamr@2: void DrawTopLeft(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const; williamr@2: void DrawRoundedTopLeft(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const; williamr@2: void DrawBottomRight(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const; williamr@2: void DrawRoundedBottomRight(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const; williamr@2: void DrawRoundedCorner(CGraphicsContext& aGc,const TPoint& aStart,const TInt aRoundedLength, const TBool aUp, const TBool aRight) const; williamr@2: TInt RoundingMargin(const TInt aRoundedLength) const; williamr@2: inline TInt InternalType() const; williamr@2: void TranslateLegacyTypes(); williamr@2: private: williamr@2: TInt iType; williamr@2: }; williamr@2: williamr@2: /** williamr@2: The MGulLogicalBorder class specifices an interface for logical borders. williamr@2: williamr@2: @internalTechnology*/ williamr@2: class MGulLogicalBorder williamr@2: { williamr@2: public: williamr@2: virtual void Draw(const TGulBorder& aBorder,CGraphicsContext& aGc, const TRect& aRect, const TGulBorder::TColors& aBorderColors) const=0; williamr@2: virtual TMargins Margins(const TGulBorder& aBorder) const=0; williamr@2: private: williamr@2: IMPORT_C virtual void MGulLogicalBorderReserved(); williamr@2: }; williamr@2: williamr@2: /** williamr@2: The GulTls class sets and gets the thread local storage for EGul. williamr@2: williamr@2: @internalTechnology*/ williamr@2: class GulTls williamr@2: { williamr@2: public: williamr@2: IMPORT_C static void SetLogicalBorder(MGulLogicalBorder* aLogicalBorder); williamr@2: IMPORT_C static const MGulLogicalBorder* LogicalBorder(); williamr@2: }; williamr@2: williamr@2: #endif