|
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 CColumnListBoxData |
|
16 * in EIKCLBD.CPP. |
|
17 * Ensure that this piece of code is in sync with Avkon EIKCLBD.CPP(CColumnListBoxData) |
|
18 * |
|
19 */ |
|
20 |
|
21 #include <eikclbd.h> |
|
22 #include <aknlists.h> |
|
23 #include <AknsEffectAnim.h> |
|
24 #include <AknPictographInterface.h> |
|
25 #include <AknPictographDrawerInterface.h> |
|
26 #include <centralrepository.h> |
|
27 #include <AvkonInternalCRKeys.h> |
|
28 #include <AknsListBoxBackgroundControlContext.h> |
|
29 #include <AknMarqueeControl.h> |
|
30 #include <eikpanic.h> |
|
31 #include <eikcoctlpanic.h> |
|
32 #include <gulicon.h> |
|
33 #include <AknBidiTextUtils.h> |
|
34 #include <skinlayout.cdl.h> |
|
35 #include <layoutmetadata.cdl.h> |
|
36 #include <aknlayoutscalable_avkon.cdl.h> |
|
37 #include <aknphysics.h> |
|
38 #include <AknIconArray.h> |
|
39 #include <avkon.mbg> |
|
40 |
|
41 |
|
42 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
43 #include <aknlistloadertfx.h> |
|
44 #include <aknlistboxtfxinternal.h> |
|
45 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
46 |
|
47 #include <touchfeedback.h> |
|
48 |
|
49 //Start of Code Added for PhoneBook2 |
|
50 #include "cpbk2contactviewcustomlistboxdata.h" |
|
51 #include "CPbk2ContactViewListBoxModel.h" |
|
52 #include <MPbk2UiControlCmdItem.h> |
|
53 #include <AknFepInternalCRKeys.h> |
|
54 #include <AknLayoutFont.h> |
|
55 #include "CPbk2ContactViewListBox.h" |
|
56 |
|
57 //from PCS engine |
|
58 #include <CPcsDefs.h> |
|
59 #include <CPsRequestHandler.h> |
|
60 #include <CPsQuery.h> |
|
61 #include "CPbk2PredictiveSearchFilter.h" |
|
62 //End of Code Added for PhoneBook2 |
|
63 |
|
64 const TInt KColumnListBoxGranularity=4; |
|
65 const TInt KNoActualColumnFont=-1; |
|
66 const TInt KMaxColumn = 6; |
|
67 |
|
68 // colored tick marks support |
|
69 const TInt KColorIconFlag = -1; |
|
70 const TInt KColorIconIdx = 0; |
|
71 |
|
72 //Start of Code Added for PhoneBook2 |
|
73 /// Unnamed namespace for local definitions |
|
74 namespace { |
|
75 |
|
76 #ifdef _DEBUG |
|
77 enum TPanicCode |
|
78 { |
|
79 EPanicPreCond_OutOfRangeListBoxData = 1, |
|
80 EPanicColumnListInvalidBitmapIndexListBoxData, |
|
81 EPanicNullPointerListBoxData, |
|
82 EPanicColumnListLayoutErrorListBoxData |
|
83 }; |
|
84 #endif // _DEBUG |
|
85 |
|
86 #ifdef _DEBUG |
|
87 void Panic(TPanicCode aReason) |
|
88 { |
|
89 _LIT(KPanicText, "CPbk2ContactViewCustomListBoxData"); |
|
90 User::Panic(KPanicText, aReason); |
|
91 } |
|
92 #endif // _DEBUG |
|
93 } |
|
94 |
|
95 |
|
96 TInt CompareByStartIndex( const TPsMatchLocation& aFirst, const TPsMatchLocation& aSecond ) |
|
97 { |
|
98 return aFirst.index - aSecond.index; |
|
99 } |
|
100 //End of Code Added for PhoneBook2 |
|
101 |
|
102 |
|
103 //Note: |
|
104 //**** |
|
105 //PBK2_AVKON_TOUCH_MARKINGMODE_CHANGES |
|
106 //Define this Flag once Pbk2 decides to implement the MarkingMode changes that has been implemented for Avkon Lists |
|
107 |
|
108 /** |
|
109 * About animation usage: |
|
110 * All animation usage is implemented in this class. Animation is eye candy and |
|
111 * low priority when it comes to resources -> on resource failures animation |
|
112 * fails fast to release resources for more critical functionality. Also, no |
|
113 * attempt to (re)construct failed animation is made. |
|
114 * |
|
115 * User inactivity is not being observed. Only one animation is used. Extension |
|
116 * is CActive to make it possible to postpone animation deletion on animation |
|
117 * failure. |
|
118 */ |
|
119 NONSHARABLE_CLASS(CPbk2ContactViewCustomListBoxDataExtension) : |
|
120 public CActive, |
|
121 public MAknPictographAnimatorCallBack, |
|
122 public MCoeForegroundObserver, |
|
123 public MAknsEffectAnimObserver, |
|
124 public MListBoxItemChangeObserver |
|
125 { |
|
126 public: |
|
127 enum TFlag |
|
128 { |
|
129 // Set if current item background should be copied to animation as |
|
130 // input layer. |
|
131 EFlagUpdateBg = 0, |
|
132 |
|
133 // Set if animation has been resized at least once |
|
134 EFlagHasLayers = 1, |
|
135 |
|
136 // Set if foreground has been gained. |
|
137 EFlagHasForeground = 2 |
|
138 }; |
|
139 enum TSubCellType |
|
140 { |
|
141 EEikSLGraphic, |
|
142 EEikSLText, |
|
143 EEikSLNumeric |
|
144 }; |
|
145 |
|
146 public: |
|
147 CPbk2ContactViewCustomListBoxDataExtension(); |
|
148 void ConstructL( CPbk2ContactViewCustomListBoxData* aListBoxData, |
|
149 const TAknsItemID& aAnimationIID ); |
|
150 ~CPbk2ContactViewCustomListBoxDataExtension(); |
|
151 static TInt RedrawEvent(TAny* aControl); |
|
152 TBool IsMarqueeOn(); |
|
153 struct SRowAndColumn |
|
154 { |
|
155 TInt iIndex; // 24 bits for row and 8 bits for column |
|
156 const CFont* iFont; |
|
157 }; |
|
158 SRowAndColumn& At(TInt aArrayIndex); |
|
159 const SRowAndColumn& At(TInt aArrayIndex) const; |
|
160 void AddRowAndColumnL(TInt aRow,TInt aColumn); |
|
161 TInt FindRowAndColumnIndex(TInt& aArrayIndex,TInt aRow,TInt aColumn) const; |
|
162 void FindRowAndColumnIndexOrAddL(TInt& aArrayIndex,TInt aRow,TInt aColumn); |
|
163 |
|
164 inline void NoAnimIfError( TInt aError ); |
|
165 void TryCreateAnimation(); |
|
166 TBool SyncAnim( const TSize& aSize ); |
|
167 TBool SyncAndDrawAnim( CBitmapContext& aGc, const TRect& aRect ); |
|
168 MAknsControlContext* SkinBackgroundContext() const; |
|
169 void DeleteAnim(); |
|
170 void FocusGained(); |
|
171 void FocusLost(); |
|
172 void SkinChangedL(); |
|
173 void SkinChanged(); |
|
174 void SetControl( CCoeControl* aControl ); |
|
175 |
|
176 // Implementation of MCoeForegroundObserver |
|
177 void HandleGainingForeground(); |
|
178 void HandleLosingForeground(); |
|
179 |
|
180 // Implementation of MAknsEffectAnimObserver |
|
181 void AnimFrameReady( TInt aError, TInt ); |
|
182 |
|
183 // Implementation of MListBoxItemChangeObserver |
|
184 void ListBoxItemsChanged(CEikListBox* aListBox); |
|
185 |
|
186 // Overloads CActive::DoCancel |
|
187 void DoCancel(); |
|
188 // Overloads CActive::RunL |
|
189 void RunL(); |
|
190 |
|
191 void Play(); |
|
192 void CreateColorBitmapsL(); |
|
193 |
|
194 TBool DrawPressedDownEffect( MAknsSkinInstance* aInstance, |
|
195 CWindowGc& aGc, |
|
196 const TRect& aOutRect, |
|
197 const TRect& aInnerRect ) const; |
|
198 |
|
199 void LoadMarkingIconsL(); |
|
200 |
|
201 public: //for handling column alignment |
|
202 struct TColumnExt |
|
203 { |
|
204 TInt iColumn; // Must be first entry |
|
205 TBool iLayoutAlign;//is layout alignment or Set by client |
|
206 }; |
|
207 TInt AddColumnExtL(TInt aColumn); |
|
208 void FindColumnExtIndexOrAddL(TInt& aArrayIndex,TInt aColumn); |
|
209 void SetColumnLayoutAlignmentL(TInt aColumn); |
|
210 |
|
211 |
|
212 TBool FindColumnExtIndex(TInt& aArrayIndex,TInt aColumn) const; |
|
213 TBool ColumnLayoutAlignment(TInt aColumn) const; |
|
214 |
|
215 public: // new list layout system |
|
216 struct SRowAndSubCell |
|
217 { |
|
218 TInt iIndex; // 24 bits for row and 8 bits for subcell |
|
219 const CFont* iFont; |
|
220 }; |
|
221 struct SSLSubCell |
|
222 { |
|
223 TInt iSubCell; // Must be first entry |
|
224 TAknTextLineLayout iTextLayout; |
|
225 TAknWindowLineLayout iGraphicLayout; |
|
226 TInt iSubCellType; |
|
227 TInt iConditionValue; // used with conditional layouts for not always drawn subcells |
|
228 }; |
|
229 |
|
230 SSLSubCell& AtSL(TInt aArrayIndex); |
|
231 const SSLSubCell& AtSL(TInt aArrayIndex) const; |
|
232 void AddSLSubCellL(TInt aSubCell); |
|
233 TInt FindSLSubCellIndex(TInt& aArrayIndex, TInt aSubCell) const; |
|
234 void FindSLSubCellIndexOrAddL(TInt& aArrayIndex, TInt aSubCell); |
|
235 void ResetSLSubCellArray(); |
|
236 |
|
237 |
|
238 private: // New internal methods |
|
239 TBool DrawHighlightBackground( CFbsBitGc& aGc ); |
|
240 void PostDeleteAnimation(); |
|
241 void CreateAnimationL(); |
|
242 void DoResizeL( const TSize& aHighlightSize, TBool aAboutToStart ); |
|
243 |
|
244 private: // from MAknPictographAnimatorCallback |
|
245 void DrawPictographArea(); |
|
246 |
|
247 public: |
|
248 CArrayPtr<CGulIcon>* iIconArray; |
|
249 CCoeControl *iControl; // not owned |
|
250 CAknsListBoxBackgroundControlContext* iSkinControlContext; |
|
251 const TAknsItemID *iSkinHighlightFrameId; |
|
252 const TAknsItemID *iSkinHighlightFrameCenterId; |
|
253 TBool iSkinEnabled; |
|
254 CAknPictographInterface* iPictoInterface; |
|
255 CAknMarqueeControl* iMarquee; |
|
256 CAknMarqueeControl* i2ndLineMarquee; |
|
257 TInt iCurrentItem; // Marquee: |
|
258 TInt iCurrentRow; // Current list row being drawn. |
|
259 CArrayFix<SRowAndColumn>* iRowAndColumnArray; |
|
260 TSize iSubCellIconSize[6]; // Store icon sizes for each column |
|
261 TAknSeparatorLinePosition iSeparatorLinePosition; |
|
262 CAknsEffectAnim* iAnimation; |
|
263 /** |
|
264 * Stored flags are explained in enumeration TFlags. |
|
265 */ |
|
266 TBitFlags32 iAnimFlags; |
|
267 CPbk2ContactViewCustomListBoxData* iListBoxData; |
|
268 TRgb iHighlightedTextColor; |
|
269 TRgb iTextColor; |
|
270 |
|
271 TAknsItemID iAnimIID; |
|
272 MColumnListBoxAnimBackgroundDrawer* iHighlightBgDrawer; |
|
273 TSize iAnimSize; // TODO Deprecating old style anim API and removing this |
|
274 TBool iUnderlineFlagSet; // underlining support for more than |
|
275 TBitFlags32 iUnderlineFlags; // one text subcell |
|
276 TBool iUseLayoutData; |
|
277 TBool iStretchingEnabled; |
|
278 CArrayFix<SRowAndSubCell>* iRowAndSubCellArray; |
|
279 CArrayFix<SSLSubCell>* iSLSubCellArray; |
|
280 TBool iSubCellsMightIntersect; |
|
281 TRect iParent; // parent for size calculations |
|
282 |
|
283 // colorskin highlight icons |
|
284 CFbsBitmap* iColorBmp; |
|
285 CFbsBitmap* iHiliBmp; |
|
286 TRgb iIconColor; |
|
287 TRgb iHiliIconColor; |
|
288 TInt iConditionalCells; |
|
289 |
|
290 // which columns of highlighted item have clipped text ? |
|
291 TUint32 iClippedColumns; |
|
292 |
|
293 TBool iKineticScrolling; |
|
294 |
|
295 |
|
296 |
|
297 CArrayFix<TColumnExt>* iColumnExtArray; //for column alignment |
|
298 TRect iMarginRect; |
|
299 |
|
300 CAknIconArray* iMarkingIconArray; |
|
301 }; |
|
302 |
|
303 /** |
|
304 * High priority is well argumented because running the active object will |
|
305 * result in animation deletion -> results in freeing resources. |
|
306 */ |
|
307 CPbk2ContactViewCustomListBoxDataExtension::CPbk2ContactViewCustomListBoxDataExtension(): |
|
308 CActive( EPriorityHigh ) |
|
309 {} |
|
310 |
|
311 void CPbk2ContactViewCustomListBoxDataExtension::ConstructL( |
|
312 CPbk2ContactViewCustomListBoxData* aListBoxData, |
|
313 const TAknsItemID& aAnimationIID ) |
|
314 { |
|
315 ASSERT( aListBoxData ); |
|
316 iListBoxData = aListBoxData; |
|
317 iRowAndColumnArray=new(ELeave) CArrayFixFlat<SRowAndColumn>(4); |
|
318 |
|
319 iSeparatorLinePosition = ENoLine; |
|
320 |
|
321 iAnimIID = aAnimationIID; |
|
322 CActiveScheduler::Add( this ); |
|
323 TryCreateAnimation(); // Animations are created by default |
|
324 |
|
325 // try to set ESS text colors here so that they will be set at least somewhere... |
|
326 iTextColor = NULL; // just in case |
|
327 iHighlightedTextColor = NULL; // just in case |
|
328 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
329 TRgb color; |
|
330 |
|
331 // set ESS text color |
|
332 TInt error = AknsUtils::GetCachedColor( skin, |
|
333 color, |
|
334 KAknsIIDQsnTextColors, |
|
335 EAknsCIQsnTextColorsCG6 ); |
|
336 if ( !error ) |
|
337 { |
|
338 iTextColor = color; |
|
339 } |
|
340 |
|
341 // set ESS highlighted text color |
|
342 error = AknsUtils::GetCachedColor( skin, |
|
343 color, |
|
344 KAknsIIDQsnTextColors, |
|
345 EAknsCIQsnTextColorsCG10 ); |
|
346 if ( !error ) |
|
347 { |
|
348 iHighlightedTextColor = color; |
|
349 } |
|
350 |
|
351 iRowAndSubCellArray=new(ELeave) CArrayFixFlat<SRowAndSubCell>(4); |
|
352 |
|
353 iSLSubCellArray=new(ELeave) CArrayFixFlat<SSLSubCell>(4); |
|
354 |
|
355 iColumnExtArray = new(ELeave) CArrayFixFlat<TColumnExt>(KColumnListBoxGranularity); |
|
356 |
|
357 #ifdef RD_LIST_STRETCH |
|
358 // check list stretching from cenrep |
|
359 CRepository* cenRep = CRepository::NewL( KCRUidAvkon ); |
|
360 cenRep->Get( KAknAutomaticListStretching, iStretchingEnabled ); |
|
361 delete cenRep; |
|
362 #endif // RD_LIST_STRETCH |
|
363 |
|
364 |
|
365 iKineticScrolling = CAknPhysics::FeatureEnabled(); |
|
366 |
|
367 LoadMarkingIconsL(); |
|
368 |
|
369 } |
|
370 |
|
371 CPbk2ContactViewCustomListBoxDataExtension::~CPbk2ContactViewCustomListBoxDataExtension() |
|
372 { |
|
373 |
|
374 Cancel(); |
|
375 |
|
376 // Stop receiving foreground events |
|
377 CCoeEnv* env = CCoeEnv::Static(); |
|
378 env->RemoveForegroundObserver( *this ); |
|
379 |
|
380 delete iRowAndColumnArray; |
|
381 iRowAndColumnArray = NULL; |
|
382 delete iSkinControlContext; |
|
383 delete iPictoInterface; |
|
384 delete iMarquee; |
|
385 delete i2ndLineMarquee; |
|
386 delete iAnimation; |
|
387 delete iRowAndSubCellArray; |
|
388 delete iSLSubCellArray; |
|
389 delete iColorBmp; |
|
390 delete iHiliBmp; |
|
391 delete iColumnExtArray; |
|
392 if ( iMarkingIconArray ) |
|
393 { |
|
394 iMarkingIconArray->ResetAndDestroy(); |
|
395 } |
|
396 |
|
397 delete iMarkingIconArray; |
|
398 } |
|
399 |
|
400 MAknsControlContext* CPbk2ContactViewCustomListBoxDataExtension::SkinBackgroundContext() const |
|
401 { |
|
402 if ( iSkinEnabled ) |
|
403 { |
|
404 return iSkinControlContext; |
|
405 } |
|
406 |
|
407 return NULL; |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // CPbk2ContactViewCustomListBoxDataExtension::NoAnimIfError |
|
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 inline void CPbk2ContactViewCustomListBoxDataExtension::NoAnimIfError( TInt aError ) |
|
415 { |
|
416 if( KErrNone != aError ) |
|
417 { |
|
418 DeleteAnim(); |
|
419 } |
|
420 } |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CPbk2ContactViewCustomListBoxDataExtension::TryCreateAnimation |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 void CPbk2ContactViewCustomListBoxDataExtension::TryCreateAnimation() |
|
427 { |
|
428 if( !iControl ) |
|
429 { |
|
430 return; |
|
431 } |
|
432 |
|
433 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
434 CEikListBox* list = static_cast<CEikListBox*>( iControl ); |
|
435 CListBoxView* view = list->View(); |
|
436 if ( !view || !view->ItemDrawer() ) |
|
437 { |
|
438 return; |
|
439 } |
|
440 CWindowGc* gc = view->ItemDrawer()->Gc(); |
|
441 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( gc ); |
|
442 if ( transApi && transApi->VerifyKml() == KErrNone ) |
|
443 { |
|
444 return; |
|
445 } |
|
446 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
447 |
|
448 // Ideally we should not create animation if the list has zero items. |
|
449 // Unfortunately, this will cause problems elsewhere as setting item text |
|
450 // array to list requires not calling HandleItemAddition (or similar |
|
451 // method) -> in some situations animation would not be created at all as |
|
452 // we don't receive item change event. Fortunately, creating animation to |
|
453 // empty list doesn't carry much overhead as layer creation is delayed to |
|
454 // first render. |
|
455 |
|
456 if( !iAnimation ) |
|
457 { |
|
458 // This must be the first call because animation does not exist. |
|
459 // Animation layers are created when the animation is rendered for the |
|
460 // first time. |
|
461 TRAPD( err, CreateAnimationL() ); |
|
462 NoAnimIfError( err ); |
|
463 } |
|
464 } |
|
465 |
|
466 // ----------------------------------------------------------------------------- |
|
467 // CPbk2ContactViewCustomListBoxDataExtension::SyncAnim |
|
468 // ----------------------------------------------------------------------------- |
|
469 // |
|
470 TBool CPbk2ContactViewCustomListBoxDataExtension::SyncAnim( const TSize& aSize ) |
|
471 { |
|
472 if( !iAnimation || aSize.iWidth <= 0 || aSize.iHeight <= 0 ) |
|
473 { |
|
474 return EFalse; |
|
475 } |
|
476 |
|
477 if( iAnimation->Size() != aSize || iAnimation->NeedsInputLayer() ) |
|
478 { |
|
479 // Resizing will update animation background |
|
480 iAnimFlags.Clear( EFlagUpdateBg ); |
|
481 |
|
482 // Animation exists but its size is out of sync or input layers have |
|
483 // been released |
|
484 TRAPD( err, DoResizeL( aSize, iAnimFlags.IsSet( EFlagHasForeground ) ) ); |
|
485 |
|
486 if( err ) |
|
487 { |
|
488 DeleteAnim(); |
|
489 return EFalse; |
|
490 } |
|
491 iAnimFlags.Set( EFlagHasLayers ); |
|
492 } |
|
493 |
|
494 // Highlight animation background needs update (current item has changed) |
|
495 if( iAnimFlags.IsSet( EFlagUpdateBg ) ) |
|
496 { |
|
497 iAnimFlags.Clear( EFlagUpdateBg ); |
|
498 |
|
499 if( iAnimation->InputRgbGc() ) |
|
500 { |
|
501 DrawHighlightBackground( *iAnimation->InputRgbGc() ); |
|
502 // We need to update the output frame (otherwise the highlight |
|
503 // would drawn with the old output before the next new animation |
|
504 // frame). |
|
505 NoAnimIfError( iAnimation->UpdateOutput() ); |
|
506 if( !iAnimation ) |
|
507 { |
|
508 return EFalse; |
|
509 } |
|
510 } |
|
511 } |
|
512 |
|
513 return ETrue; |
|
514 } |
|
515 |
|
516 // ----------------------------------------------------------------------------- |
|
517 // CPbk2ContactViewCustomListBoxDataExtension::SyncAndDrawAnim |
|
518 // ----------------------------------------------------------------------------- |
|
519 // |
|
520 TBool CPbk2ContactViewCustomListBoxDataExtension::SyncAndDrawAnim( |
|
521 CBitmapContext& aGc, const TRect& aRect ) |
|
522 { |
|
523 if( iAnimation ) |
|
524 { |
|
525 // When application loses foreground or has not yet gained foreground |
|
526 // animation is in stopped state and input layers are not present. It |
|
527 // is possible that list is repainted in this situation. Calling |
|
528 // SyncAnim will create the non-present layers -> WSERV flush -> |
|
529 // flicker. To prevent flickering we just render the existing frame. |
|
530 // This can lead to incorrect draw if the current item index is changed |
|
531 // when the app has no foreground (very unlikely). If EFlagHasLayers is |
|
532 // not set we need to do SyncAnim because it is the first call to draw |
|
533 // (and flicker is not an issue). |
|
534 if( EAknsAnimStateStopped == iAnimation->State() && |
|
535 !iAnimFlags.IsSet( EFlagHasForeground ) && |
|
536 iAnimFlags.IsSet( EFlagHasLayers ) && |
|
537 !iAnimFlags.IsSet( EFlagUpdateBg ) ) |
|
538 { |
|
539 return iAnimation->Render( aGc, aRect ); |
|
540 } |
|
541 } |
|
542 |
|
543 if( SyncAnim( aRect.Size() ) ) |
|
544 { |
|
545 return iAnimation->Render( aGc, aRect ); |
|
546 } |
|
547 |
|
548 return EFalse; |
|
549 } |
|
550 |
|
551 // ----------------------------------------------------------------------------- |
|
552 // CPbk2ContactViewCustomListBoxDataExtension::DeleteAnim |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 void CPbk2ContactViewCustomListBoxDataExtension::DeleteAnim() |
|
556 { |
|
557 // Stop receiving foreground events |
|
558 CCoeEnv* env = CCoeEnv::Static(); |
|
559 env->RemoveForegroundObserver( *this ); |
|
560 |
|
561 delete iAnimation; |
|
562 iAnimation = NULL; |
|
563 } |
|
564 |
|
565 // ----------------------------------------------------------------------------- |
|
566 // CPbk2ContactViewCustomListBoxDataExtension::FocusGained |
|
567 // ----------------------------------------------------------------------------- |
|
568 // |
|
569 void CPbk2ContactViewCustomListBoxDataExtension::FocusGained() |
|
570 { |
|
571 Play(); |
|
572 } |
|
573 |
|
574 // ----------------------------------------------------------------------------- |
|
575 // CPbk2ContactViewCustomListBoxDataExtension::FocusLost |
|
576 // ----------------------------------------------------------------------------- |
|
577 // |
|
578 void CPbk2ContactViewCustomListBoxDataExtension::FocusLost() |
|
579 { |
|
580 if( iAnimation ) |
|
581 { |
|
582 NoAnimIfError( iAnimation->Pause() ); |
|
583 } |
|
584 } |
|
585 |
|
586 // ----------------------------------------------------------------------------- |
|
587 // CPbk2ContactViewCustomListBoxDataExtension::SkinChangedL |
|
588 // ----------------------------------------------------------------------------- |
|
589 // |
|
590 void CPbk2ContactViewCustomListBoxDataExtension::SkinChangedL() |
|
591 { |
|
592 DeleteAnim(); |
|
593 TryCreateAnimation(); |
|
594 CreateColorBitmapsL(); |
|
595 LoadMarkingIconsL(); |
|
596 } |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CPbk2ContactViewCustomListBoxDataExtension::SkinChanged |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 void CPbk2ContactViewCustomListBoxDataExtension::SkinChanged() |
|
602 { |
|
603 DeleteAnim(); |
|
604 TryCreateAnimation(); |
|
605 TRAP_IGNORE( CreateColorBitmapsL() ); |
|
606 } |
|
607 |
|
608 // ----------------------------------------------------------------------------- |
|
609 // CPbk2ContactViewCustomListBoxDataExtension::SetControl |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 void CPbk2ContactViewCustomListBoxDataExtension::SetControl( CCoeControl* aControl ) |
|
613 { |
|
614 if( iControl ) |
|
615 { |
|
616 CEikListBox* list = (CEikListBox*) iControl; |
|
617 list->RemoveItemChangeObserver( this ); |
|
618 } |
|
619 |
|
620 iControl = aControl; |
|
621 |
|
622 if( iControl ) |
|
623 { |
|
624 CEikListBox* list = (CEikListBox*) iControl; |
|
625 TRAP_IGNORE( list->AddItemChangeObserverL(this) ); |
|
626 |
|
627 if( !iAnimation ) |
|
628 { |
|
629 TryCreateAnimation(); |
|
630 } |
|
631 |
|
632 if( iAnimation ) |
|
633 { |
|
634 Play(); |
|
635 } |
|
636 } |
|
637 else |
|
638 { |
|
639 DeleteAnim(); |
|
640 } |
|
641 } |
|
642 |
|
643 // ----------------------------------------------------------------------------- |
|
644 // CPbk2ContactViewCustomListBoxDataExtension::HandleGainingForeground |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 void CPbk2ContactViewCustomListBoxDataExtension::HandleGainingForeground() |
|
648 { |
|
649 // Most of the time focus focus events happen between foreground events. |
|
650 // Unfortunately, there are embedded app related cases where this does not |
|
651 // always hold (it is possible to focus in non-foreground application or |
|
652 // gain foreground without getting a focus gained). Therefore animations |
|
653 // must be started here. This causes potential problem case: foreground |
|
654 // events are broadcasted to all animations, if there are multiple lists |
|
655 // that have focus the result will be multiple animations running at the |
|
656 // same time. |
|
657 iAnimFlags.Set( EFlagHasForeground ); |
|
658 |
|
659 if( iAnimation ) |
|
660 { |
|
661 // Because we are gaining foreground we must restore input layers |
|
662 // (which are released when animation stops to reduce memory usage). |
|
663 SyncAnim( iAnimation->Size() ); |
|
664 } |
|
665 |
|
666 if( iControl ) |
|
667 { |
|
668 if( iControl->IsFocused() ) |
|
669 { |
|
670 Play(); |
|
671 } |
|
672 } |
|
673 } |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // CPbk2ContactViewCustomListBoxDataExtension::HandleLosingForeground |
|
677 // ----------------------------------------------------------------------------- |
|
678 // |
|
679 void CPbk2ContactViewCustomListBoxDataExtension::HandleLosingForeground() |
|
680 { |
|
681 iAnimFlags.Clear( EFlagHasForeground ); |
|
682 if( iAnimation ) |
|
683 { |
|
684 NoAnimIfError( iAnimation->Stop() ); |
|
685 } |
|
686 } |
|
687 |
|
688 // ----------------------------------------------------------------------------- |
|
689 // CPbk2ContactViewCustomListBoxDataExtension::AnimFrameReady |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 void CPbk2ContactViewCustomListBoxDataExtension::AnimFrameReady( TInt aError, TInt ) |
|
693 { |
|
694 if( KErrNone != aError ) |
|
695 { |
|
696 // Animation has failed to run -> schedule the animation for |
|
697 // deletion to fall back to normal rendering. |
|
698 PostDeleteAnimation(); |
|
699 return; |
|
700 } |
|
701 |
|
702 // This situation should never happen because we start/stop animation when |
|
703 // the extension's control is set. |
|
704 if( !iControl ) |
|
705 return; |
|
706 |
|
707 // From now on, we have a valid control pointer |
|
708 CEikColumnListBox* list = static_cast<CEikColumnListBox*>( iControl ); |
|
709 CListBoxView* view = list->View(); |
|
710 |
|
711 if( !view ) |
|
712 return; |
|
713 |
|
714 // We should not run animation when control is in certain states. When |
|
715 // control is in these states we idle the animation until the control state |
|
716 // becomes valid again. |
|
717 TBool invalid = !iControl->IsVisible() || |
|
718 iControl->IsDimmed() || |
|
719 (view->ItemDrawer()->Flags() & CListItemDrawer::EDisableHighlight); |
|
720 |
|
721 // Check for idling |
|
722 if( iAnimation->IsIdling() ) |
|
723 { |
|
724 if( invalid ) |
|
725 { |
|
726 // We are idling and the control is still invalid -> keep on |
|
727 // idling. |
|
728 return; |
|
729 } |
|
730 else |
|
731 { |
|
732 // Control is in valid state, animation should be continued |
|
733 TInt err = iAnimation->Continue(); |
|
734 if( err ) |
|
735 PostDeleteAnimation(); |
|
736 return; |
|
737 } |
|
738 } |
|
739 else if( invalid ) // Not idling and invalid control -> start idling |
|
740 { |
|
741 iAnimation->SetIdling( KAknsEffectAnimDefaultIdleInterval ); |
|
742 // If the highlight has been disabled, render once to clear the |
|
743 // highlight (not returning in that case). |
|
744 if( !(view->ItemDrawer()->Flags() & CListItemDrawer::EDisableHighlight) ) |
|
745 return; |
|
746 } |
|
747 |
|
748 // No items, no drawing |
|
749 if( list->Model()->NumberOfItems() == 0 ) |
|
750 { |
|
751 return; |
|
752 } |
|
753 |
|
754 // Column array is not ready yet |
|
755 if( iListBoxData->LastColumn() < 0 ) |
|
756 { |
|
757 return; |
|
758 } |
|
759 |
|
760 // Repaint the highlighted cell only |
|
761 view->DrawItem( view->CurrentItemIndex() ); |
|
762 } |
|
763 |
|
764 // ----------------------------------------------------------------------------- |
|
765 // CPbk2ContactViewCustomListBoxDataExtension::ListBoxItemsChanged |
|
766 |
|
767 // we get here from: |
|
768 // - CEikListBox::Reset() |
|
769 // - CEikListBox::HandleItemRemoval{WithoutSelections}L() |
|
770 // - CEikListBox::HandleItemAdditionL() |
|
771 // - CEikListBox::FireItemChange() |
|
772 // In all cases: |
|
773 // - feedback areas might be invalid |
|
774 // - application is responsible for redrawing the listbox. |
|
775 // |
|
776 // since re-drawing listbox fixes feedback areas, those can be reset here. |
|
777 |
|
778 // ----------------------------------------------------------------------------- |
|
779 // |
|
780 void CPbk2ContactViewCustomListBoxDataExtension::ListBoxItemsChanged( |
|
781 CEikListBox* aListBox) |
|
782 { |
|
783 TInt items = aListBox->Model()->NumberOfItems(); |
|
784 |
|
785 if( iAnimation ) |
|
786 { |
|
787 if( 0 == items ) |
|
788 { |
|
789 DeleteAnim(); |
|
790 } |
|
791 else |
|
792 { |
|
793 Play(); |
|
794 } |
|
795 } |
|
796 else if( !iAnimation ) |
|
797 { |
|
798 // Animation doesn't exist and we have > 0 items |
|
799 TryCreateAnimation(); |
|
800 } |
|
801 } |
|
802 |
|
803 // ----------------------------------------------------------------------------- |
|
804 // CPbk2ContactViewCustomListBoxDataExtension::DoCancel |
|
805 // ----------------------------------------------------------------------------- |
|
806 // |
|
807 void CPbk2ContactViewCustomListBoxDataExtension::DoCancel() |
|
808 { |
|
809 // Required method, but not needed |
|
810 } |
|
811 |
|
812 // ----------------------------------------------------------------------------- |
|
813 // CPbk2ContactViewCustomListBoxDataExtension::RunL |
|
814 // Postponed animation deletion is done here. |
|
815 // ----------------------------------------------------------------------------- |
|
816 // |
|
817 void CPbk2ContactViewCustomListBoxDataExtension::RunL() |
|
818 { |
|
819 DeleteAnim(); |
|
820 } |
|
821 |
|
822 // ----------------------------------------------------------------------------- |
|
823 // CPbk2ContactViewCustomListBoxDataExtension::Play |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 void CPbk2ContactViewCustomListBoxDataExtension::Play() |
|
827 { |
|
828 if( !iAnimation ) |
|
829 { |
|
830 return; |
|
831 } |
|
832 |
|
833 // No need to start running/finished animation |
|
834 if( EAknsAnimStateRunning == iAnimation->State() || |
|
835 EAknsAnimStateFinished == iAnimation->State() ) |
|
836 { |
|
837 return; |
|
838 } |
|
839 |
|
840 // Check that application is on foreground because there are cases where |
|
841 // focus changes are done after foreground is lost -> potentially leads to |
|
842 // multiple running animations. |
|
843 if( !iAnimFlags.IsSet( EFlagHasForeground ) ) |
|
844 { |
|
845 return; |
|
846 } |
|
847 |
|
848 // Animation cannot run if we don't have control (nowhere to draw) |
|
849 if( !iControl ) |
|
850 { |
|
851 return; |
|
852 } |
|
853 |
|
854 // The control must also have the focus |
|
855 if( !iControl->IsFocused() ) |
|
856 { |
|
857 return; |
|
858 } |
|
859 |
|
860 // Don't animate empty list |
|
861 CEikColumnListBox* list = static_cast<CEikColumnListBox*>( iControl ); |
|
862 if( list->Model()->NumberOfItems() == 0 ) |
|
863 { |
|
864 return; |
|
865 } |
|
866 |
|
867 // All preconditions are met: we have animation, foreground, focus, more |
|
868 // than zero items and animation is either paused or stopped. Invisibility, |
|
869 // dimming and disabled highlight are handled by idling the animation (see |
|
870 // AnimFrameReady). |
|
871 |
|
872 if( EAknsAnimStatePaused == iAnimation->State() ) |
|
873 { |
|
874 NoAnimIfError( iAnimation->Continue() ); |
|
875 } |
|
876 else if( EAknsAnimStateStopped == iAnimation->State() ) |
|
877 { |
|
878 NoAnimIfError( iAnimation->Start() ); |
|
879 } |
|
880 } |
|
881 |
|
882 // ----------------------------------------------------------------------------- |
|
883 // CPbk2ContactViewCustomListBoxDataExtension::DrawHighlightBackground |
|
884 // ----------------------------------------------------------------------------- |
|
885 // |
|
886 TBool CPbk2ContactViewCustomListBoxDataExtension::DrawHighlightBackground( CFbsBitGc& aGc ) |
|
887 { |
|
888 if( iHighlightBgDrawer ) // Bg drawing is done externally (in derived class) |
|
889 { |
|
890 return iHighlightBgDrawer->DrawHighlightAnimBackground( aGc ); |
|
891 } |
|
892 |
|
893 // Draw the background under the current highlight. This is simplified |
|
894 // drawing, we only grab a piece from the list background bitmap. |
|
895 CEikColumnListBox* list = |
|
896 static_cast<CEikColumnListBox*>( iControl ); |
|
897 CListBoxView* view = list->View(); |
|
898 TRect itemRect; |
|
899 TInt index = view->CurrentItemIndex(); |
|
900 |
|
901 // It is possible that the animation is constructed when the list is |
|
902 // empty. In this case draw the first element background (drawing works ok |
|
903 // even if the list has no items). |
|
904 if( list->Model()->NumberOfItems() == 0 ) |
|
905 { |
|
906 index = 0; |
|
907 } |
|
908 |
|
909 itemRect.SetRect( view->ItemPos( index ), iAnimation->Size() ); |
|
910 |
|
911 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
912 MAknsControlContext* cc = AknsDrawUtils::ControlContext( iControl ); |
|
913 |
|
914 if( !cc ) |
|
915 cc = SkinBackgroundContext(); |
|
916 |
|
917 return AknsDrawUtils::DrawBackground( skin, cc, iControl, aGc, TPoint(0,0), |
|
918 itemRect, KAknsDrawParamBottomLevelRGBOnly ); |
|
919 } |
|
920 |
|
921 // ----------------------------------------------------------------------------- |
|
922 // CPbk2ContactViewCustomListBoxDataExtension::PostDeleteAnimation |
|
923 // Schedules the animation for deletion by activating the extension itself. |
|
924 // Deletion is postponed because in many error/failure occasions the caller has |
|
925 // been animation and direct deletion is possibly not safe (because function |
|
926 // stack would return through the deleted object). |
|
927 // ----------------------------------------------------------------------------- |
|
928 // |
|
929 void CPbk2ContactViewCustomListBoxDataExtension::PostDeleteAnimation() |
|
930 { |
|
931 TRequestStatus* status = &iStatus; |
|
932 User::RequestComplete( status, KErrNone ); |
|
933 SetActive(); |
|
934 } |
|
935 |
|
936 // ----------------------------------------------------------------------------- |
|
937 // CPbk2ContactViewCustomListBoxDataExtension::CreateAnimationL |
|
938 // ----------------------------------------------------------------------------- |
|
939 // |
|
940 void CPbk2ContactViewCustomListBoxDataExtension::CreateAnimationL() |
|
941 { |
|
942 DeleteAnim(); |
|
943 |
|
944 // Check if derived class wants to disable highligh animation |
|
945 if( KAknsIIDNone == iAnimIID ) |
|
946 { |
|
947 return; |
|
948 } |
|
949 |
|
950 // Create animation |
|
951 CCoeEnv* env = CCoeEnv::Static(); |
|
952 env->AddForegroundObserverL( *this ); |
|
953 |
|
954 iAnimation = CAknsEffectAnim::NewL( this ); |
|
955 TBool ok = iAnimation->ConstructFromSkinL( iAnimIID ); |
|
956 |
|
957 if( !ok ) // Animation for the ID was not found from the skin |
|
958 { |
|
959 User::Leave( KErrNotFound ); |
|
960 } |
|
961 |
|
962 // Sync the local foreground flag state. Foreground state is stored locally |
|
963 // because calling AppUi::IsForeground causes WSERV flush (shocking) and |
|
964 // therefore it cannot be used in draw routines. |
|
965 CAknAppUi* aui = static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi()); |
|
966 iAnimFlags.Assign( EFlagHasForeground, aui->IsForeground() ); |
|
967 |
|
968 Play(); |
|
969 } |
|
970 |
|
971 // ----------------------------------------------------------------------------- |
|
972 // CPbk2ContactViewCustomListBoxDataExtension::DoResizeL |
|
973 // ----------------------------------------------------------------------------- |
|
974 // |
|
975 void CPbk2ContactViewCustomListBoxDataExtension::DoResizeL( |
|
976 const TSize& aHighlightSize, TBool aAboutToStart ) |
|
977 { |
|
978 iAnimation->BeginConfigInputLayersL( aHighlightSize, aAboutToStart ); |
|
979 |
|
980 if( iAnimation->InputRgbGc() ) |
|
981 { |
|
982 DrawHighlightBackground( *iAnimation->InputRgbGc() ); |
|
983 } |
|
984 |
|
985 iAnimation->EndConfigInputLayersL(); |
|
986 } |
|
987 |
|
988 void CPbk2ContactViewCustomListBoxDataExtension::DrawPictographArea() |
|
989 { |
|
990 iControl->DrawNow(); |
|
991 } |
|
992 |
|
993 TInt CPbk2ContactViewCustomListBoxDataExtension::RedrawEvent(TAny* aControl) |
|
994 { |
|
995 if (!((CCoeControl*)aControl)->IsVisible()) |
|
996 { |
|
997 return EFalse; |
|
998 } |
|
999 CEikColumnListBox* listBox = |
|
1000 (CEikColumnListBox*)aControl; |
|
1001 |
|
1002 // HWET-7BDDD4 |
|
1003 CListBoxView* view = listBox->View(); |
|
1004 TInt index = listBox->CurrentItemIndex(); |
|
1005 if ( view->ItemIsVisible( index ) ) |
|
1006 { |
|
1007 listBox->DrawItem( index ); |
|
1008 } |
|
1009 return ETrue; |
|
1010 } |
|
1011 |
|
1012 TBool CPbk2ContactViewCustomListBoxDataExtension::IsMarqueeOn() |
|
1013 { |
|
1014 TBool isOn = EFalse; |
|
1015 if (iMarquee) |
|
1016 isOn = iMarquee->IsMarqueeOn(); |
|
1017 return isOn; |
|
1018 } |
|
1019 void CPbk2ContactViewCustomListBoxDataExtension::AddSLSubCellL(TInt aSubCell) |
|
1020 { |
|
1021 SSLSubCell subcell; |
|
1022 subcell.iSubCell = aSubCell; |
|
1023 subcell.iTextLayout = NULL; |
|
1024 subcell.iGraphicLayout = NULL; |
|
1025 subcell.iSubCellType = 0; |
|
1026 subcell.iConditionValue = -1; |
|
1027 |
|
1028 TKeyArrayFix key(0,ECmpTInt32); |
|
1029 iSLSubCellArray->InsertIsqL(subcell,key); |
|
1030 } |
|
1031 |
|
1032 void |
|
1033 CPbk2ContactViewCustomListBoxDataExtension::AddRowAndColumnL(TInt aRow,TInt aColumn) |
|
1034 { |
|
1035 SRowAndColumn column; |
|
1036 column.iIndex = (aRow << 8) | (aColumn & 0xff); |
|
1037 TKeyArrayFix key(0,ECmpTInt32); |
|
1038 iRowAndColumnArray->InsertIsqL(column,key); |
|
1039 } |
|
1040 |
|
1041 |
|
1042 CPbk2ContactViewCustomListBoxDataExtension::SRowAndColumn& |
|
1043 CPbk2ContactViewCustomListBoxDataExtension::At(TInt aArrayIndex) |
|
1044 { |
|
1045 __ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iRowAndColumnArray->Count(),Panic(EPanicPreCond_OutOfRangeListBoxData)); |
|
1046 return(iRowAndColumnArray->At(aArrayIndex)); |
|
1047 } |
|
1048 |
|
1049 const CPbk2ContactViewCustomListBoxDataExtension::SRowAndColumn& |
|
1050 CPbk2ContactViewCustomListBoxDataExtension::At(TInt aArrayIndex) const |
|
1051 { |
|
1052 __ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iRowAndColumnArray->Count(),Panic(EPanicPreCond_OutOfRangeListBoxData)); |
|
1053 return(iRowAndColumnArray->At(aArrayIndex)); |
|
1054 } |
|
1055 |
|
1056 TInt CPbk2ContactViewCustomListBoxDataExtension::FindRowAndColumnIndex(TInt& aArrayIndex, |
|
1057 TInt aRow, |
|
1058 TInt aColumn) const |
|
1059 { |
|
1060 if (iRowAndColumnArray->Count()==0) |
|
1061 return(KErrNotFound); |
|
1062 TKeyArrayFix key(0,ECmpTInt32); |
|
1063 SRowAndColumn rowAndColumn; |
|
1064 rowAndColumn.iIndex = (aRow << 8) | (aColumn & 0xff); |
|
1065 return(iRowAndColumnArray->FindIsq(rowAndColumn,key,aArrayIndex)); |
|
1066 } |
|
1067 |
|
1068 void CPbk2ContactViewCustomListBoxDataExtension::FindRowAndColumnIndexOrAddL(TInt& aArrayIndex, |
|
1069 TInt aRow, |
|
1070 TInt aColumn) |
|
1071 { |
|
1072 if (FindRowAndColumnIndex(aArrayIndex,aRow,aColumn)!=0) //==KErrNotFound) |
|
1073 { |
|
1074 AddRowAndColumnL(aRow,aColumn); |
|
1075 FindRowAndColumnIndex(aArrayIndex,aRow,aColumn); |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 /////////////handling TColumnExt,start |
|
1080 |
|
1081 TInt CPbk2ContactViewCustomListBoxDataExtension::AddColumnExtL(TInt aColumn) |
|
1082 { |
|
1083 TColumnExt column; |
|
1084 column.iColumn=aColumn; |
|
1085 column.iLayoutAlign = ETrue; |
|
1086 TKeyArrayFix key(0,ECmpTInt); |
|
1087 return iColumnExtArray->InsertIsqL(column,key); |
|
1088 } |
|
1089 void CPbk2ContactViewCustomListBoxDataExtension::FindColumnExtIndexOrAddL(TInt& aArrayIndex,TInt aColumn) |
|
1090 { |
|
1091 if (!FindColumnExtIndex(aArrayIndex,aColumn)) |
|
1092 { |
|
1093 aArrayIndex = AddColumnExtL(aColumn); |
|
1094 |
|
1095 } |
|
1096 } |
|
1097 |
|
1098 void CPbk2ContactViewCustomListBoxDataExtension::SetColumnLayoutAlignmentL(TInt aColumn) |
|
1099 { |
|
1100 TInt index; |
|
1101 FindColumnExtIndexOrAddL(index,aColumn); |
|
1102 iColumnExtArray->At(index).iLayoutAlign = EFalse; |
|
1103 } |
|
1104 |
|
1105 |
|
1106 TBool CPbk2ContactViewCustomListBoxDataExtension::FindColumnExtIndex(TInt& aArrayIndex,TInt aColumn) const |
|
1107 { |
|
1108 if (aColumn<0 || iColumnExtArray->Count()==0) |
|
1109 return EFalse; |
|
1110 TKeyArrayFix key(0,ECmpTInt); |
|
1111 TColumnExt column; |
|
1112 column.iColumn=aColumn; |
|
1113 |
|
1114 // Returns zero if key was found, otherwise non-zero |
|
1115 TInt ret = iColumnExtArray->FindIsq(column,key,aArrayIndex); |
|
1116 return (ret == 0); |
|
1117 } |
|
1118 |
|
1119 TBool CPbk2ContactViewCustomListBoxDataExtension::ColumnLayoutAlignment(TInt aColumn) const |
|
1120 { |
|
1121 TInt index; |
|
1122 if (!FindColumnExtIndex(index,aColumn)) |
|
1123 return(ETrue); |
|
1124 return(iColumnExtArray->At(index).iLayoutAlign); |
|
1125 } |
|
1126 |
|
1127 /////////////handling TColumnExt,end |
|
1128 CPbk2ContactViewCustomListBoxDataExtension::SSLSubCell& |
|
1129 CPbk2ContactViewCustomListBoxDataExtension::AtSL(TInt aArrayIndex) |
|
1130 { |
|
1131 __ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iSLSubCellArray->Count(),Panic(EPanicPreCond_OutOfRangeListBoxData)); |
|
1132 return(iSLSubCellArray->At(aArrayIndex)); |
|
1133 } |
|
1134 |
|
1135 const CPbk2ContactViewCustomListBoxDataExtension::SSLSubCell& |
|
1136 CPbk2ContactViewCustomListBoxDataExtension::AtSL(TInt aArrayIndex) const |
|
1137 { |
|
1138 __ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iSLSubCellArray->Count(),Panic(EPanicPreCond_OutOfRangeListBoxData)); |
|
1139 return(iSLSubCellArray->At(aArrayIndex)); |
|
1140 } |
|
1141 |
|
1142 TInt CPbk2ContactViewCustomListBoxDataExtension::FindSLSubCellIndex(TInt& aArrayIndex, |
|
1143 TInt aSubCell) const |
|
1144 { |
|
1145 if (iSLSubCellArray->Count()==0) |
|
1146 return(KErrNotFound); |
|
1147 TKeyArrayFix key(0,ECmpTInt32); |
|
1148 SSLSubCell SLSubCell; |
|
1149 SLSubCell.iSubCell = aSubCell; |
|
1150 return(iSLSubCellArray->FindIsq(SLSubCell,key,aArrayIndex)); |
|
1151 } |
|
1152 |
|
1153 void CPbk2ContactViewCustomListBoxDataExtension::FindSLSubCellIndexOrAddL(TInt& aArrayIndex, |
|
1154 TInt aSubCell) |
|
1155 { |
|
1156 if (FindSLSubCellIndex(aArrayIndex, aSubCell)!=0) //==KErrNotFound) |
|
1157 { |
|
1158 AddSLSubCellL(aSubCell); |
|
1159 FindSLSubCellIndex(aArrayIndex,aSubCell); |
|
1160 } |
|
1161 } |
|
1162 |
|
1163 void CPbk2ContactViewCustomListBoxDataExtension::ResetSLSubCellArray() |
|
1164 { |
|
1165 iSLSubCellArray->Reset(); |
|
1166 iRowAndSubCellArray->Reset(); |
|
1167 } |
|
1168 |
|
1169 TBool CPbk2ContactViewCustomListBoxDataExtension::DrawPressedDownEffect( MAknsSkinInstance* aInstance, |
|
1170 CWindowGc& aGc,const TRect& aOutRect, |
|
1171 const TRect& aInnerRect ) const |
|
1172 { |
|
1173 return AknsDrawUtils::DrawFrame( aInstance, |
|
1174 aGc, |
|
1175 aOutRect, |
|
1176 aInnerRect, |
|
1177 KAknsIIDQsnFrListPressed, |
|
1178 KAknsIIDQsnFrListCenterPressed ); |
|
1179 } |
|
1180 |
|
1181 // ----------------------------------------------------------------------------- |
|
1182 // CPbk2ContactViewCustomListBoxDataExtension::LoadMarkingIconsL |
|
1183 // ----------------------------------------------------------------------------- |
|
1184 // |
|
1185 void CPbk2ContactViewCustomListBoxDataExtension::LoadMarkingIconsL() |
|
1186 { |
|
1187 if ( !iMarkingIconArray ) |
|
1188 { |
|
1189 iMarkingIconArray = new ( ELeave ) CAknIconArray( 2 ); |
|
1190 } |
|
1191 else |
|
1192 { |
|
1193 iMarkingIconArray->ResetAndDestroy(); |
|
1194 } |
|
1195 |
|
1196 CGulIcon* icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), |
|
1197 KAknsIIDQgnPropCheckboxOn, |
|
1198 AknIconUtils::AvkonIconFileName(), |
|
1199 EMbmAvkonQgn_prop_checkbox_on, |
|
1200 EMbmAvkonQgn_prop_checkbox_on_mask ); |
|
1201 |
|
1202 CleanupStack::PushL( icon ); |
|
1203 iMarkingIconArray->AppendL( icon ); |
|
1204 CleanupStack::Pop( icon ); |
|
1205 |
|
1206 icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), |
|
1207 KAknsIIDQgnPropCheckboxOff, |
|
1208 AknIconUtils::AvkonIconFileName(), |
|
1209 EMbmAvkonQgn_prop_checkbox_off, |
|
1210 EMbmAvkonQgn_prop_checkbox_off_mask ); |
|
1211 |
|
1212 CleanupStack::PushL( icon ); |
|
1213 iMarkingIconArray->AppendL( icon ); |
|
1214 CleanupStack::Pop( icon ); |
|
1215 } |
|
1216 |
|
1217 CCoeControl *CPbk2ContactViewCustomListBoxData::Control() const |
|
1218 { |
|
1219 return iExtension->iControl; |
|
1220 } |
|
1221 |
|
1222 void CPbk2ContactViewCustomListBoxData::SetControl(CCoeControl *aControl) |
|
1223 { |
|
1224 iExtension->SetControl( aControl ); |
|
1225 } |
|
1226 |
|
1227 |
|
1228 MAknsControlContext* CPbk2ContactViewCustomListBoxData::SkinBackgroundContext() const |
|
1229 { |
|
1230 if (iExtension->iSkinEnabled) |
|
1231 { |
|
1232 return iExtension->iSkinControlContext; |
|
1233 } |
|
1234 |
|
1235 return NULL; |
|
1236 } |
|
1237 |
|
1238 void CPbk2ContactViewCustomListBoxData::SetSkinBackgroundContext(CAknsListBoxBackgroundControlContext *aContext) |
|
1239 { |
|
1240 delete iExtension->iSkinControlContext; |
|
1241 iExtension->iSkinControlContext = aContext; |
|
1242 } |
|
1243 |
|
1244 void CPbk2ContactViewCustomListBoxData::CreatePictographInterfaceL() |
|
1245 { |
|
1246 if ( !iExtension->iPictoInterface ) |
|
1247 { |
|
1248 iExtension->iPictoInterface = CAknPictographInterface::NewL( |
|
1249 *iExtension->iControl, *iExtension ); |
|
1250 } |
|
1251 } |
|
1252 |
|
1253 void CPbk2ContactViewCustomListBoxData::SetSkinHighlightFrame(const TAknsItemID *aFrameId, const TAknsItemID *aFrameCenterId) |
|
1254 { |
|
1255 iExtension->iSkinHighlightFrameId = aFrameId; |
|
1256 iExtension->iSkinHighlightFrameCenterId = aFrameCenterId; |
|
1257 } |
|
1258 |
|
1259 void CPbk2ContactViewCustomListBoxData::SetSkinEnabledL(TBool aEnabled) |
|
1260 { |
|
1261 CListBoxData::SetSkinEnabledL(aEnabled); |
|
1262 iExtension->iSkinEnabled = aEnabled; |
|
1263 } |
|
1264 |
|
1265 void CPbk2ContactViewCustomListBoxData::SetSkinStyle(const TAknsItemID *aId, const TRect &aTileRect) |
|
1266 { |
|
1267 if (iExtension->iSkinControlContext) |
|
1268 { |
|
1269 iExtension->iSkinControlContext->SetTiledBitmap(*aId); |
|
1270 iExtension->iSkinControlContext->SetTiledRect(aTileRect); |
|
1271 } |
|
1272 } |
|
1273 |
|
1274 void CPbk2ContactViewCustomListBoxData::SetListEndSkinStyle(const TAknsItemID *aId, const TRect &aTileRect) |
|
1275 { |
|
1276 if (iExtension->iSkinControlContext) |
|
1277 { |
|
1278 iExtension->iSkinControlContext->SetBottomBitmap(*aId); |
|
1279 iExtension->iSkinControlContext->SetBottomRect(aTileRect); |
|
1280 } |
|
1281 } |
|
1282 |
|
1283 void CPbk2ContactViewCustomListBoxData::CreateMarqueeControlL() |
|
1284 { |
|
1285 if ( !iExtension->iMarquee ) |
|
1286 { |
|
1287 iExtension->iMarquee = CAknMarqueeControl::NewL(); |
|
1288 } |
|
1289 |
|
1290 if ( !iExtension->i2ndLineMarquee ) |
|
1291 { |
|
1292 iExtension->i2ndLineMarquee = CAknMarqueeControl::NewL(); |
|
1293 } |
|
1294 |
|
1295 TCallBack callBack(CPbk2ContactViewCustomListBoxDataExtension::RedrawEvent, |
|
1296 iExtension->iControl); |
|
1297 iExtension->iMarquee->SetRedrawCallBack(callBack); |
|
1298 iExtension->i2ndLineMarquee->SetRedrawCallBack(callBack); |
|
1299 } |
|
1300 |
|
1301 void CPbk2ContactViewCustomListBoxData::ResetMarquee() |
|
1302 { |
|
1303 if (iExtension->iMarquee) |
|
1304 { |
|
1305 iExtension->iMarquee->Reset(); |
|
1306 } |
|
1307 if (iExtension->i2ndLineMarquee) |
|
1308 { |
|
1309 iExtension->i2ndLineMarquee->Reset(); |
|
1310 } |
|
1311 } |
|
1312 |
|
1313 TInt CPbk2ContactViewCustomListBoxData::CurrentMarqueeItemIndex() |
|
1314 { |
|
1315 return iExtension->iCurrentItem; |
|
1316 } |
|
1317 |
|
1318 void CPbk2ContactViewCustomListBoxData::SetCurrentMarqueeItemIndex(TInt aIndex) |
|
1319 { |
|
1320 iExtension->iCurrentItem = aIndex; |
|
1321 } |
|
1322 |
|
1323 // |
|
1324 // Enables or disables marquee. |
|
1325 // |
|
1326 void CPbk2ContactViewCustomListBoxData::EnableMarqueeL(TBool aEnable) |
|
1327 { |
|
1328 // CreateMarqueeControlL does nothing if marquee already exists, |
|
1329 // so let's just call it just in case. |
|
1330 CreateMarqueeControlL(); |
|
1331 iExtension->iMarquee->EnableMarquee(aEnable); |
|
1332 iExtension->i2ndLineMarquee->EnableMarquee(aEnable); |
|
1333 } |
|
1334 |
|
1335 void CPbk2ContactViewCustomListBoxData::SetSeparatorLinePosition(TAknSeparatorLinePosition aPosition) |
|
1336 { |
|
1337 if (iExtension) |
|
1338 iExtension->iSeparatorLinePosition = aPosition; |
|
1339 } |
|
1340 TAknSeparatorLinePosition CPbk2ContactViewCustomListBoxData::SeparatorLinePosition() const |
|
1341 { |
|
1342 if (iExtension) |
|
1343 return iExtension->iSeparatorLinePosition; |
|
1344 else |
|
1345 return ENoLine; |
|
1346 } |
|
1347 CAknLayoutData *CPbk2ContactViewCustomListBoxData::LayoutData() const |
|
1348 { |
|
1349 return NULL; |
|
1350 } |
|
1351 |
|
1352 TBool CPbk2ContactViewCustomListBoxData::LayoutInit() const |
|
1353 { |
|
1354 return EFalse; |
|
1355 } |
|
1356 |
|
1357 void CPbk2ContactViewCustomListBoxData::SetLayoutInit(TBool /*aValue*/) const |
|
1358 { |
|
1359 } |
|
1360 |
|
1361 |
|
1362 // |
|
1363 // Class CPbk2ContactViewCustomListBoxData::TColors |
|
1364 // |
|
1365 |
|
1366 /** |
|
1367 * Constructs and intialises the data colors to blacks and whites. |
|
1368 */ |
|
1369 CPbk2ContactViewCustomListBoxData::TColors::TColors() |
|
1370 : iText(KRgbBlack), iBack(KRgbWhite), iHighlightedText(KRgbWhite), iHighlightedBack(KRgbBlack) |
|
1371 { |
|
1372 } |
|
1373 |
|
1374 // |
|
1375 // Class CPbk2ContactViewCustomListBoxData |
|
1376 // |
|
1377 |
|
1378 CPbk2ContactViewCustomListBoxData* CPbk2ContactViewCustomListBoxData::NewL( |
|
1379 CPbk2PredictiveSearchFilter &aSearchFilter ) |
|
1380 // |
|
1381 // Public c'tor |
|
1382 // |
|
1383 { |
|
1384 CPbk2ContactViewCustomListBoxData* self=new(ELeave) |
|
1385 CPbk2ContactViewCustomListBoxData( aSearchFilter ); |
|
1386 self->ConstructLD(); |
|
1387 return(self); |
|
1388 } |
|
1389 |
|
1390 CPbk2ContactViewCustomListBoxData::CPbk2ContactViewCustomListBoxData( |
|
1391 CPbk2PredictiveSearchFilter &aSearchFilter ) |
|
1392 : CListBoxData(), iSearchFilter( aSearchFilter ) |
|
1393 // |
|
1394 // Protected c'tor |
|
1395 // |
|
1396 { |
|
1397 |
|
1398 } |
|
1399 |
|
1400 CPbk2ContactViewCustomListBoxData::~CPbk2ContactViewCustomListBoxData() |
|
1401 // |
|
1402 // D'tor |
|
1403 // |
|
1404 { |
|
1405 delete iColumnArray; |
|
1406 if (IconArray()) |
|
1407 { |
|
1408 IconArray()->ResetAndDestroy(); |
|
1409 if (iExtension) |
|
1410 delete iExtension->iIconArray; |
|
1411 } |
|
1412 delete iExtension; |
|
1413 } |
|
1414 |
|
1415 void CPbk2ContactViewCustomListBoxData::ConstructLD() |
|
1416 { |
|
1417 TRAPD( err, DoConstructL( KAknsIIDQsnAnimList ) ); |
|
1418 if( err ) |
|
1419 { |
|
1420 delete(this); |
|
1421 User::Leave( err ); |
|
1422 } |
|
1423 } |
|
1424 |
|
1425 void CPbk2ContactViewCustomListBoxData::ConstructLD( |
|
1426 const TAknsItemID& aAnimationIID ) |
|
1427 { |
|
1428 TRAPD( err, DoConstructL( aAnimationIID ) ); |
|
1429 if( err ) |
|
1430 { |
|
1431 delete(this); |
|
1432 User::Leave( err ); |
|
1433 } |
|
1434 } |
|
1435 |
|
1436 void CPbk2ContactViewCustomListBoxData::DoConstructL( const TAknsItemID& aAnimationIID ) |
|
1437 { |
|
1438 iColumnArray = new(ELeave) CArrayFixFlat<SColumn>(KColumnListBoxGranularity); |
|
1439 iExtension = new(ELeave) CPbk2ContactViewCustomListBoxDataExtension; |
|
1440 |
|
1441 iExtension->iSkinEnabled = AknsUtils::AvkonSkinEnabled(); |
|
1442 SetupSkinContextL(); |
|
1443 |
|
1444 iExtension->ConstructL( this, aAnimationIID ); |
|
1445 |
|
1446 CListBoxData::SetSkinBackgroundControlContextL(iExtension->iSkinControlContext); |
|
1447 |
|
1448 // preallocate columns so that we dont need to leave on |
|
1449 // SizeChanged(). |
|
1450 // AddColumnL(0); |
|
1451 // AddColumnL(1); |
|
1452 // AddColumnL(2); |
|
1453 // AddColumnL(3); |
|
1454 // AddColumnL(4); |
|
1455 } |
|
1456 |
|
1457 TInt CPbk2ContactViewCustomListBoxData::LastColumn() const |
|
1458 // |
|
1459 // The last column defined |
|
1460 // |
|
1461 { |
|
1462 TInt count=iColumnArray->Count(); |
|
1463 if (!count) |
|
1464 return(KErrNotFound); |
|
1465 return(At(count-1).iColumn); |
|
1466 } |
|
1467 |
|
1468 TInt CPbk2ContactViewCustomListBoxData::ColumnWidthPixel(TInt aColumn) const |
|
1469 // |
|
1470 // Return the width for a column |
|
1471 // |
|
1472 { |
|
1473 TInt index; |
|
1474 if (!FindColumnIndex(index,aColumn)) |
|
1475 return(0); |
|
1476 return(At(index).iWidth); |
|
1477 } |
|
1478 |
|
1479 void CPbk2ContactViewCustomListBoxData::SetColumnWidthPixelL(TInt aColumn,TInt aWidth) |
|
1480 // |
|
1481 // Set a columns width |
|
1482 // |
|
1483 { |
|
1484 TInt index; |
|
1485 FindColumnIndexOrAddL(index,aColumn); |
|
1486 At(index).iWidth=aWidth; |
|
1487 if ( iExtension && iExtension->iUseLayoutData ) |
|
1488 { |
|
1489 iExtension->iUseLayoutData = EFalse; |
|
1490 CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View(); |
|
1491 MAknListBoxTfxInternal* transApi = |
|
1492 CAknListLoader::TfxApiInternal( view->ItemDrawer()->Gc() ); |
|
1493 if ( transApi ) |
|
1494 { |
|
1495 transApi->SetPosition( MAknListBoxTfxInternal::EListTLMargin, TPoint( 0, 0 ) ); |
|
1496 transApi->SetPosition( MAknListBoxTfxInternal::EListBRMargin, TPoint( 0, 0 ) ); |
|
1497 } |
|
1498 } |
|
1499 } |
|
1500 |
|
1501 TInt CPbk2ContactViewCustomListBoxData::ColumnHorizontalGap(TInt aColumn) const |
|
1502 // |
|
1503 // Return the vertical for a column |
|
1504 // |
|
1505 { |
|
1506 TInt index; |
|
1507 if (!FindColumnIndex(index,aColumn)) |
|
1508 return(0); |
|
1509 return(At(index).iVerticalCap); |
|
1510 } |
|
1511 |
|
1512 void CPbk2ContactViewCustomListBoxData::SetColumnHorizontalGapL(TInt aColumn,TInt aGap) |
|
1513 // |
|
1514 // Set a columns vertical cap |
|
1515 // |
|
1516 { |
|
1517 TInt index; |
|
1518 FindColumnIndexOrAddL(index,aColumn); |
|
1519 At(index).iVerticalCap=aGap; |
|
1520 } |
|
1521 |
|
1522 |
|
1523 TInt |
|
1524 CPbk2ContactViewCustomListBoxData::ColumnTextClipGap(TInt aColumnIndex) const |
|
1525 { |
|
1526 TInt index; |
|
1527 if (!FindColumnIndex(index,aColumnIndex)) |
|
1528 return TInt(0); |
|
1529 return(iColumnArray->At(index).iTextClipGap); |
|
1530 } |
|
1531 |
|
1532 void |
|
1533 CPbk2ContactViewCustomListBoxData::SetColumnTextClipGapL(TInt aColumnIndex, TInt aGap) |
|
1534 { |
|
1535 TInt index; |
|
1536 FindColumnIndexOrAddL(index,aColumnIndex); |
|
1537 At(index).iTextClipGap=aGap; |
|
1538 } |
|
1539 |
|
1540 TInt CPbk2ContactViewCustomListBoxData::ColumnBaselinePos(TInt aColumn) const |
|
1541 // |
|
1542 // Return the vertical for a column |
|
1543 // |
|
1544 { |
|
1545 TInt index; |
|
1546 if (!FindColumnIndex(index,aColumn)) |
|
1547 return(0); |
|
1548 return(At(index).iBaseline); |
|
1549 } |
|
1550 |
|
1551 void CPbk2ContactViewCustomListBoxData::SetColumnBaselinePosL(TInt aColumn,TInt aPos) |
|
1552 // |
|
1553 // Set a columns baseline position |
|
1554 // |
|
1555 { |
|
1556 TInt index; |
|
1557 FindColumnIndexOrAddL(index,aColumn); |
|
1558 At(index).iBaseline=aPos; |
|
1559 |
|
1560 // can not be nicely supported by new drawing system |
|
1561 // --> revert to Symbian style drawing |
|
1562 if ( iExtension && iExtension->iUseLayoutData ) |
|
1563 { |
|
1564 iExtension->iUseLayoutData = EFalse; |
|
1565 CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View(); |
|
1566 MAknListBoxTfxInternal* transApi = |
|
1567 CAknListLoader::TfxApiInternal( view->ItemDrawer()->Gc() ); |
|
1568 if ( transApi ) |
|
1569 { |
|
1570 transApi->SetPosition( MAknListBoxTfxInternal::EListTLMargin, TPoint( 0, 0 ) ); |
|
1571 transApi->SetPosition( MAknListBoxTfxInternal::EListBRMargin, TPoint( 0, 0 ) ); |
|
1572 } |
|
1573 } |
|
1574 } |
|
1575 |
|
1576 TMargins CPbk2ContactViewCustomListBoxData::ColumnMargins(TInt aColumn) const |
|
1577 // |
|
1578 // Return the vertical for a column |
|
1579 // |
|
1580 { |
|
1581 TInt index; |
|
1582 if (!FindColumnIndex(index,aColumn)) |
|
1583 { |
|
1584 TMargins m = {0,0,0,0}; |
|
1585 return m; |
|
1586 } |
|
1587 return(At(index).iMargins); |
|
1588 } |
|
1589 |
|
1590 void CPbk2ContactViewCustomListBoxData::SetColumnMarginsL(TInt aColumn,TMargins aMargins) |
|
1591 // |
|
1592 // Set a columns vertical cap |
|
1593 // |
|
1594 { |
|
1595 TInt index; |
|
1596 FindColumnIndexOrAddL(index,aColumn); |
|
1597 At(index).iMargins=aMargins; |
|
1598 |
|
1599 // can not be nicely supported by new drawing system |
|
1600 // --> revert to Symbian style drawing |
|
1601 if ( iExtension && iExtension->iUseLayoutData ) |
|
1602 { |
|
1603 iExtension->iUseLayoutData = EFalse; |
|
1604 CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View(); |
|
1605 MAknListBoxTfxInternal* transApi = |
|
1606 CAknListLoader::TfxApiInternal( view->ItemDrawer()->Gc() ); |
|
1607 if ( transApi ) |
|
1608 { |
|
1609 transApi->SetPosition( MAknListBoxTfxInternal::EListTLMargin, TPoint( 0, 0 ) ); |
|
1610 transApi->SetPosition( MAknListBoxTfxInternal::EListBRMargin, TPoint( 0, 0 ) ); |
|
1611 } |
|
1612 } |
|
1613 } |
|
1614 |
|
1615 |
|
1616 TInt CPbk2ContactViewCustomListBoxData::ColumnX(TInt aColumn) const |
|
1617 { |
|
1618 TInt index; |
|
1619 if (!FindColumnIndex(index,aColumn)) |
|
1620 { |
|
1621 return 0; |
|
1622 |
|
1623 } |
|
1624 return(At(index).iX); |
|
1625 } |
|
1626 |
|
1627 void CPbk2ContactViewCustomListBoxData::SetColumnXL(TInt aColumn,TInt aX) const |
|
1628 { |
|
1629 TInt index; |
|
1630 MUTABLE_CAST(CPbk2ContactViewCustomListBoxData*,this)->FindColumnIndexOrAddL(index,aColumn); |
|
1631 MUTABLE_CAST(TInt&,At(index).iX)=aX; |
|
1632 } |
|
1633 |
|
1634 |
|
1635 TInt CPbk2ContactViewCustomListBoxData::ColumnEndX(TInt aColumn) const |
|
1636 { |
|
1637 TInt index; |
|
1638 if (!FindColumnIndex(index,aColumn)) |
|
1639 { |
|
1640 return 0; |
|
1641 } |
|
1642 return(At(index).iEndX); |
|
1643 } |
|
1644 |
|
1645 void CPbk2ContactViewCustomListBoxData::SetColumnEndXL(TInt aColumn,TInt aEndX) const |
|
1646 { |
|
1647 TInt index; |
|
1648 MUTABLE_CAST(CPbk2ContactViewCustomListBoxData*,this)->FindColumnIndexOrAddL(index,aColumn); |
|
1649 MUTABLE_CAST(TInt&,At(index).iEndX)=aEndX; |
|
1650 } |
|
1651 |
|
1652 const CFont* CPbk2ContactViewCustomListBoxData::ColumnFont(TInt aColumn) const |
|
1653 // |
|
1654 // Return the font for a column |
|
1655 // |
|
1656 { |
|
1657 TInt index; |
|
1658 if (!FindColumnIndex(index,aColumn)) |
|
1659 return(NULL); |
|
1660 return(iColumnArray->At(index).iBaseFont); |
|
1661 } |
|
1662 |
|
1663 void CPbk2ContactViewCustomListBoxData::SetColumnFontL(TInt aColumn,const CFont* aFont) |
|
1664 // |
|
1665 // Set a font for a column |
|
1666 // |
|
1667 { |
|
1668 // This corrects error report KBAA-53GEQ5. |
|
1669 #if NOT_NEEDED_IN_SERIES60 |
|
1670 TInt columns=iColumnArray->Count(); |
|
1671 #endif |
|
1672 TInt index; |
|
1673 FindColumnIndexOrAddL(index,aColumn); |
|
1674 if (!At(index).iBaseFont) |
|
1675 { |
|
1676 // This corrects error report KBAA-53GEQ5. |
|
1677 #if NOT_NEEDED_IN_SERIES60 |
|
1678 TInt actualFontIndex=0; |
|
1679 TRAPD(err, actualFontIndex=AddActualFontL(aFont)); |
|
1680 if (err) |
|
1681 { |
|
1682 if (columns!=iColumnArray->Count()) |
|
1683 { |
|
1684 iColumnArray->Delete(index); |
|
1685 } |
|
1686 User::Leave(err); |
|
1687 } |
|
1688 At(index).iActualFontIndex=actualFontIndex; |
|
1689 #endif |
|
1690 // TPFIX(moved down) At(index).iBaseFont=aFont; |
|
1691 } |
|
1692 At(index).iBaseFont=aFont; |
|
1693 } |
|
1694 |
|
1695 CGraphicsContext::TTextAlign CPbk2ContactViewCustomListBoxData::ColumnAlignment(TInt aColumn) const |
|
1696 // |
|
1697 // Return a columns alignment |
|
1698 // |
|
1699 { |
|
1700 TInt index; |
|
1701 if (!FindColumnIndex(index,aColumn)) |
|
1702 return(CGraphicsContext::ELeft); |
|
1703 return(iColumnArray->At(index).iAlign); |
|
1704 } |
|
1705 |
|
1706 void CPbk2ContactViewCustomListBoxData::SetColumnAlignmentL(TInt aColumn,CGraphicsContext::TTextAlign aAlign) |
|
1707 // |
|
1708 // Set a columns alignment |
|
1709 // |
|
1710 { |
|
1711 TInt index; |
|
1712 FindColumnIndexOrAddL(index,aColumn); |
|
1713 At(index).iAlign=aAlign; |
|
1714 iExtension->SetColumnLayoutAlignmentL( aColumn); |
|
1715 } |
|
1716 |
|
1717 |
|
1718 CGraphicsContext::TPenStyle CPbk2ContactViewCustomListBoxData::ColumnSeparatorStyle(TInt aColumn) const |
|
1719 // |
|
1720 // Return a columns separator style |
|
1721 // |
|
1722 { |
|
1723 TInt index; |
|
1724 if (!FindColumnIndex(index,aColumn)) |
|
1725 return(CGraphicsContext::ENullPen); |
|
1726 return(iColumnArray->At(index).iSeparator); |
|
1727 } |
|
1728 |
|
1729 void CPbk2ContactViewCustomListBoxData::SetColumnSeparatorStyleL(TInt aColumn,CGraphicsContext::TPenStyle aSeparator) |
|
1730 // |
|
1731 // Set a columns separator style |
|
1732 // |
|
1733 { |
|
1734 TInt index; |
|
1735 FindColumnIndexOrAddL(index,aColumn); |
|
1736 At(index).iSeparator=aSeparator; |
|
1737 } |
|
1738 |
|
1739 |
|
1740 TBool CPbk2ContactViewCustomListBoxData::ColumnIsGraphics(TInt aColumn) const |
|
1741 // |
|
1742 // Return true if the column contains graphics |
|
1743 // |
|
1744 { |
|
1745 TInt index; |
|
1746 if (!FindColumnIndex(index,aColumn)) |
|
1747 return(EFalse); |
|
1748 return(iColumnArray->At(index).iGraphics); |
|
1749 } |
|
1750 |
|
1751 void CPbk2ContactViewCustomListBoxData::SetGraphicsColumnL(TInt aColumn,TBool aIsGraphics) |
|
1752 // |
|
1753 // Sets whether a column shows graphics |
|
1754 // |
|
1755 { |
|
1756 TInt index; |
|
1757 FindColumnIndexOrAddL(index,aColumn); |
|
1758 At(index).iGraphics=aIsGraphics; |
|
1759 } |
|
1760 |
|
1761 TBool CPbk2ContactViewCustomListBoxData::ColumnIsNumber(TInt aColumn) const |
|
1762 // |
|
1763 // Return true if the column contains graphics |
|
1764 // |
|
1765 { |
|
1766 TInt index; |
|
1767 if (!FindColumnIndex(index,aColumn)) |
|
1768 return(EFalse); |
|
1769 return(iColumnArray->At(index).iNumberColumn); |
|
1770 } |
|
1771 |
|
1772 void CPbk2ContactViewCustomListBoxData::SetNumberColumnL(TInt aColumn,TBool aIsNumber) |
|
1773 // |
|
1774 // Sets whether a column shows graphics |
|
1775 // |
|
1776 { |
|
1777 TInt index; |
|
1778 FindColumnIndexOrAddL(index,aColumn); |
|
1779 At(index).iNumberColumn=aIsNumber; |
|
1780 } |
|
1781 |
|
1782 |
|
1783 TBool CPbk2ContactViewCustomListBoxData::ColumnIsOptional(TInt aColumn) const |
|
1784 // |
|
1785 // Return true if the column contains graphics |
|
1786 // |
|
1787 { |
|
1788 TInt index; |
|
1789 if (!FindColumnIndex(index,aColumn)) |
|
1790 return(EFalse); |
|
1791 return(iColumnArray->At(index).iOptional); |
|
1792 } |
|
1793 |
|
1794 void CPbk2ContactViewCustomListBoxData::SetOptionalColumnL(TInt aColumn,TBool aIsOptional) |
|
1795 // |
|
1796 // Sets whether a column shows graphics |
|
1797 // |
|
1798 { |
|
1799 TInt index; |
|
1800 FindColumnIndexOrAddL(index,aColumn); |
|
1801 At(index).iOptional=aIsOptional; |
|
1802 } |
|
1803 |
|
1804 CArrayPtr<CGulIcon>* CPbk2ContactViewCustomListBoxData::IconArray() const |
|
1805 // |
|
1806 // Return the list of icons |
|
1807 // |
|
1808 { |
|
1809 if (iExtension) |
|
1810 return iExtension->iIconArray; |
|
1811 else |
|
1812 return 0; |
|
1813 } |
|
1814 |
|
1815 void CPbk2ContactViewCustomListBoxData::SetIconArray(CArrayPtr<CGulIcon>* aArray) |
|
1816 // |
|
1817 // Passes ownership of the icon list aArray (assumes any previous list has been deleted by the caller) |
|
1818 // |
|
1819 { |
|
1820 if (iExtension) |
|
1821 iExtension->iIconArray=aArray; |
|
1822 else |
|
1823 { |
|
1824 aArray->ResetAndDestroy(); |
|
1825 delete aArray; |
|
1826 } |
|
1827 } |
|
1828 |
|
1829 CFont* CPbk2ContactViewCustomListBoxData::Font(const TListItemProperties& /*aItemProperties*/, TInt aColumn) const |
|
1830 { |
|
1831 return const_cast<CFont*>(this->ColumnFont(aColumn)); |
|
1832 #if NOT_NEEDED_IN_SERIES60 |
|
1833 TInt index; |
|
1834 if (!FindColumnIndex(index,aColumn)) |
|
1835 return(NULL); |
|
1836 TInt actualFontIndex=iColumnArray->At(index).iActualFontIndex; |
|
1837 if (actualFontIndex==KNoActualColumnFont) |
|
1838 return(NULL); |
|
1839 if ((aItemProperties.IsBold()) && (aItemProperties.IsItalics())) |
|
1840 { |
|
1841 return iBoldItalicFont.iFonts->At(actualFontIndex); |
|
1842 } |
|
1843 else if (aItemProperties.IsBold()) |
|
1844 { |
|
1845 return iBoldFont.iFonts->At(actualFontIndex); |
|
1846 } |
|
1847 else if (aItemProperties.IsItalics()) |
|
1848 { |
|
1849 return iItalicFont.iFonts->At(actualFontIndex); |
|
1850 } |
|
1851 else return iNormalFont.iFonts->At(actualFontIndex); |
|
1852 #endif |
|
1853 } |
|
1854 |
|
1855 void CPbk2ContactViewCustomListBoxData::DrawHighLight( CWindowGc& aGc, const TRect& aRect, TBool aHighlight, MAknsSkinInstance* aSkin ) const |
|
1856 { |
|
1857 // SERIES60 Highlight drawing. |
|
1858 if( aHighlight ) |
|
1859 { |
|
1860 // same as CFormattedCellListBoxData::DrawDefaultHighlight |
|
1861 CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View(); |
|
1862 TBool pressedDown = view->ItemDrawer()->Flags() & CListItemDrawer::EPressedDownState; |
|
1863 |
|
1864 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
1865 MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &aGc ); |
|
1866 if ( transApi ) |
|
1867 { |
|
1868 transApi->Invalidate(MAknListBoxTfxInternal::EListHighlight ); // This will remove the old bitmap |
|
1869 transApi->BeginRedraw( MAknListBoxTfxInternal::EListHighlight, aRect ); |
|
1870 transApi->StartDrawing( MAknListBoxTfxInternal::EListHighlight ); |
|
1871 aGc.SetClippingRect( view->ViewRect() ); |
|
1872 } |
|
1873 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
1874 // Try drawing the animated highlight |
|
1875 TBool highlightDrawn = EFalse; |
|
1876 if ( iExtension->iAnimation ) |
|
1877 { |
|
1878 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
1879 if ( transApi && transApi->VerifyKml() == KErrNone ) |
|
1880 { |
|
1881 iExtension->DeleteAnim(); |
|
1882 } |
|
1883 else |
|
1884 { |
|
1885 #endif |
|
1886 TAknLayoutRect topLeft; |
|
1887 topLeft.LayoutRect(aRect, SkinLayout::List_highlight_skin_placing__general__Line_2()); |
|
1888 |
|
1889 TAknLayoutRect bottomRight; |
|
1890 bottomRight.LayoutRect(aRect, SkinLayout::List_highlight_skin_placing__general__Line_5()); |
|
1891 |
|
1892 TRect outerRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); |
|
1893 |
|
1894 aGc.SetPenStyle(CGraphicsContext::ENullPen); |
|
1895 highlightDrawn = iExtension->SyncAndDrawAnim( aGc, outerRect ); |
|
1896 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
1897 } |
|
1898 #endif |
|
1899 } |
|
1900 |
|
1901 if (!highlightDrawn) |
|
1902 { |
|
1903 // Animated highlight was not available, use normal skinned |
|
1904 // rendering. |
|
1905 MAknsControlContext *cc = AknsDrawUtils::ControlContext( Control() ); |
|
1906 if (!cc) cc = SkinBackgroundContext(); |
|
1907 if (cc) |
|
1908 { |
|
1909 TAknLayoutRect topLeft; |
|
1910 topLeft.LayoutRect(aRect, SkinLayout::List_highlight_skin_placing__general__Line_2()); |
|
1911 |
|
1912 TAknLayoutRect bottomRight; |
|
1913 bottomRight.LayoutRect(aRect, SkinLayout::List_highlight_skin_placing__general__Line_5()); |
|
1914 |
|
1915 TRect outerRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); |
|
1916 TRect innerRect(topLeft.Rect().iBr, bottomRight.Rect().iTl); |
|
1917 aGc.SetPenStyle(CGraphicsContext::ENullPen); |
|
1918 |
|
1919 |
|
1920 if ( pressedDown ) |
|
1921 { |
|
1922 highlightDrawn = iExtension->DrawPressedDownEffect( aSkin, aGc, outerRect, innerRect ); |
|
1923 //view->ItemDrawer()->ClearFlags( CListItemDrawer::EItemPressedDown ); |
|
1924 } |
|
1925 else |
|
1926 { |
|
1927 highlightDrawn = AknsDrawUtils::DrawFrame( aSkin, |
|
1928 aGc, |
|
1929 outerRect, |
|
1930 innerRect, |
|
1931 *iExtension->iSkinHighlightFrameId, |
|
1932 *iExtension->iSkinHighlightFrameCenterId ); |
|
1933 } |
|
1934 } |
|
1935 } |
|
1936 |
|
1937 // Both animated highlight and normal highlight drawing have failed. |
|
1938 if (!highlightDrawn) |
|
1939 { |
|
1940 TAknLayoutRect highlightshadow; |
|
1941 TAknLayoutRect highlight; |
|
1942 highlightshadow.LayoutRect(aRect, AKN_LAYOUT_WINDOW_List_pane_highlight_graphics__various__Line_1(aRect)); |
|
1943 highlight.LayoutRect(aRect, AKN_LAYOUT_WINDOW_List_pane_highlight_graphics__various__Line_2(aRect)); |
|
1944 highlightshadow.DrawRect(aGc); |
|
1945 highlight.DrawRect(aGc); |
|
1946 } |
|
1947 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
1948 if ( transApi ) |
|
1949 { |
|
1950 aGc.CancelClippingRect(); |
|
1951 transApi->StopDrawing(); |
|
1952 transApi->EndRedraw( MAknListBoxTfxInternal::EListHighlight ); |
|
1953 } |
|
1954 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
1955 } |
|
1956 } |
|
1957 |
|
1958 |
|
1959 void CPbk2ContactViewCustomListBoxData::BitBltColored( CWindowGc& aGc, |
|
1960 TBool aHighlight, |
|
1961 const CGulIcon* aIcon, |
|
1962 TInt aSubcell, |
|
1963 TBool aColorIcon, |
|
1964 const TRect& aGraphicRect ) const |
|
1965 { |
|
1966 // see also eikfrlbd.cpp ( sigh ). |
|
1967 CFbsBitmap* bitmap( aIcon->Bitmap() ); |
|
1968 CFbsBitmap* mask( aIcon->Mask() ); |
|
1969 |
|
1970 // possibly colorskinnable icon. Check must be after SetSize() |
|
1971 TBool bw( bitmap->DisplayMode() == EGray2 ); |
|
1972 |
|
1973 // center graphics |
|
1974 TSize size=bitmap->SizeInPixels(); |
|
1975 TInt yDiff = ( aGraphicRect.Height() - size.iHeight ) / 2; |
|
1976 TInt xDiff = ( aGraphicRect.Width() - size.iWidth ) / 2; |
|
1977 TPoint posInBitmap( 0,0 ); |
|
1978 |
|
1979 if (xDiff < 0) // icon's width bigger than subcell's width |
|
1980 { // possible, if icon is not a aknicon |
|
1981 posInBitmap.iX = -xDiff; |
|
1982 xDiff = 0; |
|
1983 } |
|
1984 |
|
1985 if (yDiff < 0) // icon's height bigger than subcell's height |
|
1986 { |
|
1987 posInBitmap.iY = -yDiff; |
|
1988 yDiff = 0; |
|
1989 } |
|
1990 |
|
1991 TPoint bmpPos( aGraphicRect.iTl + TPoint( xDiff, yDiff ) ); |
|
1992 TRect sourcerect( posInBitmap, aGraphicRect.Size() ); |
|
1993 |
|
1994 if ( mask ) |
|
1995 { |
|
1996 TInt i( 0x01 ); |
|
1997 i = i << aSubcell; |
|
1998 if ( ((i & iExtension->iConditionalCells) && bw) || aColorIcon ) |
|
1999 { |
|
2000 aGc.BitBltMasked( bmpPos, |
|
2001 aHighlight ? iExtension->iHiliBmp : iExtension->iColorBmp, |
|
2002 TRect(posInBitmap, size), mask, ETrue ); |
|
2003 } |
|
2004 else |
|
2005 { |
|
2006 aGc.BitBltMasked( bmpPos, bitmap, sourcerect, mask, ETrue ); |
|
2007 } |
|
2008 } |
|
2009 else |
|
2010 { |
|
2011 aGc.BitBlt( bmpPos, bitmap ,sourcerect ); |
|
2012 } |
|
2013 } |
|
2014 |
|
2015 void CPbk2ContactViewCustomListBoxData::DrawSimpleL( const TListItemProperties& aItemProperties, |
|
2016 CWindowGc& aGc, |
|
2017 const TDesC* aText, |
|
2018 const TRect& aRect, |
|
2019 TBool aHighlight, |
|
2020 const TColors& aColors, |
|
2021 TInt aItemIndex ) const |
|
2022 { |
|
2023 |
|
2024 CEikListBox* listbox = static_cast<CEikListBox*>( iExtension->iControl ); |
|
2025 if ( listbox && !listbox->View()->ViewRect().Intersects( aRect ) ) |
|
2026 { |
|
2027 // outside of the clipping rect -> don't process this item |
|
2028 return; |
|
2029 } |
|
2030 |
|
2031 TInt lastColumn = Min( LastColumn(), KMaxColumn ); |
|
2032 TInt column=0; |
|
2033 TPtrC text; |
|
2034 TPtrC tempText; |
|
2035 |
|
2036 TRgb aTextColor = aHighlight ? aColors.iHighlightedText : aColors.iText; |
|
2037 |
|
2038 TBool markingMode = EFalse; |
|
2039 TRect itemRect( aRect ); |
|
2040 |
|
2041 if ( listbox->View() && listbox->View()->ItemDrawer() ) |
|
2042 { |
|
2043 if ( listbox->View()->ItemDrawer()->Flags() |
|
2044 & CListItemDrawer::EMarkingModeEnabled |
|
2045 && iExtension->iMarkingIconArray |
|
2046 && iExtension->iMarkingIconArray->Count() == 2 ) |
|
2047 { |
|
2048 markingMode = ETrue; |
|
2049 itemRect.iTl.iX += |
|
2050 AknLayoutScalable_Avkon::list_single_graphic_pane_t1( 0 ).LayoutLine().il; |
|
2051 } |
|
2052 } |
|
2053 |
|
2054 MAknsSkinInstance *skin = AknsUtils::SkinInstance(); |
|
2055 MAknsControlContext *cc = AknsDrawUtils::ControlContext( Control() ); |
|
2056 if (!cc) |
|
2057 { |
|
2058 cc = SkinBackgroundContext(); |
|
2059 } |
|
2060 |
|
2061 TAknTextLineLayout textLines[KMaxColumn]; |
|
2062 TBool rectClipped[KMaxColumn]; |
|
2063 |
|
2064 Mem::FillZ( &rectClipped[0], KMaxColumn * sizeof( TBool ) ); |
|
2065 |
|
2066 if ( iExtension->iSubCellsMightIntersect ) |
|
2067 { |
|
2068 CheckIfSubCellsIntersectL( &textLines[0], &rectClipped[0], *aText, itemRect ); |
|
2069 } |
|
2070 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2071 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc ); |
|
2072 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
2073 |
|
2074 if ( !listbox || !listbox->BackgroundDrawingSuppressed() ) |
|
2075 { |
|
2076 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2077 if ( transApi ) |
|
2078 { |
|
2079 transApi->StartDrawing( MAknListBoxTfxInternal::EListView ); |
|
2080 } |
|
2081 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
2082 |
|
2083 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2084 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
2085 |
|
2086 if ( listbox ) |
|
2087 { |
|
2088 AknsDrawUtils::Background( skin, cc, listbox, aGc, aRect ); |
|
2089 } |
|
2090 else |
|
2091 { |
|
2092 aGc.Clear(aRect); |
|
2093 } |
|
2094 |
|
2095 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2096 if ( transApi ) |
|
2097 { |
|
2098 transApi->StopDrawing(); |
|
2099 } |
|
2100 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
2101 } |
|
2102 |
|
2103 CEikListBox* list = static_cast<CEikListBox*>( iExtension->iControl ); |
|
2104 if ( iExtension->iCurrentRow < list->BottomItemIndex() ) |
|
2105 { |
|
2106 AknListUtils::DrawSeparator( aGc, aRect, aColors.iText, skin ); |
|
2107 } |
|
2108 DrawHighLight( aGc, aRect, aHighlight, skin ); |
|
2109 |
|
2110 if ( markingMode && !aItemProperties.IsSelectionHidden() ) |
|
2111 { |
|
2112 TAknLayoutRect layoutRect; |
|
2113 layoutRect.LayoutRect( aRect, |
|
2114 AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) ); |
|
2115 |
|
2116 aGc.SetPenColor( aColors.iText ); |
|
2117 aGc.SetPenStyle( CGraphicsContext::ESolidPen ); |
|
2118 |
|
2119 CGulIcon* icon = (*iExtension->iMarkingIconArray)[1]; // unchecked |
|
2120 |
|
2121 if ( listbox->View()->ItemIsSelected( iExtension->iCurrentRow ) ) |
|
2122 { |
|
2123 icon = (*iExtension->iMarkingIconArray)[0]; |
|
2124 } |
|
2125 |
|
2126 CFbsBitmap* bitmap = icon->Bitmap(); |
|
2127 |
|
2128 if ( bitmap ) |
|
2129 { |
|
2130 TSize size( bitmap->SizeInPixels() ); // set size if not already |
|
2131 TSize targetSize( layoutRect.Rect().Size() ); |
|
2132 |
|
2133 if ( size.iWidth != targetSize.iWidth && size.iHeight != targetSize.iHeight ) |
|
2134 { |
|
2135 AknIconUtils::SetSize( bitmap, targetSize, |
|
2136 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
2137 } |
|
2138 |
|
2139 aGc.BitBltMasked( layoutRect.Rect().iTl, bitmap, TRect( layoutRect.Rect().Size() ), icon->Mask(), EFalse ); |
|
2140 } |
|
2141 |
|
2142 } |
|
2143 |
|
2144 // The column draw loop |
|
2145 column = 0; |
|
2146 TInt subCellIndex = 0; |
|
2147 // Whether need to redraw the PopupCharacter |
|
2148 TBool redrawPopup = EFalse; |
|
2149 |
|
2150 if ( !iExtension ) { return; } |
|
2151 |
|
2152 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2153 if ( transApi ) |
|
2154 { |
|
2155 transApi->StartDrawing( MAknListBoxTfxInternal::EListItem ); |
|
2156 CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View(); |
|
2157 aGc.SetClippingRect( view->ViewRect() ); |
|
2158 } |
|
2159 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
2160 |
|
2161 for( column = 0; column <= lastColumn; column++ ) |
|
2162 { |
|
2163 TextUtils::ColumnText( text, column, aText ); |
|
2164 if ( text == KNullDesC ) { continue; } |
|
2165 |
|
2166 if ( iExtension->FindSLSubCellIndex( subCellIndex, column )!=0 ) { continue; } |
|
2167 |
|
2168 CGraphicsContext::TTextAlign align=ColumnAlignment(column); |
|
2169 TBool isLayoutAlignment = iExtension->ColumnLayoutAlignment(column); |
|
2170 |
|
2171 if ( iExtension->AtSL(subCellIndex).iSubCellType == CPbk2ContactViewCustomListBoxDataExtension::EEikSLText ) |
|
2172 { |
|
2173 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2174 |
|
2175 TRgb textColor( aTextColor ); |
|
2176 |
|
2177 if (aHighlight) |
|
2178 { |
|
2179 textColor = aColors.iHighlightedText; |
|
2180 aGc.SetBrushColor(aColors.iHighlightedBack); |
|
2181 } |
|
2182 if (AknsUtils::AvkonSkinEnabled()) |
|
2183 { |
|
2184 if (iExtension->iTextColor != NULL) |
|
2185 { |
|
2186 textColor = iExtension->iTextColor; |
|
2187 } |
|
2188 |
|
2189 if (aHighlight && iExtension->iHighlightedTextColor != NULL) |
|
2190 { |
|
2191 textColor = iExtension->iHighlightedTextColor; |
|
2192 } |
|
2193 } |
|
2194 |
|
2195 const CFont* rowAndColFont=RowAndColumnFont(iExtension->iCurrentRow,column); |
|
2196 const CFont* colFont=Font(aItemProperties, column); |
|
2197 const CFont* tempFont=(colFont) ? colFont : NULL; |
|
2198 const CFont* usedFont=(rowAndColFont) ? rowAndColFont : tempFont; |
|
2199 |
|
2200 TAknTextLineLayout textLineLayout = NULL; |
|
2201 |
|
2202 if ( rectClipped[column] ) |
|
2203 { |
|
2204 textLineLayout = textLines[column]; |
|
2205 } |
|
2206 else |
|
2207 { |
|
2208 // check if there are icons affecting this text layout |
|
2209 TInt gSC = iExtension->AtSL(subCellIndex).iConditionValue; // graphical subcell which might affect this text subcell |
|
2210 |
|
2211 if (gSC > -1) |
|
2212 { |
|
2213 TInt tempIndex; |
|
2214 while (gSC > -1) // when gSC == -1, we have found our graphical subcell |
|
2215 { |
|
2216 if (iExtension->FindSLSubCellIndex(tempIndex,gSC)!=0) break; |
|
2217 TextUtils::ColumnText(tempText,gSC, aText); |
|
2218 if (tempText != KNullDesC) |
|
2219 { |
|
2220 textLineLayout = iExtension->AtSL(tempIndex).iTextLayout; |
|
2221 break; |
|
2222 } |
|
2223 gSC = iExtension->AtSL(tempIndex).iConditionValue; |
|
2224 } |
|
2225 } |
|
2226 |
|
2227 if (gSC == -1) // no affecting icons -> use default layout |
|
2228 { |
|
2229 textLineLayout = iExtension->AtSL(subCellIndex).iTextLayout; |
|
2230 } |
|
2231 } |
|
2232 |
|
2233 |
|
2234 if( !isLayoutAlignment ) |
|
2235 { |
|
2236 switch(align) |
|
2237 { |
|
2238 case CGraphicsContext::ELeft : |
|
2239 { |
|
2240 textLineLayout.iJ = ELayoutAlignLeft; |
|
2241 } |
|
2242 break; |
|
2243 case CGraphicsContext::ECenter: |
|
2244 { |
|
2245 textLineLayout.iJ = ELayoutAlignCenter; |
|
2246 } |
|
2247 break; |
|
2248 case CGraphicsContext::ERight: |
|
2249 { |
|
2250 textLineLayout.iJ = ELayoutAlignRight; |
|
2251 } |
|
2252 break; |
|
2253 default: break; |
|
2254 }; |
|
2255 } |
|
2256 |
|
2257 TAknLayoutText textLayout; |
|
2258 textLayout.LayoutText( itemRect, textLineLayout, usedFont ); |
|
2259 TRect layoutedRect( itemRect); |
|
2260 |
|
2261 // *2 == leave some room for marquee |
|
2262 const TInt maxlen( KMaxColumnDataLength * 2 ); |
|
2263 TBuf<maxlen> convBuf = text.Left(maxlen); |
|
2264 |
|
2265 // Note that this potentially modifies the text so its lenght in pixels |
|
2266 // might increase. Therefore, this should always be done before |
|
2267 // wrapping/clipping text. In some cases, WordWrapListItem is called |
|
2268 // before coming here. Is it certain that it is not done for number subcells? |
|
2269 |
|
2270 // Do number conversion if required. |
|
2271 if ( ColumnIsNumber( column ) ) |
|
2272 { |
|
2273 AknTextUtils::LanguageSpecificNumberConversion( convBuf ); |
|
2274 } |
|
2275 |
|
2276 // Check whether logical to visual conversion should be done here or not. |
|
2277 TBool bidiConv = ETrue; // TODO |
|
2278 |
|
2279 // if (ColumnIsNumber(column)) |
|
2280 // { |
|
2281 // AknTextUtils::LanguageSpecificNumberConversion( convBuf ); |
|
2282 // } |
|
2283 |
|
2284 // marquee & clipping detection |
|
2285 TBool doesNotFit( aHighlight && |
|
2286 textLayout.Font()->TextWidthInPixels( convBuf ) > textLayout.TextRect().Width() ); |
|
2287 |
|
2288 // iClippedColumns was cleared in ::Draw() so no need to |
|
2289 // clear anything here |
|
2290 if ( doesNotFit ) |
|
2291 { |
|
2292 iExtension->iClippedColumns |= ( 1 << column ); |
|
2293 } |
|
2294 |
|
2295 TBool marqueeDisabled = ETrue; |
|
2296 if ( listbox ) |
|
2297 { |
|
2298 marqueeDisabled = listbox->View()->ItemDrawer()->Flags() |
|
2299 & CListItemDrawer::EDisableMarquee; |
|
2300 } |
|
2301 |
|
2302 if ( iExtension->IsMarqueeOn() && doesNotFit && !marqueeDisabled ) |
|
2303 { |
|
2304 iExtension->iMarquee->UseLogicalToVisualConversion( bidiConv ); |
|
2305 |
|
2306 if ( iExtension->iMarquee->DrawText( aGc, itemRect, textLineLayout, convBuf, usedFont, textColor ) ) |
|
2307 { |
|
2308 // all the loops have been executed |
|
2309 textLayout.DrawText( aGc, convBuf, bidiConv, textColor ); |
|
2310 } |
|
2311 } |
|
2312 else |
|
2313 { |
|
2314 if ( iExtension->iMarquee && marqueeDisabled ) |
|
2315 { |
|
2316 iExtension->iMarquee->Stop(); |
|
2317 } |
|
2318 |
|
2319 //Start of Code Added for PhoneBook2 |
|
2320 TBool isContactItem = IsContactAtListboxIndex( aItemIndex ); |
|
2321 if ( iSearchFilter.IsPredictiveActivated() && isContactItem ) |
|
2322 { |
|
2323 DrawEnhancedTextL( aItemProperties, aGc, aRect, convBuf, text, |
|
2324 textLayout, textLineLayout, bidiConv, usedFont, textColor ); |
|
2325 } |
|
2326 else |
|
2327 { |
|
2328 textLayout.DrawText( aGc, convBuf, bidiConv, textColor ); |
|
2329 } |
|
2330 |
|
2331 //End of Code Added for PhoneBook2 |
|
2332 } |
|
2333 |
|
2334 if ( iExtension->iPictoInterface ) |
|
2335 { |
|
2336 TRect pictoRect = textLayout.TextRect(); |
|
2337 pictoRect.Normalize(); |
|
2338 if ( convBuf.Length() && bidiConv ) |
|
2339 { |
|
2340 TInt maxWidth = pictoRect.Size().iWidth; |
|
2341 TInt charsCanBeDisplayed = textLayout.Font()->TextCount( |
|
2342 convBuf, maxWidth ); |
|
2343 if ( charsCanBeDisplayed < convBuf.Length() ) |
|
2344 { |
|
2345 TInt clipCharWidth = textLayout.Font()->CharWidthInPixels( |
|
2346 KEllipsis /*aClipChar*/ ); |
|
2347 // Check how many characters fit in given space with truncation char. |
|
2348 charsCanBeDisplayed = textLayout.Font()->TextCount( |
|
2349 convBuf, maxWidth - clipCharWidth ); |
|
2350 |
|
2351 // This is "avkon rule": should not insert ellipsis right after a space. |
|
2352 if ( charsCanBeDisplayed > 1 && |
|
2353 convBuf[charsCanBeDisplayed - 1] == ' ' && |
|
2354 convBuf[charsCanBeDisplayed - 2] != ' ' ) |
|
2355 { |
|
2356 charsCanBeDisplayed--; |
|
2357 } |
|
2358 |
|
2359 TInt pictoRectWidth = textLayout.Font()->TextWidthInPixels( |
|
2360 convBuf.Left( charsCanBeDisplayed ) ); |
|
2361 pictoRect.SetWidth( pictoRectWidth ); |
|
2362 } |
|
2363 } |
|
2364 |
|
2365 |
|
2366 iExtension->iPictoInterface->Interface()->DrawPictographsInText( |
|
2367 aGc, *usedFont, convBuf, |
|
2368 pictoRect, |
|
2369 usedFont->AscentInPixels(), |
|
2370 textLayout.Align(), 0 ); |
|
2371 } |
|
2372 |
|
2373 aGc.SetUnderlineStyle(EUnderlineOff); // disable underline after first text. |
|
2374 } |
|
2375 else if ( iExtension->AtSL(subCellIndex).iSubCellType == CPbk2ContactViewCustomListBoxDataExtension::EEikSLGraphic ) |
|
2376 { |
|
2377 TLex lex(text); |
|
2378 TInt index(0); |
|
2379 TInt err( lex.Val(index) ); |
|
2380 __ASSERT_DEBUG(err == KErrNone,Panic(EPanicColumnListInvalidBitmapIndexListBoxData)); |
|
2381 |
|
2382 TBool colorIcon( EFalse ); |
|
2383 if ( index == KColorIconFlag ) |
|
2384 { |
|
2385 if ( iExtension->iColorBmp && iExtension->iHiliBmp ) |
|
2386 { |
|
2387 colorIcon = ETrue; |
|
2388 } |
|
2389 index = KColorIconIdx; |
|
2390 } |
|
2391 |
|
2392 if ( !IconArray() ) |
|
2393 { |
|
2394 continue; |
|
2395 } |
|
2396 |
|
2397 if (aHighlight && (index > 0xffff)) |
|
2398 { |
|
2399 index = index >> 16; // we have different icon for highlight |
|
2400 } |
|
2401 |
|
2402 index = index & 0xffff; // mask off possible highlight icon |
|
2403 __ASSERT_DEBUG((index>=0 && index<IconArray()->Count()),Panic(EPanicColumnListInvalidBitmapIndexListBoxData)); |
|
2404 |
|
2405 TAknWindowLineLayout graphicLayout = iExtension->AtSL(subCellIndex).iGraphicLayout; |
|
2406 TAknLayoutRect graphicRect; |
|
2407 |
|
2408 graphicRect.LayoutRect( itemRect,graphicLayout ); |
|
2409 TSize graphicSize( graphicRect.Rect().Size() ); |
|
2410 |
|
2411 if (index>=0 && IconArray()) |
|
2412 { |
|
2413 CGulIcon* icon=(*IconArray())[index]; |
|
2414 CFbsBitmap* bitmap=icon->Bitmap(); |
|
2415 // Sometimes we get fake bitmap... |
|
2416 if ( bitmap ) |
|
2417 { |
|
2418 TSize size( bitmap->SizeInPixels() ); |
|
2419 |
|
2420 if (size.iWidth != graphicSize.iWidth && |
|
2421 size.iHeight != graphicSize.iHeight ) |
|
2422 { |
|
2423 AknIconUtils::SetSize( bitmap, |
|
2424 graphicSize, |
|
2425 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
2426 } |
|
2427 |
|
2428 BitBltColored( aGc, aHighlight, icon, column, colorIcon, graphicRect.Rect() ); |
|
2429 } |
|
2430 } |
|
2431 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
2432 } |
|
2433 if ( !redrawPopup && column > 1 ) |
|
2434 { |
|
2435 // column > 1 means that this contact has more than |
|
2436 // one column information to show, for excample name |
|
2437 // and phonenumber. In this case, perhaps need to |
|
2438 // redraw the popupCharacter |
|
2439 redrawPopup = ETrue; |
|
2440 } |
|
2441 } |
|
2442 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2443 if ( transApi ) |
|
2444 { |
|
2445 aGc.CancelClippingRect(); |
|
2446 transApi->StopDrawing(); |
|
2447 } |
|
2448 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
2449 |
|
2450 // When scroll name list quickly using scroll bar, the popup charcter |
|
2451 // will be overlaped by redraw of usrs' phonenumbers, to fix this, |
|
2452 // show the popup charcter after the refresh |
|
2453 if ( redrawPopup ) |
|
2454 { |
|
2455 CPbk2ContactViewListBox* contactViewListBox = static_cast<CPbk2ContactViewListBox*>( iExtension->iControl ); |
|
2456 if ( contactViewListBox ) |
|
2457 { |
|
2458 contactViewListBox->HandlePopupCharacter(&aGc, aRect); |
|
2459 } |
|
2460 } |
|
2461 } |
|
2462 |
|
2463 |
|
2464 void CPbk2ContactViewCustomListBoxData::Draw( const TListItemProperties& aItemProperties, |
|
2465 CWindowGc& aGc, |
|
2466 const TDesC* aText, |
|
2467 const TRect& aRect, |
|
2468 TBool aHighlight, |
|
2469 const TColors& aColors, |
|
2470 TInt aItemIndex ) const |
|
2471 { |
|
2472 if ( aHighlight ) |
|
2473 { |
|
2474 iExtension->iClippedColumns = 0; |
|
2475 } |
|
2476 |
|
2477 if ( UsesScalableLayoutData() ) |
|
2478 { |
|
2479 TRAP_IGNORE ( DrawSimpleL( aItemProperties, aGc, aText, aRect, aHighlight, aColors, aItemIndex ) ); |
|
2480 return; |
|
2481 } |
|
2482 |
|
2483 const CFont* font=ColumnFont(0); |
|
2484 CEikonEnv* eikonEnv=CEikonEnv::Static(); |
|
2485 if (font==NULL) |
|
2486 { |
|
2487 font=eikonEnv->NormalFont(); |
|
2488 } |
|
2489 |
|
2490 TInt lastColumn=LastColumn(); |
|
2491 if (lastColumn==KErrNotFound) |
|
2492 { |
|
2493 if ( font ) |
|
2494 { |
|
2495 // use draw text so that dont need to change pen color/style |
|
2496 aGc.UseFont( font ); |
|
2497 aGc.DrawText(TPtrC(),aRect,0); |
|
2498 aGc.DiscardFont(); |
|
2499 } |
|
2500 return; |
|
2501 } |
|
2502 |
|
2503 CEikListBox* listbox = static_cast<CEikListBox*>( iExtension->iControl ); |
|
2504 TBool markingMode = EFalse; |
|
2505 TRect itemRect( aRect ); |
|
2506 |
|
2507 if ( listbox->View() && listbox->View()->ItemDrawer() ) |
|
2508 { |
|
2509 if ( listbox->View()->ItemDrawer()->Flags() |
|
2510 & CListItemDrawer::EMarkingModeEnabled && |
|
2511 iExtension->iMarkingIconArray && |
|
2512 iExtension->iMarkingIconArray->Count() == 2 ) |
|
2513 { |
|
2514 markingMode = ETrue; |
|
2515 itemRect.iTl.iX += |
|
2516 AknLayoutScalable_Avkon::list_single_graphic_pane_t1( 0 ).LayoutLine().il; |
|
2517 } |
|
2518 } |
|
2519 |
|
2520 TInt extraVerticalSpace=(aRect.Height()-font->HeightInPixels()); |
|
2521 TInt baseLineOffset=extraVerticalSpace/2+font->AscentInPixels(); |
|
2522 TRect textRect( itemRect ); |
|
2523 TRect textMRect; // textrect with margins. |
|
2524 textRect.iBr.iX = itemRect.iTl.iX; |
|
2525 TInt column=0; |
|
2526 TPtrC text; |
|
2527 |
|
2528 TRgb aTextColor = aHighlight ? aColors.iHighlightedText : aColors.iText; |
|
2529 |
|
2530 // Turned the drawing to multipass algorithm, because optionalcolumns drawing will |
|
2531 // be too difficult to do without - and this is cleaner solution. |
|
2532 |
|
2533 // pass 1, figures out x-coordinates for columns. |
|
2534 TInt x = itemRect.iTl.iX; |
|
2535 |
|
2536 TBool mirror = AknLayoutUtils::LayoutMirrored(); |
|
2537 if (mirror) |
|
2538 { |
|
2539 x = itemRect.iBr.iX; |
|
2540 } |
|
2541 TInt maxx = x; |
|
2542 while(column <= lastColumn) |
|
2543 { |
|
2544 // order of instructions is important here, do not change. |
|
2545 if (!ColumnIsOptional(column)) |
|
2546 { |
|
2547 TRAP_IGNORE(SetColumnXL(column,maxx)); |
|
2548 |
|
2549 if (!mirror) |
|
2550 x = maxx + ColumnWidthPixel(column); |
|
2551 else |
|
2552 x = maxx - ColumnWidthPixel(column); |
|
2553 |
|
2554 maxx = x; |
|
2555 } |
|
2556 else |
|
2557 { |
|
2558 if (!mirror) |
|
2559 x -= ColumnWidthPixel(column); |
|
2560 else |
|
2561 x += ColumnWidthPixel(column); |
|
2562 |
|
2563 TRAP_IGNORE(SetColumnXL(column,x)); |
|
2564 } |
|
2565 column++; |
|
2566 } |
|
2567 |
|
2568 // pass 2, figures out the end x coordinates |
|
2569 column = 0; |
|
2570 TInt endx; |
|
2571 TInt tmpcolumn; |
|
2572 while(column <= lastColumn) |
|
2573 { |
|
2574 if (!mirror) |
|
2575 endx = ColumnX(column) + ColumnWidthPixel(column); |
|
2576 else |
|
2577 endx = ColumnX(column) - ColumnWidthPixel(column); |
|
2578 |
|
2579 if (!ColumnIsOptional(column)) |
|
2580 { |
|
2581 tmpcolumn = column+1; |
|
2582 while(ColumnIsOptional(tmpcolumn)) |
|
2583 { |
|
2584 TextUtils::ColumnText(text,tmpcolumn,aText); |
|
2585 if (text!=KNullDesC) endx = ColumnX(tmpcolumn); |
|
2586 tmpcolumn++; |
|
2587 } |
|
2588 } |
|
2589 if (!mirror) |
|
2590 { |
|
2591 __ASSERT_DEBUG(ColumnX(column)<endx,Panic(EPanicColumnListLayoutErrorListBoxData)); |
|
2592 } |
|
2593 else |
|
2594 { |
|
2595 __ASSERT_DEBUG(ColumnX(column)>endx,Panic(EPanicColumnListLayoutErrorListBoxData)); |
|
2596 } |
|
2597 TRAP_IGNORE(SetColumnEndXL(column,endx)); |
|
2598 |
|
2599 column++; |
|
2600 } |
|
2601 |
|
2602 // pass 3 drawing |
|
2603 |
|
2604 // SERIES60 Background drawing. |
|
2605 MAknsSkinInstance *skin = AknsUtils::SkinInstance(); |
|
2606 MAknsControlContext *cc = AknsDrawUtils::ControlContext( Control() ); |
|
2607 if (!cc) |
|
2608 { |
|
2609 cc = SkinBackgroundContext(); |
|
2610 } |
|
2611 |
|
2612 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2613 |
|
2614 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc ); |
|
2615 |
|
2616 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
2617 |
|
2618 if ( !listbox || !listbox->BackgroundDrawingSuppressed() ) |
|
2619 { |
|
2620 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2621 if ( transApi ) |
|
2622 { |
|
2623 transApi->StartDrawing( MAknListBoxTfxInternal::EListView ); |
|
2624 } |
|
2625 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
2626 |
|
2627 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2628 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
2629 |
|
2630 if ( listbox ) |
|
2631 { |
|
2632 AknsDrawUtils::Background( skin, cc, listbox, aGc, aRect ); |
|
2633 } |
|
2634 else |
|
2635 { |
|
2636 aGc.Clear(aRect); |
|
2637 } |
|
2638 |
|
2639 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2640 if ( transApi ) |
|
2641 { |
|
2642 transApi->StopDrawing(); |
|
2643 } |
|
2644 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
2645 } |
|
2646 |
|
2647 if ( iExtension->iCurrentRow < listbox->BottomItemIndex() ) |
|
2648 |
|
2649 { |
|
2650 AknListUtils::DrawSeparator( aGc, aRect, aColors.iText, skin ); |
|
2651 } |
|
2652 |
|
2653 // LISTBOX LINES NEED TO BE DRAWN HERE. |
|
2654 DrawHighLight( aGc, aRect, aHighlight, skin ); |
|
2655 |
|
2656 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2657 if ( transApi ) |
|
2658 { |
|
2659 transApi->StartDrawing( MAknListBoxTfxInternal::EListItem ); |
|
2660 CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View(); |
|
2661 aGc.SetClippingRect( view->ViewRect() ); |
|
2662 } |
|
2663 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
2664 |
|
2665 if ( markingMode && !aItemProperties.IsSelectionHidden() ) |
|
2666 { |
|
2667 TAknLayoutRect layoutRect; |
|
2668 layoutRect.LayoutRect( |
|
2669 aRect, |
|
2670 AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) ); |
|
2671 |
|
2672 aGc.SetPenColor( aColors.iText ); |
|
2673 aGc.SetPenStyle( CGraphicsContext::ESolidPen ); |
|
2674 |
|
2675 CGulIcon* icon = (*iExtension->iMarkingIconArray)[1]; // unchecked |
|
2676 |
|
2677 if ( listbox->View()->ItemIsSelected( iExtension->iCurrentRow ) ) |
|
2678 { |
|
2679 icon = (*iExtension->iMarkingIconArray)[0]; |
|
2680 } |
|
2681 |
|
2682 CFbsBitmap* bitmap = icon->Bitmap(); |
|
2683 |
|
2684 if ( bitmap ) |
|
2685 { |
|
2686 TSize size( bitmap->SizeInPixels() ); // set size if not already |
|
2687 TSize targetSize( layoutRect.Rect().Size() ); |
|
2688 |
|
2689 if ( size.iWidth != targetSize.iWidth && |
|
2690 size.iHeight != targetSize.iHeight ) |
|
2691 { |
|
2692 AknIconUtils::SetSize( |
|
2693 bitmap, |
|
2694 targetSize, |
|
2695 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
2696 } |
|
2697 |
|
2698 aGc.BitBltMasked( layoutRect.Rect().iTl, |
|
2699 bitmap, |
|
2700 TRect( layoutRect.Rect().Size() ), |
|
2701 icon->Mask(), |
|
2702 EFalse ); |
|
2703 } |
|
2704 } |
|
2705 |
|
2706 // The column draw loop |
|
2707 column = 0; |
|
2708 FOREVER |
|
2709 { |
|
2710 if (column > lastColumn) break; |
|
2711 |
|
2712 if (!mirror) |
|
2713 { |
|
2714 textRect.iTl.iX = ColumnX(column); |
|
2715 textRect.iBr.iX = ColumnEndX(column); |
|
2716 } |
|
2717 else |
|
2718 { |
|
2719 textRect.iBr.iX = ColumnX(column); |
|
2720 textRect.iTl.iX = ColumnEndX(column); |
|
2721 } |
|
2722 |
|
2723 TextUtils::ColumnText(text,column,aText); |
|
2724 |
|
2725 TBool exit_condition = textRect.iBr.iX==textRect.iTl.iX; |
|
2726 if (ColumnIsOptional(column) && text == KNullDesC) |
|
2727 { |
|
2728 exit_condition = ETrue; |
|
2729 } |
|
2730 |
|
2731 if (!exit_condition) |
|
2732 { |
|
2733 // Margins support. |
|
2734 TMargins m = ColumnMargins(column); |
|
2735 textMRect.SetRect(textRect.iTl+TSize(m.iLeft,m.iTop),textRect.Size()-TSize(m.iRight+m.iLeft,m.iBottom+m.iTop)); |
|
2736 // end of margins support. |
|
2737 |
|
2738 CGraphicsContext::TTextAlign align=ColumnAlignment(column); |
|
2739 |
|
2740 if (!ColumnIsGraphics(column)) |
|
2741 { |
|
2742 |
|
2743 //if (align == CGraphicsContext::ECenter || align == CGraphicsContext::ERight) |
|
2744 // { |
|
2745 // textMRect.iTl.iX+=1; |
|
2746 // textMRect.iBr.iX+=1; |
|
2747 // } |
|
2748 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2749 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
2750 aGc.SetPenColor(aTextColor); |
|
2751 SetUnderlineStyle( aItemProperties, aGc, column ); |
|
2752 |
|
2753 if (aHighlight) |
|
2754 { |
|
2755 aGc.SetPenColor(aColors.iHighlightedText); |
|
2756 aGc.SetBrushColor(aColors.iHighlightedBack); |
|
2757 } |
|
2758 |
|
2759 if (AknsUtils::AvkonSkinEnabled() && iExtension) |
|
2760 { |
|
2761 if (iExtension->iTextColor != NULL) |
|
2762 { |
|
2763 aGc.SetPenColor(iExtension->iTextColor); |
|
2764 } |
|
2765 |
|
2766 if (aHighlight && iExtension->iHighlightedTextColor != NULL) |
|
2767 { |
|
2768 aGc.SetPenColor(iExtension->iHighlightedTextColor); |
|
2769 } |
|
2770 } |
|
2771 |
|
2772 const CFont* rowAndColFont=RowAndColumnFont(iExtension->iCurrentRow,column); |
|
2773 const CFont* colFont=Font(aItemProperties, column); |
|
2774 const CFont* tempFont=(colFont) ? colFont : font; |
|
2775 const CFont* usedFont=(rowAndColFont) ? rowAndColFont : tempFont; |
|
2776 |
|
2777 aGc.UseFont(usedFont); |
|
2778 |
|
2779 // baseline calc needed for each column because of margins. |
|
2780 baseLineOffset = ColumnBaselinePos(column); |
|
2781 if (!baseLineOffset) |
|
2782 { |
|
2783 baseLineOffset = (textMRect.Size().iHeight-usedFont->HeightInPixels())/2 + usedFont->AscentInPixels(); |
|
2784 } |
|
2785 baseLineOffset -= m.iTop; |
|
2786 |
|
2787 // SERIES60 LAF |
|
2788 TBuf<200+KAknBidiExtraSpacePerLine> clipbuf; |
|
2789 |
|
2790 TInt clipgap = ColumnTextClipGap(column); |
|
2791 |
|
2792 TBool clipped = AknBidiTextUtils::ConvertToVisualAndClip( |
|
2793 text.Left(200), |
|
2794 clipbuf, |
|
2795 *usedFont, |
|
2796 textMRect.Size().iWidth, |
|
2797 textMRect.Size().iWidth+clipgap); |
|
2798 |
|
2799 if (clipped) |
|
2800 { |
|
2801 if (!mirror) |
|
2802 { |
|
2803 textMRect.iBr.iX+=clipgap; |
|
2804 } |
|
2805 else |
|
2806 { |
|
2807 textMRect.iTl.iX-=clipgap; |
|
2808 } |
|
2809 |
|
2810 if ( aHighlight ) |
|
2811 { |
|
2812 iExtension->iClippedColumns |= ( 1 << column ); |
|
2813 } |
|
2814 } |
|
2815 |
|
2816 if (ColumnIsNumber(column)) |
|
2817 { |
|
2818 AknTextUtils::LanguageSpecificNumberConversion(clipbuf); |
|
2819 } |
|
2820 |
|
2821 // end of SERIES60 LAF |
|
2822 |
|
2823 CAknMarqueeControl* marquee = |
|
2824 column == 1 || column == 3 ? iExtension->iMarquee : |
|
2825 iExtension->i2ndLineMarquee; |
|
2826 |
|
2827 TBool marqueeDisabled = |
|
2828 listbox->View()->ItemDrawer()->Flags() & CListItemDrawer::EDisableMarquee; |
|
2829 |
|
2830 if ( iExtension->IsMarqueeOn() && aHighlight && clipped && !marqueeDisabled ) |
|
2831 { |
|
2832 // Bidi conversion has already been done. |
|
2833 marquee->UseLogicalToVisualConversion( EFalse ); |
|
2834 |
|
2835 if ( marquee->DrawText( aGc, textMRect, text, baseLineOffset, align, *usedFont ) ) |
|
2836 { |
|
2837 // All the loops have been executed -> the text needs to be truncated. |
|
2838 aGc.DrawText( clipbuf, textMRect, baseLineOffset, align, 0 ); |
|
2839 } |
|
2840 } |
|
2841 else |
|
2842 { |
|
2843 if ( marquee && marqueeDisabled ) |
|
2844 { |
|
2845 marquee->Stop(); |
|
2846 } |
|
2847 |
|
2848 aGc.DrawText( clipbuf, textMRect, baseLineOffset, align, 0 ); |
|
2849 } |
|
2850 |
|
2851 if ( iExtension->iPictoInterface ) |
|
2852 { |
|
2853 iExtension->iPictoInterface->Interface()->DrawPictographsInText( |
|
2854 aGc, *usedFont, clipbuf, textMRect, baseLineOffset, align, 0 ); |
|
2855 } |
|
2856 |
|
2857 aGc.SetUnderlineStyle(EUnderlineOff); // disable underline after first text. |
|
2858 } |
|
2859 else |
|
2860 { |
|
2861 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2862 if (aHighlight /*&& (LastColumn()==0) */ ) |
|
2863 { |
|
2864 aGc.SetBrushColor(aColors.iHighlightedBack); |
|
2865 } |
|
2866 |
|
2867 TLex lex(text); |
|
2868 TInt index; |
|
2869 TInt err = lex.Val(index); |
|
2870 __ASSERT_DEBUG(err==KErrNone,Panic(EPanicColumnListInvalidBitmapIndexListBoxData)); |
|
2871 |
|
2872 if ( index == KColorIconFlag ) |
|
2873 { |
|
2874 index = KColorIconIdx; |
|
2875 } |
|
2876 |
|
2877 if ( !err ) |
|
2878 { |
|
2879 if ( !IconArray() ) |
|
2880 { |
|
2881 ++column; |
|
2882 continue; |
|
2883 } |
|
2884 |
|
2885 __ASSERT_DEBUG((index>=0 && index<IconArray()->Count()),Panic(EPanicColumnListInvalidBitmapIndexListBoxData)); |
|
2886 TRect bmpRect; |
|
2887 bmpRect.iTl=textMRect.iTl; |
|
2888 if (index>=0 && IconArray()) |
|
2889 { |
|
2890 CGulIcon* icon=(*IconArray())[index]; |
|
2891 |
|
2892 if ( iExtension |
|
2893 && iExtension->iSubCellIconSize[column] != TSize(0,0) ) |
|
2894 { |
|
2895 TSize wanted( iExtension->iSubCellIconSize[column] ); |
|
2896 TSize got( icon->Bitmap()->SizeInPixels() ); |
|
2897 |
|
2898 // correct w or h is enough |
|
2899 if ( wanted.iWidth != got.iWidth |
|
2900 && wanted.iHeight != got.iHeight ) |
|
2901 { |
|
2902 AknIconUtils::SetSize( icon->Bitmap(), |
|
2903 wanted, |
|
2904 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
2905 } |
|
2906 } |
|
2907 |
|
2908 CFbsBitmap* bitmap=icon->Bitmap(); |
|
2909 |
|
2910 TSize size(bitmap->SizeInPixels()); |
|
2911 |
|
2912 // next two lines are SERIES60 additions |
|
2913 if (size.iWidth>textMRect.Size().iWidth) size.iWidth = textMRect.Size().iWidth; |
|
2914 if (size.iHeight>textMRect.Size().iHeight) size.iHeight = textMRect.Size().iHeight; |
|
2915 |
|
2916 TPoint bmpPos(textMRect.iTl); // was aRect, I dunno why |
|
2917 bmpPos.iY+=(textMRect.Height()-size.iHeight)>>1; // was aRect too... |
|
2918 switch (align) |
|
2919 { |
|
2920 case ELeft: |
|
2921 break; |
|
2922 case ECenter: |
|
2923 bmpPos.iX+=(textMRect.Width()-size.iWidth)>>1; |
|
2924 break; |
|
2925 case ERight: |
|
2926 bmpPos.iX=textMRect.iBr.iX-size.iWidth; |
|
2927 break; |
|
2928 } |
|
2929 bmpRect.SetRect(bmpPos,size); |
|
2930 TPoint posInBitmap; |
|
2931 posInBitmap += bitmap->SizeInPixels() - textMRect.Size(); |
|
2932 posInBitmap.iX >>= 1; |
|
2933 posInBitmap.iY >>= 1; |
|
2934 if (posInBitmap.iX < 0) posInBitmap.iX = 0; |
|
2935 if (posInBitmap.iY < 0) posInBitmap.iY = 0; |
|
2936 TRect rect(posInBitmap,textMRect.Size()); |
|
2937 |
|
2938 |
|
2939 if (icon->Mask()) |
|
2940 { |
|
2941 aGc.BitBltMasked( bmpPos, bitmap, rect, icon->Mask(), ETrue ); |
|
2942 } |
|
2943 else |
|
2944 { |
|
2945 aGc.BitBlt(bmpPos, bitmap,rect); |
|
2946 } |
|
2947 } |
|
2948 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2949 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
2950 } |
|
2951 } |
|
2952 } |
|
2953 |
|
2954 ++column; |
|
2955 } |
|
2956 |
|
2957 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
2958 if ( transApi ) |
|
2959 { |
|
2960 aGc.CancelClippingRect(); |
|
2961 transApi->StopDrawing(); |
|
2962 } |
|
2963 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
2964 } |
|
2965 |
|
2966 |
|
2967 void CPbk2ContactViewCustomListBoxData::AddColumnL(TInt aColumn) |
|
2968 // |
|
2969 // Add a column's worth of data |
|
2970 // |
|
2971 { |
|
2972 SColumn column; |
|
2973 column.iColumn=aColumn; |
|
2974 column.iWidth=0; |
|
2975 TMargins m = {0,0,0,0}; |
|
2976 column.iMargins=m; |
|
2977 column.iBaseFont=NULL; |
|
2978 column.iActualFontIndex=KNoActualColumnFont; |
|
2979 column.iGraphics=EFalse; |
|
2980 column.iNumberColumn = EFalse; |
|
2981 column.iOptional=EFalse; |
|
2982 column.iBaseline = 0; |
|
2983 column.iAlign=CGraphicsContext::ELeft; |
|
2984 column.iSeparator=CGraphicsContext::ENullPen; |
|
2985 column.iTextClipGap = 0; |
|
2986 TKeyArrayFix key(0,ECmpTInt); |
|
2987 iColumnArray->InsertIsqL(column,key); |
|
2988 } |
|
2989 |
|
2990 CPbk2ContactViewCustomListBoxData::SColumn& CPbk2ContactViewCustomListBoxData::At(TInt aArrayIndex) |
|
2991 // |
|
2992 // Return a column of data |
|
2993 // |
|
2994 { |
|
2995 __ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iColumnArray->Count(),Panic(EPanicPreCond_OutOfRangeListBoxData)); |
|
2996 return(iColumnArray->At(aArrayIndex)); |
|
2997 } |
|
2998 |
|
2999 const CPbk2ContactViewCustomListBoxData::SColumn& CPbk2ContactViewCustomListBoxData::At(TInt aArrayIndex) const |
|
3000 // |
|
3001 // Return a column of data |
|
3002 // |
|
3003 { |
|
3004 __ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iColumnArray->Count(),Panic(EPanicPreCond_OutOfRangeListBoxData)); |
|
3005 return(iColumnArray->At(aArrayIndex)); |
|
3006 } |
|
3007 |
|
3008 TBool CPbk2ContactViewCustomListBoxData::FindColumnIndex(TInt& aArrayIndex,TInt aColumn) const |
|
3009 // |
|
3010 // Find a column if it has been set |
|
3011 // |
|
3012 { |
|
3013 if (aColumn<0 || iColumnArray->Count()==0) |
|
3014 return EFalse; |
|
3015 TKeyArrayFix key(0,ECmpTInt); |
|
3016 SColumn column; |
|
3017 column.iColumn=aColumn; |
|
3018 |
|
3019 // Returns zero if key was found, otherwise non-zero |
|
3020 TInt ret = iColumnArray->FindIsq(column,key,aArrayIndex); |
|
3021 return (ret ? EFalse: ETrue); |
|
3022 } |
|
3023 |
|
3024 void CPbk2ContactViewCustomListBoxData::FindColumnIndexOrAddL(TInt& aArrayIndex,TInt aColumn) |
|
3025 // |
|
3026 // Find a column or add it |
|
3027 // |
|
3028 { |
|
3029 if (!FindColumnIndex(aArrayIndex,aColumn)) |
|
3030 { |
|
3031 AddColumnL(aColumn); |
|
3032 FindColumnIndex(aArrayIndex,aColumn); |
|
3033 } |
|
3034 } |
|
3035 |
|
3036 TInt CPbk2ContactViewCustomListBoxData::AddActualFontL(const CFont* aBaseFont) |
|
3037 { |
|
3038 if (!iNormalFont.iFonts) |
|
3039 { |
|
3040 iNormalFont.iFonts=new (ELeave) CArrayPtrFlat<CFont> (1); |
|
3041 iBoldFont.iFonts=new (ELeave) CArrayPtrFlat<CFont> (1); |
|
3042 iItalicFont.iFonts=new (ELeave) CArrayPtrFlat<CFont> (1); |
|
3043 iBoldItalicFont.iFonts=new (ELeave) CArrayPtrFlat<CFont> (1); |
|
3044 } |
|
3045 |
|
3046 // Reserves extra space for each font array. |
|
3047 TInt fontCount=iNormalFont.iFonts->Count()+1; |
|
3048 iNormalFont.iFonts->SetReserveL(fontCount); |
|
3049 iBoldFont.iFonts->SetReserveL(fontCount); |
|
3050 iItalicFont.iFonts->SetReserveL(fontCount); |
|
3051 iBoldItalicFont.iFonts->SetReserveL(fontCount); |
|
3052 |
|
3053 // Add Fonts. |
|
3054 TFontStyle style=aBaseFont->FontSpecInTwips().iFontStyle; |
|
3055 ConstructFontL(aBaseFont, style, iNormalFont); |
|
3056 ConstructFontL(aBaseFont, style, iBoldFont); |
|
3057 ConstructFontL(aBaseFont, style, iItalicFont); |
|
3058 ConstructFontL(aBaseFont, style, iBoldItalicFont); |
|
3059 |
|
3060 return fontCount-1; |
|
3061 } |
|
3062 |
|
3063 TBool CPbk2ContactViewCustomListBoxData::MakeColumnRect( TInt aColumn, TRect& aRect ) |
|
3064 // Returns given column rect |
|
3065 { |
|
3066 TInt lastColumn = LastColumn(); |
|
3067 if ( ( aColumn < 0 ) || ( aColumn > lastColumn ) ) return EFalse; |
|
3068 |
|
3069 TRect colRect(aRect); // we need to save original item rect |
|
3070 for ( TInt column=0; column<lastColumn; column++ ) |
|
3071 // loop throuhg columns except last one (scroll bar eats small rect from it) |
|
3072 { |
|
3073 TInt colWidth = ColumnWidthPixel( column ); |
|
3074 colRect.iBr.iX = colRect.iTl.iX + colWidth; // set column rect width |
|
3075 if ( column == aColumn ) break; // if the column, quit |
|
3076 aRect.iTl.iX += colWidth; // shrink origial rect by column with |
|
3077 colRect = aRect; // set colRect for the LAST column |
|
3078 } |
|
3079 aRect = colRect; |
|
3080 |
|
3081 return ETrue; |
|
3082 } |
|
3083 |
|
3084 void CPbk2ContactViewCustomListBoxData::SetColumnFontForRowL(TInt aRow, |
|
3085 TInt aColumn, |
|
3086 const CFont* aFont) |
|
3087 { |
|
3088 if (!iExtension) return; |
|
3089 TInt index = 0; |
|
3090 iExtension->FindRowAndColumnIndexOrAddL(index,aRow,aColumn); |
|
3091 iExtension->At(index).iFont=aFont; |
|
3092 } |
|
3093 |
|
3094 const CFont* |
|
3095 CPbk2ContactViewCustomListBoxData::RowAndColumnFont(TInt aRow,TInt aColumn) const |
|
3096 { |
|
3097 if (!iExtension) return 0; |
|
3098 TInt index = 0; |
|
3099 if (iExtension->FindRowAndColumnIndex(index,aRow,aColumn)!=0) |
|
3100 return 0; |
|
3101 return(iExtension->At(index).iFont); |
|
3102 } |
|
3103 |
|
3104 void CPbk2ContactViewCustomListBoxData::SetCurrentItemIndex(TInt aIndex) |
|
3105 { |
|
3106 if( iExtension->iCurrentRow != aIndex ) |
|
3107 { |
|
3108 iExtension->iAnimFlags.Set( CPbk2ContactViewCustomListBoxDataExtension::EFlagUpdateBg ); |
|
3109 } |
|
3110 iExtension->iCurrentRow = aIndex; |
|
3111 } |
|
3112 |
|
3113 |
|
3114 // --------------------------------------------------------------------------- |
|
3115 // Wraps the text drawing functinality with & without marquee into one |
|
3116 // function, so that inherited classes can modify their own drawing |
|
3117 // behaviour more easily. |
|
3118 // --------------------------------------------------------------------------- |
|
3119 // |
|
3120 void CPbk2ContactViewCustomListBoxData::DrawText( |
|
3121 CWindowGc& aGc, |
|
3122 const TRect& aTextRect, |
|
3123 const TDesC& aText, |
|
3124 const TDesC& aClippedText, |
|
3125 const TInt aBaselineOffset, |
|
3126 const CGraphicsContext::TTextAlign aAlign, |
|
3127 const CFont& aFont, |
|
3128 const TBool aHighlight, |
|
3129 const TBool aIsTextClipped ) const |
|
3130 { |
|
3131 TBool marqueeDisabled = |
|
3132 static_cast<CEikListBox*>( |
|
3133 Control() )->View()->ItemDrawer()->Flags() & CListItemDrawer::EDisableMarquee; |
|
3134 |
|
3135 if ( iExtension->IsMarqueeOn() && aHighlight && aIsTextClipped && !marqueeDisabled ) |
|
3136 { |
|
3137 if ( iExtension->iMarquee->DrawText( aGc, aTextRect, aText, aBaselineOffset, aAlign, aFont ) ) |
|
3138 { |
|
3139 // All the loops have been executed -> the text needs to be truncated. |
|
3140 aGc.DrawText( aClippedText, aTextRect, aBaselineOffset, aAlign, 0 ); |
|
3141 } |
|
3142 } |
|
3143 else |
|
3144 { |
|
3145 if ( iExtension->iMarquee && marqueeDisabled ) |
|
3146 { |
|
3147 iExtension->iMarquee->Stop(); |
|
3148 } |
|
3149 |
|
3150 aGc.DrawText( aClippedText, aTextRect, aBaselineOffset, aAlign, 0 ); |
|
3151 } |
|
3152 } |
|
3153 |
|
3154 |
|
3155 void CPbk2ContactViewCustomListBoxData::SetMarqueeParams(const TInt aLoops, const TInt aScrollAmount, const TInt aScrollDelay) |
|
3156 { |
|
3157 if ( iExtension->iMarquee ) |
|
3158 { |
|
3159 iExtension->iMarquee->SetLoops( aLoops ); |
|
3160 iExtension->iMarquee->SetSpeedInPixels( aScrollAmount ); |
|
3161 iExtension->iMarquee->SetDelay( aScrollDelay ); |
|
3162 } |
|
3163 if ( iExtension->i2ndLineMarquee ) |
|
3164 { |
|
3165 iExtension->i2ndLineMarquee->SetLoops( aLoops ); |
|
3166 iExtension->i2ndLineMarquee->SetSpeedInPixels( aScrollAmount ); |
|
3167 iExtension->i2ndLineMarquee->SetDelay( aScrollDelay ); |
|
3168 } |
|
3169 } |
|
3170 |
|
3171 void CPbk2ContactViewCustomListBoxData::SetMarqueeParams(const TInt aLoops, const TInt aScrollAmount, |
|
3172 const TInt aScrollDelay, const TInt aInterval) |
|
3173 { |
|
3174 if ( iExtension->iMarquee ) |
|
3175 { |
|
3176 iExtension->iMarquee->SetInterval( aInterval ); |
|
3177 iExtension->i2ndLineMarquee->SetInterval( aInterval ); |
|
3178 SetMarqueeParams( aLoops, aScrollAmount, aScrollDelay ); |
|
3179 } |
|
3180 } |
|
3181 |
|
3182 |
|
3183 |
|
3184 void CPbk2ContactViewCustomListBoxData::SetSubCellIconSize(TInt aIndex, TSize aSize) |
|
3185 { |
|
3186 if (iExtension && aIndex < 6 && aIndex >= 0) |
|
3187 { |
|
3188 iExtension->iSubCellIconSize[aIndex] = aSize; |
|
3189 } |
|
3190 } |
|
3191 |
|
3192 TSize CPbk2ContactViewCustomListBoxData::GetSubCellIconSize(TInt aIndex) |
|
3193 { |
|
3194 if (iExtension && aIndex < 6 && aIndex >= 0) |
|
3195 { |
|
3196 return iExtension->iSubCellIconSize[aIndex]; |
|
3197 } |
|
3198 return TSize(0,0); |
|
3199 } |
|
3200 |
|
3201 // ----------------------------------------------------------------------------- |
|
3202 // CPbk2ContactViewCustomListBoxData::HighlightAnim |
|
3203 // ----------------------------------------------------------------------------- |
|
3204 // |
|
3205 const CAknsEffectAnim* CPbk2ContactViewCustomListBoxData::HighlightAnim() const |
|
3206 { |
|
3207 if( iExtension ) |
|
3208 return iExtension->iAnimation; |
|
3209 return NULL; |
|
3210 } |
|
3211 |
|
3212 // ----------------------------------------------------------------------------- |
|
3213 // AboutToDrawHighlightAnim |
|
3214 // ----------------------------------------------------------------------------- |
|
3215 // |
|
3216 void CPbk2ContactViewCustomListBoxData::AboutToDrawHighlightAnim() const |
|
3217 { |
|
3218 if( !iExtension ) |
|
3219 { |
|
3220 return; |
|
3221 } |
|
3222 if( !iExtension->iAnimation || !iExtension->iControl ) |
|
3223 { |
|
3224 return; |
|
3225 } |
|
3226 |
|
3227 CEikListBox* list = static_cast<CEikListBox*>( iExtension->iControl ); |
|
3228 CListBoxView* view = list->View(); |
|
3229 if( !view ) |
|
3230 { |
|
3231 return; |
|
3232 } |
|
3233 |
|
3234 if( view->CurrentItemIndex() != iExtension->iCurrentRow ) |
|
3235 { |
|
3236 iExtension->iAnimFlags.Set( CPbk2ContactViewCustomListBoxDataExtension::EFlagUpdateBg ); |
|
3237 iExtension->iCurrentRow = view->CurrentItemIndex(); |
|
3238 } |
|
3239 |
|
3240 iExtension->SyncAnim( iExtension->iAnimSize ); |
|
3241 } |
|
3242 |
|
3243 // ----------------------------------------------------------------------------- |
|
3244 // CPbk2ContactViewCustomListBoxData::SetHighlightAnimBackgroundDrawer |
|
3245 // ----------------------------------------------------------------------------- |
|
3246 // |
|
3247 void CPbk2ContactViewCustomListBoxData::SetHighlightAnimBackgroundDrawer( |
|
3248 MColumnListBoxAnimBackgroundDrawer* aDrawer ) |
|
3249 { |
|
3250 if( iExtension ) |
|
3251 { |
|
3252 iExtension->iHighlightBgDrawer = aDrawer; |
|
3253 } |
|
3254 } |
|
3255 |
|
3256 // ----------------------------------------------------------------------------- |
|
3257 // CPbk2ContactViewCustomListBoxData::SetItemCellSize |
|
3258 // ----------------------------------------------------------------------------- |
|
3259 // |
|
3260 void CPbk2ContactViewCustomListBoxData::SetItemCellSize( const TSize& aSizeInPixels ) |
|
3261 { |
|
3262 if( iExtension ) |
|
3263 { |
|
3264 if( iExtension->iAnimSize != aSizeInPixels ) |
|
3265 { |
|
3266 iExtension->Play(); |
|
3267 } |
|
3268 iExtension->iAnimSize = aSizeInPixels; |
|
3269 } |
|
3270 } |
|
3271 |
|
3272 // ----------------------------------------------------------------------------- |
|
3273 // CPbk2ContactViewCustomListBoxData::HasHighlightAnim |
|
3274 // ----------------------------------------------------------------------------- |
|
3275 // |
|
3276 TBool CPbk2ContactViewCustomListBoxData::HasHighlightAnim() const |
|
3277 { |
|
3278 if( !iExtension ) |
|
3279 return EFalse; |
|
3280 if( !iExtension->iAnimation ) |
|
3281 return EFalse; |
|
3282 return ETrue; |
|
3283 } |
|
3284 |
|
3285 // ----------------------------------------------------------------------------- |
|
3286 // CPbk2ContactViewCustomListBoxData::DrawHighlightAnim |
|
3287 // ----------------------------------------------------------------------------- |
|
3288 // |
|
3289 TBool CPbk2ContactViewCustomListBoxData::DrawHighlightAnim( |
|
3290 CBitmapContext& aGc, const TRect& aRect ) const |
|
3291 { |
|
3292 if( !iExtension ) |
|
3293 return EFalse; |
|
3294 |
|
3295 if( !iExtension->iAnimation ) |
|
3296 return EFalse; |
|
3297 |
|
3298 return iExtension->SyncAndDrawAnim( aGc, aRect ); |
|
3299 } |
|
3300 |
|
3301 // ----------------------------------------------------------------------------- |
|
3302 // CPbk2ContactViewCustomListBoxData::FocusGained |
|
3303 // ----------------------------------------------------------------------------- |
|
3304 // |
|
3305 void CPbk2ContactViewCustomListBoxData::FocusGained() |
|
3306 { |
|
3307 iExtension->FocusGained(); |
|
3308 } |
|
3309 |
|
3310 // ----------------------------------------------------------------------------- |
|
3311 // CPbk2ContactViewCustomListBoxData::FocusLost |
|
3312 // ----------------------------------------------------------------------------- |
|
3313 // |
|
3314 void CPbk2ContactViewCustomListBoxData::FocusLost() |
|
3315 { |
|
3316 iExtension->FocusLost(); |
|
3317 } |
|
3318 |
|
3319 void CPbk2ContactViewCustomListBoxData::HandleResourceChange( TInt aType ) |
|
3320 { |
|
3321 // Animation is skin dependent, whenever skin changes animation changes |
|
3322 // too. |
|
3323 if( KAknsMessageSkinChange == aType ) |
|
3324 { |
|
3325 TRAP_IGNORE( iExtension->SkinChangedL() ); |
|
3326 |
|
3327 } |
|
3328 else if(aType == KEikDynamicLayoutVariantSwitch) |
|
3329 { |
|
3330 // What is under highlight may have changed -> we need to update |
|
3331 // highlight background to animation. |
|
3332 iExtension->iAnimFlags.Set( CPbk2ContactViewCustomListBoxDataExtension::EFlagUpdateBg ); |
|
3333 } |
|
3334 } |
|
3335 |
|
3336 void CPbk2ContactViewCustomListBoxData::SetupSkinContextL() |
|
3337 { |
|
3338 __ASSERT_DEBUG( iExtension, Panic( EPanicNullPointerListBoxData )); |
|
3339 |
|
3340 TRect mainPane; |
|
3341 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
3342 |
|
3343 TRect mainPaneRect( mainPane.Size() ); |
|
3344 |
|
3345 if ( !iExtension->iSkinControlContext ) |
|
3346 { |
|
3347 iExtension->iSkinControlContext = CAknsListBoxBackgroundControlContext::NewL( |
|
3348 KAknsIIDQsnBgAreaMainListGene, |
|
3349 mainPaneRect, |
|
3350 EFalse, |
|
3351 KAknsIIDQsnBgColumnA, |
|
3352 mainPaneRect ); |
|
3353 |
|
3354 iExtension->iSkinHighlightFrameId = &KAknsIIDQsnFrList; |
|
3355 iExtension->iSkinHighlightFrameCenterId = &KAknsIIDQsnFrListCenter; |
|
3356 } |
|
3357 else |
|
3358 { |
|
3359 iExtension->iSkinControlContext->SetRect( mainPaneRect ); |
|
3360 } |
|
3361 } |
|
3362 |
|
3363 void CPbk2ContactViewCustomListBoxData::SetESSTextColor(TRgb aTextColor) |
|
3364 { |
|
3365 if (iExtension) |
|
3366 iExtension->iTextColor = aTextColor; |
|
3367 } |
|
3368 |
|
3369 void CPbk2ContactViewCustomListBoxData::SetESSHighlightedTextColor(TRgb aHighlightedTextColor) |
|
3370 { |
|
3371 if (iExtension) |
|
3372 iExtension->iHighlightedTextColor = aHighlightedTextColor; |
|
3373 } |
|
3374 |
|
3375 void CPbk2ContactViewCustomListBoxData::SetColumnUnderlined( TBitFlags32 aUnderlinedColumns ) |
|
3376 { |
|
3377 if ( iExtension ) |
|
3378 { |
|
3379 iExtension->iUnderlineFlagSet = ETrue; |
|
3380 iExtension->iUnderlineFlags = aUnderlinedColumns; |
|
3381 } |
|
3382 } |
|
3383 |
|
3384 void CPbk2ContactViewCustomListBoxData::SetUnderlineStyle( TListItemProperties aProperties, |
|
3385 CWindowGc& aGc, |
|
3386 TInt aColumn ) const |
|
3387 { |
|
3388 if ( !iExtension ) |
|
3389 { |
|
3390 return; |
|
3391 } |
|
3392 |
|
3393 if ( !iExtension->iUnderlineFlagSet ) |
|
3394 { |
|
3395 // underlining is already either on or off and |
|
3396 // hardcoded off turning will ensure old style |
|
3397 // behaviour |
|
3398 return; |
|
3399 } |
|
3400 |
|
3401 if ( aProperties.IsUnderlined() |
|
3402 && iExtension->iUnderlineFlagSet |
|
3403 && iExtension->iUnderlineFlags.IsSet( aColumn ) ) |
|
3404 { |
|
3405 aGc.SetUnderlineStyle( EUnderlineOn ); |
|
3406 } |
|
3407 else |
|
3408 { |
|
3409 aGc.SetUnderlineStyle( EUnderlineOff ); |
|
3410 } |
|
3411 } |
|
3412 |
|
3413 // ----------------------------------------------------------------------------- |
|
3414 // CPbk2ContactViewCustomListBoxData::ResetSLSubCellArray |
|
3415 // ----------------------------------------------------------------------------- |
|
3416 // |
|
3417 void CPbk2ContactViewCustomListBoxData::ResetSLSubCellArray() |
|
3418 { |
|
3419 if ( !iExtension ) |
|
3420 { |
|
3421 return; |
|
3422 } |
|
3423 |
|
3424 iExtension->iMarginRect = TRect::EUninitialized; |
|
3425 if ( iExtension && iExtension->iUseLayoutData ) |
|
3426 { |
|
3427 iExtension->iUseLayoutData = EFalse; |
|
3428 CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View(); |
|
3429 MAknListBoxTfxInternal* transApi = |
|
3430 CAknListLoader::TfxApiInternal( view->ItemDrawer()->Gc() ); |
|
3431 if ( transApi ) |
|
3432 { |
|
3433 transApi->SetPosition( MAknListBoxTfxInternal::EListTLMargin, TPoint( 0, 0 ) ); |
|
3434 transApi->SetPosition( MAknListBoxTfxInternal::EListBRMargin, TPoint( 0, 0 ) ); |
|
3435 } |
|
3436 } |
|
3437 iExtension->ResetSLSubCellArray(); |
|
3438 // This function gets called always when size changes, so here is called |
|
3439 // SetupSkinContextL to update the layout rect of the background skin |
|
3440 // context (mainpane rect can change for example if toolbar is hidden. |
|
3441 TRAP_IGNORE( SetupSkinContextL() ); |
|
3442 } |
|
3443 |
|
3444 // ----------------------------------------------------------------------------- |
|
3445 // CPbk2ContactViewCustomListBoxData::SetGraphicSubCellL |
|
3446 // ----------------------------------------------------------------------------- |
|
3447 // |
|
3448 void CPbk2ContactViewCustomListBoxData::SetGraphicSubCellL(TInt aSubCell, |
|
3449 const TAknWindowLineLayout &aGraphicLayout) |
|
3450 { |
|
3451 if (!iExtension) return; |
|
3452 TInt index = 0; |
|
3453 iExtension->FindSLSubCellIndexOrAddL(index,aSubCell); |
|
3454 iExtension->AtSL(index).iTextLayout=NULL; |
|
3455 iExtension->AtSL(index).iGraphicLayout=aGraphicLayout; |
|
3456 iExtension->AtSL(index).iSubCellType=CPbk2ContactViewCustomListBoxDataExtension::EEikSLGraphic; |
|
3457 |
|
3458 // needed for compatibility |
|
3459 CEikColumnListBox* list = static_cast<CEikColumnListBox*>( iExtension->iControl ); |
|
3460 TAknLayoutRect layoutRect; |
|
3461 layoutRect.LayoutRect( list->View()->ItemDrawer()->ItemCellSize(), aGraphicLayout ); |
|
3462 TRect rect( layoutRect.Rect() ); |
|
3463 |
|
3464 SetSubCellIconSize( aSubCell, rect.Size() ); |
|
3465 SetColumnWidthPixelL( aSubCell, rect.Width() ); |
|
3466 SetGraphicsColumnL( aSubCell, ETrue ); |
|
3467 SetColumnXL( aSubCell, rect.iTl.iX ); |
|
3468 SetColumnEndXL( aSubCell, rect.iBr.iX ); |
|
3469 iExtension->iUseLayoutData=ETrue; // might go to own method... |
|
3470 if ( iExtension->iMarginRect == TRect::EUninitialized ) |
|
3471 { |
|
3472 iExtension->iMarginRect = rect; |
|
3473 } |
|
3474 else |
|
3475 { |
|
3476 iExtension->iMarginRect.BoundingRect( rect ); |
|
3477 } |
|
3478 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
3479 MAknListBoxTfxInternal* transApi = |
|
3480 CAknListLoader::TfxApiInternal( list->View()->ItemDrawer()->Gc() ); |
|
3481 if ( transApi ) |
|
3482 { |
|
3483 transApi->SetPosition( MAknListBoxTfxInternal::EListTLMargin, iExtension->iMarginRect.iTl ); |
|
3484 TSize size = list->View()->ItemDrawer()->ItemCellSize(); |
|
3485 TPoint br( size.AsPoint() - iExtension->iMarginRect.iBr ); |
|
3486 transApi->SetPosition( MAknListBoxTfxInternal::EListBRMargin, |
|
3487 br ); |
|
3488 } |
|
3489 #endif |
|
3490 } |
|
3491 |
|
3492 // ----------------------------------------------------------------------------- |
|
3493 // CPbk2ContactViewCustomListBoxData::SetTextSubCellL |
|
3494 // ----------------------------------------------------------------------------- |
|
3495 // |
|
3496 void CPbk2ContactViewCustomListBoxData::SetTextSubCellL(TInt aSubCell, |
|
3497 const TAknTextLineLayout &aTextLayout) |
|
3498 { |
|
3499 if (!iExtension) return; |
|
3500 TInt index = 0; |
|
3501 iExtension->FindSLSubCellIndexOrAddL(index,aSubCell); |
|
3502 iExtension->AtSL(index).iTextLayout=aTextLayout; |
|
3503 iExtension->AtSL(index).iGraphicLayout=NULL; |
|
3504 iExtension->AtSL(index).iSubCellType=CPbk2ContactViewCustomListBoxDataExtension::EEikSLText; |
|
3505 |
|
3506 // needed for compatibility |
|
3507 CEikColumnListBox* list = static_cast<CEikColumnListBox*>( iExtension->iControl ); |
|
3508 TAknLayoutText textLayout; |
|
3509 textLayout.LayoutText( list->View()->ItemDrawer()->ItemCellSize(), aTextLayout ); |
|
3510 TRect rect( textLayout.TextRect() ); |
|
3511 |
|
3512 SetColumnWidthPixelL( aSubCell, rect.Width() ); |
|
3513 SetColumnFontL( aSubCell, textLayout.Font() ); |
|
3514 SetColumnXL( aSubCell, rect.iTl.iX ); |
|
3515 SetColumnEndXL( aSubCell, rect.iBr.iX ); |
|
3516 SetColumnBaselinePosL( aSubCell, aTextLayout.iB ); |
|
3517 iExtension->iUseLayoutData=ETrue; // might go to own method... |
|
3518 if ( iExtension->iMarginRect == TRect::EUninitialized ) |
|
3519 { |
|
3520 iExtension->iMarginRect = rect; |
|
3521 } |
|
3522 else |
|
3523 { |
|
3524 iExtension->iMarginRect.BoundingRect( rect ); |
|
3525 } |
|
3526 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
3527 MAknListBoxTfxInternal* transApi = |
|
3528 CAknListLoader::TfxApiInternal( list->View()->ItemDrawer()->Gc() ); |
|
3529 if ( transApi ) |
|
3530 { |
|
3531 transApi->SetPosition( MAknListBoxTfxInternal::EListTLMargin, iExtension->iMarginRect.iTl ); |
|
3532 TSize size = list->View()->ItemDrawer()->ItemCellSize(); |
|
3533 TPoint br( size.AsPoint() - iExtension->iMarginRect.iBr ); |
|
3534 transApi->SetPosition( MAknListBoxTfxInternal::EListBRMargin, |
|
3535 br ); |
|
3536 } |
|
3537 #endif |
|
3538 } |
|
3539 |
|
3540 // ----------------------------------------------------------------------------- |
|
3541 // CPbk2ContactViewCustomListBoxData::SetConditionalSubCellL |
|
3542 // ----------------------------------------------------------------------------- |
|
3543 // |
|
3544 void CPbk2ContactViewCustomListBoxData::SetConditionalSubCellL(TInt aSubCell, |
|
3545 const TAknTextLineLayout &aTextLayout, |
|
3546 TInt aAffectedSubCell) |
|
3547 { |
|
3548 // iConditionValue of affected subcell (=text subcell, which has different layouts) |
|
3549 // contains index of graphical subcell, which existence should be checked first. |
|
3550 // This graphical subcell has in iConditionValue index of graphical subcell, |
|
3551 // which existence should be checked second etc. Each graphical subcell can |
|
3552 // affect only to 1 text subcell (or none). |
|
3553 |
|
3554 // for compabitility - needed at least for text wrapping |
|
3555 SetOptionalColumnL( aSubCell, ETrue ); |
|
3556 if (!iExtension) return; |
|
3557 |
|
3558 TInt i = 0x01; |
|
3559 i = i << aSubCell; |
|
3560 iExtension->iConditionalCells = iExtension->iConditionalCells | i; |
|
3561 |
|
3562 TInt graphicalIndex = 0; |
|
3563 if (iExtension->FindSLSubCellIndex(graphicalIndex, aSubCell)!=0) return; // subcell not found |
|
3564 // conditional layoutline can be only added to graphical subcells |
|
3565 if (iExtension->AtSL(graphicalIndex).iSubCellType!=CPbk2ContactViewCustomListBoxDataExtension::EEikSLGraphic) return; |
|
3566 |
|
3567 TInt textIndex = 0; // index of affected subcell |
|
3568 if (iExtension->FindSLSubCellIndex(textIndex, aAffectedSubCell)!=0) return; // subcell not found |
|
3569 // affected subcell can only be text subcell |
|
3570 if (iExtension->AtSL(textIndex).iSubCellType==CPbk2ContactViewCustomListBoxDataExtension::EEikSLGraphic) return; |
|
3571 |
|
3572 TInt gSC = iExtension->AtSL(textIndex).iConditionValue; // text subcell to be added in priority chain |
|
3573 |
|
3574 while (gSC > -1) |
|
3575 { |
|
3576 if (iExtension->FindSLSubCellIndex(textIndex, gSC)!=0) return; // subcell not found |
|
3577 gSC = iExtension->AtSL(textIndex).iConditionValue; |
|
3578 } |
|
3579 iExtension->AtSL(textIndex).iConditionValue = aSubCell; // add next subcell to chain |
|
3580 iExtension->AtSL(graphicalIndex).iTextLayout=aTextLayout; |
|
3581 iExtension->CreateColorBitmapsL(); |
|
3582 |
|
3583 CEikColumnListBox* list = static_cast<CEikColumnListBox*>( iExtension->iControl ); |
|
3584 TAknLayoutText textLayout; |
|
3585 textLayout.LayoutText( list->View()->ItemDrawer()->ItemCellSize(), aTextLayout ); |
|
3586 |
|
3587 if ( iExtension->iMarginRect == TRect::EUninitialized ) |
|
3588 { |
|
3589 iExtension->iMarginRect = textLayout.TextRect(); |
|
3590 } |
|
3591 else |
|
3592 { |
|
3593 iExtension->iMarginRect.BoundingRect( textLayout.TextRect() ); |
|
3594 } |
|
3595 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
3596 MAknListBoxTfxInternal* transApi = |
|
3597 CAknListLoader::TfxApiInternal( list->View()->ItemDrawer()->Gc() ); |
|
3598 if ( transApi ) |
|
3599 { |
|
3600 transApi->SetPosition( MAknListBoxTfxInternal::EListTLMargin, iExtension->iMarginRect.iTl ); |
|
3601 TSize size = list->View()->ItemDrawer()->ItemCellSize(); |
|
3602 TPoint br( size.AsPoint() - iExtension->iMarginRect.iBr ); |
|
3603 transApi->SetPosition( MAknListBoxTfxInternal::EListBRMargin, |
|
3604 br ); |
|
3605 } |
|
3606 #endif |
|
3607 } |
|
3608 |
|
3609 // ----------------------------------------------------------------------------- |
|
3610 // CPbk2ContactViewCustomListBoxData::SetStretchableGraphicSubCellL |
|
3611 // ----------------------------------------------------------------------------- |
|
3612 // |
|
3613 void CPbk2ContactViewCustomListBoxData::SetStretchableGraphicSubCellL( |
|
3614 TInt aSubCell, |
|
3615 const TAknWindowComponentLayout& aNormalLayout, |
|
3616 const TAknWindowComponentLayout& aStretchedLayout ) |
|
3617 { |
|
3618 if ( Layout_Meta_Data::IsLandscapeOrientation() && |
|
3619 Layout_Meta_Data::IsListStretchingEnabled() && |
|
3620 StretchingEnabled() ) |
|
3621 { |
|
3622 SetGraphicSubCellL( aSubCell, aStretchedLayout.LayoutLine() ); |
|
3623 } |
|
3624 else |
|
3625 { |
|
3626 SetGraphicSubCellL( aSubCell, aNormalLayout.LayoutLine() ); |
|
3627 } |
|
3628 } |
|
3629 |
|
3630 // ----------------------------------------------------------------------------- |
|
3631 // CPbk2ContactViewCustomListBoxData::SetStretchableTextSubCellL |
|
3632 // ----------------------------------------------------------------------------- |
|
3633 // |
|
3634 void CPbk2ContactViewCustomListBoxData::SetStretchableTextSubCellL( |
|
3635 TInt aSubCell, |
|
3636 const TAknTextComponentLayout& aNormalLayout, |
|
3637 const TAknTextComponentLayout& aStretchedLayout ) |
|
3638 { |
|
3639 if ( Layout_Meta_Data::IsLandscapeOrientation() && |
|
3640 Layout_Meta_Data::IsListStretchingEnabled() && |
|
3641 StretchingEnabled() ) |
|
3642 { |
|
3643 SetTextSubCellL( aSubCell, aStretchedLayout.LayoutLine() ); |
|
3644 } |
|
3645 else |
|
3646 { |
|
3647 SetTextSubCellL( aSubCell, aNormalLayout.LayoutLine() ); |
|
3648 } |
|
3649 } |
|
3650 |
|
3651 // ----------------------------------------------------------------------------- |
|
3652 // CPbk2ContactViewCustomListBoxData::SetStretchableConditionalSubCellL |
|
3653 // ----------------------------------------------------------------------------- |
|
3654 // |
|
3655 void CPbk2ContactViewCustomListBoxData::SetStretchableConditionalSubCellL( |
|
3656 TInt aSubCell, |
|
3657 const TAknTextComponentLayout& aNormalLayout, |
|
3658 const TAknTextComponentLayout& aStretchedLayout, |
|
3659 TInt aNormalSubCell, |
|
3660 TInt aStretchedSubCell ) |
|
3661 { |
|
3662 if ( Layout_Meta_Data::IsLandscapeOrientation() && |
|
3663 Layout_Meta_Data::IsListStretchingEnabled() && |
|
3664 StretchingEnabled() ) |
|
3665 { |
|
3666 SetConditionalSubCellL( aSubCell, aStretchedLayout.LayoutLine(), aStretchedSubCell ); |
|
3667 } |
|
3668 else |
|
3669 { |
|
3670 SetConditionalSubCellL( aSubCell, aNormalLayout.LayoutLine(), aNormalSubCell ); |
|
3671 } |
|
3672 } |
|
3673 |
|
3674 // ----------------------------------------------------------------------------- |
|
3675 // CPbk2ContactViewCustomListBoxData::UsesScalableLayoutData |
|
3676 // ----------------------------------------------------------------------------- |
|
3677 // |
|
3678 TBool CPbk2ContactViewCustomListBoxData::UsesScalableLayoutData() const |
|
3679 { |
|
3680 if (iExtension) |
|
3681 return iExtension->iUseLayoutData; |
|
3682 |
|
3683 return EFalse; |
|
3684 } |
|
3685 |
|
3686 // ----------------------------------------------------------------------------- |
|
3687 // CPbk2ContactViewCustomListBoxData::EnableStretching |
|
3688 // ----------------------------------------------------------------------------- |
|
3689 // |
|
3690 void CPbk2ContactViewCustomListBoxData::EnableStretching( const TBool aEnabled ) |
|
3691 { |
|
3692 if ( !iExtension ) |
|
3693 { |
|
3694 return; |
|
3695 } |
|
3696 |
|
3697 iExtension->iStretchingEnabled = aEnabled; |
|
3698 } |
|
3699 |
|
3700 #ifdef RD_LIST_STRETCH |
|
3701 // ----------------------------------------------------------------------------- |
|
3702 // CPbk2ContactViewCustomListBoxData::StretchingEnabled |
|
3703 // ----------------------------------------------------------------------------- |
|
3704 // |
|
3705 TBool CPbk2ContactViewCustomListBoxData::StretchingEnabled() const |
|
3706 { |
|
3707 if ( !iExtension ) |
|
3708 { |
|
3709 return EFalse; |
|
3710 } |
|
3711 |
|
3712 return iExtension->iStretchingEnabled; |
|
3713 } |
|
3714 |
|
3715 #else |
|
3716 // ----------------------------------------------------------------------------- |
|
3717 // CPbk2ContactViewCustomListBoxData::StretchingEnabled |
|
3718 // ----------------------------------------------------------------------------- |
|
3719 // |
|
3720 TBool CPbk2ContactViewCustomListBoxData::StretchingEnabled() const |
|
3721 { |
|
3722 return EFalse; |
|
3723 } |
|
3724 |
|
3725 #endif // RD_LIST_STRETCH |
|
3726 |
|
3727 // ----------------------------------------------------------------------------- |
|
3728 // CPbk2ContactViewCustomListBoxData::CheckIfSubCellsIntersectL |
|
3729 // ----------------------------------------------------------------------------- |
|
3730 // |
|
3731 void CPbk2ContactViewCustomListBoxData::CheckIfSubCellsIntersectL( |
|
3732 TAknTextLineLayout* aLayouts, |
|
3733 TBool* aResults, |
|
3734 const TDesC& aText, |
|
3735 const TRect& aItemRect ) const |
|
3736 { |
|
3737 TInt column = 0; |
|
3738 TInt column2; |
|
3739 TInt subCellIndex; |
|
3740 TInt subCellIndex2; |
|
3741 TInt lastColumn = Min( LastColumn(), KMaxColumn ); |
|
3742 TPtrC text; |
|
3743 TBool isEmpty[KMaxColumn]; |
|
3744 |
|
3745 // cache the empty text states |
|
3746 while ( ETrue ) |
|
3747 { |
|
3748 if ( column > lastColumn ) |
|
3749 { |
|
3750 break; |
|
3751 } |
|
3752 |
|
3753 TextUtils::ColumnText( text, column, &aText ); |
|
3754 |
|
3755 if ( text == KNullDesC || ColumnIsOptional( column ) ) |
|
3756 { |
|
3757 isEmpty[column] = ETrue; |
|
3758 } |
|
3759 else |
|
3760 { |
|
3761 isEmpty[column] = EFalse; |
|
3762 } |
|
3763 |
|
3764 ++column; |
|
3765 } |
|
3766 |
|
3767 column = 0; |
|
3768 |
|
3769 while ( ETrue ) |
|
3770 { |
|
3771 if ( column > lastColumn ) |
|
3772 { |
|
3773 break; |
|
3774 } |
|
3775 |
|
3776 if ( iExtension->FindSLSubCellIndex( subCellIndex, column ) != 0 ) |
|
3777 { |
|
3778 break; |
|
3779 } |
|
3780 |
|
3781 if ( isEmpty[column] ) |
|
3782 { |
|
3783 ++column; |
|
3784 continue; |
|
3785 } |
|
3786 |
|
3787 TRect bRect( ColumnX( column ), 0, ColumnEndX( column ), 10 ); |
|
3788 |
|
3789 for ( column2 = column + 1; column2 <= lastColumn; column2++ ) |
|
3790 { |
|
3791 if ( isEmpty[column2] ) |
|
3792 { |
|
3793 continue; |
|
3794 } |
|
3795 |
|
3796 if ( iExtension->FindSLSubCellIndex( subCellIndex2, column2 ) != 0 ) |
|
3797 { |
|
3798 break; |
|
3799 } |
|
3800 |
|
3801 TRect bRect2( ColumnX( column2 ), 0, ColumnEndX( column2 ), 10 ); |
|
3802 |
|
3803 if ( bRect.Intersects( bRect2 ) ) |
|
3804 { |
|
3805 aResults[column] = ETrue; |
|
3806 |
|
3807 if ( !AknLayoutUtils::LayoutMirrored() ) |
|
3808 { |
|
3809 bRect.iBr.iX = bRect2.iTl.iX; |
|
3810 } |
|
3811 else |
|
3812 { |
|
3813 bRect.iTl.iX = bRect2.iBr.iX; |
|
3814 } |
|
3815 } |
|
3816 } |
|
3817 |
|
3818 if ( aResults[column] ) |
|
3819 { |
|
3820 if ( iExtension->AtSL( subCellIndex ).iSubCellType == CPbk2ContactViewCustomListBoxDataExtension::EEikSLText ) |
|
3821 { |
|
3822 TAknTextLineLayout textLine = iExtension->AtSL( subCellIndex ).iTextLayout; |
|
3823 |
|
3824 textLine.iW = bRect.Width(); |
|
3825 |
|
3826 if ( !AknLayoutUtils::LayoutMirrored() ) |
|
3827 { |
|
3828 textLine.ir = aItemRect.iBr.iX - bRect.iBr.iX; |
|
3829 } |
|
3830 else |
|
3831 { |
|
3832 textLine.il = bRect.iTl.iX - aItemRect.iTl.iX; |
|
3833 } |
|
3834 |
|
3835 aLayouts[column] = textLine; |
|
3836 } |
|
3837 } |
|
3838 |
|
3839 ++column; |
|
3840 } |
|
3841 } |
|
3842 |
|
3843 // ----------------------------------------------------------------------------- |
|
3844 // CPbk2ContactViewCustomListBoxData::SubCellsMightIntersect |
|
3845 // ----------------------------------------------------------------------------- |
|
3846 // |
|
3847 void CPbk2ContactViewCustomListBoxData::SubCellsMightIntersect( const TBool aMightIntersect ) |
|
3848 { |
|
3849 iExtension->iSubCellsMightIntersect = aMightIntersect; |
|
3850 } |
|
3851 |
|
3852 void CPbk2ContactViewCustomListBoxDataExtension::CreateColorBitmapsL() |
|
3853 { |
|
3854 /* size calculation relies on fact, that currently all additional |
|
3855 * icons in column lists are same size. Size could be calculated |
|
3856 * from sizes availble in setconditionalsubcelll(), but that would |
|
3857 * be too unreliable. And there is no way to calculate size of |
|
3858 * icons created by symbian's old api. |
|
3859 */ |
|
3860 TRect mainPane; |
|
3861 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
3862 TAknLayoutRect r; |
|
3863 r.LayoutRect( mainPane, AknLayoutScalable_Avkon::listscroll_gen_pane(0) ); |
|
3864 r.LayoutRect( r.Rect(), AknLayoutScalable_Avkon::list_gen_pane(0) ); |
|
3865 r.LayoutRect( r.Rect(), AknLayoutScalable_Avkon::list_single_pane(0) ); |
|
3866 r.LayoutRect( r.Rect(), AknLayoutScalable_Avkon::list_single_pane_g1(0) ); |
|
3867 TSize aSize = r.Rect().Size(); |
|
3868 |
|
3869 TRgb color, hiliColor; |
|
3870 TInt error; |
|
3871 // icon #13 main area additional list icons #215 |
|
3872 // icon #16 list highlight additional list iconsform checkbox, radio button #215 |
|
3873 |
|
3874 error = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
3875 color, |
|
3876 KAknsIIDQsnIconColors, |
|
3877 EAknsCIQsnIconColorsCG13 ); |
|
3878 if ( error ) |
|
3879 { |
|
3880 return; |
|
3881 } |
|
3882 error = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
3883 hiliColor, |
|
3884 KAknsIIDQsnIconColors, |
|
3885 EAknsCIQsnIconColorsCG16 ); |
|
3886 if ( error ) |
|
3887 { |
|
3888 return; |
|
3889 } |
|
3890 |
|
3891 if ( iColorBmp && iColorBmp->SizeInPixels() == aSize |
|
3892 && color == iIconColor && hiliColor == iHiliIconColor ) |
|
3893 { |
|
3894 return; |
|
3895 } |
|
3896 |
|
3897 iIconColor = color; |
|
3898 iHiliIconColor = hiliColor; |
|
3899 |
|
3900 if ( !iColorBmp ) |
|
3901 { |
|
3902 iColorBmp = new( ELeave ) CFbsBitmap(); |
|
3903 iColorBmp->Create( aSize, CCoeEnv::Static()->ScreenDevice()->DisplayMode() ); |
|
3904 } |
|
3905 else if ( iColorBmp->SizeInPixels() != aSize ) |
|
3906 { |
|
3907 iColorBmp->Resize( aSize ); |
|
3908 } |
|
3909 if ( !iHiliBmp ) |
|
3910 { |
|
3911 iHiliBmp = new( ELeave ) CFbsBitmap(); |
|
3912 iHiliBmp->Create( aSize, CCoeEnv::Static()->ScreenDevice()->DisplayMode() ); |
|
3913 } |
|
3914 else if ( iHiliBmp->SizeInPixels() != aSize ) |
|
3915 { |
|
3916 iHiliBmp->Resize( aSize ); |
|
3917 } |
|
3918 |
|
3919 CFbsBitGc* fbsBitGc = CFbsBitGc::NewL(); |
|
3920 CleanupStack::PushL( fbsBitGc ); |
|
3921 |
|
3922 CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( iColorBmp ); |
|
3923 CleanupStack::PushL( bmpDevice ); |
|
3924 fbsBitGc->Activate( bmpDevice ); |
|
3925 fbsBitGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
3926 fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
3927 fbsBitGc->SetBrushColor( color ); |
|
3928 fbsBitGc->Clear(); |
|
3929 CleanupStack::PopAndDestroy( bmpDevice ); |
|
3930 bmpDevice = NULL; |
|
3931 |
|
3932 bmpDevice = CFbsBitmapDevice::NewL( iHiliBmp ); |
|
3933 CleanupStack::PushL( bmpDevice ); |
|
3934 fbsBitGc->Activate( bmpDevice ); |
|
3935 fbsBitGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
3936 fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
3937 fbsBitGc->SetBrushColor( hiliColor ); |
|
3938 fbsBitGc->Clear(); |
|
3939 CleanupStack::PopAndDestroy( bmpDevice ); |
|
3940 bmpDevice = NULL; |
|
3941 |
|
3942 CleanupStack::PopAndDestroy( fbsBitGc ); |
|
3943 } |
|
3944 |
|
3945 |
|
3946 TUint32 CPbk2ContactViewCustomListBoxData::CurrentItemTextWasClipped() const |
|
3947 { |
|
3948 return iExtension ? iExtension->iClippedColumns : 0; |
|
3949 } |
|
3950 |
|
3951 TBool CPbk2ContactViewCustomListBoxData::KineticScrollingEnabled() const |
|
3952 { |
|
3953 if ( iExtension ) |
|
3954 { |
|
3955 return iExtension->iKineticScrolling; |
|
3956 } |
|
3957 return EFalse; |
|
3958 } |
|
3959 |
|
3960 //Start of Code Added for PhoneBook2 |
|
3961 // --------------------------------------------------------------------------- |
|
3962 // CPbk2ContactViewCustomListBoxData::SetDataModel, sets the internal PCS data model. |
|
3963 // --------------------------------------------------------------------------- |
|
3964 void CPbk2ContactViewCustomListBoxData::SetDataModel(CPbk2ContactViewListBoxModel* aDataModel) |
|
3965 { |
|
3966 iDataModel = aDataModel; |
|
3967 iPsHandler = iDataModel->PSHandler(); |
|
3968 } |
|
3969 |
|
3970 // --------------------------------------------------------------------------- |
|
3971 // CPbk2ContactViewCustomListBoxData::DrawEnhancedTextL, sets the internal PCS data model. |
|
3972 // --------------------------------------------------------------------------- |
|
3973 void CPbk2ContactViewCustomListBoxData::DrawEnhancedTextL( |
|
3974 const TListItemProperties& aItemProperties, |
|
3975 CWindowGc& aGc, |
|
3976 const TRect& aRect, |
|
3977 const TDesC& aTextToDraw, |
|
3978 const TPtrC& aText, |
|
3979 TAknLayoutText &aTextLayout, |
|
3980 TAknTextLineLayout &aTextLineLayout, |
|
3981 TBool aUseLogicalToVisualConversion, |
|
3982 const CFont* aUsedFont, |
|
3983 TRgb aTextColor |
|
3984 ) const |
|
3985 { |
|
3986 TRect layoutedRect( aRect ); |
|
3987 RArray<TPsMatchLocation> searchMatches; |
|
3988 TInt currentChar(0); |
|
3989 TInt charactersToNextMatch(0); |
|
3990 TBool mirroredInput( EFalse ); |
|
3991 HBufC* visualBuf = NULL; |
|
3992 TPtrC text( aTextToDraw ); |
|
3993 TBool textClipped (EFalse); |
|
3994 TPtrC textForPSEngine (aTextToDraw); |
|
3995 |
|
3996 // Get current matches |
|
3997 // Data model should be always initialized in not NULL value |
|
3998 // This query supports bidirectional order |
|
3999 CPsQuery* queryData = NULL; |
|
4000 TRAP_IGNORE(queryData = const_cast<CPsQuery*>(iDataModel->LastPCSQuery()) ); |
|
4001 if (queryData && queryData->Count() > 0) |
|
4002 { |
|
4003 |
|
4004 //Find the clipped text that will fit into the layout |
|
4005 //we need to perform our underline operation on this clipped text |
|
4006 if ( aTextToDraw.Length() ) |
|
4007 { |
|
4008 visualBuf = HBufC::NewLC( aTextToDraw.Length() + KAknBidiExtraSpacePerLine ); |
|
4009 |
|
4010 // In OOM, logical to visual conversion is not performed... |
|
4011 |
|
4012 if ( visualBuf ) |
|
4013 { |
|
4014 *visualBuf = aTextToDraw; // copy |
|
4015 TPtr ptr = visualBuf->Des(); |
|
4016 TInt maxWidth = aTextLayout.TextRect().Size().iWidth; |
|
4017 |
|
4018 // Logical to visual conversion. |
|
4019 textClipped = AknBidiTextUtils::ConvertToVisualAndClip( |
|
4020 aText, |
|
4021 ptr, |
|
4022 *aUsedFont, |
|
4023 maxWidth, |
|
4024 maxWidth ); |
|
4025 |
|
4026 if ( textClipped ) |
|
4027 { |
|
4028 //Remove the ellipsis and pass the text to the PS Engine |
|
4029 text.Set( ptr.Left( ptr.Length() - 1 ) ); |
|
4030 } |
|
4031 else |
|
4032 { |
|
4033 text.Set( ptr ); |
|
4034 } |
|
4035 } |
|
4036 } |
|
4037 |
|
4038 // Check if we have mirrored input |
|
4039 // It is possible to have mixed input in search string. Always ask repository file to get |
|
4040 // correct input language |
|
4041 TInt inputLang = 0; |
|
4042 CRepository* centRep = NULL; |
|
4043 TRAPD(leavecode, centRep = CRepository::NewL( KCRUidAknFep ) ); |
|
4044 if( leavecode == KErrNone) |
|
4045 { |
|
4046 centRep->Get( KAknFepInputTxtLang, inputLang ); |
|
4047 } |
|
4048 delete centRep; |
|
4049 |
|
4050 mirroredInput = ( inputLang == ELangArabic || |
|
4051 inputLang == ELangHebrew || |
|
4052 inputLang == ELangFarsi); |
|
4053 |
|
4054 // We will suggest that memory is enough |
|
4055 if (mirroredInput) |
|
4056 { |
|
4057 // temporary solution |
|
4058 // PCS LookupLmethod doesn't work correctly for |
|
4059 // bidirectional languages |
|
4060 iDataModel->GetMatchingPartsL(text, searchMatches); |
|
4061 } |
|
4062 else |
|
4063 { |
|
4064 CDesCArray* matchSeq = new( ELeave ) CDesCArrayFlat(2); |
|
4065 TRAP_IGNORE(iPsHandler->LookupL( *queryData, text, *matchSeq, searchMatches) ); |
|
4066 delete matchSeq; |
|
4067 } |
|
4068 if( searchMatches.Count() ) |
|
4069 { |
|
4070 TLinearOrder<TPsMatchLocation> byStartIndex( CompareByStartIndex ); |
|
4071 searchMatches.Sort( byStartIndex ); |
|
4072 } |
|
4073 |
|
4074 |
|
4075 if( mirroredInput ) |
|
4076 { |
|
4077 currentChar = text.Length(); //aTextToDraw.Length(); |
|
4078 //TInt originalLayoutTlX( textMRect.iTl.iX ) |
|
4079 layoutedRect.iTl.iX = layoutedRect.iBr.iX; |
|
4080 for( TInt i = 0 ; i < searchMatches.Count(); i++ ) |
|
4081 { |
|
4082 #ifdef _DEBUG |
|
4083 TPsMatchLocation& location = searchMatches[i]; |
|
4084 RDebug::Print(_L("%S: searchMatch[%d] = (%d,%d), direction %d"), &text, i, |
|
4085 location.index, |
|
4086 location.length, location.direction ); |
|
4087 #endif //_DEBUG |
|
4088 searchMatches[i].index = Min( text.Length(), searchMatches[i].index ); |
|
4089 searchMatches[i].length = Min( text.Length() - searchMatches[i].index, |
|
4090 searchMatches[i].length); |
|
4091 } |
|
4092 if( !aItemProperties.IsSelectionHidden() ) |
|
4093 { |
|
4094 for( TInt i=searchMatches.Count()-1 ; i>=0 ; i-- ) |
|
4095 { |
|
4096 charactersToNextMatch = currentChar - ( searchMatches[i].index + searchMatches[i].length ); |
|
4097 if( charactersToNextMatch > 0 ) |
|
4098 { |
|
4099 layoutedRect.iTl.iX -= AknBidiTextUtils::MeasureTextBoundsWidth( *aUsedFont, |
|
4100 text.Mid( currentChar-charactersToNextMatch, |
|
4101 charactersToNextMatch ), |
|
4102 CFont::TMeasureTextInput::EFVisualOrder ); |
|
4103 //aGc.DrawText(convBuf.Mid(currentChar - charactersToNextMatch, charactersToNextMatch),layoutedRect,baseLineOffset, align, 0); |
|
4104 aTextLayout.LayoutText( layoutedRect, aTextLineLayout, aUsedFont ); |
|
4105 aTextLayout.DrawText( aGc, text.Mid(currentChar - charactersToNextMatch, charactersToNextMatch), aUseLogicalToVisualConversion, aTextColor ); |
|
4106 currentChar -= charactersToNextMatch; |
|
4107 } |
|
4108 layoutedRect.iTl.iX -= AknBidiTextUtils::MeasureTextBoundsWidth( *aUsedFont, |
|
4109 text.Mid( searchMatches[i].index, |
|
4110 searchMatches[i].length ), |
|
4111 CFont::TMeasureTextInput::EFVisualOrder ); |
|
4112 aTextLayout.LayoutText( layoutedRect, aTextLineLayout, aUsedFont ); |
|
4113 aGc.SetUnderlineStyle( EUnderlineOn ); |
|
4114 //aGc.DrawText(convBuf.Mid(searchMatches[i].index, searchMatches[i].length),layoutedRect,baseLineOffset, align, 0); |
|
4115 aTextLayout.DrawText( aGc, text.Mid(searchMatches[i].index, searchMatches[i].length), aUseLogicalToVisualConversion, aTextColor ); |
|
4116 aGc.SetUnderlineStyle( EUnderlineOff ); |
|
4117 currentChar -= searchMatches[i].length; |
|
4118 } |
|
4119 } |
|
4120 if( currentChar >= 0 ) |
|
4121 { |
|
4122 layoutedRect.iTl.iX -= AknBidiTextUtils::MeasureTextBoundsWidth( *aUsedFont, |
|
4123 text.Left(currentChar), |
|
4124 CFont::TMeasureTextInput::EFVisualOrder ); |
|
4125 //aGc.DrawText(convBuf.Left(currentChar),layoutedRect,baseLineOffset, align, 0); |
|
4126 aTextLayout.LayoutText( layoutedRect, aTextLineLayout, aUsedFont ); |
|
4127 aTextLayout.DrawText( aGc, text.Left(currentChar), aUseLogicalToVisualConversion, aTextColor ); |
|
4128 } |
|
4129 } |
|
4130 else // mirroredInput |
|
4131 { |
|
4132 if( !aItemProperties.IsSelectionHidden() ) |
|
4133 { |
|
4134 for( TInt i=0 ; i<searchMatches.Count() ; i++ ) |
|
4135 { |
|
4136 #ifdef _DEBUG |
|
4137 TPsMatchLocation& location = searchMatches[i]; |
|
4138 RDebug::Print(_L("%S: searchMatch[%d] = (%d,%d)"), &text, i, |
|
4139 location.index, |
|
4140 location.length ); |
|
4141 #endif //_DEBUG |
|
4142 searchMatches[i].index = Min( text.Length(), searchMatches[i].index ); |
|
4143 searchMatches[i].length = Min( text.Length() - searchMatches[i].index, |
|
4144 searchMatches[i].length ); |
|
4145 |
|
4146 charactersToNextMatch = searchMatches[i].index-currentChar; |
|
4147 if( charactersToNextMatch > 0 ) |
|
4148 { |
|
4149 aTextLayout.DrawText( aGc, text.Mid(currentChar, charactersToNextMatch), aUseLogicalToVisualConversion, aTextColor ); |
|
4150 //aGc.DrawText(convBuf.Mid(currentChar, charactersToNextMatch),layoutedRect,baseLineOffset, CGraphicsContext::ELeft); |
|
4151 layoutedRect.iTl.iX += AknBidiTextUtils::MeasureTextBoundsWidth( *aUsedFont, |
|
4152 text.Mid( currentChar,charactersToNextMatch ), |
|
4153 CFont::TMeasureTextInput::EFVisualOrder ); |
|
4154 |
|
4155 aTextLayout.LayoutText( layoutedRect, aTextLineLayout, aUsedFont ); |
|
4156 currentChar+=charactersToNextMatch; |
|
4157 } |
|
4158 aGc.SetUnderlineStyle( EUnderlineOn ); |
|
4159 //aGc.DrawText(convBuf.Mid(searchMatches[i].index, searchMatches[i].length),layoutedRect,baseLineOffset, CGraphicsContext::ELeft); |
|
4160 aTextLayout.DrawText( aGc, text.Mid(searchMatches[i].index, searchMatches[i].length), aUseLogicalToVisualConversion, aTextColor ); |
|
4161 aGc.SetUnderlineStyle( EUnderlineOff ); |
|
4162 layoutedRect.iTl.iX += AknBidiTextUtils::MeasureTextBoundsWidth( *aUsedFont, |
|
4163 text.Mid( searchMatches[i].index, |
|
4164 searchMatches[i].length ), |
|
4165 CFont::TMeasureTextInput::EFVisualOrder ); |
|
4166 |
|
4167 aTextLayout.LayoutText( layoutedRect, aTextLineLayout, aUsedFont ); |
|
4168 currentChar+=searchMatches[i].length; |
|
4169 } |
|
4170 } |
|
4171 if( currentChar<text.Length() ) |
|
4172 { |
|
4173 //aGc.DrawText(convBuf.Mid(currentChar),layoutedRect,baseLineOffset, CGraphicsContext::ELeft); |
|
4174 aTextLayout.DrawText( aGc, text.Mid(currentChar), aUseLogicalToVisualConversion, aTextColor ); |
|
4175 layoutedRect.iTl.iX += AknBidiTextUtils::MeasureTextBoundsWidth( *aUsedFont, text.Mid(currentChar), |
|
4176 CFont::TMeasureTextInput::EFVisualOrder ); |
|
4177 aTextLayout.LayoutText( layoutedRect, aTextLineLayout, aUsedFont ); |
|
4178 } |
|
4179 } |
|
4180 |
|
4181 if ( textClipped ) |
|
4182 { |
|
4183 //Draw the ellipsis |
|
4184 TBuf<1> buffer; |
|
4185 buffer.Append( KEllipsis ); |
|
4186 aTextLayout.DrawText( aGc, buffer, EFalse, aTextColor ); |
|
4187 } |
|
4188 searchMatches.Reset(); |
|
4189 |
|
4190 if ( visualBuf ) |
|
4191 { |
|
4192 CleanupStack::PopAndDestroy(); //visualBuf |
|
4193 } |
|
4194 } |
|
4195 else |
|
4196 { |
|
4197 aTextLayout.DrawText( aGc, aTextToDraw, aUseLogicalToVisualConversion, aTextColor ); |
|
4198 } |
|
4199 } |
|
4200 |
|
4201 // --------------------------------------------------------------------------- |
|
4202 // CPbk2ContactViewCustomListBoxData::SetListCommands |
|
4203 // --------------------------------------------------------------------------- |
|
4204 void CPbk2ContactViewCustomListBoxData::SetListCommands( |
|
4205 const RPointerArray<MPbk2UiControlCmdItem>* aCommands ) |
|
4206 { |
|
4207 iCommandItems = aCommands; |
|
4208 } |
|
4209 |
|
4210 // -------------------------------------------------------------------------- |
|
4211 // CPbk2ContactViewCustomListBoxData::IsContactAtListboxIndex |
|
4212 // Tells whether the listbox line contains a contact or not. |
|
4213 // Does not check that the aListboxIndex is within range of listbox. |
|
4214 // -------------------------------------------------------------------------- |
|
4215 // |
|
4216 TBool CPbk2ContactViewCustomListBoxData::IsContactAtListboxIndex( TInt aListboxIndex ) const |
|
4217 { |
|
4218 // There can be command items at the top of the list. |
|
4219 // The command items are not contacts. |
|
4220 const TInt enabledCommandCount = CommandItemCount(); |
|
4221 return aListboxIndex >= enabledCommandCount; |
|
4222 } |
|
4223 |
|
4224 // -------------------------------------------------------------------------- |
|
4225 // CPbk2ContactViewCustomListBoxData::CommandItemCount |
|
4226 // -------------------------------------------------------------------------- |
|
4227 // |
|
4228 TInt CPbk2ContactViewCustomListBoxData::CommandItemCount() const |
|
4229 { |
|
4230 // Some of the commands might be disabled. Don't count those. |
|
4231 TInt enabledCommandCount = 0; |
|
4232 if ( iCommandItems ) |
|
4233 { |
|
4234 for ( TInt n = 0; n < iCommandItems->Count(); ++n ) |
|
4235 { |
|
4236 const MPbk2UiControlCmdItem& cmd = *(*iCommandItems)[n]; |
|
4237 if ( cmd.IsEnabled() ) |
|
4238 { |
|
4239 enabledCommandCount++; |
|
4240 } |
|
4241 } |
|
4242 } |
|
4243 return enabledCommandCount; |
|
4244 } |
|
4245 |
|
4246 //End of Code Added for PhoneBook2 |
|
4247 |
|
4248 // End of File |