|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Picture wrapper for icons and smileys |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cimcvapppicture.h" |
|
21 #include "fbs.h" |
|
22 #include <gulicon.h> |
|
23 #include "imcvlogger.h" |
|
24 |
|
25 _LIT( KPanicText, "Smiley" ); |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CIMCVAppPicture::CIMCVAppPicture |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CIMCVAppPicture::CIMCVAppPicture( MGraphicsDeviceMap& aMap, CGulIcon* aIcon, |
|
32 TInt aIndex /* = -1 */, TBool aExternalIcon /* = ETrue */) |
|
33 : iIndex( aIndex ), |
|
34 iIcon( aIcon ), |
|
35 iExternalIcon( aExternalIcon ), |
|
36 iGfxMap( aMap ) |
|
37 { |
|
38 __ASSERT_ALWAYS( iIcon, |
|
39 User::Panic( KPanicText, 1 ) ); |
|
40 |
|
41 SetTwips(); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CIMCVAppPicture::~CIMCVAppPicture |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CIMCVAppPicture::~CIMCVAppPicture() |
|
49 { |
|
50 if ( !iExternalIcon ) |
|
51 { |
|
52 delete iIcon; |
|
53 } |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CIMCVAppPicture::LineBreakPossible |
|
58 // (other items were commented in a header). |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 TBool CIMCVAppPicture::LineBreakPossible( TUint /*aClass*/, |
|
62 TBool /*aBeforePicture*/, |
|
63 TBool /*aHaveSpaces*/ ) const |
|
64 { |
|
65 return EFalse; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CIMCVAppPicture::Draw |
|
70 // (other items were commented in a header). |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CIMCVAppPicture::Draw( CGraphicsContext& aGc, |
|
74 const TPoint& aTopLeft, |
|
75 const TRect& aClipRect, |
|
76 MGraphicsDeviceMap* /*aMap*/ ) const |
|
77 { |
|
78 IM_CV_LOGS(TXT("CIMCVAppPicture::Draw() start") ); |
|
79 TSize size( iIcon->Bitmap()->SizeInPixels() ); |
|
80 CBitmapContext& bc = static_cast<CBitmapContext&>( aGc ); |
|
81 |
|
82 |
|
83 aGc.Reset(); |
|
84 aGc.SetClippingRect( aClipRect ); |
|
85 |
|
86 if( iIcon->Mask() ) |
|
87 { |
|
88 bc.BitBltMasked( aTopLeft, iIcon->Bitmap(), size, iIcon->Mask(), ETrue ); |
|
89 } |
|
90 else |
|
91 { |
|
92 bc.BitBlt( aTopLeft, iIcon->Bitmap(), size ); |
|
93 } |
|
94 IM_CV_LOGS(TXT("CIMCVAppPicture::Draw() end") ); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CIMCVAppPicture::ExternalizeL |
|
99 // (other items were commented in a header). |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CIMCVAppPicture::ExternalizeL( RWriteStream& /*aStream*/ ) const |
|
103 { |
|
104 // nothing to be done here |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CIMCVAppPicture::GetOriginalSizeInTwips( |
|
109 // (other items were commented in a header). |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CIMCVAppPicture::GetOriginalSizeInTwips( TSize& aSize ) const |
|
113 { |
|
114 IM_CV_LOGS(TXT("CIMCVAppPicture::GetOriginalSizeInTwips() start") ); |
|
115 if ( iIcon->Bitmap() ) |
|
116 { |
|
117 aSize = iIcon->Bitmap()->SizeInTwips(); |
|
118 |
|
119 if( aSize.iHeight == 0 || aSize.iWidth == 0 ) |
|
120 { |
|
121 SetTwips(); |
|
122 aSize = iIcon->Bitmap()->SizeInTwips(); |
|
123 } |
|
124 } |
|
125 IM_CV_LOGS(TXT("CIMCVAppPicture::GetOriginalSizeInTwips() end") ); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CIMCVAppPicture::Index |
|
130 // (other items were commented in a header). |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 TInt CIMCVAppPicture::Index() const |
|
134 { |
|
135 return iIndex; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CIMCVAppPicture::SetTwips |
|
140 // (other items were commented in a header). |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 void CIMCVAppPicture::SetTwips() const |
|
144 { |
|
145 IM_CV_LOGS(TXT("CIMCVAppPicture::SetTwips() start") ); |
|
146 TSize sizeP( iIcon->Bitmap()->SizeInPixels() ); |
|
147 TSize sizeT( iGfxMap.HorizontalPixelsToTwips( sizeP.iWidth ), |
|
148 iGfxMap.VerticalPixelsToTwips( sizeP.iHeight ) ); |
|
149 iIcon->Bitmap()->SetSizeInTwips( sizeT ); |
|
150 |
|
151 IM_CV_LOGS(TXT("CIMCVAppPicture::SetTwips() end") ); |
|
152 } |