|
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 "LAFMENUP.H" |
|
20 #include <eiksfont.h> |
|
21 #include <gulfont.h> |
|
22 #include <gulicon.h> |
|
23 #include <gulutil.h> |
|
24 #include <coecntrl.h> |
|
25 #include <coeinput.h> |
|
26 |
|
27 #include <avkon.hrh> |
|
28 #include "uikon.hrh" |
|
29 |
|
30 #include "LAFSCRLB.H" |
|
31 #include "LAFSTD.H" |
|
32 #include "lafcommn.h" |
|
33 |
|
34 |
|
35 const TInt KLafMenuItemRadio = (EEikMenuItemRadioStart|EEikMenuItemRadioMiddle|EEikMenuItemRadioEnd); |
|
36 |
|
37 // Margin Values for the menu pane |
|
38 const TInt KLafLeftMargin = 2; // it is used to be KLafLeftHighlightGap |
|
39 const TInt KLafRightMargin = 2; // it is used to be KLafRightHighlightGap |
|
40 const TInt KLafTopMargin = 2; // it is used to be KLafTopHighlightGap |
|
41 const TInt KLafBottomMargin = 2; // it is used to be KLafBottomHighlightGap |
|
42 |
|
43 // Margin Values for the cascade menu |
|
44 const TInt KLafCascadeLeftMargin = KLafLeftMargin; |
|
45 const TInt KLafCascadeRightMargin = KLafRightMargin; |
|
46 const TInt KLafCascadeTopMargin = KLafTopMargin; |
|
47 const TInt KLafCascadeBottomMargin = KLafBottomMargin; |
|
48 |
|
49 // Margin Values for the scroll bar |
|
50 const TInt KLafTopScrollBarMargin = 0; //TopGapForArrowHead =10; |
|
51 const TInt KLafBottomScrollBarMargin = 0; //KLafBottomGapForArrowHead=10; |
|
52 const TInt KLafLeftScrollBarMargin = 0; |
|
53 const TInt KLafRightScrollBarMargin = 0; |
|
54 |
|
55 // These values are added to font height. They do not have any effect if the icon height is bigger. |
|
56 const TInt KLafMenuPaneTextTopSpace = 3; |
|
57 const TInt KLafMenuPaneTextBottomSpace = 3; |
|
58 |
|
59 // Separator |
|
60 const TInt KLafMenuPaneSeparatorMargin = 4; // offset from the margin for the seperator |
|
61 const TInt KLafMenuSeparatorYOffset = 2; |
|
62 |
|
63 // Left Adornment width |
|
64 const TInt KLafLeftAdornmentSpace = 8; |
|
65 // Pre and Post adornment widths |
|
66 const TInt KLafPreLeftAdornmentSpace = 3; |
|
67 const TInt KLafPostLeftAdornmentSpace = 3; |
|
68 |
|
69 |
|
70 // Right Adornment width |
|
71 const TInt KLafRightAdornmentSpace = 10; |
|
72 // Pre and Post adornment widths |
|
73 const TInt KLafPreRightAdornmentSpace = 3; // it can be used as gap between hotkey and cascade symbol. |
|
74 const TInt KLafPostRightAdornmentSpace = 3; |
|
75 |
|
76 const TInt KLafSpaceBetweenTextAndHotkey = 6; |
|
77 |
|
78 const TInt KLafMenuPaneDefaultShadowHeight = 3; |
|
79 const TInt KLafOffsetBetweenMenuPaneAndMenuPaneTitle= 0; |
|
80 |
|
81 // Pre and Post widths around the Icon |
|
82 const TInt KLafPreIconSpace = 0; |
|
83 const TInt KLafPostIconSpace = 0; |
|
84 |
|
85 const TInt KLafExtraBaselineOffset =1; |
|
86 const TInt KLafMenuPaneSeparatorAfterSpace=6; |
|
87 const TInt KLafMenuCascadeOverlap=8; // + value reduces the gap between the cascade menu and its owner |
|
88 |
|
89 |
|
90 |
|
91 // |
|
92 // Class LafMenuPane::TMenuPaneAttributes |
|
93 // |
|
94 |
|
95 EXPORT_C LafMenuPane::TItemAttributes::TItemAttributes() |
|
96 : iBaseLine(0), iFlags(0), iInternalFlags(0), iHeight(0), iHighlightType(SLafMenuPane::ENoHighlight), |
|
97 iHPosition(0) |
|
98 { |
|
99 } |
|
100 |
|
101 // |
|
102 // Class LafMenuPane |
|
103 // |
|
104 |
|
105 |
|
106 /* |
|
107 * Returns the left or right adornment width determined by aItemAttributes internal flags. |
|
108 * The internal flags are set so that it is possible to know which adornments the menu pane has and |
|
109 * which one, between left and right adornment, has to be taken in consideration in order to evaluate |
|
110 * the returning value. |
|
111 */ |
|
112 EXPORT_C TInt LafMenuPane::AdornmentSpace(const TItemAttributes& aItemAttributes) |
|
113 { |
|
114 const TInt& internalFlags = aItemAttributes.iInternalFlags; |
|
115 TInt adornment = 0; |
|
116 if (internalFlags&EMenuIsLeftAdornment) |
|
117 { |
|
118 adornment = KLafPreLeftAdornmentSpace + KLafPostLeftAdornmentSpace; |
|
119 if (internalFlags&EMenuHasLeftAdornment) |
|
120 adornment += KLafLeftAdornmentSpace; |
|
121 } |
|
122 else |
|
123 { |
|
124 adornment = KLafPreRightAdornmentSpace + KLafPostRightAdornmentSpace; |
|
125 if (internalFlags&EMenuHasRightAdornment) |
|
126 adornment += KLafRightAdornmentSpace; |
|
127 } |
|
128 return adornment; |
|
129 } |
|
130 |
|
131 /** |
|
132 * Returns the keypresses menu pane is interested in from a FEP |
|
133 */ |
|
134 EXPORT_C TInt LafMenuPane::InputCapabilities() |
|
135 { // static |
|
136 return TCoeInputCapabilities::ENavigation; |
|
137 } |
|
138 |
|
139 /** |
|
140 * Returns ETrue if the first item on a menu pane should be selected by default. |
|
141 * Returning EFalse signifies that nothing should be selected initially. |
|
142 */ |
|
143 EXPORT_C TBool LafMenuPane::SelectFirstItemOnConstruction() |
|
144 { |
|
145 return ETrue; |
|
146 } |
|
147 |
|
148 EXPORT_C TInt LafMenuPane::DefaultCbaResId() |
|
149 { // static |
|
150 return 0; |
|
151 } |
|
152 |
|
153 EXPORT_C void LafMenuPane::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) |
|
154 { // static |
|
155 TInt commonAttributes = TCoeColorUse::ENormal|TCoeColorUse::ENeutral; |
|
156 TCoeColorUse colorUse; |
|
157 |
|
158 colorUse.SetLogicalColor(EColorMenuPaneText); |
|
159 colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EActive|TCoeColorUse::ESurrounds|commonAttributes); |
|
160 aColorUseList.AppendL(colorUse); |
|
161 |
|
162 colorUse.SetLogicalColor(EColorMenuPaneBackground); |
|
163 colorUse.SetUse(TCoeColorUse::EBack|TCoeColorUse::EActive|TCoeColorUse::ESurrounds|commonAttributes); |
|
164 aColorUseList.AppendL(colorUse); |
|
165 |
|
166 colorUse.SetLogicalColor(EColorMenuPaneTextHighlight); |
|
167 colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EActive|TCoeColorUse::EHighlights|commonAttributes); |
|
168 aColorUseList.AppendL(colorUse); |
|
169 |
|
170 colorUse.SetLogicalColor(EColorMenuPaneHighlight); |
|
171 colorUse.SetUse(TCoeColorUse::EBack|TCoeColorUse::EActive|TCoeColorUse::EHighlights|commonAttributes); |
|
172 aColorUseList.AppendL(colorUse); |
|
173 |
|
174 colorUse.SetLogicalColor(EColorMenuPaneDimmedTextHighlight); |
|
175 colorUse.SetUse(TCoeColorUse::EBack|TCoeColorUse::EDimmed|TCoeColorUse::EHighlights|commonAttributes); |
|
176 aColorUseList.AppendL(colorUse); |
|
177 |
|
178 colorUse.SetLogicalColor(EColorMenuPaneDimmedHighlight); |
|
179 colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EDimmed|TCoeColorUse::EHighlights|commonAttributes); |
|
180 aColorUseList.AppendL(colorUse); |
|
181 |
|
182 colorUse.SetLogicalColor(EColorMenuPaneDimmedText); |
|
183 colorUse.SetUse(TCoeColorUse::EBack|TCoeColorUse::EDimmed|TCoeColorUse::ESurrounds|commonAttributes); |
|
184 aColorUseList.AppendL(colorUse); |
|
185 } |
|
186 |
|
187 /** |
|
188 * Returns the keycode to use with menus for the given event. Intended primarily to allow custom |
|
189 * device hardware keys to map to standard Epoc functions. |
|
190 * |
|
191 * @since App-Framework_6.1 |
|
192 */ |
|
193 EXPORT_C TUint LafMenuPane::MapKeyCode(const TKeyEvent& aKeyEvent,TEventCode /*aType*/) |
|
194 { // static |
|
195 return aKeyEvent.iCode; |
|
196 } |
|
197 |
|
198 /** |
|
199 * Returns a constant value according to aConstantType. |
|
200 * |
|
201 * @internal |
|
202 */ |
|
203 EXPORT_C TInt LafMenuPane::Constant(TConstantType aConstantType) |
|
204 {//static |
|
205 TInt retValue = 0; |
|
206 switch (aConstantType) |
|
207 { |
|
208 case EPostRightAdornmentSpace: |
|
209 retValue = KLafPostRightAdornmentSpace; |
|
210 break; |
|
211 case EMenuPaneTextTopSpace: |
|
212 retValue = KLafMenuPaneTextTopSpace; |
|
213 break; |
|
214 case EMenuPaneTextBottomSpace: |
|
215 retValue = KLafMenuPaneTextBottomSpace; |
|
216 break; |
|
217 case ESpaceBetweenTextAndHotkey: |
|
218 retValue = KLafSpaceBetweenTextAndHotkey; |
|
219 break; |
|
220 case EOffsetBetweenMenuPaneAndMenuPaneTitle: |
|
221 retValue = KLafOffsetBetweenMenuPaneAndMenuPaneTitle; |
|
222 break; |
|
223 case EMenuPaneSeparatorMargin: |
|
224 retValue = KLafMenuPaneSeparatorMargin; |
|
225 break; |
|
226 case EShadowHeight: |
|
227 retValue = KLafMenuPaneDefaultShadowHeight; |
|
228 break; |
|
229 case EPreIconSpace: |
|
230 retValue = KLafPreIconSpace; |
|
231 break; |
|
232 case EPostIconSpace: |
|
233 retValue = KLafPostIconSpace; |
|
234 break; |
|
235 case EExtraBaselineOffset: |
|
236 retValue = KLafExtraBaselineOffset; |
|
237 break; |
|
238 case EMenuPaneSeparatorAfterSpace: |
|
239 retValue = KLafMenuPaneSeparatorAfterSpace; |
|
240 break; |
|
241 case EMenuCascadeOverlap: |
|
242 retValue = KLafMenuCascadeOverlap; |
|
243 break; |
|
244 case EMenuSeparatorYOffset: |
|
245 retValue = KLafMenuSeparatorYOffset; |
|
246 break; |
|
247 case ENumberOfItemsInView: |
|
248 retValue=-1; |
|
249 break; |
|
250 default: |
|
251 __ASSERT_DEBUG(EFalse, Panic(ELafPanicConstantNotKnown)); // should never be reached |
|
252 break; |
|
253 } |
|
254 return retValue; |
|
255 } |
|
256 |
|
257 /** |
|
258 * Returns the font corresponding to aFontType. |
|
259 * |
|
260 * @internal |
|
261 */ |
|
262 EXPORT_C const CFont* LafMenuPane::Font(const MLafEnv& aLafEnv, TFontType aFontType) |
|
263 { // static |
|
264 TLogicalFont logicalFont; |
|
265 |
|
266 switch (aFontType) |
|
267 { |
|
268 case EAnnotation: |
|
269 logicalFont.iFontId=TUid::Uid(EAknLogicalFontSecondaryFont); |
|
270 break; |
|
271 case ENormal: |
|
272 logicalFont.iFontId=TUid::Uid(EAknLogicalFontPrimaryFont); |
|
273 break; |
|
274 case ESymbol: |
|
275 logicalFont.iFontId=TUid::Uid(EAknLogicalFontSecondaryFont); |
|
276 break; |
|
277 default: |
|
278 __ASSERT_DEBUG(EFalse, Panic(ELafPanicFontIndexOutOfRange)); // should never be reached |
|
279 break; |
|
280 } |
|
281 |
|
282 return aLafEnv.Font(logicalFont); |
|
283 } |
|
284 |
|
285 /** |
|
286 * Gets the default border for the matched control in aBorder. Called from the constructor of the matched control. |
|
287 */ |
|
288 EXPORT_C void LafMenuPane::GetDefaultBorder(TGulBorder& aBorder) |
|
289 { |
|
290 aBorder=TGulBorder(TGulBorder::EThickDeepRaisedWithOutline); |
|
291 } |
|
292 |
|
293 /** |
|
294 * Gets the set of border colors for the matched control in aBorderColors. The RGB values of the colors obtained |
|
295 * may depend on the the display mode, the environment color list and the instance of the |
|
296 * matched control aMatchedControl. Called by the matched control from its Draw() method and passed on to the |
|
297 * Draw() method of TGulBorder. |
|
298 */ |
|
299 EXPORT_C void LafMenuPane::GetBorderColors(TGulBorder::TColors& aBorderColors, const MLafEnv& aLafEnv, const CCoeControl& aMatchedControl) |
|
300 { |
|
301 LafCommonUtils::GetRgbDerivedBorderColors( aBorderColors, |
|
302 EColorMenuPaneBackground, aLafEnv,aMatchedControl ); |
|
303 } |
|
304 |
|
305 /** |
|
306 * Returns the default flags for the scroll bar for orientation aOrientation. |
|
307 * Called when the matched control creates its scroll bar frame.. |
|
308 */ |
|
309 EXPORT_C TInt LafMenuPane::DefaultScrollBarFlags(TInt /*aOrientation*/) |
|
310 { |
|
311 return 0; |
|
312 } |
|
313 |
|
314 /** |
|
315 * Draws the joints between menu pane and menu pane title into the graphics |
|
316 * context aGc, in the rectangle aRect. |
|
317 */ |
|
318 EXPORT_C void LafMenuPane::DrawTitlePaneJoint(const MLafEnv& aLafEnv, const CCoeControl& aMenuPane, CWindowGc& aGc, const CCoeControl* aMenuPaneTitle, const TRect& aInnerRect) |
|
319 { |
|
320 PrepareGcForDrawingItems(aLafEnv, aMenuPane, aGc); |
|
321 aGc.SetPenStyle(CGraphicsContext::ENullPen); |
|
322 aGc.DrawRect(aInnerRect); |
|
323 if (aMenuPaneTitle) |
|
324 {// pane has title, so make sure they are joined up correctly |
|
325 const TPoint titlePos = aMenuPaneTitle->Position(); |
|
326 const TInt width = aMenuPaneTitle->Size().iWidth; |
|
327 const TPoint position = aMenuPane.Position(); |
|
328 |
|
329 // left straight join |
|
330 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
331 aGc.SetPenColor(aLafEnv.ControlColor(EColorMenuPaneBackground, aMenuPane)); |
|
332 // get rid of the gray bit of border |
|
333 aGc.DrawLine(TPoint(titlePos.iX-position.iX+5,4),TPoint(titlePos.iX-position.iX+width-5,4)); |
|
334 // get rid of the black bit of border |
|
335 aGc.DrawLine(TPoint(titlePos.iX-position.iX+4,0),TPoint(titlePos.iX-position.iX+width-4,0)); |
|
336 aGc.DrawLine(TPoint(titlePos.iX-position.iX+4,1),TPoint(titlePos.iX-position.iX+width-4,1)); |
|
337 |
|
338 aGc.DrawLine(TPoint(titlePos.iX-position.iX+5,4),TPoint(titlePos.iX-position.iX+width-5,4)); |
|
339 aGc.DrawLine(TPoint(titlePos.iX-position.iX+MenuPaneSeparatorMargin() ,0),TPoint(titlePos.iX-position.iX+width-MenuPaneSeparatorMargin(),0)); |
|
340 aGc.DrawLine(TPoint(titlePos.iX-position.iX+MenuPaneSeparatorMargin() ,1),TPoint(titlePos.iX-position.iX+width-MenuPaneSeparatorMargin(),1)); |
|
341 aGc.DrawLine(TPoint(titlePos.iX-position.iX+MenuPaneSeparatorMargin() ,2),TPoint(titlePos.iX-position.iX+width-MenuPaneSeparatorMargin(),2)); |
|
342 aGc.DrawLine(TPoint(titlePos.iX-position.iX+MenuPaneSeparatorMargin() ,3),TPoint(titlePos.iX-position.iX+width-MenuPaneSeparatorMargin(),3)); |
|
343 |
|
344 // draw in black line seperator |
|
345 aGc.SetPenColor(KRgbBlack); |
|
346 aGc.DrawLine(TPoint(titlePos.iX-position.iX +MenuPaneSeparatorMargin(),0),TPoint(titlePos.iX-position.iX+width-3-MenuPaneSeparatorMargin(),0)); |
|
347 |
|
348 TGulBorder::TColors borderColors; |
|
349 GetBorderColors(borderColors, aLafEnv, *aMenuPaneTitle); |
|
350 |
|
351 aGc.SetPenColor(borderColors.iMidlight); |
|
352 aGc.DrawLine(TPoint(titlePos.iX-position.iX+1,0),TPoint(titlePos.iX-position.iX+4,0)); |
|
353 aGc.DrawLine(TPoint(titlePos.iX-position.iX+1,1),TPoint(titlePos.iX-position.iX+4,1)); |
|
354 |
|
355 if (aMenuPaneTitle->Rect().iBr.iX==aMenuPane.Rect().iBr.iX) |
|
356 {// right straight join |
|
357 aGc.SetPenColor(borderColors.iMid); |
|
358 aGc.DrawLine(TPoint(aInnerRect.iBr.iX,0),TPoint(aInnerRect.iBr.iX,5)); |
|
359 aGc.DrawLine(TPoint(aInnerRect.iBr.iX+1,0),TPoint(aInnerRect.iBr.iX+1,4)); |
|
360 aGc.DrawLine(TPoint(aInnerRect.iBr.iX+2,0),TPoint(aInnerRect.iBr.iX+2,3)); |
|
361 } |
|
362 else |
|
363 {// right corner join |
|
364 TInt xPos=titlePos.iX-position.iX+width-4; |
|
365 aGc.SetPenColor(borderColors.iMid); |
|
366 aGc.DrawLine(TPoint(xPos,0),TPoint(xPos,4)); |
|
367 aGc.DrawLine(TPoint(xPos+1,0),TPoint(xPos+1,3)); |
|
368 aGc.DrawLine(TPoint(xPos+2,0),TPoint(xPos+2,2)); |
|
369 } |
|
370 } |
|
371 } |
|
372 |
|
373 |
|
374 /** |
|
375 * Draws the aHotKeys text into the graphics context aGc, in the rectangle aRect. By defalut the |
|
376 * text is right aligned. |
|
377 */ |
|
378 EXPORT_C void LafMenuPane::DrawHotKeyText(const MLafEnv& aLafEnv, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TDesC& aHotKeysText, const TItemAttributes& aItemAttributes) |
|
379 { |
|
380 aGc.UseFont(AnnotationFont(aLafEnv)); |
|
381 // Left alignment |
|
382 aGc.DrawText(aHotKeysText, aRect, aItemAttributes.iBaseLine, CGraphicsContext::ELeft,KLafSpaceBetweenTextAndHotkey); |
|
383 aGc.UseFont(NormalFont(aLafEnv)); |
|
384 } |
|
385 |
|
386 /** |
|
387 * Draws the left adornment to the graphics context aGc, in the rectangle aRect. The menu pane |
|
388 * flags determines the type of adornment to be drawn. |
|
389 */ |
|
390 EXPORT_C void LafMenuPane::DrawLeftAdornment(const MLafEnv& aLafEnv, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TItemAttributes& aItemAttributes) |
|
391 { |
|
392 // Brush the background of the rect. |
|
393 aGc.SetPenStyle(CGraphicsContext::ENullPen); |
|
394 aGc.DrawRect(aRect); |
|
395 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
396 const TInt itemFlags = aItemAttributes.iFlags; |
|
397 if (itemFlags&EEikMenuItemSymbolOn) |
|
398 { |
|
399 if (itemFlags&EEikMenuItemCheckBox) |
|
400 { |
|
401 TRect rect = aRect; |
|
402 rect.iTl.iY += aItemAttributes.iBaseLine; |
|
403 TBuf<1> buf; |
|
404 buf.Append(TChar(ESymFontTick)); |
|
405 aGc.UseFont(SymbolFont(aLafEnv)); |
|
406 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
407 // as the tick is big, ignore KPreLeftAdornment and steal 1 pixels from left. |
|
408 aGc.DrawText(buf,TPoint(rect.iTl.iX-1, rect.iTl.iY)); |
|
409 aGc.UseFont(NormalFont(aLafEnv)); |
|
410 } |
|
411 else if (itemFlags&KLafMenuItemRadio) |
|
412 { |
|
413 TUid bmpUid(TUid::Uid(KLafUidEikonOptiVal)); |
|
414 const CFbsBitmap* bitmap = aLafEnv.Bitmap(bmpUid); |
|
415 TSize bitsize = bitmap->SizeInPixels(); |
|
416 TRect butRect(TPoint(0,0), TPoint(bitsize.iWidth,bitsize.iHeight)); |
|
417 TInt yoffset = (aRect.Size().iHeight - bitsize.iHeight) / 2; |
|
418 TInt xoffset = KLafPreLeftAdornmentSpace; |
|
419 TPoint offset(xoffset,yoffset); |
|
420 if (aItemAttributes.iHighlightType == SLafMenuPane::EDrawHighlight) |
|
421 { |
|
422 bmpUid=TUid::Uid(KLafUidEikonOptihVal); |
|
423 bitmap = aLafEnv.Bitmap(bmpUid); |
|
424 } |
|
425 bmpUid=TUid::Uid(KLafUidEikonOptimVal); |
|
426 const CFbsBitmap* mask = aLafEnv.Bitmap(bmpUid); |
|
427 aGc.BitBltMasked((aRect.iTl+offset), bitmap, butRect, mask,ETrue); |
|
428 } |
|
429 } |
|
430 } |
|
431 |
|
432 /** |
|
433 * Draws the cascade symbol into the graphics context aGc, in the rectangle aRect and sets |
|
434 * the pen color depending on whether the menu item is dimmed or focused. |
|
435 */ |
|
436 EXPORT_C void LafMenuPane::DrawRightAdornment(const MLafEnv& aLafEnv, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TItemAttributes& aItemAttributes) |
|
437 { |
|
438 const TInt cascadeSize=Min(KLafRightAdornmentSpace,aItemAttributes.iHeight); |
|
439 |
|
440 // Brush the background of the rect. |
|
441 aGc.SetPenStyle(CGraphicsContext::ENullPen); |
|
442 aGc.DrawRect(aRect); |
|
443 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
444 if (aItemAttributes.iInternalFlags&EMenuIsRightAdornment) |
|
445 { |
|
446 //Sort out rect for cascade symbol |
|
447 TRect cascadeRect=TRect(TPoint(aRect.iBr.iX-cascadeSize-PostRightAdornmentSpace(),aItemAttributes.iHPosition), |
|
448 TSize(cascadeSize,aItemAttributes.iHeight)); |
|
449 cascadeRect.iTl.iY+=((aItemAttributes.iHeight-cascadeSize)/2); |
|
450 cascadeRect.iBr.iY-=((aItemAttributes.iHeight-cascadeSize)/2); |
|
451 TBuf<1> cascade; |
|
452 cascade.Append(TChar(ESymFontMenuCascade)); |
|
453 aGc.UseFont(SymbolFont(aLafEnv)); |
|
454 aGc.DrawText(cascade,cascadeRect,cascadeRect.Height(),CGraphicsContext::ERight); |
|
455 aGc.UseFont(NormalFont(aLafEnv)); |
|
456 } |
|
457 } |
|
458 |
|
459 /** |
|
460 * Draws a line seperator between two items into the graphics context aGc, in the rectangle aRect. |
|
461 */ |
|
462 EXPORT_C void LafMenuPane::DrawSeperator(const MLafEnv& aLafEnv, const CCoeControl& aMenuPane, CWindowGc& aGc, const TRect& aRect, const TItemAttributes& /*aItemAttributes*/) |
|
463 { |
|
464 aGc.SetPenColor(aLafEnv.ControlColor(EColorMenuPaneText, aMenuPane)); |
|
465 aGc.DrawLine(aRect.iTl, aRect.iBr); |
|
466 } |
|
467 |
|
468 /** |
|
469 * Draws aText into the graphics context aGc, in the rectangle aRect. By default aText is |
|
470 * left aligned |
|
471 */ |
|
472 EXPORT_C void LafMenuPane::DrawText(const MLafEnv& /*aLafEnv*/, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TDesC& aText, const TItemAttributes& aItemAttributes) |
|
473 { |
|
474 aGc.DrawText(aText, aRect, aItemAttributes.iBaseLine, CGraphicsContext::ELeft); |
|
475 } |
|
476 |
|
477 /** |
|
478 * Returns ETrue when the window behind the menu bar should be faded. |
|
479 */ |
|
480 EXPORT_C TBool LafMenuPane::FadeBehind() |
|
481 { // static |
|
482 return EFalse; |
|
483 } |
|
484 |
|
485 /** |
|
486 * Returns the margins for the cascade menu. |
|
487 */ |
|
488 EXPORT_C const TMargins8 LafMenuPane::CascadeMargins() |
|
489 { // static |
|
490 TMargins8 cascadeMargins; |
|
491 cascadeMargins.iLeft = KLafCascadeLeftMargin; |
|
492 cascadeMargins.iRight =KLafCascadeRightMargin; |
|
493 cascadeMargins.iTop = KLafCascadeTopMargin; |
|
494 cascadeMargins.iBottom = KLafCascadeBottomMargin; |
|
495 return cascadeMargins; |
|
496 } |
|
497 |
|
498 /** |
|
499 * Returns the menu pane margins. |
|
500 */ |
|
501 EXPORT_C const TMargins8 LafMenuPane::Margins() |
|
502 { // static |
|
503 TMargins8 margins; |
|
504 margins.iLeft = KLafLeftMargin; |
|
505 margins.iRight =KLafRightMargin; |
|
506 margins.iTop = KLafTopMargin; |
|
507 margins.iBottom = KLafBottomMargin; |
|
508 return margins; |
|
509 } |
|
510 |
|
511 /** |
|
512 * Returns the menu pane margins. |
|
513 */ |
|
514 EXPORT_C const TMargins8 LafMenuPane::ScrollBarMargins() |
|
515 { // static |
|
516 TMargins8 margins; |
|
517 margins.iLeft = KLafLeftScrollBarMargin; |
|
518 margins.iRight = KLafRightScrollBarMargin; |
|
519 margins.iTop = KLafTopScrollBarMargin; |
|
520 margins.iBottom = KLafBottomScrollBarMargin; |
|
521 return margins; |
|
522 } |
|
523 |
|
524 /** |
|
525 * Prepares the graphics context aGc for drawing the items by setting the pen and brush. |
|
526 */ |
|
527 EXPORT_C void LafMenuPane::PrepareGcForDrawingItems(const MLafEnv& aLafEnv, const CCoeControl& aMenuPane, CWindowGc& aGc) |
|
528 { |
|
529 const CFont* font = NormalFont(aLafEnv); |
|
530 aGc.UseFont(font); |
|
531 aGc.SetPenColor(aLafEnv.ControlColor(EColorMenuPaneText, aMenuPane)); |
|
532 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
533 aGc.SetBrushColor(aLafEnv.ControlColor(EColorMenuPaneBackground, aMenuPane)); |
|
534 } |
|
535 |
|
536 /** |
|
537 * Prepares the graphics context aGc according of aHighlightType before drawing an item. At the |
|
538 * same time it determines and returns the text color to be used during the drawing of all components |
|
539 * of an item. |
|
540 */ |
|
541 EXPORT_C void LafMenuPane::PrepareGcForHighlight(const MLafEnv& aLafEnv, const CCoeControl& aMenuPane, CWindowGc& aGc, const TItemAttributes& aItemAttributes) |
|
542 { |
|
543 TRgb textColor = aLafEnv.ControlColor(EColorMenuPaneText, aMenuPane); //KEikMenuPaneTextColor; |
|
544 switch (aItemAttributes.iHighlightType) |
|
545 { |
|
546 case SLafMenuPane::EDrawHighlight: |
|
547 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
548 textColor = aLafEnv.ControlColor(EColorMenuPaneTextHighlight, aMenuPane); |
|
549 if (aMenuPane.IsFocused()) |
|
550 { |
|
551 aGc.SetBrushColor(aLafEnv.ControlColor(EColorMenuPaneHighlight, aMenuPane)); |
|
552 if (aItemAttributes.iFlags&EEikMenuItemDimmed) |
|
553 textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedTextHighlight, aMenuPane); |
|
554 } |
|
555 else |
|
556 { |
|
557 aGc.SetBrushColor(aLafEnv.ControlColor(EColorMenuPaneDimmedHighlight, aMenuPane)); |
|
558 textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedTextHighlight, aMenuPane); |
|
559 } |
|
560 break; |
|
561 case SLafMenuPane::ERemoveHighlight: |
|
562 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
563 if (aItemAttributes.iFlags&EEikMenuItemDimmed) |
|
564 textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedText, aMenuPane); |
|
565 break; |
|
566 case SLafMenuPane::ENoHighlight: |
|
567 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
568 if (aItemAttributes.iFlags&EEikMenuItemDimmed) |
|
569 textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedText, aMenuPane); |
|
570 break; |
|
571 default: |
|
572 break; |
|
573 } |
|
574 aGc.SetPenColor(textColor); |
|
575 } |
|
576 |
|
577 /** |
|
578 * Returns ETrue if the menu pane can show the hotkeys, otherwise it returns EFalse. |
|
579 */ |
|
580 EXPORT_C TBool LafMenuPane::ShowHotKeys() |
|
581 { // static |
|
582 return ETrue; |
|
583 } |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 // |
|
590 // class LafMenuPaneItem |
|
591 // |
|
592 |
|
593 /** |
|
594 * Draws the icon for the item to the graphics context aGc, in the middle of the rectangle aRect |
|
595 */ |
|
596 EXPORT_C void LafMenuPaneItem::DrawIcon(const MLafEnv& /*aLafEnv*/, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const CGulIcon* aIcon, SLafMenuPane::THighlightType aHighlightType) |
|
597 { |
|
598 if (aIcon) |
|
599 { |
|
600 if (aHighlightType == SLafMenuPane::EDrawHighlight) |
|
601 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
602 |
|
603 // Determine the rect available for the bitmap |
|
604 TRect rect = aRect; |
|
605 // put the image in the middle of available rect |
|
606 const CFbsBitmap* bitmap = aIcon->Bitmap(); |
|
607 const TSize bmpSize(bitmap->SizeInPixels()); |
|
608 const TSize rectSize(aRect.Size()); |
|
609 const TPoint offset(((rectSize.iWidth - bmpSize.iWidth) / 2), ((rectSize.iHeight - bmpSize.iHeight) / 2)); |
|
610 const CFbsBitmap* mask = aIcon->Mask(); |
|
611 if (mask) |
|
612 { |
|
613 const TRect bmpRect(0, 0, bmpSize.iWidth, bmpSize.iHeight); |
|
614 aGc.BitBltMasked(rect.iTl+offset, bitmap, bmpRect, mask, ETrue); |
|
615 } |
|
616 else |
|
617 aGc.BitBlt(rect.iTl+offset, bitmap); |
|
618 if (aHighlightType == SLafMenuPane::EDrawHighlight) |
|
619 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
620 } |
|
621 } |
|
622 |
|
623 |
|
624 /** |
|
625 * Gets the default attributes for the scroll bar for orientation aOrientation in aAttributes. |
|
626 * Called when the matched control creates its scroll bar frame.. |
|
627 */ |
|
628 EXPORT_C void LafMenuPane::GetDefaultScrollBarAttributes(TInt aOrientation, LafScrollBarFrame::TScrollBarAttributes& aAttributes) |
|
629 { |
|
630 aAttributes = LafScrollBarFrame::TScrollBarAttributes(); |
|
631 if (aOrientation == SLafScrollBar::EVertical) |
|
632 { |
|
633 aAttributes.iControlType = EEikCtScrollBar; |
|
634 aAttributes.iSide = SLafScrollBarFrame::EBottomOrRight; |
|
635 aAttributes.iManagement = SLafScrollBarFrame::EComponent; |
|
636 aAttributes.iBreadth = LafScrollBar::DefaultBreadth(); |
|
637 } |
|
638 } |
|
639 |
|
640 /** |
|
641 * Draws visual feedback for a menu item to indicate that it has been selected. This is shown for |
|
642 * the brief interval between the item being selected and the menu being dismissed. Uses the |
|
643 * environment aLafEnv for setting up the context aGc for the menu pane aMenuPane and draws inside |
|
644 * the item rectangle aRect. |
|
645 * |
|
646 * @since App-Framework_6.1 |
|
647 */ |
|
648 EXPORT_C void LafMenuPane::DrawVisualFeedback(const MLafEnv& /*aLafEnv*/, const CCoeControl& /*aMenuPane*/, |
|
649 CWindowGc& aGc, const TRect& aRect) |
|
650 { |
|
651 aGc.SetPenColor(KRgbBlack); |
|
652 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
653 aGc.DrawRect(aRect); |
|
654 } |
|
655 |
|
656 |