|
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 of Stroke phrase Qwerty entry state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // System includes |
|
30 #include <PtiEngine.h> |
|
31 |
|
32 // User includes |
|
33 #include "AknFepUiInputStateEntryQwertyStrokePhrase.h" |
|
34 #include "AknFepUIManagerStateInterface.h" |
|
35 #include "AknFepUICtrlInputPane.h" |
|
36 #include "AknFepUICtrlCandidatePane.h" |
|
37 #include "AknFepManagerUIInterface.h" |
|
38 #include "AknFepManager.h" |
|
39 |
|
40 // Constant definition |
|
41 const TInt KMinCnadidateCount = 1; |
|
42 const TInt KEnginePhoneticIndex = 1; |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // TAknFepInputStateEntryQwertyStrokePhrase:: |
|
46 // TAknFepInputStateEntryQwertyStrokePhrase |
|
47 // (other items were commented in a header). |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 TAknFepInputStateEntryQwertyStrokePhrase::TAknFepInputStateEntryQwertyStrokePhrase( |
|
51 MAknFepUIManagerStateInterface* aOwner, |
|
52 MAknFepUICtrlContainerChinese* aUIContainer) |
|
53 :TAknFepInputStateEntryQwertyBaseChinesePhrase(aOwner, aUIContainer) |
|
54 { |
|
55 UIContainer()->CandidatePane()->ShowCandidateOrdinals(ETrue); |
|
56 |
|
57 if (EPtiEngineStrokePhraseQwerty != iOwner->PtiEngine()->InputMode()) |
|
58 { |
|
59 iOwner->PtiEngine()->SetInputMode(EPtiEngineStrokePhraseQwerty); |
|
60 } |
|
61 iOwner->PtiEngine()->SetCase(EPtiCaseLower); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // TAknFepInputStateEntryQwertyStrokePhrase::HandleKeyL |
|
66 // (other items were commented in a header). |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 TBool TAknFepInputStateEntryQwertyStrokePhrase::HandleKeyL(TInt aKey, |
|
70 TKeyPressLength aLength) |
|
71 { |
|
72 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
73 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
74 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
75 TBool ret = ETrue; |
|
76 |
|
77 |
|
78 |
|
79 if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed) || |
|
80 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)) |
|
81 { |
|
82 ret = ETrue; |
|
83 } |
|
84 else if((aLength == EShortKeyPress) && iOwner->IsValidChineseInputKeyQwerty(aKey)) |
|
85 { |
|
86 TInt stringBeforeLength(0); |
|
87 TInt stringAfterLength(0); |
|
88 |
|
89 stringBeforeLength = ptiengine->GetPhoneticSpelling(KEnginePhoneticIndex).Length(); |
|
90 stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)aKey).Length(); |
|
91 |
|
92 if (stringBeforeLength != stringAfterLength) |
|
93 { |
|
94 RefreshUI(); |
|
95 } |
|
96 else |
|
97 { |
|
98 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
99 } |
|
100 } |
|
101 else if(aKey == EStdKeyBackspace) |
|
102 { |
|
103 if (iOwner->PtiEngine()->DeleteKeyPress().Length()) |
|
104 { |
|
105 RefreshUI(); |
|
106 } |
|
107 else |
|
108 { |
|
109 iOwner->FepMan()->TryCloseUiL(); |
|
110 if (aLength == ELongKeyPress) |
|
111 { |
|
112 iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue); |
|
113 } |
|
114 } |
|
115 } |
|
116 else if (aKey == EStdKeyEnter) |
|
117 { |
|
118 return ret; |
|
119 } |
|
120 else |
|
121 { |
|
122 ret = TAknFepInputStateEntryQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength); |
|
123 } |
|
124 |
|
125 return ret; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // TAknFepInputStateEntryQwertyStrokePhrase::RefreshUI |
|
130 // (other items were commented in a header). |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void TAknFepInputStateEntryQwertyStrokePhrase::RefreshUI() |
|
134 { |
|
135 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
136 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
137 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
138 |
|
139 // get cursor position |
|
140 TPoint baseLine; |
|
141 TInt height(0); |
|
142 TInt ascent(0); |
|
143 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
144 if (ret == KErrNone) |
|
145 { |
|
146 uiContainer->SetContainerPosition(baseLine, height); |
|
147 } |
|
148 |
|
149 // layout candidate and fill candidate buffer for first display page |
|
150 TInt candidateCount(0); |
|
151 TRAP(ret, |
|
152 candidateCount = ptiengine->GetChinesePhraseCandidatesL( |
|
153 *(uiContainer->CandidatePane()->CandidateArray()))); |
|
154 if(candidateCount == 0 || ret != KErrNone) |
|
155 { |
|
156 return; |
|
157 } |
|
158 |
|
159 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
160 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
161 |
|
162 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
163 uiContainer->CandidatePane()->IsFirstPage()); |
|
164 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
165 TBool showHorizontalScrollArrows = multiplePages || bufLength > KMinCnadidateCount; |
|
166 |
|
167 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
168 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
169 |
|
170 uiContainer->Enable(ETrue); |
|
171 uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
172 TPtrC ptr = ptiengine->GetPhoneticSpelling(KEnginePhoneticIndex); |
|
173 inputPane->SetText(ptr); |
|
174 UpdateIndicator(); |
|
175 } |
|
176 |
|
177 // End of file |