66
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* Nokia Corporation - S60 implementation
|
|
10 |
*******************************************************************************/
|
|
11 |
|
|
12 |
|
|
13 |
#ifndef SWTLISTBASE_H
|
|
14 |
#define SWTLISTBASE_H
|
|
15 |
|
|
16 |
|
|
17 |
#include <eiklbo.h>
|
|
18 |
#include "swtscrollablebase.h"
|
|
19 |
#include "swtlistboxlists.h"
|
|
20 |
#include "eswtwidgetscore.h"
|
|
21 |
|
|
22 |
|
|
23 |
const TUint KCheckboxColumnIndex = 0;
|
|
24 |
const TUint KTextColumnIndex = 1;
|
|
25 |
|
|
26 |
|
|
27 |
/**
|
|
28 |
* CSwtListBase
|
|
29 |
* @lib eswt
|
|
30 |
*/
|
|
31 |
NONSHARABLE_CLASS(CSwtListBase)
|
|
32 |
: public CAknControl
|
|
33 |
, public ASwtScrollableBase
|
|
34 |
, public MSwtListObserver
|
|
35 |
, public MEikListBoxObserver
|
|
36 |
{
|
|
37 |
// Own methods
|
|
38 |
public:
|
|
39 |
/**
|
|
40 |
* Create a list box.
|
|
41 |
* @param aStyle control style.
|
|
42 |
*/
|
|
43 |
virtual CEikTextListBox* CreateListBoxL(TInt aStyle);
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Create a list box model.
|
|
47 |
*/
|
|
48 |
virtual void CreateListBoxModelL();
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Create the list scrollbars.
|
|
52 |
* @param aLb the list having the scrollbars.
|
|
53 |
*/
|
|
54 |
virtual void CreateScrollBarsL(CEikTextListBox* aLb);
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Create the icon array containing the icons for the multi selection.
|
|
58 |
* @param aLb the list having the icons.
|
|
59 |
*/
|
|
60 |
virtual void CreateIconArrayL(CEikTextListBox* aLb);
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Create an item text according with its selection state.
|
|
64 |
* @param aPtr the item text.
|
|
65 |
* @param aSelected the item selection state.
|
|
66 |
* @return the buffer containing the item text.
|
|
67 |
*/
|
|
68 |
virtual HBufC* CreateItemTextLC(const TDesC& aPtr, TBool aSelected = EFalse);
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Update control size.
|
|
72 |
*/
|
|
73 |
virtual void UpdateSize();
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Update the list box font.
|
|
77 |
*/
|
|
78 |
void UpdateListBoxFontL();
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Update the list box text color.
|
|
82 |
*/
|
|
83 |
void UpdateListBoxTextColorL();
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Returns MSwtScrollable reference.
|
|
87 |
* @return MSwtScrollable reference.
|
|
88 |
*/
|
|
89 |
MSwtScrollable* Scrollable();
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Deselect items.
|
|
93 |
* @param aIndices the indices of items to deselect.
|
|
94 |
* @param aCount the number of items to deselect.
|
|
95 |
*/
|
|
96 |
void DeselectItems(const TInt* aIndices, TInt aCount);
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Deselect an item.
|
|
100 |
* @param aIndex the index of the item to deselect.
|
|
101 |
*/
|
|
102 |
void DeselectItem(TInt aIndex);
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Deselect a range of items.
|
|
106 |
* @param aStart the start index of the item range.
|
|
107 |
* @param aEnd the end index of the item range.
|
|
108 |
*/
|
|
109 |
void DeselectRange(TInt aStart, TInt aEnd);
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Deselect all items.
|
|
113 |
*/
|
|
114 |
void DeselectAll();
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Get focus index.
|
|
118 |
* @return the index of the focused item.
|
|
119 |
*/
|
|
120 |
TInt GetFocusIndex() const;
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Get the number of selected items.
|
|
124 |
* @return the number of selected items.
|
|
125 |
*/
|
|
126 |
TInt GetSelectionCount() const;
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Get the indices of selected items.
|
|
130 |
* @return the index array of selected items.
|
|
131 |
*/
|
|
132 |
const CArrayFix<TInt>* GetSelectionIndices() const;
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Select an item.
|
|
136 |
* @param aIndex the index of the item to select.
|
|
137 |
* @param aScroll If ETrue the list is scrolled to make visible the selected item.
|
|
138 |
*/
|
|
139 |
void SelectItemL(TInt aIndex, TBool aScroll);
|
|
140 |
|
|
141 |
/**
|
|
142 |
* Select a range of items.
|
|
143 |
* @param aStart the start index of the item range.
|
|
144 |
* @param aEnd the end index of the item range.
|
|
145 |
*/
|
|
146 |
void SelectRangeL(TInt aStart, TInt aEnd);
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Select all items.
|
|
150 |
*/
|
|
151 |
void SelectAllL();
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Show the selected item.
|
|
155 |
*/
|
|
156 |
void ShowSelection() const;
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Post a selection event.
|
|
160 |
*/
|
|
161 |
void PostSelectionEvent() const;
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Calculate the focus index and the top item index after an item removal.
|
|
165 |
* @param aNewFocusIndex the new focusindex.
|
|
166 |
* @param aRemovedItemIndices the removed item indices.
|
|
167 |
* @param aOldFocusIndex the old focus index.
|
|
168 |
*/
|
|
169 |
void CalcFocusIndexAfterItemRemoval(TInt& aNewFocusIndex,
|
|
170 |
const RArray<TInt>& aRemovedItemIndices, TInt aOldFocusIndex) const;
|
|
171 |
|
|
172 |
/**
|
|
173 |
* Get the minimum width of a list item.
|
|
174 |
* @return the minimum width of a list item.
|
|
175 |
*/
|
|
176 |
TInt MinimumListItemWidth() const;
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Get the preferred width.
|
|
180 |
* @return preferred width.
|
|
181 |
*/
|
|
182 |
TInt PreferredWidth() const;
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Get the preferred height.
|
|
186 |
* @return preferred height.
|
|
187 |
*/
|
|
188 |
TInt PreferredHeight() const;
|
|
189 |
|
|
190 |
/**
|
|
191 |
* Compute the maximum width of item text.
|
|
192 |
* @return the the maximum width of item text.
|
|
193 |
*/
|
|
194 |
TInt ComputeTextMaxWidth() const;
|
|
195 |
|
|
196 |
/**
|
|
197 |
* Compute the maximum width of item text.
|
|
198 |
* @return the the maximum width of item text.
|
|
199 |
*/
|
|
200 |
void SetTextMaxWidth(TInt aMaxTxtWidth);
|
|
201 |
|
|
202 |
/**
|
|
203 |
* Update MSK.
|
|
204 |
*/
|
|
205 |
void UpdateListMskL();
|
|
206 |
|
|
207 |
protected:
|
|
208 |
/**
|
|
209 |
* First phase constructor
|
|
210 |
* @param aDisplay parent display
|
|
211 |
* @param aPeer java peer of this class
|
|
212 |
* @param aParent composite parent
|
|
213 |
* @param aStyle control style
|
|
214 |
*/
|
|
215 |
CSwtListBase(MSwtDisplay& aDisplay, TSwtPeer aPeer, MSwtComposite& aParent, TInt aStyle);
|
|
216 |
|
|
217 |
/**
|
|
218 |
* Destructor
|
|
219 |
*/
|
|
220 |
~CSwtListBase();
|
|
221 |
|
|
222 |
/**
|
|
223 |
* Second phase constructor
|
|
224 |
*/
|
|
225 |
void ConstructL();
|
|
226 |
|
|
227 |
private:
|
|
228 |
/**
|
|
229 |
* Update the default font.
|
|
230 |
*/
|
|
231 |
void UpdateDefaultFontL();
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Handling of resource change events.
|
|
235 |
* @param aType event type.
|
|
236 |
*/
|
|
237 |
void HandleResourceChangeL(TInt aType);
|
|
238 |
|
|
239 |
/**
|
|
240 |
* Get current state of list selection.
|
|
241 |
* @param aCurrSelItems resulting array of selected items.
|
|
242 |
*/
|
|
243 |
void GetUserSelectionL(CArrayFix<TInt>* aCurrSelItems);
|
|
244 |
|
|
245 |
/**
|
|
246 |
* Updates flick scrolling status.
|
|
247 |
* @param aEventType CEikListbox event type.
|
|
248 |
*/
|
|
249 |
void UpdateFlickScrollingState(TListBoxEvent aEventType);
|
|
250 |
|
|
251 |
// From CCoeControl
|
|
252 |
public:
|
|
253 |
TInt CountComponentControls() const;
|
|
254 |
CCoeControl* ComponentControl(TInt aIndex) const;
|
|
255 |
void MakeVisible(TBool aVisible);
|
|
256 |
void SetDimmed(TBool aDimmed);
|
|
257 |
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
258 |
void HandleResourceChange(TInt aType);
|
|
259 |
|
|
260 |
protected:
|
|
261 |
void SizeChanged();
|
|
262 |
void PositionChanged();
|
|
263 |
void FocusChanged(TDrawNow aDrawNow);
|
|
264 |
TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
|
|
265 |
|
|
266 |
private:
|
|
267 |
void Draw(const TRect& aRect) const;
|
|
268 |
|
|
269 |
// From ASwtControlbase
|
|
270 |
public:
|
|
271 |
void SetFontL(const MSwtFont* aFont);
|
|
272 |
HBufC* MSKLabelL() const;
|
|
273 |
TBool MSKSelCmdEnabled() const;
|
|
274 |
|
|
275 |
protected:
|
|
276 |
const MSwtFont& DefaultFont() const;
|
|
277 |
|
|
278 |
// From MSwtControl
|
|
279 |
public:
|
|
280 |
CCoeControl& CoeControl();
|
|
281 |
const CCoeControl& CoeControl() const;
|
|
282 |
void ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
283 |
void HandlePointerEventL(const TPointerEvent& aPointerEvent);
|
|
284 |
TBool IsKeyUsed(TUint aKeyCode) const;
|
|
285 |
TRgb GetForeground() const;
|
|
286 |
void SetForegroundL(const MSwtColor* aColor);
|
|
287 |
void SetBackgroundL(const MSwtColor* aColor);
|
|
288 |
TBool IsLongTapAnimationCandidate(const TPointerEvent& aPointerEvent) const;
|
|
289 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
290 |
void EnableFocusHighlight(TBool aEnable);
|
|
291 |
#endif //RD_JAVA_S60_RELEASE_9_2
|
|
292 |
TInt FocusBackgroundPolicy() const;
|
|
293 |
|
|
294 |
// From ASwtScrollableBase
|
|
295 |
protected:
|
|
296 |
CEikScrollBarFrame* SbFrame() const;
|
|
297 |
|
|
298 |
// From MSwtListObserver
|
|
299 |
public:
|
|
300 |
void HandleSizeChangedL();
|
|
301 |
MSwtUiUtils& Utils() const;
|
|
302 |
|
|
303 |
// From MEikScrollBarObserver
|
|
304 |
public:
|
|
305 |
void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType);
|
|
306 |
|
|
307 |
// From MEikListBoxObserver
|
|
308 |
public:
|
|
309 |
void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
|
|
310 |
|
|
311 |
// Data
|
|
312 |
protected:
|
|
313 |
/**
|
|
314 |
* Previously selected items (temporary)
|
|
315 |
* Own
|
|
316 |
*/
|
|
317 |
CArrayFix<TInt>* iPrevSelItems;
|
|
318 |
|
|
319 |
/**
|
|
320 |
* Pointer to the contained ListBox.
|
|
321 |
* Own
|
|
322 |
*/
|
|
323 |
CEikTextListBox* iList;
|
|
324 |
|
|
325 |
/**
|
|
326 |
* Array of text items.
|
|
327 |
* Own
|
|
328 |
*/
|
|
329 |
CDesCArray* iTextItems;
|
|
330 |
|
|
331 |
/**
|
|
332 |
* The default font.
|
|
333 |
* Own
|
|
334 |
*/
|
|
335 |
MSwtFont* iDefaultFont;
|
|
336 |
|
|
337 |
/**
|
|
338 |
* The current used LAF font.
|
|
339 |
*/
|
|
340 |
const CFont* iCurrentLafFont;
|
|
341 |
|
|
342 |
/**
|
|
343 |
* The default item height (when default font is set).
|
|
344 |
*/
|
|
345 |
TInt iDefaultItemHeight;
|
|
346 |
|
|
347 |
/**
|
|
348 |
* Pointer to the text color.
|
|
349 |
*/
|
|
350 |
const MSwtColor* iTextColor;
|
|
351 |
|
|
352 |
/**
|
|
353 |
* Removed item indices.
|
|
354 |
*/
|
|
355 |
RArray<TInt> iRemovedItemIndices;
|
|
356 |
|
|
357 |
/**
|
|
358 |
* The maximum width of item text.
|
|
359 |
*/
|
|
360 |
TInt iTxtMaxWidth;
|
|
361 |
|
|
362 |
/**
|
|
363 |
* Deliver all pointer event to the scrollbar when this on.
|
|
364 |
*/
|
|
365 |
TBool iVScrollBarGrabsPointerEvents;
|
|
366 |
|
|
367 |
/**
|
|
368 |
* Stores last known focus index. Use only during paint and key handlers.
|
|
369 |
*/
|
|
370 |
TInt iPrevFocusIndex;
|
|
371 |
|
|
372 |
/**
|
|
373 |
* Type of the list
|
|
374 |
*/
|
|
375 |
TInt iListType;
|
|
376 |
|
|
377 |
/**
|
|
378 |
* View visible rect at last draw
|
|
379 |
*/
|
|
380 |
mutable TRect iLastViewVisibleRect;
|
|
381 |
|
|
382 |
/**
|
|
383 |
* True when list is flick scrolling
|
|
384 |
*/
|
|
385 |
TBool iFlickScrollingOngoing;
|
|
386 |
|
|
387 |
/**
|
|
388 |
* True when pointer events on scrollbar should be delivered to listbox
|
|
389 |
*/
|
|
390 |
TBool iScrollbarPointerEventToListbox;
|
|
391 |
};
|
|
392 |
|
|
393 |
|
|
394 |
#endif // SWTLISTBASE_H
|