|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Implementation for gspeninputimple |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikenv.h> |
|
20 #include <eikappui.h> |
|
21 #include <aknradiobuttonsettingpage.h> |
|
22 #include <AknColourSelectionGrid.h> |
|
23 #include <gspeninputpluginrsc.rsg> |
|
24 #include <StringLoader.h> |
|
25 #include <f32file.h> |
|
26 #include <bautils.h> |
|
27 #include <avkon.mbg> |
|
28 #include <aknlistquerydialog.h> |
|
29 #include <aknconsts.h> |
|
30 #include <eikspane.h> |
|
31 #include <akntitle.h> |
|
32 #include <akntoolbar.h> |
|
33 #include <eikapp.h> |
|
34 #include <AknNullService.h> |
|
35 |
|
36 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2 |
|
37 #include <gfxtranseffect/gfxtranseffect.h> |
|
38 #include <akntransitionutils.h> |
|
39 #include <avkondomainpskeys.h> |
|
40 #include <e32property.h> |
|
41 |
|
42 #endif |
|
43 |
|
44 #include "gspeninputplugin.h" |
|
45 #include "gspeninputimple.h" |
|
46 #include "gspeninputmodel.h" |
|
47 #include "gssettingdialog.h" |
|
48 |
|
49 #define iAvkonAppUi ((CAknAppUi*)CEikonEnv::Static()->EikAppUi()) |
|
50 |
|
51 const TInt KTitlePaneImage = 0; |
|
52 const TInt KTitlePaneText = 1; |
|
53 |
|
54 const TUid KUidPenInputSettingApp = { 0x2001959B }; |
|
55 |
|
56 #define KMaxCmdLen 16 |
|
57 |
|
58 // ======== MEMBER FUNCTIONS ======== |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // Constructor |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 CGSPenInputImple* CGSPenInputImple::NewL() |
|
65 { |
|
66 CGSPenInputImple* self = new (ELeave) CGSPenInputImple(); |
|
67 |
|
68 CleanupStack::PushL(self); |
|
69 self->ConstructL(); |
|
70 CleanupStack::Pop(self); |
|
71 |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // Destructor |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 CGSPenInputImple::~CGSPenInputImple() |
|
80 { |
|
81 iResourceLoader.Close(); |
|
82 delete iModel; |
|
83 delete iWritingSpeedItems; |
|
84 delete iPenTrailWidthItems; |
|
85 delete iInputModeItems; |
|
86 delete iInputMethodForFindItems; |
|
87 delete iGuideLineItems; |
|
88 delete iRecognitionWithDictionary; |
|
89 delete iDialog; |
|
90 delete iTitleTextBak; |
|
91 delete iChineseFindMethodItems; |
|
92 delete iNullService; |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // Get model instance |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 CGSPenInputModel* CGSPenInputImple::Model() |
|
100 { |
|
101 return iModel; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // Current writing speed name |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 void CGSPenInputImple::WritingSpeed(TDes& aWritingSpeed) |
|
109 { |
|
110 const TInt writingSpeed = iModel->WritingSpeed(); |
|
111 const TInt count = iWritingSpeedItems->Count(); |
|
112 |
|
113 for (TInt index = 0; index < count; ++index) |
|
114 { |
|
115 if (index == writingSpeed) |
|
116 { |
|
117 aWritingSpeed = (*iWritingSpeedItems)[index]; |
|
118 break; |
|
119 } |
|
120 } |
|
121 |
|
122 if (!aWritingSpeed.Length() && |
|
123 iWritingSpeedItems->Count() > 0) |
|
124 { |
|
125 aWritingSpeed = (*iWritingSpeedItems)[0]; |
|
126 } |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // Current trail width name |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 void CGSPenInputImple::TrailWidth(TDes& aTrailWidth) |
|
134 { |
|
135 const TInt trailwidth = iModel->TrailWidth(); |
|
136 const TInt count = iPenTrailWidthItems->Count(); |
|
137 |
|
138 for (TInt index = 0; index < count; ++index) |
|
139 { |
|
140 if (index == trailwidth) |
|
141 { |
|
142 aTrailWidth = (*iPenTrailWidthItems)[index]; |
|
143 break; |
|
144 } |
|
145 } |
|
146 |
|
147 if (!aTrailWidth.Length() && iPenTrailWidthItems->Count() > 0) |
|
148 { |
|
149 aTrailWidth = (*iPenTrailWidthItems)[0]; |
|
150 } |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------- |
|
154 // Current guide line name |
|
155 // --------------------------------------------------------- |
|
156 // |
|
157 void CGSPenInputImple::GuideLine(TDes& aGuideLine) |
|
158 { |
|
159 const TInt guideLine = iModel->GuideLine(); |
|
160 |
|
161 aGuideLine = (*iGuideLineItems)[guideLine == 0 ? 1:0]; |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // Current input method for find name |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 void CGSPenInputImple::InputMethodForFind(TDes& aInputMethodForFind) |
|
169 { |
|
170 const TInt inputmethodforfind = iModel->InputMethodForFind(); |
|
171 |
|
172 aInputMethodForFind = (*iInputMethodForFindItems)[inputmethodforfind == 0 ? 0:1]; |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------- |
|
176 // Current chinese find method item text |
|
177 // --------------------------------------------------------- |
|
178 // |
|
179 void CGSPenInputImple::GetCurrentChineseFineMethodItem |
|
180 ( TDes& aChineseFindMethod ) |
|
181 { |
|
182 const TInt chineseFindMethod = iModel->ChineseFindMethod(); |
|
183 if ( iChineseFindMethodItems |
|
184 && chineseFindMethod < iChineseFindMethodItems->Count() ) |
|
185 { |
|
186 aChineseFindMethod |
|
187 = (*iChineseFindMethodItems)[chineseFindMethod]; |
|
188 } |
|
189 else |
|
190 { |
|
191 aChineseFindMethod = KNullDesC; |
|
192 } |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------- |
|
196 // Load correct items for chinese find methods |
|
197 // by different chinese languages |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 void CGSPenInputImple::LoadChineseFindMethodItemsL() |
|
201 { |
|
202 TInt resourceID = iModel->ChineseFindMethodResourceID(); |
|
203 delete iChineseFindMethodItems; |
|
204 iChineseFindMethodItems = NULL; |
|
205 if ( resourceID != KErrNotFound ) |
|
206 { |
|
207 iChineseFindMethodItems |
|
208 = CEikonEnv::Static()->ReadDesC16ArrayResourceL |
|
209 ( resourceID ); |
|
210 } |
|
211 } |
|
212 |
|
213 |
|
214 // --------------------------------------------------------- |
|
215 // Load correct items for default on screen vbk items |
|
216 // --------------------------------------------------------- |
|
217 // |
|
218 void CGSPenInputImple::LoadDefaultOnScreenVkbItemsL() |
|
219 { |
|
220 TInt resourceID = iModel->InputModeResourceID(); |
|
221 // Reload input mode items |
|
222 delete iInputModeItems; |
|
223 iInputModeItems = NULL; |
|
224 if ( resourceID != KErrNotFound ) |
|
225 { |
|
226 iInputModeItems |
|
227 = CEikonEnv::Static()->ReadDesC16ArrayResourceL |
|
228 ( resourceID ); |
|
229 // Reload current input mode |
|
230 iModel->InputMode(); |
|
231 } |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------- |
|
235 // Recognition with dictionary |
|
236 // --------------------------------------------------------- |
|
237 // |
|
238 void CGSPenInputImple::RecognitionWithDictionary(TDes& aRecognitionWithDictionary) |
|
239 { |
|
240 const TInt recognitionWithDictionary = iModel->RecognitionWithDictionary(); |
|
241 |
|
242 aRecognitionWithDictionary = (*iRecognitionWithDictionary)[recognitionWithDictionary == 0 ? 1:0]; |
|
243 } |
|
244 |
|
245 |
|
246 // --------------------------------------------------------- |
|
247 // Current input mode name |
|
248 // --------------------------------------------------------- |
|
249 // |
|
250 void CGSPenInputImple::InputModeL(TDes& aInputMode) |
|
251 { |
|
252 if (!iModel->ChineseLanguage()) |
|
253 { |
|
254 return; |
|
255 } |
|
256 |
|
257 delete iInputModeItems; |
|
258 iInputModeItems = NULL; |
|
259 |
|
260 if (iModel->InputModeResourceID() != -1) |
|
261 { |
|
262 iInputModeItems = CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
263 iModel->InputModeResourceID()); |
|
264 iModel->ResetInputModeArray(iInputModeItems); |
|
265 } |
|
266 else |
|
267 { |
|
268 aInputMode = KNullDesC; |
|
269 return; |
|
270 } |
|
271 |
|
272 // Update iInputMode from CenRep |
|
273 iModel->InputMode(); |
|
274 const TInt index = iModel->InputModeInSettingPage(); |
|
275 |
|
276 if ( iInputModeItems && index < iInputModeItems->Count() ) |
|
277 { |
|
278 aInputMode = (*iInputModeItems)[index]; |
|
279 } |
|
280 else |
|
281 { |
|
282 aInputMode = KNullDesC; |
|
283 } |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------- |
|
287 // Dispaly input pen main view |
|
288 // --------------------------------------------------------- |
|
289 // |
|
290 void CGSPenInputImple::ShowMainViewL() |
|
291 { |
|
292 TUid appUid = iAvkonAppUi->Application()->AppDllUid(); |
|
293 // if open from trui, use dialog |
|
294 // otherwise, use peninput setting application |
|
295 // Launch peninputsetting application as embedded. |
|
296 if ( iNullService ) |
|
297 { |
|
298 delete iNullService; |
|
299 iNullService = NULL; |
|
300 } |
|
301 iNullService = CAknNullService::NewL |
|
302 ( KUidPenInputSettingApp, NULL ); |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------- |
|
306 // Display "Pen input language" setting page |
|
307 // --------------------------------------------------------- |
|
308 // |
|
309 TBool CGSPenInputImple::ShowInputLanguageSettingPageL() |
|
310 { |
|
311 TBool ret(EFalse); |
|
312 CDesCArrayFlat* languageItems = new(ELeave)CDesCArrayFlat(10); |
|
313 CleanupStack::PushL(languageItems); |
|
314 |
|
315 iModel->GetLanguagesFromPtiL(EFalse, languageItems); |
|
316 |
|
317 TInt currentItem = iModel->InputLanguageIndex(); |
|
318 |
|
319 CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage( |
|
320 R_GS_INPUTLANGUAGE_TEXT_SETTING_PAGE, |
|
321 currentItem, |
|
322 languageItems); |
|
323 |
|
324 CleanupStack::PushL(dlg); |
|
325 |
|
326 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
327 { |
|
328 if (currentItem != iModel->InputLanguageIndex()) |
|
329 { |
|
330 iModel->SetInputLanguageIndex(currentItem); |
|
331 iModel->SetInputLanguageL(); |
|
332 if (iModel->ChineseLanguage()) |
|
333 { |
|
334 iModel->ResetFepDefaultInputMode(); |
|
335 } |
|
336 ret = ETrue; |
|
337 } |
|
338 } |
|
339 |
|
340 CleanupStack::Pop(dlg); |
|
341 CleanupStack::PopAndDestroy(languageItems); |
|
342 |
|
343 return ret; |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------- |
|
347 // Display pop up list setting page |
|
348 // --------------------------------------------------------- |
|
349 // |
|
350 TBool CGSPenInputImple::ShowInputLanguagePageL() |
|
351 { |
|
352 TBool ret(EFalse); |
|
353 CDesCArrayFlat* languagesList = new (ELeave) CDesCArrayFlat(10); |
|
354 CleanupStack::PushL(languagesList); |
|
355 |
|
356 iModel->GetPopupQuerylanguagesFromPtiL(languagesList); |
|
357 |
|
358 TInt currentItem = iModel->InputLanguageIndex(); |
|
359 CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog(¤tItem); |
|
360 |
|
361 dlg->PrepareLC(R_GS_LANGUAGES_LIST_QUERY); |
|
362 |
|
363 CAknListQueryControl* listQueryControl = |
|
364 static_cast<CAknListQueryControl*> (dlg->Control(EListQueryControl)); |
|
365 |
|
366 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2 |
|
367 // Stops transition |
|
368 GfxTransEffect::Deregister(dlg); |
|
369 #endif |
|
370 CTextListBoxModel* model = listQueryControl->Listbox()->Model(); |
|
371 |
|
372 // Add icons to the listbox: |
|
373 CArrayPtr<CGulIcon>* icons = new( ELeave ) CArrayPtrFlat<CGulIcon>(10); |
|
374 CleanupStack::PushL(icons); |
|
375 |
|
376 LoadIconL(icons, EMbmAvkonQgn_prop_sub_current, |
|
377 EMbmAvkonQgn_prop_sub_current_mask); |
|
378 |
|
379 listQueryControl->Listbox()->ItemDrawer()->FormattedCellData() |
|
380 ->SetIconArrayL(icons); // transfer to list query |
|
381 |
|
382 CleanupStack::Pop(icons); |
|
383 |
|
384 // Activate selected language: |
|
385 model->SetOwnershipType(ELbmOwnsItemArray); |
|
386 model->SetItemTextArray(languagesList); // transfer to list query |
|
387 listQueryControl->Listbox()->SetCurrentItemIndex(currentItem); |
|
388 // Needed because not using icon in cell. |
|
389 listQueryControl->Listbox()->ItemDrawer()->FormattedCellData() |
|
390 ->SetNotAlwaysDrawnSubCellL(0, ETrue); |
|
391 |
|
392 // Fire up the dialog |
|
393 TInt returnValue = dlg->RunLD(); |
|
394 |
|
395 if(returnValue == EAknSoftkeyOk) |
|
396 { |
|
397 if(currentItem != iModel->InputLanguageIndex()) |
|
398 { |
|
399 iModel->SetInputLanguageIndex(currentItem); |
|
400 iModel->SetInputLanguageL(); |
|
401 if (iModel->ChineseLanguage()) |
|
402 { |
|
403 iModel->ResetFepDefaultInputMode(); |
|
404 } |
|
405 ret = ETrue; |
|
406 } |
|
407 } |
|
408 |
|
409 CleanupStack::Pop(languagesList); |
|
410 |
|
411 return ret; |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------- |
|
415 // Display "inputmode" setting page |
|
416 // --------------------------------------------------------- |
|
417 // |
|
418 TBool CGSPenInputImple::ShowInputModePageL() |
|
419 { |
|
420 if (!iModel->ChineseLanguage()) |
|
421 { |
|
422 return EFalse; |
|
423 } |
|
424 |
|
425 delete iInputModeItems; |
|
426 iInputModeItems = NULL; |
|
427 |
|
428 if (iModel->InputModeResourceID() != -1) |
|
429 { |
|
430 iInputModeItems = CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
431 iModel->InputModeResourceID()); |
|
432 iModel->ResetInputModeArray(iInputModeItems); |
|
433 } |
|
434 else |
|
435 { |
|
436 return EFalse; |
|
437 } |
|
438 |
|
439 TBool ret = EFalse; |
|
440 TInt currentItem = iModel->InputModeInSettingPage(); |
|
441 if ( currentItem < iInputModeItems->Count() ) |
|
442 { |
|
443 CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage( |
|
444 R_GS_VKB_DEFAULTCHINESE_OSK_TEXT_SETTING_PAGE, |
|
445 currentItem, |
|
446 iInputModeItems); |
|
447 |
|
448 CleanupStack::PushL(dlg); |
|
449 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
450 { |
|
451 if(currentItem != iModel->InputModeInSettingPage()) |
|
452 { |
|
453 iModel->SetInputModeBySettingPage(currentItem); |
|
454 ret = ETrue; |
|
455 } |
|
456 } |
|
457 |
|
458 CleanupStack::Pop(dlg); |
|
459 } |
|
460 return ret; |
|
461 } |
|
462 |
|
463 // --------------------------------------------------------- |
|
464 // Display "Writing speed" setting page |
|
465 // --------------------------------------------------------- |
|
466 // |
|
467 TBool CGSPenInputImple::ShowWritingSpeedPageL() |
|
468 { |
|
469 TInt currentItem = iModel->WritingSpeed(); |
|
470 |
|
471 CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage( |
|
472 R_GS_WRITINGSPEED_TEXT_SETTING_PAGE, |
|
473 currentItem, |
|
474 iWritingSpeedItems); |
|
475 |
|
476 CleanupStack::PushL(dlg); |
|
477 |
|
478 TBool ret = EFalse; |
|
479 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
480 { |
|
481 if(currentItem != iModel->WritingSpeed()) |
|
482 { |
|
483 iModel->SetWritingSpeed(currentItem); |
|
484 ret = ETrue; |
|
485 } |
|
486 } |
|
487 |
|
488 CleanupStack::Pop(dlg); |
|
489 |
|
490 return ret; |
|
491 } |
|
492 |
|
493 // --------------------------------------------------------- |
|
494 // Display "Guide Line" setting page |
|
495 // --------------------------------------------------------- |
|
496 // |
|
497 TBool CGSPenInputImple::ShowGuideLinePageL() |
|
498 { |
|
499 TInt currentItem = iModel->GuideLine(); |
|
500 |
|
501 if (currentItem == 1) |
|
502 { |
|
503 currentItem = 0; |
|
504 } |
|
505 else |
|
506 { |
|
507 currentItem = 1; |
|
508 } |
|
509 |
|
510 CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage( |
|
511 R_GS_GUIDLINE_TEXT_SETTING_PAGE, |
|
512 currentItem, |
|
513 iGuideLineItems); |
|
514 |
|
515 CleanupStack::PushL(dlg); |
|
516 |
|
517 TBool ret = EFalse; |
|
518 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
519 { |
|
520 if(currentItem == iModel->GuideLine()) |
|
521 { |
|
522 iModel->SetGuideLine(currentItem == 0? 1:0); |
|
523 ret = ETrue; |
|
524 } |
|
525 } |
|
526 |
|
527 CleanupStack::Pop(dlg); |
|
528 |
|
529 return ret; |
|
530 } |
|
531 |
|
532 // --------------------------------------------------------- |
|
533 // Display "Recognition with dictionary" setting page |
|
534 // --------------------------------------------------------- |
|
535 // |
|
536 TBool CGSPenInputImple::ShowRecognitionWithDictionaryL() |
|
537 { |
|
538 TInt currentItem = iModel->RecognitionWithDictionary(); |
|
539 |
|
540 if (currentItem == 1) |
|
541 { |
|
542 currentItem = 0; |
|
543 } |
|
544 else |
|
545 { |
|
546 currentItem = 1; |
|
547 } |
|
548 |
|
549 CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage( |
|
550 R_GS_RECOGNITIONWITHDICTIONARY_TEXT_SETTING_PAGE, |
|
551 currentItem, |
|
552 iRecognitionWithDictionary); |
|
553 |
|
554 CleanupStack::PushL(dlg); |
|
555 |
|
556 TBool ret = EFalse; |
|
557 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
558 { |
|
559 if(currentItem == iModel->RecognitionWithDictionary()) |
|
560 { |
|
561 iModel->SetRecognitionWithDictionary(currentItem == 0? 1:0); |
|
562 ret = ETrue; |
|
563 } |
|
564 } |
|
565 |
|
566 CleanupStack::Pop(dlg); |
|
567 |
|
568 return ret; |
|
569 } |
|
570 |
|
571 // --------------------------------------------------------- |
|
572 // Display "Pen trail width" setting page |
|
573 // --------------------------------------------------------- |
|
574 // |
|
575 TBool CGSPenInputImple::ShowTrailWidthPageL() |
|
576 { |
|
577 TInt currentItem = iModel->TrailWidth(); |
|
578 |
|
579 CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage( |
|
580 R_GS_TRAILWIDTH_TEXT_SETTING_PAGE, |
|
581 currentItem, |
|
582 iPenTrailWidthItems); |
|
583 |
|
584 CleanupStack::PushL(dlg); |
|
585 |
|
586 TBool ret = EFalse; |
|
587 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
588 { |
|
589 if(currentItem != iModel->TrailWidth()) |
|
590 { |
|
591 iModel->SetTrailWidth(currentItem); |
|
592 ret = ETrue; |
|
593 } |
|
594 } |
|
595 |
|
596 CleanupStack::Pop(dlg); |
|
597 |
|
598 return ret; |
|
599 } |
|
600 |
|
601 // --------------------------------------------------------- |
|
602 // Display "Pen trail colour" setting page |
|
603 // --------------------------------------------------------- |
|
604 // |
|
605 TBool CGSPenInputImple::ShowTrailColourPageL() |
|
606 { |
|
607 CArrayFixFlat<TRgb>* colours = new (ELeave) CArrayFixFlat<TRgb>(8); |
|
608 CleanupStack::PushL(colours); |
|
609 |
|
610 colours->AppendL(KRgbBlack); |
|
611 colours->AppendL(KRgbDarkGray); |
|
612 colours->AppendL(KRgbDarkRed); |
|
613 colours->AppendL(KRgbDarkGreen); |
|
614 colours->AppendL(KRgbDarkYellow); |
|
615 colours->AppendL(KRgbDarkBlue); |
|
616 colours->AppendL(KRgbDarkMagenta); |
|
617 colours->AppendL(KRgbDarkCyan); |
|
618 colours->AppendL(KRgbRed); |
|
619 colours->AppendL(KRgbGreen); |
|
620 colours->AppendL(KRgbYellow); |
|
621 colours->AppendL(KRgbBlue); |
|
622 colours->AppendL(KRgbMagenta); |
|
623 colours->AppendL(KRgbCyan); |
|
624 colours->AppendL(KRgbGray); |
|
625 colours->AppendL(KRgbWhite); |
|
626 |
|
627 TBool noneChosen = EFalse; |
|
628 TRgb colourChosen = TRgb(iModel->TrailColour()); |
|
629 |
|
630 CAknColourSelectionGrid* dlg = CAknColourSelectionGrid::NewL(colours, |
|
631 EFalse, |
|
632 noneChosen, |
|
633 colourChosen); |
|
634 CleanupStack::PushL(dlg); |
|
635 |
|
636 TBool ret = EFalse; |
|
637 if (dlg->ExecuteLD()) |
|
638 { |
|
639 iModel->SetTrailColour(colourChosen.Value()); |
|
640 ret = ETrue; |
|
641 } |
|
642 |
|
643 CleanupStack::Pop(dlg); |
|
644 CleanupStack::PopAndDestroy(colours); |
|
645 |
|
646 return ret; |
|
647 } |
|
648 |
|
649 // --------------------------------------------------------- |
|
650 // Display "Input method for find" setting page |
|
651 // --------------------------------------------------------- |
|
652 // |
|
653 TBool CGSPenInputImple::ShowInputMethodForFindPageL() |
|
654 { |
|
655 TInt currentItem = iModel->InputMethodForFind(); |
|
656 |
|
657 CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage( |
|
658 R_GS_INPUTMETHODFORFIND_TEXT_SETTING_PAGE, |
|
659 currentItem, |
|
660 iInputMethodForFindItems); |
|
661 |
|
662 CleanupStack::PushL(dlg); |
|
663 TBool ret = EFalse; |
|
664 |
|
665 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
666 { |
|
667 if(currentItem != iModel->InputMethodForFind()) |
|
668 { |
|
669 iModel->SetInputMethodForFind(currentItem); |
|
670 ret = ETrue; |
|
671 } |
|
672 } |
|
673 |
|
674 CleanupStack::Pop(dlg); |
|
675 return ret; |
|
676 } |
|
677 |
|
678 // --------------------------------------------------------- |
|
679 // Display "Chinese Find Method" setting page |
|
680 // --------------------------------------------------------- |
|
681 // |
|
682 TBool CGSPenInputImple::ShowChineseFindMethodPageL() |
|
683 { |
|
684 TInt currentItem = iModel->ChineseFindMethod(); |
|
685 TBool ret = EFalse; |
|
686 if ( !iChineseFindMethodItems ) |
|
687 { |
|
688 // In that case, don't open setting page |
|
689 return EFalse; |
|
690 } |
|
691 CAknRadioButtonSettingPage* dlg |
|
692 = new (ELeave) CAknRadioButtonSettingPage( |
|
693 R_GS_CHINESEFINDMETHOD_TEXT_SETTING_PAGE, |
|
694 currentItem, |
|
695 iChineseFindMethodItems); |
|
696 CleanupStack::PushL(dlg); |
|
697 |
|
698 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
699 { |
|
700 if(currentItem != iModel->ChineseFindMethod()) |
|
701 { |
|
702 iModel->SetChineseFindMethod(currentItem); |
|
703 ret = ETrue; |
|
704 } |
|
705 } |
|
706 CleanupStack::Pop(dlg); |
|
707 return ret; |
|
708 } |
|
709 |
|
710 // --------------------------------------------------------- |
|
711 // Start touch screen calibration |
|
712 // --------------------------------------------------------- |
|
713 // |
|
714 void CGSPenInputImple::StartTouchScreenCalibL() |
|
715 { |
|
716 _LIT( KTouchScreenCalibFileName, "z:TouchScreenCalib.exe" ); |
|
717 TInt err = KErrNone; |
|
718 |
|
719 TParse parse; |
|
720 parse.Set( KTouchScreenCalibFileName, |
|
721 &KDC_PROGRAMS_DIR, NULL ); |
|
722 TFileName fileName( parse.FullName() ); |
|
723 |
|
724 RProcess process; |
|
725 err = process.Create( fileName, KNullDesC ); |
|
726 User::LeaveIfError(err); |
|
727 |
|
728 CApaCommandLine* commandLine = CApaCommandLine::NewLC(); |
|
729 commandLine->SetDocumentNameL( KNullDesC ); |
|
730 commandLine->SetExecutableNameL( fileName ); |
|
731 commandLine->SetProcessEnvironmentL( process ); |
|
732 CleanupStack::PopAndDestroy( commandLine ); |
|
733 |
|
734 process.Resume(); |
|
735 process.Close(); |
|
736 } |
|
737 |
|
738 // --------------------------------------------------------- |
|
739 // Constructor |
|
740 // --------------------------------------------------------- |
|
741 // |
|
742 CGSPenInputImple::CGSPenInputImple() |
|
743 : iResourceLoader(*(CCoeEnv::Static())) |
|
744 { |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------- |
|
748 // Constructor |
|
749 // --------------------------------------------------------- |
|
750 // |
|
751 void CGSPenInputImple::ConstructL() |
|
752 { |
|
753 iModel = CGSPenInputModel::NewL( this ); |
|
754 iModel->SetOwner(NULL); |
|
755 |
|
756 iModel->InputLanguage(); |
|
757 iModel->InputMode(); |
|
758 iModel->TrailColour(); |
|
759 iModel->TrailWidth(); |
|
760 iModel->InputMethodForFind(); |
|
761 iModel->GuideLine(); |
|
762 iModel->RecognitionWithDictionary(); |
|
763 |
|
764 OpenResourceFileL(KGSInputPenPluginResourceFileName); |
|
765 iWritingSpeedItems = CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
766 R_GS_WRITINGSPEED_SETTING_PAGE_LBX); |
|
767 iPenTrailWidthItems = CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
768 R_GS_PENTRAIL_SETTING_PAGE_LBX); |
|
769 |
|
770 iGuideLineItems = CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
771 R_GS_GUIDLINE_SETTING_PAGE_LBX); |
|
772 |
|
773 iInputMethodForFindItems = CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
774 R_GS_INPUTMETHODFORFIND_SETTING_PAGE_LBX); |
|
775 iRecognitionWithDictionary = CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
776 R_GS_RECOGNIZEWITHDICTIONARY_SETTING_PAGE_LBX); |
|
777 |
|
778 if (iModel->InputModeResourceID() != -1) |
|
779 { |
|
780 iInputModeItems = CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
781 iModel->InputModeResourceID()); |
|
782 } |
|
783 } |
|
784 |
|
785 void CGSPenInputImple::HandleNotifyInt(TUint32 aId, TInt aNewValue) |
|
786 { |
|
787 if ( iDialog ) |
|
788 { |
|
789 iDialog->HandleNotifyInt( aId, aNewValue ); |
|
790 } |
|
791 } |
|
792 |
|
793 void CGSPenInputImple::HandleNotifyInt(TUid aRepositoryUid, TUint32 aId, TInt aNewValue) |
|
794 { |
|
795 if ( iDialog ) |
|
796 { |
|
797 iDialog->HandleNotifyInt( aRepositoryUid, aId, aNewValue ); |
|
798 } |
|
799 } |
|
800 |
|
801 // --------------------------------------------------------- |
|
802 // Opens the nearest localized resourcefile using aResourceLoader |
|
803 // --------------------------------------------------------- |
|
804 // |
|
805 void CGSPenInputImple::OpenResourceFileL(const TDesC& aResourceFileName) |
|
806 { |
|
807 RFs fsSession; |
|
808 User::LeaveIfError(fsSession.Connect()); |
|
809 CleanupClosePushL(fsSession); |
|
810 |
|
811 // Find the resource file: |
|
812 TParse parse; |
|
813 parse.Set(aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL); |
|
814 TFileName fileName(parse.FullName()); |
|
815 |
|
816 // Get language of resource file: |
|
817 BaflUtils::NearestLanguageFile(fsSession, fileName); |
|
818 |
|
819 // Open resource file: |
|
820 iResourceLoader.OpenL(fileName); |
|
821 |
|
822 // If leave occurs before this, close is called automatically when the |
|
823 // thread exits. |
|
824 fsSession.Close(); |
|
825 |
|
826 CleanupStack::PopAndDestroy(); //fsSession |
|
827 } |
|
828 |
|
829 // --------------------------------------------------------- |
|
830 // Load language list popup query dialog icons from resource |
|
831 // --------------------------------------------------------- |
|
832 // |
|
833 void CGSPenInputImple::LoadIconL(CArrayPtr<CGulIcon>* aIcons, |
|
834 TInt aBitmapId, |
|
835 TInt aMaskId) |
|
836 { |
|
837 CGulIcon* icon = CGulIcon::NewLC(); |
|
838 CFbsBitmap* bitmap = 0; |
|
839 CFbsBitmap* mask = 0; |
|
840 |
|
841 AknIconUtils::CreateIconL(bitmap, mask, KAvkonBitmapFile, aBitmapId, aMaskId); |
|
842 icon->SetBitmap(bitmap); |
|
843 icon->SetMask(mask); |
|
844 aIcons->AppendL(icon); |
|
845 |
|
846 CleanupStack::Pop(icon); |
|
847 } |
|
848 |
|
849 void CGSPenInputImple::PrepareScreenFurnitureL( TBool& aToolbarShow ) |
|
850 { |
|
851 // Get application UI StatusPane |
|
852 CEikStatusPane* statusPane = |
|
853 static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())->StatusPane(); |
|
854 // Get application UI TitlePane |
|
855 CAknTitlePane* titlePane = |
|
856 static_cast<CAknTitlePane*>(statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle))); |
|
857 |
|
858 CCoeControl* akncontrol = static_cast<CCoeControl*>(titlePane); |
|
859 CCoeControl* imageControl = akncontrol->ComponentControl(KTitlePaneImage); |
|
860 CCoeControl* textControl = akncontrol->ComponentControl(KTitlePaneText); |
|
861 |
|
862 if (imageControl && |
|
863 textControl && |
|
864 imageControl != textControl) |
|
865 imageControl->MakeVisible(EFalse); |
|
866 |
|
867 // Backup title pane text |
|
868 if ( iTitleTextBak ) |
|
869 { |
|
870 delete iTitleTextBak; |
|
871 iTitleTextBak = NULL; |
|
872 } |
|
873 if ( titlePane->Text() && titlePane->Text()->Length() > 0 ) |
|
874 { |
|
875 iTitleTextBak = HBufC::NewL( titlePane->Text()->Length() ); |
|
876 TPtr titlePtr = iTitleTextBak->Des(); |
|
877 titlePtr.Copy( *( titlePane->Text() ) ); |
|
878 } |
|
879 |
|
880 // Get GSPlugin title |
|
881 HBufC* result = StringLoader::LoadL(R_GS_INPUTPEN_PLUGIN_CAPTION); |
|
882 titlePane->SetText( result ); |
|
883 |
|
884 |
|
885 //Hide navibar |
|
886 CAknNavigationControlContainer* naviContainer = |
|
887 static_cast<CAknNavigationControlContainer*>( |
|
888 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
889 if( naviContainer ) |
|
890 { |
|
891 naviContainer->PushDefaultL(); |
|
892 } |
|
893 |
|
894 //Hide Toolbar |
|
895 CAknToolbar* toolBar = iAvkonAppUi->CurrentFixedToolbar(); |
|
896 if( toolBar && toolBar->IsShown() ) |
|
897 { |
|
898 aToolbarShow = ETrue; |
|
899 toolBar->SetToolbarVisibility( EFalse ); |
|
900 } |
|
901 |
|
902 // Backup status pane |
|
903 isSpVisibleBak = statusPane->IsVisible(); |
|
904 // Show status pane |
|
905 if ( !isSpVisibleBak ) |
|
906 { |
|
907 statusPane->MakeVisible( ETrue ); |
|
908 } |
|
909 } |
|
910 |
|
911 void CGSPenInputImple::RestoreScreenFurnitureL(TBool aShowToolbar ) |
|
912 { |
|
913 CEikStatusPane* statusPane = |
|
914 static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())->StatusPane(); |
|
915 // Get application UI TitlePane |
|
916 CAknTitlePane* titlePane = |
|
917 static_cast<CAknTitlePane*>(statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle))); |
|
918 |
|
919 // Reset the title |
|
920 if ( iTitleTextBak ) |
|
921 { |
|
922 titlePane->SetTextL( *iTitleTextBak ); |
|
923 delete iTitleTextBak; |
|
924 iTitleTextBak = NULL; |
|
925 } |
|
926 else |
|
927 { |
|
928 titlePane->SetTextL( KNullDesC ); |
|
929 } |
|
930 |
|
931 CCoeControl* akncontrol = static_cast<CCoeControl*>(titlePane); |
|
932 CCoeControl* imageControl = akncontrol->ComponentControl(KTitlePaneImage); |
|
933 CCoeControl* textControl = akncontrol->ComponentControl(KTitlePaneText); |
|
934 |
|
935 if (imageControl && |
|
936 textControl && |
|
937 imageControl != textControl) |
|
938 imageControl->MakeVisible(ETrue); |
|
939 |
|
940 |
|
941 //Restore Toolbar |
|
942 CAknToolbar* toolBar = iAvkonAppUi->CurrentFixedToolbar(); |
|
943 if( toolBar && aShowToolbar ) |
|
944 { |
|
945 toolBar->SetToolbarVisibility( ETrue ); |
|
946 } |
|
947 |
|
948 //Restore navibar |
|
949 CAknNavigationControlContainer* naviContainer = |
|
950 static_cast<CAknNavigationControlContainer*>( |
|
951 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
952 if( naviContainer ) |
|
953 { |
|
954 naviContainer->Pop(); |
|
955 } |
|
956 } |
|
957 |
|
958 // --------------------------------------------------------- |
|
959 // Restore caller's status pane visibility. |
|
960 // --------------------------------------------------------- |
|
961 // |
|
962 void CGSPenInputImple::RestoreStatusPaneVisibility() |
|
963 { |
|
964 CEikStatusPane* statusPane = |
|
965 static_cast<CAknAppUi*> |
|
966 (CEikonEnv::Static()->EikAppUi())->StatusPane(); |
|
967 |
|
968 // restore status pane |
|
969 if ( isSpVisibleBak != statusPane->IsVisible() ) |
|
970 { |
|
971 statusPane->MakeVisible( isSpVisibleBak ); |
|
972 } |
|
973 } |
|
974 |
|
975 // End Of File |