|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * Provides the TAknFepUIInputStateEntryQwertyBasePhrase methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
31 #include "AknFepUiCtrlContainerChinese.h" |
|
32 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
33 #include "AknFepUICtrlCandidatePane.h" |
|
34 #include "AknFepUICtrlInputPane.h" |
|
35 #include "AknFepUiInputStateEntryQwertyBasePhrase.h" |
|
36 |
|
37 #include <PtiEngine.h> //CPtiEngine |
|
38 #include <e32keys.h> //keys |
|
39 #include <avkon.rsg> |
|
40 |
|
41 TAknFepInputStateEntryQwertyBasePhrase::TAknFepInputStateEntryQwertyBasePhrase( |
|
42 MAknFepUIManagerStateInterface* aOwner, |
|
43 MAknFepUICtrlContainerChinese* aUIContainer) |
|
44 :TAknFepInputStateCandidateQwertyPhrase(aOwner,aUIContainer) |
|
45 { |
|
46 iState = EEntry; |
|
47 |
|
48 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
49 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
50 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
51 uiContainer->CandidatePane()->IsFirstPage()); |
|
52 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
53 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
54 |
|
55 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
56 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
57 uiContainer->FocusCandidatePane(ETrue); |
|
58 candidatePane->SetHighlighted(ETrue); |
|
59 candidatePane->SelectFirstPhrase(); |
|
60 candidatePane->ShowCandidateOrdinals(ETrue); |
|
61 uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutInput); |
|
62 } |
|
63 |
|
64 TBool TAknFepInputStateEntryQwertyBasePhrase::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
65 { |
|
66 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
67 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
68 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
69 |
|
70 TBool ret = ETrue; |
|
71 |
|
72 if(aKey == EStdKeyBackspace) |
|
73 { |
|
74 if (iOwner->PtiEngine()->DeleteKeyPress().Length()) |
|
75 { |
|
76 uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() && |
|
77 uiContainer->CandidatePane()->IsFirstPage())); |
|
78 SetInputPaneToneMark(); |
|
79 inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
80 RefreshUI(); |
|
81 } |
|
82 else |
|
83 { |
|
84 iOwner->FepMan()->TryCloseUiL(); |
|
85 } |
|
86 } |
|
87 else if(aLength == EShortKeyPress && iOwner->IsValidChineseInputKeyQwerty(aKey) ) |
|
88 { |
|
89 ptiengine->AppendKeyPress((TPtiKey)aKey); |
|
90 uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() && |
|
91 uiContainer->CandidatePane()->IsFirstPage())); |
|
92 SetInputPaneToneMark(); |
|
93 inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
94 RefreshUI(); |
|
95 } |
|
96 else |
|
97 { |
|
98 ret = TAknFepInputStateCandidateQwertyBasePhrase::HandleKeyL(aKey,aLength); |
|
99 } |
|
100 |
|
101 return ret; |
|
102 } |
|
103 |
|
104 void TAknFepInputStateEntryQwertyBasePhrase::RefreshUI() |
|
105 { |
|
106 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
107 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
108 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
109 |
|
110 // get cursor position |
|
111 TPoint baseLine = TPoint(0,0); |
|
112 TInt height = 0; |
|
113 TInt ascent = 0; |
|
114 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
115 if (ret == KErrNone) |
|
116 { |
|
117 uiContainer->SetContainerPosition(baseLine, height); |
|
118 } |
|
119 |
|
120 // layout candidate and fill candidate buffer for first display page |
|
121 TInt candidateCount = 0; |
|
122 if(inputPane->IsFlagSet(MAknFepUICtrlInputPane::EPhoneticChanged)) |
|
123 { |
|
124 inputPane->ClearFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
125 TRAPD(ignore, |
|
126 candidateCount = ptiengine->GetChinesePhraseCandidatesL( |
|
127 *(uiContainer->CandidatePane()->CandidateArray()))); |
|
128 if(candidateCount == 0 || ignore != KErrNone) |
|
129 { |
|
130 return; |
|
131 } |
|
132 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
133 } |
|
134 |
|
135 uiContainer->Enable(ETrue); |
|
136 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
137 |
|
138 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
139 uiContainer->CandidatePane()->IsFirstPage()); |
|
140 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
141 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
142 |
|
143 UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
144 UIContainer()->ShowVerticalScrollArrows(multiplePages); |
|
145 uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
146 |
|
147 TPtrC ptr = ptiengine->GetPhoneticSpelling(1); |
|
148 inputPane->SetText(ptr); |
|
149 } |
|
150 |
|
151 void TAknFepInputStateEntryQwertyBasePhrase::SetInputPaneToneMark() |
|
152 { |
|
153 } |
|
154 |
|
155 void TAknFepInputStateEntryQwertyBasePhrase::InitializeStateL(void) |
|
156 { |
|
157 iOwner->FepMan()->UpdateCbaL(R_AVKON_SOFTKEYS_EMPTY); |
|
158 } |
|
159 |
|
160 // End of file |