|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #if !defined(__GULBORDR_H__) |
|
17 #define __GULBORDR_H__ |
|
18 |
|
19 #if !defined(__E32DEF_H__) |
|
20 #include <e32def.h> |
|
21 #endif |
|
22 |
|
23 #if !defined(__GULDEF_H__) |
|
24 #include <guldef.h> |
|
25 #endif |
|
26 |
|
27 #if !defined(__GDI_H__) |
|
28 #include <gdi.h> |
|
29 #endif |
|
30 |
|
31 class TGulBorder |
|
32 /** Draws a border around a control. |
|
33 |
|
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. |
|
37 |
|
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. |
|
45 @publishedAll |
|
46 @released*/ |
|
47 { |
|
48 public: |
|
49 class TColors |
|
50 /** Represents the colours used within the border and for the optional single pixel |
|
51 border outlines. |
|
52 |
|
53 These colours are stored using TRgb values. |
|
54 |
|
55 An object of this type can be populated using ColorUtils::GetRgbDerivedBorderColors(). |
|
56 |
|
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. */ |
|
62 { |
|
63 public: |
|
64 IMPORT_C TColors(); |
|
65 public: |
|
66 /** The line colour. |
|
67 |
|
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. */ |
|
70 TRgb iLine; |
|
71 /** The background colour for the border. |
|
72 |
|
73 The other colours used in the border are derived from this. |
|
74 |
|
75 By default, KRgbWhite. */ |
|
76 TRgb iBack; |
|
77 /** The lightest colour. |
|
78 |
|
79 By default, KRgbWhite. */ |
|
80 TRgb iLight; |
|
81 /** The mid light colour. |
|
82 |
|
83 This colour is midway between iBack and iLight. By default, KRgbWhite. */ |
|
84 TRgb iMidlight; |
|
85 /** The mid dark colour. |
|
86 |
|
87 This colour is midway between iBack and iDark. By default, KRgbDarkGray. */ |
|
88 TRgb iMid; |
|
89 /** The darkest colour. |
|
90 |
|
91 By default, KRgbDarkGray. */ |
|
92 TRgb iDark; |
|
93 /** Not used. */ |
|
94 TRgb iInternalBack; |
|
95 }; |
|
96 |
|
97 public: |
|
98 /** Defines the border outline style. |
|
99 |
|
100 Note that not all border types have an outline. */ |
|
101 enum TOutlineStyle |
|
102 { |
|
103 /** The border has a single pixel outline, either solid (by default) or dotted. */ |
|
104 EWithOutline=0x01, |
|
105 /** The border outline is drawn using a dotted pen. */ |
|
106 EDottedOutline=0x02 |
|
107 }; |
|
108 |
|
109 /** Defines whether or not the border has a single pixel interior border. |
|
110 |
|
111 By default it does not. */ |
|
112 enum TInlineStyle |
|
113 { |
|
114 /** The border has an interior border. */ |
|
115 EWithInline=0x04 |
|
116 }; |
|
117 |
|
118 /** Defines the 3D border style. */ |
|
119 enum T3DStyle |
|
120 { |
|
121 /** A flat border. */ |
|
122 EFlat=0x10, |
|
123 /** A 3D effect sunken border. */ |
|
124 ESunken=0x20, |
|
125 /** A 3D effect raised border. */ |
|
126 ERaised=0x40 |
|
127 }; |
|
128 |
|
129 /** Defines the border's construction style. */ |
|
130 enum TConstructionStyle |
|
131 { |
|
132 /** One step border construction. |
|
133 |
|
134 This type of border is drawn using the mid light and mid dark colours on opposite |
|
135 sides of the border. */ |
|
136 EOneStep=0x100, |
|
137 /** Two step border construction. |
|
138 |
|
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. */ |
|
142 ETwoStep=0x200, |
|
143 /** Three step border construction. |
|
144 |
|
145 This type of border is drawn with an outer frame, a repeating one pixel band |
|
146 in mid tones, and an inner frame. */ |
|
147 EThreeStep=0x400, |
|
148 /** Inverted two step border construction. |
|
149 |
|
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 |
|
153 }; |
|
154 |
|
155 /** Defines the number of pixels to add to the border thickness. |
|
156 |
|
157 The border thickness is the central part of the border, coloured in the mid-tone |
|
158 highlights and lowlights. |
|
159 |
|
160 For two step-constructed borders, the additional pixels are only added to |
|
161 either the top left or bottom right hand sides. */ |
|
162 enum TThickness |
|
163 { |
|
164 /** The border has one extra pixel. */ |
|
165 EAddOnePixel=0x1000, |
|
166 /** The border has two extra pixels. */ |
|
167 EAddTwoPixels=0x2000, |
|
168 /** The border has four extra pixels. */ |
|
169 EAddFourPixels=0x4000 |
|
170 }; |
|
171 |
|
172 /** Defines the number of pixels that are removed to produce rounded corners. */ |
|
173 enum TRounding |
|
174 { |
|
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 |
|
181 }; |
|
182 private: |
|
183 enum TNull |
|
184 { |
|
185 ENoBorder=0x00 |
|
186 }; |
|
187 |
|
188 enum TLegacyStyle |
|
189 { |
|
190 EShallow=EAddOnePixel, |
|
191 EDeep=EAddTwoPixels, |
|
192 EThick=EAddFourPixels, |
|
193 EHorizontal=0x100000, |
|
194 EWithOverlap=0x200000, |
|
195 EGray=0x400000, |
|
196 EBlack=0x80000 |
|
197 }; |
|
198 |
|
199 enum TLogicalStyle |
|
200 { |
|
201 ELogical=0x800000 |
|
202 }; |
|
203 public: |
|
204 /** For logical borders, defines whether the border encloses a window, a container |
|
205 control or a control. */ |
|
206 enum TLogicalFamily |
|
207 { |
|
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 |
|
214 }; |
|
215 public: |
|
216 /** Defines the descriptive border types. */ |
|
217 enum TBorderType |
|
218 { |
|
219 /** No border. */ |
|
220 ENone=ENoBorder, |
|
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 |
|
242 right hand sides. */ |
|
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 |
|
246 }; |
|
247 |
|
248 /** Defines the logical border types. */ |
|
249 enum TLogicalType |
|
250 { |
|
251 // Window family |
|
252 /** Raised border around a window. */ |
|
253 EWindow=EWindowFamily|ERaised, |
|
254 // Container family |
|
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, |
|
261 // Control Family |
|
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 |
|
272 }; |
|
273 |
|
274 public: |
|
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; |
|
294 private: |
|
295 TBool IsSunken() const; |
|
296 TInt Depth() 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(); |
|
319 private: |
|
320 TInt iType; |
|
321 }; |
|
322 |
|
323 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
324 #include <graphics/uigraphicsutils/gullogicalborder.h> |
|
325 #endif |
|
326 |
|
327 #endif |