|
1 /* |
|
2 * Copyright (c) 2009 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: CPeninputArabicFingerHwrIndicator |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknsUtils.h> |
|
19 #include <barsread.h> |
|
20 |
|
21 #include "peninputfingerhwrarindicator.h" |
|
22 #include "peninputlayout.h" |
|
23 const TInt KInvalidResId = -1; |
|
24 const TInt KInvalidBmp = -1 ; |
|
25 const TInt KInvalidColorGroup = -1; |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CPeninputArabicFingerHwrIndicator::NewL |
|
30 // factory function |
|
31 // (other items were commented in a header). |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CPeninputArabicFingerHwrIndicator* CPeninputArabicFingerHwrIndicator::NewL(CFepUiLayout* aUiLayout, TInt aCtrlId) |
|
35 { |
|
36 CPeninputArabicFingerHwrIndicator* lable=new (ELeave) CPeninputArabicFingerHwrIndicator(aUiLayout,aCtrlId); |
|
37 |
|
38 CleanupStack::PushL(lable); |
|
39 lable->BaseConstructL(); |
|
40 CleanupStack::Pop(lable); |
|
41 |
|
42 return lable; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CPeninputArabicFingerHwrIndicator::CPeninputArabicFingerHwrIndicator |
|
47 // C++ default constructor |
|
48 // (other items were commented in a header). |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CPeninputArabicFingerHwrIndicator::CPeninputArabicFingerHwrIndicator(CFepUiLayout* aUiLayout, TInt aCtrlId) |
|
52 :CFepUiBaseCtrl(TRect(0,0,0,0),aUiLayout,aCtrlId) |
|
53 { |
|
54 SetControlType(EUserCtrlBase | ECtrlBaseCtrl); |
|
55 |
|
56 #ifdef __ALPHA_TRANCEPARENCY__ |
|
57 const TRgb KDefaultButtonBackCol = TRgb(30,30,30); |
|
58 #else |
|
59 const TRgb KDefaultButtonBackCol = TRgb(230,230,230); |
|
60 #endif |
|
61 |
|
62 SetBkColor(KDefaultButtonBackCol); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CPeninputArabicFingerHwrIndicator::~CPeninputArabicFingerHwrIndicator |
|
67 // Destructor |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CPeninputArabicFingerHwrIndicator::~CPeninputArabicFingerHwrIndicator() |
|
71 { |
|
72 |
|
73 } |
|
74 |
|
75 void CPeninputArabicFingerHwrIndicator::ConstructFromResourceL( TInt aResID ) |
|
76 { |
|
77 if (aResID == KInvalidResId) |
|
78 { |
|
79 User::Leave( KErrArgument ); |
|
80 } |
|
81 //DestroyRes(); |
|
82 |
|
83 TResourceReader reader; |
|
84 CCoeEnv::Static()->CreateResourceReaderLC(reader, aResID); |
|
85 |
|
86 // Read the file name of the bmps |
|
87 TPtrC bmpFileName = reader.ReadTPtrC(); |
|
88 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
89 TInt colorGroup = reader.ReadInt16(); |
|
90 TAknsItemID id; |
|
91 |
|
92 // Get the image ids and mask ids from resource |
|
93 TInt bmpId = reader.ReadInt16(); |
|
94 TInt bmpMskId = reader.ReadInt16(); |
|
95 |
|
96 // Read skin item id |
|
97 const TInt skinitemid = reader.ReadInt16(); |
|
98 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
99 |
|
100 if ( bmpId == KInvalidBmp || |
|
101 bmpMskId == KInvalidBmp || |
|
102 colorGroup == KInvalidColorGroup ) |
|
103 { |
|
104 User::Leave( KErrGeneral ); |
|
105 } |
|
106 |
|
107 CFbsBitmap* bmp; |
|
108 CFbsBitmap* bmpMask; |
|
109 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
110 id, |
|
111 KAknsIIDQsnIconColors, |
|
112 colorGroup, |
|
113 bmp, |
|
114 bmpMask, |
|
115 bmpFileName, |
|
116 bmpId, |
|
117 bmpMskId, |
|
118 TRgb() ); |
|
119 |
|
120 SetBitmapL(bmp); |
|
121 SetMaskBitmapL(bmpMask); |
|
122 CleanupStack::PopAndDestroy(); // reader |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CPeninputArabicFingerHwrIndicator::Draw |
|
127 // Draw the control |
|
128 // (other items were commented in a header). |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CPeninputArabicFingerHwrIndicator::Draw() |
|
132 { |
|
133 if(!AbleToDraw()) |
|
134 return; |
|
135 |
|
136 TRect rect = Rect(); |
|
137 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
138 gc->Activate(MaskBitmapDevice()); |
|
139 |
|
140 //clear the rect |
|
141 gc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
142 gc->SetBrushColor(TRgb(KTransparentColor));//transparency |
|
143 gc->SetPenStyle(CGraphicsContext::ENullPen); |
|
144 gc->DrawRect(rect); |
|
145 |
|
146 gc->Activate(BitmapDevice()); |
|
147 |
|
148 if (BackgroundBmp()) |
|
149 { |
|
150 if (BkMaskBmp()) |
|
151 { |
|
152 gc->DrawBitmapMasked(rect, BackgroundBmp(), BackgroundBmp()->SizeInPixels(), |
|
153 BkMaskBmp(), ETrue); |
|
154 } |
|
155 else |
|
156 { |
|
157 gc->DrawBitmap(rect, BackgroundBmp(), BackgroundBmp()->SizeInPixels()); |
|
158 } |
|
159 } |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CPeninputArabicFingerHwrIndicator::SetBitmapL |
|
164 // Set bitmap for given status |
|
165 // (other items were commented in a header). |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void CPeninputArabicFingerHwrIndicator::SetBitmapL(CFbsBitmap* aBitmap) |
|
169 { |
|
170 if(!aBitmap) |
|
171 { |
|
172 return; |
|
173 } |
|
174 |
|
175 SetBackgroundBitmapL(aBitmap); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // CPeninputArabicFingerHwrIndicator::SetMaskBitmapL |
|
180 // Set mask bitmap for given status |
|
181 // (other items were commented in a header). |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 void CPeninputArabicFingerHwrIndicator::SetMaskBitmapL(CFbsBitmap* aBmp) |
|
185 { |
|
186 if(!aBmp) |
|
187 { |
|
188 return; |
|
189 } |
|
190 |
|
191 SetBackgroundMaskBitmapL(aBmp); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // CPeninputArabicFingerHwrIndicator::SizeChanged |
|
196 // This methods shall be called by the container's SizeChanged handler |
|
197 // (other items were commented in a header). |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 void CPeninputArabicFingerHwrIndicator::SizeChanged(TRect aNewRect, TBool aIsReloadImages) |
|
201 { |
|
202 if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0) |
|
203 { |
|
204 return; |
|
205 } |
|
206 |
|
207 SetRect(aNewRect); |
|
208 |
|
209 if (aIsReloadImages) |
|
210 { |
|
211 ResizeBitmaps(aNewRect.Size()); |
|
212 } |
|
213 |
|
214 Draw(); |
|
215 UpdateArea(Rect(), EFalse); |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CPeninputArabicFingerHwrIndicator::ResizeBitmaps |
|
220 // This methods shall be called by the container's SizeChanged handler |
|
221 // (other items were commented in a header). |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CPeninputArabicFingerHwrIndicator::ResizeBitmaps(TSize aSize) |
|
225 { |
|
226 if (BkMaskBmp() && |
|
227 BkMaskBmp()->SizeInPixels() != aSize) |
|
228 { |
|
229 AknIconUtils::SetSize(BkMaskBmp(), aSize, EAspectRatioNotPreserved); |
|
230 } |
|
231 |
|
232 if (BackgroundBmp() && |
|
233 BackgroundBmp()->SizeInPixels() != aSize) |
|
234 { |
|
235 AknIconUtils::SetSize(BackgroundBmp(), aSize, EAspectRatioNotPreserved); |
|
236 } |
|
237 } |
|
238 |
|
239 // End Of File |