|
1 /* |
|
2 * Copyright (c) 2009 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 * |
|
16 */ |
|
17 #include <peninputdropdownlistcontext.h> |
|
18 |
|
19 #include "peninputlistonerowrollwithicon.h" |
|
20 #include "peninputcandidate.h" |
|
21 #include "peninputdropdownlist.h" |
|
22 #include "peninputlayout.h" |
|
23 |
|
24 const TInt KInvalidCandIndex = -1; |
|
25 |
|
26 CListOneRowRollWithIcon* CListOneRowRollWithIcon::NewL(CListManager* aManager, |
|
27 MFepCtrlDropdownListContext* aOwner) |
|
28 { |
|
29 CListOneRowRollWithIcon* self = new (ELeave) CListOneRowRollWithIcon(aManager, aOwner); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 CListOneRowRollWithIcon::~CListOneRowRollWithIcon() |
|
37 { |
|
38 } |
|
39 |
|
40 CListOneRowRollWithIcon::CListOneRowRollWithIcon(CListManager* aManager, |
|
41 MFepCtrlDropdownListContext* aOwner): |
|
42 CListOneRowWithIcon(aManager, aOwner) |
|
43 { |
|
44 } |
|
45 |
|
46 // not needed anymore |
|
47 // if candidate not enough to fill one row, |
|
48 // just dim next button, but not hide it |
|
49 /* |
|
50 void CListOneRowRollWithIcon::Draw() |
|
51 { |
|
52 CList::Draw(); |
|
53 DrawCandidates(); |
|
54 |
|
55 if (!iNextButtonDisable) |
|
56 { |
|
57 //Clear bg for iNavigationNextRect |
|
58 iOwner->Gc()->SetPenSize(iOwner->GetPenSize()); |
|
59 iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); |
|
60 |
|
61 iOwner->Gc()->SetPenColor(iOwner->GetBorderColor()); |
|
62 iOwner->Gc()->SetBrushColor(iOwner->GetBgColor()); |
|
63 iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
64 iOwner->Gc()->DrawRect( iNavigationNextRect ); |
|
65 |
|
66 TRect rect = iNavigationNextRect; |
|
67 rect.Shrink(1, 1); |
|
68 |
|
69 iOwner->Gc()->DrawBitmapMasked(rect, |
|
70 iBButtonDown, |
|
71 iBButtonDown->SizeInPixels(), |
|
72 iBButtonMaskDown, |
|
73 ETrue); |
|
74 } |
|
75 |
|
76 iOwner->Invalidate(iRect); |
|
77 } |
|
78 */ |
|
79 |
|
80 void CListOneRowRollWithIcon::HandlePointerDownL(const TPoint& aPoint) |
|
81 { |
|
82 // Pass the event first to the base |
|
83 CList::HandlePointerDownL(aPoint); |
|
84 |
|
85 // If click in NextButton, and it is not disable, then do |
|
86 if (iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable) |
|
87 { |
|
88 #ifdef RD_TACTILE_FEEDBACK |
|
89 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
90 DoTactileFeedback(ETouchFeedbackBasic); |
|
91 #endif //RD_TACTILE_FEEDBACK |
|
92 // If click in down button and the down button is enabled |
|
93 iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr); |
|
94 iIndicateButtonClicked = ETrue; |
|
95 DrawSelection(iClickedRect, ETrue); |
|
96 } |
|
97 } |
|
98 |
|
99 void CListOneRowRollWithIcon::HandlePointerUpL(const TPoint& aPoint) |
|
100 { |
|
101 iIndicateButtonClicked = EFalse; |
|
102 |
|
103 if (!iClickedRect.IsEmpty()) |
|
104 { |
|
105 // Find out which rectangle was clicked and save it for |
|
106 // later usage (HandlePointerUpL) |
|
107 if (iContentRect.Contains(aPoint)) |
|
108 { |
|
109 // The point is inside the content rect |
|
110 // Check whether the point is inside the same last clicked |
|
111 // candidate rectangle |
|
112 if (iClickedRect.Contains(aPoint)) |
|
113 { |
|
114 if (iClickedCandidateIndex != KErrNotFound) |
|
115 { |
|
116 // Redraw the selected aread |
|
117 DrawSelection(iClickedRect, EFalse); |
|
118 |
|
119 // We have selected a candidate and iClickedCandidateIndex is the selected Index. |
|
120 // Then send message to plugin |
|
121 CCandidate* candidate = iOwner->GetCandidate(iClickedCandidateIndex); |
|
122 if ( candidate ) |
|
123 { |
|
124 iOwner->ReportCandidateSelectEventL(candidate->GetCandidate(), |
|
125 iClickedCandidateIndex); |
|
126 } |
|
127 } |
|
128 } |
|
129 } |
|
130 else if ((iNavigationNextRect == iClickedRect) && !iNextButtonDisable) |
|
131 { |
|
132 TInt originalFirstCandIndex = iOwner->GetOriginalFirstCandIdx(); |
|
133 |
|
134 if ((iOwner->ListType() == CFepCtrlDropdownList::EListExpandableRollWithIcon) && |
|
135 (originalFirstCandIndex != KInvalidCandIndex)) |
|
136 { |
|
137 iOwner->AutoChangeActiveList(originalFirstCandIndex); |
|
138 } |
|
139 else |
|
140 { |
|
141 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
142 } |
|
143 |
|
144 iOwner->SetCapture(ETrue); |
|
145 } |
|
146 |
|
147 iClickedRect = KEmptyRect; |
|
148 } |
|
149 } |
|
150 |
|
151 void CListOneRowRollWithIcon::HandlePointerDragL(const TPoint& aPoint) |
|
152 { |
|
153 // Pass the event first to the base |
|
154 CList::HandlePointerDragL(aPoint); |
|
155 |
|
156 if (iIndicateButtonClicked) // clicked rect is not outside the whole DDL |
|
157 { |
|
158 iMoveLatestRect = KEmptyRect; |
|
159 |
|
160 if (iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable) |
|
161 { |
|
162 // If click in down button and the down button is enabled |
|
163 iMoveLatestRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr); |
|
164 } |
|
165 else if (iContentRect.Contains(aPoint)) |
|
166 { |
|
167 TInt index = -1; |
|
168 CCandidate* candidate = FindCandidate(aPoint, index); |
|
169 |
|
170 if ( candidate ) |
|
171 { |
|
172 // If click in candidates area |
|
173 iMoveLatestRect.SetRect(candidate->GetRect().iTl, candidate->GetRect().Size()); |
|
174 } |
|
175 else |
|
176 { |
|
177 iMoveLatestRect = KEmptyRect; |
|
178 } |
|
179 } |
|
180 |
|
181 CompareRect(iMoveLatestRect, iClickedRect); |
|
182 } |
|
183 } |
|
184 |
|
185 void CListOneRowRollWithIcon::SetHighlightCell(const TInt aCellIndex, |
|
186 TBool aHighlight, |
|
187 TBool aForceDraw) |
|
188 { |
|
189 if (aCellIndex < iOwner->GetLastCandidateIndex()) |
|
190 { |
|
191 CList::SetHighlightCell(aCellIndex, aHighlight, aForceDraw); |
|
192 } |
|
193 else if ((iOwner->GetLastCandidateIndex() > 0) && |
|
194 aHighlight) |
|
195 { |
|
196 TInt originalFirstCandIndex = iOwner->GetOriginalFirstCandIdx(); |
|
197 |
|
198 iOwner->SetUpdateListReDrawFlag(EFalse); |
|
199 |
|
200 if ((iOwner->ListType() == CFepCtrlDropdownList::EListExpandableRollWithIcon) && |
|
201 (originalFirstCandIndex != KInvalidCandIndex)) |
|
202 { |
|
203 iOwner->AutoChangeActiveList(originalFirstCandIndex); |
|
204 } |
|
205 else |
|
206 { |
|
207 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
208 } |
|
209 |
|
210 TRAP_IGNORE(iOwner->ActiveList()->SetNextPageHighlightCellAfterOnePageL(aCellIndex)); |
|
211 |
|
212 iOwner->SetUpdateListReDrawFlag(ETrue); |
|
213 } |
|
214 } |
|
215 |
|
216 // End Of File |