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