|
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: Multi rows list without icon for drop-down list objects |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // Include |
|
21 #include <peninputdropdownlistcontext.h> |
|
22 #include <peninputdropdownlist.h> |
|
23 |
|
24 #include "peninputlist.h" |
|
25 #include "peninputlistmultirowwithouticon.h" |
|
26 |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // Implementation of Class CListMultiRowWithoutIcon |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CListMultiRowWithoutIcon::CListMultiRowWithoutIcon |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave |
|
36 // (other items were commented in a header). |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CListMultiRowWithoutIcon::CListMultiRowWithoutIcon( CListManager* aManager, |
|
40 MFepCtrlDropdownListContext *aOwner ) |
|
41 :CList( aManager, aOwner ) |
|
42 { |
|
43 iIsMultiRows = ETrue; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CListMultiRowWithoutIcon::NewL |
|
48 // factory function |
|
49 // (other items were commented in a header). |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CListMultiRowWithoutIcon* CListMultiRowWithoutIcon::NewL( |
|
53 CListManager* aManager, |
|
54 MFepCtrlDropdownListContext *aOwner ) |
|
55 { |
|
56 CListMultiRowWithoutIcon* self |
|
57 = new (ELeave) CListMultiRowWithoutIcon( aManager, aOwner ); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CListMultiRowWithoutIcon::~CListMultiRowWithoutIcon |
|
66 // desstrutor function |
|
67 // (other items were commented in a header). |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CListMultiRowWithoutIcon::~CListMultiRowWithoutIcon() |
|
71 { |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CListMultiRowWithoutIcon::HandlePointerDragL |
|
76 // handle pointer drag function |
|
77 // (other items were commented in a header). |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CListMultiRowWithoutIcon::HandlePointerDragL( const TPoint& aPoint ) |
|
81 { |
|
82 // Pass the event first to the base |
|
83 CList::HandlePointerDragL( aPoint ); |
|
84 |
|
85 if ( !iClickedRect.IsEmpty() ) |
|
86 { |
|
87 // clicked rect is not outside the whole DDL |
|
88 TInt index = -1; |
|
89 |
|
90 CCandidate* candidate = FindCandidate( aPoint, index ); |
|
91 iMoveLatestRect = KEmptyRect; |
|
92 |
|
93 if ( candidate ) |
|
94 { |
|
95 // candidate exist |
|
96 iMoveLatestRect.SetRect( candidate->GetRect().iTl, |
|
97 candidate->GetRect().Size() ); |
|
98 } |
|
99 |
|
100 // Compare the two rect, then decide draw it or not |
|
101 CompareRect( iMoveLatestRect, iClickedRect ); |
|
102 } |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CListMultiRowWithoutIcon::HandlePointerUpL |
|
107 // handle pointer up function |
|
108 // (other items were commented in a header). |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CListMultiRowWithoutIcon::HandlePointerUpL( const TPoint& aPoint ) |
|
112 { |
|
113 // clicked rect is outside the whole DDL |
|
114 if ( iClickedRect.IsEmpty() ) |
|
115 { |
|
116 iOwner->SetCapture( EFalse ); |
|
117 // Change active list object ie. close the DDL |
|
118 iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() ); |
|
119 } |
|
120 else |
|
121 { |
|
122 if ( ( iContentRect.Contains( aPoint ) ) |
|
123 && ( iClickedRect.Contains( aPoint ) ) ) |
|
124 { |
|
125 // Redraw the selected aread |
|
126 DrawSelection( iClickedRect, EFalse ); |
|
127 |
|
128 iOwner->SetCapture( EFalse ); |
|
129 |
|
130 // We have selected a candidate and iClickedCandidateIndex is |
|
131 // the selected Index. |
|
132 // Send the candidate to others |
|
133 if (iClickedCandidateIndex != KErrNotFound) |
|
134 { |
|
135 iOwner->AutoChangeActiveList( |
|
136 iOwner->GetFirstCandidateIndex() ); |
|
137 CCandidate* candidate = iOwner->GetCandidate( |
|
138 iClickedCandidateIndex ); |
|
139 if ( candidate ) |
|
140 { |
|
141 iOwner->ReportCandidateSelectEventL( |
|
142 candidate->GetCandidate(), |
|
143 iClickedCandidateIndex ); |
|
144 } |
|
145 } |
|
146 } |
|
147 |
|
148 iClickedRect = KEmptyRect; |
|
149 } |
|
150 |
|
151 iIndicateButtonClicked = EFalse; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CListMultiRowWithoutIcon::Draw |
|
156 // draw the list |
|
157 // (other items were commented in a header). |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CListMultiRowWithoutIcon::Draw() |
|
161 { |
|
162 // Call draw in base class; |
|
163 CList::Draw(); |
|
164 |
|
165 // Draw all visible candidates |
|
166 DrawCandidates(); |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CListMultiRowWithoutIcon::CalculateAreas |
|
171 // Calculate all kinds of rectangles |
|
172 // (other items were commented in a header). |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void CListMultiRowWithoutIcon::CalculateAreas() |
|
176 { |
|
177 // Calculate the rect of the list |
|
178 iRect.iTl = iOwner->GetTopLeftPoint(); |
|
179 TInt width = iOwner->GetCellWidth() * iOwner->GetColNum() + |
|
180 iOwner->GetNaviWidth() + |
|
181 (iOwner->GetColNum() + 2) * iOwner->GetCellHorizontalMargin(); |
|
182 |
|
183 TInt height = iOwner->GetCellHeight() * iOwner->GetRowNum() + |
|
184 (iOwner->GetRowNum() + 1) * iOwner->GetCellVerticalMargin(); |
|
185 |
|
186 iRect.SetSize(TSize( width,height)); |
|
187 |
|
188 if (iOwner->CandExpandType() == CFepCtrlDropdownList::ECandExpandUpward) |
|
189 { |
|
190 // expand upward |
|
191 TInt onerowheight = iOwner->GetCellHeight() + 2 * iOwner->GetCellVerticalMargin(); |
|
192 iRect.Move(0, -(height - onerowheight)); |
|
193 } |
|
194 |
|
195 // Calculate the rect of the content |
|
196 iContentRect.iTl.SetXY(iRect.iTl.iX + iOwner->GetCellHorizontalMargin(), |
|
197 iRect.iTl.iY + iOwner->GetCellVerticalMargin()); |
|
198 |
|
199 iContentRect.SetSize(TSize (width - 2 * iOwner->GetCellHorizontalMargin(), |
|
200 height - 2 * iOwner->GetCellVerticalMargin())); |
|
201 |
|
202 // Initialized the rect of the navigation area and the down and up button |
|
203 iNavigationRect = KEmptyRect; |
|
204 iNavigationNextRect = KEmptyRect; |
|
205 iNavigationPreviousRect = KEmptyRect; |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CListMultiRowWithoutIcon::CalculatePositionsL |
|
210 // calculate the position of all visible cells in the list |
|
211 // (other items were commented in a header). |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CListMultiRowWithoutIcon::CalculatePositionsL() |
|
215 { |
|
216 TInt lastCandidateIndex = iOwner->GetLastCandidateIndex(); |
|
217 TInt count = iOwner->CandidateCount(); |
|
218 |
|
219 if ( count > 0 ) |
|
220 { |
|
221 TPoint setpoints; |
|
222 TBool candHLToR = (iOwner->CandHDirection() == CFepCtrlDropdownList::ECandFromLToR); |
|
223 candHLToR ? setpoints.SetXY(iContentRect.iTl.iX, iContentRect.iTl.iY) : |
|
224 setpoints.SetXY(iContentRect.iBr.iX, iContentRect.iTl.iY); |
|
225 |
|
226 count = Min( count, lastCandidateIndex |
|
227 + ( iOwner->GetColNum() + 1 ) * iOwner->GetRowNum() ); |
|
228 |
|
229 for ( TInt currentCellIndex = 0, |
|
230 lastUsedCellCount = 0, |
|
231 lastusedRow = 0; |
|
232 lastCandidateIndex <= count; |
|
233 lastCandidateIndex++ ) |
|
234 { |
|
235 // setting a position for this candidate |
|
236 CCandidate* candidate = iOwner->GetCandidate( lastCandidateIndex ); |
|
237 |
|
238 if ( candidate ) |
|
239 { |
|
240 // each candidate exist |
|
241 if ( currentCellIndex > iOwner->GetColNum() ) |
|
242 { |
|
243 // The cell index moved the edge of right |
|
244 lastusedRow++; |
|
245 if ( lastusedRow >= iOwner->GetRowNum() ) |
|
246 { |
|
247 // The row index moved bottom |
|
248 break; |
|
249 } |
|
250 |
|
251 currentCellIndex = 0; |
|
252 |
|
253 setpoints.iY = setpoints.iY + |
|
254 iOwner->GetCellHeight() + |
|
255 iOwner->GetCellVerticalMargin(); |
|
256 |
|
257 candHLToR ? (setpoints.iX = iContentRect.iTl.iX) : (setpoints.iX = iContentRect.iBr.iX); |
|
258 } |
|
259 |
|
260 lastUsedCellCount = candidate->SetPositionL(setpoints, |
|
261 iOwner->GetCellWidth(), |
|
262 iOwner->GetCellHeight(), |
|
263 iOwner->GetFont(), |
|
264 iOwner->GetCellHorizontalMargin()); |
|
265 |
|
266 currentCellIndex += lastUsedCellCount; |
|
267 candHLToR? (setpoints.iX += lastUsedCellCount*(iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())) : |
|
268 (setpoints.iX -= lastUsedCellCount*(iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())); |
|
269 } // if each candidate exist |
|
270 } // for-loop |
|
271 } // if candidate exist |
|
272 |
|
273 return lastCandidateIndex; // as lastCandidateIndex |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CListMultiRowWithoutIcon::UpdateList |
|
278 // update the list |
|
279 // (other items were commented in a header). |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 void CListMultiRowWithoutIcon::UpdateListL( TBool aDrawFlag, TBool aRecalculate ) |
|
283 { |
|
284 if ( aRecalculate ) |
|
285 { |
|
286 // Recalculate the position of all candidates |
|
287 iOwner->SetLastCandidateIndex( CalculatePositionsL() ); |
|
288 } |
|
289 if(aDrawFlag) |
|
290 { |
|
291 Draw(); |
|
292 iOwner->Invalidate(iRect); |
|
293 } |
|
294 } |
|
295 |
|
296 // End Of File |