author | Simon Howkins <simonh@symbian.org> |
Fri, 12 Nov 2010 15:05:47 +0000 | |
branch | RCL_3 |
changeset 48 | 1aca8c36e17c |
parent 46 | ed95320285d0 |
permissions | -rw-r--r-- |
35 | 1 |
/* |
2 |
* Copyright (c) 2006 - 2007 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: |
|
15 |
* This class is the container class of the CTouchScreenCalibView. |
|
16 |
* Is used to show tap target animation. |
|
17 |
* |
|
18 |
*/ |
|
19 |
||
20 |
||
21 |
// SYSTEM INCLUDES |
|
22 |
#include <aknappui.h> |
|
23 |
#include <aknnotewrappers.h> |
|
24 |
#include <barsread.h> |
|
25 |
#include <AknBitmapAnimation.h> |
|
26 |
#include <ConeResLoader.h> |
|
27 |
#include <AknBidiTextUtils.h> |
|
46
ed95320285d0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
28 |
#include <TouchScreenCalib_anim.rsg> |
ed95320285d0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
29 |
#include <TouchScreenCalib.rsg> |
35 | 30 |
#include <touchscreencalib.mbg> |
31 |
||
32 |
// USER INCLUDES |
|
33 |
#include "TouchScreenCalibView.h" |
|
34 |
#include "TouchScreenCalibDefines.h" |
|
35 |
#include "TouchScreenCalibAppUi.h" |
|
36 |
||
37 |
// CONSTANTS |
|
38 |
_LIT( KTargetAnimationResource, "z:TouchScreenCalib_anim.rsc" ); |
|
39 |
||
40 |
// ================= MEMBER FUNCTIONS ======================= |
|
41 |
||
42 |
// --------------------------------------------------------------------------- |
|
43 |
// CTouchScreenCalibView::ConstructL() |
|
44 |
// Symbian 2nd phase constructor can leave. |
|
45 |
// --------------------------------------------------------------------------- |
|
46 |
void CTouchScreenCalibView::ConstructL() |
|
47 |
{ |
|
48 |
TRACES("CTouchScreenCalibView::ConstructL()"); |
|
49 |
||
50 |
CreateWindowL(); |
|
51 |
||
52 |
iAnimImageRect.iAnimImageRect1 = iTouchScreenCalibAppUi->GetAnimImageRect(1); |
|
53 |
iAnimImageRect.iAnimImageRect2 = iTouchScreenCalibAppUi->GetAnimImageRect(2); |
|
54 |
iAnimImageRect.iAnimImageRect3 = iTouchScreenCalibAppUi->GetAnimImageRect(3); |
|
55 |
iAnimImageRect.iAnimImageRect4 = iTouchScreenCalibAppUi->GetAnimImageRect(4); |
|
56 |
||
57 |
// Parse filename of bitmaps |
|
58 |
_LIT( KDirAndFile, "z:TouchScreenCalib.mif" ); |
|
59 |
TParse* fp1 = new(ELeave) TParse(); |
|
60 |
fp1->Set(KDirAndFile, &KDC_APP_BITMAP_DIR, NULL); |
|
61 |
TFileName fileName( fp1->FullName() ); |
|
62 |
TRACES1("CTouchScreenCalibImage::CreateIconL(): Image: %S", &(fp1->FullName()) ); |
|
63 |
delete fp1; |
|
64 |
||
65 |
AknIconUtils::CreateIconL( iBitmap, |
|
66 |
iBitmapMask, |
|
67 |
fileName, |
|
68 |
EMbmTouchscreencalibQgn_graf_screencalib, |
|
69 |
EMbmTouchscreencalibQgn_graf_screencalib_mask); |
|
70 |
||
71 |
iAvkonAppUi->StatusPane()->MakeVisible(EFalse); |
|
72 |
||
73 |
TRACES("CTouchScreenCalibView::ConstructL(): Animation loading started"); |
|
74 |
iAnim = CAknBitmapAnimation::NewL(); |
|
75 |
iAnim->SetContainerWindowL( *this ); |
|
76 |
iAnim->SetScaleModeForAnimationFrames(EAspectRatioPreservedAndUnusedSpaceRemoved); |
|
77 |
TResourceReader rr; |
|
78 |
RConeResourceLoader loader( *iCoeEnv ); |
|
79 |
||
80 |
TParse* fp = new(ELeave) TParse(); |
|
81 |
fp->Set(KTargetAnimationResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
82 |
TRACES1("CTouchScreenCalibView::ConstructL(): Animated target resource path: %S", &fp->FullName()); |
|
83 |
TFileName name( fp->FullName() ); |
|
84 |
delete fp; |
|
85 |
TInt fileError = loader.Open( name ); |
|
86 |
if ( fileError == KErrNone ) |
|
87 |
{ |
|
88 |
CleanupClosePushL( loader ); |
|
89 |
iCoeEnv->CreateResourceReaderLC(rr, R_SHUTDOWN_ANIM); |
|
90 |
TRAPD(err, iAnim->ConstructFromResourceL( rr )); |
|
91 |
if( err == KErrNone ) |
|
92 |
{ |
|
93 |
TResourceReader timeReader; |
|
94 |
iCoeEnv->CreateResourceReaderLC(timeReader, R_ANIM_DURATION); |
|
95 |
CleanupStack::PopAndDestroy(); // pop timeReader |
|
96 |
iAnim->SetPosition(TPoint(0,0)); |
|
97 |
iAnim->SetSize(TSize(0,0)); |
|
98 |
TRACES("CTouchScreenCalibView::ConstructL(): animation succesfully loaded"); |
|
99 |
} |
|
100 |
else |
|
101 |
{ |
|
102 |
TRACES("CTouchScreenCalibView::ConstructL(): animation loading failed"); |
|
103 |
} |
|
104 |
CleanupStack::PopAndDestroy(); //pop rr |
|
105 |
TRACES("CTouchScreenCalibView::ConstructL(): animation loading ended"); |
|
106 |
CleanupStack::PopAndDestroy(); //pop loader |
|
107 |
} |
|
108 |
else |
|
109 |
{ |
|
110 |
TRACES("CTouchScreenCalibView::ConstructL(): resource file loading failed"); |
|
111 |
} |
|
112 |
||
113 |
SetRect(iAvkonAppUi->ApplicationRect()); |
|
114 |
ActivateL(); |
|
115 |
||
116 |
iFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont); |
|
117 |
iText = new( ELeave ) CArrayPtrFlat<HBufC>( 20 ); |
|
118 |
||
119 |
TApaTask self(iCoeEnv->WsSession()); |
|
120 |
self.SetWgId(iCoeEnv->RootWin().Identifier()); |
|
121 |
self.BringToForeground(); |
|
122 |
||
123 |
if (iTouchScreenCalibAppUi->FirstBoot()) |
|
124 |
{ |
|
125 |
Window().SetOrdinalPosition( 0, ECoeWinPriorityAlwaysAtFront + 10000 ); |
|
126 |
} |
|
127 |
else |
|
128 |
{ |
|
129 |
Window().SetOrdinalPosition( 0, ECoeWinPriorityHigh + 1 ); |
|
130 |
} |
|
131 |
iTouchFeedback = MTouchFeedback::Instance(); |
|
132 |
||
133 |
TRACES("CTouchScreenCalibView::ConstructL(): ConstructL ended"); |
|
134 |
} |
|
135 |
||
136 |
// ----------------------------------------------------------------------------- |
|
137 |
// CTouchScreenCalibView::NewL |
|
138 |
// Two-phased constructor. |
|
139 |
// ----------------------------------------------------------------------------- |
|
140 |
// |
|
141 |
CTouchScreenCalibView* CTouchScreenCalibView::NewL( CTouchScreenCalibAppUi* aTouchScreenCalibAppUi ) |
|
142 |
{ |
|
143 |
TRACES("CTouchScreenCalibView::NewL()"); |
|
144 |
CTouchScreenCalibView* self = new (ELeave) CTouchScreenCalibView( aTouchScreenCalibAppUi ); |
|
145 |
CleanupStack::PushL(self); |
|
146 |
self->ConstructL(); |
|
147 |
CleanupStack::Pop(); |
|
148 |
return self; |
|
149 |
} |
|
150 |
||
151 |
// --------------------------------------------------------- |
|
152 |
// CTouchScreenCalibView::CTouchScreenCalibView() |
|
153 |
// --------------------------------------------------------- |
|
154 |
CTouchScreenCalibView::CTouchScreenCalibView( CTouchScreenCalibAppUi* aTouchScreenCalibAppUi ) : |
|
155 |
iTouchScreenCalibAppUi( aTouchScreenCalibAppUi ), |
|
156 |
iAnimationShowing( EFalse ), |
|
157 |
iAnimationCancelled ( EFalse ), |
|
158 |
iText( NULL ), |
|
159 |
iCalibrationCompleted( EFalse ) |
|
160 |
{ |
|
161 |
TRACES("CTouchScreenCalibView::CTouchScreenCalibView()"); |
|
162 |
TRACES("CTouchScreenCalibView::CTouchScreenCalibView(): End"); |
|
163 |
} |
|
164 |
||
165 |
// --------------------------------------------------------------------------- |
|
166 |
// CTouchScreenCalibView::UpdateL( TAknLayoutText aTextLayout ) |
|
167 |
// --------------------------------------------------------------------------- |
|
168 |
void CTouchScreenCalibView::UpdateL( TAknLayoutText aTextLayout ) |
|
169 |
{ |
|
170 |
TRACES("CTouchScreenCalibView::UpdateL()"); |
|
171 |
||
172 |
TRect rect = iTouchScreenCalibAppUi->GetAnimImageRect(); |
|
173 |
||
174 |
SetTextL(aTextLayout); |
|
175 |
EndAnimation(); |
|
176 |
DrawDeferred(); |
|
177 |
||
178 |
TPoint pos = TPoint(rect.iTl.iX, rect.iTl.iY); |
|
179 |
TSize size = TSize(rect.iBr.iX-rect.iTl.iX, rect.iBr.iY-rect.iTl.iY); |
|
180 |
iAnim->SetPosition(pos); |
|
181 |
iAnim->SetSize(size); |
|
182 |
||
183 |
TRAPD(err, iAnim->StartAnimationL()); |
|
184 |
if ( err != KErrNone ) |
|
185 |
{ |
|
186 |
TRACES("CTouchScreenCalibView::UpdateL(): Starting animation failed"); |
|
187 |
} |
|
188 |
||
189 |
TRACES("CTouchScreenCalibView::UpdateL(): End"); |
|
190 |
} |
|
191 |
||
192 |
// --------------------------------------------------------------------------- |
|
193 |
// CTouchScreenCalibView::DrawEndingBackground() |
|
194 |
// --------------------------------------------------------------------------- |
|
195 |
void CTouchScreenCalibView::DrawEndingBackground() |
|
196 |
{ |
|
197 |
TRACES("CTouchScreenCalibView::DrawEndingBackground()"); |
|
198 |
iCalibrationCompleted = ETrue; |
|
199 |
SetRect( iAvkonAppUi->ApplicationRect() ); |
|
200 |
EndAnimation(); |
|
201 |
DrawNow(); |
|
202 |
TRACES("CTouchScreenCalibView::DrawEndingBackground(): End"); |
|
203 |
} |
|
204 |
||
205 |
// --------------------------------------------------------------------------- |
|
206 |
// CTouchScreenCalibView::EndTargetAnimation() |
|
207 |
// --------------------------------------------------------------------------- |
|
208 |
void CTouchScreenCalibView::EndTargetAnimation() |
|
209 |
{ |
|
210 |
TRACES("CTouchScreenCalibView::EndTargetAnimation()"); |
|
211 |
EndAnimation(); |
|
212 |
DrawNow(); |
|
213 |
TRACES("CTouchScreenCalibView::EndTargetAnimation(): End"); |
|
214 |
} |
|
215 |
||
216 |
// --------------------------------------------------------------------------- |
|
217 |
// CTouchScreenCalibView::~CTouchScreenCalibView() |
|
218 |
// --------------------------------------------------------------------------- |
|
219 |
CTouchScreenCalibView::~CTouchScreenCalibView() |
|
220 |
{ |
|
221 |
TRACES("CTouchScreenCalibView::~CTouchScreenCalibView() begin"); |
|
222 |
||
223 |
if( iAnim ) |
|
224 |
{ |
|
225 |
if( iAnimationShowing ) |
|
226 |
{ |
|
227 |
iAnim->CancelAnimation(); |
|
228 |
TRACES("CTouchScreenCalibView::~CTouchScreenCalibView() animation cancelled"); |
|
229 |
} |
|
230 |
} |
|
231 |
delete iAnim; |
|
232 |
TRACES("CTouchScreenCalibView::~CTouchScreenCalibView() iAnim deleted"); |
|
233 |
||
234 |
if ( iText ) |
|
235 |
{ |
|
236 |
iText->ResetAndDestroy(); |
|
237 |
delete iText; |
|
238 |
iText = NULL; |
|
239 |
} |
|
240 |
||
241 |
delete iBitmap; |
|
242 |
delete iBitmapMask; |
|
243 |
||
244 |
TRACES("CTouchScreenCalibView::~CTouchScreenCalibView() end"); |
|
245 |
} |
|
246 |
||
247 |
// --------------------------------------------------------------------------- |
|
248 |
// CTouchScreenCalibView::ComponentControl(TInt aIndex) |
|
249 |
// --------------------------------------------------------------------------- |
|
250 |
CCoeControl* CTouchScreenCalibView::ComponentControl(TInt aIndex) const |
|
251 |
{ |
|
252 |
switch ( aIndex ) |
|
253 |
{ |
|
254 |
case 0: |
|
255 |
{ |
|
256 |
return iAnim; |
|
257 |
} |
|
258 |
default: |
|
259 |
{ |
|
260 |
return NULL; |
|
261 |
} |
|
262 |
} |
|
263 |
} |
|
264 |
||
265 |
// --------------------------------------------------------------------------- |
|
266 |
// CTouchScreenCalibView::CountComponentControls() |
|
267 |
// --------------------------------------------------------------------------- |
|
268 |
TInt CTouchScreenCalibView::CountComponentControls() const |
|
269 |
{ |
|
270 |
return iAnim ? 1 : 0; // return nbr of controls inside this container |
|
271 |
} |
|
272 |
||
273 |
// --------------------------------------------------------------------------- |
|
274 |
// CTouchScreenCalibView::Draw(const TRect& aRect) const |
|
275 |
// --------------------------------------------------------------------------- |
|
276 |
void CTouchScreenCalibView::Draw(const TRect& ) const |
|
277 |
{ |
|
278 |
TRACES("CTouchScreenCalibView::Draw()"); |
|
279 |
DrawBackground(); |
|
280 |
if (!iCalibrationCompleted) |
|
281 |
{ |
|
282 |
DrawText(); |
|
283 |
ShowImage(iAnimImageRect.iAnimImageRect1); |
|
284 |
ShowImage(iAnimImageRect.iAnimImageRect2); |
|
285 |
ShowImage(iAnimImageRect.iAnimImageRect3); |
|
286 |
ShowImage(iAnimImageRect.iAnimImageRect4); |
|
287 |
} |
|
288 |
TRACES("CTouchScreenCalibView::Draw(): End"); |
|
289 |
} |
|
290 |
||
291 |
// --------------------------------------------------------------------------- |
|
292 |
// CTouchScreenCalibView::SizeChanged() |
|
293 |
// --------------------------------------------------------------------------- |
|
294 |
void CTouchScreenCalibView::SizeChanged() |
|
295 |
{ |
|
296 |
if( iAnim ) |
|
297 |
{ |
|
298 |
iAnim->SetRect(Rect()); |
|
299 |
} |
|
300 |
} |
|
301 |
||
302 |
// --------------------------------------------------------------------------- |
|
303 |
// CTouchScreenCalibView::EndAnimation() |
|
304 |
// --------------------------------------------------------------------------- |
|
305 |
void CTouchScreenCalibView::EndAnimation() |
|
306 |
{ |
|
307 |
TRACES("CTouchScreenCalibView::EndAnimation()"); |
|
308 |
iAnim->CancelAnimation(); |
|
309 |
TRACES("CTouchScreenCalibView::EndAnimation(): End"); |
|
310 |
} |
|
311 |
||
312 |
// --------------------------------------------------------------------------- |
|
313 |
// CTouchScreenCalibView::HandleControlEventL(...) |
|
314 |
// --------------------------------------------------------------------------- |
|
315 |
void CTouchScreenCalibView::HandleControlEventL( |
|
316 |
CCoeControl* , |
|
317 |
TCoeEvent ) |
|
318 |
{ |
|
319 |
//pure virtual from MCoeControlObserver |
|
320 |
TRACES("CTouchScreenCalibView::HandleControlEventL()"); |
|
321 |
} |
|
322 |
||
323 |
// --------------------------------------------------------------------------- |
|
324 |
// CTouchScreenCalibView::OfferKeyEventL(...) |
|
325 |
// --------------------------------------------------------------------------- |
|
326 |
TKeyResponse CTouchScreenCalibView::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType) |
|
327 |
{ |
|
328 |
TRACES("CTouchScreenCalibView::OfferKeyEventL()"); |
|
329 |
iTouchScreenCalibAppUi->HandleKeyL( aKeyEvent, aType ); |
|
330 |
TRACES("CTouchScreenCalibView::OfferKeyEventL(): End: return EKeyWasConsumed"); |
|
331 |
return EKeyWasConsumed; |
|
332 |
} |
|
333 |
||
334 |
// ---------------------------------------------------- |
|
335 |
// CTouchScreenCalibView::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
336 |
// ---------------------------------------------------- |
|
337 |
TKeyResponse CTouchScreenCalibView::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
338 |
{ |
|
339 |
TRACES("CTouchScreenCalibView::HandleKeyEventL()"); |
|
340 |
iTouchScreenCalibAppUi->HandleKeyL( aKeyEvent, aType ); |
|
341 |
TRACES("CTouchScreenCalibView::HandleKeyEventL(): End: return EKeyWasConsumed"); |
|
342 |
return EKeyWasConsumed; |
|
343 |
} |
|
344 |
||
345 |
// ---------------------------------------------------- |
|
346 |
// CTouchScreenCalibView::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
347 |
// ---------------------------------------------------- |
|
348 |
void CTouchScreenCalibView::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
349 |
{ |
|
350 |
TRACES("CTouchScreenCalibView::HandlePointerEventL()"); |
|
351 |
if (aPointerEvent.iType == TPointerEvent::EButton1Up) |
|
352 |
{ |
|
353 |
TRACES("CTouchScreenCalibView::HandlePointerEventL(): EButton1Up"); |
|
354 |
TRACES1("CTouchScreenCalibView::HandlePointerEventL(): X = %d",aPointerEvent.iPosition.iX); |
|
355 |
TRACES1("CTouchScreenCalibView::HandlePointerEventL(): Y = %d",aPointerEvent.iPosition.iY); |
|
356 |
||
357 |
TPoint pos; |
|
358 |
||
359 |
pos.iX = aPointerEvent.iPosition.iX; |
|
360 |
pos.iY = aPointerEvent.iPosition.iY; |
|
361 |
if (Validate(pos)) |
|
362 |
{ |
|
363 |
iTouchFeedback->InstantFeedback( ETouchFeedbackBasic ); |
|
364 |
iTouchScreenCalibAppUi->HandlePointerL( pos ); |
|
365 |
} |
|
366 |
} |
|
367 |
TRACES("CTouchScreenCalibView::HandlePointerEventL(): End --------------- Waiting for next event -------------"); |
|
368 |
} |
|
369 |
||
370 |
// ---------------------------------------------------- |
|
371 |
// CTouchScreenCalibView::Validate(TPoint aPos) |
|
372 |
// ---------------------------------------------------- |
|
373 |
TBool CTouchScreenCalibView::Validate(TPoint aPos) |
|
374 |
{ |
|
375 |
TRACES("CTouchScreenCalibView::Validate()"); |
|
376 |
TInt retval( EFalse ); |
|
377 |
||
378 |
if ((aPos.iX > iTouchScreenCalibAppUi->GetAnimImageRect().iTl.iX) && |
|
379 |
(aPos.iX < iTouchScreenCalibAppUi->GetAnimImageRect().iBr.iX) && |
|
380 |
(aPos.iY > iTouchScreenCalibAppUi->GetAnimImageRect().iTl.iY) && |
|
381 |
(aPos.iY < iTouchScreenCalibAppUi->GetAnimImageRect().iBr.iY)) |
|
382 |
{ |
|
383 |
retval = ETrue; |
|
384 |
} |
|
385 |
TRACES1("CTouchScreenCalibView::Validate(): End: Return %d",retval); |
|
386 |
return retval; |
|
387 |
} |
|
388 |
||
389 |
// --------------------------------------------------------------------------- |
|
390 |
// CTouchScreenCalibView::DrawBackground() const |
|
391 |
// --------------------------------------------------------------------------- |
|
392 |
void CTouchScreenCalibView::DrawBackground() const |
|
393 |
{ |
|
394 |
TRACES("CTouchScreenCalibView::DrawBackground()"); |
|
395 |
CWindowGc& gc = SystemGc(); |
|
396 |
TRect rect = iAvkonAppUi->ApplicationRect(); |
|
397 |
gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
398 |
gc.SetBrushColor(KRgbWhite); |
|
399 |
gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
400 |
gc.DrawRect(rect); |
|
401 |
ControlEnv()->WsSession().Flush(); // force draw of the context |
|
402 |
TRACES("CTouchScreenCalibView::DrawBackground(): End"); |
|
403 |
} |
|
404 |
||
405 |
// --------------------------------------------------------------------------- |
|
406 |
// CTouchScreenCalibView::DrawText() |
|
407 |
// --------------------------------------------------------------------------- |
|
408 |
void CTouchScreenCalibView::DrawText() const |
|
409 |
{ |
|
410 |
TRACES("CTouchScreenCalibView::DrawText()"); |
|
411 |
||
412 |
CWindowGc& gc = SystemGc(); |
|
413 |
||
414 |
gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
415 |
||
416 |
gc.UseFont( iFont ); |
|
417 |
||
418 |
gc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
419 |
||
420 |
TPoint position( 0, 0 ); |
|
421 |
TPoint topLeft; |
|
422 |
position = iTextTopLeft; |
|
423 |
||
424 |
for ( TInt index = 0 ; |
|
425 |
index < iText->Count(); |
|
426 |
index++, position.iY += iTextBaselineOffset ) |
|
427 |
{ |
|
428 |
HBufC* text = (*iText)[ index ]; |
|
429 |
if ( text ) |
|
430 |
{ |
|
431 |
topLeft = TPoint( position.iX, position.iY - iTextBaselineOffset ); |
|
432 |
gc.SetPenColor(iTextColor); |
|
433 |
TRACES2("CTouchScreenCalibView::DrawText(): TopLeft: %d, %d", topLeft.iX, topLeft.iY); |
|
434 |
gc.DrawText( *text, |
|
435 |
TRect( topLeft, iTextSize ), |
|
436 |
iTextBaselineOffset, |
|
437 |
iTextAlignment ); |
|
438 |
} |
|
439 |
} |
|
440 |
ControlEnv()->WsSession().Flush(); // force draw of the context |
|
441 |
gc.DiscardFont(); |
|
442 |
TRACES("CTouchScreenCalibView::DrawText(): End"); |
|
443 |
} |
|
444 |
||
445 |
// ----------------------------------------------------------------------------- |
|
446 |
// CTouchScreenCalibView::SetTextL(TAknLayoutText aTextLayout) |
|
447 |
// ----------------------------------------------------------------------------- |
|
448 |
void CTouchScreenCalibView::SetTextL(TAknLayoutText aTextLayout) |
|
449 |
{ |
|
450 |
TRACES("CTouchScreenCalibView::SetTextL()"); |
|
451 |
||
452 |
TInt textLineWidth; |
|
453 |
||
454 |
TRACES2("CTouchScreenCalibView::SetTextL(): Text rect top: X:%d Y:%d",aTextLayout.TextRect().iTl.iX, aTextLayout.TextRect().iTl.iY); |
|
455 |
TRACES2("CTouchScreenCalibView::SetTextL(): Text rect:bot: X:%d Y:%d",aTextLayout.TextRect().iBr.iX, aTextLayout.TextRect().iBr.iY); |
|
456 |
||
457 |
textLineWidth = aTextLayout.TextRect().Width(); |
|
458 |
||
459 |
iTextTopLeft = TPoint(aTextLayout.TextRect().iTl.iX, aTextLayout.TextRect().iTl.iY); |
|
460 |
||
461 |
iTextBaselineOffset = iFont->HeightInPixels() * 4 / 3; |
|
462 |
||
463 |
iTextSize = TSize(textLineWidth, iTextBaselineOffset + iFont->DescentInPixels()); |
|
464 |
||
465 |
iTextColor = aTextLayout.Color(); |
|
466 |
||
467 |
iTextAlignment = CGraphicsContext::ECenter; |
|
468 |
||
469 |
HBufC* mainText1 = StringLoader::LoadLC(R_QTN_TOUCH_SCREEN_CALI_INSTR_GEN, |
|
470 |
iTouchScreenCalibAppUi->GetCalibrationStep()); |
|
471 |
||
472 |
HBufC* mainText2; |
|
473 |
if (iTouchScreenCalibAppUi->FirstBoot()) |
|
474 |
{ |
|
475 |
mainText2 = CEikonEnv::Static()->AllocReadResourceLC(R_QTN_TOUCH_SCREEN_CALI_INSTR_RES ); |
|
476 |
} |
|
477 |
else |
|
478 |
{ |
|
479 |
mainText2 = CEikonEnv::Static()->AllocReadResourceLC(R_QTN_TOUCH_SCREEN_CALI_INSTR_CAN ); |
|
480 |
} |
|
481 |
||
482 |
TBuf<256> text; |
|
483 |
text.Copy( mainText1->Des() ); |
|
484 |
_LIT(KLineChange, "\n"); |
|
485 |
text.Append(KLineChange); |
|
486 |
text.Append(mainText2->Des()); |
|
487 |
||
488 |
TRACES1("CTouchScreenCalibView::SetTextL(): text: %S",&text); |
|
489 |
||
490 |
CArrayFix<TPtrC>* wrappedArray = |
|
491 |
new( ELeave ) CArrayFixFlat<TPtrC>( 10 ); |
|
492 |
CleanupStack::PushL( wrappedArray ); |
|
493 |
||
494 |
HBufC* dataToDestroy = |
|
495 |
AknBidiTextUtils::ConvertToVisualAndWrapToArrayL( |
|
496 |
text, textLineWidth, *iFont, *wrappedArray |
|
497 |
); |
|
498 |
||
499 |
TInt numLines( wrappedArray->Count() ); |
|
500 |
TRACES1("CTouchScreenCalibView::SetTextL(): Number of lines: %d",numLines ); |
|
501 |
||
502 |
if ( iText ) |
|
503 |
{ |
|
504 |
iText->ResetAndDestroy(); |
|
505 |
delete iText; |
|
506 |
iText = NULL; |
|
507 |
} |
|
508 |
iText = new( ELeave ) CArrayPtrFlat<HBufC>( 20 ); |
|
509 |
||
510 |
for ( TInt i = 0 ; i < numLines ; i++ ) |
|
511 |
{ |
|
512 |
HBufC* line = (*wrappedArray)[i].AllocLC(); |
|
513 |
TInt lineLength = line->Length(); |
|
514 |
TRACES1("CTouchScreenCalibView::SetTextL(): lineLength: %d",lineLength); |
|
515 |
if(!lineLength) |
|
516 |
{ |
|
517 |
iText->AppendL( NULL ); |
|
518 |
CleanupStack::PopAndDestroy(line); // line |
|
519 |
} |
|
520 |
else |
|
521 |
{ |
|
522 |
iText->AppendL( line ); |
|
523 |
CleanupStack::Pop(line); // line |
|
524 |
} |
|
525 |
} |
|
526 |
iText->AppendL( NULL ); |
|
527 |
||
528 |
// If the last char was newline, add one extra, since |
|
529 |
// wrapping automatically removes it. |
|
530 |
if ( text[ text.Length() - 1 ] == '\n' ) |
|
531 |
{ |
|
532 |
iText->AppendL( NULL ); |
|
533 |
} |
|
534 |
||
535 |
CleanupStack::PopAndDestroy(wrappedArray); // wrappedArray |
|
536 |
delete dataToDestroy; |
|
537 |
||
538 |
CleanupStack::PopAndDestroy(2); //mainText1, mainText2 |
|
539 |
TRACES("CTouchScreenCalibView::SetTextL(); End"); |
|
540 |
} |
|
541 |
||
542 |
// ----------------------------------------------------------------------------- |
|
543 |
// CTouchScreenCalibView::ShowImage(TRect aRect) |
|
544 |
// ----------------------------------------------------------------------------- |
|
545 |
void CTouchScreenCalibView::ShowImage(TRect aRect) const |
|
546 |
{ |
|
547 |
TRACES("CTouchScreenCalibView::ShowImage()"); |
|
548 |
CWindowGc& gc = SystemGc(); |
|
549 |
AknIconUtils::SetSize( iBitmap, aRect.Size(), EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
550 |
gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
551 |
gc.SetBrushColor(KRgbRed); |
|
552 |
gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
553 |
gc.DrawRect(aRect); |
|
554 |
gc.BitBlt( TPoint(aRect.iTl.iX, aRect.iTl.iY), iBitmap ); // CWindowGc member function |
|
555 |
ControlEnv()->WsSession().Flush(); // force draw of the context |
|
556 |
TRACES("CTouchScreenCalibView::ShowImage(): End"); |
|
557 |
} |
|
558 |
||
559 |
// ----------------------------------------------------------------------------- |
|
560 |
// CTouchScreenCalibView::SetWinPriority() |
|
561 |
// ----------------------------------------------------------------------------- |
|
562 |
void CTouchScreenCalibView::SetWinPriority(TInt aPriority) |
|
563 |
{ |
|
564 |
TRACES("CTouchScreenCalibView::SetWinPriority()"); |
|
565 |
Window().SetOrdinalPosition( 0, aPriority ); |
|
566 |
TRACES("CTouchScreenCalibView::SetWinPriority(): End"); |
|
567 |
} |
|
568 |
||
569 |
// End of File |