|
1 /* |
|
2 * Copyright (c) 2006 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 "CCAPicture.h" |
|
21 #include "ChatDebugPrint.h" |
|
22 #include "ChatDefinitions.h" |
|
23 #include "fbs.h" |
|
24 #include <gulicon.h> |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CCAPicture::CCAPicture |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CCAPicture::CCAPicture( MGraphicsDeviceMap& aMap, CGulIcon* aIcon, |
|
31 TInt aIndex /* = -1 */, TBool aExternalIcon /* = ETrue */ ) |
|
32 : iIndex( aIndex ), |
|
33 iIcon( aIcon ), |
|
34 iExternalIcon( aExternalIcon ), |
|
35 iGfxMap( aMap ) |
|
36 { |
|
37 __ASSERT_ALWAYS( iIcon, |
|
38 User::Panic( KPanicText, EIconDoesNotExist ) ); |
|
39 |
|
40 SetTwips(); |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CCAPicture::~CCAPicture |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CCAPicture::~CCAPicture() |
|
48 { |
|
49 if ( !iExternalIcon ) |
|
50 { |
|
51 delete iIcon; |
|
52 } |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CCAPicture::LineBreakPossible |
|
57 // (other items were commented in a header). |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 TBool CCAPicture::LineBreakPossible( TUint /*aClass*/, |
|
61 TBool /*aBeforePicture*/, |
|
62 TBool /*aHaveSpaces*/ ) const |
|
63 { |
|
64 return EFalse; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CCAPicture::Draw |
|
69 // (other items were commented in a header). |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CCAPicture::Draw( CGraphicsContext& aGc, |
|
73 const TPoint& aTopLeft, |
|
74 const TRect& aClipRect, |
|
75 MGraphicsDeviceMap* /*aMap*/ ) const |
|
76 { |
|
77 TSize size( iIcon->Bitmap()->SizeInPixels() ); |
|
78 CBitmapContext& bc = static_cast<CBitmapContext&>( aGc ); |
|
79 |
|
80 CHAT_DP( D_CHAT_LIT( "CCAPicture::Draw %dx%d to %d,%d" ), |
|
81 size.iWidth, size.iHeight, aTopLeft.iX, aTopLeft.iY ); |
|
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 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CCAPicture::ExternalizeL |
|
98 // (other items were commented in a header). |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CCAPicture::ExternalizeL( RWriteStream& /*aStream*/ ) const |
|
102 { |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CCAPicture::GetOriginalSizeInTwips( |
|
107 // (other items were commented in a header). |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CCAPicture::GetOriginalSizeInTwips( TSize& aSize ) const |
|
111 { |
|
112 if ( iIcon->Bitmap() ) |
|
113 { |
|
114 aSize = iIcon->Bitmap()->SizeInTwips(); |
|
115 |
|
116 if ( aSize.iHeight == 0 || aSize.iWidth == 0 ) |
|
117 { |
|
118 SetTwips(); |
|
119 aSize = iIcon->Bitmap()->SizeInTwips(); |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CCAPicture::Index |
|
126 // (other items were commented in a header). |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 TInt CCAPicture::Index() const |
|
130 { |
|
131 return iIndex; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CCAPicture::SetTwips |
|
136 // (other items were commented in a header). |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CCAPicture::SetTwips() const |
|
140 { |
|
141 TSize sizeP( iIcon->Bitmap()->SizeInPixels() ); |
|
142 TSize sizeT( iGfxMap.HorizontalPixelsToTwips( sizeP.iWidth ), |
|
143 iGfxMap.VerticalPixelsToTwips( sizeP.iHeight ) ); |
|
144 iIcon->Bitmap()->SetSizeInTwips( sizeT ); |
|
145 |
|
146 CHAT_DP( D_CHAT_LIT( "CCAPicture::CCAPicture() %dx%d (%dx%d)" ), |
|
147 sizeP.iWidth, sizeP.iHeight, |
|
148 sizeT.iWidth, sizeT.iHeight ); |
|
149 } |