66
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2007, 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 SWTLISTBOXLISTS_H
|
|
14 |
#define SWTLISTBOXLISTS_H
|
|
15 |
|
|
16 |
|
|
17 |
#include <aknlists.h>
|
|
18 |
#include "eswtwidgetscore.h"
|
|
19 |
#include "swtlistboxlistsitemdrawer.h"
|
|
20 |
|
|
21 |
template <class, class, class> class CSwtListBoxTemplate;
|
|
22 |
|
|
23 |
|
|
24 |
/** List box types. Same order as in KSwtLbCells */
|
|
25 |
enum TSwtLbType
|
|
26 |
{
|
|
27 |
ESwtLbSingle = 0,
|
|
28 |
ESwtLbSingleGraphic,
|
|
29 |
ESwtLbSingleLarge,
|
|
30 |
ESwtLbSingleHeading,
|
|
31 |
ESwtLbSingleHeadingGraphic,
|
|
32 |
ESwtLbDouble,
|
|
33 |
ESwtLbDoubleGraphic,
|
|
34 |
ESwtLbDoubleLarge,
|
|
35 |
ESwtLbTypeCount
|
|
36 |
};
|
|
37 |
|
|
38 |
/** Avkon list boxes for each list box type */
|
|
39 |
typedef CSwtListBoxTemplate <CAknSingleStyleListBox,
|
|
40 |
CSwtColumnListBoxItemDrawer,
|
|
41 |
CColumnListBoxData> CSwtListBoxSingle;
|
|
42 |
typedef CSwtListBoxTemplate <CAknSingleGraphicStyleListBox,
|
|
43 |
CSwtColumnListBoxItemDrawer,
|
|
44 |
CColumnListBoxData> CSwtListBoxSingleGraphic;
|
|
45 |
typedef CSwtListBoxTemplate <CAknSingleLargeStyleListBox,
|
|
46 |
CSwtColumnListBoxItemDrawer,
|
|
47 |
CColumnListBoxData> CSwtListBoxSingleLarge;
|
|
48 |
typedef CSwtListBoxTemplate <CAknSingleHeadingStyleListBox,
|
|
49 |
CSwtSingleHeadingStyleListBoxItemDrawer,
|
|
50 |
CColumnListBoxData> CSwtListBoxSingleHeading;
|
|
51 |
typedef CSwtListBoxTemplate <CAknSingleGraphicHeadingStyleListBox,
|
|
52 |
CSwtSingleHeadingStyleListBoxItemDrawer,
|
|
53 |
CColumnListBoxData> CSwtListBoxSingleHeadingGraphic;
|
|
54 |
typedef CSwtListBoxTemplate <CAknDoubleStyleListBox,
|
|
55 |
CSwtFormattedCellListBoxItemDrawer,
|
|
56 |
CFormattedCellListBoxData> CSwtListBoxDouble;
|
|
57 |
typedef CSwtListBoxTemplate <CAknDoubleGraphicStyleListBox,
|
|
58 |
CSwtFormattedCellListBoxItemDrawer,
|
|
59 |
CFormattedCellListBoxData> CSwtListBoxDoubleGraphic;
|
|
60 |
typedef CSwtListBoxTemplate <CAknDoubleLargeStyleListBox,
|
|
61 |
CSwtDoubleLargeStyleItemDrawer,
|
|
62 |
CFormattedCellListBoxData> CSwtListBoxDoubleLarge;
|
|
63 |
|
|
64 |
/** List box cells */
|
|
65 |
enum TSwtLbCellType
|
|
66 |
{
|
|
67 |
ECellInvalid = 0,
|
|
68 |
ECellEmpty,
|
|
69 |
ECellDtxt,
|
|
70 |
ECellDimg,
|
|
71 |
ECellHtxt,
|
|
72 |
ECellHimg
|
|
73 |
};
|
|
74 |
|
|
75 |
/** Maximum number of cells per item */
|
|
76 |
const TInt KMaxCellCount = 5;
|
|
77 |
|
|
78 |
/** List box cells for each list box type. Same order as in TSwtLbType */
|
|
79 |
const TInt KSwtLbCells[ESwtLbTypeCount][KMaxCellCount] =
|
|
80 |
{
|
|
81 |
{ ECellEmpty, ECellDtxt, ECellDimg, 0, 0 }, // ESwtLbSingle
|
|
82 |
{ ECellHimg, ECellDtxt, ECellDimg, 0, 0 }, // ESwtLbSingleGraphic
|
|
83 |
{ ECellHimg, ECellDtxt, ECellDimg, 0, 0 }, // ESwtLbSingleLarge
|
|
84 |
{ ECellHtxt, ECellDtxt, ECellDimg, 0, 0 }, // ESwtLbSingleHeading
|
|
85 |
{ ECellHimg, ECellHtxt, ECellDtxt, ECellDimg, 0 }, // ESwtLbSingleHeadingGraphic
|
|
86 |
{ ECellEmpty, ECellHtxt, ECellDtxt, ECellDimg, 0 }, // ESwtLbDouble
|
|
87 |
{ ECellHimg, ECellHtxt, ECellDtxt, ECellDimg, 0 }, // ESwtLbDoubleGraphic
|
|
88 |
{ ECellHimg, ECellHtxt, ECellDtxt, ECellDimg, 0 }, // ESwtLbDoubleLarge
|
|
89 |
};
|
|
90 |
|
|
91 |
/** List box selection types */
|
|
92 |
enum TSwtLbSelectionType
|
|
93 |
{
|
|
94 |
ESwtLbSingleSelection = 0,
|
|
95 |
ESwtLbMultiSelection
|
|
96 |
};
|
|
97 |
|
|
98 |
|
|
99 |
/**
|
|
100 |
* MSwtListObserver
|
|
101 |
*/
|
|
102 |
class MSwtListObserver
|
|
103 |
{
|
|
104 |
public:
|
|
105 |
virtual void HandleSizeChangedL() = 0;
|
|
106 |
virtual MSwtUiUtils& Utils() const = 0;
|
|
107 |
};
|
|
108 |
|
|
109 |
/**
|
|
110 |
* CSwtListBoxListTemplate
|
|
111 |
* @lib eswt
|
|
112 |
*/
|
|
113 |
template<class CType, class CSwtListBoxItemDrawerType, class CListBoxDataType>
|
|
114 |
NONSHARABLE_CLASS(CSwtListBoxTemplate)
|
|
115 |
: public CType
|
|
116 |
{
|
|
117 |
// New methods
|
|
118 |
public:
|
|
119 |
/**
|
|
120 |
* Factory
|
|
121 |
*/
|
|
122 |
static CSwtListBoxTemplate<CType, CSwtListBoxItemDrawerType,
|
|
123 |
CListBoxDataType>* NewL();
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Sets item drawer's clipping rectangle
|
|
127 |
*/
|
|
128 |
void SetItemDrawerClippingRect(const TRect& aRect);
|
|
129 |
|
|
130 |
/**
|
|
131 |
* Sets margins.
|
|
132 |
*/
|
|
133 |
void SetMargins(TInt aHorizontal, TInt aVertical);
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Destructor
|
|
137 |
*/
|
|
138 |
~CSwtListBoxTemplate();
|
|
139 |
|
|
140 |
private:
|
|
141 |
/**
|
|
142 |
* First Phase Constructor
|
|
143 |
*/
|
|
144 |
CSwtListBoxTemplate();
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Second Phase Constructor
|
|
148 |
*/
|
|
149 |
void ConstructL();
|
|
150 |
|
|
151 |
// From CCoeControl
|
|
152 |
public:
|
|
153 |
void PositionChanged();
|
|
154 |
void SizeChanged();
|
|
155 |
|
|
156 |
// From CCoeControl
|
|
157 |
protected:
|
|
158 |
TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
|
|
159 |
|
|
160 |
// From CEikListBox
|
|
161 |
public:
|
|
162 |
void SetItemHeightL(TInt aHeight);
|
|
163 |
|
|
164 |
// From CType
|
|
165 |
protected:
|
|
166 |
void CreateItemDrawerL();
|
|
167 |
|
|
168 |
// New methods
|
|
169 |
public:
|
|
170 |
/**
|
|
171 |
* Set a list observer.
|
|
172 |
* @param aListObserver The list observer
|
|
173 |
*/
|
|
174 |
void SetListObserver(MSwtListObserver* aListObserver);
|
|
175 |
|
|
176 |
private:
|
|
177 |
/**
|
|
178 |
* Calculate area capable of displaying client data.
|
|
179 |
* @param aRect
|
|
180 |
* @param aBorder
|
|
181 |
* @param aSBrame
|
|
182 |
* @param aExcludeScrollBars
|
|
183 |
*/
|
|
184 |
TRect ClientRect(TRect aRect, TGulBorder aBorder,
|
|
185 |
CEikScrollBarFrame* aSBrame, TBool aExcludeScrollBars) const;
|
|
186 |
|
|
187 |
/**
|
|
188 |
* Size or position of this control has changed.
|
|
189 |
*/
|
|
190 |
void RectChangedL(TBool aDoHandleSizeChanged);
|
|
191 |
|
|
192 |
// Data
|
|
193 |
private:
|
|
194 |
MSwtListObserver* iListObserver;
|
|
195 |
};
|
|
196 |
|
|
197 |
|
|
198 |
/**
|
|
199 |
* CSwtListBoxLists
|
|
200 |
* @lib eswt
|
|
201 |
*/
|
|
202 |
NONSHARABLE_CLASS(CSwtListBoxLists)
|
|
203 |
: public CBase
|
|
204 |
{
|
|
205 |
// New methods
|
|
206 |
public:
|
|
207 |
/**
|
|
208 |
* Create a list box.
|
|
209 |
* @param aListType see TSwtLbType
|
|
210 |
* @return pointer to created list box or NULL upon error.
|
|
211 |
*/
|
|
212 |
static CEikTextListBox* NewListL(TInt aListType);
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Set a list observer to a list.
|
|
216 |
* @param aListType see TSwtLbType
|
|
217 |
* @param aList Pointer to the list
|
|
218 |
* @param aListObserver The list observer
|
|
219 |
* @return pointer to created list box or NULL upon error.
|
|
220 |
*/
|
|
221 |
static void SetListObserver(
|
|
222 |
TInt aListType,
|
|
223 |
CEikTextListBox* aList,
|
|
224 |
MSwtListObserver* aListObserver);
|
|
225 |
|
|
226 |
/**
|
|
227 |
* Check if a certain type of listbox is formatted.
|
|
228 |
* @param aListType see TSwtLbType
|
|
229 |
* @return ETrue if listbox is formatted.
|
|
230 |
*/
|
|
231 |
static TBool IsListFormatted(TInt aListType);
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Compute an array of cell types for a certain list box type
|
|
235 |
* @param aListType see TSwtLbType
|
|
236 |
* @return ETrue if listbox is formatted.
|
|
237 |
*/
|
|
238 |
static void CellsL(TInt aListType, RArray<TInt>& aCellArray);
|
|
239 |
|
|
240 |
/**
|
|
241 |
* Check if a int value is in the range of listbox types.
|
|
242 |
* @param aVal listbox type or int value.
|
|
243 |
* @return ETrue if value is listbox type.
|
|
244 |
*/
|
|
245 |
static TBool IsListType(TInt aVal);
|
|
246 |
|
|
247 |
/**
|
|
248 |
* Sets custom clipping rectangle of the list's item drawer
|
|
249 |
*/
|
|
250 |
static void SetItemDrawerClippingRect(
|
|
251 |
TInt aListType,
|
|
252 |
CEikTextListBox* aList,
|
|
253 |
const TRect& aRect);
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Sets listbox's margins
|
|
257 |
*/
|
|
258 |
static void SetMargins(
|
|
259 |
TInt aListType,
|
|
260 |
CEikTextListBox* aList,
|
|
261 |
TInt aHorizontal, TInt aVertical);
|
|
262 |
|
|
263 |
/**
|
|
264 |
* Change stretching
|
|
265 |
*/
|
|
266 |
static void EnableStretching(
|
|
267 |
TInt aListType,
|
|
268 |
CEikTextListBox* aList,
|
|
269 |
TBool aEnabled);
|
|
270 |
|
|
271 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
272 |
/**
|
|
273 |
* Enabling focus highlight for lists
|
|
274 |
*/
|
|
275 |
static void EnableFocusHighlight(
|
|
276 |
CListItemDrawer* aItemDrawer,
|
|
277 |
TBool aEnable);
|
|
278 |
#endif //RD_JAVA_S60_RELEASE_9_2
|
|
279 |
};
|
|
280 |
|
|
281 |
#endif // SWTLISTBOXLISTS_H
|