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: Predictive candidate list |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // INCLUDE FILES |
|
30 #include <eikdef.h> |
|
31 #include <aknViewAppUi.h> |
|
32 #include <avkon.hrh> |
|
33 #include <aknPopup.h> |
|
34 #include <aknlists.h> |
|
35 |
|
36 #include "AknFepUiInterfacePanic.h" |
|
37 #include "AknFepUIAvkonCtrlJapanesePredictiveListBoxModel.h" |
|
38 #include "AknFepUIAvkonCtrlJapanesePredictivePane.h" |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CPredictivePopupLineInfo::~CPredictivePopupLineInfo |
|
43 // Destructor |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CPredictivePopupLineInfo::~CPredictivePopupLineInfo() |
|
47 { |
|
48 delete iLineText; |
|
49 delete iElementsOnLine; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CAknFepUICtrlJapanesePredictiveListBoxModel::SetLineInfoArray |
|
54 // Registering a array with candidate line information |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CAknFepUICtrlJapanesePredictiveListBoxModel::SetLineInfoArray( |
|
58 CPredictivePopupLineInfoArray* aLineInfoArray) |
|
59 { |
|
60 iLineInfoArray = aLineInfoArray; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CAknFepUICtrlJapanesePredictiveListBoxModel::LineInfoArray |
|
65 // Returning a arrary with candidate line information |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CPredictivePopupLineInfoArray* |
|
69 CAknFepUICtrlJapanesePredictiveListBoxModel::LineInfoArray() const |
|
70 { |
|
71 return iLineInfoArray; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CAknFepUICtrlJapanesePredictiveListBoxModel::SearchItemIndexFromCandidateNo |
|
76 // This function searches a item index as key in a candidate number |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TInt CAknFepUICtrlJapanesePredictiveListBoxModel::SearchItemIndexFromCandidateNo( |
|
80 TInt aCandidateNo) const |
|
81 { |
|
82 TInt lineNo = -1; |
|
83 const TInt numberOfLine = iLineInfoArray->Count(); |
|
84 TInt i; |
|
85 for (i = 0; i < numberOfLine && lineNo == -1; i++) |
|
86 { |
|
87 CPredictivePopupLineInfo* lineInfo = iLineInfoArray->At(i); |
|
88 CPredictivePopupElementArray* elementArray =lineInfo->iElementsOnLine; |
|
89 |
|
90 const TInt numberOfElement = elementArray->Count(); |
|
91 TInt j; |
|
92 for (j = 0; j < numberOfElement; j++) |
|
93 { |
|
94 TPredictivePopupElement element = elementArray->At(j); |
|
95 if (aCandidateNo == element.iCandidateNo) |
|
96 { |
|
97 lineNo = i; |
|
98 break; |
|
99 } |
|
100 } |
|
101 } |
|
102 return lineNo; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CAknFepUICtrlJapanesePredictiveListBoxModel::SearchElement |
|
107 // This function is that it checks whether the candidate is included in the line. |
|
108 // If including it, The displaying information is returned. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 TBool CAknFepUICtrlJapanesePredictiveListBoxModel::SearchElement( |
|
112 TInt aLineNo, TInt aCandidateNo, TPredictivePopupElement& aElement) |
|
113 { |
|
114 TBool foundFlag = EFalse; |
|
115 |
|
116 CPredictivePopupLineInfo* lineInfo = iLineInfoArray->At(aLineNo); |
|
117 CPredictivePopupElementArray* elementArray = lineInfo->iElementsOnLine; |
|
118 |
|
119 const TInt numberOfElement = elementArray->Count(); |
|
120 TInt i; |
|
121 for (i = 0; i < numberOfElement; i++) |
|
122 { |
|
123 TPredictivePopupElement element = elementArray->At(i); |
|
124 if (aCandidateNo < element.iCandidateNo) |
|
125 { |
|
126 break; |
|
127 } |
|
128 else if (aCandidateNo == element.iCandidateNo) |
|
129 { |
|
130 aElement.iStartXPos = element.iStartXPos; |
|
131 aElement.iEndXPos = element.iEndXPos; |
|
132 aElement.iCandidateNo = element.iCandidateNo; |
|
133 foundFlag = ETrue; |
|
134 break; |
|
135 } |
|
136 } |
|
137 return foundFlag; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CAknFepUICtrlJapanesePredictiveListBoxModel::SetMaximumItems |
|
142 // Set total item numbers in listbox |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CAknFepUICtrlJapanesePredictiveListBoxModel::SetMaximumItems( |
|
146 TInt aMaximumItems) |
|
147 { |
|
148 iMaximumItems = aMaximumItems; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CAknFepUICtrlJapanesePredictiveListBoxModel::MaximumItems |
|
153 // Return total item numbers |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CAknFepUICtrlJapanesePredictiveListBoxModel::MaximumItems() |
|
157 { |
|
158 return iMaximumItems; |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CAknFepUICtrlJapanesePredictiveListBoxModel::SearchCandidateNoFromPosition |
|
163 // This function searches a CandidateNo from linenumber and Position |
|
164 // ----------------------------------------------------------------------------- |
|
165 TInt CAknFepUICtrlJapanesePredictiveListBoxModel::SearchCandidateNoFromPosition( |
|
166 TInt aLineNo, const TPoint& aPoint) const |
|
167 { |
|
168 TInt candidateNo = -1; |
|
169 if ( 0 <= aLineNo && iLineInfoArray->Count() > aLineNo ) |
|
170 { |
|
171 CPredictivePopupLineInfo* lineInfo = iLineInfoArray->At(aLineNo); |
|
172 CPredictivePopupElementArray* elementArray = lineInfo->iElementsOnLine; |
|
173 const TInt numberOfElement = elementArray->Count(); |
|
174 candidateNo = elementArray->At(numberOfElement - 1).iCandidateNo; |
|
175 for (TInt ii = 0; ii < numberOfElement; ii++) |
|
176 { |
|
177 TPredictivePopupElement element = elementArray->At(ii); |
|
178 //if (aPoint.iX /*- margin*/ <= element.iEndXPos) |
|
179 if (aPoint.iX <= element.iEndXPos) |
|
180 { |
|
181 candidateNo = element.iCandidateNo; |
|
182 break; |
|
183 } |
|
184 } |
|
185 } |
|
186 return candidateNo; |
|
187 } |
|
188 // End of File |
|