|
1 /* |
|
2 * Copyright (c) 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: skin variation class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cimcvuiappskinvariant.h" |
|
21 |
|
22 #include "cimcvappbitmapmapping.h" |
|
23 #include <aknappui.h> |
|
24 #include <AknsSkinInstance.h> // skins |
|
25 #include <AknsUtils.h> |
|
26 #include <AknsDrawUtils.h> |
|
27 #include <AknsBasicBackgroundControlContext.h> |
|
28 #include <AknUtils.h> |
|
29 #include <gulicon.h> |
|
30 // logs |
|
31 #include "imcvlogger.h" |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CIMCVUiAppSkinVariant::CIMCVUiAppSkinVariant |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CIMCVUiAppSkinVariant::CIMCVUiAppSkinVariant() |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CIMCVUiAppSkinVariant::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CIMCVUiAppSkinVariant::ConstructL( ) |
|
51 { |
|
52 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::ConstructL() start") ) ; |
|
53 TRect mainPane( 0,0,0,0 ); |
|
54 |
|
55 // Return value can be safely ignored. |
|
56 // from AknLayoutUtils::LayoutMetricsRect documentation: |
|
57 // |
|
58 // Returns EFalse for status pane descendants if requested |
|
59 // layout component is not available in current layout. For |
|
60 // other components returns always ETrue (returned rectangle is |
|
61 // from layout definition). |
|
62 // |
|
63 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, mainPane ); |
|
64 |
|
65 iBgContext = CAknsBasicBackgroundControlContext::NewL( |
|
66 KAknsIIDQsnBgAreaMain, mainPane, EFalse ); |
|
67 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::ConstructL() start") ) ; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CIMCVUiAppSkinVariant::NewL |
|
72 // Two-phased constructor. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CIMCVUiAppSkinVariant* CIMCVUiAppSkinVariant::NewL() |
|
76 { |
|
77 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::NewL() start") ); |
|
78 CIMCVUiAppSkinVariant* self = new( ELeave ) CIMCVUiAppSkinVariant(); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL( ); |
|
81 CleanupStack::Pop( self ); |
|
82 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::NewL() end") ); |
|
83 return self; |
|
84 } |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CIMCVUiAppSkinVariant::~CIMCVUiAppSkinVariant() |
|
87 // Destructor |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CIMCVUiAppSkinVariant::~CIMCVUiAppSkinVariant() |
|
91 { |
|
92 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::~CIMCVUiAppSkinVariant() start") ); |
|
93 delete iBgContext; |
|
94 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::~CIMCVUiAppSkinVariant() end") ); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CIMCVUiAppSkinVariant::ClearChatListBoxBackGround |
|
99 // (other items were commented in a header). |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CIMCVUiAppSkinVariant::ClearChatListBoxBackGround( CWindowGc& aGc, |
|
103 const TRect& aUsedPortionOfViewRect, |
|
104 MAknsControlContext* aContext ) |
|
105 { |
|
106 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::ClearChatListBoxBackGround() start") ); |
|
107 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
108 AknsDrawUtils::Background( skin, aContext, NULL, aGc, |
|
109 aUsedPortionOfViewRect ); |
|
110 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::ClearChatListBoxBackGround() end") ); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CIMCVUiAppSkinVariant::MainPaneBackgroundContext |
|
115 // (other items were commented in a header). |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 MAknsControlContext* CIMCVUiAppSkinVariant::MainPaneBackgroundContext() const |
|
119 { |
|
120 return iBgContext; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CIMCVUiAppSkinVariant::UpdateLayout |
|
125 // (other items were commented in a header). |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CIMCVUiAppSkinVariant::UpdateLayout() |
|
129 { |
|
130 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::UpdateLayout() start") ); |
|
131 TRect screen( 0, 0, 0, 0 ); |
|
132 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
133 iBgContext->SetRect( screen ); |
|
134 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::UpdateLayout() end") ); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CIMCVUiAppSkinVariant::DrawSkinnedEditor |
|
139 // (other items were commented in a header). |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 TBool CIMCVUiAppSkinVariant::DrawSkinnedEditor( const CCoeControl* aControl, |
|
143 CWindowGc& aGc, |
|
144 TRect& /*aParentRect*/, |
|
145 TRect& aEditorRect, |
|
146 TRect& aOutlineRect ) |
|
147 { |
|
148 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::DrawSkinnedEditor() start") ); |
|
149 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
150 |
|
151 // draw editor surroundings |
|
152 AknsDrawUtils::BackgroundBetweenRects( skin, MainPaneBackgroundContext(), |
|
153 aControl, aGc, aOutlineRect, |
|
154 aEditorRect ); |
|
155 |
|
156 TRect innerRect( aOutlineRect ); |
|
157 //why 6 ? don't ask me. It was 3x3 for 176x208. |
|
158 innerRect.Shrink( TSize( 6, 6 ) ); |
|
159 // draw editor frames |
|
160 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::DrawSkinnedEditor() end") ); |
|
161 return AknsDrawUtils::DrawFrame( skin, aGc, aOutlineRect, innerRect, |
|
162 KAknsIIDQsnFrInput, KAknsIIDQsnFrInputCenter ); |
|
163 |
|
164 } |
|
165 |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CIMCVUiAppSkinVariant::LoadBitmapL |
|
169 // (other items were commented in a header). |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 CGulIcon* CIMCVUiAppSkinVariant::LoadBitmapL( TInt aBitmapId, TInt aMaskId, |
|
173 const TDesC& aFullPath, TBool /*aOverrideBrand*/, |
|
174 TRgb* /*aCustomColor*/ ) |
|
175 { |
|
176 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::LoadBitmapL() start") ); |
|
177 CFbsBitmap* bitmap = NULL; |
|
178 CFbsBitmap* mask = NULL; |
|
179 |
|
180 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
181 |
|
182 TAknsItemID itemId( KAknsIIDNone ); |
|
183 TInt colorGroupId( 0 ); |
|
184 |
|
185 MapFromBitmapIdToAknsItemId( aBitmapId, itemId, colorGroupId ); |
|
186 |
|
187 if( colorGroupId != 0 ) |
|
188 { |
|
189 |
|
190 AknsUtils::CreateColorIconLC( skin, |
|
191 itemId, KAknsIIDQsnIconColors, colorGroupId, |
|
192 bitmap, mask, aFullPath, aBitmapId, aMaskId, KRgbBlack ); |
|
193 } |
|
194 else |
|
195 { |
|
196 AknsUtils::CreateIconLC( skin, |
|
197 itemId, |
|
198 bitmap, mask, aFullPath, aBitmapId, aMaskId ); |
|
199 } |
|
200 |
|
201 CGulIcon* gulIcon = CGulIcon::NewL( bitmap, mask ); |
|
202 CleanupStack::Pop( 2 ); // bitmap, mask |
|
203 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::LoadBitmapL() end") ); |
|
204 return gulIcon; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CIMCVUiAppSkinVariant::MapFromBitmapIdToAknsItemId |
|
209 // (other items were commented in a header). |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CIMCVUiAppSkinVariant::MapFromBitmapIdToAknsItemId( TInt aBitmapId, |
|
213 TAknsItemID& aItemId, TInt& aColorGroupId ) |
|
214 { |
|
215 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::MapFromBitmapIdToAknsItemId() start") ); |
|
216 for( TInt i( 0 ); KCABitmaps[i].iBitmapId != KErrNotFound; i++ ) |
|
217 { |
|
218 if( KCABitmaps[ i ].iBitmapId == aBitmapId ) |
|
219 { |
|
220 // found it |
|
221 aItemId = *(KCABitmaps[ i ].iItemId); |
|
222 aColorGroupId = KCABitmaps[ i ].iColorGroupId; |
|
223 return; |
|
224 } |
|
225 } |
|
226 |
|
227 IM_CV_LOGS(TXT("CIMCVUiAppSkinVariant::MapFromBitmapIdToAknsItemId() start") ); |
|
228 //__ASSERT_DEBUG( EFalse ); |
|
229 } |
|
230 |
|
231 // End of File |