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 SWTLISTVIEW_H
|
|
14 |
#define SWTLISTVIEW_H
|
|
15 |
|
|
16 |
|
|
17 |
#include <eiklbo.h>
|
|
18 |
#include "eswtmobileextensions.h"
|
|
19 |
#include "swtscrollablebase.h"
|
|
20 |
#include "swtscrollbar.h"
|
|
21 |
|
|
22 |
|
|
23 |
class CAknIconArray;
|
|
24 |
class CSelectionIndexArray;
|
|
25 |
class CSwtGrid;
|
|
26 |
class CAknGridM;
|
|
27 |
class CAknGridView;
|
|
28 |
class CSwtControlMenu;
|
|
29 |
class CSwtMenu;
|
|
30 |
class CSwtMenuItem;
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
* CSwtListView
|
|
35 |
* This class implements the eSWT ListView on S60 platform
|
|
36 |
* @lib eswt
|
|
37 |
*/
|
|
38 |
NONSHARABLE_CLASS(CSwtListView)
|
|
39 |
: public CAknControl
|
|
40 |
, public ASwtScrollableBase
|
|
41 |
, public MSwtListView
|
|
42 |
, public MEikCommandObserver
|
|
43 |
, public MEikListBoxObserver
|
|
44 |
{
|
|
45 |
public:
|
|
46 |
static CSwtListView* NewL(MSwtDisplay& aDisplay, TSwtPeer aPeer,
|
|
47 |
MSwtComposite& aParent, TInt aStyle);
|
|
48 |
static CSwtListView* NewLC(MSwtDisplay& aDisplay, TSwtPeer aPeer,
|
|
49 |
MSwtComposite& aParent, TInt aStyle);
|
|
50 |
virtual ~CSwtListView();
|
|
51 |
void ScrollViewToShowAsManyItemsAsPossibleL();
|
|
52 |
TInt ScrollBarBreadth(const CEikScrollBar* aBar);
|
|
53 |
|
|
54 |
// From CCoeControl
|
|
55 |
CCoeControl* ComponentControl(TInt aIndex) const;
|
|
56 |
TInt CountComponentControls() const;
|
|
57 |
void SizeChanged();
|
|
58 |
void PositionChanged();
|
|
59 |
void HandleResourceChange(TInt aType);
|
|
60 |
void FocusChanged(TDrawNow aDrawNow);
|
|
61 |
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
|
|
62 |
void MakeVisible(TBool aVisible);
|
|
63 |
void SetDimmed(TBool aDimmed);
|
|
64 |
TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
|
|
65 |
|
|
66 |
private:
|
|
67 |
void Draw(const TRect& aRect) const;
|
|
68 |
|
|
69 |
// From MSwtListView
|
|
70 |
public:
|
|
71 |
MSwtScrollable* Scrollable();
|
|
72 |
void AppendL(const TDesC& aPtr, const MSwtImage* aImage);
|
|
73 |
void InsertL(TInt aPos, const TDesC& aPtr, const MSwtImage* aImage);
|
|
74 |
void DeselectItem(TInt aIndex);
|
|
75 |
void DeselectRange(TInt aStart, TInt aEnd);
|
|
76 |
void DeselectItems(const TInt* aIndices, TInt aCount);
|
|
77 |
void DeselectAll();
|
|
78 |
TInt GetFocusIndex() const;
|
|
79 |
void GetItemL(TInt aItemIndex, TPtrC& aString) const;
|
|
80 |
TPoint GetIconSize(TInt aStyle) const;
|
|
81 |
TInt GetItemCount() const;
|
|
82 |
CPtrCArray* GetItemsL() const;
|
|
83 |
CPtrCArray* GetSelectionL() const;
|
|
84 |
TInt GetSelectionCount() const;
|
|
85 |
const CArrayFix<TInt>* GetSelectionIndices() const;
|
|
86 |
TInt GetTopIndex() const;
|
|
87 |
TInt IndexOf(const TDesC& aString, TInt& aStart) const;
|
|
88 |
TBool IsSelected(TInt aIndex) const;
|
|
89 |
void RemoveItemL(TInt aIndex);
|
|
90 |
void RemoveRangeL(TInt aStart, TInt aEnd);
|
|
91 |
void RemoveItemsL(const TInt* aIndices, TInt aCount);
|
|
92 |
void RemoveAllL();
|
|
93 |
void SelectItemL(TInt aIndex, TBool aScroll);
|
|
94 |
void SelectRangeL(TInt aStart, TInt aEnd);
|
|
95 |
void SelectAllL();
|
|
96 |
void SetItemsL(MDesCArray* aStringArray, RPointerArray<MSwtImage>& aImagesArray);
|
|
97 |
void SetLayoutL(TInt aLayout);
|
|
98 |
void SetLayoutDensityL(TInt aDensity);
|
|
99 |
void ShowSelection();
|
|
100 |
void SetFocusIndex(TInt aIndex);
|
|
101 |
|
|
102 |
// From ASwtScrollableBase
|
|
103 |
CEikScrollBarFrame* SbFrame() const;
|
|
104 |
void SetVisibleScrollBar(TInt aStyle, TBool aVisible);
|
|
105 |
void ScrollBarDestroyed(const MSwtScrollBar* aScrollBar);
|
|
106 |
#if defined( RD_SCALABLE_UI_V2)
|
|
107 |
void HandleScrollEventL(CEikScrollBar* aScrollBar,
|
|
108 |
TEikScrollEvent aEventType);
|
|
109 |
#endif
|
|
110 |
|
|
111 |
// From MSwtControl
|
|
112 |
CCoeControl& CoeControl();
|
|
113 |
const CCoeControl& CoeControl() const;
|
|
114 |
void ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
115 |
TRgb GetBackground() const;
|
|
116 |
TRgb GetForeground() const;
|
|
117 |
void SetBackgroundL(const MSwtColor* aColor);
|
|
118 |
void SetForegroundL(const MSwtColor* aColor);
|
|
119 |
TSize ComputeSizeL(TInt aWHint, TInt aHHint);
|
|
120 |
TBool IsKeyUsed(TUint aKeyCode) const;
|
|
121 |
TBool MSKSelCmdEnabled() const;
|
|
122 |
const MSwtMenu* GetControlMenu() const;
|
|
123 |
void UpdateDoNotDrawFlag();
|
|
124 |
HBufC* MSKLabelL() const;
|
|
125 |
#if defined( RD_SCALABLE_UI_V2)
|
|
126 |
void HandlePointerEventL(const TPointerEvent& aPointerEvent);
|
|
127 |
const MSwtMenu* GetStylusPopupControlMenu() const;
|
|
128 |
#endif
|
|
129 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
130 |
void EnableFocusHighlight(TBool aEnable);
|
|
131 |
#endif //RD_JAVA_S60_RELEASE_9_2
|
|
132 |
TInt FocusBackgroundPolicy() const;
|
|
133 |
|
|
134 |
// From MEikCommandObserver
|
|
135 |
public:
|
|
136 |
void ProcessCommandL(TInt aCmdId);
|
|
137 |
|
|
138 |
// From MEikListBoxObserver
|
|
139 |
public:
|
|
140 |
void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
|
|
141 |
|
|
142 |
// Own methods
|
|
143 |
private:
|
|
144 |
CSwtListView(MSwtDisplay& aDisplay, TSwtPeer aPeer, MSwtComposite& aParent, TInt aStyle);
|
|
145 |
void ConstructL();
|
|
146 |
|
|
147 |
enum TSwtListViewDensity
|
|
148 |
{
|
|
149 |
ELowListViewDensity = 1,
|
|
150 |
EMediumListViewDensity = 2,
|
|
151 |
EHighListViewDensity = 3
|
|
152 |
};
|
|
153 |
|
|
154 |
void ApplyGridCellLayoutL();
|
|
155 |
CDesCArray* GetTextArray() const;
|
|
156 |
CAknIconArray* GetIconArray() const;
|
|
157 |
CAknGridM* GetGridModel() const;
|
|
158 |
CAknGridView* GetGridView() const;
|
|
159 |
CGulIcon* CreateIconL(const MSwtImage* aIcon) const;
|
|
160 |
void DoGridCellLayoutL(const TSwtListViewDensity& aDensity);
|
|
161 |
void LoadLayouts(const TSwtListViewDensity& aDensity, TSize& aCellSize,
|
|
162 |
TRect& aIconRect, TRect& aSelRect, TRect& aTextRect,
|
|
163 |
TInt& aTextCellFontId);
|
|
164 |
void CalcRowsColumns(const TSize& aCellSize, TInt& aXCells, TInt& aYCells) const;
|
|
165 |
void AddTextL(const TDesC& aPtr, const TInt& aPos);
|
|
166 |
void AddIconL(const MSwtImage* aImage, const TInt& aPos);
|
|
167 |
void AddItemL(const TDesC& aPtr, const MSwtImage* aImage, const TInt& aPos);
|
|
168 |
void UpdateIconIndexL(const TInt& arrayIndex);
|
|
169 |
void UpdateSelectionIndexesL(TInt aStart, TInt aEnd, TBool aItemsAdded);
|
|
170 |
void UntabifyL(RBuf& aAll);
|
|
171 |
TInt GetCaption(const TInt& aIndex, TPtrC& aTxt) const;
|
|
172 |
void SingleSelectL(const TInt& aIndex, TBool aScroll);
|
|
173 |
void SingleOrMultiSelectL(const TInt& aIndex, TBool aScroll);
|
|
174 |
void UpdateTextColorL();
|
|
175 |
CGulIcon* GetMarkedItemIconL();
|
|
176 |
void HandleResourceChangeL(TInt aType);
|
|
177 |
void SizeChangedL();
|
|
178 |
TInt ItemIconIndex(const TInt& aItemPos);
|
|
179 |
void UpdateControlMenu();
|
|
180 |
TInt GetBorderSize(const TInt& aAlignment) const;
|
|
181 |
TSize GetCellSize() const;
|
|
182 |
TUint ISqrt(TUint x);
|
|
183 |
TInt GetRowColumnCount(const TInt& aItemCount, const TInt& aRowColumnCount) const;
|
|
184 |
void UpdateMSKLabelL();
|
|
185 |
void LayoutCell(const TRect& aCellRect, TRect& aTextRect, TRect& aIconRect, TRect& aSelRect);
|
|
186 |
void UpdateSetItemCount(const TInt& textChange, const TInt& iconChange);
|
|
187 |
void DoGridCellLayoutIfNeededL();
|
|
188 |
void UpdateRemovedItemCountersL(const TInt& aIndex);
|
|
189 |
void GetSelection(CArrayFix<TInt>* aSelectionArray) const;
|
|
190 |
TInt GetSelectionL(const TInt aIndex) const;
|
|
191 |
void SetSelectionL(const CArrayFix<TInt>* aSelectionArray) const;
|
|
192 |
void UpdateImageSizes(const TSize& aNewMaxSize);
|
|
193 |
void RemoveImageRef(const TInt& aIndex);
|
|
194 |
void GetCellVariants(const TSwtListViewDensity& aDensity,
|
|
195 |
TInt& aCellVariant, TInt& aSubcellVariantG1,
|
|
196 |
TInt& aSubcellVariantG2, TInt& aSubcellVariantT) const;
|
|
197 |
void UpdateIconSizes(const TSwtListViewDensity& aDensity,
|
|
198 |
const TRect& aCellRect);
|
|
199 |
void GetLafFacadeRectIds(
|
|
200 |
const TSwtListViewDensity& aDensity,
|
|
201 |
CSwtLafFacade::TSwtLafFacadeRectId& aRectIdPane,
|
|
202 |
CSwtLafFacade::TSwtLafFacadeRectId& aRectIdPaneG1,
|
|
203 |
CSwtLafFacade::TSwtLafFacadeRectId& aRectIdPaneG2,
|
|
204 |
CSwtLafFacade::TSwtLafFacadeTextId& aRectIdPaneT1,
|
|
205 |
CSwtLafFacade::TSwtLafFacadeFontId& aRectIdPaneT1Font
|
|
206 |
) const;
|
|
207 |
void CoerceCellRect(const TSwtListViewDensity& aDensity,
|
|
208 |
TRect& aCellRect) const;
|
|
209 |
void UpdateFlickScrollingState(TListBoxEvent aEventType);
|
|
210 |
|
|
211 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
|
|
212 |
public:
|
|
213 |
void DoControlSpecificFeedback(
|
|
214 |
const TBool& aFirstTap,
|
|
215 |
const TBool& aTappedToChildRect,
|
|
216 |
const TPointerEvent& aPointerEvent) const;
|
|
217 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
|
|
218 |
|
|
219 |
private: // data
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Cell layout params for the grid.
|
|
223 |
*/
|
|
224 |
TBool iVerticalOrientation;
|
|
225 |
TBool iLeftToRight;
|
|
226 |
TBool iTopToBottom;
|
|
227 |
TInt iNumOfRows;
|
|
228 |
TInt iNumOfColumns;
|
|
229 |
TInt iWidthOfSpaceBetweenItems;
|
|
230 |
TInt iHeightOfSpaceBetweenItems;
|
|
231 |
|
|
232 |
/**
|
|
233 |
* The current density.
|
|
234 |
*/
|
|
235 |
TSwtListViewDensity iDensity;
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Icon sizes for getIconSize
|
|
239 |
*/
|
|
240 |
TPoint iIconSizeInLowDensity;
|
|
241 |
TPoint iIconSizeInMediumDensity;
|
|
242 |
TPoint iIconSizeInHighDensity;
|
|
243 |
|
|
244 |
/**
|
|
245 |
* Number of non-NULL icons and texts
|
|
246 |
*/
|
|
247 |
TInt iNumberOfTexts;
|
|
248 |
TInt iNumberOfIcons;
|
|
249 |
|
|
250 |
/**
|
|
251 |
* The control menu.
|
|
252 |
* Owned.
|
|
253 |
*/
|
|
254 |
CSwtControlMenu* iMenu;
|
|
255 |
|
|
256 |
/**
|
|
257 |
* The control menu submenu.
|
|
258 |
* Owned.
|
|
259 |
*/
|
|
260 |
CSwtControlMenu* iSubMenu;
|
|
261 |
|
|
262 |
/**
|
|
263 |
* The control menu items.
|
|
264 |
* Owned.
|
|
265 |
*/
|
|
266 |
CSwtMenuItem* iMenuItemEditList;
|
|
267 |
CSwtMenuItem* iMenuItemMarkUnmark;
|
|
268 |
CSwtMenuItem* iMenuItemMarkAll;
|
|
269 |
CSwtMenuItem* iMenuItemUnmarkAll;
|
|
270 |
|
|
271 |
/**
|
|
272 |
* The strings for mark/unmark command and its state.
|
|
273 |
*/
|
|
274 |
TBool iIsMarkDisplayed;
|
|
275 |
HBufC* iMarkString;
|
|
276 |
HBufC* iUnmarkString;
|
|
277 |
|
|
278 |
/**
|
|
279 |
* The Selection array before a key event, for multiselection only.
|
|
280 |
* Own.
|
|
281 |
*/
|
|
282 |
CArrayFix<TInt>* iOldSelectionArray;
|
|
283 |
|
|
284 |
/**
|
|
285 |
* The Selection array for handling selection indexes with mirrored layout.
|
|
286 |
* Own.
|
|
287 |
*/
|
|
288 |
CArrayFix<TInt>* iSelectionArray;
|
|
289 |
|
|
290 |
/**
|
|
291 |
* The colors used to draw text and background.
|
|
292 |
* Not own.
|
|
293 |
*/
|
|
294 |
const MSwtColor* iTextColor;
|
|
295 |
const MSwtColor* iBgColor;
|
|
296 |
|
|
297 |
/**
|
|
298 |
* Referenced images as the ListView does not copy the bitmaps it uses.
|
|
299 |
*/
|
|
300 |
RPointerArray<const MSwtImage> iRefImages;
|
|
301 |
|
|
302 |
/**
|
|
303 |
* Maximum image size for the current layout.
|
|
304 |
*/
|
|
305 |
TSize iMaxImageSize;
|
|
306 |
|
|
307 |
/**
|
|
308 |
* The grid control.
|
|
309 |
* Own.
|
|
310 |
*/
|
|
311 |
CSwtGrid* iGrid;
|
|
312 |
|
|
313 |
/**
|
|
314 |
* Deliver all pointer event to the scrollbar when this on.
|
|
315 |
*/
|
|
316 |
TBool iVScrollBarGrabsPointerEvents;
|
|
317 |
|
|
318 |
#ifdef RD_SCALABLE_UI_V2
|
|
319 |
/**
|
|
320 |
* The control menu for stylus popup.
|
|
321 |
* Owned.
|
|
322 |
*/
|
|
323 |
CSwtControlMenu* iStylusPopupMenu;
|
|
324 |
|
|
325 |
/**
|
|
326 |
* The control menu items fro stylus popup.
|
|
327 |
* Owned.
|
|
328 |
*/
|
|
329 |
CSwtMenuItem* iStylusPopupMarkAll;
|
|
330 |
CSwtMenuItem* iStylusPopupUnmarkAll;
|
|
331 |
#endif //RD_SCALABLE_UI_V2
|
|
332 |
|
|
333 |
/**
|
|
334 |
* Stores last known focus index. Use only during paint and key handlers.
|
|
335 |
*/
|
|
336 |
TInt iPrevFocusIndex;
|
|
337 |
|
|
338 |
/**
|
|
339 |
* Stores grid cell layout update status
|
|
340 |
*/
|
|
341 |
TBool iIsGridCellLayoutNeeded;
|
|
342 |
|
|
343 |
/**
|
|
344 |
* View visible rect at last draw
|
|
345 |
*/
|
|
346 |
mutable TRect iLastViewVisibleRect;
|
|
347 |
|
|
348 |
/**
|
|
349 |
* True when list is flick scrolling
|
|
350 |
*/
|
|
351 |
TBool iFlickScrollingOngoing;
|
|
352 |
|
|
353 |
/**
|
|
354 |
* True when pointer events on scrollbar should be delivered to listbox
|
|
355 |
*/
|
|
356 |
TBool iScrollbarPointerEventToListbox;
|
|
357 |
};
|
|
358 |
|
|
359 |
|
|
360 |
#endif // SWTLISTVIEW_H
|