|
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 with icon with bubble for drop-down list objects |
|
15 * |
|
16 */ |
|
17 |
|
18 // Include |
|
19 #include <fbs.h> |
|
20 #include <AknsUtils.h> |
|
21 #include <AknLayoutDef.h> |
|
22 #include <peninputdropdownlistcontext.h> |
|
23 #include <peninputdropdownlist.h> |
|
24 #include <aknsdrawutils.h> |
|
25 #include "peninputlistmultirowwithouticonwithbubble.h" |
|
26 #include "peninputlayout.h" |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // Implementation of Class CListMultiRowWithoutIconWithBubble |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CListMultiRowWithoutIconWithBubble::CListMultiRowWithoutIconWithBubble |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave |
|
36 // (other items were commented in a header). |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CListMultiRowWithoutIconWithBubble::CListMultiRowWithoutIconWithBubble(CListManager* aManager, |
|
40 MFepCtrlDropdownListContext *aOwner) |
|
41 : CListExpandableMultiRowWithoutIcon(aManager, aOwner) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CListMultiRowWithoutIconWithBubble::NewL |
|
47 // factory function |
|
48 // (other items were commented in a header). |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CListMultiRowWithoutIconWithBubble* CListMultiRowWithoutIconWithBubble::NewL(CListManager* aManager, |
|
52 MFepCtrlDropdownListContext *aOwner) |
|
53 { |
|
54 CListMultiRowWithoutIconWithBubble* self = new (ELeave) CListMultiRowWithoutIconWithBubble(aManager, aOwner); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CListMultiRowWithoutIconWithBubble::~CListMultiRowWithoutIconWithBubble |
|
63 // desstrutor function |
|
64 // (other items were commented in a header). |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CListMultiRowWithoutIconWithBubble::~CListMultiRowWithoutIconWithBubble() |
|
68 { |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CListMultiRowWithoutIconWithBubble::HandlePointerDownL |
|
74 // handle pointer down |
|
75 // (other items were commented in a header). |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CListMultiRowWithoutIconWithBubble::HandlePointerDownL(const TPoint& aPoint) |
|
79 { |
|
80 CList::HandlePointerDownL(aPoint); |
|
81 |
|
82 // also consider fuzzy boundry of drop down list |
|
83 TRect fuzzyrect = iRect; |
|
84 fuzzyrect.Grow(iOwner->FuzzyBoundry(), iOwner->FuzzyBoundry()); |
|
85 |
|
86 if (!fuzzyrect.Contains(aPoint)) |
|
87 { |
|
88 iOwner->SetCapture(EFalse); |
|
89 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
90 iOwner->ClearBubble(); |
|
91 return; |
|
92 } |
|
93 |
|
94 if(iContentRect.Contains(aPoint)) |
|
95 { |
|
96 TInt index = -1; |
|
97 CCandidate* candidate = FindCandidate(aPoint, index); |
|
98 if(candidate) |
|
99 { |
|
100 iOwner->DrawBubble(iClickedRect, candidate->GetCandidate()); |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CListMultiRowWithoutIconWithBubble::HandlePointerDragL |
|
108 // handle pointer drag function |
|
109 // (other items were commented in a header). |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CListMultiRowWithoutIconWithBubble::HandlePointerDragL(const TPoint& aPoint) |
|
113 { |
|
114 // Pass the event first to the base |
|
115 CList::HandlePointerDragL(aPoint); |
|
116 |
|
117 CCandidate* candidate = FindCandidate(aPoint, iClickedCandidateIndex); |
|
118 |
|
119 TBool isUpdateBubble = EFalse; |
|
120 if ( candidate ) |
|
121 { |
|
122 if (iClickedRect != candidate->GetRect()) |
|
123 {// move to the other candidate |
|
124 // set update prview bubble flag |
|
125 isUpdateBubble = ETrue; |
|
126 // remenber the previous cell rect |
|
127 iMoveLatestRect = iClickedRect; |
|
128 // get the new cell rect |
|
129 iClickedRect.SetRect(candidate->GetRect().iTl, candidate->GetRect().Size()); |
|
130 } |
|
131 } |
|
132 else |
|
133 {// move to the aperture |
|
134 // remember the previous cell |
|
135 iMoveLatestRect = iClickedRect; |
|
136 // set the new cell to empty |
|
137 iClickedRect = KDummyRect; |
|
138 // redraw the cell only when drag outside at the first time |
|
139 if(iMoveLatestRect != iClickedRect) |
|
140 { |
|
141 iOwner->ClearBubble(); |
|
142 DrawSelection(iMoveLatestRect, EFalse); |
|
143 DrawHighightCell(iMoveLatestRect, ETrue); |
|
144 } |
|
145 } |
|
146 |
|
147 if(candidate && isUpdateBubble) |
|
148 { |
|
149 iOwner->ClearBubble(); |
|
150 CompareRect(iMoveLatestRect, iClickedRect); |
|
151 // Show preview bubble when drag into a candidate cell |
|
152 // Make sure show the bubble after redraw clicked cell |
|
153 iOwner->DrawBubble(iClickedRect, candidate->GetCandidate()); |
|
154 } |
|
155 } |
|
156 |
|
157 |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CListMultiRowWithoutIconWithBubble::HandlePointerUpL |
|
161 // handle pointer up function |
|
162 // (other items were commented in a header). |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CListMultiRowWithoutIconWithBubble::HandlePointerUpL(const TPoint& aPoint) |
|
166 { |
|
167 // Reset the button clicked flag to EFalse |
|
168 iIndicateButtonClicked = EFalse; |
|
169 |
|
170 iOwner->ClearBubble(); |
|
171 |
|
172 #ifdef __WINS__ |
|
173 // in emulator, double click will be treated as: |
|
174 // 1 pointer down and 2 pointer up, which will cause error |
|
175 if (iClickedRect.IsEmpty() && ((CFepUiBaseCtrl*)iOwner)->PointerDown()) |
|
176 #else |
|
177 if (iClickedRect.IsEmpty()) |
|
178 #endif // __WINS__ |
|
179 { |
|
180 iOwner->SetCapture(EFalse); |
|
181 // Change active list object ie. close the dd-list |
|
182 iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() ); |
|
183 } |
|
184 else |
|
185 { |
|
186 if ( iContentRect.Contains(aPoint) ) |
|
187 { |
|
188 if ( iClickedRect.Contains(aPoint) ) |
|
189 { |
|
190 // Redraw the selected aread |
|
191 DrawSelection(iClickedRect, EFalse); |
|
192 |
|
193 iOwner->SetCapture(EFalse); |
|
194 |
|
195 // We have selected a candidate and iClickedCandidateIndex is the selected Index. |
|
196 // Send the candidate to others |
|
197 if (iClickedCandidateIndex != KErrNotFound) |
|
198 { |
|
199 iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() ); |
|
200 CCandidate* candidate = iOwner->GetCandidate(iClickedCandidateIndex); |
|
201 if ( candidate ) |
|
202 { |
|
203 iOwner->ReportCandidateSelectEventL(candidate->GetCandidate(), |
|
204 iClickedCandidateIndex); |
|
205 } |
|
206 } |
|
207 } |
|
208 } |
|
209 iClickedRect = KEmptyRect; |
|
210 } |
|
211 } |
|
212 |
|
213 |
|
214 TBool CListMultiRowWithoutIconWithBubble::CompareRect(const TRect& aSrcRect, const TRect& aDesRect) |
|
215 { |
|
216 if(aSrcRect != aDesRect) |
|
217 { |
|
218 DrawSelection(aDesRect, ETrue); |
|
219 DrawSelection(aSrcRect, EFalse); |
|
220 DrawHighightCell(aSrcRect, ETrue); |
|
221 } |
|
222 |
|
223 return EFalse; |
|
224 |
|
225 } |
|
226 |
|
227 |
|
228 // End Of File |