44
|
1 |
/*
|
|
2 |
* Copyright (c) 2009-2010 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::CreateIconL(AknsUtils::SkinInstance(),
|
|
110 |
id,
|
|
111 |
bmp,
|
|
112 |
bmpMask,
|
|
113 |
bmpFileName,
|
|
114 |
bmpId,
|
|
115 |
bmpMskId);
|
|
116 |
/*AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
|
|
117 |
id,
|
|
118 |
KAknsIIDQsnIconColors,
|
|
119 |
colorGroup,
|
|
120 |
bmp,
|
|
121 |
bmpMask,
|
|
122 |
bmpFileName,
|
|
123 |
bmpId,
|
|
124 |
bmpMskId,
|
|
125 |
TRgb() );*/
|
|
126 |
|
|
127 |
SetBitmapL(bmp);
|
|
128 |
SetMaskBitmapL(bmpMask);
|
|
129 |
CleanupStack::PopAndDestroy(); // reader
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
// CPeninputArabicFingerHwrIndicator::Draw
|
|
134 |
// Draw the control
|
|
135 |
// (other items were commented in a header).
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CPeninputArabicFingerHwrIndicator::Draw()
|
|
139 |
{
|
|
140 |
if(!AbleToDraw())
|
|
141 |
return;
|
|
142 |
|
|
143 |
TRect rect = Rect();
|
|
144 |
CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
|
|
145 |
gc->Activate(MaskBitmapDevice());
|
|
146 |
|
|
147 |
//clear the rect
|
|
148 |
gc->SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
149 |
gc->SetBrushColor(TRgb(KTransparentColor));//transparency
|
|
150 |
gc->SetPenStyle(CGraphicsContext::ENullPen);
|
|
151 |
gc->DrawRect(rect);
|
|
152 |
|
|
153 |
gc->Activate(BitmapDevice());
|
|
154 |
|
|
155 |
if (BackgroundBmp())
|
|
156 |
{
|
|
157 |
if (BkMaskBmp())
|
|
158 |
{
|
|
159 |
gc->DrawBitmapMasked(rect, BackgroundBmp(), BackgroundBmp()->SizeInPixels(),
|
|
160 |
BkMaskBmp(), ETrue);
|
|
161 |
}
|
|
162 |
else
|
|
163 |
{
|
|
164 |
gc->DrawBitmap(rect, BackgroundBmp(), BackgroundBmp()->SizeInPixels());
|
|
165 |
}
|
|
166 |
}
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
// CPeninputArabicFingerHwrIndicator::SetBitmapL
|
|
171 |
// Set bitmap for given status
|
|
172 |
// (other items were commented in a header).
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
void CPeninputArabicFingerHwrIndicator::SetBitmapL(CFbsBitmap* aBitmap)
|
|
176 |
{
|
|
177 |
if(!aBitmap)
|
|
178 |
{
|
|
179 |
return;
|
|
180 |
}
|
|
181 |
|
|
182 |
SetBackgroundBitmapL(aBitmap);
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
// CPeninputArabicFingerHwrIndicator::SetMaskBitmapL
|
|
187 |
// Set mask bitmap for given status
|
|
188 |
// (other items were commented in a header).
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CPeninputArabicFingerHwrIndicator::SetMaskBitmapL(CFbsBitmap* aBmp)
|
|
192 |
{
|
|
193 |
if(!aBmp)
|
|
194 |
{
|
|
195 |
return;
|
|
196 |
}
|
|
197 |
|
|
198 |
SetBackgroundMaskBitmapL(aBmp);
|
|
199 |
}
|
|
200 |
|
|
201 |
// ---------------------------------------------------------------------------
|
|
202 |
// CPeninputArabicFingerHwrIndicator::SizeChanged
|
|
203 |
// This methods shall be called by the container's SizeChanged handler
|
|
204 |
// (other items were commented in a header).
|
|
205 |
// ---------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
void CPeninputArabicFingerHwrIndicator::SizeChanged(TRect aNewRect, TBool aIsReloadImages)
|
|
208 |
{
|
|
209 |
if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0)
|
|
210 |
{
|
|
211 |
return;
|
|
212 |
}
|
|
213 |
|
|
214 |
SetRect(aNewRect);
|
|
215 |
|
|
216 |
if (aIsReloadImages)
|
|
217 |
{
|
|
218 |
ResizeBitmaps(aNewRect.Size());
|
|
219 |
}
|
|
220 |
|
|
221 |
Draw();
|
|
222 |
UpdateArea(Rect(), EFalse);
|
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
// CPeninputArabicFingerHwrIndicator::ResizeBitmaps
|
|
227 |
// This methods shall be called by the container's SizeChanged handler
|
|
228 |
// (other items were commented in a header).
|
|
229 |
// ---------------------------------------------------------------------------
|
|
230 |
//
|
|
231 |
void CPeninputArabicFingerHwrIndicator::ResizeBitmaps(TSize aSize)
|
|
232 |
{
|
|
233 |
if (BkMaskBmp() &&
|
|
234 |
BkMaskBmp()->SizeInPixels() != aSize)
|
|
235 |
{
|
|
236 |
AknIconUtils::SetSize(BkMaskBmp(), aSize, EAspectRatioNotPreserved);
|
|
237 |
}
|
|
238 |
|
|
239 |
if (BackgroundBmp() &&
|
|
240 |
BackgroundBmp()->SizeInPixels() != aSize)
|
|
241 |
{
|
|
242 |
AknIconUtils::SetSize(BackgroundBmp(), aSize, EAspectRatioNotPreserved);
|
|
243 |
}
|
|
244 |
}
|
|
245 |
|
|
246 |
// End Of File
|