63
|
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: PhoneBook2 custom control. Code has been modified to
|
|
15 |
* suit PhoneBook2 requirements. See CColumnListBoxItemDrawer
|
|
16 |
* in EIKCLB.CPP
|
|
17 |
* Ensure that this piece of code is in sync with Avkon EIKCLB.CPP(CColumnListBoxItemDrawer)
|
|
18 |
*
|
|
19 |
*/
|
|
20 |
|
|
21 |
|
|
22 |
#include <barsread.h>
|
|
23 |
#include <gdi.h>
|
|
24 |
#include <gulicon.h>
|
|
25 |
#include <gulutil.h>
|
|
26 |
|
|
27 |
#include <eikenv.h>
|
|
28 |
#include <eiklbi.h>
|
|
29 |
#include <eiktxlbm.h>
|
|
30 |
#include <eikedwin.h>
|
|
31 |
#include <eiklbv.h>
|
|
32 |
#include <AknUtils.h>
|
|
33 |
#include <eiksfont.h>
|
|
34 |
#include <AknsDrawUtils.h>
|
|
35 |
#include <AknsControlContext.h>
|
|
36 |
#include <aknlists.h>
|
|
37 |
#include <eikpanic.h>
|
|
38 |
#include <eikcoctlpanic.h>
|
|
39 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
40 |
|
|
41 |
#ifdef RD_UI_TRANSITION_EFFECTS_LIST
|
|
42 |
#include <aknlistloadertfx.h>
|
|
43 |
#include <aknlistboxtfxinternal.h>
|
|
44 |
#endif //RD_UI_TRANSITION_EFFECTS_LIST
|
|
45 |
#include <AknTasHook.h>
|
|
46 |
|
|
47 |
//Start of Code Added for PhoneBook2
|
|
48 |
//Added for PhoneBook2
|
|
49 |
#include "cpbk2contactviewcustomlistboxdata.h"
|
|
50 |
#include "cpbk2contactviewcustomlistboxitemdrawer.h"
|
|
51 |
//End of Code Added for PhoneBook2
|
|
52 |
|
|
53 |
//Note:
|
|
54 |
//****
|
|
55 |
//PBK2_AVKON_TOUCH_MARKINGMODE_CHANGES
|
|
56 |
//Define this Flag once Pbk2 decides to implement the MarkingMode changes that has been implemented for Avkon Lists
|
|
57 |
|
|
58 |
//
|
|
59 |
// Class CPbk2ContactViewCustomListBoxItemDrawer
|
|
60 |
//
|
|
61 |
|
|
62 |
CPbk2ContactViewCustomListBoxItemDrawer::CPbk2ContactViewCustomListBoxItemDrawer() {}
|
|
63 |
CPbk2ContactViewCustomListBoxItemDrawer::CPbk2ContactViewCustomListBoxItemDrawer(MTextListBoxModel* aTextListBoxModel,
|
|
64 |
const CFont* aFont,
|
|
65 |
CPbk2ContactViewCustomListBoxData* aColumnData )
|
|
66 |
: CTextListItemDrawer(aTextListBoxModel, aFont)
|
|
67 |
{
|
|
68 |
SetData(aColumnData);
|
|
69 |
}
|
|
70 |
|
|
71 |
CPbk2ContactViewCustomListBoxItemDrawer::~CPbk2ContactViewCustomListBoxItemDrawer()
|
|
72 |
{
|
|
73 |
delete iPropertyArray;
|
|
74 |
}
|
|
75 |
|
|
76 |
TSize CPbk2ContactViewCustomListBoxItemDrawer::MinimumCellSize() const
|
|
77 |
{
|
|
78 |
CPbk2ContactViewCustomListBoxData* data=ColumnData();
|
|
79 |
const TInt columns=data->LastColumn();
|
|
80 |
if (columns==-1)
|
|
81 |
{
|
|
82 |
return CTextListItemDrawer::MinimumCellSize();
|
|
83 |
}
|
|
84 |
TInt width=0;
|
|
85 |
TInt height=0;
|
|
86 |
TBool graphicsColumn=EFalse;
|
|
87 |
for (TInt ii=0;ii<=columns;ii++)
|
|
88 |
{
|
|
89 |
width+=data->ColumnWidthPixel(ii);
|
|
90 |
if (data->ColumnIsGraphics(ii))
|
|
91 |
{
|
|
92 |
graphicsColumn=ETrue;
|
|
93 |
}
|
|
94 |
else
|
|
95 |
{
|
|
96 |
const CFont* font=data->ColumnFont(ii);
|
|
97 |
if(font)
|
|
98 |
{
|
|
99 |
height=Max(height,font->HeightInPixels());
|
|
100 |
}
|
|
101 |
else
|
|
102 |
{
|
|
103 |
height=Max(height, iFont->HeightInPixels());
|
|
104 |
}
|
|
105 |
}
|
|
106 |
}
|
|
107 |
if (graphicsColumn)
|
|
108 |
{
|
|
109 |
CArrayPtr<CGulIcon>* iconArray=data->IconArray();
|
|
110 |
if (iconArray)
|
|
111 |
{
|
|
112 |
const TInt count=iconArray->Count();
|
|
113 |
for (TInt jj=0;jj<count;jj++)
|
|
114 |
height=Max(height,(*iconArray)[jj]->Bitmap()->SizeInPixels().iHeight);
|
|
115 |
}
|
|
116 |
}
|
|
117 |
height = Max (iData->FontBoundValues().iHeightInPixels, height);
|
|
118 |
height+=VerticalInterItemGap();
|
|
119 |
return TSize(width,height);
|
|
120 |
}
|
|
121 |
|
|
122 |
TInt CPbk2ContactViewCustomListBoxItemDrawer::ItemWidthInPixels(TInt /*aItemIndex*/) const
|
|
123 |
{
|
|
124 |
CPbk2ContactViewCustomListBoxData* data=ColumnData();
|
|
125 |
const TInt columns=data->LastColumn();
|
|
126 |
TInt itemWidth = 0;
|
|
127 |
if (iDrawMark)
|
|
128 |
{
|
|
129 |
itemWidth += (iMarkColumnWidth + iMarkGutter);
|
|
130 |
}
|
|
131 |
for (TInt ii=0;ii<=columns;ii++)
|
|
132 |
{
|
|
133 |
if (!ColumnData()->ColumnIsOptional(ii))
|
|
134 |
{
|
|
135 |
itemWidth+=data->ColumnWidthPixel(ii);
|
|
136 |
}
|
|
137 |
}
|
|
138 |
return itemWidth;
|
|
139 |
}
|
|
140 |
|
|
141 |
void CPbk2ContactViewCustomListBoxItemDrawer::SetItemCellSize(
|
|
142 |
const TSize& aSizeInPixels)
|
|
143 |
{
|
|
144 |
CTextListItemDrawer::SetItemCellSize( aSizeInPixels );
|
|
145 |
|
|
146 |
// Data needs the cell size to create/reconfigure highlight animations
|
|
147 |
CPbk2ContactViewCustomListBoxData* data = ColumnData();
|
|
148 |
data->SetItemCellSize( iItemCellSize );
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Returns a pointer to the column data. Does not imply transfer of ownership.
|
|
154 |
*
|
|
155 |
* @since ER5U
|
|
156 |
*/
|
|
157 |
CPbk2ContactViewCustomListBoxData* CPbk2ContactViewCustomListBoxItemDrawer::ColumnData() const
|
|
158 |
{
|
|
159 |
return STATIC_CAST(CPbk2ContactViewCustomListBoxData*,iData);
|
|
160 |
}
|
|
161 |
|
|
162 |
void CPbk2ContactViewCustomListBoxItemDrawer::DrawItemMark(TBool /*aItemIsSelected*/, TBool /*aViewIsDimmed*/, const TPoint& /*aMarkPos*/) const
|
|
163 |
{
|
|
164 |
// not used in S60
|
|
165 |
}
|
|
166 |
|
|
167 |
void CPbk2ContactViewCustomListBoxItemDrawer::DrawItemText( TInt aItemIndex,
|
|
168 |
const TRect& aItemTextRect,
|
|
169 |
TBool aItemIsCurrent,
|
|
170 |
TBool /*aViewIsEmphasized*/,
|
|
171 |
TBool aItemIsSelected ) const
|
|
172 |
//
|
|
173 |
// Draw the items text
|
|
174 |
//
|
|
175 |
{
|
|
176 |
#ifdef RD_UI_TRANSITION_EFFECTS_LIST
|
|
177 |
MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
|
|
178 |
if ( transApi )
|
|
179 |
{
|
|
180 |
transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified );
|
|
181 |
}
|
|
182 |
#endif // RD_UI_TRANSITION_EFFECTS_LIST
|
|
183 |
iGc->SetPenColor(iTextColor);
|
|
184 |
iGc->SetBrushColor(iBackColor);
|
|
185 |
TPtrC temp=iModel->ItemText(aItemIndex);
|
|
186 |
SetupGc(aItemIndex);
|
|
187 |
#ifdef RD_UI_TRANSITION_EFFECTS_LIST
|
|
188 |
if ( transApi )
|
|
189 |
{
|
|
190 |
transApi->StopDrawing();
|
|
191 |
}
|
|
192 |
#endif // RD_UI_TRANSITION_EFFECTS_LIST
|
|
193 |
|
|
194 |
TBufC<256> target(KNullDesC);
|
|
195 |
// SERIES60 ITEM MARKS! SAPLAF (the same code is in eikfrlb.cpp and eikclb.cpp)
|
|
196 |
TPtrC repl;
|
|
197 |
TInt pos = -1;
|
|
198 |
|
|
199 |
TBool removeicon = (!aItemIsSelected && !ItemMarkReverse()) || (aItemIsSelected && ItemMarkReverse());
|
|
200 |
|
|
201 |
if ( Flags() & CListItemDrawer::EMarkingModeEnabled )
|
|
202 |
{
|
|
203 |
removeicon = EFalse;
|
|
204 |
}
|
|
205 |
if ( Flags() & EDrawMarkSelection && ItemMarkPosition() != -1 && removeicon)
|
|
206 |
{
|
|
207 |
repl.Set( ItemMarkReplacement() );
|
|
208 |
pos = ItemMarkPosition();
|
|
209 |
}
|
|
210 |
|
|
211 |
// Try to allocate buffer dynamically. If out of memory, use the fixed size stack buffer.
|
|
212 |
// (+1 is for the last column separator)
|
|
213 |
TInt size = temp.Length() + repl.Length() + 1;
|
|
214 |
if ( pos >= 0 )
|
|
215 |
{
|
|
216 |
size += pos; // space for other column separators
|
|
217 |
}
|
|
218 |
|
|
219 |
HBufC* buffer = NULL;
|
|
220 |
if ( size > 256 )
|
|
221 |
{
|
|
222 |
buffer = HBufC::New( size );
|
|
223 |
}
|
|
224 |
|
|
225 |
TPtr des = ( buffer ? buffer->Des() : target.Des() );
|
|
226 |
// Note that ReplaceColumn does not update correct length in variable 'des',
|
|
227 |
// because it is not a reference parameter :(
|
|
228 |
AknLAFUtils::ReplaceColumn(des, &temp, &repl, '\t', pos);
|
|
229 |
des.Set( buffer ? buffer->Des() : target.Des() );
|
|
230 |
|
|
231 |
// END OF ITEM MARKS! SAPLAF
|
|
232 |
|
|
233 |
CPbk2ContactViewCustomListBoxData::TColors colors;
|
|
234 |
colors.iText=iTextColor;
|
|
235 |
colors.iBack=iBackColor;
|
|
236 |
colors.iHighlightedText=iHighlightedTextColor;
|
|
237 |
colors.iHighlightedBack=iHighlightedBackColor;
|
|
238 |
|
|
239 |
if (ColumnData()->CurrentMarqueeItemIndex() != aItemIndex && aItemIsCurrent)
|
|
240 |
{
|
|
241 |
ColumnData()->ResetMarquee();
|
|
242 |
ColumnData()->SetCurrentMarqueeItemIndex(aItemIndex);
|
|
243 |
}
|
|
244 |
ColumnData()->SetCurrentItemIndex(aItemIndex);
|
|
245 |
ColumnData()->Draw(Properties(aItemIndex), *iGc,&des,aItemTextRect,(aItemIsCurrent /*|| aViewIsEmphasized*/),colors, aItemIndex);
|
|
246 |
|
|
247 |
#ifdef RD_UI_TRANSITION_EFFECTS_LIST
|
|
248 |
if ( transApi )
|
|
249 |
{
|
|
250 |
transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified );
|
|
251 |
}
|
|
252 |
#endif // RD_UI_TRANSITION_EFFECTS_LIST
|
|
253 |
iGc->DiscardFont();
|
|
254 |
#ifdef RD_UI_TRANSITION_EFFECTS_LIST
|
|
255 |
if ( transApi )
|
|
256 |
{
|
|
257 |
transApi->StopDrawing();
|
|
258 |
}
|
|
259 |
#endif // RD_UI_TRANSITION_EFFECTS_LIST
|
|
260 |
// end of SERIES60 LAF code.
|
|
261 |
|
|
262 |
delete buffer;
|
|
263 |
}
|
|
264 |
|
|
265 |
TAny* CPbk2ContactViewCustomListBoxItemDrawer::Reserved_1()
|
|
266 |
{
|
|
267 |
return NULL;
|
|
268 |
}
|
|
269 |
|
|
270 |
|
|
271 |
void CPbk2ContactViewCustomListBoxItemDrawer::ClearAllPropertiesL()
|
|
272 |
{
|
|
273 |
delete iPropertyArray;
|
|
274 |
iPropertyArray = NULL;
|
|
275 |
iPropertyArray = new (ELeave) CArrayFixFlat<SListProperties>(2);
|
|
276 |
}
|
|
277 |
|
|
278 |
void CPbk2ContactViewCustomListBoxItemDrawer::SetPropertiesL(TInt aItemIndex, TListItemProperties aProperty)
|
|
279 |
{
|
|
280 |
if (!iPropertyArray) ClearAllPropertiesL();
|
|
281 |
TInt index;
|
|
282 |
TKeyArrayFix key(0,ECmpTInt);
|
|
283 |
SListProperties prop;
|
|
284 |
prop.iItem = aItemIndex;
|
|
285 |
|
|
286 |
if (iPropertyArray->FindIsq(prop, key, index))
|
|
287 |
{
|
|
288 |
iPropertyArray->InsertIsqL(prop, key);
|
|
289 |
iPropertyArray->FindIsq(prop, key, index);
|
|
290 |
}
|
|
291 |
iPropertyArray->At(index).iProperties = aProperty;
|
|
292 |
}
|
|
293 |
|
|
294 |
|
|
295 |
TListItemProperties CPbk2ContactViewCustomListBoxItemDrawer::Properties(TInt aItemIndex) const
|
|
296 |
{
|
|
297 |
if ( !iPropertyArray )
|
|
298 |
{
|
|
299 |
TListItemProperties prop(
|
|
300 |
CTextListItemDrawer::Properties( aItemIndex ) );
|
|
301 |
// Do not allow marking other than contact items
|
|
302 |
if ( !ColumnData()->IsContactAtListboxIndex( aItemIndex ) )
|
|
303 |
{
|
|
304 |
prop.SetHiddenSelection( ETrue );
|
|
305 |
}
|
|
306 |
return prop;
|
|
307 |
}
|
|
308 |
|
|
309 |
CAknListBoxFilterItems *filter = STATIC_CAST(CAknFilteredTextListBoxModel*,iModel)->Filter();
|
|
310 |
if (filter)
|
|
311 |
{
|
|
312 |
aItemIndex = filter->FilteredItemIndex(aItemIndex);
|
|
313 |
}
|
|
314 |
TKeyArrayFix key(0,ECmpTInt);
|
|
315 |
SListProperties prop;
|
|
316 |
prop.iItem = aItemIndex;
|
|
317 |
TInt index;
|
|
318 |
if (iPropertyArray->FindIsq(prop, key, index)) return CTextListItemDrawer::Properties(aItemIndex);
|
|
319 |
return iPropertyArray->At(index).iProperties;
|
|
320 |
}
|
|
321 |
|
|
322 |
void CPbk2ContactViewCustomListBoxItemDrawer::CPbk2ContactViewCustomListBoxItemDrawer_Reserved()
|
|
323 |
{
|
|
324 |
}
|
|
325 |
|
|
326 |
// End of File
|