|
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 "lafimage.h" |
|
20 |
|
21 #include <w32std.h> |
|
22 #include <coecntrl.h> |
|
23 #include <uiklaf/private/lafenv.h> |
|
24 #include <lafmain.h> |
|
25 |
|
26 #include <AknsDrawUtils.h> |
|
27 #include <coeccntx.h> |
|
28 |
|
29 EXPORT_C void LafImage::Draw(const MLafEnv& aEnv,const CCoeControl& aControl,CWindowGc& aGc,const TRect& /*aRect*/, |
|
30 TMargins8 aMargins,TGulAlignment aAlignment,const CFbsBitmap& aBitmap, |
|
31 const CFbsBitmap* aMask,TBool aFullEmphasis) |
|
32 { // static |
|
33 if (aFullEmphasis) |
|
34 { |
|
35 aGc.SetBrushColor(KRgbBlack); |
|
36 aGc.SetDrawMode(CGraphicsContext::EDrawModeNOTPEN); |
|
37 } |
|
38 const TRect rect(aControl.Rect()); |
|
39 TRect inner=aMargins.InnerRect(rect); |
|
40 TSize bmpSize=aBitmap.SizeInPixels(); |
|
41 const TSize innerSize=inner.Size(); |
|
42 inner=aAlignment.InnerRect(inner,bmpSize); |
|
43 if (innerSize.iWidth<bmpSize.iWidth || innerSize.iHeight<bmpSize.iHeight) |
|
44 DrawPicture(aEnv,aControl,aGc,inner,aBitmap,aMask,ETrue); |
|
45 else |
|
46 DrawPicture(aEnv,aControl,aGc,inner,aBitmap,aMask,EFalse); |
|
47 aGc.SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
48 |
|
49 AknsDrawUtils::BackgroundBetweenRects( AknsUtils::SkinInstance(), |
|
50 AknsDrawUtils::ControlContext( &aControl ), &aControl, |
|
51 aGc, rect, inner ); |
|
52 } |
|
53 |
|
54 void LafImage::DrawPicture(const MLafEnv& aEnv,const CCoeControl& aControl,CWindowGc& aGc,const TRect& aRect, |
|
55 const CFbsBitmap& aBitmap,const CFbsBitmap* aMask,TBool aToBeClipped) |
|
56 { // static |
|
57 const TSize size=(aToBeClipped? aRect.Size() : aBitmap.SizeInPixels()); |
|
58 const TRect rect(size); |
|
59 if (aControl.IsDimmed()) |
|
60 { |
|
61 if (aMask) |
|
62 aGc.BitBltMasked(aRect.iTl,aEnv.Bitmap(TUid::Uid(KLafUidEikonGrayVal)),rect,aMask,ETrue); |
|
63 else |
|
64 aGc.BitBlt(aRect.iTl,&aBitmap,rect); |
|
65 return; |
|
66 } |
|
67 if (aMask) |
|
68 { |
|
69 // Reset the gc to make sure that the brush & pen are not used in blitting |
|
70 MCoeControlContext* ctrlCtx = aControl.ControlContext(); |
|
71 if ( ctrlCtx ) |
|
72 { |
|
73 ctrlCtx->ResetContext( aGc ); |
|
74 } |
|
75 else |
|
76 { |
|
77 aGc.Reset(); |
|
78 } |
|
79 aGc.BitBltMasked(aRect.iTl,&aBitmap,rect,aMask,ETrue); |
|
80 return; |
|
81 } |
|
82 aGc.BitBlt(aRect.iTl,&aBitmap,rect); |
|
83 } |