williamr@2
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
#if !defined(__GULBORDR_H__)
|
williamr@2
|
17 |
#define __GULBORDR_H__
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#if !defined(__E32DEF_H__)
|
williamr@2
|
20 |
#include <e32def.h>
|
williamr@2
|
21 |
#endif
|
williamr@2
|
22 |
|
williamr@2
|
23 |
#if !defined(__GULDEF_H__)
|
williamr@2
|
24 |
#include <guldef.h>
|
williamr@2
|
25 |
#endif
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#if !defined(__GDI_H__)
|
williamr@2
|
28 |
#include <gdi.h>
|
williamr@2
|
29 |
#endif
|
williamr@2
|
30 |
|
williamr@2
|
31 |
class TGulBorder
|
williamr@2
|
32 |
/** Draws a border around a control.
|
williamr@2
|
33 |
|
williamr@2
|
34 |
The rectangular areas enclosed by borders are typically working areas of the
|
williamr@2
|
35 |
graphics context so the class supplies a number of methods which describe
|
williamr@2
|
36 |
how it occupies the area.
|
williamr@2
|
37 |
|
williamr@2
|
38 |
A distinction between descriptive and logical borders is made. For descriptive
|
williamr@2
|
39 |
borders the appearance of the border is known and fixed. The type of border
|
williamr@2
|
40 |
drawn is determined by flags which describe how it is to be constructed. These
|
williamr@2
|
41 |
flags can be combined to achieve many different effects, and standard combinations
|
williamr@2
|
42 |
have been supplied (see the TBorderType enumeration). For logical borders
|
williamr@2
|
43 |
the use of the border is known and fixed but the appearance is not specified.
|
williamr@2
|
44 |
The appearance and sizing functions must be supplied in custom written code.
|
williamr@2
|
45 |
@publishedAll
|
williamr@2
|
46 |
@released*/
|
williamr@2
|
47 |
{
|
williamr@2
|
48 |
public:
|
williamr@2
|
49 |
class TColors
|
williamr@2
|
50 |
/** Represents the colours used within the border and for the optional single pixel
|
williamr@2
|
51 |
border outlines.
|
williamr@2
|
52 |
|
williamr@2
|
53 |
These colours are stored using TRgb values.
|
williamr@2
|
54 |
|
williamr@2
|
55 |
An object of this type can be populated using ColorUtils::GetRgbDerivedBorderColors().
|
williamr@2
|
56 |
|
williamr@2
|
57 |
The colours used inside the border are derived from iBack, the border's background
|
williamr@2
|
58 |
colour, so that border colours can be lighter or darker shades of the colour
|
williamr@2
|
59 |
used in the main body of the control they enclose. Different combinations
|
williamr@2
|
60 |
of light and dark shades are used to draw opposite border sides, to achieve
|
williamr@2
|
61 |
a raised or sunken effect. */
|
williamr@2
|
62 |
{
|
williamr@2
|
63 |
public:
|
williamr@2
|
64 |
IMPORT_C TColors();
|
williamr@2
|
65 |
public:
|
williamr@2
|
66 |
/** The line colour.
|
williamr@2
|
67 |
|
williamr@2
|
68 |
This is the colour used to draw the outlines on either side of the border.
|
williamr@2
|
69 |
Not all border types have an outline. By default, KRgbBlack. */
|
williamr@2
|
70 |
TRgb iLine;
|
williamr@2
|
71 |
/** The background colour for the border.
|
williamr@2
|
72 |
|
williamr@2
|
73 |
The other colours used in the border are derived from this.
|
williamr@2
|
74 |
|
williamr@2
|
75 |
By default, KRgbWhite. */
|
williamr@2
|
76 |
TRgb iBack;
|
williamr@2
|
77 |
/** The lightest colour.
|
williamr@2
|
78 |
|
williamr@2
|
79 |
By default, KRgbWhite. */
|
williamr@2
|
80 |
TRgb iLight;
|
williamr@2
|
81 |
/** The mid light colour.
|
williamr@2
|
82 |
|
williamr@2
|
83 |
This colour is midway between iBack and iLight. By default, KRgbWhite. */
|
williamr@2
|
84 |
TRgb iMidlight;
|
williamr@2
|
85 |
/** The mid dark colour.
|
williamr@2
|
86 |
|
williamr@2
|
87 |
This colour is midway between iBack and iDark. By default, KRgbDarkGray. */
|
williamr@2
|
88 |
TRgb iMid;
|
williamr@2
|
89 |
/** The darkest colour.
|
williamr@2
|
90 |
|
williamr@2
|
91 |
By default, KRgbDarkGray. */
|
williamr@2
|
92 |
TRgb iDark;
|
williamr@2
|
93 |
/** Not used. */
|
williamr@2
|
94 |
TRgb iInternalBack;
|
williamr@2
|
95 |
};
|
williamr@2
|
96 |
|
williamr@2
|
97 |
public:
|
williamr@2
|
98 |
/** Defines the border outline style.
|
williamr@2
|
99 |
|
williamr@2
|
100 |
Note that not all border types have an outline. */
|
williamr@2
|
101 |
enum TOutlineStyle
|
williamr@2
|
102 |
{
|
williamr@2
|
103 |
/** The border has a single pixel outline, either solid (by default) or dotted. */
|
williamr@2
|
104 |
EWithOutline=0x01,
|
williamr@2
|
105 |
/** The border outline is drawn using a dotted pen. */
|
williamr@2
|
106 |
EDottedOutline=0x02
|
williamr@2
|
107 |
};
|
williamr@2
|
108 |
|
williamr@2
|
109 |
/** Defines whether or not the border has a single pixel interior border.
|
williamr@2
|
110 |
|
williamr@2
|
111 |
By default it does not. */
|
williamr@2
|
112 |
enum TInlineStyle
|
williamr@2
|
113 |
{
|
williamr@2
|
114 |
/** The border has an interior border. */
|
williamr@2
|
115 |
EWithInline=0x04
|
williamr@2
|
116 |
};
|
williamr@2
|
117 |
|
williamr@2
|
118 |
/** Defines the 3D border style. */
|
williamr@2
|
119 |
enum T3DStyle
|
williamr@2
|
120 |
{
|
williamr@2
|
121 |
/** A flat border. */
|
williamr@2
|
122 |
EFlat=0x10,
|
williamr@2
|
123 |
/** A 3D effect sunken border. */
|
williamr@2
|
124 |
ESunken=0x20,
|
williamr@2
|
125 |
/** A 3D effect raised border. */
|
williamr@2
|
126 |
ERaised=0x40
|
williamr@2
|
127 |
};
|
williamr@2
|
128 |
|
williamr@2
|
129 |
/** Defines the border's construction style. */
|
williamr@2
|
130 |
enum TConstructionStyle
|
williamr@2
|
131 |
{
|
williamr@2
|
132 |
/** One step border construction.
|
williamr@2
|
133 |
|
williamr@2
|
134 |
This type of border is drawn using the mid light and mid dark colours on opposite
|
williamr@2
|
135 |
sides of the border. */
|
williamr@2
|
136 |
EOneStep=0x100,
|
williamr@2
|
137 |
/** Two step border construction.
|
williamr@2
|
138 |
|
williamr@2
|
139 |
This type of border uses light and dark colours for the main border frame
|
williamr@2
|
140 |
(or mid light for the flat border), and an additional half frame using mid
|
williamr@2
|
141 |
light or mid dark colours. */
|
williamr@2
|
142 |
ETwoStep=0x200,
|
williamr@2
|
143 |
/** Three step border construction.
|
williamr@2
|
144 |
|
williamr@2
|
145 |
This type of border is drawn with an outer frame, a repeating one pixel band
|
williamr@2
|
146 |
in mid tones, and an inner frame. */
|
williamr@2
|
147 |
EThreeStep=0x400,
|
williamr@2
|
148 |
/** Inverted two step border construction.
|
williamr@2
|
149 |
|
williamr@2
|
150 |
This is the same as ETwoStep except that for raised and sunken borders, the
|
williamr@2
|
151 |
additional half frame is drawn on the opposite side to that used in ETwoStep. */
|
williamr@2
|
152 |
EInvertedTwoStep=0x800
|
williamr@2
|
153 |
};
|
williamr@2
|
154 |
|
williamr@2
|
155 |
/** Defines the number of pixels to add to the border thickness.
|
williamr@2
|
156 |
|
williamr@2
|
157 |
The border thickness is the central part of the border, coloured in the mid-tone
|
williamr@2
|
158 |
highlights and lowlights.
|
williamr@2
|
159 |
|
williamr@2
|
160 |
For two step-constructed borders, the additional pixels are only added to
|
williamr@2
|
161 |
either the top left or bottom right hand sides. */
|
williamr@2
|
162 |
enum TThickness
|
williamr@2
|
163 |
{
|
williamr@2
|
164 |
/** The border has one extra pixel. */
|
williamr@2
|
165 |
EAddOnePixel=0x1000,
|
williamr@2
|
166 |
/** The border has two extra pixels. */
|
williamr@2
|
167 |
EAddTwoPixels=0x2000,
|
williamr@2
|
168 |
/** The border has four extra pixels. */
|
williamr@2
|
169 |
EAddFourPixels=0x4000
|
williamr@2
|
170 |
};
|
williamr@2
|
171 |
|
williamr@2
|
172 |
/** Defines the number of pixels that are removed to produce rounded corners. */
|
williamr@2
|
173 |
enum TRounding
|
williamr@2
|
174 |
{
|
williamr@2
|
175 |
/** Border rounded by removing one extra pixel. */
|
williamr@2
|
176 |
EAddOneRoundingPixel=0x10000,
|
williamr@2
|
177 |
/** Border rounded by removing two extra pixels. */
|
williamr@2
|
178 |
EAddTwoRoundingPixels=0x20000,
|
williamr@2
|
179 |
/** Border rounded by by removing four extra pixels. */
|
williamr@2
|
180 |
EAddFourRoundingPixels=0x40000
|
williamr@2
|
181 |
};
|
williamr@2
|
182 |
private:
|
williamr@2
|
183 |
enum TNull
|
williamr@2
|
184 |
{
|
williamr@2
|
185 |
ENoBorder=0x00
|
williamr@2
|
186 |
};
|
williamr@2
|
187 |
|
williamr@2
|
188 |
enum TLegacyStyle
|
williamr@2
|
189 |
{
|
williamr@2
|
190 |
EShallow=EAddOnePixel,
|
williamr@2
|
191 |
EDeep=EAddTwoPixels,
|
williamr@2
|
192 |
EThick=EAddFourPixels,
|
williamr@2
|
193 |
EHorizontal=0x100000,
|
williamr@2
|
194 |
EWithOverlap=0x200000,
|
williamr@2
|
195 |
EGray=0x400000,
|
williamr@2
|
196 |
EBlack=0x80000
|
williamr@2
|
197 |
};
|
williamr@2
|
198 |
|
williamr@2
|
199 |
enum TLogicalStyle
|
williamr@2
|
200 |
{
|
williamr@2
|
201 |
ELogical=0x800000
|
williamr@2
|
202 |
};
|
williamr@2
|
203 |
public:
|
williamr@2
|
204 |
/** For logical borders, defines whether the border encloses a window, a container
|
williamr@2
|
205 |
control or a control. */
|
williamr@2
|
206 |
enum TLogicalFamily
|
williamr@2
|
207 |
{
|
williamr@2
|
208 |
/** Logical border around a window. */
|
williamr@2
|
209 |
EWindowFamily=ELogical|0x1,
|
williamr@2
|
210 |
/** Logical border around a container. */
|
williamr@2
|
211 |
EContainerFamily=ELogical|0x2,
|
williamr@2
|
212 |
/** Logical border around a control. */
|
williamr@2
|
213 |
EControlFamily=ELogical|0x3
|
williamr@2
|
214 |
};
|
williamr@2
|
215 |
public:
|
williamr@2
|
216 |
/** Defines the descriptive border types. */
|
williamr@2
|
217 |
enum TBorderType
|
williamr@2
|
218 |
{
|
williamr@2
|
219 |
/** No border. */
|
williamr@2
|
220 |
ENone=ENoBorder,
|
williamr@2
|
221 |
/** Border is a 1 pixel wide grey outline. */
|
williamr@2
|
222 |
ESingleGray=EWithOutline|EGray,
|
williamr@2
|
223 |
/** Border is a 1 pixel wide black outline. */
|
williamr@2
|
224 |
ESingleBlack=EWithOutline|EBlack,
|
williamr@2
|
225 |
/** Border is a 1 pixel wide dotted outline. */
|
williamr@2
|
226 |
ESingleDotted=EWithOutline|EDottedOutline,
|
williamr@2
|
227 |
/** A 3D raised border, with 1 pixel thickness. */
|
williamr@2
|
228 |
EShallowRaised=ERaised|EOneStep|EAddOnePixel,
|
williamr@2
|
229 |
/** A 3D sunken border, with 1 pixel thickness. */
|
williamr@2
|
230 |
EShallowSunken=ESunken|EOneStep|EAddOnePixel,
|
williamr@2
|
231 |
/** A 3D raised border, with outline, and 2 pixel thickness. */
|
williamr@2
|
232 |
EDeepRaised=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
|
williamr@2
|
233 |
/** The same as EDeepRaised. */
|
williamr@2
|
234 |
EDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddTwoPixels,
|
williamr@2
|
235 |
/** A 3D sunken border, with outline, and 2 pixel thickness. */
|
williamr@2
|
236 |
EDeepSunken=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
|
williamr@2
|
237 |
/** The same as EDeepSunken. */
|
williamr@2
|
238 |
EDeepSunkenWithOutline=EWithOutline|ESunken|EOneStep|EAddTwoPixels,
|
williamr@2
|
239 |
/** A 3D raised border, with outline, and 3 pixel thickness. */
|
williamr@2
|
240 |
EThickDeepRaisedWithOutline=EWithOutline|ERaised|EOneStep|EAddOnePixel|EAddTwoPixels,
|
williamr@2
|
241 |
/** A 3D raised border, with 2 pixels thickness and no outline on the left and
|
williamr@2
|
242 |
right hand sides. */
|
williamr@2
|
243 |
EVerticalBar=ERaised|EOneStep|EAddTwoPixels|EWithOverlap,
|
williamr@2
|
244 |
/** A 3D raised border, with 2 pixels thickness and no outline on the top and bottom. */
|
williamr@2
|
245 |
EHorizontalBar=ERaised|EOneStep|EAddTwoPixels|EHorizontal|EWithOverlap
|
williamr@2
|
246 |
};
|
williamr@2
|
247 |
|
williamr@2
|
248 |
/** Defines the logical border types. */
|
williamr@2
|
249 |
enum TLogicalType
|
williamr@2
|
250 |
{
|
williamr@2
|
251 |
// Window family
|
williamr@2
|
252 |
/** Raised border around a window. */
|
williamr@2
|
253 |
EWindow=EWindowFamily|ERaised,
|
williamr@2
|
254 |
// Container family
|
williamr@2
|
255 |
/** Flat border around a container. */
|
williamr@2
|
256 |
EFlatContainer=EContainerFamily|EFlat,
|
williamr@2
|
257 |
/** Raised border around a container. */
|
williamr@2
|
258 |
ERaisedContainer=EContainerFamily|ERaised,
|
williamr@2
|
259 |
/** Sunken border around a container. */
|
williamr@2
|
260 |
ESunkenContainer=EContainerFamily|ESunken,
|
williamr@2
|
261 |
// Control Family
|
williamr@2
|
262 |
/** Flat border around a control. */
|
williamr@2
|
263 |
EFlatControl=EControlFamily|EFlat,
|
williamr@2
|
264 |
/** Raised border around a control. */
|
williamr@2
|
265 |
ERaisedControl=EControlFamily|ERaised,
|
williamr@2
|
266 |
/** Sunken border around a control. */
|
williamr@2
|
267 |
ESunkenControl=EControlFamily|ESunken,
|
williamr@2
|
268 |
/** Raised border around a control with focus. */
|
williamr@2
|
269 |
EFocusedRaisedControl=EControlFamily|ERaised|0x100,
|
williamr@2
|
270 |
/** Sunken border around a control with focus. */
|
williamr@2
|
271 |
EFocusedSunkenControl=EControlFamily|ESunken|0x100
|
williamr@2
|
272 |
};
|
williamr@2
|
273 |
|
williamr@2
|
274 |
public:
|
williamr@2
|
275 |
IMPORT_C TGulBorder();
|
williamr@2
|
276 |
IMPORT_C TGulBorder(TBorderType aType);
|
williamr@2
|
277 |
IMPORT_C TGulBorder(TBorderType aType,TGulAdjacent aAdjacent);
|
williamr@2
|
278 |
IMPORT_C TGulBorder(TInt aType);
|
williamr@2
|
279 |
IMPORT_C TGulBorder(TInt aType,TGulAdjacent aAdjacent);
|
williamr@2
|
280 |
IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect,const TColors& aBorderColors) const;
|
williamr@2
|
281 |
IMPORT_C void Draw(CGraphicsContext& aGc,const TRect& aRect) const;
|
williamr@2
|
282 |
IMPORT_C TRect InnerRect(const TRect& aOuterRect) const;
|
williamr@2
|
283 |
IMPORT_C TRect OuterRect(const TRect& aInnerRect) const;
|
williamr@2
|
284 |
IMPORT_C void SetType(TInt aType);
|
williamr@2
|
285 |
IMPORT_C void SetAdjacent(TInt aAdjacent);
|
williamr@2
|
286 |
IMPORT_C TSize SizeDelta() const;
|
williamr@2
|
287 |
IMPORT_C TMargins Margins() const;
|
williamr@2
|
288 |
IMPORT_C TBool HasBorder() const;
|
williamr@2
|
289 |
IMPORT_C TInt Adjacent() const;
|
williamr@2
|
290 |
IMPORT_C TInt Type() const;
|
williamr@2
|
291 |
public: // Internal to Symbian
|
williamr@2
|
292 |
IMPORT_C TInt Thickness() const;
|
williamr@2
|
293 |
IMPORT_C TInt Rounding() const;
|
williamr@2
|
294 |
private:
|
williamr@2
|
295 |
TBool IsSunken() const;
|
williamr@2
|
296 |
TInt Depth() const;
|
williamr@2
|
297 |
void DrawOutline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
|
williamr@2
|
298 |
void DrawRectOutline(CGraphicsContext& aGc,const TRect& aRect) const;
|
williamr@2
|
299 |
void DrawInline(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor) const;
|
williamr@2
|
300 |
TMargins OutlineMargins() const;
|
williamr@2
|
301 |
TMargins BorderMargins() const;
|
williamr@2
|
302 |
TMargins InlineMargins() const;
|
williamr@2
|
303 |
TRect OutlineInnerRect(const TRect& aOuterRect) const;
|
williamr@2
|
304 |
TRect BorderInnerRect(const TRect& aOuterRect) const;
|
williamr@2
|
305 |
TInt BorderRounding() const;
|
williamr@2
|
306 |
TInt InlineRounding() const;
|
williamr@2
|
307 |
void DrawOneStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aMidlight,TRgb aMid) const;
|
williamr@2
|
308 |
void DrawTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
|
williamr@2
|
309 |
void DrawInvertedTwoStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
|
williamr@2
|
310 |
void DrawThreeStep(CGraphicsContext& aGc,const TRect& aRect,TRgb aBack,TRgb aLight,TRgb aMidlight,TRgb aMid,TRgb aDark) const;
|
williamr@2
|
311 |
void DrawTopLeft(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
|
williamr@2
|
312 |
void DrawRoundedTopLeft(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
|
williamr@2
|
313 |
void DrawBottomRight(CGraphicsContext& aGc,const TRect& aRect,TRgb aColor,const TInt aRounding) const;
|
williamr@2
|
314 |
void DrawRoundedBottomRight(CGraphicsContext& aGc,const TRect& aRect,const TInt aRounding) const;
|
williamr@2
|
315 |
void DrawRoundedCorner(CGraphicsContext& aGc,const TPoint& aStart,const TInt aRoundedLength, const TBool aUp, const TBool aRight) const;
|
williamr@2
|
316 |
TInt RoundingMargin(const TInt aRoundedLength) const;
|
williamr@2
|
317 |
inline TInt InternalType() const;
|
williamr@2
|
318 |
void TranslateLegacyTypes();
|
williamr@2
|
319 |
private:
|
williamr@2
|
320 |
TInt iType;
|
williamr@2
|
321 |
};
|
williamr@2
|
322 |
|
williamr@4
|
323 |
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
|
williamr@4
|
324 |
#include <graphics/uigraphicsutils/gullogicalborder.h>
|
williamr@4
|
325 |
#endif
|
williamr@2
|
326 |
|
williamr@2
|
327 |
#endif
|