|
1 /* |
|
2 * Copyright (c) 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: Implement of class CTruiMainViewContainer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eiklabel.h> |
|
20 #include <barsread.h> |
|
21 #include <aknnavide.h> |
|
22 #include <akntabgrp.h> |
|
23 #include <eikspane.h> |
|
24 #include <aknViewAppUi.h> |
|
25 #include <eikedwin.h> |
|
26 #include <aknbutton.h> |
|
27 #include <aknchoicelist.h> |
|
28 #include <aknSctDialog.h> |
|
29 #include <trui.rsg> |
|
30 #include <StringLoader.h> |
|
31 #include <aknnotewrappers.h> |
|
32 #include <aknlayoutscalable_apps.cdl.h> |
|
33 #include <AknsBasicBackgroundControlContext.h> |
|
34 #include <AknsDrawUtils.h> |
|
35 #include <layoutmetadata.cdl.h> |
|
36 #include <akntoolbar.h> |
|
37 #include <AknPreviewPopUpController.h> |
|
38 #include <AknsConstants.h> |
|
39 #include <trui_icons.mbg> |
|
40 #include <featmgr.h> |
|
41 |
|
42 #include "truicontainerbase.h" |
|
43 #include "truimainviewcontainer.h" |
|
44 #include "truihwrbox.h" |
|
45 #include "truiengine.h" |
|
46 #include "truiappui.h" |
|
47 #include "truiapplication.h" |
|
48 #include "truihelp.h" |
|
49 #include "trui.hrh" |
|
50 #include "truimainview.h" |
|
51 |
|
52 // Max length of text in indicator |
|
53 const TInt KIndicatorTextLen = 10; |
|
54 |
|
55 // Max length of text of silimar message |
|
56 const TInt KSimilarMsgLength = 160; |
|
57 |
|
58 // Delay time of showing tooltip |
|
59 const TInt KTooltipShowDelay = 0; |
|
60 |
|
61 // Delay time of hiding tooltip |
|
62 const TInt KTooltipHideDelay = 3000; |
|
63 |
|
64 // Size for buffer to fill maximum characters from SCT. |
|
65 const TInt KSctBufferSize = 32; |
|
66 |
|
67 const TInt KHwrTooltipY = 20; |
|
68 |
|
69 const TInt KVarityNaviPaneContents = 0; |
|
70 |
|
71 //the special gesture characters |
|
72 _LIT(KDisplayBackspace, "\x2190"); |
|
73 _LIT(KDisplaySpace, "\xF800"); |
|
74 _LIT(KDisplayEnter, "\xF801"); |
|
75 |
|
76 // ======== MEMBER FUNCTIONS ======== |
|
77 |
|
78 CTruiMainViewContainer::CTruiMainViewContainer() |
|
79 { |
|
80 } |
|
81 |
|
82 void CTruiMainViewContainer::ConstructL( const TRect& aRect ) |
|
83 { |
|
84 // Initialize control array |
|
85 InitComponentArrayL(); |
|
86 |
|
87 // Set parent control or owning window |
|
88 CreateWindowL(); |
|
89 |
|
90 iBackGround = CAknsBasicBackgroundControlContext::NewL |
|
91 ( KAknsIIDQsnBgAreaMain, |
|
92 Rect(), |
|
93 EFalse ); |
|
94 |
|
95 // Initialize controls |
|
96 InitializeControlsL(); |
|
97 |
|
98 SetRect( aRect ); |
|
99 |
|
100 // Set first character of the character set as the default trained character |
|
101 const HBufC* charSet = iEngine->CharacterSet(); |
|
102 ASSERT( charSet ); |
|
103 SetCurrentCharL( charSet->Mid( 0, 1 ) ); |
|
104 |
|
105 TInt currentRangeId = iEngine->GetCurrentCharacterRange(); |
|
106 const RArray<TInt>& rangeIdArray = |
|
107 iEngine->GetCurrentSupportedRangesId(); |
|
108 TInt indexOfMenuItems = rangeIdArray.Find( currentRangeId ); |
|
109 if ( indexOfMenuItems != KErrNotFound ) |
|
110 { |
|
111 // Set choiclist' selected item to index. |
|
112 iChoicelist->SetSelectedIndex( indexOfMenuItems ); |
|
113 } |
|
114 else |
|
115 { |
|
116 iChoicelist->SetSelectedIndex( 0 ); |
|
117 } |
|
118 |
|
119 // Set hwrbox's rect to engine and set guiding line to hwrbox |
|
120 iHwrBox->SetDisplayBottomGuideLine( ETrue ); |
|
121 if ( iEngine->CurrentLanguageScript() == EMainViewSubmenuHebrew ) |
|
122 { |
|
123 iHwrBox->SetDisplayTopGuideLine( ETrue ); |
|
124 } |
|
125 |
|
126 ActivateL(); |
|
127 |
|
128 } |
|
129 |
|
130 CTruiMainViewContainer* CTruiMainViewContainer::NewL( const TRect& aRect ) |
|
131 { |
|
132 CTruiMainViewContainer* self = CTruiMainViewContainer::NewLC( aRect ); |
|
133 CleanupStack::Pop( self ); |
|
134 return self; |
|
135 } |
|
136 |
|
137 CTruiMainViewContainer* CTruiMainViewContainer::NewLC( const TRect& aRect ) |
|
138 { |
|
139 CTruiMainViewContainer* self = new (ELeave) CTruiMainViewContainer(); |
|
140 CleanupStack::PushL( self ); |
|
141 self->ConstructL( aRect ); |
|
142 return self; |
|
143 } |
|
144 |
|
145 CTruiMainViewContainer::~CTruiMainViewContainer() |
|
146 { |
|
147 if ( iBackGround ) |
|
148 { |
|
149 delete iBackGround; |
|
150 } |
|
151 delete iWrappedLabelText; |
|
152 delete iLabeltext; |
|
153 iLineWidthArray.Close(); |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // Create controls to be displayed in this container. |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CTruiMainViewContainer::InitializeControlsL() |
|
161 { |
|
162 CAknToolbar* toolbar = iAppUi->View( KTruiMainViewId )->Toolbar(); |
|
163 // Get Clear button from toolbar |
|
164 if ( toolbar ) |
|
165 { |
|
166 iClearBtn = static_cast<CAknButton*> |
|
167 ( toolbar->ControlOrNull( EMainViewButtonIdDelete ) ); |
|
168 iPreviewBtn = static_cast<CAknButton*> |
|
169 ( toolbar->ControlOrNull( EMainViewButtonIdPreview ) ); |
|
170 } |
|
171 |
|
172 // Create Label for text above writting box |
|
173 iLabel = CreateLabelL( R_MAINVIEW_LABEL_TIP, this, NULL ); |
|
174 Components().AppendLC( iLabel ); |
|
175 CleanupStack::Pop( iLabel ); |
|
176 |
|
177 // Create left button |
|
178 iLeftBtn = CreateButtonL( R_MAINVIEW_BUTTON_LEFT, this, this ); |
|
179 Components().AppendLC( iLeftBtn ); |
|
180 CleanupStack::Pop( iLeftBtn ); |
|
181 |
|
182 // Create indicator |
|
183 iIindicator = CreateLabelL( R_MAINVIEW_LABEL_INDICATOR, this, this ); |
|
184 Components().AppendLC( iIindicator ); |
|
185 CleanupStack::Pop( iIindicator ); |
|
186 |
|
187 // Create right button |
|
188 iRightBtn = CreateButtonL( R_MAINVIEW_BUTTON_RIGHT, this, this ); |
|
189 Components().AppendLC( iRightBtn ); |
|
190 CleanupStack::Pop( iRightBtn ); |
|
191 |
|
192 // Create choicelist |
|
193 TInt buttonResource = ButtonResourceId |
|
194 ( iEngine->GetCurrentCharacterRange() ); |
|
195 CAknButton* rangeButton = CreateButtonL( buttonResource, |
|
196 this, NULL ); |
|
197 iCurChoiceListBtn = rangeButton; |
|
198 CDesCArray* charRangeArray = iEngine->GetCharacterRangeName(); |
|
199 CDesCArray* ownedCharRangeArray = new ( ELeave ) CDesCArrayFlat |
|
200 ( charRangeArray->MdcaCount() ); |
|
201 |
|
202 CleanupStack::PushL( ownedCharRangeArray ); |
|
203 for ( TInt i=0; i<charRangeArray->MdcaCount(); i++ ) |
|
204 { |
|
205 ownedCharRangeArray->AppendL( charRangeArray->MdcaPoint( i ) ); |
|
206 } |
|
207 iChoicelist = CreateChoiceListL( this, this, |
|
208 ownedCharRangeArray,rangeButton ); |
|
209 CleanupStack::Pop( ownedCharRangeArray ); |
|
210 ownedCharRangeArray = NULL;// Ownership has been transfered to choicelist |
|
211 Components().AppendLC( iChoicelist ); |
|
212 CleanupStack::Pop( iChoicelist ); |
|
213 |
|
214 iHwrBox = CreateHwrBoxL( this, this ); |
|
215 iHwrBox->SetHwrBoxFlag( CTruiHwrBox::EFrameHwrBox ); |
|
216 Components().AppendLC( iHwrBox ); |
|
217 CleanupStack::Pop( iHwrBox ); |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // Create label and display it in the container. |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 CEikLabel* CTruiMainViewContainer::CreateLabelL( const TInt aResourceId, |
|
225 const CCoeControl* aParent, |
|
226 MCoeControlObserver* aObserver ) |
|
227 { |
|
228 CEikLabel* aknLabel = new (ELeave) CEikLabel(); |
|
229 CleanupStack::PushL( aknLabel ); |
|
230 if ( aParent ) |
|
231 { |
|
232 aknLabel->SetContainerWindowL( *aParent ); |
|
233 } |
|
234 if ( aObserver ) |
|
235 { |
|
236 aknLabel->SetObserver( aObserver ); |
|
237 } |
|
238 if ( aResourceId != 0 ) |
|
239 { |
|
240 TResourceReader reader; |
|
241 iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
242 aknLabel->ConstructFromResourceL( reader ); |
|
243 CleanupStack::PopAndDestroy(); // reader |
|
244 } |
|
245 aknLabel->ActivateL(); |
|
246 CleanupStack::Pop( aknLabel ); |
|
247 return aknLabel; |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // Create choicelist and display it in the container. |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 CAknChoiceList* CTruiMainViewContainer::CreateChoiceListL |
|
255 ( CCoeControl* aParent, |
|
256 MCoeControlObserver* aObserver, |
|
257 CDesCArray* aTextArray, |
|
258 CAknButton* aButton ) |
|
259 { |
|
260 CAknChoiceList* choiceList = CAknChoiceList::NewLC( aParent, |
|
261 aTextArray, |
|
262 CAknChoiceList::EAknChoiceListWithoutCurrentSelection, |
|
263 aButton ); |
|
264 choiceList->SetObserver( aObserver ); |
|
265 CleanupStack::Pop( choiceList ); |
|
266 return choiceList; |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // Create HWRBox and display it in the container. |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 CTruiHwrBox* CTruiMainViewContainer::CreateHwrBoxL( CCoeControl* aParent, |
|
274 MTruiHwrBoxObserver* aObserver ) |
|
275 { |
|
276 return CTruiHwrBox::NewL( aParent, aObserver, iBackGround ); |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // Responds to changes to the size and position of the contents of this control. |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 void CTruiMainViewContainer::SizeChanged() |
|
284 { |
|
285 TInt varity = Layout_Meta_Data::IsLandscapeOrientation() ? KLandscapeVarity |
|
286 : KPortraitVarity; |
|
287 DoSizeChanged( varity ); |
|
288 |
|
289 if ( iBackGround ) |
|
290 { |
|
291 iBackGround->SetRect( Rect() ); |
|
292 } |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // From class CCoeControl. |
|
297 // Handles key event. |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 TKeyResponse CTruiMainViewContainer::OfferKeyEventL |
|
301 ( const TKeyEvent& aKeyEvent, |
|
302 TEventCode aType ) |
|
303 { |
|
304 if ( aType == EEventKey ) |
|
305 { |
|
306 switch ( aKeyEvent.iCode ) |
|
307 { |
|
308 case EKeyLeftArrow: |
|
309 { |
|
310 return EKeyWasConsumed; |
|
311 } |
|
312 case EKeyRightArrow: |
|
313 { |
|
314 CAknNavigationDecorator* naviDecorator = |
|
315 iAppUi->GetNaviDecorator(); |
|
316 CAknTabGroup* tabGroup = static_cast<CAknTabGroup*> |
|
317 ( naviDecorator->DecoratedControl() ); |
|
318 return tabGroup->OfferKeyEventL( aKeyEvent, aType ); |
|
319 } |
|
320 default: |
|
321 break; |
|
322 } |
|
323 } |
|
324 return EKeyWasNotConsumed; |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // From class CCoeControl. |
|
329 // The region of the control to be redrawn. |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 void CTruiMainViewContainer::Draw( const TRect& /*aRect*/ ) const |
|
333 { |
|
334 // Get the standard graphics context |
|
335 CWindowGc& gc = SystemGc(); |
|
336 // Gets the control's extent |
|
337 TRect rect( Rect() ); |
|
338 // Clears the screen |
|
339 gc.Clear( rect ); |
|
340 |
|
341 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
342 if ( AknsDrawUtils::HasBitmapBackground( skin, iBackGround ) ) |
|
343 { |
|
344 AknsDrawUtils::Background( skin, iBackGround, gc, rect ); |
|
345 } |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // From class CCoeControl. |
|
350 // Handles a change to the control's resources. |
|
351 // --------------------------------------------------------------------------- |
|
352 // |
|
353 void CTruiMainViewContainer::HandleResourceChange( TInt aType ) |
|
354 { |
|
355 CTruiContainerBase::HandleResourceChange( aType ); |
|
356 if ( aType == KEikDynamicLayoutVariantSwitch && iHwrBox ) |
|
357 { |
|
358 if ( iHwrBox->BoxState() == CTruiHwrBox::ENewModelDraw ) |
|
359 { |
|
360 TRAP_IGNORE( iHwrBox->SaveModelByManuallyL() ); |
|
361 } |
|
362 } |
|
363 |
|
364 if ( aType == KAknsMessageSkinChange ) |
|
365 { |
|
366 TRgb labelColor = KRgbBlack; |
|
367 TInt error = GetCachedLabelTextColor( labelColor ); |
|
368 if ( error == KErrNone ) |
|
369 { |
|
370 TRAPD( errLable, iLabel->OverrideColorL( EColorLabelText, |
|
371 labelColor ) ); |
|
372 if ( errLable != KErrNone ) |
|
373 { |
|
374 return; |
|
375 } |
|
376 TRAP_IGNORE( iIindicator->OverrideColorL( EColorLabelText, |
|
377 labelColor ) ); |
|
378 } |
|
379 TRgb iconColor = KRgbBlack; |
|
380 // Change left icon |
|
381 iLeftBtn->State()->SetIcon( ConstructIconFromResourceL |
|
382 ( R_MAINVIEW_BUTTON_LEFT ) ); |
|
383 // Change right icon |
|
384 iRightBtn->State()->SetIcon( ConstructIconFromResourceL |
|
385 ( R_MAINVIEW_BUTTON_RIGHT ) ); |
|
386 |
|
387 // Change choicelist button |
|
388 TInt rangeId = iEngine->GetCurrentCharacterRange(); |
|
389 TInt buttonResoureId = ButtonResourceId( rangeId ); |
|
390 iCurChoiceListBtn->State()->SetIcon( ConstructIconFromResourceL |
|
391 ( buttonResoureId ) ); |
|
392 } |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // Handles an event from an observed control. |
|
397 // --------------------------------------------------------------------------- |
|
398 // |
|
399 void CTruiMainViewContainer::HandleControlEventL(CCoeControl* aControl, |
|
400 TCoeEvent aEventType) |
|
401 { |
|
402 // Handle left button event |
|
403 if ( aControl == iLeftBtn && aEventType == EEventStateChanged ) |
|
404 { |
|
405 //Get character set |
|
406 const HBufC* charSet = iEngine->CharacterSet(); |
|
407 ASSERT( charSet ); |
|
408 //Locate current position |
|
409 TInt charPos = charSet->Find( iCurrentChar ); |
|
410 if ( charPos != KErrNotFound ) |
|
411 { |
|
412 //Move left |
|
413 TInt length = charSet->Length(); |
|
414 charPos = ( charPos - 1 + length ) % length; |
|
415 SetCurrentCharL( charSet->Mid( charPos, 1 ) ); |
|
416 } |
|
417 } |
|
418 // Handle indicator button event |
|
419 else if ( aControl == iIindicator && aEventType == EEventRequestFocus ) |
|
420 { |
|
421 PreviewCharacterModel(); |
|
422 } |
|
423 // Handle right button event |
|
424 else if ( aControl == iRightBtn && aEventType == EEventStateChanged ) |
|
425 { |
|
426 //Get character set |
|
427 const HBufC* charSet = iEngine->CharacterSet(); |
|
428 ASSERT( charSet ); |
|
429 //Locate current position |
|
430 TInt charPos = charSet->Find( iCurrentChar ); |
|
431 if ( charPos != KErrNotFound ) |
|
432 { |
|
433 //Move left |
|
434 TInt length = charSet->Length(); |
|
435 charPos = ( charPos + 1 + length ) % length; |
|
436 SetCurrentCharL( charSet->Mid( charPos, 1 ) ); |
|
437 } |
|
438 } |
|
439 // Handle choicelist event |
|
440 else if ( aControl == iChoicelist && aEventType == EEventStateChanged ) |
|
441 { |
|
442 // Handle character range changing event |
|
443 // Get the selected index |
|
444 TInt index = iChoicelist->SelectedIndex(); |
|
445 |
|
446 // Set current character range by index in Engine |
|
447 iEngine->SetCharacterRangeByIndexL( index ); |
|
448 |
|
449 // Get the current character range Id |
|
450 TInt rangeId = iEngine->GetCurrentCharacterRange(); |
|
451 |
|
452 // Handle character range changed |
|
453 HandleCharRangeChangedL( index, rangeId ); |
|
454 } |
|
455 } |
|
456 |
|
457 // --------------------------------------------------------------------------- |
|
458 // From class MTruiHWRBoxObserver. |
|
459 // Responds to changes to the size and position of the contents of control. |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void CTruiMainViewContainer::SaveNewModelL() |
|
463 { |
|
464 TBuf<KSimilarMsgLength> similarMsg; |
|
465 TRAPD( err, iEngine->SetCharacterModelL( iCurrentChar, |
|
466 iHwrBox->Model(), |
|
467 similarMsg ) ); |
|
468 switch ( err ) |
|
469 { |
|
470 case KErrNone: |
|
471 { |
|
472 //Dim clear button and preview button |
|
473 if ( iClearBtn ) |
|
474 { |
|
475 iClearBtn->SetDimmed( EFalse ); |
|
476 iClearBtn->DrawNow(); |
|
477 } |
|
478 if ( iPreviewBtn ) |
|
479 { |
|
480 iPreviewBtn->SetDimmed( EFalse ); |
|
481 iPreviewBtn->DrawNow(); |
|
482 } |
|
483 TPoint hwrPos = iHwrBox->PositionRelativeToScreen(); |
|
484 HBufC* tooltipText = |
|
485 iEikonEnv->AllocReadResourceLC( R_TRUI_TOOLTIP_SAVED ); |
|
486 iHwrBox->ShowTooltipL( *tooltipText, |
|
487 hwrPos + TPoint( iHwrBox->Size().iWidth, KHwrTooltipY ), |
|
488 KTooltipShowDelay, KTooltipHideDelay ); |
|
489 CleanupStack::PopAndDestroy( tooltipText ); |
|
490 break; |
|
491 } |
|
492 case KErrAlreadyExists: |
|
493 { |
|
494 //Clear invalid model |
|
495 ClearCurrentModel(); |
|
496 |
|
497 // Transfer some special gesture chars into displayable chars. |
|
498 AdjustDisplayChars( similarMsg ); |
|
499 |
|
500 //Popup err message |
|
501 HBufC* errMsg = iEikonEnv->AllocReadResourceLC( R_TRUI_NOTE_SIMILAR_MODEL ); |
|
502 HBufC* tooltipText = HBufC::NewLC( errMsg->Length() + similarMsg.Length() |
|
503 + KExtraSize ); |
|
504 TPtr tooltipTextPtr = tooltipText->Des(); |
|
505 tooltipTextPtr.Format( *errMsg, &similarMsg ); |
|
506 PopupInformationNoteL( *tooltipText ); |
|
507 CleanupStack::PopAndDestroy( tooltipText ); |
|
508 CleanupStack::PopAndDestroy( errMsg ); |
|
509 break; |
|
510 } |
|
511 default: |
|
512 { |
|
513 //Clear invalid model |
|
514 ClearCurrentModel(); |
|
515 //Popup err message |
|
516 HBufC* tooltipText = iEikonEnv->AllocReadResourceLC( R_TRUI_NOTE_SAVE_FAILED ); |
|
517 PopupInformationNoteL( *tooltipText ); |
|
518 CleanupStack::PopAndDestroy( tooltipText ); |
|
519 break; |
|
520 } |
|
521 } |
|
522 }; |
|
523 |
|
524 // --------------------------------------------------------------------------- |
|
525 // From class MTruiHWRBoxObserver. |
|
526 // Handle the message event from the HWRBox |
|
527 // --------------------------------------------------------------------------- |
|
528 // |
|
529 void CTruiMainViewContainer::HandleEventL( TMessageType aMessage ) |
|
530 { |
|
531 if ( aMessage == EModelExist ) |
|
532 { |
|
533 HBufC* tooltipText = |
|
534 iEikonEnv->AllocReadResourceLC( R_TRUI_NOTE_CLEAR_BOX ); |
|
535 PopupInformationNoteL( *tooltipText ); |
|
536 CleanupStack::PopAndDestroy( tooltipText ); |
|
537 } |
|
538 } |
|
539 |
|
540 // --------------------------------------------------------------------------- |
|
541 // Handles language script changed. |
|
542 // --------------------------------------------------------------------------- |
|
543 // |
|
544 void CTruiMainViewContainer::HandleLanguageScriptChangedL( TInt aScriptId ) |
|
545 { |
|
546 CTruiEngine* engine = iAppUi->HwrEngine(); |
|
547 const RArray<TInt>& languageScriptId = engine->SupportedLanguageScript(); |
|
548 TInt index = languageScriptId.Find( aScriptId ); |
|
549 if ( index != KErrNotFound ) |
|
550 { |
|
551 // Set the language script |
|
552 engine->SetLanguageScriptByIndexL( aScriptId ); |
|
553 |
|
554 // Copy language script names array |
|
555 CDesCArray* rangeNames = engine->GetCharacterRangeName(); |
|
556 CDesCArray* itemsInChoiceList = new (ELeave) CDesCArrayFlat |
|
557 ( rangeNames->Count() ); |
|
558 CleanupStack::PushL( itemsInChoiceList ); |
|
559 for ( TInt i = 0; i < rangeNames->Count(); i++ ) |
|
560 { |
|
561 itemsInChoiceList->AppendL( ( *rangeNames )[i] ); |
|
562 } |
|
563 |
|
564 // Set the items in choicelist |
|
565 iChoicelist->SetItems( itemsInChoiceList ); // Transfered ownership |
|
566 CleanupStack::Pop( itemsInChoiceList ); |
|
567 |
|
568 // Set hwrbox's rect to engine and set guiding line to hwrbox |
|
569 TBool isDisplayTopGuideLine = ( iEngine->CurrentLanguageScript() |
|
570 == EMainViewSubmenuHebrew ) ? ETrue : EFalse; |
|
571 |
|
572 iHwrBox->SetDisplayTopGuideLine( isDisplayTopGuideLine ); |
|
573 |
|
574 // Get the ative character range's ID. |
|
575 TInt rangeId = engine->GetCurrentCharacterRange(); |
|
576 // Handle char range changed with index 0 |
|
577 HandleCharRangeChangedL( 0, rangeId ); |
|
578 } |
|
579 } |
|
580 |
|
581 // --------------------------------------------------------------------------- |
|
582 // Handles character range changed. |
|
583 // --------------------------------------------------------------------------- |
|
584 // |
|
585 void CTruiMainViewContainer::HandleCharRangeChangedL( TInt aIndex, |
|
586 TInt aRangeId ) |
|
587 { |
|
588 // Get the button's resourceID by char range's ID |
|
589 TInt buttonResoureId = ButtonResourceId( aRangeId ); |
|
590 // Create new button with the reourceID |
|
591 // and add it to the AknChoiceList |
|
592 if ( buttonResoureId ) |
|
593 { |
|
594 CAknButton* rangeButton = CreateButtonL( buttonResoureId, |
|
595 this, NULL ); |
|
596 iCurChoiceListBtn = rangeButton; |
|
597 CleanupStack::PushL( rangeButton ); |
|
598 iChoicelist->SetButtonL( rangeButton ); |
|
599 CleanupStack::Pop( rangeButton ); |
|
600 iChoicelist->DrawNow(); |
|
601 } |
|
602 // Set choiclist' selected item to index. |
|
603 iChoicelist->SetSelectedIndex( aIndex ); |
|
604 |
|
605 // Refresh the active char with the first char in the character set |
|
606 const HBufC* charSet = iEngine->CharacterSet(); |
|
607 ASSERT( charSet ); |
|
608 SetCurrentCharL( charSet->Mid( 0, 1 ) ); |
|
609 } |
|
610 |
|
611 // --------------------------------------------------------------------------- |
|
612 // Handles choosing an active char from SCT. |
|
613 // --------------------------------------------------------------------------- |
|
614 // |
|
615 void CTruiMainViewContainer::HandleChooseCharEventL() |
|
616 { |
|
617 TInt rangeId = |
|
618 iAppUi->HwrEngine()->GetCurrentCharacterRange(); |
|
619 |
|
620 // Get character set id by character range id |
|
621 TInt characterSetId = SctCharacterSetId( rangeId ); |
|
622 |
|
623 // Popup SCT dialog |
|
624 TBuf<KSctBufferSize> selectedStr; |
|
625 TInt buttonId = PopupSctDialogL( EAknSCTLowerCase, |
|
626 selectedStr, |
|
627 characterSetId ); |
|
628 if ( buttonId != 0 && selectedStr.Length() > 0 ) |
|
629 { |
|
630 SetCurrentCharL( selectedStr.Mid( 0, 1 ) ); |
|
631 } |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // Check if clear button has been dimmed. |
|
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 TBool CTruiMainViewContainer::IsButtonDimmed() |
|
639 { |
|
640 return iClearBtn ? iClearBtn->IsDimmed() : EFalse; |
|
641 } |
|
642 |
|
643 // --------------------------------------------------------------------------- |
|
644 // Check if all delete button has been dimmed. |
|
645 // --------------------------------------------------------------------------- |
|
646 // |
|
647 TBool CTruiMainViewContainer::IsAllDelete() |
|
648 { |
|
649 const HBufC* charSet = iEngine->CharacterSet(); |
|
650 for ( TInt i = 0; i < charSet->Length(); i++ ) |
|
651 { |
|
652 if ( iEngine->CheckCharacterModel( charSet->Mid( i, 1 ) ) ) |
|
653 { |
|
654 return EFalse; |
|
655 } |
|
656 } |
|
657 return ETrue; |
|
658 } |
|
659 |
|
660 // --------------------------------------------------------------------------- |
|
661 // Return button's resourceId by Character Range Id. |
|
662 // Use this resoueceId to create the correct button. |
|
663 // --------------------------------------------------------------------------- |
|
664 // |
|
665 TInt CTruiMainViewContainer::ButtonResourceId( TInt aRangeId ) const |
|
666 { |
|
667 TInt resoureId; |
|
668 switch ( aRangeId ) |
|
669 { |
|
670 case ELatinLowerLetters: |
|
671 { |
|
672 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_LATIN_LOWER; |
|
673 } |
|
674 break; |
|
675 case ELatinUpperLetters: |
|
676 { |
|
677 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_LATIN_UPPER; |
|
678 } |
|
679 break; |
|
680 case ELatinAccent: |
|
681 { |
|
682 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_LATIN_ACCENT; |
|
683 } |
|
684 break; |
|
685 case ELatinDigital: |
|
686 { |
|
687 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_NUMERIC; |
|
688 } |
|
689 break; |
|
690 case ELatinSymbol: |
|
691 { |
|
692 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_SYMBOL; |
|
693 } |
|
694 break; |
|
695 case ECyrillicLowerLetters: |
|
696 { // |
|
697 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_CYRILLIC_LOWER; |
|
698 } |
|
699 break; |
|
700 case ECyrillicUpperLetters: |
|
701 { |
|
702 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_CYRILLIC_UPPER; |
|
703 } |
|
704 break; |
|
705 case ECyrillicAccent: |
|
706 { |
|
707 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_CYRILLIC_ACCENT; |
|
708 } |
|
709 break; |
|
710 case EGreekLowerLetters: |
|
711 { |
|
712 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_GREEK_LOWER; |
|
713 } |
|
714 break; |
|
715 case EGreekUpperLetters: |
|
716 { |
|
717 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_GREEK_UPPER; |
|
718 } |
|
719 break; |
|
720 case EHebrewLetters: |
|
721 { |
|
722 resoureId = R_MAINVIEW_BUTTON_CHARRANGE_HEBREW_LETTERS; |
|
723 } |
|
724 break; |
|
725 default: |
|
726 { |
|
727 resoureId = 0; |
|
728 } |
|
729 } |
|
730 return resoureId; |
|
731 } |
|
732 |
|
733 // --------------------------------------------------------------------------- |
|
734 // Pop Sct dialog. |
|
735 // --------------------------------------------------------------------------- |
|
736 // |
|
737 TInt CTruiMainViewContainer::PopupSctDialogL( TInt aCharCase, |
|
738 TDes& aSpecialChars, |
|
739 TInt aCharSetResourceId ) |
|
740 { |
|
741 CAknCharMapDialog* sct = new (ELeave) CAknCharMapDialog( aCharCase, |
|
742 aSpecialChars, |
|
743 aCharSetResourceId ); |
|
744 TInt keyboardMode = CurrentKeyBoardModeL(); |
|
745 if ( keyboardMode ) |
|
746 { |
|
747 // QWERTY: Lock numeric keys. |
|
748 sct->LockNumericKeys( ETrue ); |
|
749 } |
|
750 else |
|
751 { |
|
752 // ITU-T: Unlock numeric keys. |
|
753 sct->LockNumericKeys( EFalse ); |
|
754 } |
|
755 |
|
756 sct->DisableRecentCharsRow(); |
|
757 TInt retValue = sct->ExecuteLD( R_TRUI_SCT_DIALOG ); |
|
758 return retValue; |
|
759 } |
|
760 |
|
761 // --------------------------------------------------------------------------- |
|
762 // Set current trained char |
|
763 // --------------------------------------------------------------------------- |
|
764 // |
|
765 void CTruiMainViewContainer::SetCurrentCharL( const TPtrC& aChar ) |
|
766 { |
|
767 //If previous char's model is not saved, save it before setting new char. |
|
768 if ( iHwrBox->BoxState() == CTruiHwrBox::ENewModelDraw ) |
|
769 { |
|
770 //Call save function from hwrbox, |
|
771 //in order to stop periodics in the hwrbox |
|
772 iHwrBox->SaveModelByManuallyL(); |
|
773 } |
|
774 // In case of new localization not check-in, temporary |
|
775 if ( iCurrentChar != aChar ) |
|
776 { |
|
777 //Set current char |
|
778 iCurrentChar = aChar; |
|
779 //Set Top Label's text |
|
780 HBufC* teachCharacter = NULL; |
|
781 teachCharacter = StringLoader::LoadLC |
|
782 ( R_TRUI_MAINVIEW_TEXT_TEACH_CHARACTER, aChar ); |
|
783 if ( !iLabeltext ) |
|
784 { |
|
785 delete iLabeltext; |
|
786 iLabeltext = NULL; |
|
787 iLabeltext = HBufC::NewL( teachCharacter->Length() + KExtraSize ); |
|
788 } |
|
789 TPtr labelOldPtr = iLabeltext->Des(); |
|
790 if ( labelOldPtr.MaxLength() < teachCharacter->Length() ) |
|
791 { |
|
792 iLabeltext = iLabeltext->ReAlloc( teachCharacter->Length() + KExtraSize ); |
|
793 } |
|
794 TPtr labelTextPtr = iLabeltext->Des(); |
|
795 labelTextPtr.Copy( *teachCharacter ); |
|
796 CleanupStack::PopAndDestroy( teachCharacter ); |
|
797 |
|
798 delete iWrappedLabelText; |
|
799 iWrappedLabelText = NULL; |
|
800 iWrappedLabelText = HBufC::NewL( iLabeltext->Length() |
|
801 + iLineWidthArray.Count() |
|
802 + KExtraSize ); |
|
803 // Be ready to show label |
|
804 const CFont* font = AknLayoutUtils::FontFromId( iMultilineLayout.FontId() ); |
|
805 TRAPD( err, WrapLabelTextL( font, *iLabeltext, iLineWidthArray, iWrappedLabelText ) ); |
|
806 if ( err == KErrNone ) |
|
807 { |
|
808 iLabel->SetTextL( *iWrappedLabelText ); |
|
809 } |
|
810 else |
|
811 { |
|
812 iLabel->SetTextL( *iLabeltext ); |
|
813 } |
|
814 AknLayoutUtils::LayoutLabel( iLabel, |
|
815 iLabelPaneRect, |
|
816 iMultilineLayout ); |
|
817 TRgb labelColor = KRgbBlack; |
|
818 if ( GetCachedLabelTextColor( labelColor ) == KErrNone ) |
|
819 { |
|
820 iLabel->OverrideColorL( EColorLabelText, labelColor ); |
|
821 } |
|
822 |
|
823 //Set Indicator's text |
|
824 const HBufC* charIndicator = iEikonEnv->AllocReadResourceL |
|
825 ( R_TRUI_MAINVIEW_ACTIVE_CHAR_INDICATOR ); |
|
826 TBuf<KIndicatorTextLen> indicatortext; |
|
827 indicatortext.Format( *charIndicator, &aChar ); |
|
828 delete charIndicator; |
|
829 charIndicator = NULL; |
|
830 iIindicator->SetTextL( indicatortext ); |
|
831 } |
|
832 |
|
833 iHwrBox->ClearExistModel(); |
|
834 //Load existing model and dim clear button |
|
835 if ( iEngine->CheckCharacterModel( iCurrentChar ) ) |
|
836 { |
|
837 //Get model from engine |
|
838 TRAPD( err, iEngine->GetCharacterModelL( iCurrentChar, iHwrBox->Model() ) ); |
|
839 if ( err == KErrNone ) |
|
840 { |
|
841 iHwrBox->ModelIsReady(); |
|
842 //Activate clear button and preview button |
|
843 if ( iClearBtn ) |
|
844 { |
|
845 iClearBtn->SetDimmed( EFalse ); |
|
846 iClearBtn->DrawNow(); |
|
847 } |
|
848 if ( iPreviewBtn ) |
|
849 { |
|
850 iPreviewBtn->SetDimmed( EFalse ); |
|
851 iPreviewBtn->DrawNow(); |
|
852 } |
|
853 } |
|
854 //Preview |
|
855 iHwrBox->PlayAnimation( EFalse ); |
|
856 } |
|
857 else |
|
858 { |
|
859 iHwrBox->ModelIsReady( EFalse ); |
|
860 if ( iClearBtn ) |
|
861 { |
|
862 //Dim clear button and preview button |
|
863 iClearBtn->SetDimmed( ETrue ); |
|
864 iClearBtn->DrawNow(); |
|
865 } |
|
866 if ( iPreviewBtn ) |
|
867 { |
|
868 iPreviewBtn->SetDimmed( ETrue ); |
|
869 iPreviewBtn->DrawNow(); |
|
870 } |
|
871 } |
|
872 } |
|
873 |
|
874 // --------------------------------------------------------------------------- |
|
875 // Preview character model |
|
876 // --------------------------------------------------------------------------- |
|
877 // |
|
878 void CTruiMainViewContainer::PreviewCharacterModel() |
|
879 { |
|
880 if ( iEngine->CheckCharacterModel( iCurrentChar ) ) |
|
881 { |
|
882 iHwrBox->PlayAnimation( EFalse ); |
|
883 } |
|
884 } |
|
885 |
|
886 // --------------------------------------------------------------------------- |
|
887 // Clear current model |
|
888 // --------------------------------------------------------------------------- |
|
889 // |
|
890 void CTruiMainViewContainer::ClearCurrentModel() |
|
891 { |
|
892 if ( iClearBtn ) |
|
893 { |
|
894 iClearBtn->SetDimmed( ETrue ); |
|
895 iClearBtn->DrawNow(); |
|
896 } |
|
897 if ( iPreviewBtn ) |
|
898 { |
|
899 iPreviewBtn->SetDimmed( ETrue ); |
|
900 iPreviewBtn->DrawNow(); |
|
901 } |
|
902 iHwrBox->ClearExistModel(); |
|
903 } |
|
904 |
|
905 // --------------------------------------------------------------------------- |
|
906 // Popup information note |
|
907 // --------------------------------------------------------------------------- |
|
908 // |
|
909 void CTruiMainViewContainer::PopupInformationNoteL( const TDesC& aText ) |
|
910 { |
|
911 CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue ); |
|
912 note->ExecuteLD( aText ); |
|
913 } |
|
914 // --------------------------------------------------------------------------- |
|
915 // Adjust special behavior characters to displayable characters. |
|
916 // --------------------------------------------------------------------------- |
|
917 // |
|
918 void CTruiMainViewContainer::AdjustDisplayChars( TDes& aResult ) |
|
919 { |
|
920 if ( aResult.Length() > 0 && aResult.Length() <= 1 ) |
|
921 { |
|
922 switch ( aResult[0] ) |
|
923 { |
|
924 case EKeyEnter: |
|
925 { |
|
926 aResult.Replace( 0, 1, KDisplayEnter ); |
|
927 break; |
|
928 } |
|
929 case EKeySpace: |
|
930 { |
|
931 aResult.Replace( 0, 1, KDisplaySpace ); |
|
932 break; |
|
933 } |
|
934 case EKeyBackspace: |
|
935 { |
|
936 aResult.Replace( 0, 1, KDisplayBackspace ); |
|
937 break; |
|
938 } |
|
939 } |
|
940 } |
|
941 } |
|
942 |
|
943 // --------------------------------------------------------------------------- |
|
944 // Delete model of the shortcut |
|
945 // --------------------------------------------------------------------------- |
|
946 // |
|
947 void CTruiMainViewContainer::DeleteModelL() |
|
948 { |
|
949 // Delete shortcut from engine |
|
950 if ( iEngine->DeleteCharacterModel( *iIindicator->Text() ) |
|
951 == KErrNone ) |
|
952 { |
|
953 ClearCurrentModel(); |
|
954 |
|
955 // Pop tooltip |
|
956 HBufC* tooltipText = |
|
957 iEikonEnv->AllocReadResourceLC( R_TRUI_TOOLTIP_DELETED ); |
|
958 TPoint hwrPos = iHwrBox->PositionRelativeToScreen(); |
|
959 iHwrBox->ShowTooltipL( *tooltipText, |
|
960 hwrPos + TPoint( iHwrBox->Size().iWidth, KHwrTooltipY ), |
|
961 KTooltipShowDelay, KTooltipHideDelay ); |
|
962 CleanupStack::PopAndDestroy( tooltipText ); |
|
963 } |
|
964 } |
|
965 |
|
966 // --------------------------------------------------------------------------- |
|
967 // Delete all models of current character |
|
968 // --------------------------------------------------------------------------- |
|
969 // |
|
970 void CTruiMainViewContainer::DeleteAllModelL() |
|
971 { |
|
972 // Popup note dialog |
|
973 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
974 if ( dlg->ExecuteLD( R_TRUI_QUERYDIALOG_DELETE_ALL_MODELS ) ) |
|
975 { |
|
976 // press yes |
|
977 const HBufC* charSet = iEngine->CharacterSet(); |
|
978 for ( TInt i = 0; i < charSet->Length(); i++ ) |
|
979 { |
|
980 if ( iEngine->CheckCharacterModel( charSet->Mid( i, 1 ) ) ) |
|
981 { |
|
982 if ( *iIindicator->Text() == charSet->Mid( i, 1 ) ) |
|
983 { |
|
984 DeleteModelL(); |
|
985 } |
|
986 else |
|
987 { |
|
988 iEngine->DeleteCharacterModel( charSet->Mid( i, 1 ) ); |
|
989 } |
|
990 } |
|
991 } |
|
992 } |
|
993 } |
|
994 |
|
995 // --------------------------------------------------------------------------- |
|
996 // Get character set Id, |
|
997 // used to choose which characters will be displayed in SCT |
|
998 // --------------------------------------------------------------------------- |
|
999 // |
|
1000 TInt CTruiMainViewContainer::SctCharacterSetId( TInt aRangeId ) |
|
1001 { |
|
1002 TInt characterSetId; |
|
1003 switch ( aRangeId ) |
|
1004 { |
|
1005 case EMainViewSubmenuLatinLowerLetter: |
|
1006 { |
|
1007 characterSetId = R_TRUI_SCT_CHARSET_LATIN_LOWER; |
|
1008 break; |
|
1009 } |
|
1010 case EMainViewSubmenuCyrillicLowerLetters: |
|
1011 { |
|
1012 characterSetId = SctCyrillicLowerCharacterSetId |
|
1013 ( iEngine->InputLanguage() ); |
|
1014 break; |
|
1015 } |
|
1016 case EMainViewSubmenuGreekLowerLetters: |
|
1017 { |
|
1018 characterSetId = R_TRUI_SCT_CHARSET_GREEK_LOWER; |
|
1019 break; |
|
1020 } |
|
1021 case EMainViewSubmenuHebrewLetters: |
|
1022 { |
|
1023 characterSetId = R_TRUI_SCT_CHARSET_HEBREW_LETTERS; |
|
1024 break; |
|
1025 } |
|
1026 case EMainViewSubmenuLatinAccent: |
|
1027 { |
|
1028 characterSetId = R_TRUI_SCT_CHARSET_LATIN_ACCENT; |
|
1029 break; |
|
1030 } |
|
1031 case EMainViewSubmenuLatinUpperLetter: |
|
1032 { |
|
1033 characterSetId = R_TRUI_SCT_CHARSET_LATIN_UPPER; |
|
1034 break; |
|
1035 } |
|
1036 case EMainViewSubmenuCyrillicUpperLetters: |
|
1037 { |
|
1038 characterSetId = SctCyrillicUpperCharacterSetId |
|
1039 ( iEngine->InputLanguage() ); |
|
1040 break; |
|
1041 } |
|
1042 case EMainViewSubmenuCyrillicAccent: |
|
1043 { |
|
1044 characterSetId = R_TRUI_SCT_CHARSET_CYRILLIC_ACCENT; |
|
1045 break; |
|
1046 } |
|
1047 case EMainViewSubmenuGreekUpperLetters: |
|
1048 { |
|
1049 characterSetId = R_TRUI_SCT_CHARSET_GREEK_UPPER; |
|
1050 break; |
|
1051 } |
|
1052 case EMainViewSubmenuDigital: |
|
1053 { |
|
1054 characterSetId = R_TRUI_SCT_CHARSET_LATIN_NUMERIC; |
|
1055 break; |
|
1056 } |
|
1057 case EMainViewSubmenuSymbols: |
|
1058 { |
|
1059 if ( FeatureManager::FeatureSupported(KFeatureIdChinese) ) |
|
1060 { |
|
1061 characterSetId = R_TRUI_SCT_CHARSET_LATIN_SYMBOL_CHINESE; |
|
1062 } |
|
1063 else |
|
1064 { |
|
1065 characterSetId = R_TRUI_SCT_CHARSET_LATIN_SYMBOL; |
|
1066 } |
|
1067 break; |
|
1068 } |
|
1069 default: |
|
1070 { |
|
1071 characterSetId = 0; |
|
1072 } |
|
1073 } |
|
1074 return characterSetId; |
|
1075 } |
|
1076 |
|
1077 // --------------------------------------------------------------------------- |
|
1078 // Get cyrillic lower character set Id. |
|
1079 // --------------------------------------------------------------------------- |
|
1080 // |
|
1081 TInt CTruiMainViewContainer::SctCyrillicLowerCharacterSetId |
|
1082 ( TLanguage aInputLanguage ) |
|
1083 { |
|
1084 if ( aInputLanguage == ELangBulgarian ) |
|
1085 { |
|
1086 return R_TRUI_SCT_CHARSET_CYRILLIC_LOWER_BULGARIAN; |
|
1087 } |
|
1088 else if ( aInputLanguage == ELangRussian ) |
|
1089 { |
|
1090 return R_TRUI_SCT_CHARSET_CYRILLIC_LOWER_RUSSIAN; |
|
1091 } |
|
1092 else if ( aInputLanguage == ELangUkrainian ) |
|
1093 { |
|
1094 return R_TRUI_SCT_CHARSET_CYRILLIC_LOWER_UKRAINE; |
|
1095 } |
|
1096 else |
|
1097 { |
|
1098 return R_TRUI_SCT_CHARSET_CYRILLIC_LOWER; |
|
1099 } |
|
1100 } |
|
1101 |
|
1102 // --------------------------------------------------------------------------- |
|
1103 // Get cyrillic upper character set Id. |
|
1104 // --------------------------------------------------------------------------- |
|
1105 // |
|
1106 TInt CTruiMainViewContainer::SctCyrillicUpperCharacterSetId |
|
1107 ( TLanguage aInputLanguage ) |
|
1108 { |
|
1109 if ( aInputLanguage == ELangBulgarian ) |
|
1110 { |
|
1111 return R_TRUI_SCT_CHARSET_CYRILLIC_UPPER_BULGARIAN; |
|
1112 } |
|
1113 else if ( aInputLanguage == ELangRussian ) |
|
1114 { |
|
1115 return R_TRUI_SCT_CHARSET_CYRILLIC_UPPER_RUSSIAN; |
|
1116 } |
|
1117 else if ( aInputLanguage == ELangUkrainian ) |
|
1118 { |
|
1119 return R_TRUI_SCT_CHARSET_CYRILLIC_UPPER_UKRAINE; |
|
1120 } |
|
1121 else |
|
1122 { |
|
1123 return R_TRUI_SCT_CHARSET_CYRILLIC_UPPER; |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 // --------------------------------------------------------------------------- |
|
1128 // Before exit, do some necessary operation |
|
1129 // --------------------------------------------------------------------------- |
|
1130 // |
|
1131 void CTruiMainViewContainer::PrepareToExitL() |
|
1132 { |
|
1133 //If previous char's model is not saved, save it before exit. |
|
1134 if ( iHwrBox->BoxState() == CTruiHwrBox::ENewModelDraw ) |
|
1135 { |
|
1136 //Call save function from hwrbox, |
|
1137 //in order to stop periodics in the hwrbox |
|
1138 iHwrBox->SaveModelByManuallyL(); |
|
1139 } |
|
1140 iHwrBox->HideInfoPopupNote(); |
|
1141 } |
|
1142 |
|
1143 // --------------------------------------------------------------------------- |
|
1144 // This is called whenever the control gains or loses focus, |
|
1145 // --------------------------------------------------------------------------- |
|
1146 // |
|
1147 void CTruiMainViewContainer::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
1148 { |
|
1149 if ( IsFocused() ) |
|
1150 { |
|
1151 if ( iHwrBox->BoxState() == CTruiHwrBox::EExistModelStop ) |
|
1152 { |
|
1153 iHwrBox->ResumePlaying(); |
|
1154 } |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 if ( iHwrBox->BoxState() == CTruiHwrBox::EExistModelDraw ) |
|
1159 { |
|
1160 iHwrBox->PausePlaying(); |
|
1161 } |
|
1162 } |
|
1163 iHwrBox->SetFocus( IsFocused() ); |
|
1164 } |
|
1165 |
|
1166 // --------------------------------------------------------------------------- |
|
1167 // Gets the control's help context. Returns a NULL context by default. |
|
1168 // --------------------------------------------------------------------------- |
|
1169 // |
|
1170 void CTruiMainViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
1171 { |
|
1172 aContext.iMajor = KUidtruiApp; |
|
1173 aContext.iContext = HWRT_HLP_MAIN_VIEW; |
|
1174 } |
|
1175 |
|
1176 // --------------------------------------------------------------------------- |
|
1177 // Handle size changed. |
|
1178 // --------------------------------------------------------------------------- |
|
1179 // |
|
1180 void CTruiMainViewContainer::DoSizeChanged( TInt aVarity ) |
|
1181 { |
|
1182 TRect rect = Rect(); |
|
1183 |
|
1184 TAknWindowComponentLayout main_pane_layout = |
|
1185 AknLayoutScalable_Apps::main_hwr_training_pane(); |
|
1186 TAknLayoutRect main_pane_layout_rect; |
|
1187 main_pane_layout_rect.LayoutRect( rect, main_pane_layout ); |
|
1188 TRect main_pane_rect = main_pane_layout_rect.Rect(); |
|
1189 |
|
1190 // Caculate hwr_training_navi_pane |
|
1191 TAknWindowComponentLayout navi_pane_layout = |
|
1192 AknLayoutScalable_Apps::hwr_training_navi_pane( aVarity ); |
|
1193 TAknLayoutRect navi_pane_layout_rect; |
|
1194 navi_pane_layout_rect.LayoutRect( main_pane_rect, navi_pane_layout ); |
|
1195 TRect navi_pane_rect = navi_pane_layout_rect.Rect(); |
|
1196 // Caculate navi pane contents |
|
1197 // hwr_training_navi_pane_g1 |
|
1198 TAknWindowComponentLayout navi_pane_g1_layout = |
|
1199 AknLayoutScalable_Apps::hwr_training_navi_pane_g1 |
|
1200 ( KVarityNaviPaneContents ); |
|
1201 TAknLayoutRect navi_pane_g1_layout_rect; |
|
1202 navi_pane_g1_layout_rect.LayoutRect( navi_pane_rect, navi_pane_g1_layout ); |
|
1203 TRect choicelistRect = navi_pane_g1_layout_rect.Rect(); |
|
1204 iChoicelist->SetRect( choicelistRect ); |
|
1205 |
|
1206 // hwr_training_navi_pane_g2 |
|
1207 // hwr_training_navi_pane_g3 |
|
1208 TAknWindowComponentLayout navi_pane_g3_layout = |
|
1209 AknLayoutScalable_Apps::hwr_training_navi_pane_g3 |
|
1210 ( KVarityNaviPaneContents ); |
|
1211 TAknLayoutRect navi_pane_g3_layout_rect; |
|
1212 navi_pane_g3_layout_rect.LayoutRect( navi_pane_rect, navi_pane_g3_layout ); |
|
1213 iLeftBtn->SetRect( navi_pane_g3_layout_rect.Rect() ); |
|
1214 // hwr_training_navi_pane_g4 |
|
1215 TAknWindowComponentLayout navi_pane_g4_layout = |
|
1216 AknLayoutScalable_Apps::hwr_training_navi_pane_g4 |
|
1217 ( KVarityNaviPaneContents ); |
|
1218 TAknLayoutRect navi_pane_g4_layout_rect; |
|
1219 navi_pane_g4_layout_rect.LayoutRect( navi_pane_rect, navi_pane_g4_layout ); |
|
1220 iRightBtn->SetRect( navi_pane_g4_layout_rect.Rect() ); |
|
1221 // hwr_training_navi_pane_g5 |
|
1222 TAknWindowComponentLayout navi_pane_g5_layout = |
|
1223 AknLayoutScalable_Apps::hwr_training_navi_pane_g5 |
|
1224 ( KVarityNaviPaneContents ); |
|
1225 TAknLayoutRect navi_pane_g5_layout_rect; |
|
1226 navi_pane_g5_layout_rect.LayoutRect( navi_pane_rect, navi_pane_g5_layout ); |
|
1227 TRect indicator_rect = navi_pane_g5_layout_rect.Rect(); |
|
1228 iIindicator->SetRect( indicator_rect ); |
|
1229 // hwr_training_navi_pane_t1 |
|
1230 TAknTextComponentLayout nave_pane_t1_layout = |
|
1231 AknLayoutScalable_Apps::hwr_training_navi_pane_t1 |
|
1232 ( KVarityNaviPaneContents ); |
|
1233 TAknLayoutText navi_pane_t1_layout_text; |
|
1234 navi_pane_t1_layout_text.LayoutText( indicator_rect, nave_pane_t1_layout ); |
|
1235 iIindicator->SetFont( navi_pane_t1_layout_text.Font() ); |
|
1236 iIindicator->SetLabelAlignment( navi_pane_t1_layout_text.Align() ); |
|
1237 |
|
1238 // hwr_training_write_pane |
|
1239 TAknWindowComponentLayout write_pane_layout = |
|
1240 AknLayoutScalable_Apps::hwr_training_write_pane( aVarity ); |
|
1241 TAknLayoutRect write_pane_layout_rect; |
|
1242 write_pane_layout_rect.LayoutRect( main_pane_rect, write_pane_layout ); |
|
1243 iHwrBox->SetRect( write_pane_layout_rect.Rect() ); |
|
1244 |
|
1245 TPoint hwrPos = iHwrBox->PositionRelativeToScreen(); |
|
1246 iHwrBox->SetTooltipPosition( hwrPos + TPoint( iHwrBox->Size().iWidth, KHwrTooltipY ) ); |
|
1247 |
|
1248 // hwr_training_instruct_pane |
|
1249 TAknWindowComponentLayout instruct_pane_layout = |
|
1250 AknLayoutScalable_Apps::hwr_training_instruct_pane( aVarity ); |
|
1251 TAknLayoutRect instruct_pane_layout_rect; |
|
1252 instruct_pane_layout_rect.LayoutRect( main_pane_rect, instruct_pane_layout ); |
|
1253 iLabelPaneRect = instruct_pane_layout_rect.Rect(); |
|
1254 |
|
1255 // count of text rows |
|
1256 TInt count = AknLayoutScalable_Apps:: |
|
1257 list_single_hwr_training_instruct_pane_ParamLimits().LastRow() + 1; |
|
1258 |
|
1259 // array contains all text rows in help screen |
|
1260 RArray<TAknTextComponentLayout> textLayoutArray; |
|
1261 iLineWidthArray.Reset(); |
|
1262 for( TInt i = 0; i < count; i++ ) |
|
1263 { |
|
1264 // pane area for each row |
|
1265 TAknWindowComponentLayout each_row_layout = |
|
1266 AknLayoutScalable_Apps::list_single_hwr_training_instruct_pane( 0, 0, i ); |
|
1267 TAknLayoutRect each_row_layout_rect; |
|
1268 each_row_layout_rect.LayoutRect( iLabelPaneRect, |
|
1269 each_row_layout ); |
|
1270 iLineWidthArray.Append( each_row_layout_rect.Rect().Width() ); |
|
1271 // smaller pane for text itself |
|
1272 TAknTextComponentLayout each_row_text_layout = |
|
1273 AknLayoutScalable_Apps::list_single_hwr_training_instruct_pane_t1(); |
|
1274 |
|
1275 // composition of two latter componets |
|
1276 TAknTextComponentLayout textCompCompositionWiz = |
|
1277 TAknWindowComponentLayout::ComposeText( |
|
1278 each_row_layout, each_row_text_layout ); |
|
1279 |
|
1280 TRAPD(error, textLayoutArray.AppendL( textCompCompositionWiz ) ); |
|
1281 // if error in append function, then just exit the loop |
|
1282 if ( error != KErrNone ) |
|
1283 { |
|
1284 |
|
1285 break; |
|
1286 } |
|
1287 } |
|
1288 |
|
1289 iMultilineLayout = TAknTextComponentLayout::Multiline( textLayoutArray ); |
|
1290 if ( iLabeltext && iWrappedLabelText ) |
|
1291 { |
|
1292 // Be ready to show label |
|
1293 TAknLayoutText multilineTextLayout; |
|
1294 multilineTextLayout.LayoutText( iLabelPaneRect, iMultilineLayout ); |
|
1295 const CFont* font = AknLayoutUtils::FontFromId( iMultilineLayout.FontId() ); |
|
1296 TRAPD( err, WrapLabelTextL( font, *iLabeltext, iLineWidthArray, iWrappedLabelText ) ); |
|
1297 if ( err == KErrNone ) |
|
1298 { |
|
1299 TRAP_IGNORE( iLabel->SetTextL( *iWrappedLabelText ) ); |
|
1300 } |
|
1301 else |
|
1302 { |
|
1303 TRAP_IGNORE( iLabel->SetTextL( *iLabeltext ) ); |
|
1304 } |
|
1305 AknLayoutUtils::LayoutLabel( iLabel, |
|
1306 iLabelPaneRect, |
|
1307 iMultilineLayout ); |
|
1308 } |
|
1309 textLayoutArray.Close(); |
|
1310 |
|
1311 TRgb labelColor = KRgbBlack; |
|
1312 TInt error = GetCachedLabelTextColor( labelColor ); |
|
1313 if ( error == KErrNone ) |
|
1314 { |
|
1315 TRAP_IGNORE( iLabel->OverrideColorL( EColorLabelText, labelColor ) ); |
|
1316 TRAP_IGNORE( iIindicator->OverrideColorL( EColorLabelText, labelColor ) ); |
|
1317 } |
|
1318 } |
|
1319 |
|
1320 void CTruiMainViewContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
1321 { |
|
1322 if ( iHwrBox->BoxState() == CTruiHwrBox::ENewModelDraw ) |
|
1323 { |
|
1324 //Call save function from hwrbox, |
|
1325 //in order to stop periodics in the hwrbox |
|
1326 iHwrBox->HandlePointerEventL( aPointerEvent ); |
|
1327 } |
|
1328 else |
|
1329 { |
|
1330 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
1331 } |
|
1332 } |
|
1333 |