|
1 /* |
|
2 * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aknborders.h> |
|
20 #include "lafAknBorders.h" |
|
21 #include <gulutil.h> |
|
22 #include <AknUtils.h> |
|
23 |
|
24 const TInt KMaxBorderBits = 3; |
|
25 |
|
26 |
|
27 struct SBorderBit |
|
28 { |
|
29 enum TSide |
|
30 { |
|
31 ELeft = 1, |
|
32 ERight = 2, |
|
33 ETop = 4, |
|
34 EBottom = 8, |
|
35 EBottomRight = 10, |
|
36 EAll = 15 |
|
37 }; |
|
38 |
|
39 // TInt iColorIndex; |
|
40 TInt iColor; |
|
41 TInt iSides; |
|
42 TInt iLeftIndent; // relative to overall rectangle iTl.iX |
|
43 TInt iTopIndent; // relative to overall rectangle iTl.iY |
|
44 TInt iWidthDiff; // relative to overall rectangle width |
|
45 TInt iHeightDiff; // relative to overall rectangle height |
|
46 |
|
47 void Draw(CGraphicsContext& aGc, const TRect& aRect) const; |
|
48 TRect Rect(const TRect& aParent) const; |
|
49 void DrawSide(CGraphicsContext& aGc, const TRect& aRect, TInt aSide) const; |
|
50 }; |
|
51 |
|
52 |
|
53 struct SBorderSpec |
|
54 { |
|
55 TMargins iMargins; // margins between overall rect and inside area |
|
56 TInt iNumBits; // number of sub parts |
|
57 SBorderBit iBits[KMaxBorderBits]; // array of sub parts |
|
58 |
|
59 void Draw(CGraphicsContext& aGc,const TRect& aRect) const; |
|
60 void ClearMargins(CGraphicsContext& aGc,const TRect& aRect) const; |
|
61 }; |
|
62 |
|
63 // Table derived from Series 60 LAF v0.8, with changes for apparent bugs (marked **) |
|
64 const SBorderSpec gBorderSpecs[] = // indexed from bordertype - EAknBorderNotePopup |
|
65 { |
|
66 // EAknBorderNotePopup - Table 151 Eur. LAF 3.2 |
|
67 { |
|
68 {3, 5, 3, 7}, // margins (l,r,t,b) |
|
69 3, // number of sub parts |
|
70 { |
|
71 {0x999999, SBorderBit::EBottomRight, 6, 6, 8, 10}, // 2nd shadow |
|
72 {0x777777, SBorderBit::EBottomRight, 4, 4, 7, 9}, // 1st shadow |
|
73 {0x000000, SBorderBit::EAll, 2, 2, 6, 8} // outline |
|
74 } |
|
75 }, |
|
76 |
|
77 // EAknBorderMenuPopup |
|
78 { |
|
79 {3, 5, 3, 3}, // margins ** table 164.5 H = p-6 |
|
80 3, // number of sub parts |
|
81 { |
|
82 {0x999999, SBorderBit::EBottomRight, 6, 6, 8, 6}, // 2nd shadow |
|
83 {0x777777, SBorderBit::EBottomRight, 4, 4, 7, 5}, // 1st shadow |
|
84 {0x000000, SBorderBit::EAll, 2, 2, 6, 4} // outline |
|
85 } |
|
86 }, |
|
87 |
|
88 // EAknBorderMenuSubmenuPopup |
|
89 { |
|
90 {2, 3, 2, 3}, // margins ** table 170.5 W,H = p-5 |
|
91 2, // number of sub parts |
|
92 { |
|
93 {0x777777, SBorderBit::EBottomRight, 3, 3, 4, 4}, // 1st shadow |
|
94 {0x000000, SBorderBit::EAll, 1, 1, 3, 3} // outline |
|
95 } |
|
96 }, |
|
97 |
|
98 // EAknBorderNotificationPopup ** table 190.1 H = 61? |
|
99 { |
|
100 {3, 5, 9, 3}, // margins |
|
101 3, // number of sub parts |
|
102 { |
|
103 {0x999999, SBorderBit::EBottomRight, 6, 12, 8, 12}, // 2nd shadow |
|
104 {0x777777, SBorderBit::EBottomRight, 4, 10, 7, 11}, // 1st shadow |
|
105 {0x000000, SBorderBit::EAll, 2, 8, 6, 10} // outline |
|
106 } |
|
107 }, |
|
108 |
|
109 // EAknBorderGroupedNotificationsPopup |
|
110 { |
|
111 {3, 5, 9, 7}, // margins |
|
112 3, // number of sub parts |
|
113 { |
|
114 {0x999999, SBorderBit::EBottomRight, 6, 12, 8, 16}, // 2nd shadow ** table 194.2 l = 6 |
|
115 {0x777777, SBorderBit::EBottomRight, 4, 10, 7, 15}, // 1st shadow |
|
116 {0x000000, SBorderBit::EAll, 2, 8, 6, 14} // outline |
|
117 } |
|
118 }, |
|
119 |
|
120 // EAknBorderCharacterSelectionPopup |
|
121 { |
|
122 {3, 4, 3, 7}, // margins |
|
123 3, // number of sub parts |
|
124 { |
|
125 {0x999999, SBorderBit::EBottomRight, 6, 6, 7, 10}, // 2nd shadow |
|
126 {0x777777, SBorderBit::EBottomRight, 4, 4, 6, 9}, // 1st shadow |
|
127 {0x000000, SBorderBit::EAll, 2, 2, 5, 8} // outline |
|
128 } |
|
129 }, |
|
130 |
|
131 }; |
|
132 |
|
133 |
|
134 void LafAknBorders::DrawLogicalBorder(const TGulBorder& aBorder,CGraphicsContext& aGc,const TRect& aRect,const TGulBorder::TColors& /*aBorderColors*/) |
|
135 { |
|
136 TInt type = aBorder.Type(); |
|
137 ASSERT(AknBorderId::EAknBorderNotePopup <= type && type < AknBorderId::EAknBorderMax); |
|
138 switch (type) |
|
139 { |
|
140 case AknBorderId::EAknBorderPopups: |
|
141 { |
|
142 // from popup_menu_window/LAF specification |
|
143 TInt height = aRect.Size().iHeight; |
|
144 TAknLayoutRect cover, second, first, outline, inside; |
|
145 cover.LayoutRect( aRect, 0, 0, 0, ELayoutEmpty, ELayoutEmpty, 176, height); |
|
146 second.LayoutRect( aRect, 86, 6, 6, ELayoutEmpty, ELayoutEmpty, 168, height-6); |
|
147 first.LayoutRect( aRect, 221, 4, 4, ELayoutEmpty, ELayoutEmpty, 169, height-4); |
|
148 outline.LayoutRect(aRect, 215, 2, 2, ELayoutEmpty, ELayoutEmpty, 170, height-3); |
|
149 inside.LayoutRect( aRect, 0, 3, 3, ELayoutEmpty, ELayoutEmpty, 168, height-4); |
|
150 AknDraw::DrawWindowShadow(STATIC_CAST(CWindowGc&,aGc), cover, second, first, outline, inside); |
|
151 } |
|
152 break; |
|
153 case AknBorderId::EAknBorderPopupsWithHeading: |
|
154 { |
|
155 // popup menu with heading window graphics |
|
156 TInt height = aRect.Size().iHeight; |
|
157 TAknLayoutRect cover, second, first, outline, inside; |
|
158 cover.LayoutRect( aRect, 0, 0, 0, ELayoutEmpty, ELayoutEmpty, 176, height+23); |
|
159 second.LayoutRect( aRect, 86, 6, 6, ELayoutEmpty, ELayoutEmpty, 168, height+13); |
|
160 first.LayoutRect( aRect, 221, 4, 4, ELayoutEmpty, ELayoutEmpty, 169, height+14); |
|
161 outline.LayoutRect(aRect, 215, 2, 2, ELayoutEmpty, ELayoutEmpty, 170, height+15); |
|
162 inside.LayoutRect( aRect, 0, 3, 3, ELayoutEmpty, ELayoutEmpty, 168, height+13); |
|
163 AknDraw::DrawWindowShadow(STATIC_CAST(CWindowGc&,aGc), cover, second, first, outline, inside); |
|
164 } |
|
165 default: |
|
166 TInt index = type - AknBorderId::EAknBorderNotePopup; |
|
167 if (index >= 0 && index < sizeof(gBorderSpecs)/sizeof(SBorderSpec)) |
|
168 { |
|
169 gBorderSpecs[index].Draw(aGc, aRect); |
|
170 } |
|
171 } |
|
172 } |
|
173 |
|
174 TMargins LafAknBorders::LogicalBorderMargins(const TGulBorder& aBorder) |
|
175 { |
|
176 TMargins m; |
|
177 m.iTop = 0; |
|
178 m.iLeft = 0; |
|
179 m.iRight = 0; |
|
180 m.iBottom = 0; |
|
181 |
|
182 TInt type = aBorder.Type(); |
|
183 ASSERT(AknBorderId::EAknBorderNotePopup <= type && type < AknBorderId::EAknBorderMax); |
|
184 |
|
185 if (type >= AknBorderId::EAknBorderNotePopup && type < AknBorderId::EAknBorderPopups) |
|
186 { |
|
187 TInt index = type - AknBorderId::EAknBorderNotePopup; |
|
188 return gBorderSpecs[index].iMargins; |
|
189 } |
|
190 |
|
191 // EAknBorderPopupsWithHeading and EAknBorderPopups return zeros. |
|
192 return m; |
|
193 } |
|
194 |
|
195 |
|
196 void SBorderBit::Draw(CGraphicsContext& aGc, const TRect& aRect) const |
|
197 { |
|
198 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
199 aGc.SetPenColor(TRgb(iColor)); |
|
200 |
|
201 TRect rect = Rect(aRect); |
|
202 rect.iBr -= TPoint(1,1); // convert to inclusive rect |
|
203 DrawSide(aGc, rect, iSides & ELeft); |
|
204 DrawSide(aGc, rect, iSides & EBottom); |
|
205 DrawSide(aGc, rect, iSides & ERight); |
|
206 DrawSide(aGc, rect, iSides & ETop); |
|
207 } |
|
208 |
|
209 void SBorderBit::DrawSide(CGraphicsContext& aGc, const TRect& aRect, TInt aSide) const |
|
210 { |
|
211 TPoint start; |
|
212 TPoint end; |
|
213 |
|
214 switch (aSide) |
|
215 { |
|
216 case ELeft: |
|
217 start = aRect.iTl; |
|
218 end = TPoint(aRect.iTl.iX, aRect.iBr.iY); |
|
219 end.iY++; |
|
220 break; |
|
221 |
|
222 case ERight: |
|
223 start = aRect.iBr; |
|
224 end = TPoint(aRect.iBr.iX, aRect.iTl.iY); |
|
225 end.iY--; |
|
226 break; |
|
227 |
|
228 case ETop: |
|
229 start = TPoint(aRect.iBr.iX, aRect.iTl.iY); |
|
230 end = aRect.iTl; |
|
231 end.iX--; |
|
232 break; |
|
233 |
|
234 case EBottom: |
|
235 start = TPoint(aRect.iTl.iX, aRect.iBr.iY); |
|
236 end = aRect.iBr; |
|
237 end.iX++; |
|
238 break; |
|
239 |
|
240 default: |
|
241 return; |
|
242 } |
|
243 |
|
244 aGc.DrawLine(start, end); |
|
245 } |
|
246 |
|
247 TRect SBorderBit::Rect(const TRect& aParent) const |
|
248 { |
|
249 TRect rect = aParent; |
|
250 rect.Move(iLeftIndent, iTopIndent); |
|
251 rect.iBr -= TPoint(iWidthDiff, iHeightDiff); |
|
252 return rect; |
|
253 } |
|
254 |
|
255 |
|
256 void SBorderSpec::Draw(CGraphicsContext& aGc,const TRect& aRect) const |
|
257 { |
|
258 ClearMargins(aGc, aRect); |
|
259 for (TInt ii=0; ii<iNumBits; ii++) |
|
260 iBits[ii].Draw(aGc, aRect); |
|
261 } |
|
262 |
|
263 void SBorderSpec::ClearMargins(CGraphicsContext& aGc,const TRect& aRect) const |
|
264 { |
|
265 // This blanks the entire margin space, so may cause flicker |
|
266 // more cunning margin clearers may be considered if this is a problem |
|
267 |
|
268 TRect inside = aRect; |
|
269 inside.iTl.iX += iMargins.iLeft; |
|
270 inside.iTl.iY += iMargins.iTop; |
|
271 inside.iBr.iX -= iMargins.iRight; |
|
272 inside.iBr.iY -= iMargins.iBottom; |
|
273 |
|
274 aGc.SetBrushColor(KRgbWhite); |
|
275 DrawUtils::ClearBetweenRects(aGc, aRect, inside); |
|
276 } |
|
277 |