1 gulbordr.h |
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". |
|
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 |
|
32 class TGulBorder |
|
33 /** Draws a border around a control. |
|
34 |
|
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. |
|
38 |
|
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. |
|
46 @publishedAll |
|
47 @released*/ |
|
48 { |
|
49 public: |
|
50 class TColors |
|
51 /** Represents the colours used within the border and for the optional single pixel |
|
52 border outlines. |
|
53 |
|
54 These colours are stored using TRgb values. |
|
55 |
|
56 An object of this type can be populated using ColorUtils::GetRgbDerivedBorderColors(). |
|
57 |
|
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. */ |
|
63 { |
|
64 public: |
|
65 IMPORT_C TColors(); |
|
66 public: |
|
67 /** The line colour. |
|
68 |
|
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. */ |
|
71 TRgb iLine; |
|
72 /** The background colour for the border. |
|
73 |
|
74 The other colours used in the border are derived from this. |
|
75 |
|
76 By default, KRgbWhite. */ |
|
77 TRgb iBack; |
|
78 /** The lightest colour. |
|
79 |
|
80 By default, KRgbWhite. */ |
|
81 TRgb iLight; |
|
82 /** The mid light colour. |
|
83 |
|
84 This colour is midway between iBack and iLight. By default, KRgbWhite. */ |
|
85 TRgb iMidlight; |
|
86 /** The mid dark colour. |
|
87 |
|
88 This colour is midway between iBack and iDark. By default, KRgbDarkGray. */ |
|
89 TRgb iMid; |
|
90 /** The darkest colour. |
|
91 |
|
92 By default, KRgbDarkGray. */ |
|
93 TRgb iDark; |
|
94 /** Not used. */ |
|
95 TRgb iInternalBack; |
|
96 }; |
|
97 |
|
98 public: |
|
99 /** Defines the border outline style. |
|
100 |
|
101 Note that not all border types have an outline. */ |
|
102 enum TOutlineStyle |
|
103 { |
|
104 /** The border has a single pixel outline, either solid (by default) or dotted. */ |
|
105 EWithOutline=0x01, |
|
106 /** The border outline is drawn using a dotted pen. */ |
|
107 EDottedOutline=0x02 |
|
108 }; |
|
109 |
|
110 /** Defines whether or not the border has a single pixel interior border. |
|
111 |
|
112 By default it does not. */ |
|
113 enum TInlineStyle |
|
114 { |
|
115 /** The border has an interior border. */ |
|
116 EWithInline=0x04 |
|
117 }; |
|
118 |
|
119 /** Defines the 3D border style. */ |
|
120 enum T3DStyle |
|
121 { |
|
122 /** A flat border. */ |
|
123 EFlat=0x10, |
|
124 /** A 3D effect sunken border. */ |
|
125 ESunken=0x20, |
|
126 /** A 3D effect raised border. */ |
|
127 ERaised=0x40 |
|
128 }; |
|
129 |
|
130 /** Defines the border's construction style. */ |
|
131 enum TConstructionStyle |
|
132 { |
|
133 /** One step border construction. |
|
134 |
|
135 This type of border is drawn using the mid light and mid dark colours on opposite |
|
136 sides of the border. */ |
|
137 EOneStep=0x100, |
|
138 /** Two step border construction. |
|
139 |
|
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. */ |
|
143 ETwoStep=0x200, |
|
144 /** Three step border construction. |
|
145 |
|
146 This type of border is drawn with an outer frame, a repeating one pixel band |
|
147 in mid tones, and an inner frame. */ |
|
148 EThreeStep=0x400, |
|
149 /** Inverted two step border construction. |
|
150 |
|
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 |
|
154 }; |
|
155 |
|
156 /** Defines the number of pixels to add to the border thickness. |
|
157 |
|
158 The border thickness is the central part of the border, coloured in the mid-tone |
|
159 highlights and lowlights. |
|
160 |
|
161 For two step-constructed borders, the additional pixels are only added to |
|
162 either the top left or bottom right hand sides. */ |
|
163 enum TThickness |
|
164 { |
|
165 /** The border has one extra pixel. */ |
|
166 EAddOnePixel=0x1000, |
|
167 /** The border has two extra pixels. */ |
|
168 EAddTwoPixels=0x2000, |
|
169 /** The border has four extra pixels. */ |
|
170 EAddFourPixels=0x4000 |
|
171 }; |
|
172 |
|
173 /** Defines the number of pixels that are removed to produce rounded corners. */ |
|
174 enum TRounding |
|
175 { |
|
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 |
|
182 }; |
|
183 private: |
|
184 enum TNull |
|
185 { |
|
186 ENoBorder=0x00 |
|
187 }; |
|
188 |
|
189 enum TLegacyStyle |
|
190 { |
|
191 EShallow=EAddOnePixel, |
|
192 EDeep=EAddTwoPixels, |
|
193 EThick=EAddFourPixels, |
|
194 EHorizontal=0x100000, |
|
195 EWithOverlap=0x200000, |
|
196 EGray=0x400000, |
|
197 EBlack=0x80000 |
|
198 }; |
|
199 |
|
200 enum TLogicalStyle |
|
201 { |
|
202 ELogical=0x800000 |
|
203 }; |
|
204 public: |
|
205 /** For logical borders, defines whether the border encloses a window, a container |
|
206 control or a control. */ |
|
207 enum TLogicalFamily |
|
208 { |
|
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 |
|
215 }; |
|
216 public: |
|
217 /** Defines the descriptive border types. */ |
|
218 enum TBorderType |
|
219 { |
|
220 /** No border. */ |
|
221 ENone=ENoBorder, |
|
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 |
|
243 right hand sides. */ |
|
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 |
|
247 }; |
|
248 |
|
249 /** Defines the logical border types. */ |
|
250 enum TLogicalType |
|
251 { |
|
252 // Window family |
|
253 /** Raised border around a window. */ |
|
254 EWindow=EWindowFamily|ERaised, |
|
255 // Container family |
|
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, |
|
262 // Control Family |
|
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 |
|
273 }; |
|
274 |
|
275 public: |
|
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; |
|
295 private: |
|
296 TBool IsSunken() const; |
|
297 TInt Depth() 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(); |
|
320 private: |
|
321 TInt iType; |
|
322 }; |
|
323 |
|
324 /** |
|
325 The MGulLogicalBorder class specifices an interface for logical borders. |
|
326 |
|
327 @internalTechnology*/ |
|
328 class MGulLogicalBorder |
|
329 { |
|
330 public: |
|
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; |
|
333 private: |
|
334 IMPORT_C virtual void MGulLogicalBorderReserved(); |
|
335 }; |
|
336 |
|
337 /** |
|
338 The GulTls class sets and gets the thread local storage for EGul. |
|
339 |
|
340 @internalTechnology*/ |
|
341 class GulTls |
|
342 { |
|
343 public: |
|
344 IMPORT_C static void SetLogicalBorder(MGulLogicalBorder* aLogicalBorder); |
|
345 IMPORT_C static const MGulLogicalBorder* LogicalBorder(); |
|
346 }; |
|
347 |
|
348 #endif |