|
1 /* |
|
2 * Copyright (c) 2002-2004 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 * Provides the TAknFepInputStateCompletionKatakana methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 // INCLUDE FILES |
|
31 #include "AknFepUiInputStateCompletionKatakana.h" |
|
32 #include "AknFepUIManagerStateInterface.h" // MAknFepUIManagerStateInterface |
|
33 #include "AknFepManagerUIInterface.h" // MAknFepManagerUIInterface |
|
34 #include "AknFepUICtrlContainerJapanese.h" |
|
35 |
|
36 #include <PtiDefs.h> // keys |
|
37 #include <PtiEngine.h> |
|
38 #include <PtiCompositionDataIF.h> // MPtiEngineCompositionDataInterface |
|
39 |
|
40 |
|
41 /** |
|
42 * TAknFepUiInputStateCompletionHiraganaKanji class. |
|
43 * |
|
44 */ |
|
45 |
|
46 //============================ MEMBER FUNCTIONS ============================== |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // TAknFepUiInputStateCompletionKatakana:: |
|
50 // TAknFepUiInputStateCompletionKatakana |
|
51 // C++ default Constructor |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 TAknFepUiInputStateCompletionKatakana:: |
|
55 TAknFepUiInputStateCompletionKatakana( |
|
56 MAknFepUIManagerStateInterface* aOwner, |
|
57 MAknFepUICtrlContainerJapanese* aUIContainer) |
|
58 :TAknFepUiInputStateCompletionJapaneseMultitap(aOwner, aUIContainer) |
|
59 { |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // TAknFepUiInputStateCompletionKatakana:: |
|
64 // HandleNumericShortKeyL |
|
65 // Handling short keypress events of the numeric and the star. |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 TBool TAknFepUiInputStateCompletionKatakana::HandleNumericShortKeyL(TInt aKey) |
|
69 { |
|
70 TBool ret = ETrue; |
|
71 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
72 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
73 |
|
74 CommitInlineEditingCharacterL(); |
|
75 const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData(); |
|
76 TPtrC text = data->ConvertingString(); |
|
77 if (text.Length() > 0 && fepMan->EditorHasFreeSpace()) |
|
78 { // for last character is space or line feed |
|
79 iOwner->ChangeState(EInitial); |
|
80 iOwner->FepMan()->SimulateKeyEventL(aKey, ETrue); |
|
81 ret = ETrue; |
|
82 } |
|
83 else |
|
84 { |
|
85 ptiEngine->ClearCurrentWord(); |
|
86 iOwner->ChangeState(EInitial); |
|
87 } |
|
88 |
|
89 return ret; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // TAknFepUiInputStateCompletionJapaneseMultitap::UpdateInlineEditingCharacterL |
|
94 // Update inline editing string |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 TBool TAknFepUiInputStateCompletionKatakana::UpdateInlineEditingCharacterL() |
|
98 { |
|
99 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
100 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
101 TBool ret = EFalse; |
|
102 |
|
103 if(CommitInlineEditingCharacterL()) |
|
104 { |
|
105 ptiEngine->ClearCurrentWord(); |
|
106 iOwner->ChangeState(EInitial); |
|
107 ret = ETrue; |
|
108 } |
|
109 |
|
110 return ret; |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // TAknFepUiInputStateCompletionJapaneseMultitap::CommitInlineEditingCharacterL |
|
115 // Commit inline editing string |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 TBool TAknFepUiInputStateCompletionKatakana::CommitInlineEditingCharacterL() |
|
119 { |
|
120 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
121 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
122 const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData(); |
|
123 TPtrC text = data->CompletedString(); |
|
124 if (text.Length() > 0) |
|
125 { |
|
126 HBufC* buf = HBufC::NewLC(text.Length()); |
|
127 TPtr ptr(buf->Des()); |
|
128 ptr.Copy(text); |
|
129 if (fepMan->InputMode() == EHiragana) |
|
130 { |
|
131 for (TInt index=text.Length()-1; index >= 0; index-- ) |
|
132 { |
|
133 if (!IsFullHiragana(TChar(text[index]))) |
|
134 { |
|
135 ptr.Delete(index, 1); |
|
136 } |
|
137 } |
|
138 } |
|
139 |
|
140 fepMan->CommitInlineEditL(ptr, ptr.Length()); |
|
141 CleanupStack::PopAndDestroy(buf); |
|
142 } |
|
143 return ETrue; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // TAknFepUiInputStateCompletionKatakana::IsFullHiragana |
|
148 // Check a character whether it is Full-width Katakana |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 TBool TAknFepUiInputStateCompletionKatakana::IsFullHiragana(const TChar aChr) |
|
152 { |
|
153 TBool rtn = EFalse; |
|
154 const TUint KFullHiraganaStart = 0x3041; |
|
155 const TUint KFullHiraganaEnd = 0x3094; |
|
156 |
|
157 if (KFullHiraganaStart <= aChr && aChr <= KFullHiraganaEnd) |
|
158 { |
|
159 rtn = ETrue; |
|
160 } |
|
161 |
|
162 return rtn; |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // TAknFepUiInputStateCompletionKatakana::HandleAuxKeyL |
|
167 // Handling auxiliary keypress events including OK and Backspace |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TBool TAknFepUiInputStateCompletionKatakana::HandleAuxKeyL(TInt aKey, |
|
171 TKeyPressLength aLength) |
|
172 { |
|
173 TBool ret = ETrue; |
|
174 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
175 |
|
176 if (aKey == EKeyOK |
|
177 || aKey == EStdKeyDevice3 /* 0xA7 */ |
|
178 || aKey == EStdKeyEnter |
|
179 || aKey == EStdKeyNkpEnter) |
|
180 { |
|
181 TPtiEngineCommand ptiCommand = EPtiCommandUserActionComplete; |
|
182 if (aLength == ELongKeyPress) |
|
183 { |
|
184 ptiCommand = EPtiCommandUserActionAllComplete; |
|
185 } |
|
186 ptiEngine->HandleCommandL(ptiCommand); |
|
187 UpdateInlineEditingCharacterL(); |
|
188 // OK-key or Enter-key shouldn't be consumed in Latin input. |
|
189 // Because OK-key or Enter-key might be used in application side. |
|
190 ret = EFalse; |
|
191 } |
|
192 |
|
193 return ret; |
|
194 } |
|
195 |
|
196 // End of file |